ach.vectorGraphics
Class GraphicEditor

java.lang.Object
  extended byach.vectorGraphics.GraphicEditor

public class GraphicEditor
extends java.lang.Object

AnnotationEditor.java
Copyright (c) 2004 Helge Hackbarth, All Rights Reserved.
A class to edit vector graphic objects.

THE AUTHOR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHOR SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.


Field Summary
 ach.vectorGraphics.Shape currentShape
          Generic Shape object pointing to current drawing shape
 ShapeProps currentShapeProps
          shape properties for current drawing mode
 int currentStampIdx
           
static int DISABLED
          Editing mode "disabled"
static int MEMOMODE
          Memo drawing mode
static int OVALMODE
          Oval (ellipse) drawing mode
static int POINTERMODE
          Pointer mode (objects can be marked, moved, deleted etc.)
static int POLYGONMODE
          Polygon / freehand drawing mode
static int RECTANGLEMODE
          Rectangle drawing mode
static int STAMPMODE
          Stamping mode
static int TEXTMODE
          text drawing mode
 
Constructor Summary
GraphicEditor(java.awt.Frame frame)
          Constructor
 
Method Summary
 int getMode()
          Get current drawing mode.
 ShapeList getShapeList()
          Get current list of shapes as ShapeList.
 Stamp[] getStamps()
          Get current stamps.
 boolean handleMouseDown(int x, int y, int modifiers, int clickCount, java.awt.Graphics g)
          Handle mouse down event.
 boolean handleMouseDrag(int oldx, int oldy, int newx, int newy, int modifiers, java.awt.Graphics g)
          Handle mouse drag event.
 boolean handleMouseUp(int x, int y, int modifiers, java.awt.Graphics g)
          Handle mouse up event.
 void requestShapeProps()
          Allow user to specify current shape properties interactively in a dialog.
 void setMode(int mode, java.awt.Graphics g)
          Set current drawing mode.
 void setShapeList(ShapeList sl)
          Set or replace current ShapeList.
 void setStamps(Stamp[] stamps)
          Set stamps.
 ach.vectorGraphics.Shape tagShape(int x, int y, boolean additivMode, java.awt.Graphics g)
          Find the topmost shape that contains the given point (the point with these coordinates is painted by the shape) and tag this shape depending on the tagmode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISABLED

public static final int DISABLED
Editing mode "disabled"

See Also:
Constant Field Values

POINTERMODE

public static final int POINTERMODE
Pointer mode (objects can be marked, moved, deleted etc.)

See Also:
Constant Field Values

RECTANGLEMODE

public static final int RECTANGLEMODE
Rectangle drawing mode

See Also:
Constant Field Values

OVALMODE

public static final int OVALMODE
Oval (ellipse) drawing mode

See Also:
Constant Field Values

POLYGONMODE

public static final int POLYGONMODE
Polygon / freehand drawing mode

See Also:
Constant Field Values

MEMOMODE

public static final int MEMOMODE
Memo drawing mode

See Also:
Constant Field Values

TEXTMODE

public static final int TEXTMODE
text drawing mode

See Also:
Constant Field Values

STAMPMODE

public static final int STAMPMODE
Stamping mode

See Also:
Constant Field Values

currentShapeProps

public ShapeProps currentShapeProps
shape properties for current drawing mode


currentShape

public ach.vectorGraphics.Shape currentShape
Generic Shape object pointing to current drawing shape


currentStampIdx

public int currentStampIdx
Constructor Detail

GraphicEditor

public GraphicEditor(java.awt.Frame frame)
Constructor

Parameters:
frame - parent frame (referenced by pop up dialogs)
Method Detail

setShapeList

public void setShapeList(ShapeList sl)
Set or replace current ShapeList.

Parameters:
sl - a ShapeList that contains shapes to be drawn and edited

getShapeList

public ShapeList getShapeList()
Get current list of shapes as ShapeList.

Returns:
ShapeList containing the current list of shapes.

setStamps

public void setStamps(Stamp[] stamps)
Set stamps.

Parameters:
stamps - an array of Stamp objects.

getStamps

public Stamp[] getStamps()
Get current stamps.

Returns:
Stamp[] array of Stamp objects.

setMode

public void setMode(int mode,
                    java.awt.Graphics g)
Set current drawing mode.


getMode

public int getMode()
Get current drawing mode.

Returns:
drawing mode.

requestShapeProps

public void requestShapeProps()
Allow user to specify current shape properties interactively in a dialog.


tagShape

public ach.vectorGraphics.Shape tagShape(int x,
                                         int y,
                                         boolean additivMode,
                                         java.awt.Graphics g)
Find the topmost shape that contains the given point (the point with these coordinates is painted by the shape) and tag this shape depending on the tagmode

Parameters:
x - x-coordinate of the point to be checked which shape contains it
y - y-coordinate of the point to be checked which shape contains it
additivMode - specifies if the shape should be added to a list of already tagged shapes
g - Graphics context where the tagged shapes should be marked as tagged
Returns:
Shape that was marked or null if no containing shape was found

handleMouseDown

public boolean handleMouseDown(int x,
                               int y,
                               int modifiers,
                               int clickCount,
                               java.awt.Graphics g)
Handle mouse down event.

Parameters:
x - coordinate of mouse position
y - coordinate of mouse position
modifiers - current state of modifiers (Shift-/Control-/Alt-Key)
clickCount - to distinguish between single and double click
g - Graphics context for drawing operations

handleMouseDrag

public boolean handleMouseDrag(int oldx,
                               int oldy,
                               int newx,
                               int newy,
                               int modifiers,
                               java.awt.Graphics g)
Handle mouse drag event.

Parameters:
oldx - coordinate of previous mouse position
oldy - coordinate of previous mouse position
newx - coordinate of current mouse position
newy - coordinate of current mouse position
modifiers - current state of modifiers (Shift-/Control-/Alt-Key)
g - Graphics context for drawing operations

handleMouseUp

public boolean handleMouseUp(int x,
                             int y,
                             int modifiers,
                             java.awt.Graphics g)
Handle mouse up event.

Parameters:
x - coordinate of mouse position
y - coordinate of mouse position
modifiers - current state of modifiers (Shift-/Control-/Alt-Key)
g - Graphics context for drawing operations