|
FreeHEP API Version current |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JPanel org.freehep.swing.graphics.GraphicalSelectionPanel org.freehep.swing.graphics.AbstractRegionSelectionPanel
This abstract class defines the majority of the functionality needed to make selections of arbitrary parallelogram regions on the screen.
Nested Class Summary |
Nested classes inherited from class javax.swing.JPanel |
JPanel.AccessibleJPanel |
Nested classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
Nested classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
protected int |
activeCtrlPt
Which control point is the active one, or which one can be controlled from the arrow keys on the keyboard? |
protected static int |
ctrlPtSize
The size of the control point boxes. |
protected int |
hitThreshold
The maximum distance from a control point the cursor can be and still be selected. |
protected Rectangle |
lastDrawnRect
The bounding rectangle of the last box which was drawn. |
protected boolean |
lastDrawnRectValid
Flag indicating whether or not the last drawn rectangle is valid. |
protected int |
nCtrlPts
The number of control points for this component. |
static int |
NO_CONTROL_POINT
A constant which flags that no control point was near the mouse-pressed event. |
protected Rectangle |
rectToDraw
The bounding rectangle of the next box to be drawn. |
protected Rectangle |
updateRect
The bounding box of the region to repaint, usually the union of the rectToDraw and lastDrawnRect rectangles. |
protected boolean |
visible
Flag indicating whether or not the selection box is visible. |
protected boolean |
visibleGuides
Flag indicating whether or not additional guide lines should be visible. |
protected int[] |
xCtrlPts
The x-coordinates of the control points. |
protected int[] |
yCtrlPts
The y-coordinates of the control points. |
Fields inherited from class org.freehep.swing.graphics.GraphicalSelectionPanel |
actionMap, defaultModeAction, nextAction, previousAction, selectionActions, thickStroke, thinStroke |
Fields inherited from class javax.swing.JComponent |
accessibleContext, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
AbstractRegionSelectionPanel()
This constructor makes a new AbstractRegionSelectionPanel. |
Method Summary | |
static Cursor |
compassCursor(String type,
int dx,
int dy,
int n,
boolean diagonal)
returns the appropriate cursor for any of the compass points. |
int |
forceXCoordinateWithinBounds(int x)
A utility method which forces the x-coordinate to be within the component boundries. |
int |
forceYCoordinateWithinBounds(int y)
A utility method which forces the y-coordinate to be within the component boundries. |
Cursor |
getControlPointCursor(int index)
Returns the Cursor to be displayed for a certain control point and the default cursor for this SelectionPanel for an index of NO_CONTROL_POINT. |
abstract int |
getNumberOfControlPoints()
Useful subclasses must define the number of control points on the selected region. |
boolean |
getVisibleGuides()
Get whether or not the guides are visible. |
abstract void |
initializeControlPoints(int x,
int y)
Initialize the control points. |
abstract boolean |
isValidSelection()
This returns whether the current selected region is valid. |
void |
keyReleased(KeyEvent e)
Process key-released events. |
abstract AffineTransform |
makeAffineTransform()
Make the affine transform which corresponds to this rectangular selection. |
Polygon |
makeOutlinePolygon()
Make the outline of the selection. |
protected void |
makeSelectionEvent(int actionCode)
A utility function which creates an appropriate selection event when the user accepts the current selection. |
protected AffineTransform |
makeTransform(double x0,
double y0,
double x1,
double y1,
double x2,
double y2)
A utility which makes an AffineTransform given three corner points. |
void |
mouseDragged(MouseEvent e)
Invoked when a mouse button is pressed on a component and then dragged. |
void |
mouseMoved(MouseEvent e)
Changes the active control point according to mouse movements |
void |
mousePressed(MouseEvent e)
Handle the mousePressed events. |
void |
mouseReleased(MouseEvent e)
Invoked when a mouse button has been released on a component. |
protected void |
moveActiveControlPoint(int dx,
int dy)
A utility method which moves the currently active control point by the given delta-x and delta-y. |
protected int |
nearWhichControlPoint(int x,
int y,
int maxDist)
Check to see if the point (x,y) is near one of the control points. |
void |
paintComponent(Graphics g)
Repaint this component. |
protected void |
repaintPanel()
Repaint the panel. |
void |
resetSelection()
Make the selection box invisible. |
void |
setVisibleGuides(boolean visibleGuides)
Determine whether or not to display guide lines. |
abstract void |
updateActiveControlPoint(int x,
int y)
Change the active control point to the point (x,y). |
Methods inherited from class org.freehep.swing.graphics.GraphicalSelectionPanel |
addActionEntry, addActionEntry, addGraphicalSelectionListener, cancelPopupProcessing, fireGraphicalSelectionMade, getBorder, getPopupMenu, isProcessingPopup, keyPressed, keyTyped, mouseClicked, mouseEntered, mouseExited, removeGraphicalSelectionListener, setBorder, setBounds, setSelectionActionsEnabled, testPopupTrigger |
Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int NO_CONTROL_POINT
protected boolean visibleGuides
protected Rectangle rectToDraw
protected Rectangle lastDrawnRect
protected Rectangle updateRect
protected boolean visible
protected boolean lastDrawnRectValid
protected int hitThreshold
protected static int ctrlPtSize
protected int nCtrlPts
protected int activeCtrlPt
protected int[] xCtrlPts
protected int[] yCtrlPts
Constructor Detail |
public AbstractRegionSelectionPanel()
Method Detail |
public void setVisibleGuides(boolean visibleGuides)
public boolean getVisibleGuides()
public void keyReleased(KeyEvent e)
arrow keys: move the active control point in the specified direction. backspace key: reset selection region (make invisible). delete key: reset selection region (make invisible). escape key: leave selection mode (make component invisible). tab key: next selection mode (make next component visible). enter key: accept selection region (send off region selected event) spacebar: accept selection region (send off region selected event)
keyReleased
in interface KeyListener
keyReleased
in class GraphicalSelectionPanel
e
- KeyEvent describing the key which has been releasedprotected void makeSelectionEvent(int actionCode)
makeSelectionEvent
in class GraphicalSelectionPanel
public void mouseMoved(MouseEvent e)
mouseMoved
in interface MouseMotionListener
mouseMoved
in class GraphicalSelectionPanel
e
- MouseEvent describing actionpublic void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
mousePressed
in class GraphicalSelectionPanel
e
- MouseEvent describing actionpublic int forceXCoordinateWithinBounds(int x)
x
- x-coordinate to force within boundries
public int forceYCoordinateWithinBounds(int y)
y
- y-coordinate to force within boundries
public void mouseDragged(MouseEvent e)
GraphicalSelectionPanel
mouseDragged
in interface MouseMotionListener
mouseDragged
in class GraphicalSelectionPanel
e
- MouseEvent describing actionpublic void mouseReleased(MouseEvent e)
GraphicalSelectionPanel
mouseReleased
in interface MouseListener
mouseReleased
in class GraphicalSelectionPanel
e
- MouseEvent describing actionpublic abstract boolean isValidSelection()
protected void moveActiveControlPoint(int dx, int dy)
dx
- the distance to move the x-coordinatedy
- the distance to move the y-coordinateprotected int nearWhichControlPoint(int x, int y, int maxDist)
x
- x-coordinate to compare to control pointsy
- y-coordinate to compare to control pointsmaxDist
- the maximum distance from a control point which
still selects it
public void resetSelection()
resetSelection
in class GraphicalSelectionPanel
protected void repaintPanel()
public abstract void initializeControlPoints(int x, int y)
x
- x-coordinate of initial mouse-pressed eventy
- y-coordinate of initial mouse-pressed eventpublic abstract void updateActiveControlPoint(int x, int y)
x
- x-coordinate of the new pointy
- y-coordinate of the new pointpublic abstract int getNumberOfControlPoints()
public Cursor getControlPointCursor(int index)
public void paintComponent(Graphics g)
g
- Graphics context in which to drawpublic Polygon makeOutlinePolygon()
public abstract AffineTransform makeAffineTransform()
protected AffineTransform makeTransform(double x0, double y0, double x1, double y1, double x2, double y2)
public static Cursor compassCursor(String type, int dx, int dy, int n, boolean diagonal)
type
- type of cursor (Resize/Rotation)dx
- screen x of directiondy
- screen y of direction (positive is down)n
- number of compass points (4 or 8)diagonal
- in case n = 4, a diagonal compass point is returned
|
FreeHEP API Version current |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |