Package diva.canvas

Examples of diva.canvas.Site


            Iterator i = _geometry.sites();
            GrabHandle g = null;

            while (i.hasNext()) {
                // Create a grab handle and set up the interactor
                Site site = (Site) i.next();
                g = getGrabHandleFactory().createGrabHandle(site);
                g.setParent(this);
                g.setInteractor(getHandleInteractor());
                addGrabHandle(g);
            }
View Full Code Here


            Iterator i = _geometry.sites();
            GrabHandle g = null;

            while (i.hasNext()) {
                // Create a grab handle and set up the interactor
                Site site = (Site) i.next();
                g = getGrabHandleFactory().createGrabHandle(site);
                g.setParent(this);
                g.setInteractor(getHandleInteractor());
                addGrabHandle(g);
            }
View Full Code Here

     */
    public void createConnectors() {
        FigureLayer layer = graphicsPane.getForegroundLayer();

        // Create the first connector
        Site a = figureA.getE();
        Site b = figureB.getN();
        connectorA = new StraightConnector(a, b);

        // Add the circle and arrowhead to it
        Blob blob = new Blob(a.getX(), a.getY(), a.getNormal(),
                Blob.BLOB_CIRCLE);
        connectorA.setTailEnd(blob);

        Arrowhead arrow = new Arrowhead(b.getX(), b.getY(), b.getNormal());
        connectorA.setHeadEnd(arrow);

        // Add it to the layer
        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);
View Full Code Here

        /** Return the nearest site on the figure
         */
        public Site getHeadSite(Figure f, double x, double y) {
            if (f instanceof SitedRectangle) {
                SitedRectangle sr = (SitedRectangle) f;
                Site s = closest(sr.getN(), sr.getS(), x, y);
                s = closest(s, sr.getE(), x, y);
                s = closest(s, sr.getW(), x, y);
                return s;
            } else {
                return null;
View Full Code Here

                }
                if (_sites[cursor] == null) {
                    _sites[cursor] = new BoundsSite(cursor);
                }

                Site result = _sites[cursor];
                cursor++;
                return result;
            }

            public void remove() {
View Full Code Here

            GrabHandle g = null;

            while (i.hasNext()) {
                // Create a grab handle and set up the interactor.
                // Unless it's a close segment, in which case we ignore it.
                Site site = (Site) i.next();

                if (!(site instanceof PathGeometry.CloseSegment)) {
                    g = getGrabHandleFactory().createGrabHandle(site);
                    g.setParent(this);
                    g.setInteractor(getHandleInteractor());
View Full Code Here

        // Create the target that finds sites on the figures
        target = new SelfPTarget();

        // Create the first connector. We don't care about the actual
        // location at this stage
        Site a = target.getTailSite(figureA, 0.0, 0.0);
        Site b = target.getHeadSite(figureB, 0.0, 0.0);
        connectorA = new StraightConnector(a, b);
        layer.add(connectorA);

        // Add an arrowhead to it
        Arrowhead arrow = new Arrowhead(b.getX(), b.getY(), b.getNormal());
        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);
        layer.add(connectorD);
        arrow = new Arrowhead(b.getX(), b.getY(), b.getNormal());
        connectorD.setHeadEnd(arrow);
    }
View Full Code Here

    public Site getHeadSite(Figure f, double x, double y) {
        if (!(f instanceof Connector)) {
            if (_siteMap.containsKey(f)) {
                return (Site) _siteMap.get(f);
            } else {
                Site s = new CenterSite(f);
                _siteMap.put(f, s);
                return s;
            }
        }
View Full Code Here

     * type is tighter.
     */
    public Polyline2D routeManhattan(ManhattanConnector c) {
        TransformContext currentContext = c.getTransformContext();

        Site headSite = c.getHeadSite();
        Site tailSite = c.getTailSite();
        Point2D headPt;
        Point2D tailPt;

        // Get the transformed head and tail points. Sometimes
        // people will call this before the connector is added
        // to a container, so deal with it
        if (currentContext != null) {
            tailPt = tailSite.getPoint(currentContext);
            headPt = headSite.getPoint(currentContext);
        } else {
            tailPt = tailSite.getPoint();
            headPt = headSite.getPoint();
        }

        double xDiff = headPt.getX() - tailPt.getX();
        double yDiff = headPt.getY() - tailPt.getY();

        // Infer normals if there are none.  This needs to be
        // smarter, and should depend on the normal at the other
        // end if there is one.
        int headDir = CanvasUtilities.reverseDirection(getManhattanDirection(
                xDiff, yDiff));

        // FIXME: Changing the normal here has the side effect
        // of also changing the point on the head site!
        // This means that on the next call, getManhattanDirection()
        // above may return a different direction, resulting in an
        // annoying flip-flopping of the direction.
        headSite.setNormal(CanvasUtilities.getNormal(headDir));

        if (currentContext != null) {
            headPt = headSite.getPoint(currentContext);
        } else {
            headPt = headSite.getPoint();
        }

        int tailDir = getManhattanDirection(xDiff, yDiff);
        tailSite.setNormal(CanvasUtilities.getNormal(tailDir));

        if (currentContext != null) {
            tailPt = tailSite.getPoint(currentContext);
        } else {
            tailPt = tailSite.getPoint();
        }

        // The site may not allow it's normal to be changed.  In
        // which case, we have to ask it for its site again.
        headDir = CanvasUtilities.getDirection(headSite.getNormal());
        tailDir = CanvasUtilities.getDirection(tailSite.getNormal());

        // Adjust for decorations on the ends
        double headAngle = CanvasUtilities.getNormal(headDir);
        double tailAngle = CanvasUtilities.getNormal(tailDir);

View Full Code Here

    protected void fireConnectorEvent(int id) {
        // NOTE: The following cast is safe because the method that
        // creates grab handles in ArcManipulator ensures that the
        // connector is an instance of ArcConnector.
        ArcConnector connector = (ArcConnector) getConnector();
        Site site = getHandle().getSite();
        int end;

        if (site == connector.getTailSite()) {
            end = ConnectorEvent.TAIL_END;
        } else if (site == connector.getMidpointSite()) {
View Full Code Here

TOP

Related Classes of diva.canvas.Site

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.