Example usage for java.awt Graphics fillArc

List of usage examples for java.awt Graphics fillArc

Introduction

In this page you can find the example usage for java.awt Graphics fillArc.

Prototype

public abstract void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle);

Source Link

Document

Fills a circular or elliptical arc covering the specified rectangle.

Usage

From source file:lu.lippmann.cdb.lab.mds.MDSViewBuilder.java

/**
 * //from   w  w w.  ja  va  2s. c om
 * @param g
 * @param fx
 * @param fy
 * @param size
 * @param repartition
 * @param total
 * @param colors
 */
public static void createPieChart(Graphics g, int fx, int fy, int size, Map<Object, Integer> repartition,
        int total, List<Paint> colors) {
    if (total > 0) {
        int startAngle = 0;
        int k = 0;
        double curValue = 0.0D;
        for (final Map.Entry<Object, Integer> entry : repartition.entrySet()) {
            startAngle = (int) (curValue * 360 / total);
            int arcAngle = (int) (entry.getValue() * 360 / total);
            g.setColor((Color) colors.get(k));
            g.fillArc(fx, fy, size, size, startAngle, arcAngle);
            curValue += entry.getValue();
            k++;
        }
    }
}

From source file:Main.java

public void paint(Graphics g) {

    g.fillArc(5, 15, 50, 75, 25, 165);
}

From source file:MyCanvas.java

public void paint(Graphics g) {
    g.setColor(Color.RED);
    g.fillArc(20, 20, 200, 200, 200, 200);
}

From source file:MainClass.java

public void paint(Graphics g) {
    g.setColor(Color.yellow);
    g.fillArc(5, 15, 50, 75, 25, 165);
}

From source file:MainClass.java

public void paint(Graphics g) {
    g.drawArc(10, 40, 70, 70, 0, 75);//  w  w  w . j  av a 2  s .c o m
    g.fillArc(100, 40, 70, 70, 0, 75);
    g.drawArc(10, 100, 70, 80, 0, 175);
    g.fillArc(100, 100, 70, 90, 0, 270);
    g.drawArc(200, 80, 80, 80, 0, 180);
}

From source file:Main.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    g.setColor(color);/*from  www.j ava 2 s . co  m*/
    g.fillArc(x, y, getIconWidth(), getIconHeight(), 45, 270);
}

From source file:BufferedAnimate.java

public void paint(Graphics g) {
    if ((oldSize == null) || (oldSize != getSize())) {
        oldSize = getSize();/*from  ww w . jav a 2  s. co  m*/
        buffer = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
    }
    if (insets == null) {
        insets = getInsets();
    }
    // Calculate each time in case of resize
    int x = insets.left;
    int y = insets.top;
    int width = getWidth() - insets.left - insets.right;
    int height = getHeight() - insets.top - insets.bottom;
    int start = 0;
    int steps = colors.length;
    int stepSize = 360 / steps;
    synchronized (colors) {
        Graphics bufferG = buffer.getGraphics();
        bufferG.setColor(Color.WHITE);
        bufferG.fillRect(x, y, width, height);
        for (int i = 0; i < steps; i++) {
            bufferG.setColor(colors[i]);
            bufferG.fillArc(x, y, width, height, start, stepSize);
            start += stepSize;
        }
    }
    g.drawImage(buffer, 0, 0, this);
}

From source file:FillPolyPanel.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    int radius = 40;
    int centerX = 50;
    int centerY = 100;
    int angle = 30;

    int dx = (int) (radius * Math.cos(angle * Math.PI / 180));
    int dy = (int) (radius * Math.sin(angle * Math.PI / 180));

    g.fillArc(centerX - radius, centerY - radius, 2 * radius, 2 * radius, angle, 360 - 2 * angle);

    Polygon p = new Polygon();
    centerX = 150;/* w w w. j a v  a2s  .c o m*/
    for (int i = 0; i < 5; i++)
        p.addPoint((int) (centerX + radius * Math.cos(i * 2 * Math.PI / 5)),
                (int) (centerY + radius * Math.sin(i * 2 * Math.PI / 5)));

    g.fillPolygon(p);

    p = new Polygon();
    centerX = 250;
    for (int i = 0; i < 360; i++) {
        double t = i / 360.0;
        p.addPoint((int) (centerX + radius * t * Math.cos(8 * t * Math.PI)),
                (int) (centerY + radius * t * Math.sin(8 * t * Math.PI)));
    }
    g.fillPolygon(p);
}

From source file:Animate.java

public void paint(Graphics g) {
    super.paint(g);
    if (insets == null) {
        insets = getInsets();/* w  ww  .jav  a  2  s  .  c om*/
    }
    // Calculate each time in case of resize
    int x = insets.left;
    int y = insets.top;
    int width = getWidth() - insets.left - insets.right;
    int height = getHeight() - insets.top - insets.bottom;
    int start = 0;
    int steps = colors.length;
    int stepSize = 360 / steps;
    synchronized (colors) {
        for (int i = 0; i < steps; i++) {
            g.setColor(colors[i]);
            g.fillArc(x, y, width, height, start, stepSize);
            start += stepSize;
        }
    }
}

From source file:FancyCaret.java

public void paint(Graphics g) {
    JTextComponent comp = getComponent();
    if (comp == null)
        return;/*ww w .  ja va  2  s . co  m*/

    int dot = getDot();
    Rectangle r = null;
    char dotChar;
    try {
        r = comp.modelToView(dot);
        if (r == null)
            return;
        dotChar = comp.getText(dot, 1).charAt(0);
    } catch (BadLocationException e) {
        return;
    }

    if ((x != r.x) || (y != r.y)) {
        repaint();
        x = r.x;
        y = r.y;
        height = r.height;
    }

    g.setColor(comp.getCaretColor());
    g.setXORMode(comp.getBackground());

    if (dotChar == '\n') {
        int diam = r.height;
        if (isVisible())
            g.fillArc(r.x - diam / 2, r.y, diam, diam, 270, 180); // half circle
        width = diam / 2 + 2;
        return;
    }

    if (dotChar == '\t')
        try {
            Rectangle nextr = comp.modelToView(dot + 1);
            if ((r.y == nextr.y) && (r.x < nextr.x)) {
                width = nextr.x - r.x;
                if (isVisible())
                    g.fillRoundRect(r.x, r.y, width, r.height, 12, 12);
                return;
            } else
                dotChar = ' ';
        } catch (BadLocationException e) {
            dotChar = ' ';
        }

    width = g.getFontMetrics().charWidth(dotChar);
    if (isVisible())
        g.fillRect(r.x, r.y, width, r.height);
}