Package diva.canvas

Examples of diva.canvas.FigureLayer


    }

    /** Create the figures.
     */
    public void createFigures() {
        FigureLayer layer = graphicsPane.getForegroundLayer();

        _rectangle = new BasicRectangle(50, 50, 80, 80, Color.black);
        layer.add(_rectangle);

        _circle = new BasicEllipse(150, 50, 80, 80, Color.green);
        layer.add(_circle);

        GeneralPath path = new GeneralPath();
        path.moveTo(120, 240);
        path.lineTo(240, 240);
        path.quadTo(180, 120, 120, 240);
        path.closePath();
        _shape = new BasicFigure(path, Color.red);
        layer.add(_shape);

        Polyline2D poly = new Polyline2D.Double();
        poly.moveTo(240, 120);
        poly.lineTo(280, 140);
        poly.lineTo(240, 160);
        poly.lineTo(280, 180);
        poly.lineTo(240, 200);
        poly.lineTo(280, 220);
        poly.lineTo(240, 240);
        _line = new BasicFigure(poly);
        layer.add(_line);
    }
View Full Code Here


    /** Create the figures that we will draw connectors between.
     * This is fairly uninteresting.
     */
    public void createFigures() {
        FigureLayer layer = graphicsPane.getForegroundLayer();

        figureA = new SitedRectangle(10.0, 10.0, 50.0, 50.0, Color.red);
        figureB = new SitedRectangle(100.0, 100.0, 100.0, 50.0, Color.green);

        layer.add(figureA);
        layer.add(figureB);
    }
View Full Code Here

     * Create the connectors between the two figures. We will firstly
     * create one StraightConnector with a circle and an arrowhead
     * on it, and then a ManhattanConnector with a diamond on one end.
     */
    public void createConnectors() {
        FigureLayer layer = graphicsPane.getForegroundLayer();

        // Create the first connector
        Site a = figureA.getE();
        Site b = figureB.getN();
        connectorA = new StraightConnector(a, b);

        // Add the circle and arrowhead to it
        Blob blob = new Blob(a.getX(), a.getY(), a.getNormal(),
                Blob.BLOB_CIRCLE);
        connectorA.setTailEnd(blob);

        Arrowhead arrow = new Arrowhead(b.getX(), b.getY(), b.getNormal());
        connectorA.setHeadEnd(arrow);

        // Add it to the layer
        layer.add(connectorA);

        // Create the second connector
        Site c = figureA.getS();
        Site d = figureB.getW();
        connectorB = new ManhattanConnector(c, d);

        // Add the diamond
        Blob diamond = new Blob(c.getX(), c.getY(), c.getNormal(),
                Blob.BLOB_DIAMOND);
        diamond.setSizeUnit(6.0);
        diamond.setFilled(false);
        connectorB.setTailEnd(diamond);

        // Add it to the layer
        layer.add(connectorB);
    }
View Full Code Here

     * the nmouse moves.
     */
    public void setupInteraction() {
        // Because this pane has connectors on it, we make the pick
        // halo larger than the default so we can click-select connectors
        FigureLayer layer = graphicsPane.getForegroundLayer();
        layer.setPickHalo(2.0);

        // Add the default interactor to both figures
        SelectionInteractor si = controller.getSelectionInteractor();
        figureA.setInteractor(si);
        figureB.setInteractor(si);
View Full Code Here

     * means that they behave the same when you mouse on them.
     * The interactor used to move them is an instance of
     * DragInteractor.
     */
    public void createDraggableFigures() {
        FigureLayer layer = graphicsPane.getForegroundLayer();

        // Create the interactor to do the work.
        Interactor dragger = new DragInteractor();
        dragger.setMouseFilter(MouseFilter.defaultFilter);

        // Create a rectangle and make it draggable
        BasicFigure blue = new BasicRectangle(10.0, 10.0, 50.0, 50.0,
                Color.blue);
        layer.add(blue);
        blue.setInteractor(dragger);

        // Create a circle and make it draggable
        BasicFigure red = new BasicEllipse(200.0, 200.0, 50.0, 50.0, Color.red);
        layer.add(red);
        red.setInteractor(dragger);
    }
View Full Code Here

    /** Create another simple figures and make it draggable within
     * a region of the canvas. This example uses an instance of
     * BoundedDragInteractor to move the object.
     */
    public void createBoundedDraggableFigure() {
        FigureLayer layer = graphicsPane.getForegroundLayer();

        // Create the interactor and set it up for a 200x200 rectangle
        Rectangle2D bounds = new Rectangle2D.Double(100.0, 100.0, 200.0, 200.0);
        Interactor boundedDragger = new BoundedDragInteractor(bounds);
        boundedDragger.setMouseFilter(MouseFilter.defaultFilter);

        // Create an outline rectangle that shows the boundaries
        graphicsPane.getOverlayLayer().add(bounds);

        // Create a green rectangle that stays inside the boundary
        BasicFigure green = new BasicFigure(new Rectangle2D.Double(110.0,
                110.0, 50.0, 50.0), Color.green);
        layer.add(green);
        green.setInteractor(boundedDragger);
    }
View Full Code Here

     * test suites and simple demos -- in general, an application
     * will want to construct a more sophisticated set of layers.
     */
    public BasicCanvasPane() {
        super();
        addLayer(new FigureLayer());
    }
View Full Code Here

    /** Create instances of the class defined
     * in this file. To make the demo a little more interesting,
     * make them draggable.
     */
    public void createFigures() {
        FigureLayer layer = graphicsPane.getForegroundLayer();

        // Create an interactor to do the work.
        Interactor dragger = new DragInteractor();

        // Create the figure
        Figure one = new CloudFigure(10.0, 10.0, 80.0, 80.0);
        layer.add(one);
        one.setInteractor(dragger);

        Figure two = new CloudFigure(150, 150, 200, 180);
        layer.add(two);
        two.setInteractor(dragger);
    }
View Full Code Here

    /** Create the figures that we will draw connectors between.
     * This is fairly uninteresting.
     */
    public void createFigures() {
        FigureLayer layer = graphicsPane.getForegroundLayer();

        figureA = new BasicRectangle(10.0, 10.0, 100.0, 50.0, Color.red);
        figureB = new BasicEllipse(100.0, 100.0, 100.0, 100.0, Color.green);
        figureC = new BasicEllipse(300.0, 100.0, 100.0, 100.0, Color.blue);

        layer.add(figureA);
        layer.add(figureB);
        layer.add(figureC);
    }
View Full Code Here

     * Create the connectors between the two figures. We will firstly
     * create one StraightConnector with a circle and an arrowhead
     * on it, and then an ArcConnector.
     */
    public void createConnectors() {
        FigureLayer layer = graphicsPane.getForegroundLayer();

        // Create the target that finds sites on the figures
        target = new SelfPTarget();

        // Create the first connector. We don't care about the actual
        // location at this stage
        Site a = target.getTailSite(figureA, 0.0, 0.0);
        Site b = target.getHeadSite(figureB, 0.0, 0.0);
        connectorA = new StraightConnector(a, b);
        layer.add(connectorA);

        // Add an arrowhead to it
        Arrowhead arrow = new Arrowhead(b.getX(), b.getY(), b.getNormal());
        connectorA.setHeadEnd(arrow);

        // Create the second connector with an arrowhead
        a = target.getTailSite(figureB, 0.0, 0.0);
        b = target.getHeadSite(figureC, 0.0, 0.0);
        connectorB = new ArcConnector(a, b);
        layer.add(connectorB);
        arrow = new Arrowhead(b.getX(), b.getY(), b.getNormal());
        connectorB.setHeadEnd(arrow);

        // Create the third connector with an arrowhead
        a = target.getTailSite(figureB, 0.0, 0.0);
        b = target.getHeadSite(figureC, 0.0, 0.0);
        connectorC = new ArcConnector(a, b);

        // Swap the direction
        connectorC.setAngle(-connectorC.getAngle());
        layer.add(connectorC);
        arrow = new Arrowhead(b.getX(), b.getY(), b.getNormal());
        connectorC.setHeadEnd(arrow);

        // Create a fourth connector with an arrowhead, which is a "self-loop"
        a = target.getTailSite(figureB, 0.0, 0.0);
        b = target.getHeadSite(figureB, 0.0, 0.0);
        connectorD = new ArcConnector(a, b);
        connectorD.setSelfLoop(true);

        // Swap the direction
        // connectorD.setAngle(-connectorD.getAngle());
        // connectorD.setAngle(-0.1);
        layer.add(connectorD);
        arrow = new Arrowhead(b.getX(), b.getY(), b.getNormal());
        connectorD.setHeadEnd(arrow);
    }
View Full Code Here

TOP

Related Classes of diva.canvas.FigureLayer

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.