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 int
protected BasicStroke[]
protected Color[]
protected static final float[]
protected BasicStroke
protected static final int
protected static final int
protected static final int
protected DecimalFormat
protected org.opensourcephysics.cabrillo.tracker.Ruler.Handle
protected boolean
protected int
protected int
protected ArrayList<org.opensourcephysics.cabrillo.tracker.Ruler.Label>
protected AffineTransform
protected int
protected static final double
protected static final int
protected static final int
protected static final double
protected org.opensourcephysics.cabrillo.tracker.MultiShape[]
protected static final int
protected double
protected Double
protected double
protected int
protected double
protected double
protected BasicStroke[]
protected InputTrack
protected AffineTransform
protected TPoint
protected boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Interactive
findInteractive
(TrackerPanel trackerPanel, Rectangle hitRect) Returns the Handle if this Ruler's hit shape intersects the supplied Rectangle.int
getAlpha()
Gets the alpha.getColor()
Gets the color.getFormattedValue
(double value, double min) Formats the specified value.org.opensourcephysics.cabrillo.tracker.Ruler.Handle
Gets the handle, used to adjust the ruler sizedouble
Gets the ruler line spacing.protected abstract Mark
getMark
(TrackerPanel trackerPanel, int n) Gets the mark to draw for a given frame.double
Gets the ruler size--width for tapes, radius for protractors.protected double
Gets the perpendicular screen distance from a Point to the tape or protractor base line.float
Gets the stroke width.protected boolean
Determines if a TPoint p is to the left of the line defined by end1 and end2.boolean
Gets the visibility of the ruler.void
Refreshes the strokes.void
setAlpha
(int alpha) Sets the alpha.void
Sets the color.protected void
setHandleXY
(double x, double y) Set the handle position in image units.protected void
setHitShapeVisible
(boolean vis) Sets the visibility of the hit shapevoid
setLineSpacing
(double space) Sets the ruler line spacing.void
setRulerSize
(double size) Sets the ruler size.void
setStrokeWidth
(float width) Sets the stroke width.void
setVisible
(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
-