Horus Doc || Java GUI Reference || Doxygen's quick Index  

CanvasHxImage Class Reference

Extension of CanvasImage to display a HxImageRep (C++ image). More...

Inheritance diagram for CanvasHxImage::

CanvasImage CanvasObject List of all members.

Public Methods

 CanvasHxImage (String imName, String displayMode)
 Constructor. More...

 CanvasHxImage (String imName, String displayMode, int displayDimension, int displayPlane, double resolution, int interpType)
 Constructor. More...

void draw (Graphics g)
 Draw CanvasObject on 'g', using internal CCS values. More...

void setPixel (int x, int y, Color c)
void moveImage (double x, double y)
 Moves the image to the (x,y) position, keeping current properties. More...

BufferedImage getSubImage (int x, int y, int w, int h)
 Implementation CanvasImage interface. More...

String[] getPixelStrings (int x, int y, int w, int h)
 Implementation CanvasImage interface. More...

String getSaName ()
 Overrides CanvasObject interface. More...

String getDisplayMode ()
void setDisplayMode (String displayMode)
int getDisplayDimension ()
void setDisplayDimension (int displayDimension)
int getDisplayPlane ()
void setDisplayPlane (int displayPlane)
double getResolution ()
void setResolution (double resolution)
int getInterpolationType ()
void setInterpolationType (int interpType)
void refreshPixels ()
int getHxImageRepWidth ()
int getHxImageRepHeight ()
int getHxImageRepDepth ()
Vector getVisualChangeMethods ()
 Overrides CanvasObject interface. More...


Static Public Attributes

final int TYPE_NEAREST = 0
final int TYPE_LINEAR = 1

Detailed Description

Extension of CanvasImage to display a HxImageRep (C++ image).

There are several "images" involved in this class. First of all there is the C++ image (known by its SA name). Since the C++ image can be both 2D and 3D we also hava a "display image". The display image is determined by the viewing direction and the display plane. The sizes of the display image (\_dispImWidth and \_dispImHeight) determine the sizes (in ICS) of the CanvasHxImage. For display, CanvasHxImage makes use of a BufferedImage (\_bufIm). The sizes of this image are determined by the sizes of the display image and the resolution at with the CanvasHxImage is to be displayed. For example, \_bufImWidth = round(\_dispImWidth * resolution). The draw method of this class actually draws \_bufIm at the CCS coordinates. So, Graphics.drawImage does the actual zooming of the pixel data.


Constructor & Destructor Documentation

CanvasHxImage::CanvasHxImage String    imName,
String    displayMode
[inline]
 

Constructor.

00047 {
00048     this(imName, displayMode, 3, 0, 1.0, TYPE_NEAREST);
00049 }

CanvasHxImage::CanvasHxImage String    imName,
String    displayMode,
int    displayDimension,
int    displayPlane,
double    resolution,
int    interpType
[inline]
 

Constructor.

00057 {
00058     super(Converter.ICS_ORIGIN, Converter.ICS_ORIGIN, 0., 0.);
00059     doInit(imName, displayMode, displayDimension, displayPlane, resolution,
00060            interpType);
00061 }


Member Function Documentation

void CanvasHxImage::draw Graphics    g [inline, virtual]
 

Draw CanvasObject on 'g', using internal CCS values.

Reimplemented from CanvasObject.

00065 {
00066     setupDrawMode(g);
00067     if (!getTransformOK())
00068         transformICStoCCS();
00069 if (DEBUG_OBJECTS) {
00070 OutputStreamArea.println("Draw HxImage called, image w: " +
00071                          _bufIm.getWidth(null) + ", h: " +
00072                          _bufIm.getHeight(null));
00073 dump();
00074 }
00075     g.drawImage(_bufIm, getX1Ccs(), getY1Ccs(), getWidthCcs(),
00076                 getHeightCcs(), null);
00077 }

void CanvasHxImage::setPixel int    x,
int    y,
Color    c
[inline, virtual]
 

Reimplemented from CanvasImage.

00081 {
00082     // ignore
00083 }

void CanvasHxImage::moveImage double    x,
double    y
[inline]
 

Moves the image to the (x,y) position, keeping current properties.

Reimplemented from CanvasImage.

00087 {
00088     setImageDim(x, y, getWidth(), getHeight(), getZoomFactor());
00089 }

BufferedImage CanvasHxImage::getSubImage int    x,
int    y,
int    w,
int    h
[inline, virtual]
 

Implementation CanvasImage interface.

Takes care of possible changes in resolution set by the user.

Reimplemented from CanvasImage.

00096 {
00097     int nx = (int) Math.round(x * _resolution);
00098     int ny = (int) Math.round(y * _resolution);
00099     int nw = (int) Math.round(w * _resolution);
00100     int nh = (int) Math.round(h * _resolution);
00101     return _bufIm.getSubimage(nx, ny, nw, nh);
00102 }

String [] CanvasHxImage::getPixelStrings int    x,
int    y,
int    w,
int    h
[inline, virtual]
 

Implementation CanvasImage interface.

Reimplemented from CanvasImage.

00108 {
00109     String[] strs = new String[w*h];
00110     String[] args = new String[3];
00111     args[2] = new String("int 0");
00112     for (int i=0; i<w; i++) {
00113         for (int j=0; j<h; j++) {
00114             if (x+i < 0 || y+j < 0 || x+i >= _dispImWidth || y+j >= _dispImHeight) {
00115                 strs[i+j*w] = new String("");
00116             } else {
00117                 args[0] = new String("int ") + (x+i);
00118                 args[1] = new String("int ") + (y+j);
00119                 strs[i+j*w] = _mediator.callMethod("HxImageRep", _name,
00120                                                    "getAt", "", args);
00121             }
00122         }
00123     }
00124     return strs;
00125 }

String CanvasHxImage::getSaName   [inline]
 

Overrides CanvasObject interface.

Reimplemented from CanvasObject.

00131 {
00132     return _name;
00133 }

String CanvasHxImage::getDisplayMode   [inline]
 

00137 {
00138     return _displayMode;
00139 }

void CanvasHxImage::setDisplayMode String    displayMode [inline]
 

00143 {
00144     if (displayMode != _displayMode) {
00145         updatePixels(displayMode, _displayDimension, _displayPlane,
00146                      _resolution, _interpolationType);
00147     }
00148 }

int CanvasHxImage::getDisplayDimension   [inline]
 

00152 {
00153     return _displayDimension;
00154 }

void CanvasHxImage::setDisplayDimension int    displayDimension [inline]
 

00158 {
00159     if (displayDimension != _displayDimension) {
00160         updatePixels(_displayMode, displayDimension, _displayPlane,
00161                      _resolution, _interpolationType);
00162     }
00163 }

int CanvasHxImage::getDisplayPlane   [inline]
 

00167 {
00168     return _displayPlane;
00169 }

void CanvasHxImage::setDisplayPlane int    displayPlane [inline]
 

00173 {
00174     if (displayPlane != _displayPlane) {
00175         updatePixels(_displayMode, _displayDimension, displayPlane,
00176                      _resolution, _interpolationType);
00177     }
00178 }

double CanvasHxImage::getResolution   [inline]
 

00182 {
00183     return _resolution;
00184 }

void CanvasHxImage::setResolution double    resolution [inline]
 

00188 {
00189     if (resolution != _resolution) {
00190         updatePixels(_displayMode, _displayDimension, _displayPlane,
00191                      resolution, _interpolationType);
00192     }
00193 }

int CanvasHxImage::getInterpolationType   [inline]
 

00197 {
00198     return _interpolationType;
00199 }

void CanvasHxImage::setInterpolationType int    interpType [inline]
 

00203 {
00204     if (interpType != _interpolationType) {
00205         updatePixels(_displayMode, _displayDimension, _displayPlane,
00206                      _resolution, interpType);
00207     }
00208 }

void CanvasHxImage::refreshPixels   [inline]
 

00212 {
00213 //long startTime = System.currentTimeMillis();
00214     _mediator.hxImageGetPixels(_name, _pixels, _displayMode, _displayDimension,
00215                                _displayPlane, _bufImWidth, _bufImHeight,
00216                                _interpolationType);
00217 //long endTime = System.currentTimeMillis();
00218 //endTime = endTime - startTime;
00219 //OutputStreamArea.println("display time: " + endTime);
00220 }

int CanvasHxImage::getHxImageRepWidth   [inline]
 

00224 {
00225     String[] args = { "int 1" };
00226     String result = _mediator.callMethod("HxImageRep", _name,
00227                                          "dimensionSize", "", args);
00228     return java.lang.Integer.parseInt(result);
00229 }

int CanvasHxImage::getHxImageRepHeight   [inline]
 

00233 {
00234     String[] args = { "int 2" };
00235     String result = _mediator.callMethod("HxImageRep", _name,
00236                                          "dimensionSize", "", args);
00237     return java.lang.Integer.parseInt(result);
00238 }

int CanvasHxImage::getHxImageRepDepth   [inline]
 

00242 {
00243     String[] args = { "int 3" };
00244     String result = _mediator.callMethod("HxImageRep", _name,
00245                                          "dimensionSize", "", args);
00246     return java.lang.Integer.parseInt(result);
00247 }

Vector CanvasHxImage::getVisualChangeMethods   [inline]
 

Overrides CanvasObject interface.

Extends the list of callable functions obtained from the parent with the functions for this class.

Reimplemented from CanvasObject.

00255 {
00256     Vector v = super.getVisualChangeMethods();
00257     v.add(new CallableMethod("setDisplayMode", "String", "m", "rgb"));
00258     v.add(new CallableMethod("setDisplayDimension", "int", "d", "int"));
00259     v.add(new CallableMethod("setDisplayPlane", "int", "nr", "int"));
00260     v.add(new CallableMethod("setResolution", "double", "r", "double"));
00261     v.add(new CallableMethod("setInterpolationType", "int", "i", "HxGeoIntType"));
00262     return v;
00263 }


Member Data Documentation

final int CanvasHxImage::TYPE_NEAREST = 0 [static]
 

final int CanvasHxImage::TYPE_LINEAR = 1 [static]
 


The documentation for this class was generated from the following file:
Generated on Tue Feb 3 14:19:39 2004 for JavaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001