com.nwoods.jgo.instruments
Class AbstractGraduatedScale

java.lang.Object
  extended bycom.nwoods.jgo.JGoObject
      extended bycom.nwoods.jgo.JGoDrawable
          extended bycom.nwoods.jgo.instruments.AbstractGraduatedScale
All Implemented Interfaces:
GraduatedScale, JGoXMLSaveRestore, java.io.Serializable
Direct Known Subclasses:
GraduatedScaleElliptical, GraduatedScaleLinear

public abstract class AbstractGraduatedScale
extends JGoDrawable
implements GraduatedScale

An implementation of the GraduatedScale class, used to depict a scale as a path between two end points, representing a minimum and maximum value, with all the points along that path representing uniformly delineated values.

See Also:
Serialized Form

Field Summary
static int ChangedLabelDistance
          This is a JGoObject update subhint.
static int ChangedLabelFormat
          This is a JGoObject update subhint.
static int ChangedLabelFrequency
          This is a JGoObject update subhint.
static int ChangedLabelStyle
          This is a JGoObject update subhint.
static int ChangedLabelTemplate
          This is a JGoObject update subhint.
static int ChangedMaximum
          This is a JGoObject update subhint.
static int ChangedMinimum
          This is a JGoObject update subhint.
static int ChangedTickBase
          This is a JGoObject update subhint.
static int ChangedTickColor
          This is a JGoObject update subhint.
static int ChangedTickLabels
          This is a JGoObject update subhint.
static int ChangedTickLengthLeft
          This is a JGoObject update subhint.
static int ChangedTickLengthRight
          This is a JGoObject update subhint.
static int ChangedTickMajorFrequency
          This is a JGoObject update subhint.
static int ChangedTickMajorLengthRatio
          This is a JGoObject update subhint.
static int ChangedTickMajorWidth
          This is a JGoObject update subhint.
static int ChangedTickUnit
          This is a JGoObject update subhint.
static int ChangedTickWidth
          This is a JGoObject update subhint.
static int LabelStyleAlternateStartLeft
          A style for the layout of tick labels for AbstractGraduatedScale.
static int LabelStyleAlternateStartRight
          A style for the layout of tick labels for AbstractGraduatedScale.
static int LabelStyleLeft
          A style for the layout of tick labels for AbstractGraduatedScale.
static int LabelStyleRight
          A style for the layout of tick labels for AbstractGraduatedScale.
 
Fields inherited from class com.nwoods.jgo.JGoObject
Bottom, BottomCenter, BottomLeft, BottomMiddle, BottomRight, Center, CenterLeft, CenterRight, Changed4ResizeHandles, ChangedAutoRescale, ChangedBrush, ChangedDraggable, ChangedDragsNode, ChangedGeometry, ChangedGrabChildSelection, ChangedInitializing, ChangedPen, ChangedResizable, ChangedSelectable, ChangedUpdatePartner, ChangedVisible, ChangedZOrder, LastChangedHint, Left, LeftCenter, NoHandle, NoSpot, NumReservedHandles, RepaintAll, Right, RightCenter, SideLeft, SideRight, Top, TopCenter, TopLeft, TopMiddle, TopRight
 
Constructor Summary
protected AbstractGraduatedScale()
          This constructor creates a AbstractGraduatedScale with all default properties, including not being Selectable.
 
Method Summary
 void changeValue(JGoDocumentChangedEdit e, boolean undo)
          Handle undo and redo changes.
protected abstract  void computePath(java.awt.geom.GeneralPath path)
          Determines the main path of the AbstractGraduatedScale.
 void copyNewValueForRedo(JGoDocumentChangedEdit e)
          This method is called when a JGoDocumentChangedEdit is created for a JGoDocumentEvent.CHANGED event, when a JGoObject has been changed.
 JGoObject copyObject(JGoCopyEnvironment env)
          Make sure the JGoText object that is the LabelTemplate is copied.
 void expandRectByPenWidth(java.awt.Rectangle rect)
          The paint bounds needs to include tick marks and labels.
protected  void geometryChange(java.awt.Rectangle old)
          Whenever the size and/or position is changed, we need to recalculate the GeneralPath.
abstract  boolean getIntersectionWithLine(java.awt.geom.Point2D.Float p1, java.awt.geom.Point2D.Float p2, DoubleRef outval)
          Finds the value that corresponds to the point where the scale and the line defined by p1 and p2 intersect.
abstract  java.awt.Point getLabelCenter(double val, boolean drawLeft)
          Returns the point at which the Label should be centered.
 int getLabelDistance()
          Gets the distance at which labels are centered away from the tick mark.
 java.lang.String getLabelFormat()
          Gets the format string for formatting label values.
 int getLabelFrequency()
          Gets how often to label major tick marks.
 java.lang.String getLabelString(double val)
          Returns the text string that a label marking the given value would contain.
 int getLabelStyle()
          Gets the layout style with which the tick labels are drawn.
 JGoText getLabelTemplate()
          Gets the instance of a JGoText that contains the font, size, and other text properties used when drawing labels.
protected  double getLength()
          Gets the length of the scale, in document units.
 double getMaximum()
          Gets the maximum value represented on the AbstractGraduatedScale.
 double getMinimum()
          Gets the minimum value represented on the AbstractGraduatedScale.
static boolean getNearestIntersectionOnLine(float Ax, float Ay, float Bx, float By, float Px, float Py, float Qx, float Qy, java.awt.geom.Point2D.Float R)
           
static boolean getNearestPointOnLine(float Ax, float Ay, float Bx, float By, float Px, float Py, java.awt.geom.Point2D.Float R)
           
 java.awt.geom.GeneralPath getPath()
          Get a cached GeneralPath that is produced by a call to makePath.
abstract  java.awt.geom.Point2D.Float getPointForValue(double v)
          Returns a point that represents the given value.
 double getRange()
          Gets the range of values represented by the AbstractGraduatedScale.
 double getTickBase()
          Gets the base value which is marked with a tick.
 java.awt.Color getTickColor()
          Gets the color used to draw tick marks.
abstract  void getTickEnds(double v, boolean isMajor, java.awt.geom.Point2D.Float outp1, java.awt.geom.Point2D.Float outp2)
          Finds the two end points of the tick mark for a given value.
 float getTickLengthLeft()
          Gets the length that each minor tick is drawn to the left of the AbstractGraduatedScale's path, as seen when drawing from the Minimum value to the Maximum value.
 float getTickLengthRight()
          Gets the length that each minor tick is drawn to the right of the scale's path, as seen when drawing from the Minimum value to the Maximum value.
 int getTickMajorFrequency()
          Gets when to draw emphasized tick marks.
 float getTickMajorLengthRatio()
          Gets the relative length of major tick marks compared to minor ones.
 int getTickMajorWidth()
          Gets the pen width of major tick marks.
 double getTickUnit()
          Gets the difference between two consecutive values marked by minor ticks.
 int getTickWidth()
          Gets the pen width of the tick marks.
abstract  double getValueAtPoint(java.awt.geom.Point2D.Float p)
          Returns the value which would be represented at a given point.
static boolean isDefaultBufferingImage()
          This is true when the appearance of all AbstractGraduatedScales, including labels, may be cached in an image, for painting efficiency.
 boolean isTickLabels()
          Gets whether to draw tick labels at major tick marks.
 java.awt.geom.GeneralPath makePath()
          Make sure that whenever we reconstruct the main GeneralPath for this shape, we also reconstruct the paths for the ticks.
 void paint(java.awt.Graphics2D g, JGoView view)
          Render this object to a Graphics2D object.
 void paintLabel(java.awt.Graphics2D g, JGoView view, java.awt.Point p, java.lang.String text)
          This method is responsible for properly painting a label for the given value parameter.
protected  void resetPath()
          Clear any cached GeneralPath.
static void setDefaultBufferingImage(boolean b)
          Enable more efficient painting by caching an image of the scale, including any labels.
 void setLabelDistance(int value)
          Sets the distance at which labels are centered away from the tick mark.
 void setLabelFormat(java.lang.String value)
          Sets the format string for formatting label values.
 void setLabelFrequency(int value)
          Set how often to label major tick marks.
 void setLabelStyle(int value)
          Sets the layout style with which the tick labels are drawn.
 void setLabelTemplate(JGoText value)
          Sets the instance of a JGoText that contains the font, size, and other text properties used when drawing labels.
 void setMaximum(double value)
          Sets the maximum value represented on the AbstractGraduatedScale.
 void setMinimum(double value)
          Sets the minimum value represented on the AbstractGraduatedScale.
 void setTickBase(double value)
          Sets the base value which is marked with a tick.
 void setTickColor(java.awt.Color value)
          Sets the color used to draw tick marks.
 void setTickLabels(boolean value)
          Sets whether to draw tick labels at major tick marks.
 void setTickLengthLeft(float value)
          Sets the length that each minor tick is drawn to the left of the AbstractGraduatedScale's path, as seen when drawing from the Minimum value to the Maximum value.
 void setTickLengthRight(float value)
          Sets the length that each minor tick is drawn to the right of the scale's path, as seen when drawing from the Minimum value to the Maximum value.
 void setTickMajorFrequency(int value)
          Sets when to draw emphasized tick marks.
 void setTickMajorLengthRatio(float value)
          Sets the relative length of major tick marks compared to minor ones.
 void setTickMajorWidth(int value)
          Sets the pen width of major tick marks.
 void setTickUnit(double value)
          Sets the difference between two consecutive values marked by minor ticks.
 void setTickWidth(int value)
          Sets the pen width of the tick marks.
 DomNode SVGReadObject(DomDoc svgDoc, JGoDocument jGoDoc, DomElement svgElement, DomElement jGoChildElement)
          Read this object in from a DomDoc representing a Scalable Vector Graphics (SVG) XML document.
 void SVGUpdateReference(java.lang.String attr, java.lang.Object referencedObject)
          This method will be called to fill in object references.
 void SVGWriteObject(DomDoc svgDoc, DomElement jGoElementGroup)
          Write this object out to a DomDoc representing a Scalable Vector Graphics (SVG) XML document.
 
Methods inherited from class com.nwoods.jgo.JGoDrawable
draw3DRect, draw3DRect, drawEllipse, drawEllipse, drawEllipse, drawLine, drawLine, drawPath, drawPolygon, drawPolygon, drawRect, drawRect, drawRect, drawRoundRect, drawRoundRect, getBrush, getNearestIntersectionPoint, getPen, setBrush, setPen, SVGAddPathArgs, SVGReadAttributes, SVGWriteAttributes
 
Methods inherited from class com.nwoods.jgo.JGoObject
canView, computeBoundingRect, computeMove, computeResize, copy, copyObjectDelayed, copyOldValueForUndo, copyRect, doMouseClick, doMouseDblClick, doUncapturedMouseMove, findCommonParent, foredate, gainedSelection, geometryChangeChild, getBoundingRect, getDocument, getDraggingObject, getFlags, getHeight, getLayer, getLeft, getLocation, getLocation, getParent, getParentJGoNode, getParentNode, getPartner, getRectangleSpotLocation, getSize, getSize, getSpotLocation, getSpotLocation, getToolTipText, getTop, getTopLeft, getTopLeft, getTopLevelObject, getView, getWidth, growRect, handleMove, handleResize, hideSelectionHandles, is4ResizeHandles, isAutoRescale, isBoundingRectInvalid, isChildOf, isDraggable, isDragsNode, isInitializing, isPointInObj, isResizable, isSelectable, isSkipsUndoManager, isSuspendChildUpdates, isSuspendUpdates, isTopLevel, isUpdatePartner, isVisible, lostSelection, ownerChange, partnerUpdate, pick, redirectSelection, remove, set4ResizeHandles, setAutoRescale, setBoundingRect, setBoundingRect, setBoundingRect, setBoundingRectForce, setBoundingRectForce, setBoundingRectInvalid, setBoundsRect, setDraggable, setDragsNode, setFlags, setHeight, setInitializing, setLeft, setLocation, setLocation, setLocationOffset, setLocationOffset, setParent, setPartner, setRectangleSpotLocation, setResizable, setSelectable, setSize, setSize, setSizeKeepingLocation, setSkipsUndoManager, setSpotLocation, setSpotLocation, setSpotLocation, setSpotLocationOffset, setSuspendChildUpdates, setSuspendUpdates, setTop, setTopLeft, setTopLeft, setUpdatePartner, setVisible, setWidth, showSelectionHandles, spotOpposite, update, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LabelStyleLeft

public static final int LabelStyleLeft
A style for the layout of tick labels for AbstractGraduatedScale.

All ticks are labeled on the end that is left of the AbstractGraduatedScale's path.

See Also:
Constant Field Values

LabelStyleRight

public static final int LabelStyleRight
A style for the layout of tick labels for AbstractGraduatedScale.

All ticks are labeled on the end that is right of the AbstractGraduatedScale's path.

See Also:
Constant Field Values

LabelStyleAlternateStartLeft

public static final int LabelStyleAlternateStartLeft
A style for the layout of tick labels for AbstractGraduatedScale.

Alternates which side of the tick gets labeled. The first label tick is labeled to the left.

See Also:
Constant Field Values

LabelStyleAlternateStartRight

public static final int LabelStyleAlternateStartRight
A style for the layout of tick labels for AbstractGraduatedScale.

Alternates which side of the tick gets labeled. The first label tick is labeled to the right.

See Also:
Constant Field Values

ChangedMaximum

public static final int ChangedMaximum
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedMinimum

public static final int ChangedMinimum
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedTickLengthLeft

public static final int ChangedTickLengthLeft
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedTickLengthRight

public static final int ChangedTickLengthRight
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedTickUnit

public static final int ChangedTickUnit
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedTickBase

public static final int ChangedTickBase
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedTickMajorFrequency

public static final int ChangedTickMajorFrequency
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedTickColor

public static final int ChangedTickColor
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedTickLabels

public static final int ChangedTickLabels
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedLabelStyle

public static final int ChangedLabelStyle
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedLabelFrequency

public static final int ChangedLabelFrequency
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedLabelDistance

public static final int ChangedLabelDistance
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedLabelTemplate

public static final int ChangedLabelTemplate
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedLabelFormat

public static final int ChangedLabelFormat
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedTickMajorLengthRatio

public static final int ChangedTickMajorLengthRatio
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedTickMajorWidth

public static final int ChangedTickMajorWidth
This is a JGoObject update subhint.

See Also:
Constant Field Values

ChangedTickWidth

public static final int ChangedTickWidth
This is a JGoObject update subhint.

See Also:
Constant Field Values
Constructor Detail

AbstractGraduatedScale

protected AbstractGraduatedScale()
This constructor creates a AbstractGraduatedScale with all default properties, including not being Selectable.

Because AbstractGraduatedScale is an abstract class, this constructor is protected instead of public.

Method Detail

copyObject

public JGoObject copyObject(JGoCopyEnvironment env)
Make sure the JGoText object that is the LabelTemplate is copied.

Overrides:
copyObject in class JGoDrawable
Parameters:
env - the environment for the copy operation - keeps track of copied objects.
Returns:
the new AbstractGraduatedScale

getMinimum

public double getMinimum()
Gets the minimum value represented on the AbstractGraduatedScale.

Specified by:
getMinimum in interface GraduatedScale

setMinimum

public void setMinimum(double value)
Sets the minimum value represented on the AbstractGraduatedScale.

Specified by:
setMinimum in interface GraduatedScale
Parameters:
value - This value must be less than the Maximum.

getMaximum

public double getMaximum()
Gets the maximum value represented on the AbstractGraduatedScale.

Specified by:
getMaximum in interface GraduatedScale

setMaximum

public void setMaximum(double value)
Sets the maximum value represented on the AbstractGraduatedScale.

Specified by:
setMaximum in interface GraduatedScale
Parameters:
value - This value must be greater than Minimum.

getRange

public double getRange()
Gets the range of values represented by the AbstractGraduatedScale.

This is just the Maximum minus the Minimum.

Specified by:
getRange in interface GraduatedScale

getTickUnit

public double getTickUnit()
Gets the difference between two consecutive values marked by minor ticks.


setTickUnit

public void setTickUnit(double value)
Sets the difference between two consecutive values marked by minor ticks.

Parameters:
value - The value must be positive.

getTickBase

public double getTickBase()
Gets the base value which is marked with a tick.


setTickBase

public void setTickBase(double value)
Sets the base value which is marked with a tick.

Parameters:
value - a double value, typically the same as the Minimum

getTickColor

public java.awt.Color getTickColor()
Gets the color used to draw tick marks.


setTickColor

public void setTickColor(java.awt.Color value)
Sets the color used to draw tick marks.

Parameters:
value - a non-null Color

getTickWidth

public int getTickWidth()
Gets the pen width of the tick marks.


setTickWidth

public void setTickWidth(int value)
Sets the pen width of the tick marks.

Parameters:
value - an integer value describing the width of the pen

getTickLengthLeft

public float getTickLengthLeft()
Gets the length that each minor tick is drawn to the left of the AbstractGraduatedScale's path, as seen when drawing from the Minimum value to the Maximum value.


setTickLengthLeft

public void setTickLengthLeft(float value)
Sets the length that each minor tick is drawn to the left of the AbstractGraduatedScale's path, as seen when drawing from the Minimum value to the Maximum value.

Parameters:
value - a positive float value in document coordinates

getTickLengthRight

public float getTickLengthRight()
Gets the length that each minor tick is drawn to the right of the scale's path, as seen when drawing from the Minimum value to the Maximum value.


setTickLengthRight

public void setTickLengthRight(float value)
Sets the length that each minor tick is drawn to the right of the scale's path, as seen when drawing from the Minimum value to the Maximum value.

Parameters:
value - a positive float value in document coordinates

getTickMajorFrequency

public int getTickMajorFrequency()
Gets when to draw emphasized tick marks.

A tick mark will be drawn as a major tick mark every TickMajorFrequency ticks. This defaults to 10.


setTickMajorFrequency

public void setTickMajorFrequency(int value)
Sets when to draw emphasized tick marks.

A tick mark will be drawn as a major tick mark every TickMajorFrequency ticks. If this equals 1, then only major tick marks will be drawn.

Parameters:
value - The value must be positive.

getTickMajorWidth

public int getTickMajorWidth()
Gets the pen width of major tick marks.

This defaults to 2.


setTickMajorWidth

public void setTickMajorWidth(int value)
Sets the pen width of major tick marks.

Parameters:
value - a positive integer value describing the width of the pen

getTickMajorLengthRatio

public float getTickMajorLengthRatio()
Gets the relative length of major tick marks compared to minor ones.

This defaults to 2.


setTickMajorLengthRatio

public void setTickMajorLengthRatio(float value)
Sets the relative length of major tick marks compared to minor ones.

Parameters:
value - this ratio must be non-negative.

isTickLabels

public boolean isTickLabels()
Gets whether to draw tick labels at major tick marks.

The default value is true.


setTickLabels

public void setTickLabels(boolean value)
Sets whether to draw tick labels at major tick marks.


getLabelStyle

public int getLabelStyle()
Gets the layout style with which the tick labels are drawn.


setLabelStyle

public void setLabelStyle(int value)
Sets the layout style with which the tick labels are drawn.

Parameters:
value - one of: LabelStyleLeft, LabelStyleRight, LabelStyleAlternateStartLeft, or LabelStyleAlternateStartRight

getLabelFrequency

public int getLabelFrequency()
Gets how often to label major tick marks.

The default value is 1, to label every major tick mark.


setLabelFrequency

public void setLabelFrequency(int value)
Set how often to label major tick marks.

Parameters:
value - the value must be non-negative

getLabelDistance

public int getLabelDistance()
Gets the distance at which labels are centered away from the tick mark.


setLabelDistance

public void setLabelDistance(int value)
Sets the distance at which labels are centered away from the tick mark.

Parameters:
value - a distance in document coordinates, possibly negative.

getLabelFormat

public java.lang.String getLabelFormat()
Gets the format string for formatting label values.

The default value is "{0,number}".


setLabelFormat

public void setLabelFormat(java.lang.String value)
Sets the format string for formatting label values.

Parameters:
value - a format string, with directives in curly braces.

getLabelTemplate

public JGoText getLabelTemplate()
Gets the instance of a JGoText that contains the font, size, and other text properties used when drawing labels.

This JGoText object must not be part of any JGoArea or any JGoLayer; it is just used as a template for drawing labels.


setLabelTemplate

public void setLabelTemplate(JGoText value)
Sets the instance of a JGoText that contains the font, size, and other text properties used when drawing labels.

This JGoText object must not be part of any JGoArea or any JGoLayer; it is just used as a template for drawing labels.


getIntersectionWithLine

public abstract boolean getIntersectionWithLine(java.awt.geom.Point2D.Float p1,
                                                java.awt.geom.Point2D.Float p2,
                                                DoubleRef outval)
Finds the value that corresponds to the point where the scale and the line defined by p1 and p2 intersect.

Specified by:
getIntersectionWithLine in interface GraduatedScale
Parameters:
p1 - a Point2D.Float in document coordinates
p2 - a Point2D.Float in document coordinates
outval - a DoubleRef that is modified to hold the double value of the scale at the intersection point
Returns:
true if there is an intersection and if outval holds the corresponding double value

getValueAtPoint

public abstract double getValueAtPoint(java.awt.geom.Point2D.Float p)
Returns the value which would be represented at a given point.

Specified by:
getValueAtPoint in interface GraduatedScale
Parameters:
p - a Point2D.Float in document coordinates
Returns:
the corresponding double-precision floating point value

getPointForValue

public abstract java.awt.geom.Point2D.Float getPointForValue(double v)
Returns a point that represents the given value.

Specified by:
getPointForValue in interface GraduatedScale
Parameters:
v - a double-precision floating point number
Returns:
a Point2D.Float in document coordinates

getTickEnds

public abstract void getTickEnds(double v,
                                 boolean isMajor,
                                 java.awt.geom.Point2D.Float outp1,
                                 java.awt.geom.Point2D.Float outp2)
Finds the two end points of the tick mark for a given value. Outputs the end points as the two parameters p1 and p2.

Parameters:
v - the double-precision floating point value that the tick mark would represent
isMajor - whether to find the end points for a major or a minor tick mark
outp1 - a Point2D.Float that is modified with one end point
outp2 - a Point2D.Float that is modified with the other end point

getLabelString

public java.lang.String getLabelString(double val)
Returns the text string that a label marking the given value would contain.

Default behavior returns the string produced by formatting the value using MessageFormat and the getLabelFormat() format string.

Parameters:
val - the double value to display
Returns:
the string to be drawn

getLabelCenter

public abstract java.awt.Point getLabelCenter(double val,
                                              boolean drawLeft)
Returns the point at which the Label should be centered.

Parameters:
val - the double-float value that is being labeled
drawLeft - whether to position the label on the left or the right side of the path from minimum to maximum
Returns:
a Point in document coordinates

paintLabel

public void paintLabel(java.awt.Graphics2D g,
                       JGoView view,
                       java.awt.Point p,
                       java.lang.String text)
This method is responsible for properly painting a label for the given value parameter.

Parameters:
g - a Graphics2D
view - a JGoView
p - a Point in document coordinates
text - the text string, produced by getLabelString()

paint

public void paint(java.awt.Graphics2D g,
                  JGoView view)
Render this object to a Graphics2D object.

This draws the main path and all the tick marks and labels. If the tick marks would be too close to each other, the minor tick marks, and possibly even the major tick marks, are not drawn.

If AbstractGraduatedScale.isDefaultBufferingImage() is true, and if the JGoView's getScale() == 1, then this method caches an image of the whole scale, including labels, and paints that instead of painting all of the lines, tick marks and labels each time.

Overrides:
paint in class JGoObject
Parameters:
g - the graphics context on which to draw
view - the view we're drawing in

computePath

protected abstract void computePath(java.awt.geom.GeneralPath path)
Determines the main path of the AbstractGraduatedScale. Does not include tick marks.

The abstract implementation does nothing.

Parameters:
path - a GeneralPath to be modified

getPath

public java.awt.geom.GeneralPath getPath()
Get a cached GeneralPath that is produced by a call to makePath.


resetPath

protected void resetPath()
Clear any cached GeneralPath.


makePath

public java.awt.geom.GeneralPath makePath()
Make sure that whenever we reconstruct the main GeneralPath for this shape, we also reconstruct the paths for the ticks.

This calls both computePath and an internal method for computing and remembering tick marks.

Returns:
a GeneralPath with the main path for this drawable shape

expandRectByPenWidth

public void expandRectByPenWidth(java.awt.Rectangle rect)
The paint bounds needs to include tick marks and labels.

Overrides:
expandRectByPenWidth in class JGoDrawable
Parameters:
rect - the Rectangle that is grown to cover the tick marks and labels

geometryChange

protected void geometryChange(java.awt.Rectangle old)
Whenever the size and/or position is changed, we need to recalculate the GeneralPath.

Overrides:
geometryChange in class JGoObject

getLength

protected double getLength()
Gets the length of the scale, in document units.

By default this is just the distance between the points on the scale for the minimum and maximum values.


getNearestPointOnLine

public static boolean getNearestPointOnLine(float Ax,
                                            float Ay,
                                            float Bx,
                                            float By,
                                            float Px,
                                            float Py,
                                            java.awt.geom.Point2D.Float R)

getNearestIntersectionOnLine

public static boolean getNearestIntersectionOnLine(float Ax,
                                                   float Ay,
                                                   float Bx,
                                                   float By,
                                                   float Px,
                                                   float Py,
                                                   float Qx,
                                                   float Qy,
                                                   java.awt.geom.Point2D.Float R)

copyNewValueForRedo

public void copyNewValueForRedo(JGoDocumentChangedEdit e)
Description copied from class: JGoObject
This method is called when a JGoDocumentChangedEdit is created for a JGoDocumentEvent.CHANGED event, when a JGoObject has been changed. In order for the JGoDocumentChangedEdit to be able to perform a redo, it needs to remember the new property value or state. However, the JGoObject.update method does not provide such a new value. The value must be taken from this object and copied into the JGoDocumentChangedEdit by calling setNewValue and/or setNewValueInt.

Just as the previous/old value/state information is stored as one or both of an integer and an Object, the new value/state information may be stored as either or both of an integer or an Object.

The responsibility for copying rests with the document event listener rather than the code calling JGoObject.update for efficiency when there is no undo/redo manager.

Overrides:
copyNewValueForRedo in class JGoDrawable

changeValue

public void changeValue(JGoDocumentChangedEdit e,
                        boolean undo)
Handle undo and redo changes.

Overrides:
changeValue in class JGoDrawable
Parameters:
e -
undo -

SVGWriteObject

public void SVGWriteObject(DomDoc svgDoc,
                           DomElement jGoElementGroup)
Description copied from interface: JGoXMLSaveRestore
Write this object out to a DomDoc representing a Scalable Vector Graphics (SVG) XML document.

This method will be called by com.nwoods.jgo.svg.DefaultDocument.SVGWriteDoc() for every JGoObject contained within a JGoDocument. The following example uses a JGoRectangle to illustrate the format of a generated SVG JGoObject:

<g>
<JGoClass class="com.nwoods.jgo.JGoRectangle"\>
<rect height="75" style="stroke:black;stroke-width:1;fill:rgb(255,0,0);" width="75" x="65" y="71"/>
<JGoClass class="com.nwoods.jgo.JGoDrawable" drawablebrush="jgoid1" drawablepen="jgoid2" embeddedpenbrush="false"/>
<JGoClass class="com.nwoods.jgo.JGoObject" obj_flags="1054"/>
</g>

Note that the entire JGoObject is enclosed in a group (<g>). Each subclass of the JGoObject is described by a <JGoClass> element, starting with the most specific class and moving to the more general. Each <JGoClass> element has a "class" attribute which defines the class name. Each <JGoClass> element may also have several other attributes which uniquely describe that state of that class. Following the <JGoClass> element, each class may also genereate any other elements that are required, including representations of contained objects and standard SVG elements such as the <rect> element shown in the above example. The generation of SVG elements in the output makes it possible for the output to be read by SVG viewers and other SVG aware applications. The information contained in the <JGoClass> elements allows us to accurately save and restore all the information in a particular JGoObject subclass.

If this class contains a reference to another object, call DomDoc.registerReferencingNode() to register that reference. This will cause the element representing the referenced object to be identified with a unique id attribute, and cause the element representing the referring object to have a user defined attribute containing a reference to that id. See DomDoc.registerReferencingNode() for more information.

Typically, an implementation of this method will generate a <JGoClass> element using the DomDoc.createJGoClassElement() method, adding whatever attributes are necessary to describe the class. It will then call its superclass so that the superclass can add its own <JGoClass> element and other information to jGoElementGroup within the DomDoc.

Refer to com.nwoods.jgo.examples.flower.ActivityNode.SVGWriteObject() and com.nwoods.jgo.examples.SimpleNode.SVGWriteObject() for examples using this method.

Refer to the file com.nwoods.jgo.svg\xsvg.dtd for a formal description of JGo extensions to the SVG document type.

Specified by:
SVGWriteObject in interface JGoXMLSaveRestore
Overrides:
SVGWriteObject in class JGoDrawable

SVGReadObject

public DomNode SVGReadObject(DomDoc svgDoc,
                             JGoDocument jGoDoc,
                             DomElement svgElement,
                             DomElement jGoChildElement)
Description copied from interface: JGoXMLSaveRestore
Read this object in from a DomDoc representing a Scalable Vector Graphics (SVG) XML document.

This method will be called by com.nwoods.jgo.svg.DefaultDocument.SVGReadDoc() for every <JGoClass> element encountered in a DomDoc. First, an object of the type specified by the class attribute will be created and then the SVGReadObject() method will be called on that newly created object. Refer to SVGWriteObject() for a description of the expected format of the SVG document.

This method may also be called by com.nwoods.jgo.svg.DefaultDocument.SVGReadDoc() when reading any SVG document, including those not generated by JGo and therefore not containing any <JGoClass> elements. In such cases, the DefaultDocument.SVGReadElement() method may be subclassed to examine the SVG element and cause the appropriate JGoObject to be created to represent that element and call SVGReadObject() on that newly created object. By default, standard JGoObjects such as JGoRectangles, JGoStrokes, etc will be created to represent these objects.

If this class contains a reference to another object, call DomDoc.registerReferencingObject() to register that reference. This will cause the JGoObject.SVGUpdateReference() to be called on the referencing object after all the objects have been created, passing in the object befing referenced. See DomDoc.registerReferencingObject() for more information.

Typically, an implementation of this method starts by verifying that the element being read is a <JGoClass> element (which will be true if jGoChildElement is not null). This will always be true unless you have subclassed the DefaultDocument.SVGReadElement() method as described above. It will then read the expected attributes of the <JGoClass> element (as written by SVGReadObject()), call SVGReadObject() on its superclass, and finally return the next element by calling svgElement.getNextSibling().

Refer to com.nwoods.jgo.examples.flower.ActivityNode.SVGReadObject() and com.nwoods.jgo.examples.SimpleNode.SVGReadObject() for examples using this method.

Specified by:
SVGReadObject in interface JGoXMLSaveRestore
Overrides:
SVGReadObject in class JGoDrawable

SVGUpdateReference

public void SVGUpdateReference(java.lang.String attr,
                               java.lang.Object referencedObject)
Description copied from class: JGoObject
This method will be called to fill in object references.

This is called by com.nwoods.jgo.svg.DefaultDocument.SVGReadDoc() after all the objects have been created and if DomDoc.registerReferencingObject() has been previously called by SVGReadObject().

Typically, an implementation of this method will first call the superclass and then fill in the appropriate object reference based on the attr argument.

Refer to com.nwoods.jgo.examples.SimpleNode.SVGWriteObject() for an example using this method.

Overrides:
SVGUpdateReference in class JGoDrawable

isDefaultBufferingImage

public static boolean isDefaultBufferingImage()
This is true when the appearance of all AbstractGraduatedScales, including labels, may be cached in an image, for painting efficiency. By default this value is true.


setDefaultBufferingImage

public static void setDefaultBufferingImage(boolean b)
Enable more efficient painting by caching an image of the scale, including any labels. A true value may cause each AbstractGraduatedScale to consume significantly more memory than when this value is false. A true value may also consume more CPU time to reconstruct the image if any of the properties of this AbstractGraduatedScale change frequently, including bounding rectangle, minimum and maximum values, tick properties, and label properties.