graphics
Class CompoundGraphic

java.lang.Object
  extended by graphics.AbstractGraphic
      extended by graphics.CompoundGraphic
All Implemented Interfaces:
CenterLocatable, IContainer, IGraphic, ILocatable, IRotatable, ISizeable, ImageObserver

public class CompoundGraphic
extends AbstractGraphic
implements IContainer

A Graphical object that acts as a container for other Graphical objects. Add many Graphics to this and then moving, rotating, etc. this graphic will perform the desired action on all the Graphics this contains

Author:
Michael Kozelsky Created on: Jul 28, 2006 TODO: dimensions should be set first, adjusting shapes may not be as expected CompoundGraphic.java

Field Summary
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CompoundGraphic()
          Creates a new instance of an empty CompoundGraphic with a dimension of (1,1) at point (0,0)
 
Method Summary
 void actualPaint(Graphics2D gs, Point location, Dimension dimension)
          Uses the Graphics2D object to Paint the CompoundGraphic at a specified location and with a specified dimension
 void add(IGraphic g)
          Adds a graphic to the compound
 Shape getShape()
          Returns a java.awt.Shape that represents the total sum of the areas of all the Graphics in this Compound's Bounding box.
 boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height)
           
 void remove(IGraphic g)
          Removes a Graphic from the Compound
 void repaint()
          Forces a repaint of all the Graphics in the same container as the Compound
 void repaint(Rectangle bounds)
          Forces a repaint of all the things that are on this Container in the given bounds
 void setDimension(Dimension newDimension)
          Sets the dimension of this compound, thus causing all the Graphics in the compound to be altered.
 
Methods inherited from class graphics.AbstractGraphic
addMouseListener, addMouseMotionListener, contains, getBounds, getCenterLocation, getContainer, getDimension, getLocation, getMouseListeners, getMouseMotionListeners, getRotation, intersects, move, paint, rotate, setCenterLocation, setContainer, setLocation, setMovement, setRotation
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface graphics.IContainer
getDimension
 

Constructor Detail

CompoundGraphic

public CompoundGraphic()
Creates a new instance of an empty CompoundGraphic with a dimension of (1,1) at point (0,0)

Method Detail

add

public void add(IGraphic g)
Adds a graphic to the compound

Specified by:
add in interface IContainer
Parameters:
g - The Graphic to add
See Also:
IContainer.add(graphics.IGraphic)

remove

public void remove(IGraphic g)
Removes a Graphic from the Compound

Specified by:
remove in interface IContainer
Parameters:
g - The Graphic to remove
See Also:
IContainer.remove(graphics.IGraphic)

actualPaint

public void actualPaint(Graphics2D gs,
                        Point location,
                        Dimension dimension)
Uses the Graphics2D object to Paint the CompoundGraphic at a specified location and with a specified dimension

Specified by:
actualPaint in interface IGraphic
Parameters:
gs - The Graphics2D object that will do the painting
location - The Location at which to paint the Compound
dimension - The Dimension of the Compound
See Also:
IGraphic.actualPaint(java.awt.Graphics2D, java.awt.Point, java.awt.Dimension)

repaint

public void repaint()
Forces a repaint of all the Graphics in the same container as the Compound

Specified by:
repaint in interface IContainer
See Also:
IContainer.repaint()

repaint

public void repaint(Rectangle bounds)
Description copied from interface: IContainer
Forces a repaint of all the things that are on this Container in the given bounds

Specified by:
repaint in interface IContainer
Parameters:
bounds - the bounds of which to repaint
See Also:
IContainer.repaint(java.awt.Rectangle)

imageUpdate

public boolean imageUpdate(Image img,
                           int infoflags,
                           int x,
                           int y,
                           int width,
                           int height)
Specified by:
imageUpdate in interface ImageObserver
Parameters:
img -
infoflags -
x -
y -
width -
height -
Returns:
I don't know
See Also:
Component.imageUpdate(java.awt.Image, int, int, int, int, int)

setDimension

public void setDimension(Dimension newDimension)
Sets the dimension of this compound, thus causing all the Graphics in the compound to be altered. Use with caution. It is much easier if the Dimensions of CompoundGraphics are set before any Graphics are inserted into it.

Specified by:
setDimension in interface ISizeable
Overrides:
setDimension in class AbstractGraphic
Parameters:
newDimension - The Dimension to set this CompoundGraphic to be
See Also:
ISizeable.setDimension(java.awt.Dimension)

getShape

public Shape getShape()
Returns a java.awt.Shape that represents the total sum of the areas of all the Graphics in this Compound's Bounding box.

Specified by:
getShape in interface IGraphic
Returns:
an empty java.awt.Rectangle
See Also:
IGraphic.getShape()