Java Graphics Draw drawColors(Color[] colors, Graphics g, int x1, int y1, int x2, int y2, int direction)

Here you can find the source of drawColors(Color[] colors, Graphics g, int x1, int y1, int x2, int y2, int direction)

Description

draw Colors

License

Open Source License

Declaration

private static void drawColors(Color[] colors, Graphics g, int x1, int y1, int x2, int y2, int direction) 

Method Source Code


//package com.java2s;
/*/*from w w w  . ja v  a 2s. c  om*/
* @(#)PaintUtils.java  1.0  2008-03-01
*
* Copyright (c) 2008 Jeremy Wood
* E-mail: mickleness@gmail.com
* All rights reserved.
*
* The copyright of this software is owned by Jeremy Wood.
* You may not use, copy or modify this software, except in
* accordance with the license agreement you entered into with
* Jeremy Wood. For details see accompanying license terms.
*/

import java.awt.*;
import javax.swing.*;

public class Main {
    private static void drawColors(Color[] colors, Graphics g, int x1, int y1, int x2, int y2, int direction) {
        for (int a = 0; a < colors.length; a++) {
            g.setColor(colors[colors.length - a - 1]);
            if (direction == SwingConstants.SOUTH) {
                g.drawLine(x1, y1 - a, x2, y2 - a);
            } else if (direction == SwingConstants.NORTH) {
                g.drawLine(x1, y1 + a, x2, y2 + a);
            } else if (direction == SwingConstants.EAST) {
                g.drawLine(x1 - a, y1, x2 - a, y2);
            } else if (direction == SwingConstants.WEST) {
                g.drawLine(x1 + a, y1, x2 + a, y2);
            }
        }
    }
}

Related

  1. drawBubbles(Graphics g, int nCode)
  2. drawChar(char c, int x, int y, Graphics g)
  3. drawChars(JComponent c, Graphics g, char[] data, int offset, int length, int x, int y)
  4. drawCheck(Graphics g, int x, int y)
  5. drawCheckerPattern(Graphics g_, int checkerSize)
  6. drawCoordinateAxes(Graphics2D g, Component comp)
  7. drawCross(Graphics2D g2d, int x, int y, int size)
  8. drawCrosshatch(Graphics2D g, Color color, int left, int right, int top, int height, int spacing, int verticalOffset)
  9. drawCube(Graphics g, int x, int y, int w, int h, int d, float fac)