wheelsunh.users
Class ShapeGroup

java.lang.Object
  extended by wheelsunh.etc.AbstractGraphic
      extended by wheelsunh.users.AbstractShape
          extended by wheelsunh.users.ShapeGroup
All Implemented Interfaces:
java.awt.event.MouseListener, java.util.EventListener, CustomGraphic, Locatable, Rotatable

public class ShapeGroup
extends AbstractShape
implements Locatable, Rotatable, java.awt.event.MouseListener

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

ShapeGroup

public ShapeGroup()
Constructor: defines xloc and yloc to be arbitrarily large; the first shape will set them appropriately.

Method Detail

add

public void add(AbstractShape s)
Adds a shape to this group. The group's "location" is adjusted if necessary, and the new shape is registered with this group as a mouse and keystroke listener


setLocation

public void setLocation(java.awt.Point p)
Set object's location to given point.

Specified by:
setLocation in interface Locatable
Specified by:
setLocation in class AbstractShape

contains

public boolean contains(java.awt.Point p)
returns true if p is contained within any shape in this group

Specified by:
contains in interface CustomGraphic
Parameters:
p - the point

getLocation

public java.awt.Point getLocation()
Returns the object's location.

Specified by:
getLocation in interface Locatable
Specified by:
getLocation in class AbstractShape

getBounds

public java.awt.Rectangle getBounds()
returns the bounding box of this group

Specified by:
getBounds in class AbstractShape

getXLocation

public int getXLocation()
Returns the object's x location.

Specified by:
getXLocation in interface Locatable
Specified by:
getXLocation in class AbstractShape

getYLocation

public int getYLocation()
Returns the object's y location.

Specified by:
getYLocation in interface Locatable
Specified by:
getYLocation in class AbstractShape

getWidth

public int getWidth()
Returns the object's width

Specified by:
getWidth in class AbstractShape

getHeight

public int getHeight()
Returns the object's height

Specified by:
getHeight in class AbstractShape

getRotation

public int getRotation()
returns the current absolute degree of rotation of this group By Jake Mandel, for UNH CS

Specified by:
getRotation in interface Rotatable
Specified by:
getRotation in class AbstractShape

setRotation

public 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. By Jake Mandel, for UNH CS

Specified by:
setRotation in interface Rotatable
Specified by:
setRotation in class AbstractShape

getShapes

public java.util.Set<AbstractShape> getShapes()
Return a Set of all shapes in this group.


paint

public void paint(java.awt.Graphics2D g)
Description copied from interface: CustomGraphic
The real meat of the interface. The graphic must know how to draw itself using the passed-in instance of Graphics2D. This method will be called often (whenever the containing drawing panel is repainted).

Specified by:
paint in interface CustomGraphic
Parameters:
g - the Graphics2D you should use to paint your graphic

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Description copied from class: AbstractGraphic
Called when a mouse button is pressed over the graphic.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Specified by:
mousePressed in interface CustomGraphic
Overrides:
mousePressed in class AbstractGraphic

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Description copied from class: AbstractGraphic
Called when a mouse button is released over the graphic.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Specified by:
mouseReleased in interface CustomGraphic
Overrides:
mouseReleased in class AbstractGraphic

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Description copied from class: AbstractGraphic
Called when mouse is clicked over the graphic.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Specified by:
mouseClicked in interface CustomGraphic
Overrides:
mouseClicked in class AbstractGraphic

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Description copied from class: AbstractGraphic
Called when mouse button is pressed and dragged over graphic.

Specified by:
mouseDragged in interface CustomGraphic
Overrides:
mouseDragged in class AbstractGraphic

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener