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

CanvasMask Class Reference

Inheritance diagram for CanvasMask::

ScribbleFigure ScribbleObject CanvasObject List of all members.

Public Methods

 CanvasMask (Image im, double x, double y)
 CanvasMask (int[] pixels, double x, double y, int w, int h)
 CanvasMask (Image im, 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 doPixelFit (double zoomFactor)
 Round internal ICS values to nearest natural number. More...

void setColor (Color newColor)
void setTransparency (float trans)
Image getMask ()
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)
int changePoint (int index, int x, int y)

Static Public Attributes

final int NO_PIX = 0x00000000

Protected Methods

void initMask (int[] pixels, int w, int h, Color color)
void initMask (Image im, Color color)

Protected Attributes

Image image = null

Constructor & Destructor Documentation

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

00044     {
00045         this(im, x, y, NO_COLOR, DEF_TRANS, DEF_SCALE);
00046     }

CanvasMask::CanvasMask int    pixels[],
double    x,
double    y,
int    w,
int    h
[inline]
 

00050     {
00051         super(x-0.5, y-0.5, 0., 0., COPY_MODE,
00052               NO_COLOR, false, DEF_LINEW, DEF_TRANS, DEF_SCALE);
00053         initMask(pixels, w, h, NO_COLOR);
00054     }

CanvasMask::CanvasMask Image    im,
double    x,
double    y,
Color    color,
float    trans,
double    ccs_scale
[inline]
 

00059     {
00060         super(x-0.5, y-0.5, 0., 0., COPY_MODE,
00061               color, false, DEF_LINEW, trans, ccs_scale);
00062         initMask(im, color);
00063     }


Member Function Documentation

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

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

Reimplemented from CanvasObject.

00070     {
00071         if (image != null) {
00072             setupDrawMode(g);
00073             if (!getTransformOK()) {
00074                 transformICStoCCS();
00075             }
00076             g.drawImage(image, getX1Ccs(), getY1Ccs(), getWidthCcs(), getHeightCcs(), null);
00077         }
00078     }

Object CanvasMask::clone   [inline, virtual]
 

Return an identical copy of this CanvasObject.

Reimplemented from CanvasObject.

00082     {
00083         return (new CanvasMask(image, getX1()+0.5, getY1()+0.5, 
00084                                drawColor, transparency, getZoomFactor()));
00085     }

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

00089     {
00090         return inBoundingBox(x, y);
00091     }

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

00095     {
00096         return isInside(x, y);
00097     }

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

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

Parameters are assumed Image Coordinate System values.

Reimplemented from ScribbleObject.

00101     {
00102         // overrule super.setDimension(w, h), and do nothing
00103 
00104         return;
00105     }

void CanvasMask::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.

00109     {
00110         super.doPixelFit(zoomFactor);
00111 
00112         setX1((int)getX1() - 0.5);
00113         setY1((int)getY1() - 0.5);
00114         setStartX(getX1());
00115         setStartY(getY1());
00116 
00117         setTransformOK(false);
00118     }

void CanvasMask::setColor Color    newColor [inline]
 

Reimplemented from ScribbleFigure.

00122     {
00123         if (newColor == NO_COLOR) {
00124             return;
00125         }
00126         if (getWidth() > 0. && getHeight() > 0.) {
00127             drawColor      = newColor;
00128             int width      = (int)(getWidth() + 0.5);
00129             int height     = (int)(getHeight() + 0.5);
00130             ImageBuffer ib = new ImageBuffer(image, width, height);
00131             int[] pixels   = ib.getPixels();
00132 
00133             for (int i=0; i<pixels.length; i++) {
00134                 if (pixels[i] != NO_PIX) {
00135                     pixels[i] = drawColor.getRGB();
00136                 }
00137             }
00138 
00139             ib.fill(pixels, width, height);
00140             image = ib.toImage();
00141         }
00142     }

void CanvasMask::setTransparency float    trans [inline]
 

Reimplemented from ScribbleFigure.

00146     {
00147         super.setTransparency(trans);
00148         int scaled = (((int)(transparency * 255)) << 24) | 0x00FFFFFF;
00149 
00150         if (getWidth() > 0. && getHeight() > 0.) {
00151             int width      = (int)(getWidth() + 0.5);
00152             int height     = (int)(getHeight() + 0.5);
00153             ImageBuffer ib = new ImageBuffer(image, width, height);
00154             int[] pixels   = ib.getPixels();
00155 
00156             for (int i=0; i<pixels.length; i++) {
00157                 if (pixels[i] != NO_PIX) {
00158                     pixels[i] = (pixels[i] | 0xFF000000) & scaled;
00159                 }
00160             }
00161 
00162             ib.fill(pixels, width, height);
00163             image = ib.toImage();
00164         }
00165     }

Image CanvasMask::getMask   [inline]
 

00169     {
00170         return image;
00171     }

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

To be removed.

Reimplemented from CanvasObject.

00189     {
00190         return inBoundingBoxCcs(x, y);
00191     }

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

To be removed.

Reimplemented from CanvasObject.

00195     {
00196         return isInsideCcs(x, y);
00197     }

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

Reimplemented from ScribbleObject.

00201     {
00202         // overrule super.setDimension(w, h), and do nothing
00203 
00204         return;
00205     }

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

Reimplemented from ScribbleFigure.

00209     {
00210         // overrule super.changePoint(index, x, y), and do nothing
00211 
00212         return index;
00213     }

void CanvasMask::initMask int    pixels[],
int    w,
int    h,
Color    color
[inline, protected]
 

00227     {
00228         ImageBuffer ib = new ImageBuffer(pixels, w, h);
00229         initMask(ib.toImage(), color);
00230     }

void CanvasMask::initMask Image    im,
Color    color
[inline, protected]
 

00234     {
00235         resizeable   = false;
00236         hasLineWidth = false;
00237         hasNoColor   = false;
00238         image = im;
00239         if (image != null) {
00240             setWidth(image.getWidth(null));
00241             setHeight(image.getHeight(null));
00242             setColor(color);
00243         }
00244         transformICStoCCS();
00245     }


Member Data Documentation

final int CanvasMask::NO_PIX = 0x00000000 [static]
 

Image CanvasMask::image = null [protected]
 


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