Package javax.media.jai

Examples of javax.media.jai.PlanarImage


     * @param p The point to convert.
     * @param isDistance True if p should be interpreted as a distance instead
     *                   of a point.
     */
    public void canvasToScreenCoords(Point2D.Double p, boolean isDistance) {
        PlanarImage displayImage = _imageDisplay.getDisplayImage();
        if (!isDistance && displayImage != null) {
            p.x += displayImage.getMinX();
            p.y += displayImage.getMinY();
        }
    }
View Full Code Here


     * @param p The point to convert.
     * @param isDistance True if p should be interpreted as a distance instead
     *                   of a point.
     */
    public void screenToCanvasCoords(Point2D.Double p, boolean isDistance) {
        PlanarImage displayImage = _imageDisplay.getDisplayImage();
        if (!isDistance && displayImage != null) {
            p.x -= displayImage.getMinX();
            p.y -= displayImage.getMinY();
        }
    }
View Full Code Here

    /**
     * Return a scaled down image to use for the pan window
     */
    private PlanarImage _getPannerImage() {
        PlanarImage im = _mainImageDisplay.getImageProcessor().getSourceImage();
        if (im == null)
            return null;

        FITSImage.setPreviewSize(_panWidth);

        // try to get a prescaled preview image (provided by the FITS codec)
        float scale = 1.0F;
        float w = im.getWidth(), h = im.getHeight();
        Object o = im.getProperty("#preview_image");
        if (o != null && o instanceof PlanarImage) {
            // The preview image is scaled down by an integer value, sich as 1/2x, 1/3x, ...
            PlanarImage preview = (PlanarImage) o;
            FITSImage fitsImage = (FITSImage) im.getProperty("#fits_image");
            if (fitsImage != null) {
                w = fitsImage.getRealWidth();
                h = fitsImage.getRealHeight();
            }
            scale = Math.min(preview.getWidth() / w, preview.getHeight() / h);
            _imageDisplay.setScale(scale);
            return preview;
        }

        // otherwise scale the source image with JAI and return it
View Full Code Here

    /**
     * Return the width of the source image in pixels
     */
    public int getImageWidth() {
        PlanarImage image = getImage();
        if (image != null) {
            if (_prescaled) // return original image size before prescaling
                return (int) (image.getWidth() / _scale);
            return image.getWidth();
        }
        return 0;
    }
View Full Code Here

    /**
     * Return the height of the source image in pixels
     */
    public int getImageHeight() {
        PlanarImage image = getImage();
        if (image != null) {
            if (_prescaled) // return original image size before prescaling
                return (int) (image.getHeight() / _scale);
            return image.getHeight();
        }
        return 0;
    }
View Full Code Here

    /**
     * Return true if the image has been cleared.
     */
    public boolean isClear() {
        PlanarImage im = _imageProcessor.getSourceImage();
        return (im == _EMPTY_IMAGE);
    }
View Full Code Here

    /**
     * Return the value of the pixel in the given band at the given user coordinates
     */
    public float getPixelValue(Point2D.Double p, int band) {
        PlanarImage im = _imageProcessor.getRescaledSourceImage();
        if (im != null) {
            int ix = (int) p.getX(), iy = (int) p.getY();
            if (ix < 0 || ix > im.getWidth() || iy < 0 || iy > im.getHeight())
                return 0.0F;
            int x = _XtoTileX(ix);
            int y = _YtoTileY(iy);
            if (x < 0 || y < 0)
                return 0.0F;
            Raster tile = im.getTile(x, y);
            return tile.getSampleFloat(ix, iy, band);
        }
        return 0;
    }
View Full Code Here

        if (_rescaledSourceImage == null) {
            return;
        }

        try {
            PlanarImage colorImage;
            if (_numBands == 1 && ! (_sourceImage.getColorModel() instanceof IndexColorModel)) {
                if (_shortImage == null || _scaleLookupTable == null) {
                    return;
                }
                // perform a lookup operation to scale short to byte range.
                // (_shortImage should have been already prepared when cut levels were set)
                PlanarImage byteImage = ImageOps.lookup(_shortImage, _scaleLookupTable);

                // add a color RGB lookup table so we can manipulate the image colors
                colorImage = ImageOps.lookup(byteImage, _colormap.getColorLookupTable());
            } else {
                // source image is already color
View Full Code Here

    /**
     * Update the display to show the current values
     */
    public void updateDisplay() {
        PlanarImage image = imageDisplay.getImageProcessor().getSourceImage();
        if (image == null)
            return;
        String[] columnNames = {"Property Name", "Value"};
        String[] propertyNames = image.getPropertyNames();
        if (propertyNames == null)
            return;
        int numProperties = propertyNames.length;

        // Sort the property keyword and remove the ones that can't be displayed
        // (they might not all be strings...)
        Set<String> treeSet = new TreeSet<String>();
        for (int i = 0; i < numProperties; i++) {
            String name = propertyNames[i];
            // note: special properties may start with "#" and are not listed
            if (name == null || name.length() == 0 || name.startsWith("#")) {
                continue;
            }
            // XXX who is converting the keywords to lower case?
            treeSet.add(name.toUpperCase());
        }

        Object[] keys = treeSet.toArray();
        numProperties = keys.length;
        String[][] values = new String[numProperties][2];
        for (int i = 0; i < numProperties; i++) {
            String name = (String) (keys[i]);
            values[i][0] = name;
            Object property = image.getProperty(name);
            if (property == null)
                continue;
            values[i][1] = property.toString();
        }
        table.setModel(new DefaultTableModel(values, columnNames));
View Full Code Here

    /**
     * fill in the label and text field values, where known
     */
    protected void updateValues() {
        PlanarImage im = imageProcessor.getRescaledSourceImage();
        if (im != null) {
            SampleModel sampleModel = im.getSampleModel();
            if (sampleModel != null) {
                int dataType = sampleModel.getDataType();
                if (dataType == DataBuffer.TYPE_FLOAT || dataType == DataBuffer.TYPE_DOUBLE) {
                    // double or float image type, show full preceission
                    lowValue.setText(String.valueOf((float) imageProcessor.getLowCut()));
View Full Code Here

TOP

Related Classes of javax.media.jai.PlanarImage

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.