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 intprotected Colorprotected static final intprotected static final intprotected static final intprotected static final intprotected static final int -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all points from the trail.voiddraw(DrawingPanel panel, Graphics g) Draws a representation of an object in a drawing panel.static XML.ObjectLoaderReturns the XML.ObjectLoader for this class.intGets the number of points stored in the trail.Gets the drawing stroke.doublegetXMax()Gets the maximum x needed to draw this object.doublegetXMin()Gets the minimum x needed to draw this object.doublegetYMax()Gets the maximum y needed to draw this object.doublegetYMin()Gets the minimum y needed to draw this object.booleanDetermines if information is available to set min/max values.voidmarkPoint(double x, double y) Marks a new point and draws a shape of the current style.voidsetArrowheadLength(int length) Sets the arrowhead lengthvoidSets the drawing stroke.voidsetStyle(int newStyle) Sets the style.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:DrawableDraws 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:MeasurableGets the minimum x needed to draw this object.- Specified by:
getXMinin interfaceMeasurable- Returns:
- minimum
-
getXMax
public double getXMax()Description copied from interface:MeasurableGets the maximum x needed to draw this object.- Specified by:
getXMaxin interfaceMeasurable- Returns:
- maximum
-
getYMin
public double getYMin()Description copied from interface:MeasurableGets the minimum y needed to draw this object.- Specified by:
getYMinin interfaceMeasurable- Returns:
- minimum
-
getYMax
public double getYMax()Description copied from interface:MeasurableGets the maximum y needed to draw this object.- Specified by:
getYMaxin interfaceMeasurable- Returns:
- minimum
-
isMeasured
public boolean isMeasured()Description copied from interface:MeasurableDetermines if information is available to set min/max values. Objects that store data should return false if data is null.- Specified by:
isMeasuredin interfaceMeasurable- Returns:
- true if min/max values are valid
-
getLoader
Returns the XML.ObjectLoader for this class.- Returns:
- the object loader
-