/** Creates a new instance with format name "Drawing", file extension "xml" * and mime type "image/x-jhotdraw". */ public SerializationInputOutputFormat() { this("Drawing", "ser", new DefaultDrawing()); }
@Override public Drawing construct() throws IOException { Drawing drawing = new DefaultDrawing(); InputFormat in = (file.getName().toLowerCase().endsWith(".svg")) ? new SVGInputFormat() : new SVGZInputFormat(); in.read(file.toURI(), drawing); return drawing; }
/** * Creates a new Drawing for this view. */ protected Drawing createDrawing() { DefaultDrawing drawing = new DefaultDrawing(); DOMStorableInputOutputFormat ioFormat = new DOMStorableInputOutputFormat(new PertFactory()); LinkedList<InputFormat> inputFormats = new LinkedList<InputFormat>(); inputFormats.add(ioFormat); drawing.setInputFormats(inputFormats); LinkedList<OutputFormat> outputFormats = new LinkedList<OutputFormat>(); outputFormats.add(ioFormat); outputFormats.add(new ImageOutputFormat()); drawing.setOutputFormats(outputFormats); return drawing; }
/** * Creates a drawing with input and output formats, so that drawing figures * can be copied and pasted between drawing views. * * @return a drawing */ private static Drawing createDrawing() { // Create a default drawing with // input/output formats for basic clipboard support. DefaultDrawing drawing = new DefaultDrawing(); drawing.addInputFormat(new SerializationInputOutputFormat()); drawing.addOutputFormat(new SerializationInputOutputFormat()); return drawing; } }
Drawing drawing = new DefaultDrawing();
@Override public void run() { // Create a simple drawing consisting of three // text areas and an elbow connection. LabeledEllipseFigure ta = new LabeledEllipseFigure(); ta.setBounds(new Point2D.Double(10, 10), new Point2D.Double(100, 100)); LabeledEllipseFigure tb = new LabeledEllipseFigure(); tb.setBounds(new Point2D.Double(220, 120), new Point2D.Double(310, 210)); LabeledEllipseFigure tc = new LabeledEllipseFigure(); tc.setBounds(new Point2D.Double(220, 10), new Point2D.Double(310, 100)); Drawing drawing = new DefaultDrawing(); drawing.add(ta); drawing.add(tb); drawing.add(tc); // Create a frame with a drawing view and a drawing editor JFrame f = new JFrame("My Drawing"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(400, 300); DrawingView view = new DefaultDrawingView(); view.setDrawing(drawing); f.add(view.getComponent()); f.add(new JLabel("Press space bar to toggle handles."), BorderLayout.SOUTH); DrawingEditor editor = new DefaultDrawingEditor(); editor.add(view); editor.setTool(new DelegationSelectionTool()); f.setVisible(true); } });
DefaultDrawing drawing = new DefaultDrawing(); drawing.addInputFormat(new SerializationInputOutputFormat()); drawing.addOutputFormat(new SerializationInputOutputFormat());
/** Creates new form AnimationSample */ public AnimationSample() { initComponents(); DefaultDrawingView view = new DefaultDrawingView(); view.setDrawingDoubleBuffered(false); add(view); setSize(400, 400); Drawing d = new DefaultDrawing(); d.set(CANVAS_FILL_COLOR, new Color(0x76a9d2)); final EllipseFigure ellipse = new EllipseFigure(160, 160, 80, 80); ellipse.set(STROKE_WIDTH, 7d); d.add(ellipse); view.setDrawing(d); Timer t = new Timer(10, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double alpha = 2d * Math.PI * (System.currentTimeMillis() % 1000) / 1000d; ellipse.willChange(); ellipse.setBounds(new Rectangle2D.Double(160 + Math.sin(alpha) * 100, 160 + Math.cos(alpha) * 100, 80, 80)); ellipse.changed(); } }); t.setRepeats(true); t.start(); }
Drawing drawing = new DefaultDrawing(); drawing.add(ta); drawing.add(tb);
/** * Creates a drawing with input and output formats, so that drawing figures * can be copied and pasted between drawing views. * * @return a drawing */ private static Drawing createDrawing() { // Create a default drawing with // input/output formats for basic clipboard support. DefaultDrawing drawing = new DefaultDrawing(); drawing.addInputFormat(new SerializationInputOutputFormat()); drawing.addOutputFormat(new SerializationInputOutputFormat()); drawing.addOutputFormat(new ImageOutputFormat()); return drawing; } }
cf.setStartConnector(ta.findConnector(Geom.center(ta.getBounds()), cf)); cf.setEndConnector(tb.findConnector(Geom.center(tb.getBounds()), cf)); Drawing drawing = new DefaultDrawing(); drawing.add(ta); drawing.add(tb);
@Override public void run() { // Create a graphical composite figure. GraphicalCompositeFigure composite = new GraphicalCompositeFigure(); // Add child figures to the composite figure composite.add(new TextFigure("Above the line")); composite.add(new LineFigure()); composite.add(new TextFigure("Below the line")); // Set a layouter and perform the layout composite.setLayouter(new VerticalLayouter()); composite.layout(); // Add the composite figure to a drawing Drawing drawing = new DefaultDrawing(); drawing.add(composite); // Create a frame with a drawing view and a drawing editor JFrame f = new JFrame("My Drawing"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(400, 300); DrawingView view = new DefaultDrawingView(); view.setDrawing(drawing); f.getContentPane().add(view.getComponent()); DrawingEditor editor = new DefaultDrawingEditor(); editor.add(view); editor.setTool(new DelegationSelectionTool()); f.setVisible(true); } });
cf.setStartConnector(ta.findConnector(Geom.center(ta.getBounds()), cf)); cf.setEndConnector(tb.findConnector(Geom.center(tb.getBounds()), cf)); Drawing drawing = new DefaultDrawing(); drawing.add(ta); drawing.add(tb);
this.displayViewer = displayViewer; drawing = new DefaultDrawing(); // or QuadTreeDrawing?
/** * Creates a new Drawing for this view. */ protected Drawing createDrawing() { DefaultDrawing drawing = new DefaultDrawing(); DOMStorableInputOutputFormat ioFormat = new DOMStorableInputOutputFormat(new NetFactory()); drawing.addInputFormat(ioFormat); drawing.addInputFormat(new TextInputFormat(new NodeFigure())); drawing.addOutputFormat(ioFormat); drawing.addOutputFormat(new ImageOutputFormat()); return drawing; }
Drawing drawing = new DefaultDrawing(); drawing.add(ta); drawing.add(tb);
DefaultDrawing drawing = new DefaultDrawing(); view.setDrawing(drawing); drawing.addUndoableEditListener(undoManager);
DefaultDrawing drawing = new DefaultDrawing(); view.setDrawing(drawing); drawing.addUndoableEditListener(undoManager);
log = getDisplay().getContext().getService(LogService.class); drawing = new DefaultDrawing(); // or QuadTreeDrawing?
/** * Creates the drawing. */ protected Drawing createDrawing() { DefaultDrawing drawing = new DefaultDrawing(); drawing.addInputFormat(new SVGZInputFormat()); drawing.addInputFormat(new ImageInputFormat(new SVGImageFigure())); drawing.addOutputFormat(new SVGOutputFormat()); drawing.addOutputFormat(new SVGZOutputFormat()); drawing.addOutputFormat(new ImageOutputFormat()); drawing.addOutputFormat(new ImageOutputFormat("JPG", "Joint Photographics Experts Group (JPEG)", "jpg", BufferedImage.TYPE_INT_RGB)); drawing.addOutputFormat(new ImageOutputFormat("BMP", "Windows Bitmap (BMP)", "bmp", BufferedImage.TYPE_BYTE_INDEXED)); return drawing; }