Package jsky.graphics

Examples of jsky.graphics.CanvasFigure


     * Remove all figures created by this instance.
     */
    public void clear() {
        ListIterator it = figureList.listIterator(0);
        while (it.hasNext()) {
            CanvasFigure fig = (CanvasFigure) it.next();
            if (!fig.isPersistent()) {
                graphics.remove(fig);
                it.remove();
            }
        }
    }
View Full Code Here


     */
    public void hideGraphics() {
        visible = !visible;
        ListIterator it = figureList.listIterator(0);
        while (it.hasNext()) {
            CanvasFigure fig = (CanvasFigure) it.next();
            fig.setVisible(visible);
        }
    }
View Full Code Here

     * @param interactor determines the behavior of the figure (may be null)
     * @return the handle for  the figure
     */
    public CanvasFigure makeFigure(Shape shape, Paint fill, Paint outline, float lineWidth, Composite composite,
                                   Interactor interactor) {
        CanvasFigure fig = makeFigure(shape, fill, outline, lineWidth, interactor);
        if (composite != null && fig instanceof BasicFigure) {
            ((BasicFigure) fig).setComposite((AlphaComposite) composite);
        }
        return fig;
    }
View Full Code Here

                Font font = new Font("Dialog", Font.PLAIN, 12);

                // create a rectangle with lable and rotate it
                Rectangle2D.Double r1 = new Rectangle2D.Double(30., 30., 30., 40.);
                CanvasFigure fig = g.makeLabeledRectangle(r1, CoordinateConverter.USER, null, Color.blue, 2.0F,
                        "Test1", SwingConstants.CENTER, Color.blue, font, si);
                // rotate the rectangle by 30 degrees
                fig.transform(AffineTransform.getRotateInstance(Math.toRadians(30.), 25, 25));
                g.add(fig);

                // create another labeled rectangle. This one using the fixed selection interactor
                Rectangle2D.Double r2 = new Rectangle2D.Double(70., 70., 50., 50.);
                g.add(g.makeLabeledRectangle(r2, CoordinateConverter.USER, null, Color.white, 2.0F,
                        "Test2", SwingConstants.CENTER, Color.blue, font, fsi));

                // create a rotatable, nonresizable ellipse
                Ellipse2D.Double e1 = new Ellipse2D.Double(150., 150., 50., 50.);
                RotatableCanvasFigure imageFig = g.makeEllipse(e1, CoordinateConverter.USER, Color.red, Color.white, 2.0F, rsi);
                imageFig.setResizable(false);
                g.add(imageFig);

                // create a nonrotatable rectangle
                Rectangle2D.Double r4 = new Rectangle2D.Double(120., 180., 20., 60.);
                g.add(g.makeRectangle(r4, CoordinateConverter.USER, Color.green, Color.yellow, 2.0F, si));

                // create a nonrotatable ellipse
                Ellipse2D.Double e3 = new Ellipse2D.Double(20., 220., 50., 20.);
                g.add(g.makeEllipse(e3, CoordinateConverter.USER, null, Color.white, 2.0F, si));

                // this ellipse can only be dragged
                Ellipse2D.Double e4 = new Ellipse2D.Double(55., 200., 10., 40.);
                g.add(g.makeEllipse(e4, CoordinateConverter.USER, Color.white, Color.yellow, 2.0F, di));

                // create a test label with no interactor
                Point2D.Double pos = new Point2D.Double(10., 150.);
                g.add(g.makeLabel(pos, "Test Label", Color.yellow, font));

                // test figure listener to demonstrate event handling
                CanvasFigureListener listener = new CanvasFigureListener() {
                    public void figureSelected(CanvasFigureEvent e) {
                        System.out.println("Figure selected");
                    }

                    public void figureDeselected(CanvasFigureEvent e) {
                        System.out.println("Figure deselected");
                    }

                    public void figureResized(CanvasFigureEvent e) {
                        System.out.println("Figure resized: " + e.getFigure().getShape());
                    }

                    public void figureMoved(CanvasFigureEvent e) {
                        System.out.println("Figure moved: " + e.getFigure().getShape());
                    }

                    public void figureRotated(CanvasFigureEvent e) {
                        RotatableCanvasFigure rfig = (RotatableCanvasFigure)e.getFigure();
                        System.out.println("Figure rotated: " + Math.toDegrees(rfig.getGeometry().getRotateAngle()) + " deg");
                    }
                };

                // create a rotatable figure group (call setResizable(false) to disable resizing)
                Rectangle2D.Double r3 = new Rectangle2D.Double(150., 100., 60., 40.);
                CanvasFigure f1 = g.makeRectangle(r3, CoordinateConverter.USER, null, Color.yellow, 2.0F, null);
                Ellipse2D.Double e5 = new Ellipse2D.Double(150., 100., 60., 40.);
                CanvasFigure f2 = g.makeEllipse(e5, CoordinateConverter.USER, null, Color.yellow, 2.0F, null);
                pos = new Point2D.Double(r3.x + 10, r3.y + 25);
                CanvasFigure f3 = g.makeLabel(pos, CoordinateConverter.USER, "Group", Color.yellow, new JLabel().getFont(), null);
                CanvasFigureGroup group = g.makeFigureGroup(rsi);
//                group.setResizable(false);
                // rotate the group by -25 deg
                group.transform(AffineTransform.getRotateInstance(Math.toRadians(-25.), 25, 25));
                group.add(f1);
View Full Code Here

        List<String> configList = new ArrayList<String>(n);

        ListIterator it = figureList.listIterator(0);
        int i = 0;
        while (it.hasNext()) {
            CanvasFigure cfig = (CanvasFigure) it.next();
            if (cfig instanceof ImageFigure) {
                ImageFigure fig = (ImageFigure) cfig;
                Shape shape = fig.getShape();
                Paint fill = fig.getFillPaint();
                Paint outline = fig.getStrokePaint();
View Full Code Here

            public void mouseReleased(LayerEvent e) {
                Figure fig = e.getFigureSource();
                if (fig instanceof RectangleGrabHandle) {
                    Site site = ((RectangleGrabHandle) fig).getSite();
                    CanvasFigure f = (CanvasFigure)site.getFigure();
                    if (site.getID() == 0) {
                        f.fireCanvasFigureEvent(CanvasFigure.ROTATED);
                    } else {
                        f.fireCanvasFigureEvent(CanvasFigure.RESIZED);
                    }
                }
            }
        });
View Full Code Here

                try {
                    Iterator it = e.getSelectionAdditions();
                    while (it.hasNext()) {
                        Object o = it.next();
                        if (o instanceof CanvasFigure) {
                            CanvasFigure f = (CanvasFigure) o;
                            _selectedSet.add(f);
                            f.fireCanvasFigureEvent(CanvasFigure.SELECTED);
                        }
                    }
                } catch (Exception ignored) {
                    // XXX got a null reference in Diva during testing...
                }
                try {
                    Iterator it = e.getSelectionRemovals();
                    while (it.hasNext()) {
                        Object o = it.next();
                        if (o instanceof CanvasFigure) {
                            CanvasFigure f = (CanvasFigure) o;
                            _selectedSet.remove(f);
                            ((CanvasFigure) o).fireCanvasFigureEvent(CanvasFigure.DESELECTED);
                        }
                    }
                } catch (Exception ignored) {
View Full Code Here

TOP

Related Classes of jsky.graphics.CanvasFigure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.