Inheritance diagram for CanvasObject::
Public Methods | |
CanvasObject (double x1, double y1, double x2, double y2) | |
Create CanvasObject with top-left corner of bounding box at position (x1, y1), and bottom-right corner at position (x2, y2). More... | |
CanvasObject (double x1, double y1, double x2, double y2, int mode) | |
Create CanvasObject with top-left corner of bounding box at position (x1, y1), and bottom-right corner at position (x2, y2). More... | |
CanvasObject (double x1, double y1, double x2, double y2, int mode, double zoomFactor) | |
Create CanvasObject with top-left corner of bounding box at position (x1, y1), and bottom-right corner at position (x2, y2). More... | |
abstract void | draw (Graphics g) |
Draw CanvasObject on 'g', using internal CCS values. More... | |
abstract Object | clone () |
Return an identical copy of this CanvasObject. More... | |
boolean | inBoundingBox (double x, double y) |
Check if given position is inside CanvasObject's bounding box. More... | |
double | getX1 () |
Return x-value of upper left corner of CanvasObject's bounding box. More... | |
double | getY1 () |
Return y-value of upper left corner of CanvasObject's bounding box. More... | |
double | getX2 () |
Return x-value of lower right corner of CanvasObject's bounding box. More... | |
double | getY2 () |
Return y-value of lower right corner of CanvasObject's bounding box. More... | |
double | getWidth () |
Return width of CanvasObject's bounding box, i.e. More... | |
double | getHeight () |
Return height of CanvasObject's bounding box, i.e. More... | |
int | getX1Pcs () |
Return x-value of upper left corner of CanvasObject's bounding box. More... | |
int | getY1Pcs () |
Return y-value of upper left corner of CanvasObject's bounding box. More... | |
int | getX2Pcs () |
Return x-value of lower right corner of CanvasObject's bounding box. More... | |
int | getY2Pcs () |
Return y-value of lower right corner of CanvasObject's bounding box. More... | |
int | getDrawMode () |
Return current draw-mode. More... | |
void | setDrawMode (int mode) |
Set current draw-mode. More... | |
double | getZoomFactor () |
Return current ICS to CCS zoom-factor. More... | |
void | setZoomFactor (double zoomFactor) |
Scale CanvasObject according to 'zoomFactor'. More... | |
int | getInputSource () |
Return input source, i.e. More... | |
void | setInputSource (int source) |
Set input source. More... | |
String | getSaName () |
Return name of the string addressable object (if valid). More... | |
boolean | getEditable () |
Return whether the object is editable at this moment, i.e. More... | |
void | setEditable (boolean edit) |
Set whether the object is editable at this moment, i.e. More... | |
Vector | getVisualChangeMethods () |
Builds up a list of functions that are to fill a menu for changing the visualization aspects of an object. More... | |
CanvasObject (int x1, int y1, int x2, int y2, int mode, double zoomFactor) | |
To be removed. More... | |
boolean | isInsideCcs (int x, int y) |
To be removed. More... | |
boolean | isNearCcs (int x, int y) |
To be removed. More... | |
boolean | isHitCcs (int x, int y) |
Checks whether this object is selected (hit) based on the bounding box. More... | |
boolean | isHitCcs (int x, int y, Graphics2D g) |
Interface for a more specialized version of isHitCcs for CanvasFigures. More... | |
boolean | inBoundingBoxCcs (int x, int y) |
int | getX1Ccs () |
int | getY1Ccs () |
int | getX2Ccs () |
int | getY2Ccs () |
int | getWidthCcs () |
int | getHeightCcs () |
int | getStartXCcs () |
int | getStartYCcs () |
Dimension | getDimensionCcs () |
void | dump () |
Static Public Attributes | |
final int | INP_USER = 0 |
The user created the object. More... | |
final int | INP_SASYSTEM = 1 |
Some other source created the object. More... | |
final int | INP_CORBA = 1 |
final int | COPY_MODE = 0 |
Copy draw mode. More... | |
final int | XOR_MODE = 1 |
Xor draw mode. More... | |
final Color | XOR_COLOR = Color.cyan |
Xor draw color. More... | |
final int | SPHERE = 3 |
Influence region for isHit. More... | |
final double | DEF_SCALE = 1.0f |
Default scale factor. More... | |
boolean | DEBUG_OBJECTS = false |
Protected Methods | |
void | doInit (double x1, double y1, double x2, double y2, int mode, double zoomFactor) |
Initialize CanvasObject. More... | |
void | setX1 (double x) |
void | setY1 (double y) |
void | setX2 (double x) |
void | setY2 (double y) |
void | setWidth (double w) |
void | setHeight (double h) |
double | getStartX () |
void | setStartX (double x) |
double | getStartY () |
void | setStartY (double y) |
void | setX1Ccs (int x) |
void | setY1Ccs (int y) |
void | setX2Ccs (int x) |
void | setY2Ccs (int y) |
void | setWidthCcs (int w) |
void | setHeightCcs (int h) |
void | setStartXCcs (int x) |
void | setStartYCcs (int y) |
void | setupDrawMode (Graphics g) |
Setup drawmode for 'g'. More... | |
boolean | getTransformOK () |
void | setTransformOK (boolean ok) |
void | transformICStoCCS () |
Perform a full ICS to CCS coordinate transformation. More... | |
void | transformCCStoICS () |
Perform a full CCS to ICS coordinate transformation. More... | |
void | setAdditionalPoints (double[] xCoords, double[] yCoords) |
Set additional points in ICS that will be sync-ed with coordinate transformations. More... | |
int[] | getAddXCcs () |
This function returns a reference (!) to the array of x-coordinates in CCS of the additional points specified by extensions of this class. More... | |
int[] | getAddYCcs () |
This function returns a reference (!) to the array of y-coordinates in CCS of the additional points specified by extensions of this class. More... |
There are two subclasses of objects that can be visualized: bitmap (or raster) images (specializations of CanvasImage) and vector (or line) graphics (specialization of CanvasFigure). The two types of objects differ in the way their internal data is stored, and how it is interpreted to visually represent it on screen. The common behaviour of the objects is combined in this class.
CanvasObjects may originate from different sources. The source is indicated by getInputSource. For now, the sources are the scribbles of the user in the editor and visualizations of string addressable objects. The latter are not editable while the former are, of course. However, editing of scribble objects can be disabled temporarily via the setEditable method.
A CanvasObject defines the smallest bounding box of a visualizable object. The upper left corner of the box in denoted by (X1, Y1) and the lower right corner is denoted by (X1, Y2). These coordinates are stored both in ICS and in CCS format. Subclasses may provide additional coordinates that will be maintained in both formats by CanvasObject via setAdditionalPoints.
Hit Draw Shape VisualChangeSupport
|
Create CanvasObject with top-left corner of bounding box at position (x1, y1), and bottom-right corner at position (x2, y2). Parameters are assumed Image Coordinate System values.
|
|
Create CanvasObject with top-left corner of bounding box at position (x1, y1), and bottom-right corner at position (x2, y2). Parameters are assumed Image Coordinate System values.
|
|
Create CanvasObject with top-left corner of bounding box at position (x1, y1), and bottom-right corner at position (x2, y2). Parameters are assumed Image Coordinate System values.
00101 { 00102 doInit(x1, y1, x2, y2, mode, zoomFactor); 00103 } |
|
To be removed.
|
|
Draw CanvasObject on 'g', using internal CCS values.
Reimplemented in CanvasArrow, CanvasArrowGrid, CanvasBlob, CanvasChain, CanvasColoredPolyline, CanvasFigure, CanvasFigureAggregate, CanvasHxBlob2d, CanvasHxHistogram3d, CanvasHxImage, CanvasHxImageLarge, CanvasJavaImage, CanvasLine, CanvasMask, CanvasOval, CanvasPoint, CanvasPolyline, CanvasRectangle, CanvasString, CanvasCorbaBlob2d, CanvasCorbaImage, and CanvasCorbaSequence. |
|
Return an identical copy of this CanvasObject.
Reimplemented in CanvasArrow, CanvasArrowGrid, CanvasBlob, CanvasChain, CanvasColoredPolyline, CanvasFigure, CanvasFigureAggregate, CanvasImage, CanvasLine, CanvasMask, CanvasOval, CanvasPoint, CanvasPolyline, CanvasRectangle, and CanvasString. |
|
Check if given position is inside CanvasObject's bounding box. Parameters are assumed Image Coordinate System values.
00120 { 00121 if ((x >= _ics[X1]) && (x < _ics[X2]) && 00122 (y >= _ics[Y1]) && (y < _ics[Y2])) { 00123 return true; 00124 } 00125 return false; 00126 } |
|
Return x-value of upper left corner of CanvasObject's bounding box. Returned value represents the Image Coordinate System value.
00133 { 00134 return _ics[X1]; 00135 } |
|
Return y-value of upper left corner of CanvasObject's bounding box. Returned value represents the Image Coordinate System value.
00142 { 00143 return _ics[Y1]; 00144 } |
|
Return x-value of lower right corner of CanvasObject's bounding box. Returned value represents the Image Coordinate System value.
00151 { 00152 return _ics[X2]; 00153 } |
|
Return y-value of lower right corner of CanvasObject's bounding box. Returned value represents the Image Coordinate System value.
00160 { 00161 return _ics[Y2]; 00162 } |
|
Return width of CanvasObject's bounding box, i.e. X2 - X1. Returned value represents the Image Coordinate System value.
00169 { 00170 return _ics[X2] - _ics[X1]; 00171 } |
|
Return height of CanvasObject's bounding box, i.e. Y2 - Y1. Returned value represents the Image Coordinate System value.
00178 { 00179 return _ics[Y2] - _ics[Y1]; 00180 } |
|
Return x-value of upper left corner of CanvasObject's bounding box. Returned value represents the Pixel Coordinate System value.
00187 { 00188 return Converter.ICStoPCS(_ics[X1], false); 00189 } |
|
Return y-value of upper left corner of CanvasObject's bounding box. Returned value represents the Pixel Coordinate System value.
00196 { 00197 return Converter.ICStoPCS(_ics[Y1], false); 00198 } |
|
Return x-value of lower right corner of CanvasObject's bounding box. Returned value represents the Pixel Coordinate System value. A small correction to the ICS value is made to ensure it falls within the bounding image box.
00207 { 00208 return Converter.ICStoPCS(_ics[X2], true); 00209 } |
|
Return y-value of lower right corner of CanvasObject's bounding box. Returned value represents the Pixel Coordinate System value. A small correction to the ICS value is made to ensure it falls within the bounding image box.
00218 { 00219 return Converter.ICStoPCS(_ics[Y2], true); 00220 } |
|
Return current draw-mode.
00226 { 00227 return _drawMode; 00228 } |
|
Set current draw-mode.
Reimplemented in CanvasBlob, and CanvasFigureAggregate.
|
|
Return current ICS to CCS zoom-factor.
00250 { 00251 return _zoomFactor; 00252 } |
|
Scale CanvasObject according to 'zoomFactor'. The internal ICS values are taken as base values to calculate the associated CCS values. Reimplemented in CanvasArrow, CanvasArrowGrid, CanvasBlob, CanvasFigureAggregate, and CanvasString.
00259 { 00260 _zoomFactor = zoomFactor; 00261 _transformOK = false; 00262 } |
|
Return input source, i.e. who/what created the object.
00268 { 00269 return _inputSource; 00270 } |
|
Set input source.
00276 { 00277 _inputSource = source; 00278 } |
|
Return name of the string addressable object (if valid).
Reimplemented in CanvasHxBlob2d, CanvasHxBSplineCurve, CanvasHxHistogram, CanvasHxImage, CanvasHxImageLarge, CanvasHxPolyline2d, and CanvasHxSampledBSplineCurve.
00284 { 00285 return new String("unknown"); 00286 } |
|
Return whether the object is editable at this moment, i.e. whether the object is selectable when moving, copying, reshaping, etc.
00293 { 00294 if (getInputSource() == INP_SASYSTEM) 00295 return false; 00296 return _editable; 00297 } |
|
Set whether the object is editable at this moment, i.e. whether the object is selectable when moving, copying, reshaping, etc.
00304 { 00305 _editable = edit; 00306 } |
|
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 in CanvasArrow, CanvasBlob, CanvasFigure, CanvasHxBlob2d, CanvasHxBSplineCurve, CanvasHxImage, CanvasHxImageLarge, CanvasHxSampledBSplineCurve, CanvasPolyline, ScribbleFigure, CanvasCorbaBlob2d, CanvasCorbaBSplineCurve, CanvasCorbaImage, and CanvasCorbaSampledBSplineCurve.
00316 { 00317 Vector v = new Vector(); 00318 v.add(new CallableMethod("setEditable", "boolean", "b", "boolean")); 00319 return v; 00320 } |
|
To be removed.
Reimplemented in CanvasArrow, CanvasArrowGrid, CanvasBlob, CanvasChain, CanvasFigureAggregate, CanvasImage, CanvasLine, CanvasMask, CanvasOval, CanvasPoint, CanvasPolyline, CanvasRectangle, and CanvasString.
00351 { 00352 return false; 00353 } |
|
To be removed.
Reimplemented in CanvasArrow, CanvasArrowGrid, CanvasBlob, CanvasChain, CanvasFigureAggregate, CanvasImage, CanvasLine, CanvasMask, CanvasOval, CanvasPoint, CanvasPolyline, CanvasRectangle, and CanvasString.
00359 { 00360 return false; 00361 } |
|
Checks whether this object is selected (hit) based on the bounding box.
00367 { 00368 return inBoundingBoxCcs(x, y); 00369 } |
|
Interface for a more specialized version of isHitCcs for CanvasFigures. The default implementation is the same as isHitCcs(int x, int y) but CanvasFigure provides a more accurate version based on the figures shape. Reimplemented in CanvasFigure.
00377 { 00378 return isHitCcs(x, y); 00379 } |
|
00383 { 00384 if (!_transformOK) 00385 transformICStoCCS(); 00386 if ((x >= _ccs[X1]) && (x <= _ccs[X2]) && 00387 (y >= _ccs[Y1]) && (y <= _ccs[Y2])) { 00388 return true; 00389 } 00390 return false; 00391 } |
|
00395 { 00396 if (!_transformOK) 00397 transformICStoCCS(); 00398 return _ccs[X1]; 00399 } |
|
00403 { 00404 if (!_transformOK) 00405 transformICStoCCS(); 00406 return _ccs[Y1]; 00407 } |
|
00411 { 00412 if (!_transformOK) 00413 transformICStoCCS(); 00414 return _ccs[X2]; 00415 } |
|
00419 { 00420 if (!_transformOK) 00421 transformICStoCCS(); 00422 return _ccs[Y2]; 00423 } |
|
00427 { 00428 if (!_transformOK) 00429 transformICStoCCS(); 00430 return _ccs[X2] - _ccs[X1]; 00431 } |
|
00435 { 00436 if (!_transformOK) 00437 transformICStoCCS(); 00438 return _ccs[Y2] - _ccs[Y1]; 00439 } |
|
00443 { 00444 if (!_transformOK) 00445 transformICStoCCS(); 00446 return _ccs[SX]; 00447 } |
|
00451 { 00452 if (!_transformOK) 00453 transformICStoCCS(); 00454 return _ccs[SY]; 00455 } |
|
00459 { 00460 if (!_transformOK) 00461 transformICStoCCS(); 00462 return new Dimension(getWidthCcs(), getHeightCcs()); 00463 } |
|
00467 { 00468 if (!_transformOK) 00469 transformICStoCCS(); 00470 OutputStreamArea.println("dump CanvasObject"); 00471 OutputStreamArea.println(" ICS: x1: " + _ics[X1] + ", y1: " + _ics[Y1] + 00472 ", w: " + getWidth() + ", h: " + getHeight() + 00473 ", x2: " + _ics[X2] + ", y2: " + _ics[Y2]); 00474 OutputStreamArea.println(" PCS: x1: " + getX1Pcs() + ", y1: " + getY1Pcs() + 00475 ", x2: " + getX2Pcs() + ", y2: " + getY2Pcs()); 00476 OutputStreamArea.println(" CCS: x1: " + _ccs[X1] + ", y1: " + _ccs[Y1] + 00477 ", w: " + getWidthCcs() + ", h: " + getHeightCcs() + 00478 ", x2: " + _ccs[X2] + ", y2: " + _ccs[Y2]); 00479 /* 00480 if (_addXIcs == null) 00481 return; 00482 for (int i=0 ; i<_addXIcs.length ; i++) 00483 OutputStreamArea.println(" addIcs: " + _addXIcs[i] + ", " + _addYIcs[i]); 00484 */ 00485 } |
|
Initialize CanvasObject.
00499 { 00500 setDrawMode(mode); 00501 00502 _zoomFactor = zoomFactor; 00503 _ics[X1] = x1; 00504 _ics[Y1] = y1; 00505 _ics[X2] = x2; 00506 _ics[Y2] = y2; 00507 _ics[SX] = x1; 00508 _ics[SY] = y1; 00509 00510 transformICStoCCS(); 00511 } |
|
00515 { 00516 _ics[X1] = x; 00517 } |
|
00521 { 00522 _ics[Y1] = y; 00523 } |
|
00527 { 00528 _ics[X2] = x; 00529 } |
|
00533 { 00534 _ics[Y2] = y; 00535 } |
|
00541 { 00542 _ics[X2] = _ics[X1] + w; 00543 } |
|
00549 { 00550 _ics[Y2] = _ics[Y1] + h; 00551 } |
|
00555 { 00556 return _ics[SX]; 00557 } |
|
00561 { 00562 _ics[SX] = x; 00563 } |
|
00567 { 00568 return _ics[SY]; 00569 } |
|
00573 { 00574 _ics[SY] = y; 00575 } |
|
00579 { 00580 _ccs[X1] = x; 00581 } |
|
00585 { 00586 _ccs[Y1] = y; 00587 } |
|
00591 { 00592 _ccs[X2] = x; 00593 } |
|
00597 { 00598 _ccs[Y2] = y; 00599 } |
|
00605 { 00606 _ccs[X2] = _ccs[X1] + w; 00607 } |
|
00613 { 00614 _ccs[Y2] = _ccs[Y1] + h; 00615 } |
|
00619 { 00620 _ccs[SX] = x; 00621 } |
|
00625 { 00626 _ccs[SY] = y; 00627 } |
|
Setup drawmode for 'g'.
Reimplemented in CanvasFigure, and ScribbleFigure.
00633 { 00634 if (g == null) 00635 OutputStreamArea.println("........g == null"); 00636 switch (this._drawMode) { 00637 case COPY_MODE : g.setPaintMode(); 00638 break; 00639 00640 case XOR_MODE : g.setXORMode(XOR_COLOR); 00641 break; 00642 00643 default : break; 00644 } 00645 } |
|
00649 { 00650 return _transformOK; 00651 } |
|
00655 { 00656 _transformOK = ok; 00657 } |
|
Perform a full ICS to CCS coordinate transformation.
Reimplemented in CanvasArrow, CanvasArrowGrid, CanvasChain, CanvasColoredPolyline, CanvasLine, and CanvasPolyline.
|
|
Perform a full CCS to ICS coordinate transformation. This function is used only for scribbled objects. Reimplemented in CanvasArrowGrid, CanvasColoredPolyline, CanvasLine, and CanvasPolyline.
|
|
Set additional points in ICS that will be sync-ed with coordinate transformations. Warning: the references to the arrays given will be stored.
00691 { 00692 _addXIcs = xCoords; 00693 _addYIcs = yCoords; 00694 _addXCcs = new int[_addXIcs.length]; 00695 _addYCcs = new int[_addYIcs.length]; 00696 _transformOK = false; 00697 } |
|
This function returns a reference (!) to the array of x-coordinates in CCS of the additional points specified by extensions of this class.
00704 { 00705 if (!_transformOK) 00706 transformICStoCCS(); 00707 return _addXCcs; 00708 } |
|
This function returns a reference (!) to the array of y-coordinates in CCS of the additional points specified by extensions of this class.
00715 { 00716 if (!_transformOK) 00717 transformICStoCCS(); 00718 return _addYCcs; 00719 } |
|
The user created the object.
|
|
Some other source created the object.
|
|
|
|
Copy draw mode.
|
|
Xor draw mode.
|
|
Xor draw color.
|
|
Influence region for isHit.
|
|
Default scale factor.
|
|
|