Java Code Examples for java.awt.geom.RoundRectangle2D#setRoundRect()

The following examples show how to use java.awt.geom.RoundRectangle2D#setRoundRect() . 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: DarkMacScrollBarUI.java    From darklaf with MIT License 6 votes vote down vote up
@Override
protected void paintMaxiThumb(final Graphics2D g, final Rectangle rect) {
    GraphicsContext context = GraphicsUtil.setupStrokePainting(g);
    g.setComposite(COMPOSITE.derive(thumbAlpha));
    boolean horizontal = scrollbar.getOrientation() == JScrollBar.HORIZONTAL;
    int ins = 2;
    int arc = horizontal ? (rect.height - 2 * ins) : (rect.width - 2 * ins);
    RoundRectangle2D roundRect = new RoundRectangle2D.Float();
    roundRect.setRoundRect(rect.x + ins, rect.y + ins,
                           rect.width - 2 * ins, rect.height - 2 * ins, arc, arc);
    g.setColor(getThumbColor());
    g.fill(roundRect);
    g.setColor(getThumbBorderColor());
    g.draw(roundRect);
    context.restore();
}
 
Example 2
Source File: MfCmdRoundRect.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 Dimension dim = getScaledRoundingDim();
  final RoundRectangle2D shape = new RoundRectangle2D.Double();
  shape.setRoundRect( rec.x, rec.y, rec.width, rec.height, dim.width, dim.height );
  final MfDcState state = file.getCurrentState();

  if ( state.getLogBrush().isVisible() ) {
    state.preparePaint();
    graph.fill( shape );
    state.postPaint();
  }
  if ( state.getLogPen().isVisible() ) {
    state.prepareDraw();
    graph.draw( shape );
    state.postDraw();
  }
}
 
Example 3
Source File: DarkSliderUI.java    From darklaf with MIT License 5 votes vote down vote up
private Shape getHorizontalTrackShape(final RoundRectangle2D trackShape) {
    int arc = arcSize;
    int yOff = (trackRect.height / 2) - trackSize / 2;
    int w = trackRect.width;
    if (slider.getComponentOrientation().isLeftToRight()) {
        trackShape.setRoundRect(trackRect.x, trackRect.y + yOff, w, trackSize, arc, arc);
    } else {
        trackShape.setRoundRect(trackRect.x, trackRect.y + yOff, w, trackSize, arc, arc);
    }
    return trackShape;
}
 
Example 4
Source File: DarkSliderUI.java    From darklaf with MIT License 5 votes vote down vote up
private Shape getVerticalTrackShape(final RoundRectangle2D trackShape) {
    int arc = arcSize;
    int xOff = (trackRect.width / 2) - trackSize / 2;
    int h = trackRect.height;
    if (slider.getComponentOrientation().isLeftToRight()) {
        trackShape.setRoundRect(trackRect.x + xOff, trackRect.y, trackSize, h, arc, arc);
    } else {
        trackShape.setRoundRect(trackRect.x + xOff, trackRect.y, trackSize, h, arc, arc);
    }
    return trackShape;
}
 
Example 5
Source File: RoundRectangle2DObjectDescription.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates an object based on this description.
 *
 * @return The object.
 */
public Object createObject() {
  final RoundRectangle2D rect = new RoundRectangle2D.Float();
  final float w = getFloatParameter( "width" );
  final float h = getFloatParameter( "height" );
  final float x = getFloatParameter( "x" );
  final float y = getFloatParameter( "y" );
  final float aw = getFloatParameter( "arcWidth" );
  final float ah = getFloatParameter( "arcHeight" );
  rect.setRoundRect( x, y, w, h, aw, ah );

  return rect;
}