Java Code Examples for java.awt.geom.RoundRectangle2D

The following examples show how to use java.awt.geom.RoundRectangle2D. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: openstock   Source File: FXGraphics2D.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Fills the specified shape with the current {@code paint}.  There is
 * direct handling for {@code RoundRectangle2D}, 
 * {@code Rectangle2D}, {@code Ellipse2D} and {@code Arc2D}.  
 * All other shapes are mapped to a path outline and then filled.
 * 
 * @param s  the shape ({@code null} not permitted). 
 * 
 * @see #draw(java.awt.Shape) 
 */
@Override
public void fill(Shape s) {
    if (s instanceof RoundRectangle2D) {
        RoundRectangle2D rr = (RoundRectangle2D) s;
        this.gc.fillRoundRect(rr.getX(), rr.getY(), rr.getWidth(), 
                rr.getHeight(), rr.getArcWidth(), rr.getArcHeight());
    } else if (s instanceof Rectangle2D) {
        Rectangle2D r = (Rectangle2D) s;
        this.gc.fillRect(r.getX(), r.getY(), r.getWidth(), r.getHeight());
    } else if (s instanceof Ellipse2D) {
        Ellipse2D e = (Ellipse2D) s;
        this.gc.fillOval(e.getX(), e.getY(), e.getWidth(), e.getHeight());
    } else if (s instanceof Arc2D) {
        Arc2D a = (Arc2D) s;
        this.gc.fillArc(a.getX(), a.getY(), a.getWidth(), a.getHeight(), 
                a.getAngleStart(), a.getAngleExtent(), 
                intToArcType(a.getArcType()));
    } else {
        shapeToPath(s);
        this.gc.fill();
    }
}
 
Example 2
Source Project: training   Source File: MyLineBorder.java    License: MIT License 6 votes vote down vote up
/**
 * Paints the border for the specified component with the
 * specified position and size.
 * @param c the component for which this border is being painted
 * @param g the paint graphics
 * @param x the x position of the painted border
 * @param y the y position of the painted border
 * @param width the width of the painted border
 * @param height the height of the painted border
 */
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    if ((this.thickness > 0) && (g instanceof Graphics2D)) {
        Graphics2D g2d = (Graphics2D) g;

        Color oldColor = g2d.getColor();
        g2d.setColor(this.lineColor);

        RoundRectangle2D.Float outer = new RoundRectangle2D.Float(x, y, width, height, radius, radius);
        RoundRectangle2D.Float inner = new RoundRectangle2D.Float(x + thickness, y + thickness, width - thickness * 2, height - thickness * 2, 10, 10);

        Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
        path.append(outer, false);
        path.append(inner, false);
        g2d.fill(path);
        g2d.setColor(oldColor);
    }
}
 
Example 3
Source Project: java-swing-tips   Source File: MainPanel.java    License: MIT License 6 votes vote down vote up
@Override protected void paintComponent(Graphics g) {
  float x = 0f;
  float y = 0f;
  float w = getWidth();
  float h = getHeight();
  Graphics2D g2 = (Graphics2D) g.create();
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  Shape area = new RoundRectangle2D.Float(x, y, w - 1f, h - 1f, R, R);
  Color ssc = TL;
  Color bgc = BR;
  ButtonModel m = getModel();
  if (m.isPressed()) {
    ssc = SB;
    bgc = ST;
  } else if (m.isRollover()) {
    ssc = ST;
    bgc = SB;
  }
  g2.setPaint(new GradientPaint(x, y, ssc, x, y + h, bgc, true));
  g2.fill(area);
  g2.setPaint(BR);
  g2.draw(area);
  g2.dispose();
  super.paintComponent(g);
}
 
Example 4
Source Project: pumpernickel   Source File: SubtleScrollBarUI.java    License: MIT License 6 votes vote down vote up
@Override
protected void paintThumb(Graphics g0, JComponent c, Rectangle thumbBounds) {
	Graphics2D g = (Graphics2D) g0.create();
	int alpha = 60;
	Number rollover = (Number) scrollbar
			.getClientProperty(PROPERTY_ACTIVE_NUMBER);
	if (rollover != null) {
		alpha += (int) (rollover.floatValue() * 60);
	}
	g.setColor(new Color(0, 0, 0, alpha));
	g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);
	int k = thumbWidth;
	g.fill(new RoundRectangle2D.Float(thumbBounds.x + thumbBounds.width / 2
			- thumbWidth / 2, thumbBounds.y, thumbWidth,
			thumbBounds.height, k, k));
	g.dispose();
}
 
Example 5
/**
 * Draws the component border.
 *
 * @param g
 *            the graphics context
 */
public void paintBorder(Graphics g) {
	Shape borderShape;
	int radius = RapidLookAndFeel.CORNER_DEFAULT_RADIUS;
	switch (position) {
		case SwingConstants.LEFT:
			borderShape = new RoundRectangle2D.Double(0, 0, button.getWidth() + radius, button.getHeight() - 1, radius, radius);
			RapidLookTools.drawButtonBorder(button, g, borderShape);
			break;
		case SwingConstants.CENTER:
			borderShape = new Rectangle2D.Double(0, 0, button.getWidth() + radius, button.getHeight() - 1);
			RapidLookTools.drawButtonBorder(button, g, borderShape);
			break;
		default:
			borderShape = new RoundRectangle2D.Double(-radius, 0, button.getWidth() + radius - 1, button.getHeight() - 1, radius, radius);
			RapidLookTools.drawButtonBorder(button, g, borderShape);
			// special case, right button has a left border
			borderShape = new Line2D.Double(0, 0, 0, button.getHeight());
			RapidLookTools.drawButtonBorder(button, g, borderShape);
			break;
	}

}
 
Example 6
/**
 * 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 7
Source Project: appinventor-extensions   Source File: Compiler.java    License: Apache License 2.0 6 votes vote down vote up
private BufferedImage produceRoundedCornerIcon(BufferedImage icon) {
  int imageWidth = icon.getWidth();
  // Ratio of icon size to png image size for roundRect icon is 0.93
  double iconWidth = imageWidth * 0.93;
  // Round iconWidth value to even int for a centered png
  int intIconWidth = ((int)Math.round(iconWidth / 2) * 2);
  Image tmp = icon.getScaledInstance(intIconWidth, intIconWidth, Image.SCALE_SMOOTH);
  int marginWidth = ((imageWidth - intIconWidth) / 2);
  // Corner radius of roundedCornerIcon needs to be 1/12 of width according to Android material guidelines
  float cornerRadius = intIconWidth / 12;
  BufferedImage roundedCornerIcon = new BufferedImage(imageWidth, imageWidth, BufferedImage.TYPE_INT_ARGB);
  Graphics2D g2 = roundedCornerIcon.createGraphics();
  g2.setClip(new RoundRectangle2D.Float(marginWidth, marginWidth, intIconWidth, intIconWidth, cornerRadius, cornerRadius));
  g2.drawImage(tmp, marginWidth, marginWidth, null);
  return roundedCornerIcon;
}
 
Example 8
Source Project: SikuliX1   Source File: SxButton.java    License: MIT License 6 votes vote down vote up
@Override
public void paintComponent(Graphics g) {
  super.paintComponent(g);
  Graphics2D g2d = (Graphics2D) g;
  Color cb = null;
  if (isMouseOver()) {
    cb = mouseOverColor;
  } else {
    cb = colorFront;
  }
  g2d.setColor(cb);
  RoundRectangle2D roundedRectangle = new RoundRectangle2D.Float(0, 0, getActualWidth() - 1, getActualHeight() - 1, PADDING_X, PADDING_Y);
  g2d.fill(roundedRectangle);
  g2d.setColor(cb);
  g2d.draw(roundedRectangle);
  roundedRectangle = new RoundRectangle2D.Float(1, 1, getActualWidth() - 3, getActualHeight() - 3, PADDING_X, PADDING_Y);
  g2d.setColor(colorFrame);
  g2d.draw(roundedRectangle);
  label.paintComponents(g);
}
 
Example 9
Source Project: netbeans   Source File: AbstractTitledWidget.java    License: Apache License 2.0 6 votes vote down vote up
@org.netbeans.api.annotations.common.SuppressWarnings(" NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
protected final void paintWidget() {
    Rectangle bounds = getClientArea();
    Graphics2D g = getGraphics();
    Paint oldPaint = g.getPaint();
    RoundRectangle2D rect = new RoundRectangle2D.Double(bounds.x + 0.75f,
            bounds.y+ 0.75f, bounds.width - 1.5f, bounds.height - 1.5f, radius, radius);
    if(isExpanded()) {
        int titleHeight = headerWidget.getBounds().height;
        Area titleArea = new Area(rect);
        titleArea.subtract(new Area(new Rectangle(bounds.x,
                bounds.y + titleHeight, bounds.width, bounds.height)));
        g.setPaint(getTitlePaint(titleArea.getBounds()));
        g.fill(titleArea);
        if(isOpaque()) {
            Area bodyArea = new Area(rect);
            bodyArea.subtract(titleArea);
            g.setPaint(getBackground());
            g.fill(bodyArea);
        }
    } else {
        g.setPaint(getTitlePaint(bounds));
        g.fill(rect);
    }
    g.setPaint(oldPaint);
}
 
Example 10
Source Project: java-swing-tips   Source File: MainPanel.java    License: MIT License 6 votes vote down vote up
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  Graphics2D g2 = (Graphics2D) g.create();
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  int r = ARC;
  int w = width - 1;
  int h = height - 1;

  Area round = new Area(new RoundRectangle2D.Double(x, y, w, h, r, r));
  if (c instanceof JPopupMenu) {
    g2.setPaint(c.getBackground());
    g2.fill(round);
  } else {
    Container parent = c.getParent();
    if (Objects.nonNull(parent)) {
      g2.setPaint(parent.getBackground());
      Area corner = new Area(new Rectangle2D.Double(x, y, width, height));
      corner.subtract(round);
      g2.fill(corner);
    }
  }
  g2.setPaint(c.getForeground());
  g2.draw(round);
  g2.dispose();
}
 
Example 11
@Override
public void paintLayout(Graphics2D g) throws Exception {
    RoundRectangle2D roundedRectangle = new RoundRectangle2D.Float(x, y, width, height, width * (radiusPercentW * 0.01f), height * (radiusPercentH * 0.01f));
    if (mask) {
        g.setColor(new Color(0, 0, 0, 0));
        g.setPaintMode();
        g.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR));
        g.fill(roundedRectangle);
    } else {
        g.setColor(Color.decode(hexColor));
        Composite oldComp = g.getComposite();
        g.setPaintMode();
        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity));
        g.fill(roundedRectangle);
        g.setComposite(oldComp);
    }
}
 
Example 12
Source Project: consulo   Source File: DarculaSpinnerUI.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void paint(Graphics g, JComponent c) {
  Graphics2D g2 = (Graphics2D)g.create();
  Rectangle r = new Rectangle(c.getSize());
  JBInsets.removeFrom(r, JBUI.insets(1));

  try {
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);
    g2.translate(r.x, r.y);

    float bw = BW.getFloat();
    float arc = COMPONENT_ARC.getFloat();

    g2.setColor(getBackground());
    g2.fill(new RoundRectangle2D.Float(bw, bw, r.width - bw * 2, r.height - bw * 2, arc, arc));
  }
  finally {
    g2.dispose();
  }
}
 
Example 13
public void drawExpandedSubProcess(String name, GraphicInfo graphicInfo, Boolean isTriggeredByEvent, double scaleFactor) {
  RoundRectangle2D rect = new RoundRectangle2D.Double(graphicInfo.getX(), graphicInfo.getY(), 
      graphicInfo.getWidth(), graphicInfo.getHeight(), 8, 8);
  
  // Use different stroke (dashed)
  if (isTriggeredByEvent) {
    Stroke originalStroke = g.getStroke();
    g.setStroke(EVENT_SUBPROCESS_STROKE);
    g.draw(rect);
    g.setStroke(originalStroke);
  } else {
    Paint originalPaint = g.getPaint();
    g.setPaint(SUBPROCESS_BOX_COLOR);
    g.fill(rect);
    g.setPaint(SUBPROCESS_BORDER_COLOR);
    g.draw(rect);
    g.setPaint(originalPaint);
  }

  if (scaleFactor == 1.0 && name != null && !name.isEmpty()) {
    String text = fitTextToWidth(name, (int) graphicInfo.getWidth());
    g.drawString(text, (int) graphicInfo.getX() + 10, (int) graphicInfo.getY() + 15);
  }
}
 
Example 14
Source Project: lemon   Source File: CustomProcessDiagramGenerator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 绘制任务
 */
protected static void drawTask(int x, int y, int width, int height,
        Graphics2D graphics) {
    RoundRectangle2D rect = new RoundRectangle2D.Double(x, y, width,
            height, OFFSET_TASK, OFFSET_TASK);
    graphics.draw(rect);
}
 
Example 15
Source Project: java-swing-tips   Source File: MainPanel.java    License: MIT License 5 votes vote down vote up
@Override public void paint(Graphics2D g, JComponent c, int w, int h) {
  Graphics2D g2 = (Graphics2D) g.create(0, 0, w, h);
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

  Shape r = new RoundRectangle2D.Double(0d, h - OVERPAINT, w - STROKE_SIZE, h - STROKE_SIZE, ARC, ARC);
  g2.setPaint(TABAREA_BACKGROUND);
  g2.fill(r);
  g2.setColor(TABAREA_BORDER);
  g2.setStroke(new BasicStroke(STROKE_SIZE));
  g2.draw(r);
  g2.dispose();
}
 
Example 16
Source Project: java-swing-tips   Source File: MainPanel.java    License: MIT License 5 votes vote down vote up
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  Graphics2D g2 = (Graphics2D) g.create();
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  if (c instanceof JPopupMenu) {
    g2.clearRect(x, y, width, height);
  }
  double r = ARC;
  double w = width - 1d;
  double h = height - 1d;

  Area round = new Area(new RoundRectangle2D.Double(x, y, w, h, r, r));
  Rectangle b = round.getBounds();
  b.setBounds(b.x, b.y + ARC, b.width, b.height - ARC);
  round.add(new Area(b));

  Container parent = c.getParent();
  if (Objects.nonNull(parent)) {
    g2.setPaint(parent.getBackground());
    Area corner = new Area(new Rectangle2D.Double(x, y, width, height));
    corner.subtract(round);
    g2.fill(corner);
  }

  g2.setPaint(c.getForeground());
  g2.draw(round);
  g2.dispose();
}
 
Example 17
Source Project: java-swing-tips   Source File: MainPanel.java    License: MIT License 5 votes vote down vote up
@Override public void paintIcon(Component c, Graphics g, int x, int y) {
  if (c instanceof AbstractButton) {
    AbstractButton b = (AbstractButton) c;
    // XXX: Insets i = b.getMargin();
    Insets i = b.getInsets();
    int w = c.getWidth();
    int h = c.getHeight();
    width = w - i.left - i.right;
    height = h - i.top - i.bottom;
    Graphics2D g2 = (Graphics2D) g.create();
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    float fx = (float) (x - i.left);
    float fy = (float) (y - i.top);
    Shape area = new RoundRectangle2D.Float(fx, fy, w - 1f, h - 1f, R, R);
    Color ssc = TL;
    Color bgc = BR;
    ButtonModel m = b.getModel();
    if (m.isPressed()) {
      ssc = SB;
      bgc = ST;
    } else if (m.isRollover()) {
      ssc = ST;
      bgc = SB;
    }
    g2.setPaint(new GradientPaint(0f, 0f, ssc, 0f, h, bgc, true));
    g2.fill(area);
    g2.setPaint(BR);
    g2.draw(area);
    g2.dispose();
  }
}
 
Example 18
Source Project: darklaf   Source File: BubbleBorder.java    License: MIT License 5 votes vote down vote up
private Path2D creatPointerShape(final double pointerPad, final double pSize, final double pWidth,
                                 final RoundRectangle2D.Float bubble) {
    final double w = pWidth / 2.0;
    final Path2D pointer = new Path2D.Double(Path2D.WIND_EVEN_ODD);
    double x = bubble.x;
    double y = bubble.y;
    switch (pointerSide) {
        case WEST :
            pointer.moveTo(x, y + pointerPad - w); // Top
            pointer.lineTo(x - pSize, y + pointerPad);
            pointer.lineTo(x, y + pointerPad + w);// bottom
            break;
        case EAST :
            pointer.moveTo(x + bubble.width, y + pointerPad - w);// top
            pointer.lineTo(x + bubble.width + pSize, y + pointerPad);
            pointer.lineTo(x + bubble.width, y + pointerPad + w);// bottom
            break;
        case NORTH :
        case NORTH_WEST :
        case NORTH_EAST :
            pointer.moveTo(x + pointerPad - w, y);// left
            pointer.lineTo(x + pointerPad, y - pSize);
            pointer.lineTo(x + pointerPad + w, y);// right
            break;
        case SOUTH :
        case SOUTH_WEST :
        case SOUTH_EAST :
            pointer.moveTo(x + pointerPad - w, y + bubble.height);// left
            pointer.lineTo(x + pointerPad, y + bubble.height + pSize);
            pointer.lineTo(x + pointerPad + w, y + bubble.height);// right
            break;
        default :
            break;
    }
    pointer.closePath();
    return pointer;
}
 
Example 19
Source Project: weblaf   Source File: WebDecoratedImage.java    License: GNU General Public License v3.0 5 votes vote down vote up
private Shape getBorderShape ( final int x, final int y )
{
    final Dimension ps = getPreferredSize ();
    if ( round > 0 )
    {
        return new RoundRectangle2D.Double ( x + shadeWidth, y + shadeWidth, ps.width - shadeWidth * 2 - 1,
                ps.height - shadeWidth * 2 - 1, round * 2, round * 2 );
    }
    else
    {
        return new Rectangle ( x + shadeWidth, y + shadeWidth, ps.width - shadeWidth * 2 - 1, ps.height - shadeWidth * 2 - 1 );
    }
}
 
Example 20
Source Project: littleluck   Source File: LuckPasswordFieldUI.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * <pre>
 * 初始化边框焦点监听器
 *
 * Initializes the border focus listener
 * <pre>
 *
 * @param c
 */
protected void installFocusListener(JComponent c)
{
    handle = createFocusHandle();

    borderShape = new RoundRectangle2D.Float(0, 0, 0, 0, 8, 8);

    c.addMouseListener(handle);

    c.addFocusListener(handle);
}
 
Example 21
public void fillRoundRect(SunGraphics2D sg2d,
                          int x, int y, int width, int height,
                          int arcWidth, int arcHeight)
{
    fill(sg2d, new RoundRectangle2D.Float(x, y, width, height,
                                          arcWidth, arcHeight));
}
 
Example 22
Source Project: jdk8u-jdk   Source File: BufferedRenderPipe.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void fillRoundRect(SunGraphics2D sg2d,
                          int x, int y, int width, int height,
                          int arcWidth, int arcHeight)
{
    fill(sg2d, new RoundRectangle2D.Float(x, y, width, height,
                                          arcWidth, arcHeight));
}
 
Example 23
Source Project: openjdk-8-source   Source File: LineBorder.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Paints the border for the specified component with the
 * specified position and size.
 * @param c the component for which this border is being painted
 * @param g the paint graphics
 * @param x the x position of the painted border
 * @param y the y position of the painted border
 * @param width the width of the painted border
 * @param height the height of the painted border
 */
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    if ((this.thickness > 0) && (g instanceof Graphics2D)) {
        Graphics2D g2d = (Graphics2D) g;

        Color oldColor = g2d.getColor();
        g2d.setColor(this.lineColor);

        Shape outer;
        Shape inner;

        int offs = this.thickness;
        int size = offs + offs;
        if (this.roundedCorners) {
            int arc = offs + size;
            outer = new RoundRectangle2D.Float(x, y, width, height, arc, arc);
            inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc);
        }
        else {
            outer = new Rectangle2D.Float(x, y, width, height);
            inner = new Rectangle2D.Float(x + offs, y + offs, width - size, height - size);
        }
        Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
        path.append(outer, false);
        path.append(inner, false);
        g2d.fill(path);
        g2d.setColor(oldColor);
    }
}
 
Example 24
Source Project: lemon   Source File: CustomProcessDiagramGenerator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 绘制子流程
 */
protected static void drawSubProcess(int x, int y, int width, int height,
        Graphics2D graphics) {
    RoundRectangle2D rect = new RoundRectangle2D.Double(x + 1, y + 1,
            width - 2, height - 2, OFFSET_SUBPROCESS, OFFSET_SUBPROCESS);
    graphics.draw(rect);
}
 
Example 25
Source Project: pumpernickel   Source File: LargeNavigationPanelUI.java    License: MIT License 5 votes vote down vote up
@Override
public void paint(Graphics g0, JComponent c) {
	Graphics2D g = (Graphics2D) g0.create();
	g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);
	Shape roundRect = new RoundRectangle2D.Float(0, 0, c.getWidth(),
			c.getHeight(), 9, 9);
	g.setColor(new Color(30, 30, 30, 200));
	g.fill(roundRect);
	g.dispose();
}
 
Example 26
public void drawRoundRect(SunGraphics2D sg2d,
                          int x, int y, int width, int height,
                          int arcWidth, int arcHeight)
{
    draw(sg2d, new RoundRectangle2D.Float(x, y, width, height,
                                          arcWidth, arcHeight));
}
 
Example 27
Source Project: pumpernickel   Source File: AquaMultiThumbSliderUI.java    License: MIT License 5 votes vote down vote up
protected Shape getTrackOutline() {
	trackRect = calculateTrackRect();
	float k = 4;
	int z = 3;
	if (slider.getOrientation() == MultiThumbSlider.VERTICAL) {
		return new RoundRectangle2D.Float(trackRect.x, trackRect.y - z,
				trackRect.width, trackRect.height + 2 * z, k, k);
	}
	return new RoundRectangle2D.Float(trackRect.x - z, trackRect.y,
			trackRect.width + 2 * z, trackRect.height, k, k);
}
 
Example 28
/**
 * Creates the default {@link Shape} for the given button.
 *
 * @param b
 *            the button to create the shape for
 * @return the shape instance
 */
public static Shape createShapeForButton(AbstractButton b) {
	int w = b.getWidth();
	int h = b.getHeight();
	boolean circular = Boolean.parseBoolean(String.valueOf(b.getClientProperty(RapidLookTools.PROPERTY_BUTTON_CIRCLE)));

	if (circular) {
		return createCircle(w, h);
	} else {
		return new RoundRectangle2D.Double(1, 1, w - 2, h - 2, RapidLookAndFeel.CORNER_DEFAULT_RADIUS,
				RapidLookAndFeel.CORNER_DEFAULT_RADIUS);
	}
}
 
Example 29
/**
 * Reads the object from the object input stream.
 *
 * @param in the object input stream from where to read the serialized data.
 * @return the generated object.
 * @throws IOException            if reading the stream failed.
 * @throws ClassNotFoundException if serialized object class cannot be found.
 */
public Object readObject( final ObjectInputStream in )
  throws IOException, ClassNotFoundException {
  final double x = in.readDouble();
  final double y = in.readDouble();
  final double w = in.readDouble();
  final double h = in.readDouble();
  final double aw = in.readDouble();
  final double ah = in.readDouble();
  return new RoundRectangle2D.Double( x, y, w, h, aw, ah );
}
 
Example 30
public void drawRoundRect(SunGraphics2D sg2d,
                          int x, int y, int width, int height,
                          int arcWidth, int arcHeight)
{
    draw(sg2d, new RoundRectangle2D.Float(x, y, width, height,
                                          arcWidth, arcHeight));
}