use of java.awt.geom.Arc2D in project android_frameworks_base by crdroidandroid.
the class Path_Delegate method arcTo.
/**
* Append the specified arc to the path as a new contour. If the start of
* the path is different from the path's current last point, then an
* automatic lineTo() is added to connect the current contour to the
* start of the arc. However, if the path is empty, then we call moveTo()
* with the first point of the arc. The sweep angle is tread mod 360.
*
* @param left The left of oval defining shape and size of the arc
* @param top The top of oval defining shape and size of the arc
* @param right The right of oval defining shape and size of the arc
* @param bottom The bottom of oval defining shape and size of the arc
* @param startAngle Starting angle (in degrees) where the arc begins
* @param sweepAngle Sweep angle (in degrees) measured clockwise, treated
* mod 360.
* @param forceMoveTo If true, always begin a new contour with the arc
*/
public void arcTo(float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean forceMoveTo) {
Arc2D arc = new Arc2D.Float(left, top, right - left, bottom - top, -startAngle, -sweepAngle, Arc2D.OPEN);
mPath.append(arc, true);
resetLastPointFromPath();
}
use of java.awt.geom.Arc2D in project knime-core by knime.
the class PiePlotter method setPieSections.
/**
* Calculates the size of all pie sections.
* @param vizModel the {@link PieVizModel} that provides visualisation
* information and the sections
*/
private void setPieSections(final PieVizModel vizModel) {
final Rectangle2D pieArea = vizModel.getPieArea();
final Rectangle2D explodedArea = vizModel.getExplodedArea();
final boolean explode = vizModel.explodeSelectedSections();
// final double explodePercentage = vizModel.getExplodeMargin();
final double totalVal = vizModel.getAbsAggregationValue();
final double arcPerVal = 360 / totalVal;
final AggregationMethod method = vizModel.getAggregationMethod();
final PieHiliteCalculator calculator = vizModel.getCalculator();
final List<PieSectionDataModel> pieSections = vizModel.getSections2Draw();
final int noOfSections = pieSections.size();
double startAngle = 0;
for (int i = 0; i < noOfSections; i++) {
final PieSectionDataModel section = pieSections.get(i);
final double value = Math.abs(section.getAggregationValue(method));
double arcAngle = value * arcPerVal;
// avoid a rounding gap
if (i == noOfSections - 1) {
arcAngle = 360 - startAngle;
}
if (arcAngle < PieVizModel.MINIMUM_ARC_ANGLE) {
LOGGER.debug("Pie section: " + vizModel.createLabel(section) + " angle " + arcAngle + " to small to display." + " Angle updated to set to minimum angle " + PieVizModel.MINIMUM_ARC_ANGLE);
arcAngle = PieVizModel.MINIMUM_ARC_ANGLE;
// skip this section
// section.setPieSection(null, calculator);
// continue;
}
final Rectangle2D bounds;
// explode selected sections
if (explode && section.isSelected()) {
bounds = GeometryUtil.getArcBounds(pieArea, explodedArea, startAngle, arcAngle, 1.0);
} else {
bounds = pieArea;
}
final Arc2D arc = new Arc2D.Double(bounds, startAngle, arcAngle, Arc2D.PIE);
section.setPieSection(arc, calculator);
startAngle += arcAngle;
}
}
use of java.awt.geom.Arc2D in project knime-core by knime.
the class GeometryUtil method calculateSubArc.
/**
* Calculates a sub arc that lies in the given arc.
* @param arc the basic arc
* @param fraction the fraction defines the size of the new arc in
* comparison to the basic arc in percentage 0.9 = 90%
* @return the arc
*/
public static Arc2D calculateSubArc(final Arc2D arc, final double fraction) {
if (arc == null) {
return null;
}
if (fraction < 0 || fraction > 1) {
throw new IllegalArgumentException("Fraction < 0 & > 1");
}
if (fraction <= 0) {
return null;
}
// System.out.println("bounds:\t\t\t" + arc.getBounds());
// System.out.println("bounds2d:\t\t\t" + arc.getBounds2D());
// System.out.println("startPoint:\t\t\t" + arc.getStartPoint());
// System.out.println("endPoint:\t\t\t" + arc.getEndPoint());
// System.out.println("x:\t\t\t" + arc.getX());
// System.out.println("y:\t\t\t" + arc.getY());
// System.out.println("width:\t\t\t" + arc.getWidth());
// System.out.println("height:\t\t\t" + arc.getHeight());
// System.out.println("maxX:\t\t\t" + arc.getMaxX());
// System.out.println("maxY:\t\t\t" + arc.getMaxY());
// System.out.println("minX:\t\t\t" + arc.getMinX());
// System.out.println("minY:\t\t\t" + arc.getMinY());
// System.out.println("centerX:\t\t\t" + arc.getCenterX());
// System.out.println("centerY:\t\t\t" + arc.getCenterY());
// System.out.println("angleExtent:\t\t\t" + arc.getAngleExtent());
// System.out.println("angleStart:\t\t\t" + arc.getAngleStart());
double hiliteExtend = calculatePartialExtent(arc, fraction);
if (hiliteExtend < PieVizModel.MINIMUM_ARC_ANGLE) {
hiliteExtend = PieVizModel.MINIMUM_ARC_ANGLE;
}
final Arc2D hiliteArc = new Arc2D.Double(arc.getBounds(), arc.getAngleStart(), hiliteExtend, Arc2D.PIE);
return hiliteArc;
}
use of java.awt.geom.Arc2D in project knime-core by knime.
the class DrawingUtils method drawArc.
/**
* Draws the outline of the given arc.
* @param g2 the graphic object
* @param arc the arc to draw
* @param paint the filling color or TexturePaint
* @param stroke the {@link Stroke} to use
*/
public static void drawArc(final Graphics2D g2, final Arc2D arc, final Paint paint, final BasicStroke stroke) {
if (arc == null) {
return;
}
final Arc2D outlineArc = calculateBorderArc(arc, stroke);
// save the original settings
final Paint origPaint = g2.getPaint();
final Stroke origStroke = g2.getStroke();
g2.setStroke(stroke);
g2.setPaint(paint);
g2.draw(outlineArc);
// set the old settings
g2.setPaint(origPaint);
g2.setStroke(origStroke);
}
use of java.awt.geom.Arc2D in project knime-core by knime.
the class PieDrawingPane method drawSection.
private void drawSection(final Graphics2D g2, final AggregationModel<? extends Arc2D, ? extends Arc2D> section, final boolean drawOutline) {
if (!section.isPresentable()) {
// skip not presentable sections
return;
}
final Color color = section.getColor();
final Arc2D shape = section.getShape();
final float alpha;
if (section.isSelected()) {
// fill the section
alpha = SELECTED_SECTION_ALPHA;
} else {
alpha = SECTION_ALPHA;
}
// fill the section
DrawingUtils.drawBlock(g2, shape, color, alpha);
// draw the section outline if desired
if (drawOutline) {
DrawingUtils.drawArc(g2, shape, SECTION_OUTLINE_COLOR, SECTION_OUTLINE_STROKE);
}
if (section.supportsHiliting() && section.isHilited() && section.getHiliteShape() != null) {
final Arc2D hiliteShape = section.getHiliteShape();
DrawingUtils.drawArc(g2, hiliteShape, HILITE_OUTLINE_COLOR, HILITE_OUTLINE_STROKE);
}
if (section.isSelected()) {
// fill the section
DrawingUtils.drawOutline(g2, shape, SELECTION_OUTLINE_COLOR, SELECTION_OUTLINE_STROKE);
}
}
Aggregations