Java Draw Round Rectangle drawRoundRect3D(Graphics2D g, int x, int y, int width, int height, int radius)

Here you can find the source of drawRoundRect3D(Graphics2D g, int x, int y, int width, int height, int radius)

Description

draw Round Rect D

License

Open Source License

Declaration

public static void drawRoundRect3D(Graphics2D g, int x, int y, int width, int height, int radius) 

Method Source Code

//package com.java2s;
/*// w ww  . j  av a2s.  com
 * Spirit, a study/biosample management tool for research.
 * Copyright (C) 2018 Idorsia Pharmaceuticals Ltd., Hegenheimermattweg 91,
 * CH-4123 Allschwil, Switzerland.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 * @author Joel Freyss
 */

import java.awt.Graphics2D;

public class Main {
    public static void drawRoundRect3D(Graphics2D g, int x, int y, int width, int height, int radius) {
        height -= 1;
        width -= 1;

        g.drawLine(x + radius, y, x + width - radius, y);
        g.drawLine(x + radius, y + height, x + width - radius, y + height);
        g.drawLine(x, y + radius, x, y + height - radius);
        g.drawLine(x + width, y + radius, x + width, y + height - radius);

        g.drawArc(x, y, radius * 2, radius * 2, 90, 90);
        g.drawArc(x + width - 2 * radius, y, radius * 2, radius * 2, 0, 90);
        g.drawArc(x, y + height - 2 * radius, radius * 2, radius * 2, 180, 90);
        g.drawArc(x + width - 2 * radius, y + height - 2 * radius, radius * 2, radius * 2, 270, 90);
    }
}

Related

  1. drawRoundRect(Graphics g, int x, int y, int w, int h)
  2. drawRoundedRect(Graphics g, int left, int top, int right, int bottom)
  3. drawRoundSelectorCorner(Graphics g, Color outline, Color body, int x, int y, int size)