FileDocCategorySizeDatePackage
PieUtils.javaAPI DocAzureus 3.0.3.42222Fri Jul 13 11:27:10 BST 2007org.gudy.azureus2.ui.swt.components.graphics

PieUtils

public class PieUtils extends Object
author
Olivier Chalouhi

Fields Summary
Constructors Summary
Methods Summary
public static org.eclipse.swt.graphics.ImagecomputePie(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 voiddrawPie(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);