Back to index

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

A handle to connect figures. More...

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

List of all members.

Public Member Functions

 ConnectionHandle (Figure owner, Locator l, ConnectionFigure prototype)
 Constructs a handle with the given owner, locator, and connection prototype.
void invokeStart (int x, int y, DrawingView view)
 Creates the connection.
void invokeStep (int x, int y, int anchorX, int anchorY, DrawingView view)
 Tracks the connection.
void invokeEnd (int x, int y, int anchorX, int anchorY, DrawingView view)
 Connects the figures if the mouse is released over another figure.
void draw (Graphics g)
 Draws the connection handle, by default the outline of a blue circle.
Point locate ()
 Locates the handle on the figure by forwarding the request to its figure.
void invokeStart (int x, int y, Drawing drawing)
 @ deprecated As of version 4.1, use invokeStart(x, y, drawingView) Tracks the start of the interaction.
void invokeStep (int dx, int dy, Drawing drawing)
 @ deprecated As of version 4.1, use invokeStep(x, y, anchorX, anchorY, drawingView)
void invokeEnd (int dx, int dy, Drawing drawing)
Figure owner ()
 Gets the handle's owner.
Rectangle displayBox ()
 Gets the display box of the handle.
boolean containsPoint (int x, int y)
 Tests if a point is contained in the handle.

Static Public Attributes

static final int HANDLESIZE = 8
 The standard size of a handle.

Protected Member Functions

ConnectionFigure createConnection ()
 Creates the ConnectionFigure.
Connector findConnectionTarget (int x, int y, Drawing drawing)
 Finds a connection end figure.
Connector findConnector (int x, int y, Figure f)

Private Member Functions

Connector startConnector ()
Figure findConnectableFigure (int x, int y, Drawing drawing)

Private Attributes

ConnectionFigure fConnection
 the currently created connection
ConnectionFigure fPrototype
 the prototype of the connection to be created
Figure fTarget = null
 the current target

Detailed Description

A handle to connect figures.

The connection object to be created is specified by a prototype.


Design Patterns

 o

Prototype
ConnectionHandle creates the connection by cloning a prototype.


See also:
ConnectionFigure
Object::clone

Definition at line 27 of file ConnectionHandle.java.


Constructor & Destructor Documentation

CH.ifa.draw.standard.ConnectionHandle.ConnectionHandle ( Figure  owner,
Locator  l,
ConnectionFigure  prototype 
) [inline]

Constructs a handle with the given owner, locator, and connection prototype.

Definition at line 47 of file ConnectionHandle.java.

                                                                                 {
        super(owner, l);
        fPrototype = prototype;
    }

Member Function Documentation

boolean CH.ifa.draw.standard.AbstractHandle.containsPoint ( int  x,
int  y 
) [inline, inherited]

Tests if a point is contained in the handle.

Definition at line 124 of file AbstractHandle.java.

                                               {
        return displayBox().contains(x, y);
    }

Here is the call graph for this function:

ConnectionFigure CH.ifa.draw.standard.ConnectionHandle.createConnection ( ) [inline, protected]

Creates the ConnectionFigure.

By default the figure prototype is cloned.

Definition at line 112 of file ConnectionHandle.java.

                                                  {
              try {
                     return (ConnectionFigure)fPrototype.clone();
              } catch (Exception e) {}
              return null;
    }

Here is the caller graph for this function:

Rectangle CH.ifa.draw.standard.AbstractHandle.displayBox ( ) [inline, inherited]

Gets the display box of the handle.

Definition at line 112 of file AbstractHandle.java.

                                  {
        Point p = locate();
        return new Rectangle(
                p.x - HANDLESIZE / 2,
                p.y - HANDLESIZE / 2,
                HANDLESIZE,
                HANDLESIZE);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.standard.ConnectionHandle.draw ( Graphics  g) [inline]

Draws the connection handle, by default the outline of a blue circle.

Reimplemented from CH.ifa.draw.standard.AbstractHandle.

Definition at line 153 of file ConnectionHandle.java.

                                 {
        Rectangle r = displayBox();
        g.setColor(Color.blue);
        g.drawOval(r.x, r.y, r.width, r.height);
    }

Here is the call graph for this function:

Figure CH.ifa.draw.standard.ConnectionHandle.findConnectableFigure ( int  x,
int  y,
Drawing  drawing 
) [inline, private]

Definition at line 132 of file ConnectionHandle.java.

                                                                        {
        FigureEnumeration k = drawing.figuresReverse();
        while (k.hasMoreElements()) {
            Figure figure = k.nextFigure();
            if (!figure.includes(fConnection) && figure.canConnect()) {
                if (figure.containsPoint(x, y))
                    return figure;
            }
        }
        return null;
    }

Here is the caller graph for this function:

Connector CH.ifa.draw.standard.ConnectionHandle.findConnectionTarget ( int  x,
int  y,
Drawing  drawing 
) [inline, protected]

Finds a connection end figure.

Definition at line 122 of file ConnectionHandle.java.

                                                                            {
        Figure target = findConnectableFigure(x, y, drawing);
        if ((target != null) && target.canConnect()
             && !target.includes(owner())
             && fConnection.canConnect(owner(), target)) {
                return findConnector(x, y, target);
        }
        return null;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Connector CH.ifa.draw.standard.ConnectionHandle.findConnector ( int  x,
int  y,
Figure  f 
) [inline, protected]

Definition at line 144 of file ConnectionHandle.java.

                                                              {
        return f.connectorAt(x, y);
    }

Here is the caller graph for this function:

void CH.ifa.draw.standard.ConnectionHandle.invokeEnd ( int  x,
int  y,
int  anchorX,
int  anchorY,
DrawingView  view 
) [inline]

Connects the figures if the mouse is released over another figure.

Reimplemented from CH.ifa.draw.standard.AbstractHandle.

Definition at line 88 of file ConnectionHandle.java.

                                                                                    {
        Connector target = findConnectionTarget(x, y, view.drawing());
        if (target != null) {
            fConnection.connectStart(startConnector());
            fConnection.connectEnd(target);
            fConnection.updateConnection();
        } else
            view.drawing().remove(fConnection);
        fConnection = null;
        if (fTarget != null) {
            fTarget.connectorVisibility(false);
            fTarget = null;
        }
    }

Here is the call graph for this function:

void CH.ifa.draw.standard.AbstractHandle.invokeEnd ( int  dx,
int  dy,
Drawing  drawing 
) [inline, inherited]
Deprecated:
As of version 4.1, use invokeEnd(x, y, anchorX, anchorY, drawingView).

Tracks the end of the interaction.

Definition at line 100 of file AbstractHandle.java.

{ }
void CH.ifa.draw.standard.AbstractHandle.invokeStart ( int  x,
int  y,
Drawing  drawing 
) [inline, inherited]

@ deprecated As of version 4.1, use invokeStart(x, y, drawingView) Tracks the start of the interaction.

The default implementation does nothing.

Parameters:
xthe x position where the interaction started
ythe y position where the interaction started

Definition at line 47 of file AbstractHandle.java.

{ }

Here is the caller graph for this function:

void CH.ifa.draw.standard.ConnectionHandle.invokeStart ( int  x,
int  y,
DrawingView  view 
) [inline]

Creates the connection.

Reimplemented from CH.ifa.draw.standard.AbstractHandle.

Definition at line 55 of file ConnectionHandle.java.

                                                              {
        fConnection = createConnection();
        Point p = locate();
        fConnection.startPoint(p.x, p.y);
        fConnection.endPoint(p.x, p.y);
        view.drawing().add(fConnection);
    }

Here is the call graph for this function:

void CH.ifa.draw.standard.ConnectionHandle.invokeStep ( int  x,
int  y,
int  anchorX,
int  anchorY,
DrawingView  view 
) [inline]

Tracks the connection.

Reimplemented from CH.ifa.draw.standard.AbstractHandle.

Definition at line 66 of file ConnectionHandle.java.

                                                                                      {
        Point p = new Point(x,y);
        Figure f = findConnectableFigure(x, y, view.drawing());
        // track the figure containing the mouse
        if (f != fTarget) {
            if (fTarget != null)
                fTarget.connectorVisibility(false);
            fTarget = f;
            if (fTarget != null)
                fTarget.connectorVisibility(true);
        }

        Connector target = findConnectionTarget(p.x, p.y, view.drawing());
        if (target != null)
            p = Geom.center(target.displayBox());
        fConnection.endPoint(p.x, p.y);
    }

Here is the call graph for this function:

void CH.ifa.draw.standard.AbstractHandle.invokeStep ( int  dx,
int  dy,
Drawing  drawing 
) [inline, inherited]

@ deprecated As of version 4.1, use invokeStep(x, y, anchorX, anchorY, drawingView)

Tracks a step of the interaction.

Parameters:
dxx delta of this step
dyy delta of this step

Definition at line 70 of file AbstractHandle.java.

{ }

Here is the caller graph for this function:

Point CH.ifa.draw.standard.LocatorHandle.locate ( ) [inline, virtual, inherited]

Locates the handle on the figure by forwarding the request to its figure.

Implements CH.ifa.draw.standard.AbstractHandle.

Definition at line 34 of file LocatorHandle.java.

                          {
        return fLocator.locate(owner());
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Figure CH.ifa.draw.standard.AbstractHandle.owner ( ) [inline, inherited]

Gets the handle's owner.

Definition at line 105 of file AbstractHandle.java.

                          {
        return fOwner;
    }

Here is the caller graph for this function:

Definition at line 103 of file ConnectionHandle.java.

                                       {
        Point p = locate();
        return owner().connectorAt(p.x, p.y);
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

the currently created connection

Definition at line 32 of file ConnectionHandle.java.

the prototype of the connection to be created

Definition at line 37 of file ConnectionHandle.java.

the current target

Definition at line 42 of file ConnectionHandle.java.

final int CH.ifa.draw.standard.AbstractHandle.HANDLESIZE = 8 [static, inherited]

The standard size of a handle.

Definition at line 23 of file AbstractHandle.java.


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