Inheritance diagram for CanvasArrow::

Public Methods | |
| CanvasArrow (double x, double y, double length, int angle) | |
| CanvasArrow (double x, double y, double length, int angle, Color color) | |
| CanvasArrow (double x, double y, double length, int angle, Color color, boolean fixed) | |
| CanvasArrow (double x, double y, double length, int angle, int mode, Color color, boolean stroke, float linew, float trans, boolean fixed, double ccs_scale) | |
| 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 | setPosition (double x, double y) |
| Place top left position of CanvasObject's bounding box at position (x, y). More... | |
| 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... | |
| double | getLength () |
| void | setLength (double length) |
| int | getAngle () |
| void | setAngle (int angle) |
| boolean | getFixed () |
| void | setFixed (boolean b) |
| boolean | getHeaded () |
| void | setHeaded (boolean b) |
| Vector | getVisualChangeMethods () |
| Builds up a list of functions that are to fill a menu for changing the visualization aspects of an object. More... | |
| CanvasArrow (int x, int y, int length, int angle, int mode, Color color, boolean fixed, double ccs_scale) | |
| boolean | isInsideCcs (int x, int y) |
| To be removed. More... | |
| boolean | isNearCcs (int x, int y) |
| To be removed. More... | |
| void | setPosition (int x, int y) |
| void | setDimension (int w, int h) |
| void | doMove (int w, int h) |
| int | changePoint (int index, int x, int y) |
| Point | getOrigin () |
| Point | getHead () |
Protected Methods | |
| void | initArrow (double x, double y, double length, int angle, boolean fixed) |
| void | setICS () |
| void | transformICStoCCS () |
| Perform a full ICS to CCS coordinate transformation. More... | |
| void | calcHead () |
| void | calcAngle (double w, double h) |
Protected Attributes | |
| double | ics_length |
| int | ccs_length |
| int | headX |
| int | headY |
| int | angle |
| int | beta |
| int | gamma |
| int | bx |
| int | by |
| int | gx |
| int | gy |
| double | cosa |
| double | sina |
| double | cosb |
| double | sinb |
| double | cosg |
| double | sing |
| boolean | fixed = false |
| boolean | headed = true |
| boolean | scaled = false |
Static Protected Attributes | |
| final int | HEAD_LENGTH = 6 |
| final int | HEAD_ANGLE = 20 |
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||
|
|
|
|
Draw CanvasObject on 'g', using internal CCS values.
Reimplemented from CanvasObject.
00072 {
00073 setupDrawMode(g);
00074 if (!getTransformOK()) {
00075 transformICStoCCS();
00076 }
00077 g.drawLine(getStartXCcs(), getStartYCcs(), headX, headY);
00078 if (headed) {
00079 g.drawLine(headX, headY, bx, by);
00080 g.drawLine(headX, headY, gx, gy);
00081 }
00082 }
|
|
|
Return an identical copy of this CanvasObject.
Reimplemented from CanvasObject.
00086 {
00087 Color color = drawColor;
00088 if (hasNoColor) {
00089 color = NO_COLOR;
00090 }
00091 CanvasArrow ca = new CanvasArrow(getStartX(), getStartY(),
00092 ics_length, angle, getDrawMode(),
00093 color, strokeSet, lineWidth,
00094 transparency, fixed, getZoomFactor());
00095 ca.setHeaded(headed);
00096 return ca;
00097 }
|
|
||||||||||||
|
00101 {
00102 return false;
00103 }
|
|
||||||||||||
|
00107 {
00108 // taken from 'Graphics Gems II' - James Arvo,
00109 // chap. 1.3, 'Distance from a point to a line', pages 10-13.
00110
00111
00112 // check if inside enlarged bounding box (== box + SPHERE)
00113
00114 if ((x >= getX1() - SPHERE) && (x < getX1() + getWidth() + SPHERE) &&
00115 (y >= getY1() - SPHERE) && (y < getY1() + getHeight() + SPHERE)) {
00116
00117
00118 // calculate the area of the triangle formed by the two
00119 // CanvasArrow points and the 'check' point
00120
00121 double area = (y - getStartY())*(headX - getStartX()) -
00122 (x - getStartX())*(headY - getStartY());
00123
00124
00125 // calculate approximation of distance perpendicular to
00126 // CanvasArrow
00127
00128 double abs1 = Math.abs(headX - getStartX());
00129 double abs2 = Math.abs(headY - getStartY());
00130
00131 int distance = (int)(Math.abs(area) /
00132 (abs1 + abs2 - 0.5 * Math.min(abs1, abs2)));
00133
00134
00135 // this approximation can also be used as an approximation
00136 // for the 'true' distance
00137
00138 if (distance <= SPHERE) {
00139 return true;
00140 }
00141 }
00142 return false;
00143 }
|
|
||||||||||||
|
Place top left position of CanvasObject's bounding box at position (x, y). Parameters are assumed Image Coordinate System values. Reimplemented from ScribbleObject.
|
|
||||||||||||
|
Resize CanvasObject to width 'w' and height 'h'. Parameters are assumed Image Coordinate System values. Reimplemented from ScribbleObject.
00153 {
00154 super.setDimension(w, h);
00155
00156 ics_length = (double)(Math.sqrt(w*w + h*h));
00157 calcAngle(w, h);
00158 setICS();
00159 }
|
|
|
Scale CanvasObject according to 'zoomFactor'. The internal ICS values are taken as base values to calculate the associated CCS values. Reimplemented from CanvasObject.
00163 {
00164 super.setZoomFactor(zoomFactor);
00165 scaled = true;
00166 }
|
|
|
00170 {
00171 return ics_length;
00172 }
|
|
|
00176 {
00177 ics_length = length;
00178 setICS();
00179 }
|
|
|
00183 {
00184 return angle;
00185 }
|
|
|
|
|
|
00196 {
00197 return fixed;
00198 }
|
|
|
00202 {
00203 fixed = b;
00204 }
|
|
|
00208 {
00209 return headed;
00210 }
|
|
|
00214 {
00215 headed = b;
00216 }
|
|
|
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 ScribbleFigure.
00223 {
00224 Vector v = super.getVisualChangeMethods();
00225 v.add(new CallableMethod("setFixed", "boolean", "b", "boolean"));
00226 v.add(new CallableMethod("setHeaded", "boolean", "b", "boolean"));
00227 return v;
00228 }
|
|
||||||||||||
|
To be removed.
Reimplemented from CanvasObject.
00259 {
00260 return false;
00261 }
|
|
||||||||||||
|
To be removed.
Reimplemented from CanvasObject.
00265 {
00266 if (!getTransformOK()) {
00267 transformICStoCCS();
00268 }
00269
00270 // taken from 'Graphics Gems II' - James Arvo,
00271 // chap. 1.3, 'Distance from a point to a line', pages 10-13.
00272
00273
00274 // check if inside enlarged bounding box (== box + SPHERE)
00275
00276 if ((x >= getX1Ccs() - SPHERE) && (x < getX1Ccs() + getWidthCcs() + SPHERE) &&
00277 (y >= getY1Ccs() - SPHERE) && (y < getY1Ccs() + getHeightCcs() + SPHERE)) {
00278
00279
00280 // calculate the area of the triangle formed by the two
00281 // CanvasArrow points and the 'check' point
00282
00283 int area = (y - getStartYCcs())*(headX - getStartXCcs()) -
00284 (x - getStartXCcs())*(headY - getStartYCcs());
00285
00286
00287 // calculate approximation of distance perpendicular to
00288 // CanvasArrow
00289
00290 int abs1 = Math.abs(headX - getStartXCcs());
00291 int abs2 = Math.abs(headY - getStartYCcs());
00292
00293 int distance = (int)(Math.abs(area) /
00294 (abs1 + abs2 - 0.5 * Math.min(abs1, abs2)));
00295
00296
00297 // this approximation can also be used as an approximation
00298 // for the 'true' distance
00299
00300 if (distance <= SPHERE) {
00301 return true;
00302 }
00303 }
00304 return false;
00305 }
|
|
||||||||||||
|
Reimplemented from ScribbleObject.
00309 {
00310 doMove(x-getStartXCcs(), y-getStartYCcs());
00311 }
|
|
||||||||||||
|
Reimplemented from ScribbleObject.
|
|
||||||||||||
|
Reimplemented from ScribbleObject.
|
|
||||||||||||||||
|
Reimplemented from ScribbleFigure.
00340 {
00341 if (!getTransformOK()) {
00342 transformICStoCCS();
00343 }
00344
00345 int w = x - getStartXCcs();
00346 int h = y - getStartYCcs();
00347 setDimension(w, h);
00348 return index;
00349 }
|
|
|
00353 {
00354 if (!getTransformOK()) {
00355 transformICStoCCS();
00356 }
00357
00358 return new Point(getStartXCcs(), getStartYCcs());
00359 }
|
|
|
00363 {
00364 if (!getTransformOK()) {
00365 transformICStoCCS();
00366 }
00367
00368 return new Point(headX, headY);
00369 }
|
|
||||||||||||||||||||||||
|
00384 {
00385 this.fixed = fixed;
00386 this.angle = angle;
00387 this.ics_length = length;
00388
00389 setICS();
00390 transformICStoCCS();
00391 }
|
|
|
00395 {
00396 cosa = Math.cos((angle * Math.PI) / 180);
00397 sina = Math.sin((angle * Math.PI) / 180);
00398 /*
00399 setWidth(ics_length * cosa);
00400 setHeight(-(ics_length * sina));
00401
00402 if (getWidth() < 0.) {
00403 setWidth(-getWidth());
00404 setX1(getStartX() - getWidth());
00405 }
00406 if (getHeight() < 0.) {
00407 setHeight(-getHeight());
00408 setY1(getStartY() - getHeight());
00409 }
00410 */
00411 double w = ics_length * cosa;
00412 double h = -(ics_length * sina);
00413
00414 if (w < 0.0) {
00415 setX1(getStartX() + w);
00416 setX2(getStartX());
00417 } else {
00418 setX2(getStartX() + w);
00419 }
00420 if (h < 0.0) {
00421 setY1(getStartY() + h);
00422 setY2(getStartY());
00423 } else {
00424 setY2(getStartY() + h);
00425 }
00426 setTransformOK(false);
00427 }
|
|
|
Perform a full ICS to CCS coordinate transformation.
Reimplemented from CanvasObject.
00431 {
00432 super.transformICStoCCS();
00433
00434 if (!fixed || !scaled) {
00435 double[] ics_vals = { ics_length - 0.5 };
00436 int[] ccs_vals = Converter.ICStoCCS(ics_vals, getZoomFactor());
00437 ccs_length = ccs_vals[0];
00438 }
00439 calcHead();
00440 setTransformOK(true);
00441 scaled = false;
00442 }
|
|
|
00446 {
00447 beta = 90 - angle - HEAD_ANGLE;
00448 gamma = angle - HEAD_ANGLE;
00449
00450 cosb = Math.cos((beta * Math.PI) / 180);
00451 sinb = Math.sin((beta * Math.PI) / 180);
00452 cosg = Math.cos((gamma * Math.PI) / 180);
00453 sing = Math.sin((gamma * Math.PI) / 180);
00454
00455 headX = getStartXCcs() + (int)(ccs_length * cosa);
00456 headY = getStartYCcs() - (int)(ccs_length * sina);
00457
00458 int headl = Math.min(ccs_length/2 + 1, HEAD_LENGTH);
00459
00460 bx = headX - (int)(headl * sinb);
00461 by = headY + (int)(headl * cosb);
00462 gx = headX - (int)(headl * cosg);
00463 gy = headY + (int)(headl * sing);
00464 }
|
|
||||||||||||
|
00468 {
00469 if (Math.abs(w) > Math.abs(h)) {
00470 angle = (int)(Math.asin(-h/ics_length) * 180.0 / Math.PI);
00471 if (w < 0.) {
00472 angle = 180 - angle;
00473 } else if (h > 0.) {
00474 angle = 360 + angle;
00475 }
00476 } else {
00477 angle = (int)(Math.acos(w/ics_length) * 180.0 / Math.PI);
00478 if (h > 0.) {
00479 angle = 360 - angle;
00480 }
00481 }
00482 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.2.12 written by Dimitri van Heesch,
© 1997-2001