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.
- Version:
- Sat Dec 14 17:58:30 1996
- Author:
- Lubomir Bourdev, Mark Handy, Ryan Shaun Baker
-
ballPos_
-
-
baseColors_
-
-
bases_
-
-
client_
-
-
closestIndex_
-
-
eventSequence_
-
-
height_
-
-
margin_
-
-
size_
-
-
width_
-
-
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)
-
-
closestBase(Point)
-
Brute force search, because has no assumptions about the bases'
locations.
-
drawBall(Point, Graphics)
-
Draws the ball at the given location.
-
drawBase(Point, Color, Graphics)
-
Draws the base at the given point with the given color.
-
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)
-
squareDistance(Point, Point)
-
Computes the distance between two points, needed by 'closestBase'.
-
timelinePos()
-
-
update(Graphics)
-
Method called by AWT thread at some point after this component
requests a repaint().
width_
protected int width_
height_
protected int height_
margin_
protected int margin_
bases_
protected VectorSequence bases_
baseColors_
protected VectorSequence baseColors_
eventSequence_
protected VectorSequence eventSequence_
size_
protected int size_
ballPos_
protected Point ballPos_
closestIndex_
protected int closestIndex_
client_
protected VisualizationController client_
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
update
public void update(Graphics g)
- Method called by AWT thread at some point after this component
requests a repaint(). Overridden here to remove the drawing of the
background, which causes flickering during mouseDrag() operations.
- Overrides:
- update in class Component
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)
drawBase
protected void drawBase(Point p,
Color c,
Graphics g)
- Draws the base at the given point with the given color.
Optionally override in subclasses.
- Parameters:
- p - position to draw the base at
- c - color of the base
- g - java.awt.Graphics into which to draw
drawBall
protected void drawBall(Point p,
Graphics g)
- Draws the ball at the given location. Assumes XOR mode is set
in Graphics g. Optionally override in subclasses.
- Parameters:
- p - position to draw the ball at
- g - java.awt.Graphics into which to draw
squareDistance
protected int squareDistance(Point p1,
Point p2)
- Computes the distance between two points, needed by 'closestBase'.
Note that squared distance is sufficient, since it is needed for
relative comparisons.
- Returns:
- squared distance between p1 and p2
closestBase
protected int closestBase(Point p)
- Brute force search, because has no assumptions about the bases'
locations. Can be overridden to make it more efficient.
- Returns:
- Index of base closest to the given point p
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