Package ptolemy.kernel.util

Examples of ptolemy.kernel.util.InternalErrorException


            case _DOUBLE:
                _maxValue = Double.MAX_VALUE;
                break;

            default:
                throw new InternalErrorException(this, null,
                        "Invalid value for _dataFormat private variable. "
                                + "DoubleMatrixToJAI actor (" + getFullName()
                                + ") on data type " + _dataFormat);
            }

            if ((_dataFormat == _DOUBLE) || (_dataFormat == _FLOAT)) {
                System.out.println("DoubleMatrixTOJAI:0");

                for (int i = 0; i < width; i++) {
                    for (int j = 0; j < height; j++) {
                        // There is some confusion about which order the
                        // array should be in.
                        // We go with i*height + j here so that we
                        // can read in data from the SDF VQ actors.
                        //                         newData[i*height + j] = data[i][j];
                        //                         newData[i*height + j] = newData[i*height + j] - 0.5D;
                        //                         newData[i*height + j] = newData[i*height + j]*2;
                        //                         newData[i*height + j] = newData[i*height + j]*_maxValue;
                        newData[i + (j * width)] = data[i][j];
                        newData[i + (j * width)] = newData[i + (j * width)] - 0.5D;
                        newData[i + (j * width)] = newData[i + (j * width)] * 2;
                        newData[i + (j * width)] = newData[i + (j * width)]
                                * _maxValue;
                    }
                }
            } else {
                for (int i = 0; i < width; i++) {
                    for (int j = 0; j < height; j++) {
                        //                         newData[i*height + j] =
                        //                             data[i][j]*(_maxValue - _minValue) + _minValue;
                        newData[i + (j * width)] = (data[i][j] * (_maxValue - _minValue))
                                + _minValue;
                    }
                }
            }
        } else {
            // Convert the matrix of doubles into an array of doubles
            for (int i = 0; i < width; i++) {
                for (int j = 0; j < height; j++) {
                    //                    newData[i*height + j] = data[i][j];
                    newData[i + (j * width)] = data[i][j];
                }
            }
        }

        // Create a new dataBuffer from the array of doubles
        DataBufferDouble dataBuffer = new DataBufferDouble(newData, width
                * height);

        // The length of the bandOffset array indicates how many bands
        // there are.  Since we are just dealing with a single
        // DoubleMatrixToken, the length of this array will be one.
        // The values of the array indicate the offset to be added
        // To the bands.  This is set to 0.
        int[] bandOffset = new int[1];
        bandOffset[0] = 0;

        // Create a ComponentSampleModel, with type double, the same width
        // and height as the matrix, a pixel stride of one (the final image
        // is single-banded), and a scanline stride equal to the width.
        ComponentSampleModelJAI sampleModel = new ComponentSampleModelJAI(
                DataBuffer.TYPE_DOUBLE, width, height, 1, width, bandOffset);

        // Create a new raster that has its origin at (0, 0).
        Raster raster = Raster.createWritableRaster(sampleModel, dataBuffer,
                new Point());

        // Create a grayscale colormodel.
        ComponentColorModel colorModel = new ComponentColorModel(
                new ICC_ColorSpace(ICC_Profile.getInstance(ColorSpace.CS_GRAY)),
                false, false, Transparency.OPAQUE, DataBuffer.TYPE_DOUBLE);
        TiledImage tiledImage = new TiledImage(0, 0, width, height, 0, 0,
                sampleModel, colorModel);
        tiledImage.setData(raster);

        ParameterBlock parameters = new ParameterBlock();
        parameters.addSource(tiledImage);

        switch (_dataFormat) {
        case _BYTE:
            parameters.add(DataBuffer.TYPE_BYTE);
            break;

        case _DOUBLE:
            parameters.add(DataBuffer.TYPE_DOUBLE);
            break;

        case _FLOAT:
            parameters.add(DataBuffer.TYPE_FLOAT);
            break;

        case _INT:
            parameters.add(DataBuffer.TYPE_INT);
            break;

        case _SHORT:
            parameters.add(DataBuffer.TYPE_SHORT);
            break;

        case _USHORT:
            parameters.add(DataBuffer.TYPE_USHORT);
            break;

        default:
            throw new InternalErrorException(this, null,
                    "Invalid value for _dataFormat private variable. "
                            + "DoubleMatrixToJAI actor (" + getFullName()
                            + ") on data type " + _dataFormat);
        }

View Full Code Here


                return getPort(name);
            }
        } catch (IllegalActionException ex) {
            // This exception should not occur, so we throw a runtime
            // exception.
            throw new InternalErrorException(
                    "Refinement.newPort: Internal error: " + ex.getMessage());
        } finally {
            _mirrorDisable = false;
            _workspace.doneWriting();
        }
View Full Code Here

            }
            return port;
        } catch (IllegalActionException ex) {
            // This exception should not occur, so we throw a runtime
            // exception.
            throw new InternalErrorException(
                    "MultiCompositeActor.newPort(): Internal error: "
                            + ex.getMessage());
        } finally {
            _workspace.doneWriting();
        }
View Full Code Here

            // result.setPersistent(true);
            return result;
        } catch (IllegalActionException ex) {
            // This exception should not occur, so we throw a runtime
            // exception.
            throw new InternalErrorException(this, ex, null);
        }
    }
View Full Code Here

                        Inequality ineq = new Inequality(ArrayType
                                .elementType(sourcePort), destinationPort
                                .getTypeTerm());
                        result.add(ineq);
                    } catch (IllegalActionException e) {
                        throw new InternalErrorException(e);
                    }
                } else if (destinationPort.getContainer().equals(this)) {
                    // Require that the destination port type be an array
                    // with elements compatible with the source port.
                    try {
                        Inequality ineq = new Inequality(ArrayType
                                .arrayOf(sourcePort), destinationPort
                                .getTypeTerm());
                        result.add(ineq);
                    } catch (IllegalActionException e) {
                        throw new InternalErrorException(e);
                    }
                }
            }
        }
View Full Code Here

            try {
                return new IteratePort(this, name);
            } catch (IllegalActionException ex) {
                // This exception should not occur, so we throw a runtime
                // exception.
                throw new InternalErrorException(this, ex, null);
            }
        }
View Full Code Here

                            result = true;
                        }
                    }
                } catch (NoTokenException ex) {
                    // this shouldn't happen.
                    throw new InternalErrorException(this, ex, null);
                }
            }

            return result;
        }
View Full Code Here

                        port.send(i, new ArrayToken(elementType));
                    }

                    result = true;
                } catch (NoTokenException ex) {
                    throw new InternalErrorException(this, ex, null);
                }
            }

            return result;
        }
View Full Code Here

        case _USHORT:
            result = DataBuffer.TYPE_USHORT;
            break;

        default:
            throw new InternalErrorException(this, null,
                    "Invalid value for _dataFormat private variable. "
                            + "JAIDataConvert actor (" + getFullName()
                            + ") on data type " + _dataFormat);
        }
View Full Code Here

                    if (hasToken() == true) {
                        get();
                    }
                    super.put(token);
                } catch (NoRoomException ex) {
                    throw new InternalErrorException("One-place buffer: "
                            + ex.getMessage());
                } catch (NoTokenException ex) {
                    throw new InternalErrorException("One-place buffer: "
                            + ex.getMessage());
                }
            }
        };
    }
View Full Code Here

TOP

Related Classes of ptolemy.kernel.util.InternalErrorException

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.