Back to index

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

Tool to select and manipulate figures. More...

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

List of all members.

Public Member Functions

 SelectionTool (DrawingView view)
void mouseDown (MouseEvent e, int x, int y)
 Handles mouse down events and starts the corresponding tracker.
void mouseDrag (MouseEvent e, int x, int y)
 Handles mouse drag events.
void mouseUp (MouseEvent e, int x, int y)
 Handles mouse up events.
void activate ()
 Activates the tool for the given view.
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

Tool createHandleTracker (DrawingView view, Handle handle)
 Factory method to create a Handle tracker.
Tool createDragTracker (DrawingView view, Figure f)
 Factory method to create a Drag tracker.
Tool createAreaTracker (DrawingView view)
 Factory method to create an area tracker.

Protected Attributes

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

Package Attributes

int fAnchorY

Private Attributes

Tool fChild = null

Detailed Description

Tool to select and manipulate figures.

A selection tool is in one of three states, e.g., background selection, figure selection, handle manipulation. The different states are handled by different child tools.


Design Patterns

 o

State
SelectionTool is the StateContext and child is the State. The SelectionTool delegates state specific behavior to its current child tool.


Definition at line 28 of file SelectionTool.java.


Constructor & Destructor Documentation

CH.ifa.draw.standard.SelectionTool.SelectionTool ( DrawingView  view) [inline]

Definition at line 32 of file SelectionTool.java.

                                           {
        super(view);
    }

Member Function Documentation

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

Activates the tool for the given view.

This method is called whenever the user switches to this tool. Use this method to reinitialize a tool.

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

Definition at line 41 of file AbstractTool.java.

                           {
        fView.clearSelection();
    }
Tool CH.ifa.draw.standard.SelectionTool.createAreaTracker ( DrawingView  view) [inline, protected]

Factory method to create an area tracker.

It is used to select an area.

Definition at line 106 of file SelectionTool.java.

                                                       {
        return new SelectAreaTracker(view);
    }

Here is the caller graph for this function:

Tool CH.ifa.draw.standard.SelectionTool.createDragTracker ( DrawingView  view,
Figure  f 
) [inline, protected]

Factory method to create a Drag tracker.

It is used to drag a figure.

Definition at line 98 of file SelectionTool.java.

                                                                 {
        return new DragTracker(view, f);
    }

Here is the caller graph for this function:

Tool CH.ifa.draw.standard.SelectionTool.createHandleTracker ( DrawingView  view,
Handle  handle 
) [inline, protected]

Factory method to create a Handle tracker.

It is used to track a handle.

Definition at line 91 of file SelectionTool.java.

                                                                        {
        return new HandleTracker(view, handle);
    }

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.SelectionTool.mouseDown ( MouseEvent  e,
int  x,
int  y 
) [inline]

Handles mouse down events and starts the corresponding tracker.

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

Definition at line 39 of file SelectionTool.java.

    {
        // on Windows NT: AWT generates additional mouse down events
        // when the left button is down && right button is clicked.
        // To avoid dead locks we ignore such events
        if (fChild != null)
            return;

        view().freezeView();

        Handle handle = view().findHandle(e.getX(), e.getY());
        if (handle != null) {
            fChild = createHandleTracker(view(), handle);
        }
        else {
            Figure figure = drawing().findFigure(e.getX(), e.getY());
            if (figure != null) {
                fChild = createDragTracker(view(), figure);
            }
            else {
                if (!e.isShiftDown()) {
                    view().clearSelection();
                }
                fChild = createAreaTracker(view());
            }
        }
        fChild.mouseDown(e, x, y);
    }

Here is the call graph for this function:

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

Handles mouse drag events.

The events are forwarded to the current tracker.

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

Definition at line 72 of file SelectionTool.java.

                                                      {
        if (fChild != null) // JDK1.1 doesn't guarantee mouseDown, mouseDrag, mouseUp
            fChild.mouseDrag(e, 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.SelectionTool.mouseUp ( MouseEvent  e,
int  x,
int  y 
) [inline]

Handles mouse up events.

The events are forwarded to the current tracker.

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

Definition at line 81 of file SelectionTool.java.

                                                    {
        view().unfreezeView();
        if (fChild != null) // JDK1.1 doesn't guarantee mouseDown, mouseDrag, mouseUp
            fChild.mouseUp(e, x, y);
        fChild = null;
    }

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

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.

Definition at line 30 of file SelectionTool.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: