ca.mcgill.cim.sre.cv4hci
Class TransformedShape

java.lang.Object
  extended by ca.mcgill.cim.sre.cv4hci.TransformedShape

public class TransformedShape
extends java.lang.Object

TransformedShape is a class representing a Java2D Shape + AffineTransform + Color. It is used as an entity for a shape in the rest of the package. It comes with some methods required for its use, which are not part of or not working from the constituent Shape and AffineTransform objects.

Note: This class is not optimized for object-oriented reuse, it is only a demo.

Since:
1.0

Field Summary
 java.awt.Color fillColor
          The fill Color object associated with us.
 boolean isSelected
          State indicating if we are selected by a Brick or not.
 java.awt.Color outlineColor
          The outline Color object associated with us.
 java.awt.Shape shape
          The Shape object associated with us.
 java.awt.geom.AffineTransform transform
          The AffineTransform object associated with us.
 
Constructor Summary
TransformedShape(java.awt.Shape shape, java.awt.Color color)
          TransformedShape constructor specifiying the associated Shape and Color objects.
TransformedShape(java.awt.Shape shape, java.awt.Color fillColor, java.awt.Color outlineColor)
          TransformedShape constructor specifiying the associated Shape, fill Color and outline Color objects.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of ourself.
 boolean contains(java.awt.geom.Point2D p)
          Returns whether point p is inside us or not.
 void draw(java.awt.Graphics2D g)
          Draws this shape onto g with the right transform, and the right colors.
 java.awt.geom.Rectangle2D getBounds2D()
          Returns a 2D rectangle indicating our bounds as a shape.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shape

public java.awt.Shape shape
The Shape object associated with us.


transform

public java.awt.geom.AffineTransform transform
The AffineTransform object associated with us.


fillColor

public java.awt.Color fillColor
The fill Color object associated with us.


outlineColor

public java.awt.Color outlineColor
The outline Color object associated with us.


isSelected

public boolean isSelected
State indicating if we are selected by a Brick or not. If we are selected, our outline color is drawn inverted.

Constructor Detail

TransformedShape

public TransformedShape(java.awt.Shape shape,
                        java.awt.Color fillColor,
                        java.awt.Color outlineColor)
TransformedShape constructor specifiying the associated Shape, fill Color and outline Color objects.


TransformedShape

public TransformedShape(java.awt.Shape shape,
                        java.awt.Color color)
TransformedShape constructor specifiying the associated Shape and Color objects.

Method Detail

contains

public boolean contains(java.awt.geom.Point2D p)
Returns whether point p is inside us or not.

Parameters:
p - the 2D point we want to check
Returns:
true if point p is inside us, otherwise false

getBounds2D

public java.awt.geom.Rectangle2D getBounds2D()
Returns a 2D rectangle indicating our bounds as a shape.

Returns:
the bounds rectangle

draw

public void draw(java.awt.Graphics2D g)
Draws this shape onto g with the right transform, and the right colors. The outline Color will be drawn inverted if isSelected == true.

Parameters:
g - the Graphics2D object to draw on

clone

public java.lang.Object clone()
Returns a clone of ourself.

Overrides:
clone in class java.lang.Object
Returns:
a clone of us (please, cast to TransformedShape)