/** * Writes the drawing to the specified output stream. * This method applies the specified drawingTransform to the drawing, and draws * it on an image of the specified getChildCount. */ public void write(OutputStream out, Drawing drawing, AffineTransform drawingTransform, Dimension imageSize) throws IOException { write(out, drawing.getChildren(), drawingTransform, imageSize); }
@Override public void write(OutputStream out, Drawing drawing) throws IOException { GZIPOutputStream gout = new GZIPOutputStream(out); super.write(gout, drawing, drawing.getChildren()); gout.finish(); } }
@Override public void write(OutputStream out, Drawing drawing) throws IOException { write(out, drawing.getChildren()); }
@Override public void write(OutputStream out, Drawing drawing) throws IOException { write(out, drawing, drawing.getChildren()); }
/** * Writes the drawing to the specified output stream. * This method ensures that all figures of the drawing are visible on * the image. */ @Override public void write(OutputStream out, Drawing drawing) throws IOException { write(out, drawing, drawing.getChildren(), null, null); }
/** * Writes the drawing to the specified output stream. * This method applies the specified transform to the drawing, and draws * it on an image of the specified size. */ public void write(OutputStream out, Drawing drawing, AffineTransform drawingTransform, Dimension imageSize) throws IOException { write(out, drawing, drawing.getChildren(), drawingTransform, imageSize); }
@SuppressWarnings("unchecked") @Override public void read(Transferable t, Drawing drawing, boolean replace) throws UnsupportedFlavorException, IOException { try { Drawing d = (Drawing) t.getTransferData(dataFlavor); if (replace) { for (Map.Entry<AttributeKey, Object> e : d.getAttributes().entrySet()) { drawing.set(e.getKey(), e.getValue()); } } for (Figure f : d.getChildren()) { drawing.add(f); } } catch (Throwable th) { th.printStackTrace(); } }
@SuppressWarnings("unchecked") @Override public void read(InputStream in, Drawing drawing, boolean replace) throws IOException { try { ObjectInputStream oin = new ObjectInputStream(in); Drawing d = (Drawing) oin.readObject(); if (replace) { for (Map.Entry<AttributeKey, Object> e : d.getAttributes().entrySet()) { drawing.set(e.getKey(), e.getValue()); } } for (Figure f : d.getChildren()) { drawing.add(f); } } catch (ClassNotFoundException ex) { IOException ioe = new IOException("Couldn't read drawing."); ioe.initCause(ex); throw ioe; } }
public void selectSame() { HashSet<Class> selectedClasses = new HashSet<Class>(); for (Figure selected : getView().getSelectedFigures()) { selectedClasses.add(selected.getClass()); } for (Figure f : getDrawing().getChildren()) { if (selectedClasses.contains(f.getClass())) { getView().addToSelection(f); } } } }
@Override protected void done(Drawing drawing) { CompositeFigure parent; if (createdFigure == null) { parent = (CompositeFigure) prototype; for (Figure f : drawing.getChildren()) { parent.basicAdd(f); } } else { parent = (CompositeFigure) createdFigure; parent.willChange(); for (Figure f : drawing.getChildren()) { parent.add(f); } parent.changed(); } }
/** * Selects all selectable figures. */ @Override public void selectAll() { Set<Figure> oldSelection = new HashSet<Figure>(selectedFigures); selectedFigures.clear(); for (Figure figure : drawing.getChildren()) { if (figure.isSelectable()) { selectedFigures.add(figure); } } Set<Figure> newSelection = new HashSet<Figure>(selectedFigures); invalidateHandles(); fireSelectionChanged(oldSelection, newSelection); repaint(); }
@Override public LinkedList<Figure> construct() throws Exception { for (File file : files) { FileFormatLoop: for (InputFormat format : drawing.getInputFormats()) { if (file.isFile() && format.getFileFilter().accept(file)) { if (DEBUG) { System.out.println("DefaultDrawingViewTransferHandler importing file " + file); } format.read(file.toURI(), drawing, false); } } } return new LinkedList<Figure>(drawing.getChildren()); }
svgImage.read(imageUrl, svgDrawing, true); CompositeFigure svgImageGroup = factory.createG(a); for (Figure f : svgDrawing.getChildren()) { svgImageGroup.add(f);
for (Figure f : drawing.getChildren()) { if (drawBounds == null) { drawBounds = f.getDrawingArea();
LinkedList<Figure> existingFigures = new LinkedList<Figure>(drawing.getChildren()); try { format.read(t, drawing, false); System.out.println("DefaultDrawingViewTransferHandler import succeeded"); final LinkedList<Figure> importedFigures = new LinkedList<Figure>(drawing.getChildren()); importedFigures.removeAll(existingFigures); view.clearSelection(); System.out.println("DefaultDrawingViewTransferHandler trying format:" + format); LinkedList<Figure> existingFigures = new LinkedList<Figure>(drawing.getChildren()); try { format.read(t, drawing, false); System.out.println("DefaultDrawingViewTransferHandler import succeeded"); final LinkedList<Figure> importedFigures = new LinkedList<Figure>(drawing.getChildren()); importedFigures.removeAll(existingFigures); view.clearSelection(); final java.util.List<File> files = (java.util.List<File>) t.getTransferData(DataFlavor.javaFileListFlavor); retValue = true; final LinkedList<Figure> existingFigures = new LinkedList<Figure>(drawing.getChildren()); view.getEditor().setEnabled(false);