Back to index

moin  1.9.0~rc2
Public Member Functions | Protected Member Functions | Protected Attributes | Package Attributes | Private Attributes
CH.ifa.draw.standard.CreationTool Class Reference

A tool to create new figures. More...

Inheritance diagram for CH.ifa.draw.standard.CreationTool:
Inheritance graph
[legend]
Collaboration diagram for CH.ifa.draw.standard.CreationTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CreationTool (DrawingView view, Figure prototype)
 Initializes a CreationTool with the given prototype.
void activate ()
 Sets the cross hair cursor.
void mouseDown (MouseEvent e, int x, int y)
 Creates a new figure by cloning the prototype.
void mouseDrag (MouseEvent e, int x, int y)
 Adjusts the extent of the created figure.
void mouseUp (MouseEvent e, int x, int y)
 Checks if the created figure is empty.
void deactivate ()
 Deactivates the tool.
void mouseMove (MouseEvent evt, int x, int y)
 Handles mouse moves (if the mouse button is up).
void keyDown (KeyEvent evt, int key)
 Handles key down events in the drawing view.
Drawing drawing ()
 Gets the tool's drawing.
DrawingEditor editor ()
 Gets the tool's editor.
DrawingView view ()
 Gets the tool's view.

Protected Member Functions

 CreationTool (DrawingView view)
 Constructs a CreationTool without a prototype.
Figure createFigure ()
 Creates a new figure by cloning the prototype.
Figure createdFigure ()
 Gets the currently created figure.

Protected Attributes

DrawingView fView
int fAnchorX
 The position of the initial mouse down.

Package Attributes

int fAnchorY

Private Attributes

Point fAnchorPoint
 the anchor point of the interaction
Figure fCreatedFigure
 the currently created figure
Figure fPrototype
 the prototypical figure that is used to create new figures.

Detailed Description

A tool to create new figures.

The figure to be created is specified by a prototype.


Design Patterns

 o

Prototype
CreationTool creates new figures by cloning a prototype.


See also:
Figure
Object::clone

Definition at line 28 of file CreationTool.java.


Constructor & Destructor Documentation

CH.ifa.draw.standard.CreationTool.CreationTool ( DrawingView  view,
Figure  prototype 
) [inline]

Initializes a CreationTool with the given prototype.

Definition at line 49 of file CreationTool.java.

                                                            {
        super(view);
        fPrototype = prototype;
    }
CH.ifa.draw.standard.CreationTool.CreationTool ( DrawingView  view) [inline, protected]

Constructs a CreationTool without a prototype.

This is for subclassers overriding createFigure.

Definition at line 58 of file CreationTool.java.

                                             {
        super(view);
        fPrototype = null;
    }

Member Function Documentation

Sets the cross hair cursor.

Reimplemented from CH.ifa.draw.standard.AbstractTool.

Definition at line 66 of file CreationTool.java.

                           {
        view().setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
    }

Here is the call graph for this function:

Figure CH.ifa.draw.standard.CreationTool.createdFigure ( ) [inline, protected]

Gets the currently created figure.

Definition at line 111 of file CreationTool.java.

                                     {
        return fCreatedFigure;
    }
Figure CH.ifa.draw.standard.CreationTool.createFigure ( ) [inline, protected]

Creates a new figure by cloning the prototype.

Definition at line 83 of file CreationTool.java.

                                    {
        if (fPrototype == null)
                  throw new HJDError("No protoype defined");
        return (Figure) fPrototype.clone();
    }

Here is the caller graph for this function:

void CH.ifa.draw.standard.AbstractTool.deactivate ( ) [inline, inherited]

Deactivates the tool.

This method is called whenever the user switches to another tool. Use this method to do some clean-up when the tool is switched. Subclassers should always call super.deactivate.

Reimplemented in CH.ifa.draw.standard.ConnectionTool, and CH.ifa.draw.figures.ScribbleTool.

Definition at line 51 of file AbstractTool.java.

                             {
        fView.setCursor(Cursor.getDefaultCursor());
    }
Drawing CH.ifa.draw.standard.AbstractTool.drawing ( ) [inline, inherited]

Gets the tool's drawing.

Definition at line 90 of file AbstractTool.java.

                             {
        return fView.drawing();
    }

Here is the caller graph for this function:

DrawingEditor CH.ifa.draw.standard.AbstractTool.editor ( ) [inline, inherited]

Gets the tool's editor.

Definition at line 97 of file AbstractTool.java.

                                  {
        return fView.editor();
    }

Here is the caller graph for this function:

void CH.ifa.draw.standard.AbstractTool.keyDown ( KeyEvent  evt,
int  key 
) [inline, inherited]

Handles key down events in the drawing view.

Definition at line 84 of file AbstractTool.java.

                                               {
    }
void CH.ifa.draw.standard.CreationTool.mouseDown ( MouseEvent  e,
int  x,
int  y 
) [inline]

Creates a new figure by cloning the prototype.

Reimplemented from CH.ifa.draw.standard.AbstractTool.

Definition at line 73 of file CreationTool.java.

Here is the call graph for this function:

void CH.ifa.draw.standard.CreationTool.mouseDrag ( MouseEvent  e,
int  x,
int  y 
) [inline]

Adjusts the extent of the created figure.

Reimplemented from CH.ifa.draw.standard.AbstractTool.

Definition at line 92 of file CreationTool.java.

                                                      {
        fCreatedFigure.displayBox(fAnchorPoint, new Point(x,y));
    }
void CH.ifa.draw.standard.AbstractTool.mouseMove ( MouseEvent  evt,
int  x,
int  y 
) [inline, inherited]

Handles mouse moves (if the mouse button is up).

Reimplemented in CH.ifa.draw.standard.ConnectionTool.

Definition at line 78 of file AbstractTool.java.

                                                        {
    }
void CH.ifa.draw.standard.CreationTool.mouseUp ( MouseEvent  e,
int  x,
int  y 
) [inline]

Checks if the created figure is empty.

If it is, the figure is removed from the drawing.

See also:
Figure::isEmpty

Reimplemented from CH.ifa.draw.standard.AbstractTool.

Definition at line 101 of file CreationTool.java.

                                                    {
        if (fCreatedFigure.isEmpty())
            drawing().remove(fCreatedFigure);
        fCreatedFigure = null;
        editor().toolDone();
    }

Here is the call graph for this function:

DrawingView CH.ifa.draw.standard.AbstractTool.view ( ) [inline, inherited]

Gets the tool's view.

Definition at line 104 of file AbstractTool.java.

                              {
        return fView;
    }

Here is the caller graph for this function:


Member Data Documentation

the anchor point of the interaction

Definition at line 33 of file CreationTool.java.

int CH.ifa.draw.standard.AbstractTool.fAnchorX [protected, inherited]

The position of the initial mouse down.

Definition at line 27 of file AbstractTool.java.

Definition at line 27 of file AbstractTool.java.

the currently created figure

Definition at line 38 of file CreationTool.java.

the prototypical figure that is used to create new figures.

Definition at line 43 of file CreationTool.java.

DrawingView CH.ifa.draw.standard.AbstractTool.fView [protected, inherited]

Definition at line 22 of file AbstractTool.java.


The documentation for this class was generated from the following file: