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

CanvasFigureAggregate Class Reference

Inheritance diagram for CanvasFigureAggregate::

ScribbleFigure ScribbleObject CanvasObject List of all members.

Public Methods

 CanvasFigureAggregate (ScribbleFigure[] figs)
 CanvasFigureAggregate (ScribbleFigure[] figs, int mode, Color color)
 CanvasFigureAggregate (Vector figs)
 CanvasFigureAggregate (Vector figs, int mode, Color color)
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)
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 newColor)
void setStroke (boolean stroke)
void setLineWidth (float linew)
void setTransparency (float trans)
void setDrawMode (int mode)
 Set current draw-mode. 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)

Protected Methods

void initAggregate (int mode, Color color)
void setFigures (ScribbleFigure[] figs)
void setFigures (Vector figs)
void setBox ()
boolean noneHaveColor ()

Protected Attributes

Vector figures = null

Constructor & Destructor Documentation

CanvasFigureAggregate::CanvasFigureAggregate ScribbleFigure    figs[] [inline]
 

00031     {
00032         this(figs, -1, NO_COLOR);
00033     }

CanvasFigureAggregate::CanvasFigureAggregate ScribbleFigure    figs[],
int    mode,
Color    color
[inline]
 

00038     {
00039         super(0., 0., 0., 0.);
00040         setFigures(figs);
00041         initAggregate(mode, color);
00042     }

CanvasFigureAggregate::CanvasFigureAggregate Vector    figs [inline]
 

00046     {
00047         this(figs, -1, NO_COLOR);
00048     }

CanvasFigureAggregate::CanvasFigureAggregate Vector    figs,
int    mode,
Color    color
[inline]
 

00052     {
00053         super(0., 0., 0., 0.);
00054         setFigures(figs);
00055         initAggregate(mode, color);
00056     }


Member Function Documentation

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

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

Reimplemented from CanvasObject.

00063     {
00064         if (figures != null) {
00065             if (!getTransformOK()) {
00066                 transformICStoCCS();
00067             }
00068             for (int i=0; i<figures.size(); i++) {
00069                 ((ScribbleFigure)figures.elementAt(i)).draw(g);
00070             }
00071         }
00072     }

Object CanvasFigureAggregate::clone   [inline, virtual]
 

Return an identical copy of this CanvasObject.

Reimplemented from CanvasObject.

00076     {
00077         Vector figs = (Vector)figures.clone();
00078         return (new CanvasFigureAggregate(figs));
00079     }

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

00083     {
00084         return (inBoundingBox(x, y));
00085     }

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

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

Parameters are assumed Image Coordinate System values.

Reimplemented from ScribbleObject.

00102     {
00103         if (figures != null) {
00104             ScribbleFigure cf;
00105             double w_scale = Math.abs(w)/getWidth();
00106             double h_scale = Math.abs(h)/getHeight();
00107             double d_w = 0;
00108             double d_h = 0;
00109 
00110             for (int i=0; i<figures.size(); i++) {
00111                 cf = ((ScribbleFigure)figures.elementAt(i));
00112                 d_w = (double)((cf.getX1()-getX1())*w_scale) - (cf.getX1()-getX1());
00113                 d_h = (double)((cf.getY1()-getY1())*h_scale) - (cf.getY1()-getY1());
00114 
00115                 cf.doMove(d_w, d_h);
00116                 cf.setDimension(cf.getWidth()*w_scale, cf.getHeight()*h_scale);
00117             }
00118             setBox();
00119         }
00120 
00121         if (w < 0. || h < 0.) {
00122             double move_w = 0.;
00123             double move_h = 0.;
00124 
00125             if (w < 0.) {
00126                 move_w = w;
00127             }
00128             if (h < 0.) {
00129                 move_h = h;
00130             }
00131             doMove(move_w, move_h);
00132         }
00133     }

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

00137     {
00138         if (figures != null) {
00139             super.setZoomFactor(zoomFactor);
00140             for (int i=0; i<figures.size(); i++) {
00141                 ((ScribbleFigure)figures.elementAt(i)).setZoomFactor(zoomFactor);
00142             }
00143             setBox();
00144         }
00145     }

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

00149     {
00150         if (figures != null) {
00151             super.setZoomFactor(zoomFactor);
00152             for (int i=0; i<figures.size(); i++) {
00153                 ((ScribbleFigure)figures.elementAt(i)).doPixelFit(zoomFactor);
00154             }
00155             setBox();
00156         }
00157     }

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

00161     {
00162         if (figures != null) {
00163             for (int i=0; i<figures.size(); i++) {
00164                 ((ScribbleFigure)figures.elementAt(i)).doMove(w, h);
00165             }
00166             setBox();
00167         }
00168     }

void CanvasFigureAggregate::setColor Color    newColor [inline]
 

Reimplemented from ScribbleFigure.

00172     {
00173         super.setColor(newColor);
00174 
00175         if (figures != null) {
00176             for (int i=0; i<figures.size(); i++) {
00177                 ((ScribbleFigure)figures.elementAt(i)).setColor(newColor);
00178             }
00179         }
00180     }

void CanvasFigureAggregate::setStroke boolean    stroke [inline]
 

Reimplemented from ScribbleFigure.

00184     {
00185         super.setStroke(stroke);
00186 
00187         if (figures != null) {
00188             for (int i=0; i<figures.size(); i++) {
00189                 ((ScribbleFigure)figures.elementAt(i)).setStroke(stroke);
00190             }
00191         }
00192     }

void CanvasFigureAggregate::setLineWidth float    linew [inline]
 

Reimplemented from ScribbleFigure.

00196     {
00197         super.setLineWidth(linew);
00198 
00199         if (figures != null) {
00200             for (int i=0; i<figures.size(); i++) {
00201                 ((ScribbleFigure)figures.elementAt(i)).setLineWidth(linew);
00202             }
00203         }
00204     }

void CanvasFigureAggregate::setTransparency float    trans [inline]
 

Reimplemented from ScribbleFigure.

00208     {
00209         super.setTransparency(trans);
00210 
00211         if (figures != null) {
00212             for (int i=0; i<figures.size(); i++) {
00213                 ((ScribbleFigure)figures.elementAt(i)).setTransparency(trans);
00214             }
00215         }
00216     }

void CanvasFigureAggregate::setDrawMode int    mode [inline]
 

Set current draw-mode.

Reimplemented from CanvasObject.

00220     {
00221         super.setDrawMode(mode);
00222 
00223         if (figures != null) {
00224             for (int i=0; i<figures.size(); i++) {
00225                 ((ScribbleFigure)figures.elementAt(i)).setDrawMode(mode);
00226             }
00227         }
00228     }

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

To be removed.

Reimplemented from CanvasObject.

00246     {
00247         return (inBoundingBoxCcs(x, y));
00248     }

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

To be removed.

Reimplemented from CanvasObject.

00252     {
00253         if (figures != null) {
00254             for (int i=0; i<figures.size(); i++) {
00255                 if (((ScribbleFigure)figures.elementAt(i)).isNearCcs(x, y)) {
00256                     return true;
00257                 }
00258             }
00259         }
00260         return false;
00261     }

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

Reimplemented from ScribbleObject.

00265     {
00266         if (!getTransformOK()) {
00267             transformICStoCCS();
00268         }
00269 
00270         if (figures != null) {
00271             ScribbleFigure cf;
00272             double w_scale = (double)(Math.abs(w))/(double)getWidthCcs();
00273             double h_scale = (double)(Math.abs(h))/(double)getHeightCcs();
00274             int d_w = 0;
00275             int d_h = 0;
00276 
00277             for (int i=0; i<figures.size(); i++) {
00278                 cf = ((ScribbleFigure)figures.elementAt(i));
00279                 d_w = (int)((cf.getX1Ccs()-getX1Ccs())*w_scale + 0.5) - (cf.getX1Ccs()-getX1Ccs());
00280                 d_h = (int)((cf.getY1Ccs()-getY1Ccs())*h_scale + 0.5) - (cf.getY1Ccs()-getY1Ccs());
00281 
00282                 cf.doMove(d_w, d_h);
00283                 cf.setDimension((int)(cf.getWidthCcs()*w_scale + 0.5),
00284                                 (int)(cf.getHeightCcs()*h_scale + 0.5));
00285             }
00286             setBox();
00287         }
00288 
00289         if (w < 0 || h < 0) {
00290             int move_w = 0;
00291             int move_h = 0;
00292 
00293             if (w < 0) {
00294                 move_w = w;
00295             }
00296             if (h < 0) {
00297                 move_h = h;
00298             }
00299             doMove(move_w, move_h);
00300         }
00301     }

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

Reimplemented from ScribbleObject.

00305     {
00306         if (figures != null) {
00307             for (int i=0; i<figures.size(); i++) {
00308                 ((ScribbleFigure)figures.elementAt(i)).doMove(w, h);
00309             }
00310             setBox();
00311         }
00312     }

void CanvasFigureAggregate::initAggregate int    mode,
Color    color
[inline, protected]
 

00326     {
00327         if (mode > -1) {
00328             setDrawMode(mode);
00329         }
00330         if (color == NO_COLOR) {
00331             if (noneHaveColor()) {
00332                 hasNoColor = true;
00333             } else {
00334                 hasNoColor = false;
00335             }
00336         } else {
00337             setColor(color);
00338         }
00339         setBox();
00340         transformICStoCCS();
00341     }

void CanvasFigureAggregate::setFigures ScribbleFigure    figs[] [inline, protected]
 

00345     {
00346         figures = new Vector(figs.length);
00347         for (int i=0; i<figs.length; i++) {
00348             figures.addElement(figs[i].clone());
00349             ScribbleFigure cf = (ScribbleFigure)figures.elementAt(i);
00350             if (cf instanceof CanvasOval) {
00351                 ((CanvasOval)cf).setCircle(false);
00352             }
00353             if (cf instanceof CanvasRectangle) {
00354                 ((CanvasRectangle)cf).setSquare(false);
00355             }
00356         }
00357     }

void CanvasFigureAggregate::setFigures Vector    figs [inline, protected]
 

00361     {
00362         figures = new Vector(figs.size());
00363         for (int i=0; i<figs.size(); i++) {
00364             ScribbleFigure cf = (ScribbleFigure)figs.elementAt(i);
00365             if (cf instanceof CanvasOval) {
00366                 ((CanvasOval)cf).setCircle(false);
00367             }
00368             if (cf instanceof CanvasRectangle) {
00369                 ((CanvasRectangle)cf).setSquare(false);
00370             }
00371             figures.addElement(cf.clone());
00372         }
00373     }

void CanvasFigureAggregate::setBox   [inline, protected]
 

00377     {
00378         double ics_maxX = 0.;
00379         double ics_maxY = 0.;
00380 
00381         setX1(Double.MAX_VALUE);
00382         setY1(Double.MAX_VALUE);
00383 
00384         ScribbleFigure fig;
00385 
00386         for (int i=0; i<figures.size(); i++) {
00387             fig = (ScribbleFigure)figures.elementAt(i);
00388 
00389             if (fig.getX1() < getX1()) {
00390                 setX1(fig.getX1());
00391             }
00392             if (fig.getY1() < getY1()) {
00393                 setY1(fig.getY1());
00394             }
00395             if (fig.getX1() + fig.getWidth() > ics_maxX) {
00396                 ics_maxX = fig.getX1() + fig.getWidth();
00397             }
00398             if (fig.getY1() + fig.getHeight() > ics_maxY) {
00399                 ics_maxY = fig.getY1() + fig.getHeight();
00400             }
00401         }
00402 
00403         setWidth(ics_maxX - getX1());
00404         setHeight(ics_maxY - getY1());
00405         setStartX(getX1());
00406         setStartY(getY1());
00407         setTransformOK(false);
00408     }

boolean CanvasFigureAggregate::noneHaveColor   [inline, protected]
 

00412     {
00413         if (figures != null) {
00414             for (int i=0; i<figures.size(); i++) {
00415                 if (!((ScribbleFigure)figures.elementAt(i)).hasNoColor()) {
00416                     return false;
00417                 }
00418             }
00419         }
00420         return true;
00421     }


Member Data Documentation

Vector CanvasFigureAggregate::figures = null [protected]
 


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