Package diva.canvas

Examples of diva.canvas.Site


    /** Override the base class to return a different site for each
     *  connection to a multiport.
     *  @return The connection site.
     */
    public Site getTailSite() {
        Site result = super.getTailSite();
        if ((_tailPort == null) || !_tailPort.isMultiport()) {
            return result;
        }
        if (result instanceof PortConnectSite) {
            PortTerminal terminal = ((PortConnectSite) result).getTerminal();
            int orderIndex = terminal.getOrderIndex(this);

            if (orderIndex >= 0) {
                // This should not create a new site if it has already
                // created one!  Record the ones created and return them.
                if (_tailSites == null) {
                    _tailSites = new ArrayList();
                }
                if (_tailSites.size() > orderIndex) {
                    if (_tailSites.get(orderIndex) == null) {
                        result = new PortConnectSite(result.getFigure(),
                                terminal, orderIndex + 1, result.getNormal());
                    } else {
                        result = (Site) _tailSites.get(orderIndex);
                    }
                    _tailSites.set(orderIndex, result);
                } else {
                    result = new PortConnectSite(result.getFigure(), terminal,
                            orderIndex + 1, result.getNormal());
                    while (_tailSites.size() < orderIndex) {
                        _tailSites.add(null);
                    }
                    _tailSites.add(result);
                }
View Full Code Here


            model.getArcModel().setTail(link, sourceObject);

            try {
                // add it to the foreground layer.
                FigureLayer layer = getGraphPane().getForegroundLayer();
                Site headSite;
                Site tailSite;

                // Temporary sites.  One of these will get removed later.
                headSite = new AutonomousSite(layer, event.getLayerX(), event
                        .getLayerY());
                tailSite = new AutonomousSite(layer, event.getLayerX(), event
View Full Code Here

                // connectors exit the port. Note that this direction is the
                // same direction that is used to layout the port in the
                // Entity Controller.
                figure = new PortTerminal(ioPort, figure, normal, false);
            } else {
                Site tsite = new PerimeterSite(figure, 0);
                tsite.setNormal(normal);
                figure = new TerminalFigure(figure, tsite);
            }

            // New way to specify a highlight color.
            try {
View Full Code Here

     */
    public void route() {
        repaint();

        TransformContext currentContext = getTransformContext();
        Site headSite = getHeadSite();
        Site tailSite = getTailSite();
        Figure tailFigure = tailSite.getFigure();
        Figure headFigure = headSite.getFigure();

        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();
        }

        // Figure out the centers of the attached figures
        Point2D tailCenter;

        // Figure out the centers of the attached figures
        Point2D headCenter;

        if (tailFigure != null) {
            tailCenter = CanvasUtilities.getCenterPoint(tailFigure,
                    currentContext);
        } else {
            tailCenter = tailPt;
        }

        if (headFigure != null) {
            headCenter = CanvasUtilities.getCenterPoint(headFigure,
                    currentContext);
        } else {
            headCenter = headPt;
        }

        // Change self-loop mode if necessary
        boolean selfloop = _selfloop;

        if ((tailFigure != null) && (headFigure != null)) {
            selfloop = (tailFigure == headFigure);
        }

        if (selfloop && !_selfloop) {
            setSelfLoop(true);
        } else if (!selfloop && _selfloop) {
            setSelfLoop(false);
        }

        // Figure out the angle between the centers. If a selfloop,
        // use the angle that was previously stored.
        double gamma;
        double x = headCenter.getX() - tailCenter.getX();
        double y = headCenter.getY() - tailCenter.getY();

        if (_selfloop) {
            gamma = _gamma;
        } else {
            gamma = Math.atan2(y, x);
        }

        // Tell the sites to adjust their positions
        double alpha = _exitAngle;
        double beta = (Math.PI / 2.0) - alpha;
        double headNormal = gamma - alpha - Math.PI;
        double tailNormal = gamma + alpha;
        tailSite.setNormal(tailNormal);
        headSite.setNormal(headNormal);

        // Recompute the head and tail points
        if (currentContext != null) {
            tailPt = tailSite.getPoint(currentContext);
            headPt = headSite.getPoint(currentContext);
        } else {
            tailPt = tailSite.getPoint();
            headPt = headSite.getPoint();
        }

        // Adjust for decorations on the ends
        if (getHeadEnd() != null) {
View Full Code Here

     * midpoint moves by something close to the given amount.
     */
    public void translateMidpoint(double dx, double dy) {
        // Calculate some parameters
        TransformContext currentContext = getTransformContext();
        Site headSite = getHeadSite();
        Site tailSite = getTailSite();
        Figure tailFigure = tailSite.getFigure();
        Figure headFigure = headSite.getFigure();

        Point2D headPt;
        Point2D tailPt;

        // Get the transformed head and tail points
        if (currentContext != null) {
            tailPt = tailSite.getPoint(currentContext);
            headPt = headSite.getPoint(currentContext);
        } else {
            tailPt = tailSite.getPoint();
            headPt = headSite.getPoint();
        }

        // Figure out the centers of the attached figures
        Point2D tailCenter;
View Full Code Here

    //}
    /** Detach the connector from its current site and attach
     * it to a new autonomous site at the given coordinates
     */
    private void detach(double x, double y) {
        Site newSite = new AutonomousSite(_connector.getTransformContext(), x,
                y);

        if (_handle.getSite() == _connector.getHeadSite()) {
            _connector.setHeadSite(newSite);
        } else {
View Full Code Here

     * the figure is the same as at the already-connected end of
     * the connector. (<b>Note</b>: this needs to be parameterized, as
     * sometimes snapping to a site on the same figure is useful.)
     */
    private Site findSite(Figure f, double x, double y) {
        Site ret = null;

        if (_handle.getSite() == _connector.getHeadSite()) {
            ret = _manipulator._connectorTarget
                    .getHeadSite(_connector, f, x, y);
        } else {
View Full Code Here

                return true;
            }
        });

        if (figure != null) {
            Site snap = findSite(figure, hitRect.getCenterX(), hitRect
                    .getCenterY());

            if (snap != null) {
                _target = figure;
                attach(snap);
View Full Code Here

            bounds = ShapeUtilities.transformBounds(bounds, transform);

            if (bounds.intersects(x - h, y - h, 2 * h, 2 * h)) {
                // We're still over, so snap to the nearest site -- FIXME
                //                debug("STILL OVER SAME TARGET: " + _target);
                Site current = _handle.getSite();

                // FIXME: shouldn't this be x,y?
                Site snap = findSite(current, bounds.getCenterX(), bounds
                        .getCenterY());

                //debug("SNAP: " + snap);
                if ((snap != null) && (snap != current)) {
                    attach(snap);
View Full Code Here

                return;
            }
            Iterator i = geometry.sites();
            while (i.hasNext()) {
                // Create a grab handle and set up the interactor
                Site site = (Site) i.next();
                GrabHandle g = getGrabHandleFactory().createGrabHandle(site);
                g.setParent(this);
                g.setInteractor(getHandleInteractor());
                addGrabHandle(g);
            }
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.