2,2c2,2 < * @(#)FigureSelection.java 5.2 --- > * @(#)FigureSelection.java 3a4,9 > * Project: JHotdraw - a GUI framework for technical drawings > * http://www.jhotdraw.org > * http://jhotdraw.sourceforge.net > * Copyright: © by the original author(s) and all contributors > * License: Lesser GNU Public License (LGPL) > * http://www.opensource.org/licenses/lgpl-license.html 8,11d13 < import CH.ifa.draw.util.*; < import java.util.*; < import java.io.*; < 16a19,21 > * @see CH.ifa.draw.util.Clipboard > * > * @version <$CURRENT_VERSION$> 17,17d18 < * @see Clipboard 19a24,24 > public interface FigureSelection { 20,44d23 < public class FigureSelection extends Object { < < private byte[] fData; // flattend figures, ready to be resurrected < /** < * The type identifier of the selection. < */ < public final static String TYPE = "CH.ifa.draw.Figures"; < < /** < * Constructes the Figure selection for the vector of figures. < */ < public FigureSelection(Vector figures) { < // 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(); < } 49,49c29,29 < public String getType() { --- > public String getType(); 50,51d29 < return TYPE; < } 58a37,37 > public Object getData(String type); 59,78d36 < public Object getData(String type) { < 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; < }