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

CanvasHxBlob2d Class Reference

Display a HxBlob2d (C++ blob). More...

Inheritance diagram for CanvasHxBlob2d::

CanvasFigure CanvasObject List of all members.

Public Methods

 CanvasHxBlob2d (String name)
 Constructor. More...

void draw (Graphics g)
 Implements CanvasObject "interface". More...

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

void setColor (Color color)
 Override CanvasFigure interface to update the color of the mask. More...

void setTransparency (float trans)
 Override CanvasFigure interface to update the transparency of the mask. More...

void setShowMask (boolean b)
void setShowChain (boolean b)
int getContourX ()
int getContourY ()
int getContourLength ()
int getHxBlobXmin ()
int getHxBlobYmin ()
int getHxBlobWidth ()
int getHxBlobHeight ()
Vector getVisualChangeMethods ()
 Overrides CanvasObject interface. More...


Protected Methods

Shape getShape ()
 Derived classes have to implement this method to supply the shape that represents the CanvasFigures. More...

boolean hitOnStroke ()
 Derived classes have to implement this method to indicate whether they are selected (hit) based on their stroke (border) or on their interior. More...


Detailed Description

Display a HxBlob2d (C++ blob).


Constructor & Destructor Documentation

CanvasHxBlob2d::CanvasHxBlob2d String    name [inline]
 

Constructor.

00030 {
00031     super(0., 0., 0., 0.);
00032     _name = name;
00033     _mediator = new HxMediatorPeer();
00034     setInputSource(INP_SASYSTEM);
00035     setObjectExtend();
00036     updateChain();
00037     updateMask();
00038 }


Member Function Documentation

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

Implements CanvasObject "interface".

Reimplemented from CanvasFigure.

00042 {
00043     if (_showMask) {
00044         int[] ccs = new int[4];
00045         Converter.ICStoCCS(_maskIcs, ccs, getZoomFactor());
00046         g.drawImage(_bufIm, ccs[0], ccs[1], ccs[2] - ccs[0],
00047                     ccs[3] - ccs[1], null);
00048     }
00049     if (_showChain)
00050         super.draw(g);
00051 }

String CanvasHxBlob2d::getSaName   [inline]
 

Overrides CanvasObject interface.

Reimplemented from CanvasObject.

00057 {
00058     return _name;
00059 }

void CanvasHxBlob2d::setColor Color    color [inline]
 

Override CanvasFigure interface to update the color of the mask.

The color of the chain is set to the inverted color.

Reimplemented from CanvasFigure.

00066 {
00067     if (color == null)
00068         return;
00069 
00070     _maskColor  = color;
00071     _chainColor = new Color(color.getRGB() ^ INV_PIX);
00072 
00073     super.setColor(_chainColor); // chain is drawn by CanvasFigure
00074 
00075     // We have to do the mask ourselves
00076     for (int i=0; i<_pixels.length; i++) {
00077         if (_pixels[i] != NO_PIX) {
00078             _pixels[i] = _maskColor.getRGB();
00079         }
00080     }
00081 }

void CanvasHxBlob2d::setTransparency float    trans [inline]
 

Override CanvasFigure interface to update the transparency of the mask.

Reimplemented from CanvasFigure.

00087 {
00088     super.setTransparency(trans); // chain is handled by CanvasFigure
00089 
00090     // We have to do the mask ourselves
00091     int scaled = (((int)(1.0 - getTransparency() * 255)) << 24) | 0x00FFFFFF;
00092     for (int i=0; i<_pixels.length; i++) {
00093         if (_pixels[i] != NO_PIX) {
00094             _pixels[i] = (_pixels[i] | 0xFF000000) & scaled;
00095         }
00096     }
00097 }

void CanvasHxBlob2d::setShowMask boolean    b [inline]
 

00101 {
00102     _showMask = b;
00103 }

void CanvasHxBlob2d::setShowChain boolean    b [inline]
 

00107 {
00108     _showChain = b;
00109 }

int CanvasHxBlob2d::getContourX   [inline]
 

00113 {
00114     String[] args = new String[0];
00115     String result = _mediator.callMethod("HxBlob2d", _name,
00116                                          "getContourX", "", args);
00117     return new Integer(result).intValue();
00118 }

int CanvasHxBlob2d::getContourY   [inline]
 

00122 {
00123     String[] args = new String[0];
00124     String result = _mediator.callMethod("HxBlob2d", _name,
00125                                          "getContourY", "", args);
00126     return new Integer(result).intValue();
00127 }

int CanvasHxBlob2d::getContourLength   [inline]
 

00131 {
00132     String[] args = new String[0];
00133     String result = _mediator.callMethod("HxBlob2d", _name,
00134                                          "getContourLength", "", args);
00135     return new Integer(result).intValue();
00136 }

int CanvasHxBlob2d::getHxBlobXmin   [inline]
 

00140 {
00141     String[] args = new String[1];
00142     args[0] = new String("string xmin");
00143     String result = _mediator.callMethod("HxBlob2d", _name,
00144                                          "getFeature", "", args);
00145     return new Integer(result).intValue();
00146 }

int CanvasHxBlob2d::getHxBlobYmin   [inline]
 

00150 {
00151     String[] args = new String[1];
00152     args[0] = new String("string ymin");
00153     String result = _mediator.callMethod("HxBlob2d", _name,
00154                                          "getFeature", "", args);
00155     return new Integer(result).intValue();
00156 }

int CanvasHxBlob2d::getHxBlobWidth   [inline]
 

00160 {
00161     String[] args = new String[1];
00162     args[0] = new String("string width");
00163     String result = _mediator.callMethod("HxBlob2d", _name,
00164                                          "getFeature", "", args);
00165     return new Integer(result).intValue();
00166 }

int CanvasHxBlob2d::getHxBlobHeight   [inline]
 

00170 {
00171     String[] args = new String[1];
00172     args[0] = new String("string height");
00173     String result = _mediator.callMethod("HxBlob2d", _name,
00174                                          "getFeature", "", args);
00175     return new Integer(result).intValue();
00176 }

Vector CanvasHxBlob2d::getVisualChangeMethods   [inline]
 

Overrides CanvasObject interface.

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

Reimplemented from CanvasFigure.

00185 {
00186     Vector v = super.getVisualChangeMethods();
00187     v.add(new CallableMethod("setShowMask", "boolean", "b", "boolean"));
00188     v.add(new CallableMethod("setShowChain", "boolean", "b", "boolean"));
00189     return v;
00190 }

Shape CanvasHxBlob2d::getShape   [inline, protected, virtual]
 

Derived classes have to implement this method to supply the shape that represents the CanvasFigures.

It is used to draw to figure as well as determine which figure is selected (hit) by the cursor within a canvas.

Reimplemented from CanvasFigure.

00201 {
00202     int[] xp = getAddXCcs();
00203     int[] yp = getAddYCcs();
00204     GeneralPath path = new GeneralPath(GeneralPath.WIND_NON_ZERO, xp.length);
00205     path.moveTo(xp[0], yp[0]);
00206     for (int i=1 ; i < xp.length ; i++)
00207         path.lineTo(xp[i], yp[i]);
00208     return path;
00209 }

boolean CanvasHxBlob2d::hitOnStroke   [inline, protected, virtual]
 

Derived classes have to implement this method to indicate whether they are selected (hit) based on their stroke (border) or on their interior.

Reimplemented from CanvasFigure.

00213 {
00214     return false;
00215 }


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