Class PencilDrawing
java.lang.Object
org.opensourcephysics.cabrillo.tracker.PencilDrawing
- All Implemented Interfaces:
Drawable
,Measurable
A PencilDrawing is a freeform line, arrow or ellipse.
- Author:
- Douglas Brown
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected Color
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears all points from the trail.void
draw
(DrawingPanel panel, Graphics g) Draws a representation of an object in a drawing panel.static XML.ObjectLoader
Returns the XML.ObjectLoader for this class.int
Gets the number of points stored in the trail.Gets the drawing stroke.double
getXMax()
Gets the maximum x needed to draw this object.double
getXMin()
Gets the minimum x needed to draw this object.double
getYMax()
Gets the maximum y needed to draw this object.double
getYMin()
Gets the minimum y needed to draw this object.boolean
Determines if information is available to set min/max values.void
markPoint
(double x, double y) Marks a new point and draws a shape of the current style.void
setArrowheadLength
(int length) Sets the arrowhead lengthvoid
Sets the drawing stroke.void
setStyle
(int newStyle) Sets the style.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opensourcephysics.display.Drawable
isInteractive
-
Field Details
-
STYLE_ARROW
protected static final int STYLE_ARROW- See Also:
-
STYLE_ELLIPSE
protected static final int STYLE_ELLIPSE- See Also:
-
STYLE_TRAIL
protected static final int STYLE_TRAIL- See Also:
-
MAX_LENGTH
protected static final int MAX_LENGTH- See Also:
-
MIN_LENGTH
protected static final int MIN_LENGTH- See Also:
-
color
-
arrowheadLength
protected int arrowheadLength
-
-
Method Details
-
draw
Description copied from interface:Drawable
Draws a representation of an object in a drawing panel. -
setStyle
public void setStyle(int newStyle) Sets the style. Defined styles are STYLE_TRAIL, STYLE_ARROW, STYLE_ELLIPSE- Parameters:
newStyle
- one of the defined styles
-
setArrowheadLength
public void setArrowheadLength(int length) Sets the arrowhead length- Parameters:
length
- a length
-
getPointCount
public int getPointCount()Gets the number of points stored in the trail.- Returns:
- int
-
getStroke
Gets the drawing stroke.- Returns:
- Stroke
-
setStroke
Sets the drawing stroke.- Parameters:
stroke
- Stroke
-
clear
public void clear()Clears all points from the trail. -
markPoint
public void markPoint(double x, double y) Marks a new point and draws a shape of the current style.- Parameters:
x
- doubley
- double
-
getXMin
public double getXMin()Description copied from interface:Measurable
Gets the minimum x needed to draw this object.- Specified by:
getXMin
in interfaceMeasurable
- Returns:
- minimum
-
getXMax
public double getXMax()Description copied from interface:Measurable
Gets the maximum x needed to draw this object.- Specified by:
getXMax
in interfaceMeasurable
- Returns:
- maximum
-
getYMin
public double getYMin()Description copied from interface:Measurable
Gets the minimum y needed to draw this object.- Specified by:
getYMin
in interfaceMeasurable
- Returns:
- minimum
-
getYMax
public double getYMax()Description copied from interface:Measurable
Gets the maximum y needed to draw this object.- Specified by:
getYMax
in interfaceMeasurable
- Returns:
- minimum
-
isMeasured
public boolean isMeasured()Description copied from interface:Measurable
Determines if information is available to set min/max values. Objects that store data should return false if data is null.- Specified by:
isMeasured
in interfaceMeasurable
- Returns:
- true if min/max values are valid
-
getLoader
Returns the XML.ObjectLoader for this class.- Returns:
- the object loader
-