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

CanvasBlob Class Reference

Inheritance diagram for CanvasBlob::

ScribbleFigure ScribbleObject CanvasObject List of all members.

Public Methods

 CanvasBlob ()
 CanvasBlob (Image im, double x, double y)
 CanvasBlob (Image im, double x, double y, Color color)
 CanvasBlob (Image im, int[] codes, double x, double y)
 CanvasBlob (Image im, int[] codes, double x, double y, Color color)
 CanvasBlob (Image im, int[] codes, double x, double y, Color color, float trans, double ccs_scale)
void draw (Graphics g)
 Draw CanvasObject on 'g', using internal CCS values. More...

Object clone ()
 Return an identical copy of this CanvasObject. More...

boolean isInside (double x, double y)
boolean isNear (double x, double y)
void setDimension (double w, double h)
 Resize CanvasObject to width 'w' and height 'h'. More...

void setZoomFactor (double zoomFactor)
 Scale CanvasObject according to 'zoomFactor'. More...

void doPixelFit (double zoomFactor)
 Round internal ICS values to nearest natural number. More...

void doMove (double w, double h)
 Move CanvasObject 'w' positions in x-direction, and 'h' posi- tions in y-direction. More...

void setColor (Color color)
void setTransparency (float trans)
void setDrawMode (int mode)
 Set current draw-mode. More...

void showMask (boolean b)
void showChain (boolean b)
Vector getVisualChangeMethods ()
 Builds up a list of functions that are to fill a menu for changing the visualization aspects of an object. More...

boolean isInsideCcs (int x, int y)
 To be removed. More...

boolean isNearCcs (int x, int y)
 To be removed. More...

void setDimension (int w, int h)
void doMove (int w, int h)
int changePoint (int index, int x, int y)

Protected Methods

void initBlob (Image im, int[] codes, double x, double y, Color color, float trans, double ccs_scale)
void setBox ()

Protected Attributes

CanvasMask mask = null
CanvasChain chain = null
boolean showMask = true
boolean showChain = true

Static Protected Attributes

final int INV_COLOR = 0x00FFFFFF

Constructor & Destructor Documentation

CanvasBlob::CanvasBlob   [inline]
 

00031     {
00032         this((Image)null, null, 0., 0., NO_COLOR, DEF_TRANS, DEF_SCALE);
00033     }

CanvasBlob::CanvasBlob Image    im,
double    x,
double    y
[inline]
 

00037     {
00038         this(im, null, x, y, NO_COLOR, DEF_TRANS, DEF_SCALE);
00039     }

CanvasBlob::CanvasBlob Image    im,
double    x,
double    y,
Color    color
[inline]
 

00043     {
00044         this(im, null, x, y, color, DEF_TRANS, DEF_SCALE);
00045     }

CanvasBlob::CanvasBlob Image    im,
int    codes[],
double    x,
double    y
[inline]
 

00049     {
00050         this(im, codes, x, y, NO_COLOR, DEF_TRANS, DEF_SCALE);
00051     }

CanvasBlob::CanvasBlob Image    im,
int    codes[],
double    x,
double    y,
Color    color
[inline]
 

00056     {
00057         this(im, codes, x, y, color, DEF_TRANS, DEF_SCALE);
00058     }

CanvasBlob::CanvasBlob Image    im,
int    codes[],
double    x,
double    y,
Color    color,
float    trans,
double    ccs_scale
[inline]
 

00063     {
00064         super(x-0.5, y-0.5, 0., 0., COPY_MODE,
00065               color, false, DEF_LINEW, trans, ccs_scale);
00066         initBlob(im, codes, x, y, color, trans, ccs_scale);
00067     }


Member Function Documentation

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

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

Reimplemented from CanvasObject.

00091     {
00092         if (!getTransformOK()) {
00093             transformICStoCCS();
00094         }
00095         if (mask != null && showMask) {
00096             mask.draw(g);
00097         }
00098         if (chain != null && showChain) {
00099             chain.draw(g);
00100         }
00101     }

Object CanvasBlob::clone   [inline, virtual]
 

Return an identical copy of this CanvasObject.

Reimplemented from CanvasObject.

00105     {
00106         CanvasBlob blob;
00107 
00108         if (chain == null) {
00109             blob = new CanvasBlob(mask.getMask(), null,
00110                                   getX1()+0.5, getY1()+0.5, mask.getColor(),
00111                                   transparency, getZoomFactor());
00112         } else {
00113             blob = new CanvasBlob(mask.getMask(), chain.getChain(),
00114                                   getX1()+0.5, getY1()+0.5, mask.getColor(),
00115                                   transparency, getZoomFactor());
00116         }
00117         blob.showMask(showMask);
00118         blob.showChain(showChain);
00119         return blob;
00120     }

boolean CanvasBlob::isInside double    x,
double    y
[inline]
 

00124     {
00125         if (chain != null) {
00126             return chain.isInside(x, y);
00127         } else {
00128             return mask.isInside(x, y);
00129         }
00130     }

boolean CanvasBlob::isNear double    x,
double    y
[inline]
 

00134     {
00135         if (chain != null) {
00136             return (chain.isNear(x, y) || chain.isInside(x, y));
00137         } else {
00138             return mask.isNear(x, y);
00139         }
00140     }

void CanvasBlob::setDimension double    w,
double    h
[inline]
 

Resize CanvasObject to width 'w' and height 'h'.

Parameters are assumed Image Coordinate System values.

Reimplemented from ScribbleObject.

00144     {
00145         // overrule super.setDimension(w, h), and do nothing
00146 
00147         return;
00148     }

void CanvasBlob::setZoomFactor double    zoomFactor [inline]
 

Scale CanvasObject according to 'zoomFactor'.

The internal ICS values are taken as base values to calculate the associated CCS values.

Reimplemented from CanvasObject.

00152     {
00153         super.setZoomFactor(zoomFactor);
00154 
00155         if (mask != null) {
00156             mask.setZoomFactor(zoomFactor);
00157         }
00158         if (chain != null) {
00159             chain.setZoomFactor(zoomFactor);
00160         }
00161         setBox();
00162     }

void CanvasBlob::doPixelFit double    zoomFactor [inline]
 

Round internal ICS values to nearest natural number.

Although the ICS values are changed, they are not converted to 'integer' internally.

Reimplemented from ScribbleObject.

00166     {
00167         super.setZoomFactor(zoomFactor);
00168 
00169         if (mask != null) {
00170             mask.doPixelFit(zoomFactor);
00171         }
00172         if (chain != null) {
00173             chain.doPixelFit(zoomFactor);
00174         }
00175         setBox();
00176     }

void CanvasBlob::doMove double    w,
double    h
[inline]
 

Move CanvasObject 'w' positions in x-direction, and 'h' posi- tions in y-direction.

Parameters are assumed Image Coordinate System values.

Reimplemented from ScribbleObject.

00180     {
00181         if (mask != null) {
00182             mask.doMove(w, h);
00183         }
00184         if (chain != null) {
00185             chain.setPosition(mask.getX1()+0.5, mask.getY1()+0.5);
00186         }
00187         setBox();
00188     }

void CanvasBlob::setColor Color    color [inline]
 

Reimplemented from ScribbleFigure.

00192     {
00193         if (color == NO_COLOR) {
00194             return;
00195         }
00196 
00197         Color maskColor  = color;
00198         Color chainColor = new Color(color.getRGB() ^ INV_COLOR);
00199 
00200         if ((!showMask) && showChain) {
00201             maskColor  = chainColor;
00202             chainColor = color;
00203         }
00204 
00205         if (mask != null) {
00206             mask.setColor(maskColor);
00207         }
00208         if (chain != null) {
00209             chain.setColor(chainColor);
00210         }
00211     }

void CanvasBlob::setTransparency float    trans [inline]
 

Reimplemented from ScribbleFigure.

00215     {
00216         super.setTransparency(trans);
00217 
00218         if (mask != null) {
00219             mask.setTransparency(trans);
00220         }
00221         if (chain != null) {
00222             chain.setTransparency(trans);
00223         }
00224     }

void CanvasBlob::setDrawMode int    mode [inline]
 

Set current draw-mode.

Reimplemented from CanvasObject.

00228     {
00229         super.setDrawMode(mode);
00230         if (mask != null) {
00231             mask.setDrawMode(mode);
00232         }
00233         if (chain != null) {
00234             chain.setDrawMode(mode);
00235         }
00236     }

void CanvasBlob::showMask boolean    b [inline]
 

00240     {
00241         showMask = b;
00242     }

void CanvasBlob::showChain boolean    b [inline]
 

00246     {
00247         showChain = b;
00248     }

Vector CanvasBlob::getVisualChangeMethods   [inline]
 

Builds up a list of functions that are to fill a menu for changing the visualization aspects of an object.

Classes derived from this one typically add their class-specific methods to their parents' methods by first calling the parent to fill the vector and then add their own. The result is a Vector of CallableMethods.

Reimplemented from ScribbleFigure.

00255     {
00256         Vector v = super.getVisualChangeMethods();
00257         v.add(new CallableMethod("showMask", "boolean", "b", "boolean"));
00258         v.add(new CallableMethod("showChain", "boolean", "b", "boolean"));
00259         return v;
00260     }

boolean CanvasBlob::isInsideCcs int    x,
int    y
[inline]
 

To be removed.

Reimplemented from CanvasObject.

00278     {
00279         if (chain != null) {
00280             return chain.isInsideCcs(x, y);
00281         } else {
00282             return mask.isInsideCcs(x, y);
00283         }
00284     }

boolean CanvasBlob::isNearCcs int    x,
int    y
[inline]
 

To be removed.

Reimplemented from CanvasObject.

00288     {
00289         if (chain != null) {
00290             return (chain.isNearCcs(x, y) || chain.isInsideCcs(x, y));
00291         } else {
00292             return mask.isNearCcs(x, y);
00293         }
00294     }

void CanvasBlob::setDimension int    w,
int    h
[inline]
 

Reimplemented from ScribbleObject.

00298     {
00299         // overrule super.setDimension(w, h), and do nothing
00300 
00301         return;
00302     }

void CanvasBlob::doMove int    w,
int    h
[inline]
 

Reimplemented from ScribbleObject.

00306     {
00307         if (mask != null) {
00308             mask.doMove(w, h);
00309         }
00310         if (chain != null) {
00311             chain.setPosition(mask.getX1()+0.5, mask.getY1()+0.5);
00312         }
00313         setBox();
00314     }

int CanvasBlob::changePoint int    index,
int    x,
int    y
[inline]
 

Reimplemented from ScribbleFigure.

00318     {
00319         // overrule super.changePoint(index, x, y), and do nothing
00320 
00321         return index;
00322     }

void CanvasBlob::initBlob Image    im,
int    codes[],
double    x,
double    y,
Color    color,
float    trans,
double    ccs_scale
[inline, protected]
 

00337     {
00338         resizeable   = false;
00339         hasLineWidth = false;
00340         hasNoColor   = false;
00341 
00342         mask = new CanvasMask(im, x, y, color, trans, ccs_scale);
00343 
00344         Color inverted;
00345         if (color == NO_COLOR) {
00346             inverted = new Color(DEF_COLOR.getRGB() ^ INV_COLOR);
00347         } else {
00348             inverted = new Color(color.getRGB() ^ INV_COLOR);
00349         }
00350         if (codes != null) {
00351             chain = new CanvasChain(codes, x, y, inverted,
00352                                     false, DEF_LINEW, trans, ccs_scale);
00353             chain.setPosition(x, y);
00354             chain.setCircular(true);
00355         }
00356         setBox();
00357         transformICStoCCS();
00358 
00359     }

void CanvasBlob::setBox   [inline, protected]
 

00456     {
00457         if (mask != null) {
00458             setX1(mask.getX1());
00459             setY1(mask.getY1());
00460             setWidth(mask.getWidth());
00461             setHeight(mask.getHeight());
00462         } else if (chain != null) {
00463             setX1(chain.getX1());
00464             setY1(chain.getY1());
00465             setWidth(chain.getWidth());
00466             setHeight(chain.getHeight());
00467         }
00468 
00469         setStartX(getX1());
00470         setStartY(getY1());
00471 
00472         setTransformOK(false);
00473     }


Member Data Documentation

final int CanvasBlob::INV_COLOR = 0x00FFFFFF [static, protected]
 

CanvasMask CanvasBlob::mask = null [protected]
 

CanvasChain CanvasBlob::chain = null [protected]
 

boolean CanvasBlob::showMask = true [protected]
 

boolean CanvasBlob::showChain = true [protected]
 


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