com.ermapper.ecw
Class JNCSRenderer

java.lang.Object
  |
  +--com.ermapper.ecw.JNCSFile
        |
        +--com.ermapper.ecw.JNCSRenderer
All Implemented Interfaces:
JNCSProgressiveUpdate

public class JNCSRenderer
extends JNCSFile

This class provides an easy mechanism for displaying ECW images, in progressive or non-progressive mode to a graphics context (usually a frame or panel in an application). The renderer will draw into the target device, according to the parameters passed in the setView and the drawImage calls. In progressive mode, call setView before drawing imagery. In this mode, image construction is asynchronous, and the coordinates passed to the drawImage function, may not match those passed in the setView. The renderer will adjust its drawing accordingly. The renderer constructs an image from the incomming ECW data stream (local or remote) in a background thread, and waits for a drawImage call to display the data. The renderer is capable of realtime display, and under a fast virtual machine, can interactively roam and zoom the image. In non-progressive mode it is sufficient to call drawImage with the correct world coordinates with out a valid setView. This mode is synchronous.

TODO: Super sampling (zoomed way in) when viewing over any edge (left or right) generates a "Supersampling not supported" exception. Problem is in the clipping in the setView.

TODO: SetView() using dataset coodinates are not fully implemented yet.

Since:
ECW Java SDK 2.3

Fields inherited from class com.ermapper.ecw.JNCSFile
bIsOpen, cellIncrementX, cellIncrementY, cellSizeUnits, compressionRate, datum, ECW_CELL_UNITS_DEGREES, ECW_CELL_UNITS_FEET, ECW_CELL_UNITS_INVALID, ECW_CELL_UNITS_METERS, fileName, height, numBands, originX, originY, progImageClient, progressive, projection, width
 
Constructor Summary
JNCSRenderer()
          Default constructor
JNCSRenderer(java.lang.String fileName, boolean bProgressive)
          Construct a renderer object and open the file, in progressive or static mode.
 
Method Summary
 void drawImage(java.awt.Graphics g, int tlX, int tlY, int nWidth, int nHeight, double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY, java.awt.image.ImageObserver imgObsv)
          Draw all available imagery to the graphics context.
 void refreshUpdate(int nWidth, int nHeight, double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY)
          This method gets called when imagery arrives from the network and the set view was in world coordinates.
 void refreshUpdate(int nWidth, int nHeight, int dDatasetTLX, int dDatasetTLY, double dDatasetBRX, int dDatasetBRY)
           
 void setTransparency(float value)
          Set the transparency value for the image.
 int setView(int nBands, int[] nBandList, double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY, int nWidth, int nHeight)
          Set a view of an open ECW file, in world coordinates.
 int setView(int nBands, int[] nBandList, int nDatasetTLX, int nDatasetTLY, int nDatasetBRX, int nDatasetBRY, int nWidth, int nHeight)
          Set a view of an open ECW file in dataset coordinates.
 
Methods inherited from class com.ermapper.ecw.JNCSFile
addProgressiveUpdateListener, close, convertDatasetToWorld, convertWorldToDataset, finalize, getLastErrorText, getLibVersion, getPercentComplete, open, readImageRGBA, readLineBGRA, readLineBIL, readLineBIL, readLineRGBA, refreshUpdate
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JNCSRenderer

public JNCSRenderer()
             throws JNCSException
Default constructor

JNCSRenderer

public JNCSRenderer(java.lang.String fileName,
                    boolean bProgressive)
             throws JNCSException,
                    JNCSFileOpenFailedException
Construct a renderer object and open the file, in progressive or static mode. This is equivalent to calling the null constructor and then the open method of the JNCSFile.
Parameters:
fileName - A file name, either local or an ecwp: URL.
bProgressive - Open the file in progressive or static mode.
See Also:
JNCSFile.open(java.lang.String, boolean)
Method Detail

setTransparency

public void setTransparency(float value)
Set the transparency value for the image. A value of 0.0 represents fully transparent, while a value of 1.0 represents fully opaque. Values outside this ranged are clamped to 0.0 or 1.0 accordingly. The default transparency value is 1.0. Transparency only works when running a virtual machine that is version 1.2 or above. This call will be (silently) ignored on a vm with a lower specification.
Parameters:
value - The transparency value.

setView

public int setView(int nBands,
                   int[] nBandList,
                   int nDatasetTLX,
                   int nDatasetTLY,
                   int nDatasetBRX,
                   int nDatasetBRY,
                   int nWidth,
                   int nHeight)
            throws JNCSInvalidSetViewException,
                   JNCSFileNotOpenException
Set a view of an open ECW file in dataset coordinates. Setting a view requires specifiying number of bands to decode, the band list indicating which bands should be decoded, the top left and bottom right dataset coordinates, and the sample output view width and height.

This method returns 0 on success, or 1 of the extents were outside the dataset. It only throws an exception if the set view call actually fails (for example because of an internal error). This is because exceptions are expensive at runtime, and it is valid to request an area outside the dataset, but for the renderer to silently draw nothing.

Overrides:
setView in class JNCSFile
Parameters:
nBands - The number of bands to decode
nBandList - The list indicating which bands to decode. For RGB123 this should be {0,1,2}.
nDatasetTLX - The top left X dataset cell coordinate
nDatasetTLY - The top left Y dataset cell coordinate
nDatasetBRX - The bottom right X dataset cell coordinate
nDatasetBRY - The bottom right Y dataset cell coordinate
nWith - The width of the output view
nHeight - The height of the output view
Returns:
0 for success, an error number for failure.
Throws:
JNCSFileNotOpenException - indicating there is currently no valid open file.
JNCSInvalidSetViewException - the input coordinates are not valid.
See Also:
setView(int, int, double, double, double, double, int, int)

setView

public int setView(int nBands,
                   int[] nBandList,
                   double dWorldTLX,
                   double dWorldTLY,
                   double dWorldBRX,
                   double dWorldBRY,
                   int nWidth,
                   int nHeight)
            throws JNCSInvalidSetViewException,
                   JNCSFileNotOpenException
Set a view of an open ECW file, in world coordinates. Setting a view requires specifiying number of bands to decode, the band list indicating which bands should be decoded, the top left and bottom right world coordinates, and the sample output view width and height.

This method returns 0 on success, or 1 of the extents were outside the dataset. It only throws an exception if the set view call actually fails (for example because of an internal error). This is because exceptions are expensive at runtime, and it is valid to request an area out side the dataset, but for the renderer to silently draw nothing.

Overrides:
setView in class JNCSFile
Parameters:
nBands - The number of bands to decode
nBandList - The list indicating which bands to decode. For RGB123 this should be {0,1,2}.
dWorldTLX - The top left X world coordinate
dWorldTLY - The top left Y world coordinate
dWorldBRX - The bottom right X world coordinate
dWorldBRY - The bottom right Y world coordinate
nWith - The width of the output view
nHeight - The height of the output view
Returns:
0 for success, an error number for failure.
Throws:
JNCSFileNotOpenException - indicating there is currently no valid open file.
JNCSInvalidSetViewException - the input coordinates are not valid.
See Also:
setView(int, int, int, int, int, int, int, int)

refreshUpdate

public void refreshUpdate(int nWidth,
                          int nHeight,
                          double dWorldTLX,
                          double dWorldTLY,
                          double dWorldBRX,
                          double dWorldBRY)
Description copied from interface: JNCSProgressiveUpdate
This method gets called when imagery arrives from the network and the set view was in world coordinates. When using progressive imagery, clients must implement this class.
Overrides:
refreshUpdate in class JNCSFile
Following copied from interface: com.ermapper.ecw.JNCSProgressiveUpdate
Parameters:
nWidth - The width of the setView which generated this callback
nHeight - The height of the setView which generated this callback
dWorldTLX - The top left X coord that generated this callback
dWorldTLY - The top left Y coord that generated this callback
dWorldBRX - The bottom right X coord that generated this callback
dWorldBRY - The bottom right Y coord that generated this callback
See Also:
JNCSFile.addProgressiveUpdateListener(com.ermapper.ecw.JNCSProgressiveUpdate)

refreshUpdate

public void refreshUpdate(int nWidth,
                          int nHeight,
                          int dDatasetTLX,
                          int dDatasetTLY,
                          double dDatasetBRX,
                          int dDatasetBRY)

drawImage

public void drawImage(java.awt.Graphics g,
                      int tlX,
                      int tlY,
                      int nWidth,
                      int nHeight,
                      double dWorldTLX,
                      double dWorldTLY,
                      double dWorldBRX,
                      double dWorldBRY,
                      java.awt.image.ImageObserver imgObsv)
Draw all available imagery to the graphics context. Call this method to draw whatever imagery is currently available from the net (or local) to the specified graphics context. The first four int parameters represent the bounding rect that the renderer should draw into. The imgObv parameter is a standard Java ImageObserver, normally implemented by any component that you may wish to draw into, such as an applet or frame. In progressive mode, the current available imagery may not match the current extents of the frame (since decoding and image display are asynchronous in this mode). Therefore, you must specify the extents of the output device and the world extents they represent, the renderer will scale and offset the imagery accordingly.
Parameters:
g - The Java graphics context
tlX - The x offset into the graphics context
tlY - The y offset into the graphics context
nWidth - The width of the graphics context
nHeight - The height of the graphics context
dWorldTLX - The world top left X coordinate of the graphics context
dWorldTLY - The world top left Y coordinate of the graphics context
dWorldBRX - The world bottom right X coordinate of the graphics context
dWorldBRY - The world bottom right Y coordinate of the graphics context
imgObsv - The component being drawn.
See Also:
Graphics