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

CanvasPolyline Class Reference

Inheritance diagram for CanvasPolyline::

ScribbleFigure ScribbleObject CanvasObject CanvasColoredPolyline List of all members.

Public Methods

 CanvasPolyline ()
 CanvasPolyline (double[] xpoints, double[]ypoints, int npoints)
 CanvasPolyline (double[] xpoints, double[] ypoints, int npoints, Color color)
 CanvasPolyline (double[] xpoints, double[] ypoints, int npoints, Color color, boolean closed)
 CanvasPolyline (double[] xpoints, double[] ypoints, int npoints, int mode, Color color, boolean stroke, float linew, float trans, boolean closed, 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 setDimension (double w, double h)
 Resize CanvasObject to width 'w' and height 'h'. 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 addPoint (double x, double y)
boolean removePoint (int index)
boolean removeLastPoint ()
boolean isClosed ()
void setClosed (boolean b)
double[] getXPoints ()
double[] getYPoints ()
int getNrPoints ()
void pointsToMediator ()
void makeBSpline (int degree)
Vector getVisualChangeMethods ()
 Builds up a list of functions that are to fill a menu for changing the visualization aspects of an object. More...

 CanvasPolyline (int[] xpoints, int[] ypoints, int npoints, int mode, Color color, boolean closed, double ccs_scale)
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)
int changePoint (int index, int x, int y)
void addPoint (int x, int y)
void removeRedundantPoints ()
int[] getCcsXPoints ()
int[] getCcsYPoints ()

Protected Methods

void initPoly (double[] xpoints, double[] ypoints, int npoints, boolean closed)
void transformICStoCCS ()
 Perform a full ICS to CCS coordinate transformation. More...

void transformCCStoICS ()
 Perform a full CCS to ICS coordinate transformation. More...

void setBox ()

Protected Attributes

double[] ics_xPoints
double[] ics_yPoints
Polygon ccs_poly
boolean closed = false

Constructor & Destructor Documentation

CanvasPolyline::CanvasPolyline   [inline]
 

00033     {
00034         super(0, 0, 0, 0);
00035     }

CanvasPolyline::CanvasPolyline double    xpoints[],
doubleypoints   [],
int    npoints
[inline]
 

00040     {
00041         this(xpoints, ypoints, npoints, COPY_MODE,
00042              NO_COLOR, false, DEF_LINEW, DEF_TRANS, false, DEF_SCALE);
00043     }

CanvasPolyline::CanvasPolyline double    xpoints[],
double    ypoints[],
int    npoints,
Color    color
[inline]
 

00048     {
00049         this(xpoints, ypoints, npoints, COPY_MODE,
00050              color, false, DEF_LINEW, DEF_TRANS, false, DEF_SCALE);
00051     }

CanvasPolyline::CanvasPolyline double    xpoints[],
double    ypoints[],
int    npoints,
Color    color,
boolean    closed
[inline]
 

00056     {
00057         this(xpoints, ypoints, npoints, COPY_MODE,
00058              color, false, DEF_LINEW, DEF_TRANS, closed, DEF_SCALE);
00059     }

CanvasPolyline::CanvasPolyline double    xpoints[],
double    ypoints[],
int    npoints,
int    mode,
Color    color,
boolean    stroke,
float    linew,
float    trans,
boolean    closed,
double    ccs_scale
[inline]
 

00066     {
00067         super(0, 0, 0, 0,
00068               mode, color, stroke, linew, trans, true, ccs_scale);
00069         initPoly(xpoints, ypoints, npoints, closed);
00070     }

CanvasPolyline::CanvasPolyline int    xpoints[],
int    ypoints[],
int    npoints,
int    mode,
Color    color,
boolean    closed,
double    ccs_scale
[inline]
 

00380     {
00381         super(0, 0, 0, 0, mode, color, true, ccs_scale);
00382         
00383         double[] ics_xs = Converter.CCStoICS(xpoints, ccs_scale);
00384         double[] ics_ys = Converter.CCStoICS(ypoints, ccs_scale);
00385 
00386         initPoly(ics_xs, ics_ys, npoints, closed);
00387     }


Member Function Documentation

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

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

Reimplemented from CanvasObject.

Reimplemented in CanvasColoredPolyline.

00077     {
00078         setupDrawMode(g);
00079         if (!getTransformOK()) {
00080             transformICStoCCS();
00081         }
00082         if (closed) {
00083             g.drawPolygon(ccs_poly);
00084         } else {
00085             g.drawPolyline(ccs_poly.xpoints,
00086                            ccs_poly.ypoints, ccs_poly.npoints);
00087         }
00088     }

Object CanvasPolyline::clone   [inline, virtual]
 

Return an identical copy of this CanvasObject.

Reimplemented from CanvasObject.

Reimplemented in CanvasColoredPolyline.

00092     {
00093         Color color = drawColor;
00094         if (hasNoColor) {
00095             color = NO_COLOR;
00096         }
00097         return (new CanvasPolyline(ics_xPoints, ics_yPoints,
00098                           ccs_poly.npoints, getDrawMode(), color, strokeSet,
00099                           lineWidth, transparency, closed, getZoomFactor()));
00100     }

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

00104     {
00105         if (closed) {
00106             double[] ics_vals = { x, y };
00107             int[]    ccs_vals = Converter.ICStoCCS(ics_vals, getZoomFactor());
00108 
00109             if (!getTransformOK()) {
00110                 transformICStoCCS();
00111             }
00112 
00113             return (ccs_poly.contains(ccs_vals[0], ccs_vals[1]));
00114         }
00115         return false;
00116     }

boolean CanvasPolyline::isNear double    x,
double    y
[inline]
 

00120     {
00121         // adapted from 'Graphics Gems II' - James Arvo,
00122         // chap. 1.3, 'Distance from a point to a line', pages 10-13.
00123 
00124 
00125         // check if inside enlarged bounding box (== box + SPHERE)
00126 
00127         if (!((x >= getX1() - SPHERE) && (x < getX1() + getWidth() + SPHERE) &&
00128               (y >= getY1() - SPHERE) && (y < getY1() + getHeight() + SPHERE))) {
00129             return false;
00130         }
00131 
00132 
00133         // we are inside the box, now check each line of the polygon
00134 
00135         double min_x, min_y, max_x, max_y;
00136         double area, abs1, abs2, distance;
00137 
00138         for (int i=0, j=1; i<ics_xPoints.length; i++, j++) {
00139 
00140             if (j == ics_xPoints.length) {
00141                 if (!closed) {
00142                     break;
00143                 }
00144                 j = 0;
00145             }
00146 
00147             min_x = Math.min(ics_xPoints[i], ics_xPoints[j]);
00148             min_y = Math.min(ics_yPoints[i], ics_yPoints[j]);
00149             max_x = Math.max(ics_xPoints[i], ics_xPoints[j]);
00150             max_y = Math.max(ics_yPoints[i], ics_yPoints[j]);
00151 
00152 
00153             // check if inside enlarged bounding box of line
00154 
00155             if ((x >= min_x - SPHERE) && (x < max_x + SPHERE) &&
00156                 (y >= min_y - SPHERE) && (y < max_y + SPHERE)) {
00157 
00158 
00159                 // calculate the area of the triangle formed by the two
00160                 // CanvasPolyline points and the 'check' point
00161 
00162                 area = (y - ics_yPoints[i])*
00163                        (ics_xPoints[j] - ics_xPoints[i]) -
00164                        (x - ics_xPoints[i])*
00165                        (ics_yPoints[j] - ics_yPoints[i]);
00166 
00167 
00168                 // calculate approximation of distance perpendicular to
00169                 // CanvasLine
00170 
00171 
00172                 abs1 = Math.abs(ics_xPoints[j] - ics_xPoints[i]);
00173                 abs2 = Math.abs(ics_yPoints[j] - ics_yPoints[i]);
00174 
00175                 distance = (int)(Math.abs(area) /
00176                            (abs1 + abs2 - 0.5 * Math.min(abs1, abs2)));
00177 
00178 
00179                 // this approximation can also be used as an
00180                 // approximation for the 'true' distance
00181 
00182                 if (distance <= SPHERE) {
00183                     return true;
00184                 }
00185             }
00186         }
00187         return false;
00188     }

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

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

Parameters are assumed Image Coordinate System values.

Reimplemented from ScribbleObject.

00192     {
00193         double w_scale = (double)(Math.abs(w))/(double)getWidth();
00194         double h_scale = (double)(Math.abs(h))/(double)getHeight();
00195 
00196         for (int i=0; i < ics_xPoints.length; i++) {
00197             ics_xPoints[i] = getX1() + (ics_xPoints[i]-getX1())*w_scale;
00198             ics_yPoints[i] = getY1() + (ics_yPoints[i]-getY1())*h_scale;
00199         }
00200         if (w < 0.) {
00201             for (int i=0; i < ics_xPoints.length; i++) {
00202                 ics_xPoints[i] += w;
00203             }
00204         }
00205         if (h < 0.) {
00206             for (int i=0; i < ics_xPoints.length; i++) {
00207                 ics_yPoints[i] += h;
00208             }
00209         }
00210         setZoomFactor(getZoomFactor());
00211     }

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

00215     {
00216         super.doPixelFit(zoomFactor);
00217 
00218         // Round ICS values of polyline...
00219 
00220         for (int i=0; i < ics_xPoints.length; i++) {
00221             ics_xPoints[i] = Math.round(ics_xPoints[i]);
00222             ics_yPoints[i] = Math.round(ics_yPoints[i]);
00223         }
00224         setTransformOK(false);
00225     }

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

00229     {
00230         super.doMove(w, h);
00231 
00232         for (int i=0; i < ics_xPoints.length; i++) {
00233             ics_xPoints[i] += w;
00234             ics_yPoints[i] += h;
00235         }
00236         setTransformOK(false);
00237     }

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

Reimplemented from ScribbleFigure.

00241     {
00242         int length = ics_xPoints.length;
00243 
00244         double[] ics_xs = new double[length + 1];
00245         double[] ics_ys = new double[length + 1];
00246 
00247         for (int i=0; i < length; i++) {
00248             ics_xs[i] = ics_xPoints[i];
00249             ics_ys[i] = ics_yPoints[i];
00250         }
00251         ics_xs[length] = x;
00252         ics_ys[length] = y;
00253 
00254         ics_xPoints = new double[length + 1];
00255         ics_yPoints = new double[length + 1];
00256 
00257         for (int i=0; i < length + 1; i++) {
00258             ics_xPoints[i] = ics_xs[i];
00259             ics_yPoints[i] = ics_ys[i];
00260         }
00261         setTransformOK(false);
00262     }

boolean CanvasPolyline::removePoint int    index [inline]
 

Reimplemented from ScribbleFigure.

Reimplemented in CanvasColoredPolyline.

00266     {
00267         if (ics_xPoints.length <= 2 ||
00268             index < 0 || index >= ics_xPoints.length) {
00269             return false;
00270         }
00271 
00272         int npoints = ics_xPoints.length - 1;
00273         double[] ics_xs = new double[npoints];
00274         double[] ics_ys = new double[npoints];
00275 
00276         for (int i=0; i<npoints; i++) {
00277             if (i < index) {
00278                 ics_xs[i] = ics_xPoints[i];
00279                 ics_ys[i] = ics_yPoints[i];
00280             } else if (i >= index) {
00281                 ics_xs[i] = ics_xPoints[i+1];
00282                 ics_ys[i] = ics_yPoints[i+1];
00283             }
00284         }
00285 
00286         ics_xPoints = new double[npoints];
00287         ics_yPoints = new double[npoints];
00288 
00289         for (int i=0; i<npoints; i++) {
00290             ics_xPoints[i] = ics_xs[i];
00291             ics_yPoints[i] = ics_ys[i];
00292         }
00293         setTransformOK(false);
00294         return true;
00295     }

boolean CanvasPolyline::removeLastPoint   [inline]
 

Reimplemented from ScribbleFigure.

00299     {
00300         if (ics_xPoints.length <= 0) {
00301             return false;
00302         }
00303         return removePoint(ics_xPoints.length - 1);
00304     }

boolean CanvasPolyline::isClosed   [inline]
 

00308     {
00309         return (closed);
00310     }

void CanvasPolyline::setClosed boolean    b [inline]
 

00314     {
00315         this.closed = b;
00316     }

double [] CanvasPolyline::getXPoints   [inline]
 

00320     {
00321         return ics_xPoints;
00322     }

double [] CanvasPolyline::getYPoints   [inline]
 

00326     {
00327         return ics_yPoints;
00328     }

int CanvasPolyline::getNrPoints   [inline]
 

00332     {
00333         return ics_xPoints.length;
00334     }

void CanvasPolyline::pointsToMediator   [inline]
 

00338     {
00339 //        String dummy = _mediator.makeVectorOfPoint2d(getXPoints(),
00340 //                                        getYPoints(), getNrPoints());
00341     }

void CanvasPolyline::makeBSpline int    degree [inline]
 

00345     {
00346 //        String dummy = _mediator.makeBSplineCurve(isClosed(), degree,
00347 //                            getXPoints(), getYPoints(), getNrPoints());
00348 
00349     }

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

00356     {
00357         Vector v = super.getVisualChangeMethods();
00358         v.add(new CallableMethod("makeBSpline", "int", "degree", "int"));
00359         return v;
00360     }

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

To be removed.

Reimplemented from CanvasObject.

00391     {
00392         if (closed) {
00393             return (ccs_poly.contains(x, y));
00394         }
00395         return false;
00396     }

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

To be removed.

Reimplemented from CanvasObject.

00400     {
00401         if (!getTransformOK()) {
00402             transformICStoCCS();
00403         }
00404 
00405         // adapted from 'Graphics Gems II' - James Arvo,
00406         // chap. 1.3, 'Distance from a point to a line', pages 10-13.
00407 
00408 
00409         // check if inside enlarged bounding box (== box + SPHERE)
00410 
00411         if (!((x >= getX1Ccs() - SPHERE) && (x < getX1Ccs() + getWidthCcs() + SPHERE) &&
00412               (y >= getY1Ccs() - SPHERE) && (y < getY1Ccs() + getHeightCcs() + SPHERE))) {
00413             return false;
00414         }
00415 
00416 
00417         // we are inside the box, now check each line of the polygon
00418 
00419         int min_x, min_y, max_x, max_y;
00420         int area, abs1, abs2, distance;
00421 
00422         for (int i=0, j=1; i<ccs_poly.npoints; i++, j++) {
00423 
00424             if (j == ccs_poly.npoints) {
00425                 if (!closed) {
00426                     break;
00427                 }
00428                 j = 0;
00429             }
00430 
00431             min_x = Math.min(ccs_poly.xpoints[i], ccs_poly.xpoints[j]);
00432             min_y = Math.min(ccs_poly.ypoints[i], ccs_poly.ypoints[j]);
00433             max_x = Math.max(ccs_poly.xpoints[i], ccs_poly.xpoints[j]);
00434             max_y = Math.max(ccs_poly.ypoints[i], ccs_poly.ypoints[j]);
00435 
00436 
00437             // check if inside enlarged bounding box of line
00438 
00439             if ((x >= min_x - SPHERE) && (x < max_x + SPHERE) &&
00440                 (y >= min_y - SPHERE) && (y < max_y + SPHERE)) {
00441 
00442 
00443                 // calculate the area of the triangle formed by the two
00444                 // CanvasPolyline points and the 'check' point
00445 
00446                 area = (y - ccs_poly.ypoints[i])*
00447                        (ccs_poly.xpoints[j] - ccs_poly.xpoints[i]) -
00448                        (x - ccs_poly.xpoints[i])*
00449                        (ccs_poly.ypoints[j] - ccs_poly.ypoints[i]);
00450 
00451 
00452                 // calculate approximation of distance perpendicular to
00453                 // CanvasLine
00454 
00455 
00456                 abs1 = Math.abs(ccs_poly.xpoints[j] - ccs_poly.xpoints[i]);
00457                 abs2 = Math.abs(ccs_poly.ypoints[j] - ccs_poly.ypoints[i]);
00458 
00459                 distance = (int)(Math.abs(area) /
00460                            (abs1 + abs2 - 0.5 * Math.min(abs1, abs2)));
00461 
00462 
00463                 // this approximation can also be used as an
00464                 // approximation for the 'true' distance
00465 
00466                 if (distance <= SPHERE) {
00467                     return true;
00468                 }
00469             }
00470         }
00471         return false;
00472     }

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

Reimplemented from ScribbleObject.

00476     {
00477         if (!getTransformOK()) {
00478             transformICStoCCS();
00479         }
00480 
00481         double w_scale = (double)(Math.abs(w))/(double)getWidthCcs();
00482         double h_scale = (double)(Math.abs(h))/(double)getHeightCcs();
00483 
00484         for (int i=0; i < ccs_poly.npoints; i++) {
00485             ics_xPoints[i] = getX1() + (ics_xPoints[i]-getX1())*w_scale;
00486             ics_yPoints[i] = getY1() + (ics_yPoints[i]-getY1())*h_scale;
00487         }
00488 
00489         int[]    ccs_vals = { w + getX1Ccs(), h + getY1Ccs() };
00490         double[] ics_vals = Converter.CCStoICS(ccs_vals, getZoomFactor());
00491 
00492         double tmp_w = ics_vals[0] - getX1();
00493         double tmp_h = ics_vals[1] - getY1();
00494 
00495         if (w < 0) {
00496             for (int i=0; i < ccs_poly.npoints; i++) {
00497                 ics_xPoints[i] += tmp_w;
00498             }
00499         }
00500         if (h < 0) {
00501             for (int i=0; i < ccs_poly.npoints; i++) {
00502                 ics_yPoints[i] += tmp_h;
00503             }
00504         }
00505         setZoomFactor(getZoomFactor());
00506     }

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

Reimplemented from ScribbleObject.

00510     {
00511         super.doMove(w, h);
00512 
00513         for (int i=0; i < ccs_poly.npoints; i++) {
00514             ccs_poly.xpoints[i] += w;
00515             ccs_poly.ypoints[i] += h;
00516         }
00517         ccs_poly = new Polygon(ccs_poly.xpoints,
00518                                ccs_poly.ypoints, ccs_poly.npoints);
00519         transformCCStoICS();
00520     }

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

Reimplemented from ScribbleFigure.

00524     {
00525         if (!getTransformOK()) {
00526             transformICStoCCS();
00527         }
00528 
00529         if (index >= ccs_poly.npoints) {
00530             return -1; 
00531         }
00532 
00533         ccs_poly.xpoints[index] = x;
00534         ccs_poly.ypoints[index] = y;
00535         ccs_poly = new Polygon(ccs_poly.xpoints,
00536                                ccs_poly.ypoints, ccs_poly.npoints);
00537 
00538         transformCCStoICS();
00539         return index;
00540     }

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

Reimplemented from ScribbleFigure.

00544     {
00545         if (!getTransformOK()) {
00546             transformICStoCCS();
00547         }
00548 
00549         ccs_poly.addPoint(x, y);
00550 
00551         ics_xPoints = new double[ccs_poly.npoints];
00552         ics_yPoints = new double[ccs_poly.npoints];
00553 
00554         transformCCStoICS();
00555     }

void CanvasPolyline::removeRedundantPoints   [inline]
 

00559     {
00560         if (!getTransformOK()) {
00561             transformICStoCCS();
00562         }
00563 
00564         if (ccs_poly.npoints <= 2) {
00565             return;
00566         }
00567 
00568         double[] tmp_icsXs = new double[ccs_poly.npoints];
00569         double[] tmp_icsYs = new double[ccs_poly.npoints];
00570         Polygon  tmp_poly  = new Polygon(ccs_poly.xpoints,
00571                                  ccs_poly.ypoints, ccs_poly.npoints);
00572 
00573         ccs_poly  = new Polygon();
00574         int index = 0;
00575 
00576         for (int i=0, j=1; i<tmp_poly.npoints; i++, j++) {
00577 
00578             if (j == tmp_poly.npoints) {
00579                 j = 0;
00580             }
00581             if (!(tmp_poly.xpoints[i] == tmp_poly.xpoints[j] &&
00582                   tmp_poly.ypoints[i] == tmp_poly.ypoints[j])) {
00583                 ccs_poly.addPoint(tmp_poly.xpoints[i],
00584                                   tmp_poly.ypoints[i]);
00585                 tmp_icsXs[ccs_poly.npoints - 1] = ics_xPoints[i];
00586                 tmp_icsYs[ccs_poly.npoints - 1] = ics_yPoints[i];
00587             }
00588         }
00589 
00590         ics_xPoints = new double[ccs_poly.npoints];
00591         ics_yPoints = new double[ccs_poly.npoints];
00592 
00593         transformCCStoICS();
00594     }

int [] CanvasPolyline::getCcsXPoints   [inline]
 

00598     {
00599         if (!getTransformOK()) {
00600             transformICStoCCS();
00601         }
00602 
00603         return ccs_poly.xpoints;
00604     }

int [] CanvasPolyline::getCcsYPoints   [inline]
 

00608     {
00609         if (!getTransformOK()) {
00610             transformICStoCCS();
00611         }
00612 
00613         return ccs_poly.ypoints;
00614     }

void CanvasPolyline::initPoly double    xpoints[],
double    ypoints[],
int    npoints,
boolean    closed
[inline, protected]
 

00629     {
00630         setComplex(true);
00631         this.closed = closed;
00632 
00633         ics_xPoints = new double[npoints];
00634         ics_yPoints = new double[npoints];
00635 
00636         for (int i=0; i < npoints; i++) {
00637             ics_xPoints[i] = xpoints[i];
00638             ics_yPoints[i] = ypoints[i];
00639         }
00640         
00641         setStartX(xpoints[0]);
00642         setStartY(ypoints[0]);
00643 
00644         transformICStoCCS();
00645 
00646 //        _mediator = new HxMediatorPeer();
00647     }

void CanvasPolyline::transformICStoCCS   [inline, protected]
 

Perform a full ICS to CCS coordinate transformation.

Reimplemented from CanvasObject.

Reimplemented in CanvasColoredPolyline.

00651     {
00652         if (ics_xPoints != null) {
00653             int[] ccs_xs = Converter.ICStoCCS(ics_xPoints, getZoomFactor());
00654             int[] ccs_ys = Converter.ICStoCCS(ics_yPoints, getZoomFactor());
00655 
00656             ccs_poly = new Polygon(ccs_xs, ccs_ys, ccs_xs.length);
00657             setBox();
00658             super.transformICStoCCS();
00659         }
00660     }

void CanvasPolyline::transformCCStoICS   [inline, protected]
 

Perform a full CCS to ICS coordinate transformation.

This function is used only for scribbled objects.

Reimplemented from CanvasObject.

Reimplemented in CanvasColoredPolyline.

00664     {
00665         double[] xs = Converter.CCStoICS(ccs_poly.xpoints, getZoomFactor());
00666         double[] ys = Converter.CCStoICS(ccs_poly.ypoints, getZoomFactor());
00667 
00668         for (int i=0; i < ccs_poly.npoints; i++) {
00669             ics_xPoints[i] = xs[i];
00670             ics_yPoints[i] = ys[i];
00671         }
00672         setBox();
00673         super.transformCCStoICS();
00674     }

void CanvasPolyline::setBox   [inline, protected]
 

00678     {
00679         double ics_maxX = 0.;
00680         double ics_maxY = 0.;
00681 
00682         setX1(Double.MAX_VALUE);
00683         setY1(Double.MAX_VALUE);
00684 
00685         for (int i=0; i < ics_xPoints.length; i++) {
00686             if (ics_xPoints[i] < getX1()) {
00687                 setX1(ics_xPoints[i]);
00688             }
00689             if (ics_yPoints[i] < getY1()) {
00690                 setY1(ics_yPoints[i]);
00691             }
00692             if (ics_xPoints[i] > ics_maxX) {
00693                 ics_maxX = ics_xPoints[i];
00694             }
00695             if (ics_yPoints[i] > ics_maxY) {
00696                 ics_maxY = ics_yPoints[i];
00697             }
00698         }
00699 
00700         setWidth(ics_maxX - getX1());
00701         setHeight(ics_maxY - getY1());
00702 
00703         setTransformOK(false);
00704     }


Member Data Documentation

double [] CanvasPolyline::ics_xPoints [protected]
 

double [] CanvasPolyline::ics_yPoints [protected]
 

Polygon CanvasPolyline::ccs_poly [protected]
 

boolean CanvasPolyline::closed = false [protected]
 


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