Java Arc2D.setAngles(double x1, double y1, double x2, double y2)

Syntax

Arc2D.setAngles(double x1, double y1, double x2, double y2) has the following syntax.

public void setAngles(double x1,  double y1,  double x2,  double y2)

Example

In the following code shows how to use Arc2D.setAngles(double x1, double y1, double x2, double y2) method.


//from   ww  w.  jav a 2 s  .co  m
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Arc2D;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class Main extends JPanel {

  public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    int w = getSize().width;
    int h = getSize().height;

    Arc2D arc = new Arc2D.Double(0.0, 0.5, w, h, 0.0, 60.0, Arc2D.CHORD);
    arc.setAngles(0.4,0.5,0.6,0.3);
    g2.draw(arc);

    arc = new Arc2D.Float(0.0f, 0.0f, w, h, 80.0f, 110.0f, Arc2D.PIE);

    g2.fill(arc);

    arc = new Arc2D.Float(0.0f, 0.0f, w, h, 210.0f, 130.0f, Arc2D.OPEN);

    g2.draw(arc);
  }

  public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.getContentPane().add(new Main());

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(200, 200);
    frame.setVisible(true);
  }
}




















Home »
  Java Tutorial »
    java.awt.geom »




AffineTransform
Arc2D
Area
CubicCurve2D
Ellipse2D
GeneralPath