Java Code Examples for java.awt.geom.Arc2D#setFrame()

The following examples show how to use java.awt.geom.Arc2D#setFrame() . 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: PlumNeedle.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) {

    Arc2D shape = new Arc2D.Double(Arc2D.PIE);
    double radius = plotArea.getHeight();
    double halfX = plotArea.getWidth() / 2;
    double diameter = 2 * radius;

    shape.setFrame(plotArea.getMinX() + halfX - radius ,
                   plotArea.getMinY() - radius,
                   diameter, diameter);
    radius = Math.toDegrees(Math.asin(halfX / radius));
    shape.setAngleStart(270 - radius);
    shape.setAngleExtent(2 * radius);

    Area s = new Area(shape);

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

    defaultDisplay(g2, s);
}
 
Example 2
Source File: PlumNeedle.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) {

    Arc2D shape = new Arc2D.Double(Arc2D.PIE);
    double radius = plotArea.getHeight();
    double halfX = plotArea.getWidth() / 2;
    double diameter = 2 * radius;

    shape.setFrame(plotArea.getMinX() + halfX - radius ,
                   plotArea.getMinY() - radius,
                   diameter, diameter);
    radius = Math.toDegrees(Math.asin(halfX / radius));
    shape.setAngleStart(270 - radius);
    shape.setAngleExtent(2 * radius);

    Area s = new Area(shape);

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

    defaultDisplay(g2, s);
}
 
Example 3
Source File: PlumNeedle.java    From opensim-gui with Apache License 2.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) {

    Arc2D shape = new Arc2D.Double(Arc2D.PIE);
    double radius = plotArea.getHeight();
    double halfX = plotArea.getWidth() / 2;
    double diameter = 2 * radius;

    shape.setFrame(plotArea.getMinX() + halfX - radius ,
                   plotArea.getMinY() - radius,
                   diameter, diameter);
    radius = Math.toDegrees(Math.asin(halfX / radius));
    shape.setAngleStart(270 - radius);
    shape.setAngleExtent(2 * radius);

    Area s = new Area(shape);

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

    defaultDisplay(g2, s);
}
 
Example 4
Source File: MfCmdArc.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 = getScaledBounds();
  final Point start = getScaledStartingIntersection();
  final Point end = getScaledEndingIntersection();

  final Arc2D arc = new Arc2D.Double();
  arc.setArcType( Arc2D.OPEN );
  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 5
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 6
Source File: MfCmdPie.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 = getScaledBounds();
  final Point start = getScaledStartingIntersection();
  final Point end = getScaledEndingIntersection();

  final Arc2D arc = new Arc2D.Double();
  arc.setArcType( Arc2D.PIE );
  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: PlumNeedle.java    From openstock with GNU General Public License v3.0 5 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) {

    Arc2D shape = new Arc2D.Double(Arc2D.PIE);
    double radius = plotArea.getHeight();
    double halfX = plotArea.getWidth() / 2;
    double diameter = 2 * radius;

    shape.setFrame(plotArea.getMinX() + halfX - radius ,
                   plotArea.getMinY() - radius,
                   diameter, diameter);
    radius = Math.toDegrees(Math.asin(halfX / radius));
    shape.setAngleStart(270 - radius);
    shape.setAngleExtent(2 * radius);

    Area s = new Area(shape);

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

    defaultDisplay(g2, s);
}
 
Example 8
Source File: PlumNeedle.java    From ccu-historian with GNU General Public License v3.0 5 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) {

    Arc2D shape = new Arc2D.Double(Arc2D.PIE);
    double radius = plotArea.getHeight();
    double halfX = plotArea.getWidth() / 2;
    double diameter = 2 * radius;

    shape.setFrame(plotArea.getMinX() + halfX - radius ,
                   plotArea.getMinY() - radius,
                   diameter, diameter);
    radius = Math.toDegrees(Math.asin(halfX / radius));
    shape.setAngleStart(270 - radius);
    shape.setAngleExtent(2 * radius);

    Area s = new Area(shape);

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

    defaultDisplay(g2, s);
}
 
Example 9
Source File: PlumNeedle.java    From SIMVA-SoS with Apache License 2.0 5 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) {

    Arc2D shape = new Arc2D.Double(Arc2D.PIE);
    double radius = plotArea.getHeight();
    double halfX = plotArea.getWidth() / 2;
    double diameter = 2 * radius;

    shape.setFrame(plotArea.getMinX() + halfX - radius ,
                   plotArea.getMinY() - radius,
                   diameter, diameter);
    radius = Math.toDegrees(Math.asin(halfX / radius));
    shape.setAngleStart(270 - radius);
    shape.setAngleExtent(2 * radius);

    Area s = new Area(shape);

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

    defaultDisplay(g2, s);
}
 
Example 10
Source File: PlumNeedle.java    From ECG-Viewer with GNU General Public License v2.0 5 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) {

    Arc2D shape = new Arc2D.Double(Arc2D.PIE);
    double radius = plotArea.getHeight();
    double halfX = plotArea.getWidth() / 2;
    double diameter = 2 * radius;

    shape.setFrame(plotArea.getMinX() + halfX - radius ,
                   plotArea.getMinY() - radius,
                   diameter, diameter);
    radius = Math.toDegrees(Math.asin(halfX / radius));
    shape.setAngleStart(270 - radius);
    shape.setAngleExtent(2 * radius);

    Area s = new Area(shape);

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

    defaultDisplay(g2, s);
}
 
Example 11
Source File: PlumNeedle.java    From buffer_bci with GNU General Public License v3.0 5 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) {

    Arc2D shape = new Arc2D.Double(Arc2D.PIE);
    double radius = plotArea.getHeight();
    double halfX = plotArea.getWidth() / 2;
    double diameter = 2 * radius;

    shape.setFrame(plotArea.getMinX() + halfX - radius ,
                   plotArea.getMinY() - radius,
                   diameter, diameter);
    radius = Math.toDegrees(Math.asin(halfX / radius));
    shape.setAngleStart(270 - radius);
    shape.setAngleExtent(2 * radius);

    Area s = new Area(shape);

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

    defaultDisplay(g2, s);
}
 
Example 12
Source File: PlumNeedle.java    From buffer_bci with GNU General Public License v3.0 5 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) {

    Arc2D shape = new Arc2D.Double(Arc2D.PIE);
    double radius = plotArea.getHeight();
    double halfX = plotArea.getWidth() / 2;
    double diameter = 2 * radius;

    shape.setFrame(plotArea.getMinX() + halfX - radius ,
                   plotArea.getMinY() - radius,
                   diameter, diameter);
    radius = Math.toDegrees(Math.asin(halfX / radius));
    shape.setAngleStart(270 - radius);
    shape.setAngleExtent(2 * radius);

    Area s = new Area(shape);

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

    defaultDisplay(g2, s);
}