Here you can find the source of drawColors(Color[] colors, Graphics g, int x1, int y1, int x2, int y2, int direction)
private static void drawColors(Color[] colors, Graphics g, int x1, int y1, int x2, int y2, int direction)
//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); } } } }