Examples of Locatable


Examples of ptolemy.kernel.util.Locatable

     *   be found.
     */
    private double[] _locationOf(WirelessIOPort port)
            throws IllegalActionException {
        Entity container = (Entity) port.getContainer();
        Locatable location = null;
        location = (Locatable) container.getAttribute(LOCATION_ATTRIBUTE_NAME,
                Locatable.class);

        if (location == null) {
            throw new IllegalActionException(
                    "Cannot determine location for port " + port.getName()
                            + ".");
        }

        return location.getLocation();
    }
View Full Code Here

Examples of ptolemy.kernel.util.Locatable

            // Wrap the figure in a TerminalFigure to set the direction that
            // connectors exit the port.  Note that this direction is the
            // OPPOSITE direction that is used to layout the port in the
            // Entity Controller.
            int direction;
            Locatable location = (Location) n;

            if (location != null) {
                final Port port = (Port) location.getContainer();

                Color fill;

                if (!(port instanceof IOPort)) {
                    polygon.moveTo(-6, 6);
View Full Code Here

Examples of ptolemy.kernel.util.Locatable

     *   to this container (not thrown in this base class).
     */
    public void attributeChanged(Attribute attribute)
            throws IllegalActionException {
        if (attribute instanceof Locatable) {
            Locatable location = (Locatable) attribute;

            if (_port != null) {
                Attribute portAttribute = _port.getAttribute("_location");
                Locatable portLocation = null;

                if (portAttribute instanceof Locatable) {
                    portLocation = (Locatable) portAttribute;
                } else {
                    try {
                        portLocation = new Location(_port, "_location");
                        ((NamedObj) portLocation).propagateExistence();
                    } catch (KernelException ex) {
                        throw new InternalErrorException(ex);
                    }
                }

                double[] locationValues = location.getLocation();
                double[] portLocationValues = new double[2];
                portLocationValues[0] = locationValues[0] - 20.0;
                portLocationValues[1] = locationValues[1] - 5.0;
                portLocation.setLocation(portLocationValues);
            }
        } else {
            super.attributeChanged(attribute);
        }
    }
View Full Code Here

Examples of ptolemy.kernel.util.Locatable

         this graph or composite node.
         *  @param composite The composite, which is assumed to be an icon.
         *  @return The number of ports contained in the container of the icon.
         */
        public int getNodeCount(Object composite) {
            Locatable location = (Locatable) composite;
            return ((ComponentEntity) location.getContainer()).portList()
                    .size();
        }
View Full Code Here

Examples of ptolemy.kernel.util.Locatable

         @param composite The composite, which is assumed to be an icon.
         *  @return An iterator over the ports contained in the container
         *   of the icon.
         */
        public Iterator nodes(Object composite) {
            Locatable location = (Locatable) composite;
            Nameable container = location.getContainer();

            if (container instanceof ComponentEntity) {
                ComponentEntity entity = (ComponentEntity) container;
                return entity.portList().iterator();
            } else {
View Full Code Here

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

Examples of ptolemy.kernel.util.Locatable

         * 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

Examples of ptolemy.kernel.util.Locatable

        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

Examples of ptolemy.kernel.util.Locatable

                        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

Examples of ptolemy.kernel.util.Locatable

         *  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
TOP
Copyright © 2018 www.massapi.com. 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.