Back to index

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

FigureSelection enables to transfer the selected figures to a clipboard. More...

Collaboration diagram for CH.ifa.draw.framework.FigureSelection:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FigureSelection (Vector figures)
 Constructes the Figure selection for the vecotor of figures.
String getType ()
 Gets the type of the selection.
Object getData (String type)
 Gets the data of the selection.

Static Public Attributes

static final String TYPE = "CH.ifa.draw.Figures"
 The type identifier of the selection.

Private Attributes

byte[] fData

Detailed Description

FigureSelection enables to transfer the selected figures to a clipboard.

Will soon be converted to the JDK 1.1 Transferable interface.

See also:
Clipboard

Definition at line 20 of file FigureSelection.java.


Constructor & Destructor Documentation

Constructes the Figure selection for the vecotor of figures.

Definition at line 31 of file FigureSelection.java.

                                           {
        // a FigureSelection is represented as a flattened ByteStream
        // of figures.
        ByteArrayOutputStream output = new ByteArrayOutputStream(200);
        StorableOutput writer = new StorableOutput(output);
        writer.writeInt(figures.size());
        Enumeration selected = figures.elements();
        while (selected.hasMoreElements()) {
            Figure figure = (Figure) selected.nextElement();
            writer.writeStorable(figure);
        }
        writer.close();
        fData = output.toByteArray();
    }

Member Function Documentation

Object CH.ifa.draw.framework.FigureSelection.getData ( String  type) [inline]

Gets the data of the selection.

The result is returned as a Vector of Figures.

Returns:
a copy of the figure selection.

Definition at line 59 of file FigureSelection.java.

                                       {
        if (type.equals(TYPE)) {
            InputStream input = new ByteArrayInputStream(fData);
            Vector result = new Vector(10);
            StorableInput reader = new StorableInput(input);
            int numRead = 0;
            try {
                int count = reader.readInt();
                while (numRead < count) {
                    Figure newFigure = (Figure) reader.readStorable();
                    result.addElement(newFigure);
                    numRead++;
                }
            } catch (IOException e) {
                System.out.println(e.toString());
            }
            return result;
        }
        return null;
    }

Gets the type of the selection.

Definition at line 49 of file FigureSelection.java.

                            {
        return TYPE;
    }

Member Data Documentation

Definition at line 22 of file FigureSelection.java.

final String CH.ifa.draw.framework.FigureSelection.TYPE = "CH.ifa.draw.Figures" [static]

The type identifier of the selection.

Definition at line 26 of file FigureSelection.java.


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