java.awt.geom.Arc2D Java Examples

The following examples show how to use java.awt.geom.Arc2D. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PiePlot.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a rectangle that can be used to create a pie section (taking
 * into account the amount by which the pie section is 'exploded').
 *
 * @param unexploded  the area inside which the unexploded pie sections are
 *                    drawn.
 * @param exploded  the area inside which the exploded pie sections are 
 *                  drawn.
 * @param angle  the start angle.
 * @param extent  the extent of the arc.
 * @param explodePercent  the amount by which the pie section is exploded.
 *
 * @return A rectangle that can be used to create a pie section.
 */
protected Rectangle2D getArcBounds(Rectangle2D unexploded, 
                                   Rectangle2D exploded,
                                   double angle, double extent, 
                                   double explodePercent) {

    if (explodePercent == 0.0) {
        return unexploded;
    }
    else {
        Arc2D arc1 = new Arc2D.Double(unexploded, angle, extent / 2, 
                Arc2D.OPEN);
        Point2D point1 = arc1.getEndPoint();
        Arc2D.Double arc2 = new Arc2D.Double(exploded, angle, extent / 2, 
                Arc2D.OPEN);
        Point2D point2 = arc2.getEndPoint();
        double deltaX = (point1.getX() - point2.getX()) * explodePercent;
        double deltaY = (point1.getY() - point2.getY()) * explodePercent;
        return new Rectangle2D.Double(unexploded.getX() - deltaX, 
                unexploded.getY() - deltaY, unexploded.getWidth(), 
                unexploded.getHeight());
    }
}
 
Example #2
Source File: ArcDialFrame.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the shape for the window for this dial.  Some dial layers will
 * request that their drawing be clipped within this window.
 *
 * @param frame  the reference frame (<code>null</code> not permitted).
 *
 * @return The shape of the dial's window.
 */
@Override
public Shape getWindow(Rectangle2D frame) {

    Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame,
            this.innerRadius, this.innerRadius);
    Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame,
            this.outerRadius, this.outerRadius);
    Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle,
            this.extent, Arc2D.OPEN);
    Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle
            + this.extent, -this.extent, Arc2D.OPEN);
    GeneralPath p = new GeneralPath();
    Point2D point1 = inner.getStartPoint();
    p.moveTo((float) point1.getX(), (float) point1.getY());
    p.append(inner, true);
    p.append(outer, true);
    p.closePath();
    return p;

}
 
Example #3
Source File: MeterPlot.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws an arc.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param minValue  the minimum value.
 * @param maxValue  the maximum value.
 * @param paint  the paint.
 * @param stroke  the stroke.
 */
protected void drawArc(Graphics2D g2, Rectangle2D area, double minValue,
                       double maxValue, Paint paint, Stroke stroke) {

    double startAngle = valueToAngle(maxValue);
    double endAngle = valueToAngle(minValue);
    double extent = endAngle - startAngle;

    double x = area.getX();
    double y = area.getY();
    double w = area.getWidth();
    double h = area.getHeight();
    g2.setPaint(paint);
    g2.setStroke(stroke);

    if (paint != null && stroke != null) {
        Arc2D.Double arc = new Arc2D.Double(x, y, w, h, startAngle,
                extent, Arc2D.OPEN);
        g2.setPaint(paint);
        g2.setStroke(stroke);
        g2.draw(arc);
    }

}
 
Example #4
Source File: MeterPlot.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws an arc.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 * @param minValue  the minimum value.
 * @param maxValue  the maximum value.
 * @param paint  the paint.
 * @param stroke  the stroke.
 */
protected void drawArc(Graphics2D g2, Rectangle2D area, double minValue,
                       double maxValue, Paint paint, Stroke stroke) {

    double startAngle = valueToAngle(maxValue);
    double endAngle = valueToAngle(minValue);
    double extent = endAngle - startAngle;

    double x = area.getX();
    double y = area.getY();
    double w = area.getWidth();
    double h = area.getHeight();
    g2.setPaint(paint);
    g2.setStroke(stroke);

    if (paint != null && stroke != null) {
        Arc2D.Double arc = new Arc2D.Double(x, y, w, h, startAngle,
                extent, Arc2D.OPEN);
        g2.setPaint(paint);
        g2.setStroke(stroke);
        g2.draw(arc);
    }

}
 
Example #5
Source File: ArcDialFrame.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the outer window.
 *
 * @param frame  the frame.
 *
 * @return The outer window.
 */
protected Shape getOuterWindow(Rectangle2D frame) {
    double radiusMargin = 0.02;
    double angleMargin = 1.5;
    Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame,
            this.innerRadius - radiusMargin, this.innerRadius
            - radiusMargin);
    Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame,
            this.outerRadius + radiusMargin, this.outerRadius
            + radiusMargin);
    Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle
            - angleMargin, this.extent + 2 * angleMargin, Arc2D.OPEN);
    Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle
            + angleMargin + this.extent, -this.extent - 2 * angleMargin,
            Arc2D.OPEN);
    GeneralPath p = new GeneralPath();
    Point2D point1 = inner.getStartPoint();
    p.moveTo((float) point1.getX(), (float) point1.getY());
    p.append(inner, true);
    p.append(outer, true);
    p.closePath();
    return p;
}
 
Example #6
Source File: MfCmdChord.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Replays the command on the given WmfFile.
 *
 * @param file the meta file.
 */
public void replay( final WmfFile file ) {
  final Graphics2D graph = file.getGraphics2D();
  final Rectangle rec = getBounds();
  final Point start = getStartingIntersection();
  final Point end = getEndingIntersection();

  final Arc2D arc = new Arc2D.Double();
  arc.setArcType( Arc2D.CHORD );
  arc.setFrame( rec.x, rec.y, rec.width, rec.height );
  arc.setAngles( start.x, start.y, end.x, end.y );

  final MfDcState state = file.getCurrentState();

  if ( state.getLogBrush().isVisible() ) {
    state.preparePaint();
    graph.fill( arc );
    state.postPaint();
  }
  if ( state.getLogPen().isVisible() ) {
    state.prepareDraw();
    graph.draw( arc );
    state.postDraw();
  }

}
 
Example #7
Source File: ShipNeedle.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the needle.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param rotate  the rotation point.
 * @param angle  the angle.
 */
@Override
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea,
                          Point2D rotate, double angle) {

    GeneralPath shape = new GeneralPath();
    shape.append(new Arc2D.Double(-9.0, -7.0, 10, 14, 0.0, 25.5,
            Arc2D.OPEN), true);
    shape.append(new Arc2D.Double(0.0, -7.0, 10, 14, 154.5, 25.5,
            Arc2D.OPEN), true);
    shape.closePath();
    getTransform().setToTranslation(plotArea.getMinX(), plotArea.getMaxY());
    getTransform().scale(plotArea.getWidth(), plotArea.getHeight() / 3);
    shape.transform(getTransform());

    if ((rotate != null) && (angle != 0)) {
        /// we have rotation
        getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
        shape.transform(getTransform());
    }

    defaultDisplay(g2, shape);
}
 
Example #8
Source File: ShapeUtilities.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests two shapes for equality.  If both shapes are <code>null</code>,
 * this method will return <code>true</code>.
 * <p>
 * In the current implementation, the following shapes are supported:
 * <code>Ellipse2D</code>, <code>Line2D</code> and <code>Rectangle2D</code>
 * (implicit).
 *
 * @param s1  the first shape (<code>null</code> permitted).
 * @param s2  the second shape (<code>null</code> permitted).
 *
 * @return A boolean.
 */
public static boolean equal(Shape s1, Shape s2) {
    if (s1 instanceof Line2D && s2 instanceof Line2D) {
        return equal((Line2D) s1, (Line2D) s2);
    }
    else if (s1 instanceof Ellipse2D && s2 instanceof Ellipse2D) {
        return equal((Ellipse2D) s1, (Ellipse2D) s2);
    }
    else if (s1 instanceof Arc2D && s2 instanceof Arc2D) {
        return equal((Arc2D) s1, (Arc2D) s2);
    }
    else if (s1 instanceof Polygon && s2 instanceof Polygon) {
        return equal((Polygon) s1, (Polygon) s2);
    }
    else if (s1 instanceof GeneralPath && s2 instanceof GeneralPath) {
        return equal((GeneralPath) s1, (GeneralPath) s2);
    }
    else {
        // this will handle Rectangle2D...
        return ObjectUtilities.equal(s1, s2);
    }
}
 
Example #9
Source File: DialPointer.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the pointer.
 *
 * @param g2  the graphics target.
 * @param plot  the plot.
 * @param frame  the dial's reference frame.
 * @param view  the dial's view.
 */
@Override
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
    Rectangle2D view) {

    g2.setPaint(this.paint);
    g2.setStroke(this.stroke);
    Rectangle2D arcRect = DialPlot.rectangleByRadius(frame,
            this.radius, this.radius);

    double value = plot.getValue(this.datasetIndex);
    DialScale scale = plot.getScaleForDataset(this.datasetIndex);
    double angle = scale.valueToAngle(value);

    Arc2D arc = new Arc2D.Double(arcRect, angle, 0, Arc2D.OPEN);
    Point2D pt = arc.getEndPoint();

    Line2D line = new Line2D.Double(frame.getCenterX(),
            frame.getCenterY(), pt.getX(), pt.getY());
    g2.draw(line);
}
 
Example #10
Source File: ArcDialFrame.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the shape for the window for this dial.  Some dial layers will
 * request that their drawing be clipped within this window.
 *
 * @param frame  the reference frame (<code>null</code> not permitted).
 *
 * @return The shape of the dial's window.
 */
@Override
public Shape getWindow(Rectangle2D frame) {

    Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame,
            this.innerRadius, this.innerRadius);
    Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame,
            this.outerRadius, this.outerRadius);
    Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle,
            this.extent, Arc2D.OPEN);
    Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle
            + this.extent, -this.extent, Arc2D.OPEN);
    GeneralPath p = new GeneralPath();
    Point2D point1 = inner.getStartPoint();
    p.moveTo((float) point1.getX(), (float) point1.getY());
    p.append(inner, true);
    p.append(outer, true);
    p.closePath();
    return p;

}
 
Example #11
Source File: RadialWipeTransition2D.java    From Pixelitor with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Transition2DInstruction[] getInstructions(float progress,
                                                 Dimension size) {

    int multiplier2 = -1;
    if (type == COUNTER_CLOCKWISE) {
        multiplier2 = 1;
    }
    //for a good time, don't make multiplier1 = 0
    int multiplier1 = 0; //multiplier2;
    int k = Math.max(size.width, size.height);
    Area area = new Area(new Arc2D.Double(new Rectangle2D.Double(size.width / 2 - 2 * k, size.height / 2 - 2 * k, k * 4, k * 4),
            90 + multiplier1 * progress * 360, multiplier2 * progress * 360, Arc2D.PIE));
    area.intersect(new Area(new Rectangle(0, 0, size.width, size.height)));

    return new ImageInstruction[]{
            new ImageInstruction(true),
            new ImageInstruction(false, null, area)
    };
}
 
Example #12
Source File: ShipNeedle.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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) {

    GeneralPath shape = new GeneralPath();
    shape.append(new Arc2D.Double(-9.0, -7.0, 10, 14, 0.0, 25.5, 
            Arc2D.OPEN), true);
    shape.append(new Arc2D.Double(0.0, -7.0, 10, 14, 154.5, 25.5, 
            Arc2D.OPEN), true);
    shape.closePath();
    getTransform().setToTranslation(plotArea.getMinX(), plotArea.getMaxY());
    getTransform().scale(plotArea.getWidth(), plotArea.getHeight() / 3);
    shape.transform(getTransform());

    if ((rotate != null) && (angle != 0)) {
        /// we have rotation
        getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
        shape.transform(getTransform());
    }

    defaultDisplay(g2, shape);
}
 
Example #13
Source File: ShipNeedle.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the needle.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * @param rotate  the rotation point.
 * @param angle  the angle.
 */
@Override
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea,
                          Point2D rotate, double angle) {

    GeneralPath shape = new GeneralPath();
    shape.append(new Arc2D.Double(-9.0, -7.0, 10, 14, 0.0, 25.5,
            Arc2D.OPEN), true);
    shape.append(new Arc2D.Double(0.0, -7.0, 10, 14, 154.5, 25.5,
            Arc2D.OPEN), true);
    shape.closePath();
    getTransform().setToTranslation(plotArea.getMinX(), plotArea.getMaxY());
    getTransform().scale(plotArea.getWidth(), plotArea.getHeight() / 3);
    shape.transform(getTransform());

    if ((rotate != null) && (angle != 0)) {
        /// we have rotation
        getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
        shape.transform(getTransform());
    }

    defaultDisplay(g2, shape);
}
 
Example #14
Source File: CompositionGuide.java    From Pixelitor with GNU General Public License v3.0 6 votes vote down vote up
private static void drawSpiral3(Rectangle2D rect, Shape[] arc2D, double arcWidth, double arcHeight) {
    double angle;
    Point2D.Double center;
    angle = 0;
    center = new Point2D.Double(rect.getX() + (rect.getWidth() - arcWidth), rect.getY());

    for (int i = 0; i < NUM_SPIRAL_SEGMENTS; i++) {
        arc2D[i] = new Arc2D.Double(
            center.getX() - arcWidth,
            center.getY() - arcHeight,
            arcWidth * 2,
            arcHeight * 2,
            angle,
            -90,
            Arc2D.OPEN);

        angle -= 90;
        arcWidth = arcWidth / GOLDEN_RATIO;
        arcHeight = arcHeight / GOLDEN_RATIO;
        center.setLocation(
            center.getX() + Math.sin(Math.toRadians(90 - angle)) * arcWidth / GOLDEN_RATIO,
            center.getY() + Math.sin(Math.toRadians(0 - angle)) * arcHeight / GOLDEN_RATIO
        );
    }
}
 
Example #15
Source File: PiePlot.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns a rectangle that can be used to create a pie section (taking
 * into account the amount by which the pie section is 'exploded').
 *
 * @param unexploded  the area inside which the unexploded pie sections are
 *                    drawn.
 * @param exploded  the area inside which the exploded pie sections are 
 *                  drawn.
 * @param angle  the start angle.
 * @param extent  the extent of the arc.
 * @param explodePercent  the amount by which the pie section is exploded.
 *
 * @return A rectangle that can be used to create a pie section.
 */
protected Rectangle2D getArcBounds(Rectangle2D unexploded, 
                                   Rectangle2D exploded,
                                   double angle, double extent, 
                                   double explodePercent) {

    if (explodePercent == 0.0) {
        return unexploded;
    }
    else {
        Arc2D arc1 = new Arc2D.Double(unexploded, angle, extent / 2, 
                Arc2D.OPEN);
        Point2D point1 = arc1.getEndPoint();
        Arc2D.Double arc2 = new Arc2D.Double(exploded, angle, extent / 2, 
                Arc2D.OPEN);
        Point2D point2 = arc2.getEndPoint();
        double deltaX = (point1.getX() - point2.getX()) * explodePercent;
        double deltaY = (point1.getY() - point2.getY()) * explodePercent;
        return new Rectangle2D.Double(unexploded.getX() - deltaX, 
                unexploded.getY() - deltaY, unexploded.getWidth(), 
                unexploded.getHeight());
    }
}
 
Example #16
Source File: SpotImagePanel.java    From orbit-image-analysis with GNU General Public License v3.0 6 votes vote down vote up
protected SpotPos detectSpot(double x, double y) {
    Arc2D.Double arc;
    x -= iOffsX;
    y -= iOffsY;
    x /= scale;
    y /= scale;
    Point p;

    if (SpotImagePanel.this.spotPosList != null && SpotImagePanel.this.spotPosList.size() > 0) {
        for (SpotPos sp : SpotImagePanel.this.spotPosList) {
            p = sp.getPos();
            arc = new Arc2D.Double(p.x - SpotImagePanel.this.radius, p.y - SpotImagePanel.this.radius, SpotImagePanel.this.radius * 2, SpotImagePanel.this.radius * 2, 0, 360, Arc2D.CHORD);
            if (arc.contains(new Point((int) x, (int) y))) {
                return sp;
            }

        }
    }
    return null;
}
 
Example #17
Source File: RadialWipeTransition2D.java    From pumpernickel with MIT License 6 votes vote down vote up
@Override
public Transition2DInstruction[] getInstructions(float progress,
		Dimension size) {

	int multiplier2 = -1;
	if (type == COUNTER_CLOCKWISE)
		multiplier2 = 1;
	// for a good time, don't make multiplier1 = 0
	int multiplier1 = 0; // multiplier2;
	int k = Math.max(size.width, size.height);
	Area area = new Area(new Arc2D.Double(new Rectangle2D.Double(size.width
			/ 2 - 2 * k, size.height / 2 - 2 * k, k * 4, k * 4), 90
			+ multiplier1 * progress * 360, multiplier2 * progress * 360,
			Arc2D.PIE));
	area.intersect(new Area(new Rectangle(0, 0, size.width, size.height)));

	return new ImageInstruction[] { new ImageInstruction(true),
			new ImageInstruction(false, null, area) };
}
 
Example #18
Source File: DialPointer.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the pointer.
 *
 * @param g2  the graphics target.
 * @param plot  the plot.
 * @param frame  the dial's reference frame.
 * @param view  the dial's view.
 */
@Override
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
    Rectangle2D view) {

    g2.setPaint(this.paint);
    g2.setStroke(this.stroke);
    Rectangle2D arcRect = DialPlot.rectangleByRadius(frame,
            this.radius, this.radius);

    double value = plot.getValue(this.datasetIndex);
    DialScale scale = plot.getScaleForDataset(this.datasetIndex);
    double angle = scale.valueToAngle(value);

    Arc2D arc = new Arc2D.Double(arcRect, angle, 0, Arc2D.OPEN);
    Point2D pt = arc.getEndPoint();

    Line2D line = new Line2D.Double(frame.getCenterX(),
            frame.getCenterY(), pt.getX(), pt.getY());
    g2.draw(line);
}
 
Example #19
Source File: ArcDialFrame.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the shape for the window for this dial.  Some dial layers will
 * request that their drawing be clipped within this window.
 *
 * @param frame  the reference frame (<code>null</code> not permitted).
 *
 * @return The shape of the dial's window.
 */
@Override
public Shape getWindow(Rectangle2D frame) {

    Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame,
            this.innerRadius, this.innerRadius);
    Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame,
            this.outerRadius, this.outerRadius);
    Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle,
            this.extent, Arc2D.OPEN);
    Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle
            + this.extent, -this.extent, Arc2D.OPEN);
    GeneralPath p = new GeneralPath();
    Point2D point1 = inner.getStartPoint();
    p.moveTo((float) point1.getX(), (float) point1.getY());
    p.append(inner, true);
    p.append(outer, true);
    p.closePath();
    return p;

}
 
Example #20
Source File: LoopPipe.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void fillArc(SunGraphics2D sg2d,
                    int x, int y, int width, int height,
                    int startAngle, int arcAngle)
{
    sg2d.shapepipe.fill(sg2d, new Arc2D.Float(x, y, width, height,
                                              startAngle, arcAngle,
                                              Arc2D.PIE));
}
 
Example #21
Source File: MinMaxCategoryRenderer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Provides serialization support.
 *
 * @param stream  the input stream.
 *
 * @throws IOException  if there is an I/O error.
 * @throws ClassNotFoundException  if there is a classpath problem.
 */
private void readObject(ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    this.groupStroke = SerialUtilities.readStroke(stream);
    this.groupPaint = SerialUtilities.readPaint(stream);

    this.minIcon = getIcon(new Arc2D.Double(-4, -4, 8, 8, 0, 360,
            Arc2D.OPEN), null, Color.black);
    this.maxIcon = getIcon(new Arc2D.Double(-4, -4, 8, 8, 0, 360,
            Arc2D.OPEN), null, Color.black);
    this.objectIcon = getIcon(new Line2D.Double(-4, 0, 4, 0), false, true);
}
 
Example #22
Source File: BorderRenderer.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Shape getBorderBottomShape() {
  if ( borderShapeBottom != null ) {
    return borderShapeBottom;
  }

  final StaticBoxLayoutProperties sblp = this.staticBoxLayoutProperties;
  final long halfBorderWidth = sblp.getBorderBottom() / 2;
  final long x = this.x;
  final long y = this.y;
  final long w = this.width;
  final long h = this.height;

  final Border border = boxDefinition.getBorder();
  final long bottomLeftWidth = border.getBottomLeft().getWidth();
  final long bottomLeftHeight = border.getBottomLeft().getHeight();
  final long bottomRightWidth = border.getBottomRight().getWidth();
  final long bottomRightHeight = border.getBottomRight().getHeight();

  if ( bottomLeftWidth == 0 && bottomRightWidth == 0 && bottomLeftHeight == 0 && bottomRightHeight == 0 ) {
    // Make a square corner
    final double lineX1 = StrictGeomUtility.toExternalValue( x );
    final double lineX2 = StrictGeomUtility.toExternalValue( x + w );
    final double lineY = StrictGeomUtility.toExternalValue( y + h - halfBorderWidth );
    borderShapeBottom = new Line2D.Double( lineX1, lineY, lineX2, lineY );
    return borderShapeBottom;
  }

  // Make a rounded corner
  final GeneralPath generalPath = new GeneralPath( GeneralPath.WIND_NON_ZERO, 20 );
  generalPath.append( configureArc( x + w - 2 * bottomRightWidth, y + h - 2 * bottomRightHeight,
      2 * bottomRightWidth, 2 * bottomRightHeight, -45, -45, Arc2D.OPEN ), true );
  generalPath.lineTo( (float) ( x + bottomLeftWidth ), (float) ( y + h ) ); // 6
  generalPath.append( configureArc( x, y + h - 2 * bottomLeftHeight, 2 * bottomLeftWidth, 2 * bottomLeftHeight, -90,
      -45, Arc2D.OPEN ), true );
  generalPath.transform( BorderRenderer.scaleInstance );
  borderShapeBottom = generalPath;
  return generalPath;
}
 
Example #23
Source File: BufferedRenderPipe.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void drawArc(SunGraphics2D sg2d,
                    int x, int y, int width, int height,
                    int startAngle, int arcAngle)
{
    draw(sg2d, new Arc2D.Float(x, y, width, height,
                               startAngle, arcAngle,
                               Arc2D.OPEN));
}
 
Example #24
Source File: MinMaxCategoryRenderer.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Provides serialization support.
 *
 * @param stream  the input stream.
 *
 * @throws IOException  if there is an I/O error.
 * @throws ClassNotFoundException  if there is a classpath problem.
 */
private void readObject(ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    this.groupStroke = SerialUtilities.readStroke(stream);
    this.groupPaint = SerialUtilities.readPaint(stream);

    this.minIcon = getIcon(new Arc2D.Double(-4, -4, 8, 8, 0, 360,
            Arc2D.OPEN), null, Color.black);
    this.maxIcon = getIcon(new Arc2D.Double(-4, -4, 8, 8, 0, 360,
            Arc2D.OPEN), null, Color.black);
    this.objectIcon = getIcon(new Line2D.Double(-4, 0, 4, 0), false, true);
}
 
Example #25
Source File: FXGraphics2D.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
private ArcType intToArcType(int t) {
    if (t == Arc2D.CHORD) {
        return ArcType.CHORD;
    } else if (t == Arc2D.OPEN) {
        return ArcType.OPEN;
    } else if (t == Arc2D.PIE) {
        return ArcType.ROUND;
    }
    throw new IllegalArgumentException("Unrecognised t: " + t);
}
 
Example #26
Source File: SpiderWebPlot.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the location for a label
 *
 * @param labelBounds the label bounds.
 * @param ascent the ascent (height of font).
 * @param plotArea the plot area
 * @param startAngle the start angle for the pie series.
 *
 * @return The location for a label.
 */
protected Point2D calculateLabelLocation(Rectangle2D labelBounds,
                                         double ascent,
                                         Rectangle2D plotArea,
                                         double startAngle)
{
    Arc2D arc1 = new Arc2D.Double(plotArea, startAngle, 0, Arc2D.OPEN);
    Point2D point1 = arc1.getEndPoint();

    double deltaX = -(point1.getX() - plotArea.getCenterX())
                    * this.axisLabelGap;
    double deltaY = -(point1.getY() - plotArea.getCenterY())
                    * this.axisLabelGap;

    double labelX = point1.getX() - deltaX;
    double labelY = point1.getY() - deltaY;

    if (labelX < plotArea.getCenterX()) {
        labelX -= labelBounds.getWidth();
    }

    if (labelX == plotArea.getCenterX()) {
        labelX -= labelBounds.getWidth() / 2;
    }

    if (labelY > plotArea.getCenterY()) {
        labelY += ascent;
    }

    return new Point2D.Double(labelX, labelY);
}
 
Example #27
Source File: SpiderWebPlot.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the location for a label
 *
 * @param labelBounds the label bounds.
 * @param ascent the ascent (height of font).
 * @param plotArea the plot area
 * @param startAngle the start angle for the pie series.
 *
 * @return The location for a label.
 */
protected Point2D calculateLabelLocation(Rectangle2D labelBounds,
                                         double ascent,
                                         Rectangle2D plotArea,
                                         double startAngle)
{
    Arc2D arc1 = new Arc2D.Double(plotArea, startAngle, 0, Arc2D.OPEN);
    Point2D point1 = arc1.getEndPoint();

    double deltaX = -(point1.getX() - plotArea.getCenterX())
                    * this.axisLabelGap;
    double deltaY = -(point1.getY() - plotArea.getCenterY())
                    * this.axisLabelGap;

    double labelX = point1.getX() - deltaX;
    double labelY = point1.getY() - deltaY;

    if (labelX < plotArea.getCenterX()) {
        labelX -= labelBounds.getWidth();
    }

    if (labelX == plotArea.getCenterX()) {
        labelX -= labelBounds.getWidth() / 2;
    }

    if (labelY > plotArea.getCenterY()) {
        labelY += ascent;
    }

    return new Point2D.Double(labelX, labelY);
}
 
Example #28
Source File: BufferedRenderPipe.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void drawArc(SunGraphics2D sg2d,
                    int x, int y, int width, int height,
                    int startAngle, int arcAngle)
{
    draw(sg2d, new Arc2D.Float(x, y, width, height,
                               startAngle, arcAngle,
                               Arc2D.OPEN));
}
 
Example #29
Source File: FXGraphics2D.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
private ArcType intToArcType(int t) {
    if (t == Arc2D.CHORD) {
        return ArcType.CHORD;
    } else if (t == Arc2D.OPEN) {
        return ArcType.OPEN;
    } else if (t == Arc2D.PIE) {
        return ArcType.ROUND;
    }
    throw new IllegalArgumentException("Unrecognised t: " + t);
}
 
Example #30
Source File: BufferedRenderPipe.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void fillArc(SunGraphics2D sg2d,
                    int x, int y, int width, int height,
                    int startAngle, int arcAngle)
{
    fill(sg2d, new Arc2D.Float(x, y, width, height,
                               startAngle, arcAngle,
                               Arc2D.PIE));
}