Java Draw Rectangle drawRectOrOval(Graphics2D g, boolean oval, int arc, int x, int y, int width, int height)

Here you can find the source of drawRectOrOval(Graphics2D g, boolean oval, int arc, int x, int y, int width, int height)

Description

draw Rect Or Oval

License

Apache License

Declaration

private static void drawRectOrOval(Graphics2D g, boolean oval, int arc, int x, int y, int width, int height) 

Method Source Code

//package com.java2s;
/*/*from   w  w w. j  a v  a2  s  . com*/
 * Copyright 2000-2012 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.awt.*;

public class Main {
    private static void drawRectOrOval(Graphics2D g, boolean oval, int arc, int x, int y, int width, int height) {
        if (oval) {
            g.drawOval(x, y, width, height);
        } else {
            if (arc == 0) {
                g.drawRect(x, y, width, height);
            } else {
                g.drawRoundRect(x, y, width, height, arc, arc);
            }
        }
    }
}

Related

  1. drawRect(Graphics g, int left, int top, int width, int height, int lineWidth)
  2. drawRect(Graphics g, int x, int y, int w, int h)
  3. drawRect(Graphics g, int x, int y, int w, int h)
  4. drawRect(Graphics g, Rectangle r)
  5. drawRect(Rectangle r, Graphics2D g)
  6. drawRectPlot(Graphics2D g, int x, int y, int size)
  7. drawRoundRect(Graphics g, int left, int top, int width, int height, int arcWidth, int arcHeight, int lineWidth)
  8. drawThickRect(Graphics g, int x, int y, int w, int h, int d)
  9. drawThickRect(Graphics g, int x, int y, int width, int height, int thickness)