Examples of LabelFigure


Examples of diva.canvas.toolbox.LabelFigure

    public static class LabelFigureFactory implements FigureTest.FigureFactory {
        // FindBugs suggests making this class static so as to decrease
        // the size of instances and avoid dangling references.

        public Figure createFigure() {
            LabelFigure label = new LabelFigure("Hello!");
            label.translate(200, 200);
            return label;
        }
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

                headSite.getNormal());
        c.setHeadEnd(arrow);

        Object p = "edge"; //edge.getProperty("label");
        String label = (p == null) ? "#" : (String) p;
        LabelFigure labelFigure = new LabelFigure(label);
        String fontname = labelFigure.getFont().getFontName();
        labelFigure.setFont(new Font(fontname, Font.ITALIC, 14));
        c.setLabelFigure(labelFigure);
        return c;
    }
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

                    }
                };

                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.
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

     @return A new figure.
     */
    public Figure createBackgroundFigure() {
        // Measure width of a character.  Unfortunately, this
        // requires generating a label figure that we will not use.
        LabelFigure label = new LabelFigure("m", _labelFont, 1.0,
                SwingConstants.CENTER);
        Rectangle2D stringBounds = label.getBounds();

        try {
            int numberOfCharacters = ((IntToken) displayWidth.getToken())
                    .intValue();

View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

            public void run() {
                String string = _displayString();
                Iterator figures = _liveFigureIterator();

                while (figures.hasNext()) {
                    LabelFigure figure = (LabelFigure) figures.next();
                    figure.setString(string);
                }
            }
        });
    }
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

            String name = container.getDisplayName();

            // Do not add a label figure if the name is null.
            if ((name != null) && !name.equals("")) {
                if (!_isPropertySet(container, "_centerName")) {
                    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() + 5, backBounds.getY());
                    figure.add(label);
                } else {
                    LabelFigure label = new LabelFigure(name, _labelFont, 1.0,
                            SwingConstants.CENTER);
                    label.translateTo(backBounds.getCenterX(), backBounds
                            .getCenterY());
                    figure.add(label);
                }
            }
        }

        // If specified by a preference, then show parameters.
        Token show = PtolemyPreferences.preferenceValueLocal(container,
                "_showParameters");

        if (show instanceof StringToken) {
            String value = ((StringToken) show).stringValue();
            boolean showOverriddenParameters = value
                    .equals("Overridden parameters only");
            boolean showAllParameters = value.equals("All");

            if ((showOverriddenParameters && !_isPropertySet(container,
                    "_hideAllParameters"))
                    || showAllParameters) {
                StringBuffer parameters = new StringBuffer();
                Iterator settables = container.attributeList(Settable.class)
                        .iterator();

                while (settables.hasNext()) {
                    Settable settable = (Settable) settables.next();

                    if (settable.getVisibility() != Settable.FULL) {
                        continue;
                    }

                    if (!showAllParameters
                            && !((NamedObj) settable).isOverridden()) {
                        continue;
                    }

                    if (!showAllParameters
                            && _isPropertySet((NamedObj) settable, "_hide")) {
                        continue;
                    }

                    String name = settable.getName();
                    String displayName = settable.getDisplayName();
                    parameters.append(displayName);

                    if (showAllParameters && !name.equals(displayName)) {
                        parameters.append(" (" + name + ")");
                    }

                    parameters.append(": ");
                    parameters.append(settable.getExpression());

                    if (settables.hasNext()) {
                        parameters.append("\n");
                    }
                }

                LabelFigure label = new LabelFigure(parameters.toString(),
                        _parameterFont, 1.0, SwingConstants.NORTH_WEST);

                // Shift the label slightly right so it doesn't
                // collide with ports.
                label.translateTo(backBounds.getX() + 5, backBounds.getY()
                        + backBounds.getHeight());
                figure.add(label);
            }
        }
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()) + 10;
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

        // 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.
        LabelFigure newFigure;

        if (_text != null) {
            newFigure = new LabelFigure(_text, _font);
        } else {
            newFigure = new LabelFigure(_DEFAULT_TEXT, _font);
        }

        // By default, the origin should be the upper left.
        newFigure.setAnchor(SwingConstants.NORTH_WEST);
        newFigure.setFillPaint(_textColor);

        _addLiveFigure(newFigure);
        return newFigure;
    }
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

        if (_iconCache != null) {
            return _iconCache;
        }

        // No cached object, so rerender the icon.
        LabelFigure figure = new LabelFigure(_iconText, _font);
        figure.setFillPaint(_textColor);
        _iconCache = new FigureIcon(figure, 20, 15);
        return _iconCache;
    }
View Full Code Here

Examples of diva.canvas.toolbox.LabelFigure

        Nameable container = getContainer();

        if (container instanceof Settable) {
            String name = container.getDisplayName();
            String value = ((Settable) container).getExpression();
            LabelFigure label = new LabelFigure(name + ": " + value,
                    _labelFont, 1.0, SwingConstants.SOUTH_WEST);
            background.add(label);
            return background;
        } else {
            String name = container.getName();
            LabelFigure label = new LabelFigure(name, _labelFont, 1.0,
                    SwingConstants.SOUTH_WEST);
            background.add(label);
            return background;
        }
    }
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.