|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectca.mcgill.cim.sre.cv4hci.Brick
public class Brick
Brick is a class visually representing a "brick" and its state. A brick has an x,y position, an angle, a state indicating whether it's "up" or not, it's shape (usually a rectangle) and its area. It also keeps in memory its previous state so it can do more interesting stuff (translation, etc.) when the doStuffWithSelectedShape method is called.
Note: This class is not optimized for object-oriented reuse, it is only a demo.
Field Summary | |
---|---|
double |
angle
The current angle of the brick (in radian). |
double |
area
The current area of the shape. |
boolean |
isUp
The current "up" state of the brick. |
TransformedShape |
myShape
The shape used to draw (with Java2D) the brick. |
double |
pickUpArea
The update method uses the pickUpArea value to know when a brick is considered "up". |
java.awt.geom.Point2D |
position
The current position of the brick. |
double |
previousAngle
The previous angle of the brick (in radian). |
java.awt.geom.Point2D |
previousPosition
The previous position of the brick. |
double |
putDownArea
The update method uses the putDownArea value to know when a brick is considered "down". |
TransformedShape |
selectedShape
The currently selected shape used by the doStuffWithSelectedShape method. |
boolean |
wasUp
The previous up" state of the brick. |
Constructor Summary | |
---|---|
Brick()
Brick constructor. |
|
Brick(int width,
int height)
Brick constructor specifiying the width and the height (in pixels) of the shape (rectangle) to be drawn. |
Method Summary | |
---|---|
void |
doStuffWithSelectedShape(Brick theOtherBrick)
Manipulates the selectedShape according to the the movement of the brick. |
double |
getHeight()
Gets the height of the shape of this brick. |
java.awt.geom.AffineTransform |
getUpdateTransform()
Returns the necessary transform (rotation about the brick position then translation) to move a shape according to the new state of this brick minus its previous state |
double |
getWidth()
Gets the width of the shape of this brick. |
void |
pickUpOrDropShape(java.util.LinkedList<TransformedShape> shapeList,
java.util.LinkedList<TransformedShape> shapeMenuList)
Picks up or drops shapes if wasPickedUp() is true. |
void |
setSize(int width,
int height)
Sets the width and the height of the shape (rectangle) to be drawn. |
void |
update(java.awt.geom.Point2D center,
java.awt.geom.Dimension2D size,
double angle,
java.awt.Color color)
Updates the current state of this brick with new information. |
boolean |
wasPickedUp()
Returns true if !wasUp && isUp, that is if the brick was just picked up |
boolean |
wasPutDown()
Returns true if wasUp && !isUp, that is if the brick was just put down |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.awt.geom.Point2D position
public java.awt.geom.Point2D previousPosition
public double previousAngle
public double angle
public boolean isUp
public boolean wasUp
public TransformedShape myShape
public TransformedShape selectedShape
public double area
public double pickUpArea
public double putDownArea
Constructor Detail |
---|
public Brick()
public Brick(int width, int height)
Method Detail |
---|
public void setSize(int width, int height)
width
- width in pixelsheight
- height in pixelspublic double getWidth()
public double getHeight()
public void update(java.awt.geom.Point2D center, java.awt.geom.Dimension2D size, double angle, java.awt.Color color)
The size is only used for comparison with pickUpArea and putDownArea. It is NOT used for the size of the rectangular shape representing this brick in the drawing. To set this size, use the setSize method.
center
- new x,y position of the brick in pixelssize
- new width and height in pixelsangle
- new angle in radiancolor
- new colorpublic boolean wasPickedUp()
public boolean wasPutDown()
public java.awt.geom.AffineTransform getUpdateTransform()
public void pickUpOrDropShape(java.util.LinkedList<TransformedShape> shapeList, java.util.LinkedList<TransformedShape> shapeMenuList)
shapeList
- a list of working shapesshapeMenuList
- a list of shapes used as a menu, to produce working shapespublic void doStuffWithSelectedShape(Brick theOtherBrick)
theOtherBrick
- the other brick used in concert with this one to do scaling
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |