Back to index

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

A container for a figure's attributes. More...

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

List of all members.

Public Member Functions

 FigureAttributes ()
 Constructs the FigureAttributes.
Object get (String name)
 Gets the attribute with the given name.
void set (String name, Object value)
 Sets the attribute with the given name and overwrites its previous value.
boolean hasDefined (String name)
 Tests if an attribute is defined.
Object clone ()
 Clones the attributes.
void read (StorableInput dr) throws IOException
 Reads the attributes from a StorableInput.
void write (StorableOutput dw)
 Writes the attributes to a StorableInput.

Private Attributes

Hashtable fMap
int figureAttributesSerializedDataVersion = 1

Static Private Attributes

static final long serialVersionUID = -6886355144423666716L

Detailed Description

A container for a figure's attributes.

The attributes are stored as key/value pairs.

See also:
Figure

Definition at line 23 of file FigureAttributes.java.


Constructor & Destructor Documentation

Constructs the FigureAttributes.

Definition at line 38 of file FigureAttributes.java.

                              {
        fMap = new Hashtable();
    }

Here is the caller graph for this function:


Member Function Documentation

Clones the attributes.

Definition at line 68 of file FigureAttributes.java.

                         {
        try {
            FigureAttributes a = (FigureAttributes) super.clone();
            a.fMap = (Hashtable) fMap.clone();
            return a;
        } catch (CloneNotSupportedException e) {
               throw new InternalError();
        }
    }

Here is the call graph for this function:

Object CH.ifa.draw.standard.FigureAttributes.get ( String  name) [inline]

Gets the attribute with the given name.

Returns:
attribute or null if the key is not defined

Definition at line 46 of file FigureAttributes.java.

                                   {
        return fMap.get(name);
    }

Here is the caller graph for this function:

boolean CH.ifa.draw.standard.FigureAttributes.hasDefined ( String  name) [inline]

Tests if an attribute is defined.

Definition at line 61 of file FigureAttributes.java.

                                           {
        return fMap.containsKey(name);
    }

Here is the caller graph for this function:

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

Reads the attributes from a StorableInput.

FigureAttributes store the following types directly: Color, Boolean, String, Int. Other attribute types have to implement the Storable interface or they have to be wrapped by an object that implements Storable.

See also:
Storable
write

Definition at line 87 of file FigureAttributes.java.

                                                          {
        String s = dr.readString();
        if (!s.toLowerCase().equals("attributes"))
            throw new IOException("Attributes expected");

        fMap = new Hashtable();
        int size = dr.readInt();
        for (int i=0; i<size; i++) {
            String key = dr.readString();
            String valtype = dr.readString();
            Object val = null;
            if (valtype.equals("Color"))
                val = new Color(dr.readInt(), dr.readInt(), dr.readInt());
            else if (valtype.equals("Boolean"))
                val = new Boolean(dr.readString());
            else if (valtype.equals("String"))
                val = dr.readString();
            else if (valtype.equals("Int"))
                val = new Integer(dr.readInt());
            else if (valtype.equals("Storable"))
                val = dr.readStorable();
            else if (valtype.equals("UNKNOWN"))
                continue;

            fMap.put(key,val);
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Sets the attribute with the given name and overwrites its previous value.

Definition at line 54 of file FigureAttributes.java.

                                               {
        fMap.put(name, value);
    }

Here is the caller graph for this function:

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

Writes the attributes to a StorableInput.

FigureAttributes store the following types directly: Color, Boolean, String, Int. Other attribute types have to implement the Storable interface or they have to be wrapped by an object that implements Storable.

See also:
Storable
write

Definition at line 124 of file FigureAttributes.java.

                                         {
        dw.writeString("attributes");

        dw.writeInt(fMap.size());   // number of attributes
        Enumeration k = fMap.keys();
        while (k.hasMoreElements()) {
            String s = (String) k.nextElement();
            dw.writeString(s);
            Object v = fMap.get(s);
            if (v instanceof String) {
                dw.writeString("String");
                dw.writeString((String) v);
            } else if (v instanceof Color) {
                dw.writeString("Color");
                dw.writeInt(((Color)v).getRed());
                dw.writeInt(((Color)v).getGreen());
                dw.writeInt(((Color)v).getBlue());
            } else if (v instanceof Boolean) {
                dw.writeString("Boolean");
                if (((Boolean)v).booleanValue())
                    dw.writeString("TRUE");
                else
                    dw.writeString("FALSE");
            } else if (v instanceof Integer) {
                dw.writeString("Int");
                dw.writeInt(((Integer)v).intValue());
            } else if (v instanceof Storable) {
                dw.writeString("Storable");
                dw.writeStorable((Storable)v);
            } else {
                System.out.println(v);
                dw.writeString("UNKNOWN");
            }
        }
    }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 33 of file FigureAttributes.java.

Definition at line 27 of file FigureAttributes.java.

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

Definition at line 32 of file FigureAttributes.java.


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