Example usage for java.awt.geom Arc2D getAngleStart

List of usage examples for java.awt.geom Arc2D getAngleStart

Introduction

In this page you can find the example usage for java.awt.geom Arc2D getAngleStart.

Prototype

public abstract double getAngleStart();

Source Link

Document

Returns the starting angle of the arc.

Usage

From source file:Main.java

/**
 * Compares two arcs and returns <code>true</code> if they are equal or
 * both <code>null</code>./*from   ww w. ja  v  a 2s .  c o m*/
 *
 * @param a1  the first arc (<code>null</code> permitted).
 * @param a2  the second arc (<code>null</code> permitted).
 *
 * @return A boolean.
 */
public static boolean equal(final Arc2D a1, final Arc2D a2) {
    if (a1 == null) {
        return (a2 == null);
    }
    if (a2 == null) {
        return false;
    }
    if (!a1.getFrame().equals(a2.getFrame())) {
        return false;
    }
    if (a1.getAngleStart() != a2.getAngleStart()) {
        return false;
    }
    if (a1.getAngleExtent() != a2.getAngleExtent()) {
        return false;
    }
    if (a1.getArcType() != a2.getArcType()) {
        return false;
    }
    return true;
}

From source file:Main.java

/**
 * Serialises a <code>Shape</code> object.
 *
 * @param shape  the shape object (<code>null</code> permitted).
 * @param stream  the output stream (<code>null</code> not permitted).
 *
 * @throws IOException if there is an I/O error.
 *//* w ww.j  av  a 2 s .c  o  m*/
public static void writeShape(final Shape shape, final ObjectOutputStream stream) throws IOException {

    if (stream == null) {
        throw new IllegalArgumentException("Null 'stream' argument.");
    }
    if (shape != null) {
        stream.writeBoolean(false);
        if (shape instanceof Line2D) {
            final Line2D line = (Line2D) shape;
            stream.writeObject(Line2D.class);
            stream.writeDouble(line.getX1());
            stream.writeDouble(line.getY1());
            stream.writeDouble(line.getX2());
            stream.writeDouble(line.getY2());
        } else if (shape instanceof Rectangle2D) {
            final Rectangle2D rectangle = (Rectangle2D) shape;
            stream.writeObject(Rectangle2D.class);
            stream.writeDouble(rectangle.getX());
            stream.writeDouble(rectangle.getY());
            stream.writeDouble(rectangle.getWidth());
            stream.writeDouble(rectangle.getHeight());
        } else if (shape instanceof Ellipse2D) {
            final Ellipse2D ellipse = (Ellipse2D) shape;
            stream.writeObject(Ellipse2D.class);
            stream.writeDouble(ellipse.getX());
            stream.writeDouble(ellipse.getY());
            stream.writeDouble(ellipse.getWidth());
            stream.writeDouble(ellipse.getHeight());
        } else if (shape instanceof Arc2D) {
            final Arc2D arc = (Arc2D) shape;
            stream.writeObject(Arc2D.class);
            stream.writeDouble(arc.getX());
            stream.writeDouble(arc.getY());
            stream.writeDouble(arc.getWidth());
            stream.writeDouble(arc.getHeight());
            stream.writeDouble(arc.getAngleStart());
            stream.writeDouble(arc.getAngleExtent());
            stream.writeInt(arc.getArcType());
        } else if (shape instanceof GeneralPath) {
            stream.writeObject(GeneralPath.class);
            final PathIterator pi = shape.getPathIterator(null);
            final float[] args = new float[6];
            stream.writeBoolean(pi.isDone());
            while (!pi.isDone()) {
                final int type = pi.currentSegment(args);
                stream.writeInt(type);
                // TODO: could write this to only stream the values
                // required for the segment type
                for (int i = 0; i < 6; i++) {
                    stream.writeFloat(args[i]);
                }
                stream.writeInt(pi.getWindingRule());
                pi.next();
                stream.writeBoolean(pi.isDone());
            }
        } else {
            stream.writeObject(shape.getClass());
            stream.writeObject(shape);
        }
    } else {
        stream.writeBoolean(true);
    }
}

From source file:Main.java

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);
    System.out.println(arc.getAngleStart());
    g2.draw(arc);// w w w  . j  av  a  2 s  . co  m

    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);
}