use of java.awt.geom.Ellipse2D in project poi by apache.
the class SLGraphics method drawOval.
/**
* Draws the outline of an oval.
* The result is a circle or ellipse that fits within the
* rectangle specified by the <code>x</code>, <code>y</code>,
* <code>width</code>, and <code>height</code> arguments.
* <p>
* The oval covers an area that is
* <code>width + 1</code> pixels wide
* and <code>height + 1</code> pixels tall.
* @param x the <i>x</i> coordinate of the upper left
* corner of the oval to be drawn.
* @param y the <i>y</i> coordinate of the upper left
* corner of the oval to be drawn.
* @param width the width of the oval to be drawn.
* @param height the height of the oval to be drawn.
* @see java.awt.Graphics#fillOval
*/
public void drawOval(int x, int y, int width, int height) {
Ellipse2D oval = new Ellipse2D.Double(x, y, width, height);
draw(oval);
}
use of java.awt.geom.Ellipse2D in project intellij-community by JetBrains.
the class LabelIcon method paintTag.
public void paintTag(Graphics2D g2, float scale, float x, float y) {
Path2D.Float path = new Path2D.Float();
path.moveTo(x + 1 * scale, y + 2 * scale);
path.lineTo(x + 3 * scale, y + 2 * scale);
path.lineTo(x + 6 * scale, y + 5 * scale);
path.lineTo(x + 4 * scale, y + 7 * scale);
path.lineTo(x + 1 * scale, y + 4 * scale);
path.lineTo(x + 1 * scale, y + 2 * scale);
path.closePath();
Ellipse2D hole = new Ellipse2D.Float(x + 2 * scale, y + 3 * scale, scale, scale);
Area area = new Area(path);
area.subtract(new Area(hole));
g2.fill(area);
}
use of java.awt.geom.Ellipse2D in project processdash by dtuma.
the class OverspentDiscItemRenderer method drawDisc.
@Override
protected void drawDisc(Graphics2D g2, Ellipse2D discShape, Paint discPaint, int item) {
super.drawDisc(g2, discShape, discPaint, item);
Number actualDirectTime = underlyingDataset.getValue(item, PlanVsActualCategoryChartSeries.ACTUAL_DIRECT_TIME_COLUMN_POS);
Number plannedTime = underlyingDataset.getValue(item, PlanVsActualCategoryChartSeries.PLANNED_TIME_COLUMN_POS);
double scale = getScale(discShape, actualDirectTime);
double discWidth = discShape.getWidth();
if (plannedTime.doubleValue() < actualDirectTime.doubleValue()) {
// The task is overspent.
g2.setColor(overspentGradientFill);
// We draw multiple red ellipses to represent the overspent section. The first
// one we draw is as big as the entire disc and the last one has the same
// width as the overspentCircle. The radius of the overspent circle is the
// square root of the task's planned time (multiplied by the scale). To get to
// width, we simply multiply by 2. Since all ellipses are semi-transparent and
// are drawn over each other, this makes a nice gradient effect. Since drawing
// multiple semi-transparent ellipses over each other creates a
// multiplicative alpha blending, we calculate the width of the ellipses in
// a exponential manner, so they are farther apart near the center.
double overspentCircleWidth = (Math.sqrt(plannedTime.doubleValue()) * scale) * 2;
Ellipse2D shape = null;
double width = discWidth;
double x = 0;
double lastX = Math.pow(discWidth - overspentCircleWidth, 1 / EXPONENT);
double increment = lastX / NUM_CIRCLES_OVERSPENT_SECTION;
while (x < lastX + (1 * increment)) {
width = -Math.pow(x, EXPONENT) + discWidth;
shape = getEllipseShape(discShape, width);
g2.fill(shape);
x += increment;
}
// We now draw a smaller disc that represents the planned time for the task
g2.setPaint(discPaint);
shape = getEllipseShape(discShape, overspentCircleWidth);
g2.fill(shape);
// We finally draw the overspent delimitation circle
shape = getEllipseShape(discShape, overspentCircleWidth);
g2.setColor(overspentColor);
g2.setStroke(OVERSPENT_CIRCLE_STROKE);
g2.draw(shape);
}
if (showQuantiles) {
g2.setPaint(QUANTILE_PAINT);
g2.setStroke(QUANTILE_STROKE);
for (int i = 1; i < 4; i++) {
double percent = i / 4.0;
double quantileTime = plannedTime.doubleValue() * percent;
double radius = Math.sqrt(quantileTime) * scale;
double width = radius * 2;
if (width > discWidth)
break;
g2.draw(new Arc2D.Double(discShape.getCenterX() - radius, discShape.getCenterY() - radius, width, width, 90 - QUANTILE_ARC_DEGREES / 2, QUANTILE_ARC_DEGREES, Arc2D.OPEN));
}
}
}
use of java.awt.geom.Ellipse2D in project processdash by dtuma.
the class DiscPlot method drawDiscs.
private void drawDiscs(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info) {
getDiscDistributor().setDiscDataArea(dataArea);
DiscItemRendererState state = getDiscRenderer().initialise(g2, dataArea, this, dataset, info);
for (int item = 0; item < dataset.getItemCount(); item++) {
Ellipse2D discLocation = getDiscDistributor().getDiscLocation(item);
getDiscRenderer().drawItem(g2, state, dataArea, discLocation, info, this, dataset, item);
}
}
use of java.awt.geom.Ellipse2D in project scriptographer by scriptographer.
the class AbstractGraphics2D method fillOval.
/**
* Fills an oval bounded by the specified rectangle with the
* current color.
* @param x the <i>x</i> coordinate of the upper left corner
* of the oval to be filled.
* @param y the <i>y</i> coordinate of the upper left corner
* of the oval to be filled.
* @param width the width of the oval to be filled.
* @param height the height of the oval to be filled.
* @see java.awt.Graphics#drawOval
*/
public void fillOval(int x, int y, int width, int height) {
Ellipse2D oval = new Ellipse2D.Float(x, y, width, height);
fill(oval);
}
Aggregations