|
|||||||||
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 Locatable
setLocation
in class AbstractShape
public boolean contains(java.awt.Point p)
contains
in interface CustomGraphic
p
- the pointpublic java.awt.Point getLocation()
getLocation
in interface Locatable
getLocation
in class AbstractShape
public java.awt.Rectangle getBounds()
getBounds
in class AbstractShape
public int getXLocation()
getXLocation
in interface Locatable
getXLocation
in class AbstractShape
public int getYLocation()
getYLocation
in interface Locatable
getYLocation
in class AbstractShape
public int getWidth()
getWidth
in class AbstractShape
public int getHeight()
getHeight
in class AbstractShape
public int getRotation()
getRotation
in interface Rotatable
getRotation
in class AbstractShape
public void setRotation(int degrees)
setRotation
in interface Rotatable
setRotation
in class AbstractShape
public java.util.Set<AbstractShape> getShapes()
public void paint(java.awt.Graphics2D g)
CustomGraphic
Graphics2D
. This
method will be called often (whenever the containing drawing panel is
repainted).
paint
in interface CustomGraphic
g
- the Graphics2D
you should use to paint your
graphicpublic void mousePressed(java.awt.event.MouseEvent e)
AbstractGraphic
mousePressed
in interface java.awt.event.MouseListener
mousePressed
in interface CustomGraphic
mousePressed
in class AbstractGraphic
public void mouseReleased(java.awt.event.MouseEvent e)
AbstractGraphic
mouseReleased
in interface java.awt.event.MouseListener
mouseReleased
in interface CustomGraphic
mouseReleased
in class AbstractGraphic
public void mouseClicked(java.awt.event.MouseEvent e)
AbstractGraphic
mouseClicked
in interface java.awt.event.MouseListener
mouseClicked
in interface CustomGraphic
mouseClicked
in class AbstractGraphic
public void mouseDragged(java.awt.event.MouseEvent e)
AbstractGraphic
mouseDragged
in interface CustomGraphic
mouseDragged
in class AbstractGraphic
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public 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 |