public abstract class MouseSelectionTracker extends MouseInputAdapter
This controller should then be registered with one, and only one, component using the following syntax:
Component component = ... MouseSelectionTracker control = ... component.addMouseListener(control);
Defined in the
|Constructor and Description|
Constructs an object which will allow rectangular regions to be selected using the mouse.
|Modifier and Type||Method and Description|
Returns the geometric shape to use for marking the boundaries of a region.
Returns the geometric shape surrounding the last region to be selected by the user.
Informs this controller that the mouse has been dragged.
Informs this controller that the mouse has been moved but not as a result of the user selecting a region.
Informs this controller that the mouse button has been pressed.
Informs this controller that the mouse button has been released.
Method which is automatically invoked after the user selects a region with the mouse.
Specifies the colors to be used for drawing the outline of a box when the user selects a region.
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
acolors will be replaced by
bcolors and vice versa.
a- The color to be replaced by color b.
b- The color replacing the color a.
protected Shape getModel(MouseEvent event)
Rectangle2D) and their parameters which are not related to their position (for example, the arc size of a rectangle with rounded corners).
The shape returned will usually be an instance of a class derived from
but could also be an instance of the
Line2D class. Any other class risks
ClassCastException when executed.
The default implementation always returns an instance of
event- Mouse coordinate when the button is pressed. This information can be used by subclasses overriding this method if the mouse location is relevant to the choice of a geometric shape.
nullto indicate that we do not want to make a selection.
protected abstract void selectionPerformed(int ox, int oy, int px, int py)
ox- x coordinate of the mouse when the user pressed the mouse button.
oy- y coordinate of the mouse when the user pressed the mouse button.
px- x coordinate of the mouse when the user released the mouse button.
py- y coordinate of the mouse when the user released the mouse button.
public Shape getSelectedArea(AffineTransform transform) throws NoninvertibleTransformException
Line2D(which means that this
MouseSelectionTrackeronly draws a line between points), the object returned will belong to the
Rectangle2D. There could be situations where the returned object is an instance of an another class, for example if the affine transform performs a rotation.
transform- Affine transform which converts logical coordinates into pixel coordinates. This is usually the same transform than the one used for drawing in a
nullif no selection has yet been made.
NoninvertibleTransformException- If the affine transform can't be inverted.
public void mousePressed(MouseEvent event) throws ClassCastException
MouseSelectionTrackerto observe the mouse movements.
event- Contains mouse coordinates where the button has been pressed.
getModel(java.awt.event.MouseEvent)doesn't return a shape from the class
public void mouseDragged(MouseEvent event)
public void mouseReleased(MouseEvent event)
selectionPerformed(int, int, int, int)with the bounds of the selected region as parameters.
public void mouseMoved(MouseEvent event)
MouseSelectionTrackeris no longer interested in being informed about mouse movements.
Copyright © 2009–2017 Geotoolkit.org. All rights reserved.