|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object vmm.core.Exhibit vmm.planecurve.PlaneCurve
public abstract class PlaneCurve
A PlaneCurve represents a curve in the xy-plane that is defined by an array of points. Since a null value in that array is interpreted as a break in the curve, the curve can in fact consist of multiple segments.
Field Summary | |
---|---|
protected java.awt.geom.Point2D[] |
movingSquare
|
protected java.awt.geom.Point2D[] |
points
The array of xy-points that define the curve. |
protected java.awt.geom.Point2D[] |
randomSquare
|
Fields inherited from class vmm.core.Exhibit |
---|
decorations, exhibitNeedsRedraw, isMorphing, morphingView, parameters, previousTransform |
Constructor Summary | |
---|---|
PlaneCurve()
|
Method Summary | |
---|---|
protected void |
computeDrawData(View view,
boolean exhibitNeedsRedraw,
Transform previousTransform,
Transform newTransform)
Recompute any cached data in the Exhibit that might have changed since it was computed. |
protected void |
doDraw(java.awt.Graphics2D g,
View view,
Transform transform)
Do the actual drawing of the exhibit. |
java.awt.geom.Point2D[] |
fillRandomSquare(int numPoints)
public Point2D[] fillRandomSquare() puts numPoints random points into a square of edge length 2. |
java.awt.geom.Point2D |
getPoint(int index)
Get one of the points in the point array that defines this curve. |
int |
getPointCount()
Returns the number of points in the Point array for this curve (including any null values). |
java.awt.geom.Point2D[] |
initializeMovingSquare(int numPoints)
initializeMovingSquare(numPoints) Initializes the array MovingSquare[] and its elements only once for each new call of a curve exhibit. |
protected abstract void |
makePoints()
This method should compute the array of points that define the curve. |
protected java.awt.geom.Point2D[] |
moveSquare(int numPoints,
double xm,
double ym,
double ex,
double ey,
double ll)
Point2D[] moveSquare(...) moves the scaled standard random square along the curve. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.awt.geom.Point2D[] points
protected java.awt.geom.Point2D[] randomSquare
protected java.awt.geom.Point2D[] movingSquare
Constructor Detail |
---|
public PlaneCurve()
Method Detail |
---|
protected abstract void makePoints()
points
. This method
is called by the computeDrawData(View, boolean, Transform, Transform)
method.
public int getPointCount()
public java.awt.geom.Point2D getPoint(int index)
index
- the index of the point in the point array. The value must be in the range from 0 to one less than the
value returned by getPointCount()
, or an error of type NullPointerException or ArrayIndexOutOfBoundsError
will occur.
protected void computeDrawData(View view, boolean exhibitNeedsRedraw, Transform previousTransform, Transform newTransform)
Exhibit
computeDrawDataHook
)
by the render
method before it calls doDraw
. Its purpose
is to give the Exhibit a chance to recalculate any data that it needs in order to
draw itself. Not all Exhibits will need to "cache" computed data in this way.
The method in this top-level exhibit class does nothing.
computeDrawData
in class Exhibit
view
- The View that is drawing the Exhibit.exhibitNeedsRedraw
- This parameter is set to "true" if the Exhibit's forceRedraw()
method has been called since the last redraw. If it is true, then presumably the appearance of the Exhibit has
changed, so any cached data should be recomputed.previousTransform
- The Transform object that was used the last time the Exhibit was
drawn. This can be null if the Exhibit is being drawn for the first time.newTransform
- The Transform object that is being used for this drawing of the Exhibit.
Transform objects contain data about the window in the xy-plane where the Exhibit is
being drawn and about the pixel coordinates on the drawing area.
The two Transform objects are provided in case any cached data depends on the xy-window
or on the pixel coordinates. Note that the Transform might have changed even if exhibitNeedsRedraw is false.Exhibit.render(Graphics2D, View, Transform, ArrayList)
,
Exhibit.forceRedraw()
,
Exhibit.doDraw(Graphics2D, View, Transform)
protected void doDraw(java.awt.Graphics2D g, View view, Transform transform)
Exhibit
doDrawHook
)
by render
to draw the Exhibit. The computeDrawData
method is called
by render
before it calls this method, so any cached data should be valid by the time this method
is called. The method in this class does nothing. Subclasses should override this method, unless they provide
some other technique for drawing the Exhibit.
doDraw
in class Exhibit
g
- The graphics context where the Exhibit is being drawn. It has already been cleared
to the background color (assuming that drawing is being done in the usual way, as defined in the
top-level View class).view
- The View that is drawing the Exhibit; this object contains other
information that might be of use, such as the Display, if any, associated with
the View.transform
- Contains information about the rectangular area in the
xy-plane that is being drawn and about the rectangle of pixels in the graphics
context where it is drawn. Note that at least for the top-level View class,
transform.getX() and transform.getY() can be assumed to be zero.Exhibit.render(Graphics2D, View, Transform, ArrayList)
,
Exhibit.computeDrawData(View, boolean, Transform, Transform)
public java.awt.geom.Point2D[] fillRandomSquare(int numPoints)
public java.awt.geom.Point2D[] initializeMovingSquare(int numPoints)
protected java.awt.geom.Point2D[] moveSquare(int numPoints, double xm, double ym, double ex, double ey, double ll)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |