Examples of ManhattanConnector


Examples of diva.canvas.connector.ManhattanConnector

        layer.add(connectorA);

        // Create the second connector
        Site c = figureA.getS();
        Site d = figureB.getW();
        connectorB = new ManhattanConnector(c, d);

        // Add the diamond
        Blob diamond = new Blob(c.getX(), c.getY(), c.getNormal(),
                Blob.BLOB_DIAMOND);
        diamond.setSizeUnit(6.0);
View Full Code Here

Examples of diva.canvas.connector.ManhattanConnector

         @param headSite The head site.
         *  @return The Connector that represents the edge.
         */
        public Connector render(Object edge, Site tailSite, Site headSite) {
            Link link = (Link) edge;
            ManhattanConnector connector = new LinkManhattanConnector(tailSite,
                    headSite, link);

            if ((link.getHead() != null) && (link.getTail() != null)) {
                connector.setLineWidth((float) 2.0);
            }

            connector.setUserObject(edge);

            // The default bend radius of 50 is too large...
            // parallel curves look bad.
            connector.setBendRadius(20);

            Relation relation = link.getRelation();

            if (relation != null) {
                String tipText = relation.getName();
                String displayName = relation.getDisplayName();
                if (!tipText.equals(displayName)) {
                    tipText = displayName + " (" + tipText + ")";
                }
                connector.setToolTipText(tipText);

                try {
                    // FIXME: This isn't quite right for relation groups.
                    StringAttribute colorAttribute = (StringAttribute) (relation
                            .getAttribute("_color", StringAttribute.class));

                    if (colorAttribute != null) {
                        String color = colorAttribute.getExpression();
                        if (color != null && !color.trim().equals("")) {
                            connector.setStrokePaint(SVGUtilities
                                    .getColor(color));
                        }
                    }
                } catch (IllegalActionException e) {
                    // Ignore;
                }
                try {
                    // FIXME: This isn't quite right for relation groups.
                    ColorAttribute colorAttribute = (ColorAttribute) (relation
                            .getAttribute("color", ColorAttribute.class));

                    if (colorAttribute != null) {
                        Color color = colorAttribute.asColor();
                        connector.setStrokePaint(color);
                    }
                } catch (IllegalActionException e) {
                    // Ignore;
                }

                StringAttribute _explAttr = (StringAttribute) (relation
                        .getAttribute("_explanation"));

                if (_explAttr != null) {
                    connector.setToolTipText(_explAttr.getExpression());
                }

                // NOTE: The preferences mechanism may set this.
                Token radiusValue = PtolemyPreferences.preferenceValue(
                        relation, "_linkBendRadius");

                if (radiusValue instanceof DoubleToken) {
                    double overrideRadius = ((DoubleToken) radiusValue)
                            .doubleValue();
                    connector.setBendRadius(overrideRadius);
                }
            }

            return connector;
        }
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.