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

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

public abstract class AbstractDrawable
extends java.lang.Object
implements java.io.Serializable

All shapes drawn onto a DrawableLabel extend this class

See Also:
Serialized Form

Field Summary
protected static int BLACK_SQUARE_SIZE
          The size of the black squares that are drawn around an image when it's selected
protected  DrawableLabel drawableLabel
           
protected  boolean isCompleted
           
static int MARGIN
          Specifies how close a mouse click must be to an shapes border for the program to select the shape
protected  int userID
           
 
Constructor Summary
AbstractDrawable(DrawableLabel d)
           
 
Method Summary
protected  boolean allowMoving()
          Returns true if user has completed drawing the shape
protected  void changeNormalStatusToModified()
          Indicate user has modified an existing shape in the database
 void createFromShapeRecord(ShapeRecord shapeRecord)
          Called from subclasses that override this method, this class only sets the shapeID variable
 boolean createNewShapeOnMousePress()
          Returns true
 void draw(java.awt.Graphics g)
          Sets the color and draws the black squares aroudn the Drawable
protected static void drawBlackSquare(java.awt.Graphics g, int x, int y)
          Draws a black square of size BLACK_SQUARE_SIZE at position (x,y)
protected  void drawBlackSquares(java.awt.Graphics g, Point[] points)
          Draws black squares around the shape (indicates the shape has been selected)
protected  Point[] getBlackSquares()
          Returns an empty array; This method is overwritten in subclasses
protected  java.awt.Color getColor()
          Returns the color in which the drawable will be painted
protected  int getDrawingX(int x)
          Gets the X that should be drawn onto the label using the g.drawXXX, given the X in the database
protected  int getDrawingY(int y)
           
abstract  InsertSQL getInsertSQL(int scoredImageID)
          Returns a SQL statement to update an existing shape in the database.
protected  int getNormalX(int x)
          Gets the X that should be stored into the database, given the X that has been generated by a mouseEvent
protected  int getNormalY(int y)
           
 int getShapeID()
          Gets the unique ShapeID of this shape in the database table Shapes
 DrawableStatus getStatus()
          Returns the status of this shape, e.g.
abstract  UpdateSQL getUpdateSQL()
          Returns a SQL statement to insert this shape into the database.
 int getUserID()
          Returns the UserID of the person drawing this shape
 void handleKeyPressed(java.awt.event.KeyEvent e)
          Does nothing.
 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
 void handleMouseReleased(java.awt.event.MouseEvent e)
          Indicate the user has finished drawing the shape
 boolean isCompleted()
          Returns true if the user is finished drawing the shape
 boolean isHighlighted()
          Returns true if the drawable is selected
protected abstract  void move(int xDiff, int yDiff)
          Moves the shape by adding xDiff and YDiff to it's current x and y, respectively.
protected  void repaintDrawableLabel()
           
 void setDrawableLabel(DrawableLabel label)
          Sets the DrawableLabel on which this shape is being drawn
 void setIsCompleted(boolean b)
          Sets whether the user has finished drawing the shape
 void setIsHighlighted(boolean b)
           
 void setShapeID(int i)
          Sets the unique ShapeID of this shape in the database table Shapes
 void setStatus(DrawableStatus i)
           
 void setUserID(int i)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isCompleted

protected boolean isCompleted

userID

protected transient int userID

drawableLabel

protected transient DrawableLabel drawableLabel

MARGIN

public static final int MARGIN
Specifies how close a mouse click must be to an shapes border for the program to select the shape

See Also:
Constant Field Values

BLACK_SQUARE_SIZE

protected static final int BLACK_SQUARE_SIZE
The size of the black squares that are drawn around an image when it's selected

See Also:
Constant Field Values
Constructor Detail

AbstractDrawable

public AbstractDrawable(DrawableLabel d)
Method Detail

repaintDrawableLabel

protected void repaintDrawableLabel()

getUpdateSQL

public abstract UpdateSQL getUpdateSQL()
Returns a SQL statement to insert this shape into the database.


getInsertSQL

public abstract InsertSQL getInsertSQL(int scoredImageID)
Returns a SQL statement to update an existing shape in the database.


move

protected abstract void move(int xDiff,
                             int yDiff)
Moves the shape by adding xDiff and YDiff to it's current x and y, respectively.


isHighlighted

public boolean isHighlighted()
Returns true if the drawable is selected


setIsHighlighted

public void setIsHighlighted(boolean b)

getColor

protected java.awt.Color getColor()
Returns the color in which the drawable will be painted


draw

public void draw(java.awt.Graphics g)
Sets the color and draws the black squares aroudn the Drawable


getBlackSquares

protected Point[] getBlackSquares()
Returns an empty array; This method is overwritten in subclasses


getStatus

public DrawableStatus getStatus()
Returns the status of this shape, e.g. DrawableStatus.CREATE


setStatus

public void setStatus(DrawableStatus i)

getShapeID

public int getShapeID()
Gets the unique ShapeID of this shape in the database table Shapes


setShapeID

public void setShapeID(int i)
Sets the unique ShapeID of this shape in the database table Shapes


createFromShapeRecord

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


getNormalX

protected int getNormalX(int x)
Gets the X that should be stored into the database, given the X that has been generated by a mouseEvent


getNormalY

protected int getNormalY(int y)

getDrawingX

protected int getDrawingX(int x)
Gets the X that should be drawn onto the label using the g.drawXXX, given the X in the database


getDrawingY

protected int getDrawingY(int y)

setDrawableLabel

public void setDrawableLabel(DrawableLabel label)
Sets the DrawableLabel on which this shape is being drawn


drawBlackSquares

protected void drawBlackSquares(java.awt.Graphics g,
                                Point[] points)
Draws black squares around the shape (indicates the shape has been selected)


drawBlackSquare

protected static void drawBlackSquare(java.awt.Graphics g,
                                      int x,
                                      int y)
Draws a black square of size BLACK_SQUARE_SIZE at position (x,y)


isCompleted

public boolean isCompleted()
Returns true if the user is finished drawing the shape


setIsCompleted

public void setIsCompleted(boolean b)
Sets whether the user has finished drawing the shape


handleMousePressed

public void handleMousePressed(java.awt.event.MouseEvent e)
Registers tempX and tempX if moving is allowed


handleMouseDragged

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


changeNormalStatusToModified

protected void changeNormalStatusToModified()
Indicate user has modified an existing shape in the database


allowMoving

protected boolean allowMoving()
Returns true if user has completed drawing the shape


handleMouseReleased

public void handleMouseReleased(java.awt.event.MouseEvent e)
Indicate the user has finished drawing the shape


handleKeyPressed

public void handleKeyPressed(java.awt.event.KeyEvent e)
Does nothing. Overwritten in the TextDrawable class


createNewShapeOnMousePress

public boolean createNewShapeOnMousePress()
Returns true


getUserID

public int getUserID()
Returns the UserID of the person drawing this shape


setUserID

public void setUserID(int i)