|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectwheelsunh.etc.AbstractGraphic
wheelsunh.users.AbstractShape
wheelsunh.users.ShapeGroup
public class ShapeGroup
A class representing a group of Shapes which can be moved as a single entity. The group also registers clicks and keystrokes on its members; by default, it takes no action, but this behavior can be overridden in subclasses. The group's nominal location is the upper left-hand corner of a nominal rectangle enclosing all the shapes in the group (in other words, the smallest x and y coordinates in the group).
| Field Summary |
|---|
| Fields inherited from class wheelsunh.users.AbstractShape |
|---|
_rot |
| Constructor Summary | |
|---|---|
ShapeGroup()
Constructor: defines xloc and yloc to be arbitrarily large; the first shape will set them appropriately. |
|
| Method Summary | |
|---|---|
void |
add(AbstractShape s)
Adds a shape to this group. |
boolean |
contains(java.awt.Point p)
returns true if p is contained within any shape in this group |
java.awt.Rectangle |
getBounds()
returns the bounding box of this group |
int |
getHeight()
Returns the object's height |
java.awt.Point |
getLocation()
Returns the object's location. |
int |
getRotation()
returns the current absolute degree of rotation of this group By Jake Mandel, for UNH CS |
java.util.Set<AbstractShape> |
getShapes()
Return a Set of all shapes in this group. |
int |
getWidth()
Returns the object's width |
int |
getXLocation()
Returns the object's x location. |
int |
getYLocation()
Returns the object's y location. |
void |
mouseClicked(java.awt.event.MouseEvent e)
Called when mouse is clicked over the graphic. |
void |
mouseDragged(java.awt.event.MouseEvent e)
Called when mouse button is pressed and dragged over graphic. |
void |
mouseEntered(java.awt.event.MouseEvent e)
|
void |
mouseExited(java.awt.event.MouseEvent e)
|
void |
mousePressed(java.awt.event.MouseEvent e)
Called when a mouse button is pressed over the graphic. |
void |
mouseReleased(java.awt.event.MouseEvent e)
Called when a mouse button is released over the graphic. |
void |
paint(java.awt.Graphics2D g)
The real meat of the interface. |
void |
setLocation(java.awt.Point p)
Set object's location to given point. |
void |
setRotation(int degrees)
sets the rotation angle of this ShapeGroup to (degrees) absolute This method handles repositioning the shapes, then rotates each of them separately. |
| Methods inherited from class wheelsunh.users.AbstractShape |
|---|
boundsIntersects, center, distance, getCenter, getCenterX, getCenterY, getIntersection, intersects, intersects, setCenter, setLocation |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface wheelsunh.Locatable |
|---|
setLocation |
| Constructor Detail |
|---|
public ShapeGroup()
| Method Detail |
|---|
public void add(AbstractShape s)
public void setLocation(java.awt.Point p)
setLocation in interface LocatablesetLocation in class AbstractShapepublic boolean contains(java.awt.Point p)
contains in interface CustomGraphicp - the pointpublic java.awt.Point getLocation()
getLocation in interface LocatablegetLocation in class AbstractShapepublic java.awt.Rectangle getBounds()
getBounds in class AbstractShapepublic int getXLocation()
getXLocation in interface LocatablegetXLocation in class AbstractShapepublic int getYLocation()
getYLocation in interface LocatablegetYLocation in class AbstractShapepublic int getWidth()
getWidth in class AbstractShapepublic int getHeight()
getHeight in class AbstractShapepublic int getRotation()
getRotation in interface RotatablegetRotation in class AbstractShapepublic void setRotation(int degrees)
setRotation in interface RotatablesetRotation in class AbstractShapepublic java.util.Set<AbstractShape> getShapes()
public void paint(java.awt.Graphics2D g)
CustomGraphicGraphics2D. This
method will be called often (whenever the containing drawing panel is
repainted).
paint in interface CustomGraphicg - the Graphics2D you should use to paint your
graphicpublic void mousePressed(java.awt.event.MouseEvent e)
AbstractGraphic
mousePressed in interface java.awt.event.MouseListenermousePressed in interface CustomGraphicmousePressed in class AbstractGraphicpublic void mouseReleased(java.awt.event.MouseEvent e)
AbstractGraphic
mouseReleased in interface java.awt.event.MouseListenermouseReleased in interface CustomGraphicmouseReleased in class AbstractGraphicpublic void mouseClicked(java.awt.event.MouseEvent e)
AbstractGraphic
mouseClicked in interface java.awt.event.MouseListenermouseClicked in interface CustomGraphicmouseClicked in class AbstractGraphicpublic void mouseDragged(java.awt.event.MouseEvent e)
AbstractGraphic
mouseDragged in interface CustomGraphicmouseDragged in class AbstractGraphicpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenerpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListener
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||