Examples of BasicFigure


Examples of diva.canvas.toolbox.BasicFigure

        //                 _container.getWidth()/2, _container.getHeight()/2);
        //         pane.translate(_origin.x, _origin.y);
        pane.setTransform(transform);
        pane.setAntialiasing(true);

        _crosshairX = new BasicFigure(new java.awt.geom.Line2D.Double(0, 2, 0,
                -2));
        _crosshairY = new BasicFigure(new java.awt.geom.Line2D.Double(2, 0, -2,
                0));
        _overlayLayer.add(_crosshairX.getShape());
        _overlayLayer.add(_crosshairY.getShape());

        _eventHandler = new ViewScreen2DListener();
View Full Code Here

Examples of diva.canvas.toolbox.BasicFigure

        rectangle.setFrameFromCenter(_getCenterPoint(), _getCornerPoint());
        rectangle.arcwidth = ((DoubleToken) arcWidth.getToken()).doubleValue();
        rectangle.archeight = ((DoubleToken) arcHeight.getToken())
                .doubleValue();

        return new BasicFigure(rectangle);
    }
View Full Code Here

Examples of diva.canvas.toolbox.BasicFigure

     @exception IllegalActionException If a parameter value is not valid.
     */
    protected BasicFigure _createFigure() throws IllegalActionException {
        java.awt.geom.Ellipse2D.Double ellipse = new java.awt.geom.Ellipse2D.Double();
        ellipse.setFrameFromCenter(_getCenterPoint(), _getCornerPoint());
        return new BasicFigure(ellipse);
    }
View Full Code Here

Examples of diva.canvas.toolbox.BasicFigure

                    //                     //polygon2.lineTo(5, 9);

                    //                     polygon2.closePath();
                    //                     paintedList.add(new PaintedPath(polygon2, (float) 1.0, Color.black));
                    //                     figure = new PaintedFigure(paintedList);
                    figure = new BasicFigure(polygon, new Color(0, 0, 0, 0),
                            (float) 0.0);
                } else {
                    figure = new BasicFigure(polygon, fill, (float) 1.5);
                }

                if (!(port instanceof IOPort)) {
                    direction = SwingConstants.NORTH;
                } else {
                    IOPort ioport = (IOPort) port;

                    if (ioport.isInput() && ioport.isOutput()) {
                        direction = SwingConstants.NORTH;
                    } else if (ioport.isInput()) {
                        direction = SwingConstants.EAST;
                    } else if (ioport.isOutput()) {
                        direction = SwingConstants.WEST;
                    } else {
                        // should never happen
                        direction = SwingConstants.NORTH;
                    }
                }

                double normal = CanvasUtilities.getNormal(direction);

                String name = port.getName();
                Rectangle2D backBounds = figure.getBounds();
                figure = 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() {
                        return _portTooltip(port);
                    }
                };

                if ((name != null) && !name.equals("")
                        && !(port instanceof ParameterPort)) {
                    LabelFigure label = new LabelFigure(name, _labelFont, 1.0,
                            SwingConstants.SOUTH_WEST);

                    // Shift the label slightly right so it doesn't
                    // collide with ports.
                    label.translateTo(backBounds.getX(), backBounds.getY());
                    ((CompositeFigure) figure).add(label);
                }

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

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

                        if (numberOfLinks > 1) {
                            // The diagonal is necessary.
                            // Line depends on the orientation.
                            double startX;

                            // The diagonal is necessary.
                            // Line depends on the orientation.
                            double startY;

                            // The diagonal is necessary.
                            // Line depends on the orientation.
                            double endX;

                            // The diagonal is necessary.
                            // 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 * IOPortController.MULTIPORT_CONNECTION_SPACING);
                                endY = startY
                                        + (extent * IOPortController.MULTIPORT_CONNECTION_SPACING);
                            } else if (direction == SwingConstants.WEST) {
                                startX = x;
                                startY = y + (height / 2);
                                endX = startX
                                        - (extent * IOPortController.MULTIPORT_CONNECTION_SPACING);
                                endY = startY
                                        - (extent * IOPortController.MULTIPORT_CONNECTION_SPACING);
                            } else if (direction == SwingConstants.NORTH) {
                                startX = x + (width / 2);
                                startY = y;
                                endX = startX
                                        - (extent * IOPortController.MULTIPORT_CONNECTION_SPACING);
                                endY = startY
                                        - (extent * IOPortController.MULTIPORT_CONNECTION_SPACING);
                            } else {
                                startX = x + (width / 2);
                                startY = y + height;
                                endX = startX
                                        + (extent * IOPortController.MULTIPORT_CONNECTION_SPACING);
                                endY = startY
                                        + (extent * IOPortController.MULTIPORT_CONNECTION_SPACING);
                            }

                            Line2D line = new Line2D.Double(startX, startY,
                                    endX, endY);
                            Figure lineFigure = new BasicFigure(line, fill,
                                    (float) 2.0);
                            ((CompositeFigure) figure).add(lineFigure);
                        }
                    }

                    figure = new PortTerminal(ioPort, figure, normal, true);
                } else {
                    Site tsite = new PerimeterSite(figure, 0);
                    tsite.setNormal(normal);
                    tsite = new FixedNormalSite(tsite);
                    figure = new TerminalFigure(figure, tsite) {
                        // Override this because the tooltip may
                        // change over time.  I.e., the port may
                        // change from being an input or output, etc.
                        public String getToolTipText() {
                            return _portTooltip(port);
                        }
                    };
                }

                // Have to do this as well or awt will not render a tooltip.
                figure.setToolTipText(port.getName());
            } else {
                polygon.moveTo(0, 0);
                polygon.lineTo(0, 10);
                polygon.lineTo(12, 0);
                polygon.lineTo(0, -10);
                polygon.closePath();

                figure = new BasicFigure(polygon, Color.black);
                figure.setToolTipText("Unknown port");
            }

            return figure;
        }
View Full Code Here

Examples of diva.canvas.toolbox.BasicFigure

            CompositeFigure cf = (CompositeFigure) nf;
            Figure backgroundFigure = cf.getBackgroundFigure();

            // This might be null because the node is hidden.
            if (backgroundFigure != null) {
                BasicFigure bf = new BasicFigure(backgroundFigure.getBounds(),
                        4.0f);
                bf.setStrokePaint(_HIGHLIGHT_COLOR);
                // Put the highlighting in the background,
                // behind the actor label.
                int index = cf.getFigureCount();
                if (index < 0) {
                    index = 0;
View Full Code Here

Examples of diva.canvas.toolbox.BasicFigure

                if (object instanceof NamedObj && cf != null && !_transformed
                        && _results != null
                        && _results.get(_currentPosition).containsValue(object)) {
                    Rectangle2D bounds = cf.getBackgroundFigure().getBounds();
                    float padding = _HIGHLIGHT_PADDING;
                    BasicFigure bf = new BasicRectangle(bounds.getX() - padding,
                            bounds.getY() - padding,
                            bounds.getWidth() + padding * 2.0,
                            bounds.getHeight() + padding * 2.0,
                            _HIGHLIGHT_THICKNESS);
                    bf.setStrokePaint(_HIGHLIGHT_COLOR);

                    int index = cf.getFigureCount();
                    if (index < 0) {
                        index = 0;
                    }
View Full Code Here

Examples of diva.canvas.toolbox.BasicFigure

        // able to update that figure when setShape() is called.  Hence,
        // this class keeps a list of all the figures it has created.
        // The references to these figures, however, have to be weak
        // references, so that this class does not interfere with garbage
        // collection of the figure when the view is destroyed.
        BasicFigure newFigure;

        if (_shape != null) {
            newFigure = new BasicFigure(_shape);
        } else {
            // Create a white rectangle.
            newFigure = new BasicFigure(new Rectangle2D.Double(0.0, 0.0, 20.0,
                    20.0));
        }

        // By default, the origin should be the upper left.
        newFigure.setCentered(_centered);
        newFigure.setLineWidth(_lineWidth);
        newFigure.setDashArray(_dashArray);
        newFigure.setStrokePaint(_lineColor);
        newFigure.setFillPaint(_fillColor);

        _addLiveFigure(newFigure);

        return newFigure;
    }
View Full Code Here

Examples of diva.canvas.toolbox.BasicFigure

            polygon.lineTo(0, height / 2);
            polygon.lineTo(-width / 2, 0);
            polygon.lineTo(0, -height / 2);
            polygon.closePath();

            Figure figure = new BasicFigure(polygon, Color.black);

            if (node != null) {
                ActorGraphModel model = (ActorGraphModel) getController()
                        .getGraphModel();
                figure
                        .setToolTipText(relation.getName(model
                                .getPtolemyModel()));
                // Old way to set the color.
                try {
                    StringAttribute colorAttr = (StringAttribute) (relation
                            .getAttribute("_color", StringAttribute.class));

                    if (colorAttr != null) {
                        String color = colorAttr.getExpression();
                        ((BasicFigure) figure).setFillPaint(SVGUtilities
                                .getColor(color));
                    }
                } catch (IllegalActionException e) {
                    // Ignore.
                }
                // New way to set the color
                try {
                    ColorAttribute colorAttr = (ColorAttribute) (relation
                            .getAttribute("_color", ColorAttribute.class));
                    if (colorAttr != null) {
                        Color color = colorAttr.asColor();
                        ((BasicFigure) figure).setFillPaint(color);
                    }
                } catch (IllegalActionException e) {
                    // Ignore.
                }
            }

            CompositeFigure result = new CompositeFigure(figure);

            if (relation instanceof IORelation) {
                if (((IORelation) relation).getWidth() > 1) {
                    // Restore width and height to the default to get a reasonable slash.
                    width = 12.0;
                    height = 12.0;

                    Line2D.Double line = new Line2D.Double(-width / 2,
                            height / 2, width / 2, -height / 2);
                    Figure lineFigure = new BasicFigure(line, Color.black);
                    result.add(lineFigure);

                    LabelFigure label = new LabelFigure(""
                            + ((IORelation) relation).getWidth(),
                            _relationLabelFont, 0, SwingConstants.SOUTH_WEST);
View Full Code Here

Examples of diva.canvas.toolbox.BasicFigure

            // Get the corresponding graph node and its figure
            Object node = _nodeMap.get(actor);
            LabelWrapper wrapper = (LabelWrapper) _graphPane
                    .getGraphController().getFigure(node);
            final BasicFigure figure = (BasicFigure) wrapper.getChild();

            // Color the graph
            try {
                // Used to use invokeAndWait() here, but this leads to deadlock!
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        if (state == ExecEvent.WAITING) {
                            figure.setFillPaint(Color.yellow);
                        } else if (state == ExecEvent.ACCESSING) {
                            figure.setFillPaint(Color.green);
                        } else if (state == ExecEvent.BLOCKED) {
                            figure.setFillPaint(Color.red);
                        } else {
                            System.err.println("Unknown state: " + state);
                        }
                    }
                });
View Full Code Here

Examples of diva.canvas.toolbox.BasicFigure

            boolean isEllipse = actor instanceof Controller
                    || actor instanceof Memory
                    || actor instanceof ContentionAlarm;

            BasicFigure f;

            if (isEllipse) {
                f = new BasicEllipse(0, 0, _size, _size);
            } else {
                f = new BasicRectangle(0, 0, _size, _size);
                f.setFillPaint(Color.blue);
            }

            String label = actor.getName();
            LabelWrapper w = new LabelWrapper(f, label);
            w.setAnchor(SwingConstants.SOUTH);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.