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

CanvasRectangle Class Reference

Inheritance diagram for CanvasRectangle::

ScribbleFigure ScribbleObject CanvasObject List of all members.

Public Methods

 CanvasRectangle (double x, double y, double w, double h)
 CanvasRectangle (double x, double y, double w, double h, Color color)
 CanvasRectangle (double x, double y, double w, double h, Color color, boolean square)
 CanvasRectangle (double x, double y, double w, double h, int mode, Color color, boolean stroke, float linew, float trans, boolean square, double ccsScale)
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...

boolean isSquare ()
void setSquare (boolean square)
 CanvasRectangle (int x, int y, int w, int h, int mode, Color color, boolean square, double ccs_scale)
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)

Protected Attributes

boolean square = false

Constructor & Destructor Documentation

CanvasRectangle::CanvasRectangle double    x,
double    y,
double    w,
double    h
[inline]
 

00031     {
00032         super(x, y, w, h);
00033     }

CanvasRectangle::CanvasRectangle double    x,
double    y,
double    w,
double    h,
Color    color
[inline]
 

00038     {
00039         super(x, y, w, h, color);
00040     }

CanvasRectangle::CanvasRectangle double    x,
double    y,
double    w,
double    h,
Color    color,
boolean    square
[inline]
 

00045     {
00046         super(x, y, w, h, color);
00047         setSquare(square);
00048     }

CanvasRectangle::CanvasRectangle double    x,
double    y,
double    w,
double    h,
int    mode,
Color    color,
boolean    stroke,
float    linew,
float    trans,
boolean    square,
double    ccsScale
[inline]
 

00055     {
00056         super(x, y, w, h, mode, color, stroke, linew, trans, ccsScale);
00057         setSquare(square);
00058     }

CanvasRectangle::CanvasRectangle int    x,
int    y,
int    w,
int    h,
int    mode,
Color    color,
boolean    square,
double    ccs_scale
[inline]
 

00186     {
00187         super(x, y, w, h, mode, color, ccs_scale);
00188         setSquare(square);
00189     }


Member Function Documentation

void CanvasRectangle::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         }
00070 if (DEBUG_OBJECTS) {
00071 OutputStreamArea.println("Draw rectangle called");
00072 dump();
00073 }
00074         g.drawRect(getX1Ccs(), getY1Ccs(), getWidthCcs(), getHeightCcs());
00075     }

Object CanvasRectangle::clone   [inline, virtual]
 

Return an identical copy of this CanvasObject.

Reimplemented from CanvasObject.

00079     {
00080         Color color = drawColor;
00081         if (hasNoColor) {
00082             color = NO_COLOR;
00083         }
00084         return (new CanvasRectangle(getX1(), getY1(), getWidth(), getHeight(), getDrawMode(),
00085                                     color, strokeSet, lineWidth,
00086                                     transparency, square, getZoomFactor()));
00087     }

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

00091     {
00092         return inBoundingBox(x, y);
00093     }

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

00097     {
00098         // check if inside enlarged bounding box (== box + SPHERE),
00099         // but outside smaller bounding box (== box - SPHERE)
00100 
00101         if ((x >= getX1() - SPHERE) && (x < getX1() + getWidth() + SPHERE) &&
00102             (y >= getY1() - SPHERE) && (y < getY1() + getHeight() + SPHERE) &&
00103             !((x >= getX1() + SPHERE) && (x < getX1() + getWidth() - SPHERE) &&
00104               (y >= getY1() + SPHERE) && (y < getY1() + getHeight() - SPHERE))) {
00105             return true;
00106         }
00107         return false;
00108     }

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

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

Parameters are assumed Image Coordinate System values.

Reimplemented from ScribbleObject.

00112     {
00113         if (square) {
00114             
00115             double ics_max = Math.max(Math.abs(w), Math.abs(h));
00116 
00117             setWidth(ics_max);
00118             setHeight(ics_max);
00119 
00120             if (w <= 0.) {
00121                 w = -getWidth();
00122             } else {
00123                 w = getWidth();
00124             }
00125 
00126             if (h <= 0.) {
00127                 h = -getHeight();
00128             } else {
00129                 h = getHeight();
00130             }
00131         }
00132         super.setDimension(w, h);
00133     }

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

00137     {
00138         super.doPixelFit(zoomFactor);
00139 
00140         if (square) {
00141             double w = getWidth();
00142             double h = getHeight();
00143 
00144             if (getX1() != getStartX()) {
00145                 w = -w;
00146             }
00147             if (getY1() != getStartY()) {
00148                 h = -h;
00149             }
00150             setDimension(w, h);
00151         }
00152     }

boolean CanvasRectangle::isSquare   [inline]
 

00156     {
00157         return square;
00158     }

void CanvasRectangle::setSquare boolean    square [inline]
 

00162     {
00163         this.square = square;
00164         if (square) {
00165             this.setDimension(getWidth(), getHeight());
00166         }
00167     }

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

To be removed.

Reimplemented from CanvasObject.

00193     {
00194         return inBoundingBoxCcs(x, y);
00195     }

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

To be removed.

Reimplemented from CanvasObject.

00199     {
00200         if (!getTransformOK()) {
00201             transformICStoCCS();
00202         }
00203 
00204         // check if inside enlarged bounding box (== box + SPHERE),
00205         // but outside smaller bounding box (== box - SPHERE)
00206 
00207         if ((x >= getX1Ccs() - SPHERE) && (x < getX1Ccs() + getWidthCcs() + SPHERE) &&
00208             (y >= getY1Ccs() - SPHERE) && (y < getY1Ccs() + getHeightCcs() + SPHERE) &&
00209             !((x >= getX1Ccs() + SPHERE) && (x < getX1Ccs() + getWidthCcs() - SPHERE) &&
00210               (y >= getY1Ccs() + SPHERE) && (y < getY1Ccs() + getHeightCcs() - SPHERE))) {
00211             return true;
00212         }
00213         return false;
00214     }

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

Reimplemented from ScribbleObject.

00218     {
00219         if (!getTransformOK()) {
00220             transformICStoCCS();
00221         }
00222 
00223         if (square) {
00224 
00225             int ccs_max = Math.max(Math.abs(w), Math.abs(h));
00226 
00227             setWidthCcs(ccs_max);
00228             setHeightCcs(ccs_max);
00229 
00230             if (w <= 0) {
00231                 w = -getWidthCcs();
00232             } else {
00233                 w = getWidthCcs();
00234             }
00235 
00236             if (h <= 0) {
00237                 h = -getHeightCcs();
00238             } else {
00239                 h = getHeightCcs();
00240             }
00241         }
00242         super.setDimension(w, h);
00243     }

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

Reimplemented from ScribbleFigure.

00247     {
00248         int retval = super.changePoint(index, x, y);
00249         int min = Math.min(Math.abs(getWidthCcs()), Math.abs(getHeightCcs()));
00250         int max = Math.max(Math.abs(getWidthCcs()), Math.abs(getHeightCcs()));
00251 
00252         if (square && min > 0) {
00253             setWidthCcs(max);
00254             setHeightCcs(max);
00255 
00256             if (getX1Ccs() != getStartXCcs()) {
00257                 setX1Ccs(getStartXCcs() - getWidthCcs());
00258             }
00259             if (getY1Ccs() != getStartYCcs()) {
00260                 setY1Ccs(getStartYCcs() - getHeightCcs());
00261             }
00262 
00263             transformCCStoICS();
00264         }
00265 
00266         return (retval);
00267     }


Member Data Documentation

boolean CanvasRectangle::square = false [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