Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] How to create a Path using PathData ?


Note that your SWT.PATH_LINE_TO switch is wrong, if you fix that it is gone to work
properly.

Silenio



"Thomas Wojcik" <tomwoj@xxxxxxx>
Sent by: platform-swt-dev-bounces@xxxxxxxxxxx

06/28/2005 08:50 AM

Please respond to
"Eclipse Platform SWT component developers list."

To
<platform-swt-dev@xxxxxxxxxxx>
cc
Subject
[platform-swt-dev] How to create a Path using PathData ?





Hi all,
the org.eclipse.swt.graphics.Path has a method called getPathData()
returning "a device independent representation" of the path. Unfortunatly
there is no setPathData() method. I've tried something like this to create a
Path using the PathData.points and PathData.types arrays :

public void loadPath(Path path,float[] points,byte[] types) {
 int j=0;
 for (int i=0; i<types.length; i++) {
  float x,y,x2,y2,x3,y3;

  switch (types[i]) {
  case SWT.PATH_MOVE_TO:
   x = points[j++];
   y = points[j++];
   path.moveTo(x,y);
   break;
  case SWT.PATH_LINE_TO:
   x = points[j++];
   y = points[j++];
   path.moveTo(x,y);
   break;
  case SWT.PATH_CUBIC_TO:
   x = points[j++];
   y = points[j++];
   x2 = points[j++];
   y2 = points[j++];
   x3 = points[j++];
   y3 = points[j++];
   path.cubicTo(x,y,x2,y2,x3,y3);
   break;
  case SWT.PATH_QUAD_TO:  // never used ???
   x = points[j++];
   y = points[j++];
   x2 = points[j++];
   y2 = points[j++];
   path.quadTo(x,y,x2,y2);
   break;
  case SWT.PATH_CLOSE:
   path.close();
   break;
  default:
   break;
  }
 }
}

To test this method I do simply the following:
   Path path= new Path(null);
   Font font =new Font(null,"times",40,0);
   path.addString("ZABCD",50,50,font);
   Path path2= new Path(null);
   loadPath(path2,path.getPathData().points,path.getPathData().types);
   gc.drawPath(path2);

And the result is : BCD characters are well rendered but non Z and A !  (In
fact using another font only C remains correct !)
What's wrong with my loadPath() method ? Perhaps something's wrong with the
"PATH_CLOSE" and subpaths ? Or is there a known bug ?

Thanks
Thomas



_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top