Inheritance diagram for CanvasFigure::
Public Methods | |
Object | clone () |
Implements CanvasObject abstract function. More... | |
void | draw (Graphics g) |
Implements CanvasObject "interface". More... | |
boolean | isHitCcs (int x, int y, Graphics2D g) |
A more specialized version of isHitCcs that uses the Graphics2d.hit and the getShape() member function to determine if this figures is selected with the given position. More... | |
boolean | hasNoColor () |
Color | getColor () |
void | setColor (Color newColor) |
boolean | getFilled () |
void | setFilled (boolean filled) |
boolean | getDashed () |
void | setDashed (boolean dashed) |
boolean | hasLineWidth () |
float | getLineWidth () |
void | setLineWidth (float linew) |
float | getTransparency () |
void | setTransparency (float trans) |
Vector | getVisualChangeMethods () |
Builds up a list of functions that are to fill a menu for changing the visualization aspects of an object. More... | |
Static Public Attributes | |
final int | NO_PIX = 0x00000000 |
Indicates that no pixel value is set. More... | |
final int | INV_PIX = 0x00FFFFFF |
Invert pixel via : c.getRGB() ^ INV_COLOR. More... | |
final Color | NO_COLOR = (Color) null |
No color specified. More... | |
final Color | DEF_COLOR = Color.red |
The default color for drawing figures. More... | |
final float | DEF_LINEW = 1.0f |
The default line width for figures. More... | |
final float | DEF_TRANS = 0.0f |
The default transparency for figures. More... | |
Protected Methods | |
CanvasFigure (double x1, double y1, double x2, double y2) | |
abstract Shape | getShape () |
Derived classes have to implement this method to supply the shape that represents the CanvasFigures. More... | |
abstract boolean | hitOnStroke () |
Derived classes have to implement this method to indicate whether they are selected (hit) based on their stroke (border) or on their interior. More... | |
void | setupDrawMode (Graphics g) |
Setup drawmode for 'g'. More... |
|
00044 { 00045 super(x1, y1, x2, y2); 00046 } |
|
Implements CanvasObject abstract function. This side of the tree is not clonable, nor need it be? Reimplemented from CanvasObject.
00053 { 00054 return null; 00055 } |
|
Implements CanvasObject "interface".
Reimplemented from CanvasObject. Reimplemented in CanvasHxBlob2d, and CanvasCorbaBlob2d.
00061 { 00062 setupDrawMode(g); 00063 if (g instanceof Graphics2D) { 00064 Graphics2D g2d = (Graphics2D) g; 00065 if (_filled) 00066 g2d.fill(getShape()); 00067 else 00068 g2d.draw(getShape()); 00069 } else { 00070 ErrorStreamArea.println("CanvasFigure: draw needs Graphics2d."); 00071 } 00072 } |
|
A more specialized version of isHitCcs that uses the Graphics2d.hit and the getShape() member function to determine if this figures is selected with the given position. Uses hitOnStroke to choose between hit on stroke or hit on interior. Reimplemented from CanvasObject.
00081 { 00082 int spere = CanvasObject.SPHERE; 00083 if (! hitOnStroke()) 00084 spere = 1; 00085 Rectangle r = new Rectangle(x - spere, y - spere, 2 * spere, 2 * spere); 00086 return g.hit(r, getShape(), hitOnStroke()); 00087 } |
|
00091 { 00092 return _hasNoColor; 00093 } |
|
00097 { 00098 return _drawColor; 00099 } |
|
Reimplemented in CanvasHxBlob2d, and CanvasCorbaBlob2d.
|
|
00115 { 00116 return _filled; 00117 } |
|
00121 { 00122 _filled = filled; 00123 } |
|
00127 { 00128 return _dashed; 00129 } |
|
00133 { 00134 if (_hasLineWidth) // no dash without a linewidth 00135 _dashed = dashed; 00136 } |
|
00140 { 00141 return _hasLineWidth; 00142 } |
|
00146 { 00147 return _lineWidth; 00148 } |
|
|
|
00163 { 00164 return _transparency; 00165 } |
|
Reimplemented in CanvasHxBlob2d, and CanvasCorbaBlob2d.
00169 { 00170 if (trans < 0.0f) { 00171 trans = 0.0f; 00172 } else if (trans > 1.0f) { 00173 trans = 1.0f; 00174 } 00175 _transparency = trans; 00176 } |
|
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 CanvasHxBlob2d, CanvasHxBSplineCurve, CanvasHxSampledBSplineCurve, CanvasCorbaBlob2d, CanvasCorbaBSplineCurve, and CanvasCorbaSampledBSplineCurve.
00183 { 00184 Vector v = super.getVisualChangeMethods(); 00185 v.add(new CallableMethod("setColor", "Color", "c", "Color")); 00186 v.add(new CallableMethod("setFilled", "boolean", "b", "boolean")); 00187 v.add(new CallableMethod("setDashed", "boolean", "b", "boolean")); 00188 v.add(new CallableMethod("setLineWidth", "float", "w", "float")); 00189 v.add(new CallableMethod("setTransparency", "float", "t", "float")); 00190 return v; 00191 } |
|
Derived classes have to implement this method to supply the shape that represents the CanvasFigures. It is used to draw to figure as well as determine which figure is selected (hit) by the cursor within a canvas. Reimplemented in CanvasHxBlob2d, CanvasHxBSplineCurve, CanvasHxHistogram, CanvasHxPolyline2d, CanvasHxSampledBSplineCurve, CanvasCorbaBlob2d, CanvasCorbaBSplineCurve, CanvasCorbaHistogram, CanvasCorbaPolyline2d, and CanvasCorbaSampledBSplineCurve. |
|
Derived classes have to implement this method to indicate whether they are selected (hit) based on their stroke (border) or on their interior.
Reimplemented in CanvasHxBlob2d, CanvasHxBSplineCurve, CanvasHxHistogram, CanvasHxPolyline2d, CanvasHxSampledBSplineCurve, CanvasCorbaBlob2d, CanvasCorbaBSplineCurve, CanvasCorbaHistogram, CanvasCorbaPolyline2d, and CanvasCorbaSampledBSplineCurve. |
|
Setup drawmode for 'g'.
Reimplemented from CanvasObject.
00217 { 00218 if (g instanceof Graphics2D) { 00219 00220 Graphics2D g2d = (Graphics2D) g; 00221 switch (getDrawMode()) { 00222 case COPY_MODE : 00223 g2d.setPaintMode(); 00224 g2d.setComposite(AlphaComposite.getInstance( 00225 AlphaComposite.SRC_OVER, 1.0f - _transparency)); 00226 if (_drawColor != null) { 00227 g2d.setColor(_drawColor); 00228 } 00229 break; 00230 00231 case XOR_MODE : 00232 g2d.setXORMode(XOR_COLOR); 00233 g2d.setColor(DEF_COLOR); 00234 g2d.setComposite(AlphaComposite.getInstance( 00235 AlphaComposite.SRC_OVER, 1.0f)); 00236 g2d.setStroke(new BasicStroke()); 00237 return; 00238 } 00239 00240 float lwidth; 00241 00242 if (_hasLineWidth) { 00243 lwidth = _lineWidth; 00244 } else { 00245 lwidth = DEF_LINEW; 00246 } 00247 00248 float[] dash = { 6.f }; 00249 if (!(_dashed && _hasLineWidth)) { 00250 dash = null; 00251 } 00252 g2d.setStroke(new BasicStroke(lwidth, 00253 BasicStroke.CAP_BUTT, 00254 BasicStroke.JOIN_MITER, 00255 10.f, dash, 0.f)); 00256 } else { // We have a "normal" graphics 00257 super.setupDrawMode(g); 00258 if (getDrawMode() == XOR_MODE) { 00259 g.setColor(DEF_COLOR); 00260 } else { 00261 g.setColor(_drawColor); 00262 } 00263 } 00264 } |
|
Indicates that no pixel value is set.
|
|
Invert pixel via : c.getRGB() ^ INV_COLOR.
|
|
No color specified.
|
|
The default color for drawing figures.
|
|
The default line width for figures.
|
|
The default transparency for figures.
|