Here you can find the source of makeEllipse(double x, double y, double size)
Parameter | Description |
---|---|
x | the center X coord in screen coords |
y | the center Y coord in screen coords |
size | the radius of the symbol |
public static Shape makeEllipse(double x, double y, double size)
//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; } }