public class FITSImage extends SimpleRenderedImage
This class defines a number of properties that can be accessed by applications via the getProperty method.
The value of the property "#fits_image" returns the FITSImage object managing the image data.
The value of the property "#num_pages" returns an Integer with the number of HDUs (FITS header/data units).
The "#preview_image" property returns a preshrunk preview image suitable for use in a pan window. The size of the preview image may be set by calling the static method FITSImage.setPreviewSize(int).
colorModel, height, minX, minY, properties, sampleModel, sources, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, width
Constructor and Description |
---|
FITSImage(Fits fits,
FITSDecodeParam param,
int page)
Create a FITSImage from an already existing Fits object.
|
FITSImage(Object ar)
Create a FITSImage from a primitive array of data.
|
FITSImage(com.sun.media.jai.codec.SeekableStream input,
FITSDecodeParam param,
int page)
Construct a FITSImage.
|
FITSImage(String fileOrUrl)
Construct a FITSImage from an image file or URL.
|
Modifier and Type | Method and Description |
---|---|
void |
clearTileCache()
Try to save memory by clearing out the tile cache
|
void |
close()
Close the FITS input stream.
|
MappedByteBuffer |
getByteBuffer()
Return the memory mapped to the image data, if the FITS input is from a BufferedFile, otherwise null.
|
int |
getCurrentHDUIndex()
Return the index of the current image HDU
|
static int |
getDefaultTileHeight() |
static int |
getDefaultTileWidth() |
Fits |
getFits()
Return the internal Fits object used to manage the image
|
BasicHDU |
getHDU(int num)
Return the given HDU or null if it can not be accessed.
|
Header |
getHeader()
Return the FITS header object
|
ImageTiler |
getImageTiler()
Return the object used to access FITS data tiles (used only if MappedByteBuffer can't be used)
|
String |
getKeywordComment(String name)
Return the comment for the given FITS keyword from the FITS header,
or null if not found.
|
String[] |
getKeywords()
Returns a list of FITS keywords for this image.
|
Object |
getKeywordValue(String name)
Return the value of the given FITS keyword from the FITS header,
or null if not found.
|
double |
getKeywordValue(String name,
double defaultValue)
Return the value of the given FITS keyword as a double,
or the given default value, if not found.
|
float |
getKeywordValue(String name,
float defaultValue)
Return the value of the given FITS keyword as a float,
or the given default value, if not found.
|
int |
getKeywordValue(String name,
int defaultValue)
Return the value of the given FITS keyword as an integer,
or the given default value, if not found.
|
String |
getKeywordValue(String name,
String defaultValue)
Return the value of the given FITS keyword as a string,
or the given default value, if not found.
|
int |
getNAXIS()
Return the number of axes
|
int |
getNumHDUs()
Return the number of FITS HDUs in the current image.
|
static int |
getPreviewSize()
Return the requested size for the preview image
|
Object |
getProperty(String name)
Gets a property from the property set of this image.
|
String[] |
getPropertyNames()
Returns a list of property names that are recognized by this image.
|
int |
getRealHeight()
Returns the real height of the image.
|
int |
getRealWidth()
Returns the real width of the image.
|
float |
getScale()
Return the current scale factor (zooming out is handled here for performance reasons).
|
int |
getSubsample()
Return the increment to use when accessing the image data if _scale is less than 1.
|
Raster |
getTile(int tileX,
int tileY)
Generate and return the given tile (required by the RenderedImage interface).
|
boolean |
isEmpty()
Return true if the image is empty (such as the primary extension)
|
boolean |
isYFlipped()
Return true if the Y axis of the image data tiles returned by this class is flipped
(for performance reasons, so it doesn't have to be done afterwards).
|
static void |
setDefaultTileHeight(int h) |
static void |
setDefaultTileWidth(int w) |
void |
setHDU(int num)
Move to the given HDU.
|
static void |
setPreviewSize(int i)
Set the requested size for the preview image
|
boolean |
setScale(float scale)
Set the scale (zoom factor) for the image and return true if a new image was generated.
|
void |
update()
This method should be called after adding a new HDU.
|
copyData, getBounds, getColorModel, getData, getData, getHeight, getMaxTileX, getMaxTileY, getMaxX, getMaxY, getMinTileX, getMinTileY, getMinX, getMinY, getNumXTiles, getNumYTiles, getPropertyNames, getSampleModel, getSources, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getWidth, tileXToX, tileXToX, tileYToY, tileYToY, XToTileX, XToTileX, YToTileY, YToTileY
public FITSImage(com.sun.media.jai.codec.SeekableStream input, FITSDecodeParam param, int page) throws IOException, FitsException
input
- the SeekableStream for the FITS file.param
- the parameter passed to the JAI create methodpage
- specifies the desired image extension (default: 0, for the primary extension)IOException
FitsException
public FITSImage(String fileOrUrl) throws IOException, FitsException
fileOrURL
- the file name or URLIOException
FitsException
public FITSImage(Fits fits, FITSDecodeParam param, int page) throws IOException, FitsException
fits
- object managing the FITS fileparam
- the parameter passed to the JAI create methodpage
- specifies the desired image extension (default: 0, for the primary extension)IOException
FitsException
public FITSImage(Object ar) throws IOException, FitsException
ar
- a 2D array of a primitive numeric type (doubles not supported yet)IOException
FitsException
public int getCurrentHDUIndex()
public void close()
public int getNumHDUs()
public Fits getFits()
public BasicHDU getHDU(int num)
public void update()
public void setHDU(int num) throws IOException, FitsException
num
- The HDU number (0 is the primary HDU).IOException
FitsException
public int getRealWidth()
public int getRealHeight()
public int getNAXIS()
public ImageTiler getImageTiler()
public boolean isEmpty()
public float getScale()
public int getSubsample()
public MappedByteBuffer getByteBuffer()
public static void setDefaultTileWidth(int w)
public static int getDefaultTileWidth()
public static void setDefaultTileHeight(int h)
public static int getDefaultTileHeight()
public void clearTileCache()
public Header getHeader()
public Object getProperty(String name)
getProperty
in interface RenderedImage
getProperty
in class SimpleRenderedImage
name
- the name of the property to get, as a String.public String[] getPropertyNames()
getPropertyNames
in interface RenderedImage
getPropertyNames
in class SimpleRenderedImage
public Object getKeywordValue(String name)
name
- a FITS keywordpublic String getKeywordComment(String name)
name
- a FITS keywordpublic String getKeywordValue(String name, String defaultValue)
name
- a FITS keyworddefaultValue
- the value to return if the keyword is not foundpublic int getKeywordValue(String name, int defaultValue)
name
- a FITS keyworddefaultValue
- the value to return if the keyword is not foundpublic double getKeywordValue(String name, double defaultValue)
name
- a FITS keyworddefaultValue
- the value to return if the keyword is not foundpublic float getKeywordValue(String name, float defaultValue)
name
- a FITS keyworddefaultValue
- the value to return if the keyword is not foundpublic String[] getKeywords()
public boolean setScale(float scale) throws IOException
Note that zooming out is handled here for performance reasons, to avoid having to read in whole tiles, only to discard most of the data later. Zooming in should be handled in the image viewer widget at the end of the image processing chain.
scale
- the scale factor (a value of less than 1.0 means the image is zoomed out and is
handled specially here)IOException
public boolean isYFlipped()
public Raster getTile(int tileX, int tileY)
tileX
- the X index of the requested tile in the tile array.tileY
- the Y index of the requested tile in the tile array.public static void setPreviewSize(int i)
public static int getPreviewSize()
Copyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.