|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectNGP.Graphics.Shape
NGP.Graphics.RectangularShape
NGP.Graphics.FramedRectangularShape
NGP.Graphics.FramedRectangle
cs015.SketchySupport.BoundingBox
This class models a bounding box to be used with a SketchyShape. It has handles that can be dragged with the mouse to adjust the size of the shape that it's attached to.
Field Summary | |
protected SketchyShape |
_shape
|
Fields inherited from class NGP.Graphics.Shape |
_awtShape, _dpanel |
Fields inherited from interface NGP.Colorable |
DEFAULT_GRAY |
Constructor Summary | |
BoundingBox(DrawingPanel dp)
Creates a bounding box. |
Method Summary | |
void |
attachShape(SketchyShape shape)
Sets the SketchyShape that the bounding box will be acting on. |
double |
degToRad(int deg)
Converts an angle in degrees to an angle in radians. |
java.awt.Point |
getCenterLocation()
Gets the location of the CENTER of the bounding box. |
java.awt.Point |
getLocation()
Gets the location of the CENTER of the bounding box. |
void |
handleDragged(java.awt.event.MouseEvent e,
Handle handle)
This method is called whenever one of the BoundingBox's Handles are dragged. |
void |
handlePressed(java.awt.event.MouseEvent e,
Handle handle)
This method is called whenever one of the Handles is pressed. |
void |
handleReleased(java.awt.event.MouseEvent e,
Handle handle)
This method is called whenever one of the Handles is released. |
void |
hide()
Hide the bounding box. |
int |
radToDeg(double rad)
Converts an angle in radians to an angle in degrees. |
void |
removeShape()
This method makes the bounding box lose its reference to its attached shape and then hides the box. |
void |
resize(java.awt.Point oldLoc,
java.awt.Point newLoc,
Handle handle)
This method should be called when a Handle is dragged in an attempt to resize the BoundingBox and attached Shape. |
void |
rotateClockwise(int degrees)
Rotates the BoundingBox and its attached shape by the given number of degrees in the clockwise direction. |
java.awt.Point |
rotatePoint(java.awt.Point p,
int degrees)
A math function that takes a Point p and an angle in degrees and returns p after a clockwise rotation through degrees around the origin. |
void |
setCenterLocation(java.awt.Point p)
Change the location of the bounding box and its attached shape. |
void |
setDimension(java.awt.Dimension d)
Sets the dimension of the BoundingBox and its attached SketchyShape. |
void |
setLocation(java.awt.Point p)
Change the location of the bounding box and its attached shape. |
void |
setRotation(int rotation)
Sets the bounding box and its attached shape's rotation. |
void |
show()
Show the bounding box. |
void |
vectorRotate(java.awt.Point tail,
java.awt.Point head)
This method takes two points, finds the angle between vectors from the center of the bounding box to each of the points, and then rotates the bounding box and its attached shape by this angle. |
Methods inherited from class NGP.Graphics.FramedRectangularShape |
actualPaint, getBounds, getThickness, setThickness |
Methods inherited from class NGP.Graphics.RectangularShape |
getDimension, unwrap, wrap |
Methods inherited from class NGP.Graphics.Shape |
contains, drag, getColor, getDrawingPanel, getRotation, intersects, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, paint, react, setColor, setDrawingPanel |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected SketchyShape _shape
Constructor Detail |
public BoundingBox(DrawingPanel dp)
dp
- the DrawingPanel where the bounding box will be drawn.Method Detail |
public void attachShape(SketchyShape shape)
shape
- The shape which the bounding box will manipulate.public void removeShape()
public void hide()
public void show()
public int radToDeg(double rad)
rad
- radian value
public double degToRad(int deg)
deg
- value to convert to radians
public void setDimension(java.awt.Dimension d)
d
- the new dimension of the BoundingBox and its attached shape.public void setRotation(int rotation)
public void setLocation(java.awt.Point p)
p
- the new position of the CENTER of the bounding box.public java.awt.Point getLocation()
public void setCenterLocation(java.awt.Point p)
p
- the new position of the CENTER of the bounding box.public java.awt.Point getCenterLocation()
public void rotateClockwise(int degrees)
degrees
- the number of degrees to rotate bypublic java.awt.Point rotatePoint(java.awt.Point p, int degrees)
p
- the point to be rotateddegrees
- the angle through which to rotate ppublic void resize(java.awt.Point oldLoc, java.awt.Point newLoc, Handle handle)
oldLoc
- the old location of the handle in box-relative coordinatesnewLoc
- what the new location of the handle should be in box-
relative coordinates.handle
- the Handle that is being dragged.public void vectorRotate(java.awt.Point tail, java.awt.Point head)
tail
- the tail of the rotation vector. If the box is being
rotated by dragging a Handle, then this would correspond to the
location of that Handle.head
- the head of the rotation vector. If the box is being
rotated by dragging a Handle, then this would correspond to the
location of the mouse after the drag event.public void handleDragged(java.awt.event.MouseEvent e, Handle handle)
e
- the mouse event generated by the dragging.handle
- the Handle being dragged.public void handlePressed(java.awt.event.MouseEvent e, Handle handle)
e
- the MouseEvent generated by the press.handle
- the Handle being dragged.public void handleReleased(java.awt.event.MouseEvent e, Handle handle)
e
- the MouseEvent generated by the release.handle
- the Handle being dragged.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |