Java Draw Rectangle drawRectPlot(Graphics2D g, int x, int y, int size)

Here you can find the source of drawRectPlot(Graphics2D g, int x, int y, int size)

Description

Draws a rectangle centered on (x, y)

License

Open Source License

Declaration

public static void drawRectPlot(Graphics2D g, int x, int y, int size) 

Method Source Code


//package com.java2s;
/*/*from w w  w.  j a v  a 2s.  co  m*/
 * Copyright (c) Leuville Objects All Rights Reserved.
 *
 * Leuville Objects MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. Leuville Objects SHALL NOT BE LIABLE FOR
 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */

import java.awt.*;

public class Main {
    /**
     * Draws a rectangle centered on (x, y)
     */
    public static void drawRectPlot(Graphics2D g, int x, int y, int size) {
        g.drawRect(x - size / 2, y - size / 2, size, size);
    }
}

Related

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