Back to index

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

AbstractFigure provides default implementations for the Figure interface. More...

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

List of all members.

Public Member Functions

void moveBy (int dx, int dy)
 Moves the figure by the given offset.
void displayBox (Point origin, Point corner)
 Changes the display box of a figure.
abstract void basicDisplayBox (Point origin, Point corner)
 Sets the display box of a figure.
abstract Rectangle displayBox ()
 Gets the display box of a figure.
abstract Vector handles ()
 Returns the handles of a Figure that can be used to manipulate some of its attributes.
FigureEnumeration figures ()
 Returns an Enumeration of the figures contained in this figure.
Dimension size ()
 Gets the size of the figure.
boolean isEmpty ()
 Checks if the figure is empty.
Figure findFigureInside (int x, int y)
 Returns the figure that contains the given point.
boolean containsPoint (int x, int y)
 Checks if a point is inside the figure.
void displayBox (Rectangle r)
 Changes the display box of a figure.
boolean includes (Figure figure)
 Checks whether the given figure is contained in this figure.
FigureEnumeration decompose ()
 Decomposes a figure into its parts.
void addToContainer (FigureChangeListener c)
 Sets the Figure's container and registers the container as a figure change listener.
void removeFromContainer (FigureChangeListener c)
 Removes a figure from the given container and unregisters it as a change listener.
void addFigureChangeListener (FigureChangeListener l)
 Adds a listener for this figure.
void removeFigureChangeListener (FigureChangeListener l)
 Removes a listener for this figure.
FigureChangeListener listener ()
 Gets the figure's listners.
void release ()
 A figure is released from the drawing.
void invalidate ()
 Invalidates the figure.
void willChange ()
 Informes that a figure is about to change something that affects the contents of its display box.
void changed ()
 Informs that a figure changed the area of its display box.
Point center ()
 Gets the center of a figure.
boolean canConnect ()
 Checks if this figure can be connected.
Insets connectionInsets ()
 Returns the connection inset.
Connector connectorAt (int x, int y)
 Returns the Figures connector for the specified location.
void connectorVisibility (boolean isVisible)
 Sets whether the connectors should be visible.
Locator connectedTextLocator (Figure text)
 Returns the locator used to located connected text.
Object defaultAttribute (String name)
 Gets a the default value for a named attribute.
Object getAttribute (String name)
 Returns the named attribute or null if a a figure doesn't have an attribute.
void setAttribute (String name, Object value)
 Sets the named attribute to the new value.
Object clone ()
 Clones a figure.
void write (StorableOutput dw)
 Stores the Figure to a StorableOutput.
void read (StorableInput dr) throws IOException
 Reads the Figure from a StorableInput.

Protected Member Functions

 AbstractFigure ()
abstract void basicMoveBy (int dx, int dy)
 Moves the figure.

Static Protected Attributes

static Font dialogFont = Font.decode("dialog-PLAIN-12")

Private Attributes

FigureAttributes fAttributes
 The attributes of a figure.
transient FigureChangeListener fListener
 The listeners for a figure's changes.
int abstractFigureSerializedDataVersion = 1

Static Private Attributes

static final long serialVersionUID = -10857585979273442L

Detailed Description

AbstractFigure provides default implementations for the Figure interface.


Design Patterns

 o

Template Method
Template Methods implement default and invariant behavior for figure subclasses.


See also:
Figure
Handle

Definition at line 31 of file AbstractFigure.java.


Constructor & Destructor Documentation

Definition at line 58 of file AbstractFigure.java.

{ }

Member Function Documentation

void CH.ifa.draw.standard.AbstractFigure.addFigureChangeListener ( FigureChangeListener  l) [inline]

Adds a listener for this figure.

Definition at line 211 of file AbstractFigure.java.

                                                                {
        fListener = FigureChangeEventMulticaster.add(fListener, l);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.standard.AbstractFigure.addToContainer ( FigureChangeListener  c) [inline]

Sets the Figure's container and registers the container as a figure change listener.

A figure's container can be any kind of FigureChangeListener. A figure is not restricted to have a single container.

Definition at line 193 of file AbstractFigure.java.

Here is the call graph for this function:

abstract void CH.ifa.draw.standard.AbstractFigure.basicDisplayBox ( Point  origin,
Point  corner 
) [pure virtual]

Sets the display box of a figure.

This is the method that subclassers override. Clients usually call displayBox.

See also:
displayBox

Implemented in CH.ifa.draw.standard.StandardDrawing, and CH.ifa.draw.standard.DecoratorFigure.

Here is the caller graph for this function:

abstract void CH.ifa.draw.standard.AbstractFigure.basicMoveBy ( int  dx,
int  dy 
) [protected, pure virtual]

Moves the figure.

This is the method that subclassers override. Clients usually call displayBox.

See also:
moveBy

Implemented in CH.ifa.draw.standard.CompositeFigure, and CH.ifa.draw.standard.DecoratorFigure.

Here is the caller graph for this function:

Checks if this figure can be connected.

By default AbstractFigures can be connected.

Reimplemented in CH.ifa.draw.standard.DecoratorFigure.

Definition at line 287 of file AbstractFigure.java.

                                {
        return true;
    }

Gets the center of a figure.

A convenice method that is rarely overridden.

Definition at line 279 of file AbstractFigure.java.

                          {
        return Geom.center(displayBox());
    }

Here is the call graph for this function:

Informs that a figure changed the area of its display box.

See also:
FigureChangeEvent
Figure::changed

Definition at line 268 of file AbstractFigure.java.

                          {
        invalidate();
        if (fListener != null)
            fListener.figureChanged(new FigureChangeEvent(this));

    }

Here is the call graph for this function:

Here is the caller graph for this function:

Clones a figure.

Creates a clone by using the storable mechanism to flatten the Figure to stream followed by resurrecting it from the same stream.

See also:
Figure::clone

Definition at line 364 of file AbstractFigure.java.

                          {
        Object clone = null;
        ByteArrayOutputStream output = new ByteArrayOutputStream(200);
        try {
            ObjectOutput writer = new ObjectOutputStream(output);
            writer.writeObject(this);
            writer.close();
        } catch (IOException e) {
            System.out.println("Class not found: " + e);
        }

        InputStream input = new ByteArrayInputStream(output.toByteArray());
        try {
            ObjectInput reader = new ObjectInputStream(input);
            clone = (Object) reader.readObject();
        } catch (IOException e) {
            System.out.println(e.toString());
        }
        catch (ClassNotFoundException e) {
            System.out.println("Class not found: " + e);
        }
        return clone;
    }

Returns the locator used to located connected text.

Reimplemented in CH.ifa.draw.standard.DecoratorFigure.

Definition at line 321 of file AbstractFigure.java.

                                                     {
        return RelativeLocator.center();
    }

Here is the call graph for this function:

Returns the connection inset.

The connection inset defines the area where the display box of a figure can't be connected. By default the entire display box can be connected.

Reimplemented in CH.ifa.draw.standard.DecoratorFigure.

Definition at line 298 of file AbstractFigure.java.

                                     {
        return new Insets(0, 0, 0, 0);
    }
Connector CH.ifa.draw.standard.AbstractFigure.connectorAt ( int  x,
int  y 
) [inline]

Returns the Figures connector for the specified location.

By default a ChopBoxConnector is returned.

See also:
ChopBoxConnector

Reimplemented in CH.ifa.draw.standard.DecoratorFigure.

Definition at line 307 of file AbstractFigure.java.

                                               {
        return new ChopBoxConnector(this);
    }
void CH.ifa.draw.standard.AbstractFigure.connectorVisibility ( boolean  isVisible) [inline]

Sets whether the connectors should be visible.

By default they are not visible and

Reimplemented in CH.ifa.draw.standard.DecoratorFigure.

Definition at line 315 of file AbstractFigure.java.

                                                       {
    }
boolean CH.ifa.draw.standard.AbstractFigure.containsPoint ( int  x,
int  y 
) [inline]

Checks if a point is inside the figure.

Reimplemented in CH.ifa.draw.standard.DecoratorFigure.

Definition at line 154 of file AbstractFigure.java.

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

Here is the call graph for this function:

Here is the caller graph for this function:

FigureEnumeration CH.ifa.draw.standard.AbstractFigure.decompose ( ) [inline]

Decomposes a figure into its parts.

It returns a Vector that contains itself.

Returns:
an Enumeration for a Vector with itself as the only element.

Reimplemented in CH.ifa.draw.standard.DecoratorFigure.

Definition at line 181 of file AbstractFigure.java.

                                         {
        Vector figures = new Vector(1);
        figures.addElement(this);
        return new FigureEnumerator(figures);
    }

Here is the call graph for this function:

Object CH.ifa.draw.standard.AbstractFigure.defaultAttribute ( String  name) [inline]

Gets a the default value for a named attribute.

See also:
getAttribute

Definition at line 329 of file AbstractFigure.java.

                                                {
       return null;
    }

Here is the caller graph for this function:

void CH.ifa.draw.standard.AbstractFigure.displayBox ( Point  origin,
Point  corner 
) [inline]

Changes the display box of a figure.

Clients usually call this method. It changes the display box and announces the corresponding change.

Parameters:
originthe new origin
cornerthe new corner
See also:
displayBox

Definition at line 85 of file AbstractFigure.java.

                                                       {
        willChange();
        basicDisplayBox(origin, corner);
        changed();
    }

Here is the call graph for this function:

abstract Rectangle CH.ifa.draw.standard.AbstractFigure.displayBox ( ) [pure virtual]

Gets the display box of a figure.

Implemented in CH.ifa.draw.standard.StandardDrawing, and CH.ifa.draw.standard.DecoratorFigure.

Here is the caller graph for this function:

void CH.ifa.draw.standard.AbstractFigure.displayBox ( Rectangle  r) [inline]

Changes the display box of a figure.

This is a convenience method. Implementors should only have to override basicDisplayBox

See also:
displayBox

Definition at line 164 of file AbstractFigure.java.

                                        {
        displayBox(new Point(r.x, r.y), new Point(r.x+r.width, r.y+r.height));
    }

Here is the call graph for this function:

FigureEnumeration CH.ifa.draw.standard.AbstractFigure.figures ( ) [inline]

Returns an Enumeration of the figures contained in this figure.

See also:
CompositeFigure

Reimplemented in CH.ifa.draw.standard.DecoratorFigure, and CH.ifa.draw.standard.CompositeFigure.

Definition at line 116 of file AbstractFigure.java.

                                       {
        Vector figures = new Vector(1);
        figures.addElement(this);
        return new FigureEnumerator(figures);
    }

Here is the caller graph for this function:

Figure CH.ifa.draw.standard.AbstractFigure.findFigureInside ( int  x,
int  y 
) [inline]

Returns the figure that contains the given point.

In contrast to containsPoint it returns its innermost figure that contains the point.

See also:
containsPoint

Reimplemented in CH.ifa.draw.standard.CompositeFigure, and CH.ifa.draw.standard.DecoratorFigure.

Definition at line 145 of file AbstractFigure.java.

                                                 {
        if (containsPoint(x, y))
            return this;
        return null;
    }

Here is the call graph for this function:

Object CH.ifa.draw.standard.AbstractFigure.getAttribute ( String  name) [inline]

Returns the named attribute or null if a a figure doesn't have an attribute.

All figures support the attribute names FillColor and FrameColor

Reimplemented in CH.ifa.draw.standard.DecoratorFigure.

Definition at line 339 of file AbstractFigure.java.

                                            {
        if (fAttributes != null) {
            if (fAttributes.hasDefined(name))
                return fAttributes.get(name);
        }
        return defaultAttribute(name);
    }

Here is the call graph for this function:

abstract Vector CH.ifa.draw.standard.AbstractFigure.handles ( ) [pure virtual]

Returns the handles of a Figure that can be used to manipulate some of its attributes.

Returns:
a Vector of handles
See also:
Handle

Implemented in CH.ifa.draw.standard.StandardDrawing, and CH.ifa.draw.standard.DecoratorFigure.

boolean CH.ifa.draw.standard.AbstractFigure.includes ( Figure  figure) [inline]

Checks whether the given figure is contained in this figure.

Reimplemented in CH.ifa.draw.standard.CompositeFigure, and CH.ifa.draw.standard.DecoratorFigure.

Definition at line 171 of file AbstractFigure.java.

                                           {
        return figure == this;
    }

Invalidates the figure.

This method informs the listeners that the figure's current display box is invalid and should be refreshed.

Definition at line 244 of file AbstractFigure.java.

                             {
        if (fListener != null) {
            Rectangle r = displayBox();
            r.grow(Handle.HANDLESIZE, Handle.HANDLESIZE);
            fListener.figureInvalidated(new FigureChangeEvent(this, r));
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Checks if the figure is empty.

The default implementation returns true if the width or height of its display box is < 3

See also:
Figure::isEmpty

Definition at line 134 of file AbstractFigure.java.

                             {
        return (size().width < 3) || (size().height < 3);
    }

Here is the call graph for this function:

FigureChangeListener CH.ifa.draw.standard.AbstractFigure.listener ( ) [inline]

Gets the figure's listners.

Definition at line 225 of file AbstractFigure.java.

                                           {
        return fListener;
    }

Here is the caller graph for this function:

void CH.ifa.draw.standard.AbstractFigure.moveBy ( int  dx,
int  dy 
) [inline]

Moves the figure by the given offset.

Reimplemented in CH.ifa.draw.standard.DecoratorFigure.

Definition at line 63 of file AbstractFigure.java.

                                       {
        willChange();
        basicMoveBy(dx, dy);
        changed();
    }

Here is the call graph for this function:

void CH.ifa.draw.standard.AbstractFigure.read ( StorableInput  dr) throws IOException [inline]

Reads the Figure from a StorableInput.

Reimplemented in CH.ifa.draw.standard.CompositeFigure, and CH.ifa.draw.standard.DecoratorFigure.

Definition at line 403 of file AbstractFigure.java.

                                                          {
       // test for number being next; if it's a number this is
       // an old-format file with no attributes on this figure type
       if (dr.testForNumber())
           return;
       String s = dr.readString();
       if (s.toLowerCase().equals("attributes")) {
           fAttributes = new FigureAttributes();
           fAttributes.read(dr);
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

A figure is released from the drawing.

You never call this method directly. Release notifies its listeners.

See also:
Figure::release

Reimplemented in CH.ifa.draw.standard.CompositeFigure, and CH.ifa.draw.standard.DecoratorFigure.

Definition at line 234 of file AbstractFigure.java.

                          {
        if (fListener != null)
            fListener.figureRemoved(new FigureChangeEvent(this));
    }

Here is the caller graph for this function:

void CH.ifa.draw.standard.AbstractFigure.removeFigureChangeListener ( FigureChangeListener  l) [inline]

Removes a listener for this figure.

Definition at line 218 of file AbstractFigure.java.

                                                                   {
        fListener = FigureChangeEventMulticaster.remove(fListener, l);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.standard.AbstractFigure.removeFromContainer ( FigureChangeListener  c) [inline]

Removes a figure from the given container and unregisters it as a change listener.

Definition at line 202 of file AbstractFigure.java.

Here is the call graph for this function:

void CH.ifa.draw.standard.AbstractFigure.setAttribute ( String  name,
Object  value 
) [inline]

Sets the named attribute to the new value.

Reimplemented in CH.ifa.draw.standard.DecoratorFigure.

Definition at line 350 of file AbstractFigure.java.

                                                        {
        if (fAttributes == null)
            fAttributes = new FigureAttributes();
        fAttributes.set(name, value);
        changed();
    }

Here is the call graph for this function:

Gets the size of the figure.

A convenience method.

Definition at line 125 of file AbstractFigure.java.

                            {
        return new Dimension(displayBox().width, displayBox().height);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Informes that a figure is about to change something that affects the contents of its display box.

See also:
Figure::willChange

Definition at line 258 of file AbstractFigure.java.

                             {
        invalidate();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.standard.AbstractFigure.write ( StorableOutput  dw) [inline]

Stores the Figure to a StorableOutput.

Reimplemented in CH.ifa.draw.standard.CompositeFigure, and CH.ifa.draw.standard.DecoratorFigure.

Definition at line 391 of file AbstractFigure.java.

                                         {
        if (fAttributes == null)
            dw.writeString("no_attributes");
        else {
            dw.writeString("attributes");
            fAttributes.write(dw);
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 54 of file AbstractFigure.java.

Font CH.ifa.draw.standard.AbstractFigure.dialogFont = Font.decode("dialog-PLAIN-12") [static, protected]

Definition at line 56 of file AbstractFigure.java.

The attributes of a figure.

Each figure can have an open ended set of attributes. Attributes are identified by name.

See also:
getAttribute
setAttribute

Definition at line 40 of file AbstractFigure.java.

transient FigureChangeListener CH.ifa.draw.standard.AbstractFigure.fListener [private]

The listeners for a figure's changes.

See also:
invalidate
changed
willChange

Definition at line 48 of file AbstractFigure.java.

final long CH.ifa.draw.standard.AbstractFigure.serialVersionUID = -10857585979273442L [static, private]

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