Java Screen Size makeEllipse(double x, double y, double size)

Here you can find the source of makeEllipse(double x, double y, double size)

Description

Return a Shape object for an "ellipse" symbol.

License

LGPL

Parameter

Parameter Description
x the center X coord in screen coords
y the center Y coord in screen coords
size the radius of the symbol

Declaration

public static Shape makeEllipse(double x, double y, double size) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.awt.Shape;

import java.awt.geom.Ellipse2D;
import java.awt.geom.GeneralPath;

import java.awt.geom.Point2D;

public class Main {
    /**/*  w  ww .ja  v a2  s  . c  o  m*/
     * Return a Shape object for an "ellipse" symbol.
     *
     * @param x the center X coord in screen coords
     * @param y the center Y coord in screen coords
     * @param size the radius of the symbol
     */
    public static Shape makeEllipse(double x, double y, double size) {
        return new Ellipse2D.Double(x - size, y - size, size * 2, size * 2);
    }

    /**
     * Return a Shape object for an "ellipse" symbol.
     *
     * @param center the center point in screen coords
     * @param north the north point in screen coords
     * @param east the east point in screen coords
     */
    public static Shape makeEllipse(Point2D.Double center, Point2D.Double north, Point2D.Double east) {

        Point2D.Double south = new Point2D.Double(center.x - (north.x - center.x), center.y - (north.y - center.y));
        Point2D.Double west = new Point2D.Double(center.x + (center.x - east.x), center.y + (center.y - east.y));

        // XXX Note: This is not an ellipse. What we really want is a "smooth polygon"...
        GeneralPath p = new GeneralPath();
        p.moveTo((float) north.x, (float) north.y);
        p.quadTo((float) west.x, (float) west.y, (float) south.x, (float) south.y);
        p.quadTo((float) east.x, (float) east.y, (float) north.x, (float) north.y);
        p.closePath();
        return p;
    }
}

Related

  1. getMaxWindowSize()
  2. getMinimumCacheSize(int tileSize, double overdrawFactor)
  3. getSizeWithScreen(double xd, double yd)
  4. getSystemSizeRate()
  5. getWindowActualSize(final Window window)
  6. maximizeWindowWithMargin(final Window window, final int margin, final Dimension maxSize)
  7. screenSize()
  8. setLocationRelativeToAndSizeToWindow(Component parent, Component child, Dimension max)
  9. setSize(final Window window, final int minusX, final int minusY)