Java Graphics Draw drawDottedRect(Graphics g, int x, int y, int w, int h)

Here you can find the source of drawDottedRect(Graphics g, int x, int y, int w, int h)

Description

draw Dotted Rect

License

Open Source License

Declaration

public static void drawDottedRect(Graphics g, int x, int y, int w, int h) 

Method Source Code

//package com.java2s;
/*//from   w  w w .  j  a  v  a2  s.co m
 This file belongs to the Servoy development and deployment environment, Copyright (C) 1997-2010 Servoy BV
    
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU Affero 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 Affero General Public License for more details.
    
 You should have received a copy of the GNU Affero General Public License along
 with this program; if not, see http://www.gnu.org/licenses or write to the Free
 Software Foundation,Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
*/

import java.awt.Graphics;

public class Main {
    public static void drawDottedRect(Graphics g, int x, int y, int w, int h) {
        drawDotLine(g, x, y, x + w, y);
        drawDotLine(g, x + w, y, x + w, y + h);
        drawDotLine(g, x, y + h, x + w, y + h);
        drawDotLine(g, x, y, x, y + h);
    }

    public static void drawDotLine(Graphics g, int x0, int y0, int x1, int y1) {
        drawDots(g, x0, y0, x1, y1, 2);
    }

    public static void drawDots(Graphics g, int x0, int y0, int x1, int y1, int interval) {
        if (y0 == y1) {
            for (int i = x0; i < x1; i += interval) {
                g.drawLine(i, y0, i, y1);
            }
        } else {
            for (int i = y0; i < y1; i += interval) {
                g.drawLine(x0, i, x1, i);
            }
        }
    }
}

Related

  1. drawDiamond(Graphics2D g2d, int xPos, int yPos)
  2. drawDisc(Graphics g)
  3. drawDot(Graphics g, int x, int y)
  4. drawDots(Graphics g, int x0, int y0, int x1, int y1, int interval)
  5. drawDottedDashLine(Graphics2D g, int x1, int y1, int x2, int y2)
  6. drawDropshipISPip(Graphics2D g2d, int width, int height, int circleSize, int fillCircleSize)
  7. drawEdge(Graphics g, int w, int h)
  8. drawEtchedRect(Graphics g, int x, int y, int width, int height, Color shadow, Color darkShadow, Color highlight, Color lightHighlight)
  9. drawFilledBox(Graphics2D g, int x, int y, int width, int height)