|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opensourcephysics.display.AbstractInteractive org.opensourcephysics.display.InteractiveShape
public class InteractiveShape
A shape that implements Interactive.
Nested Class Summary | |
---|---|
protected static class |
InteractiveShape.InteractiveShapeLoader
A class to save and load InteractiveShape in an XMLControl. |
Field Summary | |
---|---|
java.awt.Color |
edgeColor
|
protected double |
height
|
protected boolean |
pixelSized
|
protected java.awt.Shape |
shape
|
protected java.lang.String |
shapeClass
|
protected double |
theta
|
protected double |
width
|
protected double |
xoff
|
protected double |
yoff
|
Fields inherited from class org.opensourcephysics.display.AbstractInteractive |
---|
color, x, y |
Constructor Summary | |
---|---|
InteractiveShape(java.awt.Shape s)
Constructs an InteractiveShape at the origin. |
|
InteractiveShape(java.awt.Shape s,
double _x,
double _y)
Constructs an InteractiveShape with the given coordinates. |
Method Summary | |
---|---|
boolean |
contains(double x,
double y)
Tests if the specified coordinates are inside the boundary of the Shape . |
static InteractiveShape |
createArrow(double x,
double y,
double w,
double h)
Creates an interactive arrow. |
static InteractiveShape |
createCenteredArrow(double x,
double y,
double w,
double h)
Creates an interactive arrow. |
static InteractiveShape |
createCircle(double x,
double y,
double d)
Creates an interactive circle. |
static InteractiveShape |
createEllipse(double x,
double y,
double w,
double h)
Creates an interactive ellipse. |
static InteractiveShape |
createImage(java.awt.Image image,
double x,
double y)
Creates an interactive image. |
static InteractiveShape |
createRectangle(double x,
double y,
double w,
double h)
Creates an interactive rectangle. |
static InteractiveShape |
createSquare(double x,
double y,
double w)
Creates an interactive square. |
static InteractiveShape |
createTextLine(double x,
double y,
java.lang.String text)
Creates an interactive image. |
static InteractiveShape |
createTriangle(double x,
double y,
double b,
double h)
Creates an interactive triangle with a base parallel to the x axis. |
void |
draw(DrawingPanel panel,
java.awt.Graphics g)
Draws the shape. |
double |
getHeight()
Gets the height of this shape. |
static XML.ObjectLoader |
getLoader()
Gets the XML object loader for this class. |
java.awt.Shape |
getShape()
Gets the Java shape that is being drawn. |
double |
getWidth()
Gets the width of this shape. |
double |
getXMax()
Implements measurable by getting the x center of the circle. |
double |
getXMin()
Implements measurable by getting the x center of the circle. |
double |
getYMax()
Implements measurable by getting the y center of the circle. |
double |
getYMin()
Implements measurable by getting the y center of the circle. |
boolean |
isInside(DrawingPanel panel,
int xpix,
int ypix)
Determines if the shape is enabled and if the given pixel coordinates are within the shape. |
boolean |
isMeasured()
Determines if this circle should effect the scale of a drawing panel. |
void |
setHeight(double height)
Sets the height of the shape to the given value. |
void |
setMarkerColor(java.awt.Color _fillColor,
java.awt.Color _edgeColor)
Sets the shape's drawing colors. |
void |
setMeasured(boolean _enableMeasure)
Enables the measured flag so that this arrow effects the scale of a drawing panel. |
void |
setOffset(double xoffset,
double yoffset)
Sets the drawing offset; Fixed size shapes cannot be offset. |
void |
setPixelSized(boolean enable)
Sets the pixelSized flag. |
void |
setTheta(double theta)
Sets the rotation angle in radians. |
void |
setWidth(double width)
Sets the width of the shape to the given value. |
void |
setX(double _x)
Sets the x coordinate. |
void |
setXY(double _x,
double _y)
Sets the x and y coordinates. |
void |
setY(double _y)
Sets the y coordinate. |
java.lang.String |
toString()
Gets a description of this object. |
void |
tranform(double[][] mat)
Transforms the shape using the given matrix. |
void |
transform(java.awt.geom.AffineTransform transformation)
Transforms the shape. |
Methods inherited from class org.opensourcephysics.display.AbstractInteractive |
---|
findInteractive, getX, getY, isEnabled, setEnabled |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public java.awt.Color edgeColor
protected java.awt.Shape shape
protected java.lang.String shapeClass
protected double theta
protected double width
protected double height
protected double xoff
protected double yoff
protected boolean pixelSized
Constructor Detail |
---|
public InteractiveShape(java.awt.Shape s, double _x, double _y)
s
- _x
- coordinate_y
- coordinatepublic InteractiveShape(java.awt.Shape s)
s
- Method Detail |
---|
public static InteractiveShape createEllipse(double x, double y, double w, double h)
x
- y
- w
- h
-
public static InteractiveShape createCircle(double x, double y, double d)
x
- y
- d
- the diameter
public static InteractiveShape createRectangle(double x, double y, double w, double h)
x
- y
- w
- h
-
public static InteractiveShape createTriangle(double x, double y, double b, double h)
x
- y
- b
- baseh
- height
public static InteractiveShape createImage(java.awt.Image image, double x, double y)
x
- y
- image
-
public static InteractiveShape createTextLine(double x, double y, java.lang.String text)
x
- y
- text
-
public static InteractiveShape createArrow(double x, double y, double w, double h)
x
- y
- w
- baseh
- height
public static InteractiveShape createCenteredArrow(double x, double y, double w, double h)
x
- y
- w
- baseh
- height
public static InteractiveShape createSquare(double x, double y, double w)
x
- y
- w
-
public void transform(java.awt.geom.AffineTransform transformation)
transformation
- AffineTransformpublic void draw(DrawingPanel panel, java.awt.Graphics g)
draw
in interface Drawable
draw
in class AbstractInteractive
panel
- the drawing panelg
- the graphics contextpublic boolean contains(double x, double y)
Shape
.
x
- y
-
true
if the specified coordinates are inside
the Shape
boundary; false
otherwise.public java.awt.Shape getShape()
public void tranform(double[][] mat)
mat
- double[][]public boolean isInside(DrawingPanel panel, int xpix, int ypix)
isInside
in class AbstractInteractive
panel
- DrawingPanelxpix
- intypix
- int
public void setMarkerColor(java.awt.Color _fillColor, java.awt.Color _edgeColor)
_fillColor
- _edgeColor
- public void setTheta(double theta)
theta
- the new anglepublic void setPixelSized(boolean enable)
enable
- booleanpublic double getWidth()
public void setWidth(double width)
width
- doublepublic double getHeight()
public void setHeight(double height)
height
- doublepublic void setOffset(double xoffset, double yoffset)
xoffset
- doubleyoffset
- doublepublic void setXY(double _x, double _y)
setXY
in interface Interactive
setXY
in class AbstractInteractive
_x
- _y
- public void setX(double _x)
setX
in interface Interactive
setX
in class AbstractInteractive
_x
- public void setY(double _y)
setY
in interface Interactive
setY
in class AbstractInteractive
_y
- public java.lang.String toString()
toString
in class java.lang.Object
public void setMeasured(boolean _enableMeasure)
public boolean isMeasured()
isMeasured
in interface Measurable
isMeasured
in class AbstractInteractive
public double getXMin()
getXMin
in interface Measurable
getXMin
in class AbstractInteractive
public double getXMax()
getXMax
in interface Measurable
getXMax
in class AbstractInteractive
public double getYMin()
getYMin
in interface Measurable
getYMin
in class AbstractInteractive
public double getYMax()
getYMax
in interface Measurable
getYMax
in class AbstractInteractive
public static XML.ObjectLoader getLoader()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |