Package ptolemy.data

Examples of ptolemy.data.ArrayToken


        }
        int outputWidth = 0;
        Token[][] inputs = new Token[width][];
        for (int i = 0; i < width; i++) {
            if (input.hasToken(i)) {
                ArrayToken token = (ArrayToken) input.get(i);
                inputs[i] = token.arrayValue();
                outputWidth += inputs[i].length;
            }
        }
        Token[] array = new Token[outputWidth];
        int runningPosition = 0;
        for (int i = 0; i < width; i++) {
            System.arraycopy(inputs[i], 0, array, runningPosition,
                    inputs[i].length);
            runningPosition += inputs[i].length;
        }
        Type elementType = ((ArrayType) input.getType()).getElementType();
        output.send(0, new ArrayToken(elementType, array));
    }
View Full Code Here


     *   nondecreasing and nonnegative.
     */
    public void attributeChanged(Attribute attribute)
            throws IllegalActionException {
        if (attribute == offsets) {
            ArrayToken offsetsValue = (ArrayToken) offsets.getToken();
            _offsets = new double[offsetsValue.length()];

            double previous = 0.0;

            for (int i = 0; i < offsetsValue.length(); i++) {
                _offsets[i] = ((DoubleToken) offsetsValue.getElement(i))
                        .doubleValue();

                // Check nondecreasing property.
                if (_offsets[i] < previous) {
                    throw new IllegalActionException(this,
View Full Code Here

     @exception IllegalActionException If the <i>values</i> and
     *   <i>offsets</i> parameters do not have the same length.
     */
    public boolean prefire() throws IllegalActionException {
        // FIXME: why put the check here???
        ArrayToken val = (ArrayToken) (values.getToken());

        if (_offsets.length != val.length()) {
            throw new IllegalActionException(this,
                    "Values and offsets vectors do not have the same length.");
        }

        return super.prefire();
View Full Code Here

     @return A token that contains the output value.
     *  @exception IllegalActionException If the index is out of the range of
     *  the values parameter.
     */
    protected Token _getValue(int index) throws IllegalActionException {
        ArrayToken val = (ArrayToken) (values.getToken());

        if ((val == null) || (val.length() <= index)) {
            throw new IllegalActionException(this,
                    "Index out of range of the values parameter.");
        }

        return val.getElement(index);
    }
View Full Code Here

            throws IllegalActionException, NameDuplicationException {
        super(container, name);
        output.setTypeEquals(BaseType.OBJECT);
        width = new Parameter(this, "width", new IntToken(0));
        height = new Parameter(this, "height", new IntToken(0));
        bandValues = new Parameter(this, "bandValues", new ArrayToken(
                BaseType.INT, _defaultValues));
        dataFormat = new StringAttribute(this, "dataFormat");
        dataFormat.setExpression("byte");
        _dataFormat = _BYTE;
    }
View Full Code Here

        setBackground = new Parameter(this, "setBackground");
        setBackground.setTypeEquals(BaseType.BOOLEAN);
        setBackground.setToken(BooleanToken.FALSE);

        background = new Parameter(this, "background", new ArrayToken(
                BaseType.INT, _initialArray));
    }
View Full Code Here

        if (!periodicValue) {
            output.send(0, _zero);
            return;
        }

        ArrayToken arrayToken = (ArrayToken) initialTrace.getToken();
        output.send(0, arrayToken.getElement(_count));
        _count++;

        if (_count == arrayToken.length()) {
            _count = 0;
            _updateInitialTrace();
        }
    }
View Full Code Here

        _updateInitialTrace();

        // Produce the data on the output so that this can be used in
        // feedback look in dataflow models.
        ArrayToken arrayToken = (ArrayToken) initialTrace.getToken();
        output.send(0, arrayToken.arrayValue(), arrayToken.length());

        _count = 0;
    }
View Full Code Here

            int lengthValue = ((IntToken) length.getToken()).intValue();
            ((Plot) plot).clear(0);

            boolean connected = false;
            ArrayToken defaultValues = (ArrayToken) initialTrace.getToken();

            for (int i = 0; i < lengthValue; i++) {
                double value = 0.0;

                if ((defaultValues != null) && (i < defaultValues.length())) {
                    value = ((DoubleToken) defaultValues.getElement(i))
                            .doubleValue();
                }

                ((Plot) plot).addPoint(0, i, value, connected);
                connected = true;
View Full Code Here

                for (int i = 0; i < _data[1].length; i++) {
                    record[i] = new DoubleToken(_data[1][i]);
                }

                ArrayToken newValue = new ArrayToken(BaseType.DOUBLE, record);
                initialTrace.setToken(newValue);
            } finally {
                _dataModified = false;
            }
        }
View Full Code Here

TOP

Related Classes of ptolemy.data.ArrayToken

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.