Package diva.canvas

Examples of diva.canvas.Figure


            public void run() {
                _debugRenderer.renderSelected(figure);
            }
        });

        final Figure debugRendered = figure;

        // Wait for user to select Resume.
        manager.pauseOnBreakpoint(message);

        if (debugRendered != null) {
View Full Code Here


                if (_prototype != null) {
                    location = _prototype.getAttribute("_location");
                }

                Figure figure = renderer.render(location);

                FigureIcon icon = new FigureIcon(figure, 25, 25, 1, true);
                putValue(GUIUtilities.LARGE_ICON, icon);
            }
            putValue("tooltip", description);
View Full Code Here

    /** Draw the node at its location. This overrides the base class
     *  to assign a location to the object.
     */
    public Figure drawNode(Object node) {
        Figure nf = super.drawNode(node);
        locateFigure(node);
        return nf;
    }
View Full Code Here

     *  of TerminalFigure, then modify the location to ensure that the
     *  connect site snaps to grid.
     *  @param node The object to locate.
     */
    public void locateFigure(Object node) {
        Figure nf = getController().getFigure(node);

        try {
            if (hasLocation(node)) {
                double[] location = getLocation(node);
                CanvasUtilities.translateTo(nf, location[0], location[1]);
View Full Code Here

        // that enforces that a CompositeFigure is returned.
        // *sigh*
        if (nf instanceof CompositeFigure) {
            cf = (CompositeFigure) nf;
        } else if (nf instanceof TerminalFigure) {
            Figure f = ((TerminalFigure) nf).getFigure();

            if (f instanceof CompositeFigure) {
                cf = (CompositeFigure) f;
            } else {
                cf = null;
View Full Code Here

     @return the newly created figure.
     */
    protected Figure _renderNode(java.lang.Object node) {
        if ((node == null) || _hide(node)) {
            // Return an empty figure.
            Figure newFigure = new CompositeFigure();
            newFigure.setVisible(false);
            newFigure.setInteractor(getNodeInteractor());
            newFigure.setUserObject(node);
            getController().setFigure(node, newFigure);
            return newFigure;
        } else {
            Figure nf = super._renderNode(node);
            GraphModel model = getController().getGraphModel();
            Object object = model.getSemanticObject(node);
            CompositeFigure cf = _getCompositeFigure(nf);

            if (_decoratable
View Full Code Here

     *  to another.
     */
    protected class LinkCreator extends AbstractInteractor {
        /** Initiate creation of an arc. */
        public void mousePressed(LayerEvent event) {
            Figure source = event.getFigureSource();
            NamedObj sourceObject = (NamedObj) source.getUserObject();

            Arc link = new Arc();

            // Set the tail, going through the model so the link is added
            // to the list of links.
            FSMGraphModel model = (FSMGraphModel) getGraphModel();
            model.getArcModel().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 removed 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
                Figure ef = getFigure(link);
                getSelectionModel().addSelection(ef);

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

            super("New State");
            putValue("tooltip", "New State");

            NodeRenderer renderer = new StateController.StateRenderer(
                    getGraphModel());
            Figure figure = renderer.render(_prototypeState);

            // Standard toolbar icons are 25x25 pixels.
            FigureIcon icon = new FigureIcon(figure, 25, 25, 1, true);
            putValue(diva.gui.GUIUtilities.LARGE_ICON, icon);
            putValue("tooltip", "New State");
View Full Code Here

            AffineTransform transform = AffineTransform.getRotateInstance(Math
                    .toRadians(rotation));
            shape = ShapeUtilities.transformModify(shape, transform);

            // Create a figure with a tooltip.
            Figure figure = new BasicFigure(shape, fill, (float) 1.5) {
                // Override this because we want to show the type.
                // It doesn't work to set it once because the type
                // has not been resolved, and anyway, it may
                // change. NOTE: This is copied below.
                public String getToolTipText() {
                    String tipText = port.getName();
                    String displayName = port.getDisplayName();
                    if (!tipText.equals(displayName)) {
                        tipText = displayName + " (" + tipText + ")";
                    }
                    StringAttribute _explAttr = (StringAttribute) (port
                            .getAttribute("_explanation"));

                    if (_explAttr != null) {
                        tipText = _explAttr.getExpression();
                    } else if (port instanceof Typeable) {
                        try {
                            tipText = tipText + ", type:"
                                    + ((Typeable) port).getType();
                        } catch (IllegalActionException ex) {
                            // System.out.println("Tooltip failed: " + ex);
                        }
                    }

                    return tipText;
                }
            };
            // Have to do this also, or the AWT doesn't display any
            // tooltip at all.
            String tipText = port.getName();
            String displayName = port.getDisplayName();
            if (!tipText.equals(displayName)) {
                tipText = displayName + " (" + tipText + ")";
            }
            figure.setToolTipText(tipText);

            double normal = CanvasUtilities.getNormal(direction);

            if (port instanceof IOPort) {
                // Create a diagonal connector for multiports, if necessary.
                IOPort ioPort = (IOPort) port;

                if (ioPort.isMultiport()) {
                    int numberOfLinks = ioPort.linkedRelationList().size();

                    if (numberOfLinks > 1) {
                        // The diagonal is necessary.
                        CompositeFigure compositeFigure = new CompositeFigure(
                                figure) {
                            // Override this because we want to show the type.
                            // It doesn't work to set it once because the type
                            // has not been resolved, and anyway, it may
                            // change. NOTE: This is copied from above.
                            public String getToolTipText() {
                                String tipText = port.getName();
                                String displayName = port.getDisplayName();
                                if (!tipText.equals(displayName)) {
                                    tipText = displayName + " (" + tipText
                                            + ")";
                                }
                                StringAttribute _explAttr = (StringAttribute) (port
                                        .getAttribute("_explanation"));

                                if (_explAttr != null) {
                                    tipText = _explAttr.getExpression();
                                } else if (port instanceof Typeable) {
                                    try {
                                        tipText = tipText + ", type:"
                                                + ((Typeable) port).getType();
                                    } catch (IllegalActionException ex) {
                                        // System.out.println("Tooltip failed: " + ex);
                                    }
                                }
                                return tipText;
                            }
                        };

                        // Line depends on the orientation.
                        double startX;

                        // Line depends on the orientation.
                        double startY;

                        // Line depends on the orientation.
                        double endX;

                        // Line depends on the orientation.
                        double endY;
                        Rectangle2D bounds = figure.getShape().getBounds2D();
                        double x = bounds.getX();
                        double y = bounds.getY();
                        double width = bounds.getWidth();
                        double height = bounds.getHeight();
                        int extent = numberOfLinks - 1;

                        if (direction == SwingConstants.EAST) {
                            startX = x + width;
                            startY = y + (height / 2);
                            endX = startX
                                    + (extent * MULTIPORT_CONNECTION_SPACING);
                            endY = startY
                                    + (extent * MULTIPORT_CONNECTION_SPACING);
                        } else if (direction == SwingConstants.WEST) {
                            startX = x;
                            startY = y + (height / 2);
                            endX = startX
                                    - (extent * MULTIPORT_CONNECTION_SPACING);
                            endY = startY
                                    - (extent * MULTIPORT_CONNECTION_SPACING);
                        } else if (direction == SwingConstants.NORTH) {
                            startX = x + (width / 2);
                            startY = y;
                            endX = startX
                                    - (extent * MULTIPORT_CONNECTION_SPACING);
                            endY = startY
                                    - (extent * MULTIPORT_CONNECTION_SPACING);
                        } else {
                            startX = x + (width / 2);
                            startY = y + height;
                            endX = startX
                                    + (extent * MULTIPORT_CONNECTION_SPACING);
                            endY = startY
                                    + (extent * MULTIPORT_CONNECTION_SPACING);
                        }

                        Line2D line = new Line2D.Double(startX, startY, endX,
                                endY);
                        Figure lineFigure = new BasicFigure(line, fill,
                                (float) 2.0);
                        compositeFigure.add(lineFigure);
                        figure = compositeFigure;
                    }
                }
View Full Code Here

        /** Called when a connector end is dropped.  Attach or
         *  detach the edge as appropriate.
         */
        public void connectorDropped(ConnectorEvent evt) {
            Connector c = evt.getConnector();
            Figure f = evt.getTarget();
            Object edge = c.getUserObject();
            Object node = (f == null) ? null : f.getUserObject();
            FSMGraphModel model = (FSMGraphModel) getController()
                    .getGraphModel();

            switch (evt.getEnd()) {
            case ConnectorEvent.HEAD_END:
View Full Code Here

TOP

Related Classes of diva.canvas.Figure

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.