Package org.opensourcephysics.display
Class BoundedShape
java.lang.Object
org.opensourcephysics.display.AbstractInteractive
org.opensourcephysics.display.InteractiveShape
org.opensourcephysics.display.BoundedShape
- All Implemented Interfaces:
Drawable,Interactive,Measurable,Selectable
- Direct Known Subclasses:
BoundedImage,InteractiveArrow,InteractiveCenteredArrow
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA class to save and load BoundedShape in an XMLControl.Nested classes/interfaces inherited from class org.opensourcephysics.display.InteractiveShape
InteractiveShape.InteractiveShapeLoader -
Field Summary
Fields inherited from class org.opensourcephysics.display.InteractiveShape
edgeColor, height, pixelPt, pixelSized, shape, shapeClass, theta, toPixels, trIS, width, xoff, yoffFields inherited from class org.opensourcephysics.display.AbstractInteractive
color, x, y -
Constructor Summary
ConstructorsConstructorDescriptionBoundedShape(Shape s, double x, double y) Constructs a BoundedShape object for the given shape. -
Method Summary
Modifier and TypeMethodDescriptionstatic BoundedShapecreateBoundedArrow(double x, double y, double w, double h) Creates a bounded arrow.static BoundedShapecreateBoundedCenteredArrow(double x, double y, double w, double h) Creates a bounded arrow.static BoundedShapecreateBoundedCircle(double x, double y, double d) Creates a bounded circle.static BoundedShapecreateBoundedEllipse(double x, double y, double w, double h) Creates a bounded ellipse.static BoundedShapecreateBoundedImage(Image image, double x, double y) Creates a bounded image.static BoundedShapecreateBoundedRectangle(double x, double y, double w, double h) Creates a bounded rectangle.static BoundedShapecreateBoundedTriangle(double x, double y, double b, double h) Creates a bounded rectangle.voiddraw(DrawingPanel panel, Graphics g) Draws the shape.findInteractive(DrawingPanel panel, int xpix, int ypix) Finds the interactive object that will respond to mouse actions.protected Rectangle2D.DoublegetBounds2D(Shape temp) static XML.ObjectLoaderGets the XML object loader for this class.booleanGets the height drag option.booleanisInside(DrawingPanel panel, int xpix, int ypix) Determines if the shape is enabled and if the given pixel coordinates are within the shape.booleanGets the rotate drag option.booleanbooleanGets the width width drag option.booleanisXYDrag()Gets the xy drag boolean.voidsetHeightDrag(boolean enable) Sets the height drag option.voidsetRotateDrag(boolean enable) Sets the rotate drag option.voidsetSelected(boolean selected) voidsetWidthDrag(boolean enable) Sets the width drag option.voidsetXYDrag(boolean enable) Sets the xy drag option.voidtoString()Gets a description of this object.Methods inherited from class org.opensourcephysics.display.InteractiveShape
contains, createArrow, createCenteredArrow, createCircle, createEllipse, createImage, createRectangle, createSquare, createTextLine, createTriangle, getHeight, getPixelPt, getRotateInstance, getRotateInstance, getScaleInstance, getShape, getTranslateInstance, getWidth, getXMax, getXMin, getYMax, getYMin, isMeasured, setHeight, setMarkerColor, setMeasured, setOffset, setPixelSized, setTheta, setWidth, setX, setXY, setY, tranform, transformMethods inherited from class org.opensourcephysics.display.AbstractInteractive
getX, getY, isEnabled, setEnabledMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.opensourcephysics.display.Interactive
getX, getY, isEnabled, isInteractive, setEnabled, setX, setXY, setYMethods inherited from interface org.opensourcephysics.display.Measurable
getXMax, getXMin, getYMax, getYMin, isMeasured
-
Constructor Details
-
BoundedShape
Constructs a BoundedShape object for the given shape.- Parameters:
s- Shapex- doubley- double
-
-
Method Details
-
createBoundedRectangle
Creates a bounded rectangle.- Parameters:
x-y-w-h-- Returns:
- the interactive rectangle
-
createBoundedTriangle
Creates a bounded rectangle.- Parameters:
x-y-b- baseh- height- Returns:
- the rectangle
-
createBoundedArrow
Creates a bounded arrow.- Parameters:
x-y-w- baseh- height- Returns:
- the arrow
-
createBoundedCenteredArrow
Creates a bounded arrow.- Parameters:
x-y-w- baseh- height- Returns:
- the arrow
-
createBoundedImage
Creates a bounded image.- Parameters:
x-y-image-- Returns:
- the rectangle
-
createBoundedEllipse
Creates a bounded ellipse.- Parameters:
x-y-w-h-- Returns:
- BoundedShape
-
createBoundedCircle
Creates a bounded circle.- Parameters:
x-y-d- the diameter- Returns:
- the circle
-
setSelected
public void setSelected(boolean selected) - Specified by:
setSelectedin interfaceSelectable
-
isSelected
public boolean isSelected()- Specified by:
isSelectedin interfaceSelectable
-
setXYDrag
public void setXYDrag(boolean enable) Sets the xy drag option.- Parameters:
enable- boolean
-
isXYDrag
public boolean isXYDrag()Gets the xy drag boolean.- Returns:
- boolean true if center can be dragged
-
setRotateDrag
public void setRotateDrag(boolean enable) Sets the rotate drag option.- Parameters:
enable- boolean
-
isRotateDrag
public boolean isRotateDrag()Gets the rotate drag option.- Returns:
- boolean
-
setWidthDrag
public void setWidthDrag(boolean enable) Sets the width drag option.- Parameters:
enable- boolean
-
isWidthDrag
public boolean isWidthDrag()Gets the width width drag option.- Returns:
- boolean true if center can be dragged
-
setHeightDrag
public void setHeightDrag(boolean enable) Sets the height drag option.- Parameters:
enable- boolean
-
isHeightDrag
public boolean isHeightDrag()Gets the height drag option.- Returns:
- boolean true if center can be dragged
-
getPreferredCursor
- Specified by:
getPreferredCursorin interfaceSelectable
-
toggleSelected
public void toggleSelected()- Specified by:
toggleSelectedin interfaceSelectable
-
findInteractive
Description copied from class:AbstractInteractiveFinds the interactive object that will respond to mouse actions.- Specified by:
findInteractivein interfaceInteractive- Overrides:
findInteractivein classAbstractInteractive- Parameters:
panel- DrawingPanelxpix- intypix- int- Returns:
- Interactive
-
isInside
Determines if the shape is enabled and if the given pixel coordinates are within the shape.- Overrides:
isInsidein classInteractiveShape- Parameters:
panel- DrawingPanelxpix- intypix- int- Returns:
- boolean
-
getBounds2D
-
draw
Draws the shape.- Specified by:
drawin interfaceDrawable- Overrides:
drawin classInteractiveShape- Parameters:
panel- the drawing panelg- the graphics context
-
toString
Gets a description of this object.- Overrides:
toStringin classInteractiveShape- Returns:
- String
-
getLoader
Gets the XML object loader for this class.- Returns:
- ObjectLoader
-