public class Panner extends Drawable implements MouseListener, MouseMotionListener
A Panner, p, is inactive if its "visible" property has been set to false. (This is done by calling p.setVisible(false).)
Constructor and Description |
---|
Panner()
Create a Panner object that will let the user pan the CoordinateRect
that contains the Panner by
right-clicking and dragging (or, on Macintosh, command-clicking).
|
Panner(int modifierSet)
Create a Panner object that will let the user click-and-drag to pan the CoordinateRect
that contains the Panner.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(Graphics g,
boolean coordsChanged)
Override the abstract draw() method from the Drawable class.
|
Controller |
getOnFinishDrag()
Get the Controller that is notified when the user finishs a drag.
|
Controller |
getOnUserAction()
Get the Controller that is notified when the user moves the mouse during a drag.
|
void |
mouseClicked(MouseEvent evt)
Responds to a mouse-click.
|
void |
mouseDragged(MouseEvent evt)
Responds to a mouse-drag.
|
void |
mouseEntered(MouseEvent evt)
Responds to a mouse-enter event.
|
void |
mouseExited(MouseEvent evt)
Responds to a mouse-exit event.
|
void |
mouseMoved(MouseEvent evt)
Responds when mouse moves.
|
void |
mousePressed(MouseEvent evt)
Responds to a mouse-press.
|
void |
mouseReleased(MouseEvent evt)
Responds to a mouse-release.
|
void |
setOnFinishDrag(Controller c)
Set a Controller that will be notified (by calling its compute method) whenever
the user finishes a drag operation.
|
void |
setOnUserAction(Controller c)
Set a Controller that will be notified (by calling its compute method) whenever
the user moves the mouse during a drag.
|
protected void |
setOwnerData(DisplayCanvas canvas,
CoordinateRect coords)
Called when this object is added to a DisplayCanvas.
|
getVisible, needsRedraw, setVisible
public Panner()
public Panner(int modifierSet)
modifiers
- If the value is zero, the user drags the CoordinateRect by clicking without
pressing any modifier keys. Otherwise, the value should be a combination of
one or more of the constants MouseEvent.SHIFT_MASK, MouseEvent.CTRL_MASK,
MouseEvent.META_MASK, and MouseEvent.ALT_MASK, or'ed together. (Remember
that right-clicking sets META_MASK and clicking with a middle mouse button
sets ALT_MASK.)public void setOnUserAction(Controller c)
public Controller getOnUserAction()
public void setOnFinishDrag(Controller c)
public Controller getOnFinishDrag()
protected void setOwnerData(DisplayCanvas canvas, CoordinateRect coords)
setOwnerData
in class Drawable
public void draw(Graphics g, boolean coordsChanged)
draw
in class Drawable
g
- The graphics context in which the Drawble is to be drawn. (The drawing
can change the color in g, but should not permanently change font, painting mode, etc.
Thus, every drawable is responsible for setting the color it wants to use.)coordsChanged
- Indicates whether the CoordinateRect has changed.public void mousePressed(MouseEvent evt)
mousePressed
in interface MouseListener
public void mouseDragged(MouseEvent evt)
mouseDragged
in interface MouseMotionListener
public void mouseReleased(MouseEvent evt)
mouseReleased
in interface MouseListener
public void mouseClicked(MouseEvent evt)
mouseClicked
in interface MouseListener
public void mouseMoved(MouseEvent evt)
mouseMoved
in interface MouseMotionListener
public void mouseEntered(MouseEvent evt)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent evt)
mouseExited
in interface MouseListener