PieUtilspublic class PieUtils extends Object
Methods Summary |
---|
public static org.eclipse.swt.graphics.Image | computePie(org.eclipse.swt.widgets.Display display, int width, int height, int percent)
Image image = new Image(display,width,height);
GC gcImage = new GC(image);
gcImage.setForeground(Colors.blue);
int angle = (percent * 360) / 100;
gcImage.setBackground(Colors.blues[Colors.BLUES_MIDDARK]);
gcImage.fillArc(0,0,width,height,90-angle,angle);
gcImage.drawOval(0 , 0 , width-1, height-1);
gcImage.dispose();
return image;
| public static void | drawPie(org.eclipse.swt.graphics.GC gc, int x, int y, int width, int height, int percent)
Color background = gc.getBackground();
gc.setForeground(Colors.blue);
int angle = (percent * 360) / 100;
if(angle<4)
angle = 0; // workaround fillArc rendering bug
gc.setBackground(Colors.white);
gc.fillArc(x,y,width,height,0,360);
gc.setBackground(background);
gc.fillArc(x,y,width,height,90,angle*-1);
gc.drawOval(x , y , width-1, height-1);
|
|