|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component net.sourceforge.webcompmath.draw.Drawable net.sourceforge.webcompmath.draw.Panner
public class Panner
When a Panner object is added to a CoordinateRect, it becomes possible to "grab" the coordinate rectangle and pan it (that is, slide it around by moving it with the mouse). By default, the user must right-click-and-drag to pan the coordinates, but this can be changed by providing an argument to the constructor. It is possible to set a Controller to be notified each time the mouse moves while the user is dragging. Alternatively, or in addition, you can set a Controller to be notified when the user finishes dragging. However, for the most part this is unnecessary, since the Drawables in the CoordinateRect will for the most part redraw themselves properly when the limits on the CoordinateRect change. However, if you have Computable objects that depend on the coordinate limits, then they will need to be recomputed. (This will be the case if you use value objects returned by the getValueObject() method in the CoordinateRect class.)
A Panner, p, is inactive if its "visible" property has been set to false. (This is done by calling p.setVisible(false).)
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class net.sourceforge.webcompmath.draw.Drawable |
---|
canvas, coords |
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 | |
---|---|
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. |
Method Summary | |
---|---|
void |
draw(java.awt.Graphics g,
boolean coordsChanged)
Override the abstract draw() method from the Drawable class. |
int |
getModifiers()
Get the combination of MouseEvent.SHIFT_MASK, MouseEvent.CTRL_MASK, MouseEvent.META_MASK, and MouseEvent.ALT_MASK that must be present in the mouse-pressed event for a drag to start. |
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(java.awt.event.MouseEvent evt)
Responds to a mouse-click. |
void |
mouseDragged(java.awt.event.MouseEvent evt)
Responds to a mouse-drag. |
void |
mouseEntered(java.awt.event.MouseEvent evt)
Responds to a mouse-enter event. |
void |
mouseExited(java.awt.event.MouseEvent evt)
Responds to a mouse-exit event. |
void |
mouseMoved(java.awt.event.MouseEvent evt)
Responds when mouse moves. |
void |
mousePressed(java.awt.event.MouseEvent evt)
Responds to a mouse-press. |
void |
mouseReleased(java.awt.event.MouseEvent evt)
Responds to a mouse-release. |
void |
setModifiers(int modifiers)
Set the combination of MouseEvent.SHIFT_MASK, MouseEvent.CTRL_MASK, MouseEvent.META_MASK, and MouseEvent.ALT_MASK that must be present in the mouse-pressed event for a drag to start. |
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. |
Methods inherited from class net.sourceforge.webcompmath.draw.Drawable |
---|
getVisible, needsRedraw, setVisible |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Panner()
public Panner(int modifierSet)
modifierSet
- 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.)Method Detail |
---|
public void setOnUserAction(Controller c)
c
- the controllerpublic Controller getOnUserAction()
public void setOnFinishDrag(Controller c)
c
- the controllerpublic Controller getOnFinishDrag()
protected void setOwnerData(DisplayCanvas canvas, CoordinateRect coords)
setOwnerData
in class Drawable
canvas
- DisplayCanvas to usecoords
- CoordinateRect to usepublic void draw(java.awt.Graphics g, boolean coordsChanged)
draw
in class Drawable
g
- graphics contextcoordsChanged
- true or falsepublic void mousePressed(java.awt.event.MouseEvent evt)
mousePressed
in interface java.awt.event.MouseListener
evt
- event created when user presses mouse buttonpublic void mouseDragged(java.awt.event.MouseEvent evt)
mouseDragged
in interface java.awt.event.MouseMotionListener
evt
- event created when user drags mousepublic void mouseReleased(java.awt.event.MouseEvent evt)
mouseReleased
in interface java.awt.event.MouseListener
evt
- event created when user releases mouse buttonpublic void mouseClicked(java.awt.event.MouseEvent evt)
mouseClicked
in interface java.awt.event.MouseListener
evt
- the eventpublic void mouseMoved(java.awt.event.MouseEvent evt)
mouseMoved
in interface java.awt.event.MouseMotionListener
evt
- the eventpublic void mouseEntered(java.awt.event.MouseEvent evt)
mouseEntered
in interface java.awt.event.MouseListener
evt
- the eventpublic void mouseExited(java.awt.event.MouseEvent evt)
mouseExited
in interface java.awt.event.MouseListener
evt
- the eventpublic int getModifiers()
public void setModifiers(int modifiers)
modifiers
- the masks for the key combinations
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |