Package diva.canvas

Examples of diva.canvas.FigureLayer


     * 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(4.0);

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


    }

    /** Create a collection of terminals.
     */
    public void createTerminals() {
        FigureLayer layer = graphicsPane.getForegroundLayer();

        // Draw a rectangle to position them
        BasicRectangle square = new BasicRectangle(160, 80, 80, 80);
        square.setStrokePaint(Color.gray);
        layer.add(square);

        // Create a BoundsGeometry to help get sites
        BoundsGeometry _geometry = new BoundsGeometry(square, square
                .getBounds());

        // Create a set of terminals, one by one
        // NORTH
        StraightTerminal north = new StraightTerminal(_geometry.getN());

        //Site connectNorth = north.getConnectSite();
        Blob blobNorth = new Blob();
        blobNorth.setSizeUnit(5.0);
        north.setEnd(blobNorth);
        layer.add(north);

        // SOUTH
        StraightTerminal south = new StraightTerminal(_geometry.getS());

        //Site connectSouth = south.getConnectSite();
        Blob blobSouth = new Blob();
        blobSouth.setStyle(Blob.BLOB_DIAMOND);
        blobSouth.setSizeUnit(5.0);
        blobSouth.setFilled(false);
        south.setEnd(blobSouth);
        layer.add(south);

        // WEST
        StraightTerminal west = new StraightTerminal(_geometry.getW());

        //Site connectWest = west.getConnectSite();
        Arrowhead arrowWest = new Arrowhead();
        west.setEnd(arrowWest);
        layer.add(west);

        // EAST
        StraightTerminal east = new StraightTerminal(_geometry.getE());

        //Site connectEast = east.getConnectSite();
        Arrowhead arrowEast = new Arrowhead();
        arrowEast.setFlipped(true);
        east.setEnd(arrowEast);
        layer.add(east);

        // Make sure it's clean now
        layer.repaint();
    }
View Full Code Here

     * the BasicRectangle class. This class, together with a number
     * other useful predefined figure classes, is contained in the
     * package <b>diva.canvas.toolbox</b>.
     */
    public void createBasicRectangle() {
        FigureLayer layer = graphicsPane.getForegroundLayer();
        Figure rectangle = new BasicRectangle(50, 50, 80, 80, Color.blue);
        layer.add(rectangle);
    }
View Full Code Here

     * the BasicShape class, which draws itself using any instance
     * of the Java2D interface, <b>java.awt.Shape</b>. In this example,
     * we use an instance of GeneralPath.
     */
    public void createBasicFigure() {
        FigureLayer layer = graphicsPane.getForegroundLayer();
        GeneralPath path = new GeneralPath();
        path.moveTo(120, 240);
        path.lineTo(240, 240);
        path.quadTo(180, 120, 120, 240);
        path.closePath();

        Figure semi = new BasicFigure(path, Color.green);
        layer.add(semi);
    }
View Full Code Here

    /** Create a polyline. Again, this uses the BasicFigure class,
     * but this time the shape is an instance of <b>diva.util.Polyline2D</b>.
     */
    public void createPolyline() {
        FigureLayer layer = graphicsPane.getForegroundLayer();
        Polyline2D path = new Polyline2D.Double();
        path.moveTo(240, 120);
        path.lineTo(280, 140);
        path.lineTo(240, 160);
        path.lineTo(280, 180);
        path.lineTo(240, 200);
        path.lineTo(280, 220);
        path.lineTo(240, 240);

        Figure line = new BasicFigure(path);
        layer.add(line);
    }
View Full Code Here

     */
    public void addEdge(Object edge, Object node, int end, double x, double y) {
        MutableGraphModel model = (MutableGraphModel) _controller
                .getGraphModel();
        Figure nf = _controller.getFigure(node);
        FigureLayer layer = _controller.getGraphPane().getForegroundLayer();
        Site headSite;
        Site tailSite;

        // Temporary sites.  One of these will get blown away later.
        headSite = new AutonomousSite(layer, x, y);
View Full Code Here

     * the view, then use any information in that figure to help draw the
     * edge.
     */
    public Figure drawEdge(Object edge) {
        GraphModel model = _controller.getGraphModel();
        FigureLayer layer = _controller.getGraphPane().getForegroundLayer();
        Object tail = model.getTail(edge);
        Object head = model.getHead(edge);

        Connector connector = (Connector) _controller.getFigure(edge);
        Figure tailFigure = _controller.getFigure(tail);
View Full Code Here

    /** Create a new edge, add it to the graph controller and add
     * the connector to the selection.
     */
    public void mousePressed(LayerEvent e) {
        Figure source = e.getFigureSource();
        FigureLayer layer = (FigureLayer) e.getLayerSource();

        Object edge = createEdge();

        // Add it to the editor
        // FIXME what about an error?
        _controller.addEdge(edge, source.getUserObject(),
                ConnectorEvent.TAIL_END, e.getLayerX(), e.getLayerY());

        // Add it to the selection so it gets a manipulator, and
        // make events go to the grab-handle under the mouse
        Figure ef = _controller.getFigure(edge);
        _controller.getSelectionModel().addSelection(ef);

        ConnectorManipulator cm = (ConnectorManipulator) ef.getParent();
        GrabHandle gh = cm.getHeadHandle();
        layer.grabPointer(e, gh);
    }
View Full Code Here

            ActorGraphModel model = (ActorGraphModel) getGraphModel();
            model.getLinkModel().setTail(link, sourceObject);

            try {
                // add it to the foreground layer.
                FigureLayer layer = getGraphPane().getForegroundLayer();
                Site headSite;
                Site tailSite;

                // Temporary sites.  One of these will get blown away later.
                headSite = new AutonomousSite(layer, event.getLayerX(), event
                        .getLayerY());
                tailSite = new AutonomousSite(layer, event.getLayerX(), event
                        .getLayerY());

                // Render the edge.
                Connector c = getEdgeController(link).render(link, layer,
                        tailSite, headSite);

                // get the actual attach site.
                tailSite = getEdgeController(link).getConnectorTarget()
                        .getTailSite(c, source, event.getLayerX(),
                                event.getLayerY());

                if (tailSite == null) {
                    throw new RuntimeException("Invalid connector target: "
                            + "no valid site found for tail of new connector.");
                }

                // And reattach the connector.
                c.setTailSite(tailSite);

                // Add it to the selection so it gets a manipulator, and
                // make events go to the grab-handle under the mouse
                getSelectionModel().addSelection(c);

                ConnectorManipulator cm = (ConnectorManipulator) c.getParent();
                GrabHandle gh = cm.getHeadHandle();
                layer.grabPointer(event, gh);
            } catch (Exception ex) {
                MessageHandler.error("Drag connection failed:", ex);
            }
        }
View Full Code Here

    /** Draw a reference box with the default icon size, 60x40.
     */
    protected void _drawReferenceBox() {
        // The background layer is a FigureLayer, despite the fact that
        // getBackgroundLayer() only returns a CanvasLayer.
        FigureLayer layer = (FigureLayer) getJGraph().getGraphPane()
                .getBackgroundLayer();
        layer.setVisible(true);

        BasicRectangle reference = new BasicRectangle(-30.0, -20.0, 60.0, 40.0,
                0.1f);
        reference.setStrokePaint(Color.BLUE);
        layer.add(reference);
    }
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.