Java Graphics Draw drawDot(Graphics g, int x, int y)

Here you can find the source of drawDot(Graphics g, int x, int y)

Description

draw Dot

License

Open Source License

Declaration

public static void drawDot(Graphics g, int x, int y) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Jay Unruh, Stowers Institute for Medical Research.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 ******************************************************************************/

import java.awt.Graphics;

public class Main {
    public static void drawDot(Graphics g, int x, int y) {
        g.drawLine(x - 1, y - 1, x, y - 1);
        g.drawLine(x - 1, y, x, y);/*from w ww .  j  a  v a2 s . c  o  m*/
    }

    public static void drawLine(Graphics g, int x1, int y1, int x2, int y2,
            boolean thick) {
        if (thick) {
            drawThickLine(g, x1, y1, x2, y2);
        } else {
            g.drawLine(x1, y1, x2, y2);
        }
    }

    public static void drawThickLine(Graphics g, int x1, int y1, int x2,
            int y2) {
        float length = (float) Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1)
                * (y2 - y1));
        float dx = (x2 - x1) / length;
        float dy = (y2 - y1) / length;
        float xpos = x1;
        float ypos = y1;
        for (int i = 0; i < (int) length; i++) {
            drawDot(g, (int) xpos, (int) ypos);
            xpos += dx;
            ypos += dy;
        }
        drawDot(g, x2, y2);
    }
}

Related

  1. drawCross(Graphics2D g2d, int x, int y, int size)
  2. drawCrosshatch(Graphics2D g, Color color, int left, int right, int top, int height, int spacing, int verticalOffset)
  3. drawCube(Graphics g, int x, int y, int w, int h, int d, float fac)
  4. drawDiamond(Graphics2D g2d, int xPos, int yPos)
  5. drawDisc(Graphics g)
  6. drawDots(Graphics g, int x0, int y0, int x1, int y1, int interval)
  7. drawDottedDashLine(Graphics2D g, int x1, int y1, int x2, int y2)
  8. drawDottedRect(Graphics g, int x, int y, int w, int h)
  9. drawDropshipISPip(Graphics2D g2d, int width, int height, int circleSize, int fillCircleSize)