There are 8 code examples for java.awt.geom.Ellipse2D.

The API names are highlighted below. You can use suckoo button to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.

Project Name: jFreeChart Package: org.jfree.chart.needle

Source Code: MiddlePinNeedle.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Draws the needle.
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param rotate  the rotation point.
 * @param angle  the angle.
 */
protected void drawNeedle(Graphics2D g2,Rectangle2D plotArea,Point2D rotate,double angle){
  Area shape;
  GeneralPath pointer=new GeneralPath();
  int minY=(int)(plotArea.getMinY());
  int maxY=(int)(plotArea.getMaxY());
  int midY=((maxY - minY) / 2) + minY;
  int midX=(int)(plotArea.getMinX() + (plotArea.getWidth() / 2));
  int lenX=(int)(plotArea.getWidth() / 10);
  if (lenX < 2) {
    lenX=2;
  }
  pointer.moveTo(midX - lenX,midY - lenX);
  pointer.lineTo(midX + lenX,midY - lenX);
  pointer.lineTo(midX,minY);
  pointer.closePath();
  lenX=4 * lenX;
  Ellipse2D circle=new Ellipse2D.Double(midX - lenX / 2,midY - lenX,lenX,lenX);
  shape=new Area(circle);
  shape.add(new Area(pointer));
  if ((rotate != null) && (angle != 0)) {
    getTransform().setToRotation(angle,rotate.getX(),rotate.getY());
    shape.transform(getTransform());
  }
  defaultDisplay(g2,shape);
}
 

Project Name: jFreeChart Package: org.jfree.chart.needle

Source Code: PinNeedle.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Draws the needle.
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param rotate  the rotation point.
 * @param angle  the angle.
 */
protected void drawNeedle(Graphics2D g2,Rectangle2D plotArea,Point2D rotate,double angle){
  Area shape;
  GeneralPath pointer=new GeneralPath();
  int minY=(int)(plotArea.getMinY());
  int maxY=(int)(plotArea.getMaxY());
  int midX=(int)(plotArea.getMinX() + (plotArea.getWidth() / 2));
  int lenX=(int)(plotArea.getWidth() / 10);
  if (lenX < 2) {
    lenX=2;
  }
  pointer.moveTo(midX - lenX,maxY - lenX);
  pointer.lineTo(midX + lenX,maxY - lenX);
  pointer.lineTo(midX,minY + lenX);
  pointer.closePath();
  lenX=4 * lenX;
  Ellipse2D circle=new Ellipse2D.Double(midX - lenX / 2,plotArea.getMaxY() - lenX,lenX,lenX);
  shape=new Area(circle);
  shape.add(new Area(pointer));
  if ((rotate != null) && (angle != 0)) {
    getTransform().setToRotation(angle,rotate.getX(),rotate.getY());
    shape.transform(getTransform());
  }
  defaultDisplay(g2,shape);
}
 

Project Name: jFreeChart Package: org.jfree.chart.plot

Source Code: CompassPlot.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns a clone of the plot.
 * @return A clone.
 * @throws CloneNotSupportedException  this class will not throw this
 * exception, but subclasses (if any) might.
 */
public Object clone() throws CloneNotSupportedException {
  CompassPlot clone=(CompassPlot)super.clone();
  if (this.circle1 != null) {
    clone.circle1=(Ellipse2D)this.circle1.clone();
  }
  if (this.circle2 != null) {
    clone.circle2=(Ellipse2D)this.circle2.clone();
  }
  if (this.a1 != null) {
    clone.a1=(Area)this.a1.clone();
  }
  if (this.a2 != null) {
    clone.a2=(Area)this.a2.clone();
  }
  if (this.rect1 != null) {
    clone.rect1=(Rectangle2D)this.rect1.clone();
  }
  clone.datasets=(ValueDataset[])this.datasets.clone();
  clone.seriesNeedle=(MeterNeedle[])this.seriesNeedle.clone();
  for (int i=0; i < this.datasets.length; ++i) {
    if (clone.datasets[i] != null) {
      clone.datasets[i].addChangeListener(clone);
    }
  }
  return clone;
}
 

Project Name: jFreeChart Package: org.jfree.chart.plot

Source Code: WaferMapPlot.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Draws the waferedge, including the notch.
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 */
protected void drawWaferEdge(Graphics2D g2,Rectangle2D plotArea){
  Ellipse2D waferEdge=getWaferEdge(plotArea);
  g2.setColor(Color.black);
  g2.draw(waferEdge);
  Arc2D notch=null;
  Rectangle2D waferFrame=waferEdge.getFrame();
  double notchDiameter=waferFrame.getWidth() * 0.04;
  if (this.orientation == PlotOrientation.HORIZONTAL) {
    Rectangle2D notchFrame=new Rectangle2D.Double(waferFrame.getX() + waferFrame.getWidth() - (notchDiameter / 2),waferFrame.getY() + (waferFrame.getHeight() / 2) - (notchDiameter / 2),notchDiameter,notchDiameter);
    notch=new Arc2D.Double(notchFrame,90d,180d,Arc2D.OPEN);
  }
 else {
    Rectangle2D notchFrame=new Rectangle2D.Double(waferFrame.getX() + (waferFrame.getWidth() / 2) - (notchDiameter / 2),waferFrame.getY() + waferFrame.getHeight() - (notchDiameter / 2),notchDiameter,notchDiameter);
    notch=new Arc2D.Double(notchFrame,0d,180d,Arc2D.OPEN);
  }
  g2.setColor(Color.white);
  g2.fill(notch);
  g2.setColor(Color.black);
  g2.draw(notch);
}
 

Project Name: jFreeChart Package: org.jfree.chart.plot.dial

Source Code: DialCap.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Draws the background to the specified graphics device.  If the dial
 * frame specifies a window, the clipping region will already have been
 * set to this window before this method is called.
 * @param g2  the graphics device (<code>null</code> not permitted).
 * @param plot  the plot (ignored here).
 * @param frame  the dial frame (ignored here).
 * @param view  the view rectangle (<code>null</code> not permitted).
 */
public void draw(Graphics2D g2,DialPlot plot,Rectangle2D frame,Rectangle2D view){
  g2.setPaint(this.fillPaint);
  Rectangle2D f=DialPlot.rectangleByRadius(frame,this.radius,this.radius);
  Ellipse2D e=new Ellipse2D.Double(f.getX(),f.getY(),f.getWidth(),f.getHeight());
  g2.fill(e);
  g2.setPaint(this.outlinePaint);
  g2.setStroke(this.outlineStroke);
  g2.draw(e);
}
 

Project Name: jFreeChart Package: org.jfree.chart.plot.dial

Source Code: StandardDialFrame.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Draws the frame.  This method is called by the {@link DialPlot} class,
 * you shouldn't need to call it directly.
 * @param g2  the graphics target (<code>null</code> not permitted).
 * @param plot  the plot (<code>null</code> not permitted).
 * @param frame  the frame (<code>null</code> not permitted).
 * @param view  the view (<code>null</code> not permitted).
 */
public void draw(Graphics2D g2,DialPlot plot,Rectangle2D frame,Rectangle2D view){
  Shape window=getWindow(frame);
  Rectangle2D f=DialPlot.rectangleByRadius(frame,this.radius + 0.02,this.radius + 0.02);
  Ellipse2D e=new Ellipse2D.Double(f.getX(),f.getY(),f.getWidth(),f.getHeight());
  Area area=new Area(e);
  Area area2=new Area(window);
  area.subtract(area2);
  g2.setPaint(this.backgroundPaint);
  g2.fill(area);
  g2.setStroke(this.stroke);
  g2.setPaint(this.foregroundPaint);
  g2.draw(window);
  g2.draw(e);
}
 

Project Name: jFreeChart Package: org.jfree.chart.renderer

Source Code: DefaultPolarItemRenderer.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Draw the radial gridlines - the rings.
 * @param g2  the drawing surface.
 * @param plot  the plot.
 * @param radialAxis  the radial axis.
 * @param ticks  the ticks.
 * @param dataArea  the data area.
 */
public void drawRadialGridLines(Graphics2D g2,PolarPlot plot,ValueAxis radialAxis,List ticks,Rectangle2D dataArea){
  g2.setFont(radialAxis.getTickLabelFont());
  g2.setPaint(plot.getRadiusGridlinePaint());
  g2.setStroke(plot.getRadiusGridlineStroke());
  double axisMin=radialAxis.getLowerBound();
  Point center=plot.translateValueThetaRadiusToJava2D(axisMin,axisMin,dataArea);
  Iterator iterator=ticks.iterator();
  while (iterator.hasNext()) {
    NumberTick tick=(NumberTick)iterator.next();
    double angleDegrees=plot.isCounterClockwise() ? plot.getAngleOffset() : -plot.getAngleOffset();
    Point p=plot.translateValueThetaRadiusToJava2D(angleDegrees,tick.getNumber().doubleValue(),dataArea);
    int r=p.x - center.x;
    int upperLeftX=center.x - r;
    int upperLeftY=center.y - r;
    int d=2 * r;
    Ellipse2D ring=new Ellipse2D.Double(upperLeftX,upperLeftY,d,d);
    g2.setPaint(plot.getRadiusGridlinePaint());
    g2.draw(ring);
  }
}
 

Project Name: jFreeChart Package: org.jfree.chart.renderer.category

Source Code: BoxAndWhiskerRenderer.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Draws two dots to represent the average value of more than one outlier.
 * @param point  the location
 * @param boxWidth  the box width.
 * @param oRadius  the radius.
 * @param g2  the graphics device.
 */
private void drawMultipleEllipse(Point2D point,double boxWidth,double oRadius,Graphics2D g2){
  Ellipse2D dot1=new Ellipse2D.Double(point.getX() - (boxWidth / 2) + oRadius,point.getY(),oRadius,oRadius);
  Ellipse2D dot2=new Ellipse2D.Double(point.getX() + (boxWidth / 2),point.getY(),oRadius,oRadius);
  g2.draw(dot1);
  g2.draw(dot2);
}