All Packages Class Hierarchy This Package Previous Next Index
Class jdsltools.visualization.GenericShape
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Canvas
|
+----jdsltools.visualization.GenericShape
- public abstract class GenericShape
- extends Canvas
- implements Timeline, MouseListener, MouseMotionListener
A Timeline that extends a java.awt.Canvas.
Maintains the set of base locations and draws the bases (where "base"
is the graphical dot that represents an "event" in Timeline parlance).
Animates the ball that the user moves with the mouse to change the
current event.
Three methods are abstract. They deal with the particular
shape that the subclass defines.
-
GenericShape()
-
Constructor is empty to support instantiation with
java.lang.Class.newInstance().
-
addEvent(Point, Color, Object)
-
Ditto above, with hint about color in which to draw the base.
-
addEvent(Point, Object)
-
Called to add a new event.
-
addEventScroll(Point, Color, Object, boolean)
-
-
analogousInTree(BinaryTree, BinaryTree, Position)
-
-
analogousPosition(Container, Container, Position)
-
-
ballMoveTo(Point)
-
Moves the ball closest to the given point, but still on the shape.
-
beginOperation()
-
Called to reset the Timeline and
begin a new sequence of events.
-
client()
-
Gives the current client.
-
clipEnd(String, int)
-
-
drawEmpty(Graphics)
-
Do something when there is nothing to do -- i.e., when there are
no events to be drawn.
-
drawShape(Graphics)
-
Draw the shape in the Graphics.
-
endOperation()
-
Called when the current sequence
of events is over.
-
init(int, int, int, VisualizationController)
-
Actual initialization work.
-
isAtBottom()
-
-
mouseClicked(MouseEvent)
-
-
mouseDragged(MouseEvent)
-
-
mouseEntered(MouseEvent)
-
-
mouseExited(MouseEvent)
-
-
mouseMoved(MouseEvent)
-
-
mousePressed(MouseEvent)
-
-
mouseReleased(MouseEvent)
-
-
onShape(Point, boolean)
-
Return a corresponding point on the shape to the parameter point
(probably the closest point).
-
paint(Graphics)
-
-
setClient(TimelineClient)
-
Sets the link to the client.
-
setInfo(String)
-
-
setSize(int, int)
-
Method of Canvas that is called by AWT for layout purposes.
-
setTimelinePos(Point)
-
-
setTimelineToBottom()
-
-
spaint(Graphics)
-
Draws the shape, the bases, and the ball at the last base (if any)
-
timelinePos()
-
GenericShape
public GenericShape()
- Constructor is empty to support instantiation with
java.lang.Class.newInstance(). Initialization done in init(.), which
should be called immediately after construction.
onShape
public abstract Point onShape(Point p,
boolean constrain)
- Return a corresponding point on the shape to the parameter point
(probably the closest point).
- Parameters:
- p - Some point somewhere
- constrain - Whether the returned point should be constrained
to be on the part of the shape between the first base and the last,
as opposed to whether it should be somewhere on the mathematical
curve
- Returns:
- The closest or otherwise corresponding point on the shape
drawShape
public abstract void drawShape(Graphics g)
- Draw the shape in the Graphics.
drawEmpty
public abstract void drawEmpty(Graphics g)
- Do something when there is nothing to do -- i.e., when there are
no events to be drawn.
- Parameters:
- g - Graphics into which to draw a "no events" message
init
public void init(int width,
int height,
int margin,
VisualizationController client)
- Actual initialization work.
- Parameters:
- width - width of canvas
- height - height of canvas
- margin - offset of the shape from the boundary of canvas
setSize
public void setSize(int width,
int height)
- Method of Canvas that is called by AWT for layout purposes.
- Parameters:
- width - New width of Canvas
- height - New height of Canvas
- Overrides:
- setSize in class Component
client
public TimelineClient client()
- Gives the current client.
setClient
public void setClient(TimelineClient client)
- Sets the link to the client.
- Parameters:
- New - client to which this Timeline will report selected events
beginOperation
public void beginOperation()
- Called to reset the Timeline and
begin a new sequence of events.
endOperation
public void endOperation()
- Called when the current sequence
of events is over.
addEvent
public void addEvent(Point locatorPosition,
Object clientData)
- Called to add a new event.
- Parameters:
- locatorPosition - Hint about where on path to place base
- clientData - Object to report to client when corresponding
event is selected
addEvent
public void addEvent(Point locatorPosition,
Color baseColor,
Object clientData)
- Ditto above, with hint about color in which to draw the base.
Subclass should extend this method to add a new base position
to Sequence bases_.
addEventScroll
public void addEventScroll(Point locatorPosition,
Color baseColor,
Object clientData,
boolean scroll)
spaint
public void spaint(Graphics g)
- Draws the shape, the bases, and the ball at the last base (if any)
- Parameters:
- g - java.awt.Graphics into which to draw.
paint
public void paint(Graphics g)
- Overrides:
- paint in class Canvas
ballMoveTo
public void ballMoveTo(Point p)
- Moves the ball closest to the given point, but still on the shape.
Visualizes the container closest to the mouse position.
- Parameters:
- p - coordinates of the point (will be mapped to the shape)
isAtBottom
public boolean isAtBottom()
timelinePos
public Point timelinePos()
setTimelinePos
public void setTimelinePos(Point p)
setTimelineToBottom
public void setTimelineToBottom()
setInfo
public void setInfo(String s)
mouseClicked
public void mouseClicked(MouseEvent e)
mousePressed
public void mousePressed(MouseEvent e)
mouseReleased
public void mouseReleased(MouseEvent e)
mouseEntered
public void mouseEntered(MouseEvent e)
mouseExited
public void mouseExited(MouseEvent e)
mouseDragged
public void mouseDragged(MouseEvent e)
mouseMoved
public void mouseMoved(MouseEvent e)
analogousPosition
public Position analogousPosition(Container initial,
Container duplicate,
Position toanalogize)
analogousInTree
public Position analogousInTree(BinaryTree initial,
BinaryTree duplicate,
Position toanalogize)
clipEnd
public String clipEnd(String s,
int howmuch)
All Packages Class Hierarchy This Package Previous Next Index