Package diva.canvas.toolbox

Examples of diva.canvas.toolbox.BasicFigure


                bounds = new Rectangle2D.Double(bounds.getX() - padding, bounds
                        .getY()
                        - padding, bounds.getWidth() + padding * 2.0, bounds
                        .getHeight()
                        + padding * 2.0);
                BasicFigure bf = new BasicFigure(bounds);
                bf.setStroke(stroke);
                bf.setStrokePaint(CLASS_ELEMENT_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


            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

        // translate origin towards center of canvas
        AffineTransform at = new AffineTransform();
        at.translate(200.0f, 200.0f);
        p.transform(at);

        BasicFigure star = new BasicFigure(p);
        star.setLineWidth(2);
        star.setStrokePaint(Color.blue);
        figureLayer.add(star);
        star.setInteractor(selectionInteractor);

        // Create a cloud, Claude
        Shape area = ShapeUtilities.createCloudShape();

        //         Area area = new Area();
        //         Ellipse2D c = new Ellipse2D.Double();
        //         c.setFrame(0,25,50,50);
        //         area.add(new Area(c));
        //         c.setFrame(25,0,40,40);
        //         area.add(new Area(c));
        //         c.setFrame(25,25,60,60);
        //         area.add(new Area(c));
        //         c.setFrame(60,30,40,40);
        //         area.add(new Area(c));
        //         c.setFrame(60,10,30,30);
        //         area.add(new Area(c));
        AffineTransform cat = new AffineTransform();
        cat.translate(200, 100);
        cat.scale(2.0, 2.0);

        Shape bigarea = cat.createTransformedShape(area);

        BasicFigure cloud = new BasicFigure(bigarea, Color.blue);
        cloud.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
                0.5f));
        figureLayer.add(cloud);
        cloud.setInteractor(selectionInteractor);
    }
View Full Code Here

        // The measure-band figure (made up of sub figures below)
        mband = new CompositeFigure();

        // Diagonal line
        mbandLine = new BasicFigure(new GeneralPath(), 1.0f);
        mbandLine.setStrokePaint(Color.white);
        mband.add(mbandLine);

        // Angle lines (horizontal and vertical)
        mbandAngle = new BasicFigure(new Polyline2D.Double(), 1.0f);
        mbandAngle.setStrokePaint(Color.white);
        mbandAngle.setStroke(new BasicStroke(1,
                BasicStroke.CAP_BUTT,
                BasicStroke.JOIN_BEVEL,
                0,
                new float[]{4, 4},
                0));
        mband.add(mbandAngle);

        // box around width label
        mbandWidthRect = new BasicFigure(new Rectangle2D.Double(), Color.yellow);
        mband.add(mbandWidthRect);

        // box around height label
        mbandHeightRect = new BasicFigure(new Rectangle2D.Double(), Color.yellow);
        mband.add(mbandHeightRect);

        // box around diagonal label
        mbandDiagRect = new BasicFigure(new Rectangle2D.Double(), Color.yellow);
        mband.add(mbandDiagRect);

        // The width label
        mbandWidthText = new LabelFigure(" "); // note: diva-0.3 bug with empty string
        mbandWidthText.setFillPaint(Color.blue);
View Full Code Here

TOP

Related Classes of diva.canvas.toolbox.BasicFigure

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.