Back to index

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

SelectAreaTracker implements a rubberband selection of an area. More...

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

List of all members.

Public Member Functions

 SelectAreaTracker (DrawingView view)
void mouseDown (MouseEvent e, int x, int y)
 Handles mouse down events in the drawing view.
void mouseDrag (MouseEvent e, int x, int y)
 Handles mouse drag events in the drawing view.
void mouseUp (MouseEvent e, int x, int y)
 Handles mouse up in the drawing view.
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 Attributes

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

Package Attributes

int fAnchorY

Private Member Functions

void rubberBand (int x1, int y1, int x2, int y2)
void eraseRubberBand ()
void drawXORRect (Rectangle r)
void selectGroup (boolean toggle)

Private Attributes

Rectangle fSelectGroup

Detailed Description

SelectAreaTracker implements a rubberband selection of an area.

Definition at line 16 of file SelectAreaTracker.java.


Constructor & Destructor Documentation

Definition at line 20 of file SelectAreaTracker.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();
    }
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:

void CH.ifa.draw.standard.SelectAreaTracker.drawXORRect ( Rectangle  r) [inline, private]

Definition at line 55 of file SelectAreaTracker.java.

    {
        Graphics g = view().getGraphics();
        g.setXORMode(view().getBackground());
        g.setColor(Color.black);
        g.drawRect(r.x, r.y, r.width, r.height);
    }

Here is the call graph for this function:

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:

Definition at line 50 of file SelectAreaTracker.java.

Here is the call graph for this function:

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

Handles mouse down events in the drawing view.

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

Definition at line 24 of file SelectAreaTracker.java.

                                                      {
        // use event coordinates to supress any kind of
        // transformations like constraining points to a grid
        super.mouseDown(e, e.getX(), e.getY());
        rubberBand(fAnchorX, fAnchorY, fAnchorX, fAnchorY);
    }

Here is the call graph for this function:

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

Handles mouse drag events in the drawing view.

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

Definition at line 31 of file SelectAreaTracker.java.

                                                      {
        super.mouseDrag(e, x, y);
        eraseRubberBand();
        rubberBand(fAnchorX, fAnchorY, x, y);
    }

Here is the call graph for this function:

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

Handles mouse up in the drawing view.

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

Definition at line 37 of file SelectAreaTracker.java.

                                                    {
        super.mouseUp(e, x, y);
        eraseRubberBand();
        selectGroup(e.isShiftDown());
    }

Here is the call graph for this function:

void CH.ifa.draw.standard.SelectAreaTracker.rubberBand ( int  x1,
int  y1,
int  x2,
int  y2 
) [inline, private]

Definition at line 43 of file SelectAreaTracker.java.

    {
        fSelectGroup = new Rectangle(new Point(x1, y1));
        fSelectGroup.add(new Point(x2, y2));
        drawXORRect(fSelectGroup);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.standard.SelectAreaTracker.selectGroup ( boolean  toggle) [inline, private]

Definition at line 63 of file SelectAreaTracker.java.

    {
        FigureEnumeration k = drawing().figuresReverse();
        while (k.hasMoreElements()) {
            Figure figure = k.nextFigure();
            Rectangle r2 = figure.displayBox();
            if (fSelectGroup.contains(r2.x, r2.y) && fSelectGroup.contains(r2.x+r2.width, r2.y+r2.height)) {
                if (toggle)
                    view().toggleSelection(figure);
                else
                    view().addToSelection(figure);
            }
        }
    }

Here is the call graph for this function:

Here is the caller 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 18 of file SelectAreaTracker.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: