Class Ruler
java.lang.Object
org.opensourcephysics.cabrillo.tracker.Ruler
- Direct Known Subclasses:
AngleRuler,WorldRuler
This draws ruled lines and labels for a protractor.
- Author:
- Douglas Brown
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected BasicStroke[]protected Color[]protected static final float[]protected BasicStrokeprotected static final intprotected static final intprotected static final intprotected DecimalFormatprotected org.opensourcephysics.cabrillo.tracker.Ruler.Handleprotected booleanprotected intprotected intprotected ArrayList<org.opensourcephysics.cabrillo.tracker.Ruler.Label>protected AffineTransformprotected intprotected static final doubleprotected static final intprotected static final intprotected static final doubleprotected org.opensourcephysics.cabrillo.tracker.MultiShape[]protected static final intprotected doubleprotected Doubleprotected doubleprotected intprotected doubleprotected doubleprotected BasicStroke[]protected InputTrackprotected AffineTransformprotected TPointprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected InteractivefindInteractive(TrackerPanel trackerPanel, Rectangle hitRect) Returns the Handle if this Ruler's hit shape intersects the supplied Rectangle.intgetAlpha()Gets the alpha.getColor()Gets the color.getFormattedValue(double value, double min) Formats the specified value.org.opensourcephysics.cabrillo.tracker.Ruler.HandleGets the handle, used to adjust the ruler sizedoubleGets the ruler line spacing.protected abstract MarkgetMark(TrackerPanel trackerPanel, int n) Gets the mark to draw for a given frame.doubleGets the ruler size--width for tapes, radius for protractors.protected doubleGets the perpendicular screen distance from a Point to the tape or protractor base line.floatGets the stroke width.protected booleanDetermines if a TPoint p is to the left of the line defined by end1 and end2.booleanGets the visibility of the ruler.voidRefreshes the strokes.voidsetAlpha(int alpha) Sets the alpha.voidSets the color.protected voidsetHandleXY(double x, double y) Set the handle position in image units.protected voidsetHitShapeVisible(boolean vis) Sets the visibility of the hit shapevoidsetLineSpacing(double space) Sets the ruler line spacing.voidsetRulerSize(double size) Sets the ruler size.voidsetStrokeWidth(float width) Sets the stroke width.voidsetVisible(boolean isVisible) Sets the visibility of the ruler.
-
Field Details
-
DASHED_LINE
protected static final float[] DASHED_LINE -
MAX_RULER_SIZE
protected static final int MAX_RULER_SIZE- See Also:
-
DEFAULT_RULER_SIZE
protected static final int DEFAULT_RULER_SIZE- See Also:
-
MAX_RULER_LINE_SPACING
protected static final double MAX_RULER_LINE_SPACING- See Also:
-
MIN_RULER_LINE_SPACING
protected static final double MIN_RULER_LINE_SPACING- See Also:
-
NUMBER_OF_LEVELS
protected static final int NUMBER_OF_LEVELS- See Also:
-
MIN_INSET_PER_LEVEL
protected static final int MIN_INSET_PER_LEVEL- See Also:
-
DEFAULT_LABEL_GAP
protected static final int DEFAULT_LABEL_GAP- See Also:
-
DEFAULT_LINE_GAP
protected static final int DEFAULT_LINE_GAP- See Also:
-
track
-
baseStrokes
-
strokes
-
dashedStroke
-
colors
-
alpha
protected int alpha -
lines
-
multiShapes
protected org.opensourcephysics.cabrillo.tracker.MultiShape[] multiShapes -
labelMarks
-
handle
protected org.opensourcephysics.cabrillo.tracker.Ruler.Handle handle -
utilityPoint
-
visible
protected boolean visible -
hitShapeVisible
protected boolean hitShapeVisible -
rulerSize
protected double rulerSize -
rulerLineSpacing
protected double rulerLineSpacing -
insetPerLevel
protected int insetPerLevel -
labelGap
protected int labelGap -
lineGap
protected int lineGap -
transform
-
labelTransform
-
format
-
previousDistFromLineEnd
-
previousLineSpacing
protected double previousLineSpacing -
previousAngle
protected double previousAngle -
prevSigFigs
protected int prevSigFigs
-
-
Constructor Details
-
Ruler
Constructor.- Parameters:
track- a TapeMeasure or Protractor
-
-
Method Details
-
getMark
Gets the mark to draw for a given frame.- Parameters:
trackerPanel- the TrackerPanel to draw onn- the frame number- Returns:
- the Mark
-
findInteractive
Returns the Handle if this Ruler's hit shape intersects the supplied Rectangle.- Parameters:
trackerPanel- the TrackerPanelhitRect- the Rectangle- Returns:
- the Handle if hit
-
setHandleXY
protected void setHandleXY(double x, double y) Set the handle position in image units.- Parameters:
x-y-
-
getHandle
public org.opensourcephysics.cabrillo.tracker.Ruler.Handle getHandle()Gets the handle, used to adjust the ruler size- Returns:
- the Handle TPoint
-
setHitShapeVisible
protected void setHitShapeVisible(boolean vis) Sets the visibility of the hit shape- Parameters:
vis- true to draw the hit shape
-
setStrokeWidth
public void setStrokeWidth(float width) Sets the stroke width.- Parameters:
width- the desired width
-
getStrokeWidth
public float getStrokeWidth()Gets the stroke width.- Returns:
- the width
-
refreshStrokes
public void refreshStrokes()Refreshes the strokes. -
setRulerSize
public void setRulerSize(double size) Sets the ruler size. May be positive or negative.- Parameters:
size- the desired size
-
getRulerSize
public double getRulerSize()Gets the ruler size--width for tapes, radius for protractors.- Returns:
- the size
-
setLineSpacing
public void setLineSpacing(double space) Sets the ruler line spacing. The line spacing is the minimum allowed screen distance between ruler lines--the actual spacing depends on the scale.- Parameters:
space- the desired spacing
-
getLineSpacing
public double getLineSpacing()Gets the ruler line spacing.- Returns:
- the spacing
-
getColor
Gets the color.- Returns:
- the line color
-
setColor
Sets the color.- Parameters:
color- the desired line color
-
getAlpha
public int getAlpha()Gets the alpha.- Returns:
- the line color alpha
-
setAlpha
public void setAlpha(int alpha) Sets the alpha.- Parameters:
alpha- the desired alpha
-
setVisible
public void setVisible(boolean isVisible) Sets the visibility of the ruler.- Parameters:
isVisible- true to draw this ruler
-
isVisible
public boolean isVisible()Gets the visibility of the ruler.- Returns:
- true if visible
-
getFormattedValue
Formats the specified value.- Parameters:
value- the value to formatmin- the smallest value expected, used to determine format pattern- Returns:
- the formatted value string
-
getScreenDistanceToBase
Gets the perpendicular screen distance from a Point to the tape or protractor base line.- Returns:
- the distance in screen pixels
-
isLeft
Determines if a TPoint p is to the left of the line defined by end1 and end2.- Parameters:
p- the TPoint to testend1- one end of the lineend2- second end of the line- Returns:
- true if to the left
-