DrawableSurface
Class PaintSurface

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--DrawableSurface.DrawableSurface
                    |
                    +--DrawableSurface.PaintSurface

public class PaintSurface
extends DrawableSurface
implements MouseListener, MouseMotionListener

This class defines a surface on which a user can draw forms and can manipulate them.

Version:
1.0
Author:
Sebastien Baehni
See Also:
Serialized Form

Field Summary
protected  Point circleCenter
          We keep in memory the first click of the user.
protected  FormsAdministrator formsAdministrator
          Administrator for the texture.
protected  FormsMakerPanel formsMakerPanel
          We must take the different parameters the user specified (texture, color, type of forms).
protected  int indexCircleChoosen
          We keep in mind if the user has clicked on a circle.
protected  int indexPolygonChoosen
          We keep in mind if the user has clicked on a polygon.
protected  int indexRectangleChoosen
          We keep in mind if the user has clicked on a rectangle.
protected  int numberOfClicks
          This variable is very useful for drawing a polygon.
protected  Point rectangleFirstPoint
          We keep in memory the first click of the user.
protected  TextureAdministrator textureAdministrator
          Administrator for the texture.
protected  ToolPanel toolPanel
          This is the panel on which we can give some explanation about what the user must do.
 
Fields inherited from class DrawableSurface.DrawableSurface
animatedImage, height, painted, width
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
PaintSurface(int width, int height)
          A second constructor.
PaintSurface(int width, int height, Color backgroundColor)
          The first constructor.
 
Method Summary
 void init(ToolPanel toolPanel, FormsMakerPanel formsMakerPanel)
          Initialisation of the paintSurface.
 void mouseClicked(MouseEvent e)
          When the user clicked on the area.
 void mouseDragged(MouseEvent e)
          When the mouse is dragged.
 void mouseEntered(MouseEvent e)
          When the mouse enters the area.
 void mouseExited(MouseEvent e)
          When the mouse exits the area.
 void mouseMoved(MouseEvent e)
          When the mouse is moved on the area.
 void mousePressed(MouseEvent e)
          When the mouse is pressed.
 void mouseReleased(MouseEvent e)
          When the mouse is released.
 boolean negativeChoosen()
          Test if the user has choosen the negative image or not.
 
Methods inherited from class DrawableSurface.DrawableSurface
animatedImage, eraseSurface, height, paint, start, update, width
 
Methods inherited from class java.awt.Canvas
addNotify
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

toolPanel

protected ToolPanel toolPanel
This is the panel on which we can give some explanation about what the user must do.

formsMakerPanel

protected FormsMakerPanel formsMakerPanel
We must take the different parameters the user specified (texture, color, type of forms).

formsAdministrator

protected FormsAdministrator formsAdministrator
Administrator for the texture.
See Also:
FormsAdministrator

textureAdministrator

protected TextureAdministrator textureAdministrator
Administrator for the texture.
See Also:
TextureAdministrator

circleCenter

protected Point circleCenter
We keep in memory the first click of the user. This is center of a circle.

rectangleFirstPoint

protected Point rectangleFirstPoint
We keep in memory the first click of the user. This is the corner of a rectange.

numberOfClicks

protected int numberOfClicks
This variable is very useful for drawing a polygon. We can also change the help message with this variable. When the user has clicked once to specify the center of a circle (by exemple) the help message change.

indexCircleChoosen

protected int indexCircleChoosen
We keep in mind if the user has clicked on a circle.

indexRectangleChoosen

protected int indexRectangleChoosen
We keep in mind if the user has clicked on a rectangle.

indexPolygonChoosen

protected int indexPolygonChoosen
We keep in mind if the user has clicked on a polygon.
Constructor Detail

PaintSurface

public PaintSurface(int width,
                    int height,
                    Color backgroundColor)
The first constructor.
Parameters:
width - The width of our PaintSurface.
height - The height of our PaintSurface.
backgroundColor - The background color of our PaintSurface.

PaintSurface

public PaintSurface(int width,
                    int height)
A second constructor. The background color is white.
Parameters:
width - The width of our PaintSurface.
height - The height of our PaintSurface.
Method Detail

init

public void init(ToolPanel toolPanel,
                 FormsMakerPanel formsMakerPanel)
Initialisation of the paintSurface.
Parameters:
toolPanel - The panel on which we are going to display help messages.
formsMakerPanel - That panel is going to give us the information about waht the user want to do.

negativeChoosen

public boolean negativeChoosen()
Test if the user has choosen the negative image or not.
Returns:
True if the negative image has been choosen.

mousePressed

public void mousePressed(MouseEvent e)
When the mouse is pressed.
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
When the mouse is released.
Specified by:
mouseReleased in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
When the mouse enters the area.
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
When the mouse exits the area.
Specified by:
mouseExited in interface MouseListener

mouseClicked

public void mouseClicked(MouseEvent e)
When the user clicked on the area.
Specified by:
mouseClicked in interface MouseListener

mouseDragged

public void mouseDragged(MouseEvent e)
When the mouse is dragged.
Specified by:
mouseDragged in interface MouseMotionListener

mouseMoved

public void mouseMoved(MouseEvent e)
When the mouse is moved on the area.
Specified by:
mouseMoved in interface MouseMotionListener