Examples of LabelFigure


Examples of diva.canvas.toolbox.LabelFigure

     */
    public Figure createFigure() {
        CompositeFigure result = (CompositeFigure) super.createFigure();
        String truncated = _displayString();

        LabelFigure label = new LabelFigure(truncated, _labelFont, 1.0,
                SwingConstants.CENTER);
        Rectangle2D backBounds = result.getBackgroundFigure().getBounds();
        label.translateTo(backBounds.getCenterX(), backBounds.getCenterY());
        result.add(label);

        _addLiveFigure(label);
        return result;
    }
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

    protected RotateOrFlipPorts _rotatePortsCounterclockwise = new RotateOrFlipPorts(
            RotateOrFlipPorts.COUNTERCLOCKWISE, "Rotate Ports Counterclockwise");

    private LabelFigure _createPortLabelFigure(String string, Font font,
            double x, double y, int direction) {
        LabelFigure label;

        if (direction == SwingConstants.SOUTH) {
            // The 1.0 argument is the padding.
            label = new LabelFigure(string, font, 1.0,
                    SwingConstants.SOUTH_WEST);

            // Shift the label down so it doesn't
            // collide with ports.
            label.translateTo(x, y + 5);

            // Rotate the label.
            AffineTransform rotate = AffineTransform.getRotateInstance(
                    Math.PI / 2.0, x, y + 5);
            label.transform(rotate);
        } else if (direction == SwingConstants.EAST) {
            // The 1.0 argument is the padding.
            label = new LabelFigure(string, font, 1.0,
                    SwingConstants.SOUTH_WEST);

            // Shift the label right so it doesn't
            // collide with ports.
            label.translateTo(x + 5, y);
        } else if (direction == SwingConstants.WEST) {
            // The 1.0 argument is the padding.
            label = new LabelFigure(string, font, 1.0,
                    SwingConstants.SOUTH_EAST);

            // Shift the label left so it doesn't
            // collide with ports.
            label.translateTo(x - 5, y);
        } else { // Must be north.

            // The 1.0 argument is the padding.
            label = new LabelFigure(string, font, 1.0,
                    SwingConstants.SOUTH_WEST);

            // Shift the label right so it doesn't
            // collide with ports.  It will probably
            // collide with the actor name.
            label.translateTo(x, y - 5);

            // Rotate the label.
            AffineTransform rotate = AffineTransform.getRotateInstance(
                    -Math.PI / 2.0, x, y - 5);
            label.transform(rotate);
        }

        return label;
    }
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

                            } catch (KernelException ex) {
                                // Ignore.
                            }
                        }

                        LabelFigure labelFigure = _createPortLabelFigure(
                                rateString, _portLabelFont, x, y, direction);
                        labelFigure.setFillPaint(Color.BLUE);
                        figure.add(labelFigure);
                    }
                }

                // If the port contains an attribute named "_showName",
                // then render the name of the port as well. If the
                // attribute is a boolean-valued parameter, then
                // show the name only if the value is true.
                Attribute showAttribute = port.getAttribute("_showName");
                String toShow = null;
                if (showAttribute != null) {
                    boolean show = true;

                    if (showAttribute instanceof Parameter) {
                        try {
                            Token token = ((Parameter) showAttribute)
                                    .getToken();

                            if (token instanceof BooleanToken) {
                                show = ((BooleanToken) token).booleanValue();
                            }
                        } catch (IllegalActionException e) {
                            // Ignore. Presence of the attribute will prevail.
                        }
                    }

                    if (show) {
                        toShow = port.getDisplayName();
                    }
                }
                // In addition, if the port contains an attribute
                // called "_showInfo", then if that attribute is
                // a variable, then its value is shown. Otherwise,
                // if it is a Settable, then its expression is shown.
                Attribute showInfo = port.getAttribute("_showInfo");
                try {
                    if (showInfo instanceof Variable
                            && !((Variable) showInfo).isStringMode()) {
                        String value = ((Variable) showInfo).getToken()
                                .toString();
                        if (toShow != null) {
                            toShow += " (" + value + ")";
                        } else {
                            toShow = value;
                        }
                    } else if (showInfo instanceof Settable) {
                        if (toShow != null) {
                            toShow += " ("
                                    + ((Settable) showInfo).getExpression()
                                    + ")";
                        } else {
                            toShow = ((Settable) showInfo).getExpression();
                        }
                    }
                } catch (IllegalActionException e) {
                    toShow += e.getMessage();
                }

                if (toShow != null) {
                    LabelFigure labelFigure = _createPortLabelFigure(toShow,
                            _portLabelFont, x, y, direction);
                    figure.add(labelFigure);
                }
            }
        }
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

        double width = 60;
        double height = 30;

        // Measure width of the text.  Unfortunately, this
        // requires generating a label figure that we will not use.
        LabelFigure label = new LabelFigure(name, _labelFont, 1.0,
                SwingConstants.CENTER);
        Rectangle2D stringBounds = label.getBounds();

        // NOTE: Padding of 20. Quantize the height so that
        // snap to grid still works.
        width = Math.floor(stringBounds.getWidth()) + 20;
        height = Math.floor(stringBounds.getHeight()) + 10;
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

        String name = "No Name";
        NamedObj container = getContainer();
        if (container != null) {
            name = container.getDisplayName();
        }
        LabelFigure label = new LabelFigure(name, _labelFont, 1.0,
                SwingConstants.CENTER);
        Rectangle2D backBounds = result.getBackgroundFigure().getBounds();
        label.translateTo(backBounds.getCenterX(), backBounds.getCenterY());
        result.add(label);
        return result;
    }
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

                    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);
                    label.translateTo((width / 2) + 1.0, (-height / 2) - 1.0);
                    result.add(label);
                }
            }

            return result;
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

        double height = 30;

        if (displayString != null) {
            // Measure width of the text.  Unfortunately, this
            // requires generating a label figure that we will not use.
            LabelFigure label = new LabelFigure(displayString, _labelFont, 1.0,
                    SwingConstants.CENTER);
            Rectangle2D stringBounds = label.getBounds();

            // NOTE: Padding of 20. Quantize the height so that
            // snap to grid still works.
            width = Math.floor(stringBounds.getWidth()) + 20;
            height = Math.floor(stringBounds.getHeight()) + 20;
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

        double heigth = 30;

        if (displayString != null) {
            // Measure width of the text.  Unfortunately, this
            // requires generating a label figure that we will not use.
            LabelFigure label = new LabelFigure(displayString, _labelFont, 1.0,
                    SwingConstants.CENTER);
            Rectangle2D stringBounds = label.getBounds();

            // NOTE: Padding of 20.
            width = stringBounds.getWidth() + 20;
            heigth = stringBounds.getHeight() + 10;
        }
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

        // NOTE: This violates the Diva MVC architecture!
        // This attribute is part of the model, and should not have
        // a reference to this figure.  By doing so, it precludes the
        // possibility of having multiple views on this model.
        LabelFigure label = new LabelFigure(truncated, _labelFont, 1.0,
                SwingConstants.CENTER);
        Rectangle2D backBounds = result.getBackgroundFigure().getBounds();
        label.translateTo(backBounds.getCenterX(), backBounds.getCenterY());
        result.add(label);

        _addLiveFigure(label);
        return result;
    }
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

            public void changeFailed(ChangeRequest change, Exception exception) {
                if (_graphPane == null) {
                    super.changeFailed(change, exception);
                    return;
                }
                LabelFigure newFigure = new LabelFigure("No icon available",
                        _font);
                _graphPane.getForegroundLayer().add(newFigure);
                CanvasUtilities.translateTo(newFigure, 100.0, 100.0);
                controller.dispatch(new GraphViewEvent(this,
                        GraphViewEvent.NODE_DRAWN, newFigure));
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.