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

ScribbleFigure Class Reference

Inheritance diagram for ScribbleFigure::

ScribbleObject CanvasObject CanvasArrow CanvasArrowGrid CanvasBlob CanvasChain CanvasFigureAggregate CanvasLine CanvasMask CanvasOval CanvasPoint CanvasPolyline CanvasRectangle CanvasString List of all members.

Public Methods

void addPoint (double x, double y)
boolean removePoint (int index)
boolean removeLastPoint ()
boolean hasNoColor ()
Color getColor ()
void setColor (Color newColor)
boolean getStroke ()
void setStroke (boolean stroke)
boolean hasLineWidth ()
float getLineWidth ()
void setLineWidth (float linew)
float getTransparency ()
void setTransparency (float trans)
boolean isComplex ()
boolean isResizeable ()
Vector getVisualChangeMethods ()
 Builds up a list of functions that are to fill a menu for changing the visualization aspects of an object. More...

 ScribbleFigure (int x, int y, int w, int h, int mode, Color color, double ccs_scale)
 ScribbleFigure (int x, int y, int w, int h, int mode, Color color, boolean complex, double ccs_scale)
int changePoint (int index, int x, int y)
void addPoint (int x, int y)

Static Public Attributes

final Color NO_COLOR = (Color)null
final Color DEF_COLOR = Color.red
final float DEF_LINEW = 1.0f
final float DEF_TRANS = 1.0f

Protected Methods

void initFigure (Color color, boolean stroke, float linew, float trans, boolean complex)
void setupDrawMode (Graphics g)
 Setup drawmode for 'g'. More...

void setComplex (boolean complex)

Protected Attributes

boolean complex = false
boolean resizeable = true
boolean strokeSet = false
boolean hasLineWidth = true
boolean hasNoColor = true
Color drawColor = NO_COLOR
float lineWidth = DEF_LINEW
float transparency = DEF_TRANS

Constructor & Destructor Documentation

ScribbleFigure::ScribbleFigure int    x,
int    y,
int    w,
int    h,
int    mode,
Color    color,
double    ccs_scale
[inline]
 

00236     {
00237         super(x, y, w, h, mode, ccs_scale);
00238         initFigure(color, false, DEF_LINEW, DEF_TRANS, false);
00239     }

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

00244     {
00245         super(x, y, w, h, mode, ccs_scale);
00246         initFigure(color, false, DEF_LINEW, DEF_TRANS, complex);
00247     }


Member Function Documentation

void ScribbleFigure::addPoint double    x,
double    y
[inline]
 

Reimplemented in CanvasPolyline.

00089     {
00090         // Implement this method in case of a complex figure
00091         // (such as: Polygon, Polyline, etc.)
00092     }

boolean ScribbleFigure::removePoint int    index [inline]
 

Reimplemented in CanvasColoredPolyline, and CanvasPolyline.

00096     {
00097         // Implement this method in case of a complex figure
00098         // (such as: Polygon, Polyline, etc.)
00099 
00100         return false;
00101     }

boolean ScribbleFigure::removeLastPoint   [inline]
 

Reimplemented in CanvasPolyline.

00105     {
00106         // Implement this method in case of a complex figure
00107         // (such as: Polygon, Polyline, etc.)
00108 
00109         return false;
00110     }

boolean ScribbleFigure::hasNoColor   [inline]
 

00114     {
00115         return hasNoColor;
00116     }

Color ScribbleFigure::getColor   [inline]
 

00120     {
00121         return drawColor;
00122     }

void ScribbleFigure::setColor Color    newColor [inline]
 

Reimplemented in CanvasBlob, CanvasChain, CanvasColoredPolyline, CanvasFigureAggregate, and CanvasMask.

00126     {
00127         if (newColor == NO_COLOR) {
00128             drawColor  = DEF_COLOR;
00129             hasNoColor = true;
00130         } else {
00131             drawColor  = newColor;
00132             hasNoColor = false;
00133         }
00134     }

boolean ScribbleFigure::getStroke   [inline]
 

00138     {
00139         return strokeSet;
00140     }

void ScribbleFigure::setStroke boolean    stroke [inline]
 

Reimplemented in CanvasFigureAggregate.

00144     {
00145         if (hasLineWidth) {         // no stroke without a linewidth
00146             strokeSet = stroke;
00147         }
00148     }

boolean ScribbleFigure::hasLineWidth   [inline]
 

00152     {
00153         return hasLineWidth;
00154     }

float ScribbleFigure::getLineWidth   [inline]
 

00158     {
00159         return lineWidth;
00160     }

void ScribbleFigure::setLineWidth float    linew [inline]
 

Reimplemented in CanvasFigureAggregate.

00164     {
00165         if (hasLineWidth) {
00166             if (linew < DEF_LINEW) {
00167                 linew = DEF_LINEW;
00168             }
00169             lineWidth = linew;
00170         }
00171     }

float ScribbleFigure::getTransparency   [inline]
 

00175     {
00176         return transparency;
00177     }

void ScribbleFigure::setTransparency float    trans [inline]
 

Reimplemented in CanvasBlob, CanvasFigureAggregate, and CanvasMask.

00181     {
00182         if (trans < 0.0f) {
00183             trans = 0.0f;
00184         } else if (trans > DEF_TRANS) {
00185             trans = DEF_TRANS;
00186         }
00187         transparency = trans;
00188     }

boolean ScribbleFigure::isComplex   [inline]
 

00192     {
00193         return complex;
00194     }

boolean ScribbleFigure::isResizeable   [inline]
 

00198     {
00199         return resizeable;
00200     }

Vector ScribbleFigure::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 CanvasObject.

Reimplemented in CanvasArrow, CanvasBlob, and CanvasPolyline.

00207     {
00208         Vector v = super.getVisualChangeMethods();
00209         //v.add(new CallableMethod("setColor", "Color", "c", "Color"));
00210         //v.add(new CallableMethod("setStroke", "boolean", "b", "boolean"));
00211         //v.add(new CallableMethod("setLineWidth", "float", "w", "float"));
00212         v.add(new CallableProperty("color", "setColor", "Color", drawColor));
00213         v.add(new CallableProperty("stroke", "setStroke", "boolean", new Boolean(strokeSet)));
00214         v.add(new CallableProperty("line width", "setLineWidth", "float", new Float(lineWidth)));
00215         v.add(new CallableMethod("setTransparency", "float", "t", "float"));
00216         return v;
00217     }

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

Reimplemented in CanvasArrow, CanvasBlob, CanvasChain, CanvasLine, CanvasMask, CanvasOval, CanvasPolyline, and CanvasRectangle.

00269     {
00270         if (!getTransformOK()) {
00271             transformICStoCCS();
00272         }
00273 
00274         int xval = 0;
00275         int yval = 0;
00276         setStartXCcs(getX1Ccs());
00277         setStartYCcs(getY1Ccs());
00278 
00279         switch (index) {
00280             case 0  : setStartXCcs(getStartXCcs() + getWidthCcs());
00281                       setStartYCcs(getStartYCcs() + getHeightCcs());
00282                       if (x > getX1Ccs() + getWidthCcs()) {
00283                           xval = 1;
00284                       }
00285                       if (y > getY1Ccs() + getHeightCcs()) {
00286                           yval = 2;
00287                       }
00288                       break;
00289             case 1  : setStartYCcs(getStartYCcs() + getHeightCcs());
00290                       if (x < getX1Ccs()) {
00291                           xval = -1;
00292                       }
00293                       if (y > getY1Ccs() + getHeightCcs()) {
00294                           yval = 2;
00295                       }
00296                       break;
00297             case 2  : setStartXCcs(getStartXCcs() + getWidthCcs());
00298                       if (x > getX1Ccs() + getWidthCcs()) {
00299                           xval = 1;
00300                       }
00301                       if (y < getY1Ccs()) {
00302                           yval = -2;
00303                       }
00304                       break;
00305             case 3  : if (x < getX1Ccs()) {
00306                           xval = -1;
00307                       }
00308                       if (y < getY1Ccs()) {
00309                           yval = -2;
00310                       }
00311                       break;
00312             default : return -1;
00313         }
00314 
00315         setDimension(x-getStartXCcs(), y-getStartYCcs());
00316         return (xval + yval + index);
00317     }

void ScribbleFigure::addPoint int    x,
int    y
[inline]
 

Reimplemented in CanvasPolyline.

00321     {
00322         // Implement this method in case of a complex figure
00323         // (such as: Polygon, Polyline, etc.)
00324     }

void ScribbleFigure::initFigure Color    color,
boolean    stroke,
float    linew,
float    trans,
boolean    complex
[inline, protected]
 

00339     {
00340         setComplex(complex);
00341         setColor(color);
00342         setStroke(stroke);
00343         setLineWidth(linew);
00344         setTransparency(trans);
00345     }

void ScribbleFigure::setupDrawMode Graphics    g [inline, protected]
 

Setup drawmode for 'g'.

Reimplemented from CanvasObject.

00349     {
00350         if (g instanceof Graphics2D) {
00351 
00352             Graphics2D g2d = (Graphics2D)g;
00353             switch (getDrawMode()) {
00354                 case COPY_MODE :
00355                         g2d.setPaintMode();
00356                         g2d.setComposite(AlphaComposite.getInstance(
00357                                AlphaComposite.SRC_OVER, transparency));
00358                         if (drawColor != null) {
00359                             g2d.setColor(drawColor);
00360                         }
00361                         break;
00362 
00363                 case XOR_MODE  :
00364                         g2d.setXORMode(XOR_COLOR);
00365                         g2d.setColor(DEF_COLOR);
00366                         g2d.setComposite(AlphaComposite.getInstance(
00367                                          AlphaComposite.SRC_OVER, 1.f));
00368                         g2d.setStroke(new BasicStroke());
00369                         return;
00370             }
00371 
00372             float lwidth;
00373 
00374             if (hasLineWidth) {
00375                 lwidth = lineWidth;
00376             } else {
00377                 lwidth = DEF_LINEW;
00378             }
00379 
00380             float[] dash = { 6.f };
00381             if (!(strokeSet && hasLineWidth)) {
00382                 dash = null;
00383             }
00384             g2d.setStroke(new BasicStroke(lwidth,
00385                                           BasicStroke.CAP_BUTT,
00386                                           BasicStroke.JOIN_MITER,
00387                                           10.f, dash, 0.f));
00388         } else {
00389             super.setupDrawMode(g);
00390             if (getDrawMode() == XOR_MODE) {
00391                 g.setColor(DEF_COLOR);
00392             } else {
00393                 g.setColor(drawColor);
00394             }
00395         }
00396     }

void ScribbleFigure::setComplex boolean    complex [inline, protected]
 

00400     {
00401         this.complex = complex;
00402     }


Member Data Documentation

final Color ScribbleFigure::NO_COLOR = (Color)null [static]
 

final Color ScribbleFigure::DEF_COLOR = Color.red [static]
 

final float ScribbleFigure::DEF_LINEW = 1.0f [static]
 

final float ScribbleFigure::DEF_TRANS = 1.0f [static]
 

boolean ScribbleFigure::complex = false [protected]
 

boolean ScribbleFigure::resizeable = true [protected]
 

boolean ScribbleFigure::strokeSet = false [protected]
 

boolean ScribbleFigure::hasLineWidth = true [protected]
 

boolean ScribbleFigure::hasNoColor = true [protected]
 

Color ScribbleFigure::drawColor = NO_COLOR [protected]
 

float ScribbleFigure::lineWidth = DEF_LINEW [protected]
 

float ScribbleFigure::transparency = DEF_TRANS [protected]
 


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