Package ptolemy.kernel.util

Examples of ptolemy.kernel.util.Locatable


                // attribute (applies to "unseen" relations)
                continue;
            }

            // Set the new location attribute.
            Locatable locatable = (Locatable) locationList.get(0);

            // Give default values in case the previous locations value
            // has not yet been set
            double[] newLocation = new double[] { 0, 0 };

            if (locatable.getLocation() != null) {
                newLocation = locatable.getLocation();
            }

            // NOTE: we use the transform worked out for the drag to
            // set the original MoML location
            double[] oldLocation = new double[2];
            oldLocation[0] = newLocation[0] + transform[0];
            oldLocation[1] = newLocation[1] + transform[1];

            // Create the MoML, wrapping the new location attribute
            // in an element refering to the container
            String containingElementName = element.getElementName();
            String elementToMove = "<" + containingElementName + " name=\""
                    + element.getName() + "\" >\n";
            moml.append(elementToMove);
            undoMoml.append(elementToMove);

            // NOTE: use the moml info element name here in case the
            // location is a vertex
            String momlInfo = ((NamedObj) locatable).getElementName();
            moml.append("<" + momlInfo + " name=\"" + locatable.getName()
                    + "\" value=\"[" + newLocation[0] + ", " + newLocation[1]
                    + "]\" />\n");
            undoMoml.append("<" + momlInfo + " name=\"" + locatable.getName()
                    + "\" value=\"[" + oldLocation[0] + ", " + oldLocation[1]
                    + "]\" />\n");
            moml.append("</" + containingElementName + ">\n");
            undoMoml.append("</" + containingElementName + ">\n");
        }
View Full Code Here


         * highlight the node. If the StringAttribute _explanation of the node
         * is set then use it to set the tooltip.
         * @see diva.graph.NodeRenderer#render(java.lang.Object)
         */
        public Figure render(Object n) {
            Locatable location = (Locatable) n;
            final NamedObj object = location.getContainer();

            // NOTE: this code is similar to that in PtolemyTreeCellRenderer
            Figure result = null;

            try {
View Full Code Here

        if (settable instanceof Locatable && !_inValueChanged) {
            // Have to defer this to the event thread, or repaint
            // doesn't work properly.
            Runnable action = new Runnable() {
                public void run() {
                    Locatable location = (Locatable) settable;
                    Figure figure = getFigure(location);
                    if (figure != null) {
                        Point2D origin = figure.getOrigin();

                        double originalUpperLeftX = origin.getX();
                        double originalUpperLeftY = origin.getY();

                        // NOTE: the following call may trigger an evaluation,
                        // which results in another recursive call to this method.
                        // Thus, we ignore the inside call and detect it with a
                        // private variable.
                        double[] newLocation;

                        try {
                            _inValueChanged = true;
                            newLocation = location.getLocation();
                        } finally {
                            _inValueChanged = false;
                        }

                        double translationX = newLocation[0]
View Full Code Here

                        if (centeredValue) {
                            ((BasicFigure) subFigure).setCentered(true);
                        }
                    }

                    Locatable location = (Locatable) attribute.getAttribute(
                            "_location", Locatable.class);

                    if (location != null) {
                        double[] locationValue = location.getLocation();
                        CanvasUtilities.translateTo(subFigure,
                                locationValue[0], locationValue[1]);
                    }
                } catch (IllegalActionException e) {
                    throw new InternalErrorException(e);
View Full Code Here

         *  of the port.
         *  @param node The node.
         *  @return A valid MoML string.
         */
        public String getDeleteNodeMoML(Object node) {
            Locatable location = (Locatable) node;
            ComponentPort port = (ComponentPort) location.getContainer();
            StringBuffer moml = new StringBuffer();
            moml.append("<deletePort name=\"" + port.getName() + "\"/>\n");
            return moml.toString();
        }
View Full Code Here

         *   the root of this graph model.
         *  @return An iterator of Link objects, all of which have
         *   the given node as their head.
         */
        public Iterator inEdges(Object node) {
            Locatable location = (Locatable) node;
            //ComponentPort port = (ComponentPort) location.getContainer();

            // make sure that the links to relations that we are connected to
            // are up to date.
            // Go through all the links, creating a list of
View Full Code Here

         *   the root of this graph model.
         *  @return An iterator of Link objects, all of which have their
         *   tail as the given node.
         */
        public Iterator outEdges(Object node) {
            Locatable location = (Locatable) node;
            //ComponentPort port = (ComponentPort) location.getContainer();

            // make sure that the links to relations that we are connected to
            // are up to date.
            // Go through all the links, creating a list of
View Full Code Here

         @param eventSource The source of the event that will be dispatched,
         *   e.g. the view that made this call.
         *  @param node The node.
         */
        public void removeNode(final Object eventSource, Object node) {
            Locatable location = (Locatable) node;
            ComponentPort port = (ComponentPort) location.getContainer();
            NamedObj container = port.getContainer();
            ;

            StringBuffer moml = new StringBuffer();
            moml.append("<deletePort name=\"" + port.getName(container)
View Full Code Here

         @param n The object to be rendered.  This object should
         *  of type Locatable.
         *  @return A Figure.
         */
        public Figure render(Object n) {
            Locatable location = (Locatable) n;
            final NamedObj object = location.getContainer();
            EditorIcon icon;

            try {
                // In theory, there shouldn't be more than one
                // icon, but if there are, use the last one.
View Full Code Here

            // because we have no way of representing it in this editor.
            return;
        }

        Port port1 = (Port) linkedPortList.get(0);
        Locatable location1 = _getLocation(port1.getContainer());
        Port port2 = (Port) linkedPortList.get(1);
        Locatable location2 = _getLocation(port2.getContainer());

        Arc link;

        try {
            link = new Arc();
View Full Code Here

TOP

Related Classes of ptolemy.kernel.util.Locatable

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.