|
||||||||||
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.DraggablePoint
public class DraggablePoint
A DraggablePoint can be added to a DisplayCanvas, where it appears as a small disk, square, or cross. (The visual style is a settable property.) This object can be dragged with the mouse, within the limits of the CoordinateRect that contains the DraggablePoint. Either the x- or y-value of the point can be clamped to a specified Value. Typically, the y-value might be given by some function of the x-value. In that case, the point is constrained to move along the graph of the function. Or the x- or y-value can be clamped to a constant to make the point move along a vertical or horizontal line. Two Variables are associated with the DraggablePoint. These Variables represent the x- and y- values of the point. Each Variable implements the Tieable interface, so it can be synchronized with other Tieable values such as a VariableIput or VariableSlider.
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 | |
---|---|
static int |
CROSS
A style constant that specifies the visual appearance of a DraggablePoint to be a cross. |
static int |
DISK
A style constant that specifies the visual appearance of a DraggablePoint to be a disk. |
static int |
SQUARE
A style constant that specifies the visual appearance of a DraggablePoint to be a square. |
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 | |
---|---|
DraggablePoint()
Create a DraggablePoint with default values for style, radius, color. |
|
DraggablePoint(int style)
Create a DraggablePoint with specified visual style. |
Method Summary | |
---|---|
void |
checkInput()
This method is required by the InputObject interface. |
void |
clampX(double x)
Clamp the x-value of the point to the constant x, so that the point is constrained to a vertical line. |
void |
clampX(Function f)
Clamp the x-value of the point to the function f, so that the point is constrained to move along the graph of x = f(y). |
void |
clampX(Value v)
Clamp the x-value of the point to v. |
void |
clampY(double y)
Clamp the y-value of the point to the constant y, so that the point is constrained to a horizontal line. |
void |
clampY(Function f)
Clamp the y-value of the point to the function f, so that the point is constrained to move along the graph of y = f(x). |
void |
clampY(Value v)
Clamp the y-value of the point to v. |
void |
continueDrag(java.awt.event.MouseEvent evt)
Continue a drag operation begun in startDrag(). |
void |
draw(java.awt.Graphics g,
boolean coordsChanged)
This method, from the Drawable interface, draws the point. |
void |
finishDrag(java.awt.event.MouseEvent evt)
Finish a drag operation begun in startDrag(). |
java.awt.Color |
getColor()
Get the color used for drawing the point. |
java.awt.Color |
getGhostColor()
Get the "ghostColor" of the point. |
Controller |
getOnUserAction()
Get the Controller that is notified when the user drags the point. |
int |
getRadius()
Get the radius used for drawing the point. |
int |
getStyle()
Get the visual style of the point, which must be one of the constants DraggablePoint.DISK, DraggablePoint.SQUARE, or DraggablePoint.CROSS. |
Variable |
getXVar()
Get the variable that represents the current x-value of the point. |
Variable |
getYVar()
Get the variable that represents the current y-value of the point. |
void |
notifyControllerOnChange(Controller c)
Method required by InputObject interface; in this class, it simply calls setOnUserAction(c). |
void |
setColor(java.awt.Color c)
Set the color to be used for drawing the point. |
void |
setGhostColor(java.awt.Color c)
Set the ghoseColor to be used for drawing the point when it location is undefined or is outside the proper limits. |
void |
setLocation(double x,
double y)
Move the point to (x,y), then "clamp" the value of x or y, if a clamp Value has been set. |
void |
setOnUserAction(Controller c)
Set the Controller that is to be notified when the user drags the point. |
void |
setRadius(int r)
Set the radius that determines the size of the point when it is drawn. |
void |
setStyle(int style)
Set the visual style of the point. |
boolean |
startDrag(java.awt.event.MouseEvent evt)
Check whether a mouse click (as specified in the MouseEvent parameter) is a click on this DraggablePoint. |
Methods inherited from class net.sourceforge.webcompmath.draw.Drawable |
---|
getVisible, needsRedraw, setOwnerData, 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 |
Field Detail |
---|
public static final int DISK
public static final int SQUARE
public static final int CROSS
Constructor Detail |
---|
public DraggablePoint()
public DraggablePoint(int style)
style
- One of the style constants DraggablePoint.DISK,
DraggablePoint.SQUARE, or DraggablePoint.CROSS.Method Detail |
---|
public void clampX(Value v)
v
- value to clamp topublic void clampY(Value v)
v
- value to clamp topublic void clampX(double x)
x
- value to clamp topublic void clampY(double y)
y
- value to clamp topublic void clampX(Function f)
f
- function to clamp topublic void clampY(Function f)
f
- function to clamp topublic int getRadius()
public void setRadius(int r)
r
- radiuspublic void setStyle(int style)
style
- DISK, SQUARE, or CROSSpublic int getStyle()
public Variable getXVar()
getXVar
in interface MouseVar
public Variable getYVar()
getYVar
in interface MouseVar
public java.awt.Color getColor()
public void setColor(java.awt.Color c)
c
- point's colorpublic java.awt.Color getGhostColor()
public void setGhostColor(java.awt.Color c)
c
- ghost colorpublic void setOnUserAction(Controller c)
c
- controller to usepublic void notifyControllerOnChange(Controller c)
notifyControllerOnChange
in interface InputObject
c
- controller to notifypublic Controller getOnUserAction()
public void setLocation(double x, double y)
x
- x coord to move toy
- y coord to move topublic void checkInput()
checkInput
in interface InputObject
public void draw(java.awt.Graphics g, boolean coordsChanged)
draw
in class Drawable
g
- graphics contextcoordsChanged
- true or falsepublic boolean startDrag(java.awt.event.MouseEvent evt)
startDrag
in interface Draggable
evt
- event created when user drags mouse
public void continueDrag(java.awt.event.MouseEvent evt)
continueDrag
in interface Draggable
evt
- event created when user drags mousepublic void finishDrag(java.awt.event.MouseEvent evt)
finishDrag
in interface Draggable
evt
- event created when user stops dragging mouse
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |