Package diva.canvas

Examples of diva.canvas.Site


    public void translate(LayerEvent e, double dx, double dy) {
        // 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();

        // Process movement in one of the end manipulators
        if (site != connector.getMidpointSite()) {
            super.translate(e, dx, dy);
        } else {
View Full Code Here


    /** Tell the connector to route itself between the
     * current positions of the head and tail sites.
     */
    public void route() {
        TransformContext currentContext = getTransformContext();
        Site headSite = getHeadSite();
        Site tailSite = getTailSite();
        Point2D headPt;
        Point2D tailPt;

        repaint();

        // 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 (tailSite.getFigure() != null) {
            tailCenter = CanvasUtilities.getCenterPoint(tailSite.getFigure(),
                    currentContext);
        } else {
            tailCenter = tailPt;
        }

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

        // Figure out the normal at the line ends.
        double x = headCenter.getX() - tailCenter.getX();
        double y = headCenter.getY() - tailCenter.getY();
        double angle = Math.atan2(y, x);

        // Tell the sites to adjust their positions
        tailSite.setNormal(angle);
        headSite.setNormal(angle - Math.PI);

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

        // Remember these points for the label
        this._headPt = headPt;
View Full Code Here

             *  site of the terminal instead of a new perimeter site.
             * @deprecated Use getHeadSite that takes a connector.
             */
            public Site getHeadSite(Figure f, double x, double y) {
                if (f instanceof Terminal) {
                    Site site = ((Terminal) f).getConnectSite();
                    return site;
                } else {
                    return super.getHeadSite(f, x, y);
                }
            }
View Full Code Here

    public void addEdge(Object edge, Object node, int end, double x, double y) {
        MutableGraphModel model = (MutableGraphModel) _controller
                .getGraphModel();
        Figure nf = _controller.getFigure(node);
        FigureLayer layer = _controller.getGraphPane().getForegroundLayer();
        Site headSite;
        Site tailSite;

        // Temporary sites.  One of these will get blown away later.
        headSite = new AutonomousSite(layer, x, y);
        tailSite = new AutonomousSite(layer, x, y);
View Full Code Here

        Connector connector = (Connector) _controller.getFigure(edge);
        Figure tailFigure = _controller.getFigure(tail);
        Figure headFigure = _controller.getFigure(head);

        Site tailSite;
        Site headSite;

        // If the tail is not attached,
        if (tailFigure == null) {
            // Then try to find the old tail site.
            if (connector != null) {
View Full Code Here

                        }
                    }

                    figure = new PortTerminal(ioPort, figure, normal, true);
                } else {
                    Site tsite = new PerimeterSite(figure, 0);
                    tsite.setNormal(normal);
                    tsite = new FixedNormalSite(tsite);
                    figure = new TerminalFigure(figure, tsite) {
                        // Override this because the tooltip may
                        // change over time.  I.e., the port may
                        // change from being an input or output, etc.
View Full Code Here

            model.getLinkModel().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 blown away later.
                headSite = new AutonomousSite(layer, event.getLayerX(), event
                        .getLayerY());
                tailSite = new AutonomousSite(layer, event.getLayerX(), event
View Full Code Here

                    // Swap the head and the tail if it will improve the
                    // layout, since LevelLayout only uses directed edges.
                    if (tailFigure instanceof Terminal) {
                        Terminal terminal = (Terminal) tailFigure;
                        Site site = terminal.getConnectSite();

                        if (site instanceof FixedNormalSite) {
                            double normal = site.getNormal();
                            int direction = CanvasUtilities
                                    .getDirection(normal);

                            if (direction == SwingUtilities.WEST) {
                                Object temp = origTail;
                                origTail = origHead;
                                origHead = temp;
                            }
                        }
                    } else if (headFigure instanceof Terminal) {
                        Terminal terminal = (Terminal) headFigure;
                        Site site = terminal.getConnectSite();

                        if (site instanceof FixedNormalSite) {
                            double normal = site.getNormal();
                            int direction = CanvasUtilities
                                    .getDirection(normal);

                            if (direction == SwingUtilities.EAST) {
                                Object temp = origTail;
View Full Code Here

         @param y The y location.
         *  @return The head site.
         */
        public Site getHeadSite(Figure f, double x, double y) {
            if (f instanceof Terminal) {
                Site site = ((Terminal) f).getConnectSite();
                return site;
            } else {
                return super.getHeadSite(f, x, y);
            }
        }
View Full Code Here

    /** Override the base class to return a different site for each
     *  connection to a multiport.
     *  @return The connection site.
     */
    public Site getHeadSite() {
        Site result = super.getHeadSite();
        if ((_headPort == null) || !_headPort.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 (_headSites == null) {
                    _headSites = new ArrayList();
                }
                if (_headSites.size() > orderIndex) {
                    if (_headSites.get(orderIndex) == null) {
                        result = new PortConnectSite(result.getFigure(),
                                terminal, orderIndex + 1, result.getNormal());
                    } else {
                        result = (Site) _headSites.get(orderIndex);
                    }
                    _headSites.set(orderIndex, result);
                } else {
                    result = new PortConnectSite(result.getFigure(), terminal,
                            orderIndex + 1, result.getNormal());
                    while (_headSites.size() < orderIndex) {
                        _headSites.add(null);
                    }
                    _headSites.add(result);
                }
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.