Package diva.canvas.connector

Examples of diva.canvas.connector.ArcConnector

Currently, only the first is supported.

The connector uses an instance of PaintedPath to draw itself, so see that class for a more detailed description of the paint- and stroke-related methods. @version $Id: ArcConnector.java,v 1.19 2005/07/08 19:54:48 cxh Exp $ @author Edward Lee @author John Reekie @Pt.AcceptedRating Red


        connectorA.setHeadEnd(arrow);

        // Create the second connector with an arrowhead
        a = target.getTailSite(figureB, 0.0, 0.0);
        b = target.getHeadSite(figureC, 0.0, 0.0);
        connectorB = new ArcConnector(a, b);
        layer.add(connectorB);
        arrow = new Arrowhead(b.getX(), b.getY(), b.getNormal());
        connectorB.setHeadEnd(arrow);

        // Create the third connector with an arrowhead
        a = target.getTailSite(figureB, 0.0, 0.0);
        b = target.getHeadSite(figureC, 0.0, 0.0);
        connectorC = new ArcConnector(a, b);

        // Swap the direction
        connectorC.setAngle(-connectorC.getAngle());
        layer.add(connectorC);
        arrow = new Arrowhead(b.getX(), b.getY(), b.getNormal());
        connectorC.setHeadEnd(arrow);

        // Create a fourth connector with an arrowhead, which is a "self-loop"
        a = target.getTailSite(figureB, 0.0, 0.0);
        b = target.getHeadSite(figureB, 0.0, 0.0);
        connectorD = new ArcConnector(a, b);
        connectorD.setSelfLoop(true);

        // Swap the direction
        // connectorD.setAngle(-connectorD.getAngle());
        // connectorD.setAngle(-0.1);
View Full Code Here


        Figure tf = tailSite.getFigure();
        Figure hf = headSite.getFigure();

        //if the edge is a self loop, create an ArcConnector instead!
        if ((tf != null) && (hf != null) && (tf == hf)) {
            c = new ArcConnector(tailSite, headSite);
        } else {
            c = new StraightConnector(tailSite, headSite);
        }

        Arrowhead arrow = new Arrowhead(headSite.getX(), headSite.getY(),
View Full Code Here

public class ArcRenderer implements EdgeRenderer {
    /** Render a visual representation of the given edge.
     */
    public Connector render(Object edge, Site tailSite, Site headSite) {
        // FIXME: Find a way to set the curvature (the third argument).
        ArcConnector c = new ArcConnector(tailSite, headSite);
        Arrowhead arrow = new Arrowhead(headSite.getX(), headSite.getY(),
                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

    /** Render a link.
     */
    public class LinkRenderer implements EdgeRenderer {
        /** Render a visual representation of the given edge. */
        public Connector render(Object edge, Site tailSite, Site headSite) {
            ArcConnector c = new ArcConnector(tailSite, headSite);
            Arrowhead arrowhead = new Arrowhead();
            c.setHeadEnd(arrowhead);
            c.setLineWidth((float) 2.0);
            c.setUserObject(edge);

            Arc arc = (Arc) edge;
            Transition transition = (Transition) arc.getRelation();

            // When first dragging out a transition, the relation
            // may still be null.
            if (transition != null) {
                // Use a larger, unfilled arrowhead for a reset transition.
                try {
                    if (((BooleanToken) transition.reset.getToken())
                            .booleanValue()) {
                        arrowhead.setFilled(false);
                    }
                } catch (IllegalActionException e) {
                    // Ignore erroneous parameter value.
                }
                if (transition.isPreemptive()) {
                    Blob blob = new Blob(0, 0, 0, Blob.BLOB_CIRCLE, 4.0,
                            Color.red);
                    blob.setFilled(true);
                    c.setTailEnd(blob);
                }
                if (transition.isNondeterministic()) {
                    c.setStrokePaint(Color.RED);
                }

                c.setToolTipText(transition.getName());

                String labelStr = transition.getLabel();

                try {
                    double exitAngle = ((DoubleToken) (transition.exitAngle
                            .getToken())).doubleValue();

                    // If the angle is too large, then truncate it to
                    // a reasonable value.
                    double maximum = 99.0 * Math.PI;

                    if (exitAngle > maximum) {
                        exitAngle = maximum;
                    } else if (exitAngle < -maximum) {
                        exitAngle = -maximum;
                    }

                    // If the angle is zero, then the arc does not get
                    // drawn.  So we restrict it so that it can't quite
                    // go to zero.
                    double minimum = Math.PI / 999.0;

                    if ((exitAngle < minimum) && (exitAngle > -minimum)) {
                        if (exitAngle > 0.0) {
                            exitAngle = minimum;
                        } else {
                            exitAngle = -minimum;
                        }
                    }

                    c.setAngle(exitAngle);

                    // Set the gamma angle
                    double gamma = ((DoubleToken) (transition.gamma.getToken()))
                            .doubleValue();
                    c.setGamma(gamma);
                } catch (IllegalActionException ex) {
                    // Ignore, accepting the default.
                    // This exception should not occur.
                }

                if (!labelStr.equals("")) {
                    // FIXME: get label position modifier, if any.
                    LabelFigure label = new LabelFigure(labelStr, _labelFont);
                    label.setFillPaint(Color.black);
                    c.setLabelFigure(label);
                }
            }

            return c;
        }
View Full Code Here

TOP

Related Classes of diva.canvas.connector.ArcConnector

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.