edu.jhu.tmaj.client.image.draw
Class RectangleDrawable

java.lang.Object
  extended by edu.jhu.tmaj.client.image.draw.AbstractDrawable
      extended by edu.jhu.tmaj.client.image.draw.RectangleDrawable
All Implemented Interfaces:
Drawable, java.io.Serializable
Direct Known Subclasses:
OvalDrawable

public class RectangleDrawable
extends AbstractDrawable
implements Drawable, java.io.Serializable

A rectangle

See Also:
Serialized Form

Field Summary
protected  int height
           
protected  int width
           
protected  int x
           
protected  int y
           
 
Fields inherited from class edu.jhu.tmaj.client.image.draw.AbstractDrawable
BLACK_SQUARE_SIZE, drawableLabel, isCompleted, MARGIN, userID
 
Constructor Summary
RectangleDrawable(DrawableLabel d)
           
 
Method Summary
protected  void callSuperDotDraw(java.awt.Graphics g)
           
 void createFromShapeRecord(ShapeRecord shapeRecord)
          Called from subclasses that override this method, this class only sets the shapeID variable
 void draw(java.awt.Graphics g)
          Sets the color and draws the black squares aroudn the Drawable
protected  Point[] getBlackSquares()
          Returns an empty array; This method is overwritten in subclasses
protected static java.awt.Rectangle getDrawableRectangle(java.awt.Rectangle currentRect)
           
 InsertSQL getInsertSQL(int scoredImageID)
          Returns a SQL statement to update an existing shape in the database.
protected  InsertSQL getInsertSQL(java.lang.String type, int scoredImageID)
           
 UpdateSQL getUpdateSQL()
          Returns a SQL statement to insert this shape into the database.
 void handleMouseDragged(java.awt.event.MouseEvent e)
          Moves the shape depending on difference between last point, if the user has finished drawing it.
 void handleMousePressed(java.awt.event.MouseEvent e)
          Registers tempX and tempX if moving is allowed
 boolean isValid()
          Returns true if the shape is "worth saving".
protected  void move(int xDiff, int yDiff)
          Moves the shape by adding xDiff and YDiff to it's current x and y, respectively.
 boolean shouldPointActivate(int xPos, int yPos)
          Returns true if the x and y are close enough to the border of the shape to "Select" the shape
 java.lang.String toString()
           
 
Methods inherited from class edu.jhu.tmaj.client.image.draw.AbstractDrawable
allowMoving, changeNormalStatusToModified, createNewShapeOnMousePress, drawBlackSquare, drawBlackSquares, getColor, getDrawingX, getDrawingY, getNormalX, getNormalY, getShapeID, getStatus, getUserID, handleKeyPressed, handleMouseReleased, isCompleted, isHighlighted, repaintDrawableLabel, setDrawableLabel, setIsCompleted, setIsHighlighted, setShapeID, setStatus, setUserID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.jhu.tmaj.client.image.draw.Drawable
createNewShapeOnMousePress, getShapeID, getStatus, handleKeyPressed, handleMouseReleased, isCompleted, isHighlighted, setIsCompleted, setIsHighlighted, setShapeID, setStatus, setUserID
 

Field Detail

x

protected int x

y

protected int y

width

protected int width

height

protected int height
Constructor Detail

RectangleDrawable

public RectangleDrawable(DrawableLabel d)
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

handleMousePressed

public void handleMousePressed(java.awt.event.MouseEvent e)
Description copied from class: AbstractDrawable
Registers tempX and tempX if moving is allowed

Specified by:
handleMousePressed in interface Drawable
Overrides:
handleMousePressed in class AbstractDrawable

handleMouseDragged

public void handleMouseDragged(java.awt.event.MouseEvent e)
Description copied from class: AbstractDrawable
Moves the shape depending on difference between last point, if the user has finished drawing it.

Specified by:
handleMouseDragged in interface Drawable
Overrides:
handleMouseDragged in class AbstractDrawable

move

protected void move(int xDiff,
                    int yDiff)
Description copied from class: AbstractDrawable
Moves the shape by adding xDiff and YDiff to it's current x and y, respectively.

Specified by:
move in class AbstractDrawable

callSuperDotDraw

protected void callSuperDotDraw(java.awt.Graphics g)

draw

public void draw(java.awt.Graphics g)
Description copied from class: AbstractDrawable
Sets the color and draws the black squares aroudn the Drawable

Specified by:
draw in interface Drawable
Overrides:
draw in class AbstractDrawable

getDrawableRectangle

protected static java.awt.Rectangle getDrawableRectangle(java.awt.Rectangle currentRect)

shouldPointActivate

public boolean shouldPointActivate(int xPos,
                                   int yPos)
Description copied from interface: Drawable
Returns true if the x and y are close enough to the border of the shape to "Select" the shape

Specified by:
shouldPointActivate in interface Drawable

createFromShapeRecord

public void createFromShapeRecord(ShapeRecord shapeRecord)
Description copied from class: AbstractDrawable
Called from subclasses that override this method, this class only sets the shapeID variable

Specified by:
createFromShapeRecord in interface Drawable
Overrides:
createFromShapeRecord in class AbstractDrawable

getInsertSQL

public InsertSQL getInsertSQL(int scoredImageID)
Description copied from class: AbstractDrawable
Returns a SQL statement to update an existing shape in the database.

Specified by:
getInsertSQL in interface Drawable
Specified by:
getInsertSQL in class AbstractDrawable

getInsertSQL

protected InsertSQL getInsertSQL(java.lang.String type,
                                 int scoredImageID)

getUpdateSQL

public UpdateSQL getUpdateSQL()
Description copied from class: AbstractDrawable
Returns a SQL statement to insert this shape into the database.

Specified by:
getUpdateSQL in interface Drawable
Specified by:
getUpdateSQL in class AbstractDrawable

isValid

public boolean isValid()
Description copied from interface: Drawable
Returns true if the shape is "worth saving". A line of zero length of text with 0 characters is not valid

Specified by:
isValid in interface Drawable

getBlackSquares

protected Point[] getBlackSquares()
Description copied from class: AbstractDrawable
Returns an empty array; This method is overwritten in subclasses

Overrides:
getBlackSquares in class AbstractDrawable