Examples of FITSImage


Examples of jsky.image.fits.codec.FITSImage

        _historyList.addToHistory();
        _filename = fileOrUrl;
        _url = _origURL = FileUtil.makeURL(null, fileOrUrl);

        // free up any previously opened FITS images
        FITSImage fitsImage = getFitsImage();
        if (fitsImage != null) {
            fitsImage.close();
            fitsImage.clearTileCache();
            clearFitsImage();
        }

        // load non FITS images with JAI, but try to load FITS files using the
        // the FITS I/O library, which is more efficient when using its own RandomAccess I/O
        if (isJAIImageType(_filename)) {
            try {
                setImage(JAI.create("fileload", _filename));
            } catch (Exception e) {
                DialogUtil.error(e);
                _filename = null;
                _url = _origURL = null;
                clear();
            }
        } else {
            try {
                fitsImage = new FITSImage(_filename);
                initFITSImage(fitsImage);
                setImage(fitsImage);
            } catch (Exception e) {
                // fall back to JAI method
                try {
View Full Code Here

Examples of jsky.image.fits.codec.FITSImage

    /**
     * Return the name of the object being displayed, if known, otherwise null.
     */
    public String getObjectName() {
        FITSImage fitsImage = getFitsImage();
        if (fitsImage != null) {
            Object o = fitsImage.getKeywordValue("OBJECT");
            if (o instanceof String) {
                return o.toString();
            }
        }
        return null;
View Full Code Here

Examples of jsky.image.fits.codec.FITSImage

            // check for graphics items saved in a FITS binary table named ".GRAPHICS"
            // (also produced by skycat)
            _fitsGraphics.loadGraphicsFromImage(".GRAPHICS");

            FITSImage fitsImage = getFitsImage();
            _fitsExtensionsAction.setEnabled(fitsImage != null && fitsImage.getNumHDUs() > 1);

            updateEnabledStates();
        }

        // notify listeners that a new image was (or will be) loaded
View Full Code Here

Examples of jsky.image.fits.codec.FITSImage

     * @param show if true, always show the window, if there are any extensions,
     *             otherwise, just update the window if it is already showing
     *             or show it if the primary extension is empty.
     */
    public void checkExtensions(boolean show) {
        FITSImage fitsImage = getFitsImage();
        int numHDUs;
        if (fitsImage == null || (numHDUs = fitsImage.getNumHDUs()) <= 1) {
            if (_fitsHDUChooser != null) {
                _fitsHDUChooser.clear();
                _fitsHDUChooser.setShow(false);
            }
            return;
        }

        // Must be more than one FITS extension: update and show the window if it was already open
        if (!show) {
            show = (_fitsHDUChooserFrame != null && _fitsHDUChooserFrame.isVisible());
        }

        // check the primary HDU to see if it is empty
        int currentHDU = fitsImage.getCurrentHDUIndex();
        boolean skipEmptyPrimary = (numHDUs >= 2)
                && currentHDU == 0
                && fitsImage.isEmpty()
                && (fitsImage.getHDU(1) instanceof ImageHDU);

        if (!show) {
            show = skipEmptyPrimary && numHDUs > 2;
        }

View Full Code Here

Examples of jsky.image.fits.codec.FITSImage

    /**
     * Pop up a dialog window for displaying a table of the FITS extensions
     */
    public void viewFitsExtensions() {
        FITSImage fitsImage = getFitsImage();
        if (fitsImage != null && fitsImage.getNumHDUs() > 1) {
            checkExtensions(true);
        } else {
            DialogUtil.error("There are no FITS extensions for this image.");
        }
    }
View Full Code Here

Examples of jsky.image.fits.codec.FITSImage

            JAI.create("filestore", getImage(), tmpFile, "TIFF", new TIFFEncodeParam());
        } else if (s.endsWith(".bmp")) {
            JAI.create("filestore", getDisplayImage(), tmpFile, "BMP", new BMPEncodeParam());
        } else {
            // assume FITS format
            FITSImage fitsImage = getFitsImage();
            if (fitsImage != null && _url != null) {
                try {
                    BufferedFile bf = new BufferedFile(tmpFile, "rw");
                    fitsImage.getFits().write(bf);
                    bf.close();

                    // under Windows, this is necessary to avoid an error
                    fitsImage.getFits().getStream().close();
                } catch (Exception e) {
                    DialogUtil.error(e);
                }
            } else {
                // XXX the FITS codec code for the call below is not implemented yet...
View Full Code Here

Examples of jsky.image.fits.codec.FITSImage

    /**
     * Update the display to show the values in the current FITS HDU.
     */
    public void updateDisplay() {
        FITSImage fitsImage = _imageDisplay.getFitsImage();

        if (fitsImage == null) {
            _table.setModel(new DefaultTableModel());
            return;
        }
        updateDisplay(fitsImage.getCurrentHDUIndex());
    }
View Full Code Here

Examples of jsky.image.fits.codec.FITSImage

    /**
     * Update the display to show the values in the current FITS HDU.
     */
    public void updateDisplay(int hduIndex) {
        FITSImage fitsImage = _imageDisplay.getFitsImage();

        BasicHDU hdu = null;
        if (fitsImage == null || (hdu = fitsImage.getHDU(hduIndex)) == null) {
            _table.setModel(new DefaultTableModel());
            return;
        }

        String[] columnNames = {"Keyword", "Value", "Comment"};
View Full Code Here

Examples of jsky.image.fits.codec.FITSImage

    /**
     * Save the current image graphics to a binary FITS table with the given name
     * in the current image.
     */
    public void saveGraphicsWithImage(String extName) throws FitsException {
        FITSImage fitsImage = imageDisplay.getFitsImage();
        if (fitsImage == null) {
            DialogUtil.error("Graphics can only be saved in a FITS image");
            return;
        }

        List<Figure> figureList = canvasDraw.getFigureList();
        int n = figureList.size();
        List<String> typeList = new ArrayList<String>(n);
        List<String> coordList = new ArrayList<String>(n);
        List<String> configList = new ArrayList<String>(n);

        ListIterator it = figureList.listIterator(0);
        int i = 0;
        while (it.hasNext()) {
            CanvasFigure cfig = (CanvasFigure) it.next();
            if (cfig instanceof ImageFigure) {
                ImageFigure fig = (ImageFigure) cfig;
                Shape shape = fig.getShape();
                Paint fill = fig.getFillPaint();
                Paint outline = fig.getStrokePaint();
                float lineWidth = fig.getLineWidth();
                Composite composite = fig.getComposite();
                try {
                    String type = getType(shape);
                    String coords = getCoords(shape);
                    String config = getConfig(fill, outline, (int) lineWidth, composite);
                    typeList.add(type);
                    coordList.add(coords);
                    configList.add(config);
                } catch (Exception e) {
                    continue; // ignore unsupported figures
                }
            } else if (cfig instanceof ImageLabel) {
                ImageLabel fig = (ImageLabel) cfig;
                Font font = fig.getFont();
                String text = fig.getString();
                Paint fill = fig.getFillPaint();
                typeList.add("text");
                coordList.add(getCoords((Point2D.Double) fig.getAnchorPoint()));
                configList.add(getConfig(text, font, fill));
            }
            i++;
        }

        Fits fits = fitsImage.getFits();
        _deleteBinaryTable(fits, extName);
        BinaryTable table = new BinaryTable();
        FitsFactory.setUseAsciiTables(false);
        table.addColumn(typeList.toArray(new String[typeList.size()]));
        table.addColumn(coordList.toArray(new String[coordList.size()]));
View Full Code Here

Examples of jsky.image.fits.codec.FITSImage

     * load the previously saved image graphics from it.
     *
     * @param extName the name of the FITS table holding the graphics info (".GRAPHICS")
     */
    public void loadGraphicsFromImage(String extName) {
        FITSImage fitsImage = imageDisplay.getFitsImage();
        if (fitsImage == null) {
            return;
        }
        int n = fitsImage.getNumHDUs();
        if (n <= 1) {
            return;
        }

        for (int i = 0; i < n; i++) {
            BasicHDU hdu = fitsImage.getHDU(i);
            if (hdu instanceof TableHDU) {
                Header header = hdu.getHeader();
                String name = header.getStringValue("EXTNAME");
                if (name != null && name.equals(extName)) {
                    try {
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.