Package ptolemy.kernel.util

Examples of ptolemy.kernel.util.Locatable


                // Change the color of the icon to green.
                _circle2.fillColor.setToken("{0.0, 1.0, 0.0, 1.0}");

                CompositeEntity container = (CompositeEntity) getContainer();
                Entity destNode = container.getEntity(destination);
                Locatable destLocation = (Locatable) destNode.getAttribute(
                        "_location", Locatable.class);
                Locatable myLocation = (Locatable) this.getAttribute(
                        "_location", Locatable.class);

                if ((destLocation == null) || (myLocation == null)) {
                    throw new IllegalActionException(
                            "Cannot determine location for node "
                                    + destNode.getName() + ".");
                }

                Iterator nodes = _connectedNodes.iterator();
                double minDistance = _distanceBetween(destLocation, myLocation);
                String to = " ";
                boolean multi = ((BooleanToken) doublePath.getToken())
                        .booleanValue();
                double nextMinDistance = _distanceBetween(destLocation,
                        myLocation);
                String to2 = " ";

                while (nodes.hasNext()) {
                    Entity node = (Entity) nodes.next();
                    Locatable location = (Locatable) node.getAttribute(
                            "_location", Locatable.class);

                    if (location == null) {
                        throw new IllegalActionException(
                                "Cannot determine location for node "
View Full Code Here


     @exception IllegalActionException If a valid location attribute cannot
     *   be found.
     */
    protected double[] _locationOf(IOPort port) throws IllegalActionException {
        Entity container = (Entity) port.getContainer();
        Locatable location = null;

        if (container == getContainer()) {
            location = (Locatable) port.getAttribute(LOCATION_ATTRIBUTE_NAME,
                    Locatable.class);
        } else {
            location = (Locatable) container.getAttribute(
                    LOCATION_ATTRIBUTE_NAME, Locatable.class);
        }

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

        // NOTE: We assume here that the implementation
        // of addValueListener() is smart enough to not add
        // this if it is already a listener.
        location.addValueListener(this);
        return location.getLocation();
    }
View Full Code Here

     *   be found.
     */
    public static double[] locationOf(IOPort port)
            throws IllegalActionException {
        Entity portContainer = (Entity) port.getContainer();
        Locatable location = null;

        //FIXME: What should I do here...
        //if (portContainer == container) {
        //    location = (Locatable)port.getAttribute(LOCATION_ATTRIBUTE_NAME,
        //            Locatable.class);
        //} else {
        location = (Locatable) portContainer.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

     *   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

        super.initialize();
        _terrain.width.setToken(new IntToken(10));
        _number = 10;
        _offset = new double[2];

        Locatable location = (Locatable) getAttribute(LOCATION_ATTRIBUTE_NAME,
                Locatable.class);

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

        double[] center = _polygonCenter();

        //Note: the polygon is not centered, but the location
        //refers to the center of the polygon. We adjust the
        //offset here.
        _offset[0] = location.getLocation()[0] + center[0];
        _offset[1] = location.getLocation()[1] + center[1];

        CompositeEntity container = (CompositeEntity) getContainer();
        _channelName = channelName.stringValue();

        Entity channel = container.getEntity(_channelName);
View Full Code Here

     *   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

            // 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

     *   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

         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

         @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

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.