| javax.swing.event.MouseInputAdapter org.geotools.gui.swing.MouseSelectionTracker
MouseSelectionTracker | abstract class MouseSelectionTracker extends MouseInputAdapter (Code) | | Controller which allows the user to select a region of a component. The user must click on a
point in the component, then drag the mouse pointer whilst keeping the button pressed. During
the dragging, the shape which is drawn will normally be a rectangle. Other shapes could always
be used such as, for example, an ellipse. To use this class, it is necessary to create a derived
class which defines the following methods:
This controller should then be registered with one, and only one, component
using the following syntax:
Component component=...
MouseSelectionTracker control=...
component.addMouseListener(control);
since: 2.0 version: $Id: MouseSelectionTracker.java 22482 2006-10-31 02:58:00Z desruisseaux $ author: Martin Desruisseaux |
Constructor Summary | |
public | MouseSelectionTracker() Constructs an object which will allow rectangular regions to be selected using the mouse. |
Method Summary | |
protected Shape | getModel(MouseEvent event) Returns the geometric shape to use for marking the boundaries of a region. | public Shape | getSelectedArea(AffineTransform transform) Returns the geometric shape surrounding the last region to be selected by the user. | public void | mouseDragged(MouseEvent event) Informs this controller that the mouse has been dragged. | public void | mouseMoved(MouseEvent event) Informs this controller that the mouse has been moved but not as a
result of the user selecting a region. | public void | mousePressed(MouseEvent event) Informs this controller that the mouse button has been pressed. | public void | mouseReleased(MouseEvent event) Informs this controller that the mouse button has been released. | abstract protected void | selectionPerformed(int ox, int oy, int px, int py) Method which is automatically called after the user selects a region with the mouse. | public void | setXORColors(Color a, Color b) Specifies the colours to be used for drawing the outline of a box when
the user selects a region. |
MouseSelectionTracker | public MouseSelectionTracker()(Code) | | Constructs an object which will allow rectangular regions to be selected using the mouse.
|
getModel | protected Shape getModel(MouseEvent event)(Code) | | Returns the geometric shape to use for marking the boundaries of a region. This shape is
normally a rectangle but could also be an ellipse, an arrow or even other shapes. The
coordinates of the returned shape will not be taken into account. In fact, these coordinates
will regularly be discarded. Only the class of the returned shape will count (for example,
java.awt.geom.Ellipse2D vs
java.awt.geom.Rectangle2D ) and their parameters
which are not linked to their position (for example, the rounding of a rectangle's
corners).
The shape returned will normally be from a class derived from
RectangularShape ,
but could also be from the
Line2D class. Any other class risks throwing a
ClassCastException when executed.
The default implementation always returns an object
Rectangle .
Parameters: event - Mouse coordinate when the button is pressed. This information can be used bythe derived classes which like to be informed of the position of the mouse beforechosing a geometric shape. Shape from the class {link RectangularShape} or {link Line2D}, or null to indicate that we do not want to make a selection. |
getSelectedArea | public Shape getSelectedArea(AffineTransform transform) throws NoninvertibleTransformException(Code) | | Returns the geometric shape surrounding the last region to be selected by the user. An
optional affine transform can be specified to convert the region selected by the user
into logical coordinates. The class of the shape returned depends on the model returned by
MouseSelectionTracker.getModel :
- If the model is null (which means that this
MouseSelectionTracker object only
draws a line between points), the object returned will belong to the
Line2D class.
- If the model is not null, the object returned can be from the same class (most often
java.awt.geom.Rectangle2D ). There could always be situations where the object
returned is from another class, for example if the affine transform carries out a
rotation.
Parameters: transform - Affine transform which converts logical coordinates into pixel coordinates.It is usually an affine transform which is used in a paint(...) method todraw shapes expressed in logical coordinates. A geometric shape enclosing the last region to be selected by the user, or null if no selection has yet been made. throws: NoninvertibleTransformException - If the affine transform can't be inverted. |
mouseDragged | public void mouseDragged(MouseEvent event)(Code) | | Informs this controller that the mouse has been dragged. The default
implementation uses this to move a corner of the rectangle used to
select the region. The other corner remains fixed at the point
where the mouse was at the moment its button was pressed..
|
mouseMoved | public void mouseMoved(MouseEvent event)(Code) | | Informs this controller that the mouse has been moved but not as a
result of the user selecting a region. The default implementation
signals to the source component that
this is no longer
interested in being informed about mouse movements.
|
mousePressed | public void mousePressed(MouseEvent event) throws ClassCastException(Code) | | Informs this controller that the mouse button has been pressed.
The default implementation retains the mouse coordinate (which will
become one of the corners of the future rectangle to be drawn)
and prepares
this to observe the mouse movements.
throws: ClassCastException - if MouseSelectionTracker.getModel doesn't return a shapefrom the class {link RectangularShape} or {link Line2D}. |
selectionPerformed | abstract protected void selectionPerformed(int ox, int oy, int px, int py)(Code) | | Method which is automatically called after the user selects a region with the mouse.
All coordinates passed in as parameters are expressed in pixels.
Parameters: ox - x coordinate of the mouse when the user pressed the mouse button. Parameters: oy - y coordinate of the mouse when the user pressed the mouse button. Parameters: px - x coordinate of the mouse when the user released the mouse button. Parameters: py - y coordinate of the mouse when the user released the mouse button. |
setXORColors | public void setXORColors(Color a, Color b)(Code) | | Specifies the colours to be used for drawing the outline of a box when
the user selects a region. All
a colours will be replaced
by
b colours and vice versa.
|
|
|