net.sourceforge.webcompmath.draw
Class Drawable

java.lang.Object
  extended by java.awt.Component
      extended by net.sourceforge.webcompmath.draw.Drawable
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
DraggablePoint, DrawBorder, DrawGeometric, DrawString, Graph1D, Grid, MouseTracker, Panner, ParametricCurve, RiemannArcLength, RiemannSlice, RiemannSumRects, ScatterPlot, Sequence, TableFunctionGraph, VectorField, WcmAxes, WCMAxisTickBean, WCMIntegralCurveBean

public abstract class Drawable
extends java.awt.Component
implements java.io.Serializable

A Drawable object can be added to a CoordinateRect, which is itself in a DisplayCanvas. Its purpose is, generally, to draw something in the rectangular area represented by the CoordinateRect. The drawing can use information in the CoordinateRect, which includes both the real number coordinates and the pixel coordinates of the rectangular area. The only reason that Drawables extend Component is so that Eclipse VE will allow you to drop them on a DisplayCanvas. No other functionality of Components is used.

See Also:
Serialized Form

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
protected  DisplayCanvas canvas
          The canvas on which this Drawable is drawn.
protected  CoordinateRect coords
          The CoordinateRect for the rectagular area where this Drawable is drawn.
 
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
Drawable()
           
 
Method Summary
abstract  void draw(java.awt.Graphics g, boolean coordsChanged)
          Draw this drawable in the graphics context g.
 boolean getVisible()
          Return true if this Drawable is visible, false if it is hidden.
 void needsRedraw()
          This routine should be called if the appearance of the Drawable changes so that the rectangular area that it occupies has to be redrawn.
protected  void setOwnerData(DisplayCanvas canvas, CoordinateRect coords)
          Sets the values of member variables canvas and coords.
 void setVisible(boolean show)
          Set the visibility of this Drawable.
 
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

coords

protected CoordinateRect coords
The CoordinateRect for the rectagular area where this Drawable is drawn. This is set automatically when the Drawable is added to a CoordingteRect and should not be changed. (It will be changed automatically if the Drawable is removed from the CoordinateRect.)


canvas

protected DisplayCanvas canvas
The canvas on which this Drawable is drawn. This is set automatically when the Drawable is added to a CoordinateRect and it should not be changed. (It will be changed automatically if the Drawable is removed from the CoordinateRect.)

Constructor Detail

Drawable

public Drawable()
Method Detail

draw

public abstract void draw(java.awt.Graphics g,
                          boolean coordsChanged)
Draw this drawable in the graphics context g. This is meant to be called only by the CoordinateRect, coords, that manages this Drawable. The coords contains information about the rectangular area in which this Drawable is displayed, both in terms of pixels and in terms of real (x,y)-coordinates. The value of coordsChanged is true if any of the values coords.getXmin(), coords.getXmax(), coords.getYmin(), coords.getYmax(), coords.getLeft(), coords.getRight(), coords.getTop(), coords.getBottom(), or coords.getGap() has changed. Drawables that depend only on this information can check the value of coordsChanged to see whether they need to update any previously computed member variables that depend on these values. This method is meant to be called only by the system.

Parameters:
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.

getVisible

public boolean getVisible()
Return true if this Drawable is visible, false if it is hidden. A hidden Drawable is ignored by the CoordinateRect that manages it.

Returns:
true or false

setVisible

public void setVisible(boolean show)
Set the visibility of this Drawable. If show is false, then the Drawable is hidden. If it is true, the Drawable is shown.

Overrides:
setVisible in class java.awt.Component
Parameters:
show - true or false

needsRedraw

public void needsRedraw()
This routine should be called if the appearance of the Drawable changes so that the rectangular area that it occupies has to be redrawn. The routine is generally meant to be called by the Drawable itself. It will notify the DisplayCanvas, canvas, that the CoordinateRect, coords, needs to be redrawn, where canvas and coords are the member variables in this class. If canvas is null, nothing happens, since presumably the Drawable is not displayed anywhere in that case.


setOwnerData

protected void setOwnerData(DisplayCanvas canvas,
                            CoordinateRect coords)
Sets the values of member variables canvas and coords. This is designed to be called only by the CoordinateRect class.

Parameters:
canvas - DisplayCanvas to use
coords - CoordinateRect to use