1 package org.columba.core.gui.base; 19 20 import java.awt.Color ; 21 import java.awt.Component ; 22 import java.awt.Graphics ; 23 24 import javax.swing.Icon ; 25 26 public class TriangleSquareWindowsCornerIcon implements Icon { 27 28 private static final Color THREE_D_EFFECT_COLOR = new Color (255, 255, 255); 30 private static final Color SQUARE_COLOR_LEFT = new Color (184, 180, 163); 31 private static final Color SQUARE_COLOR_TOP_RIGHT = new Color (184, 180, 161); 32 private static final Color SQUARE_COLOR_BOTTOM_RIGHT = new Color (184, 181, 161); 33 34 private static final int WIDTH = 12; 36 private static final int HEIGHT = 12; 37 38 39 40 public int getIconHeight() { 41 return WIDTH; 42 } 43 44 public int getIconWidth() { 45 return HEIGHT; 46 } 47 48 public void paintIcon(Component c, Graphics g, int x, int y) { 49 50 int firstRow = 0; 52 int firstColumn = 0; 53 int rowDiff = 4; 54 int columnDiff = 4; 55 56 int secondRow = firstRow + rowDiff; 57 int secondColumn = firstColumn + columnDiff; 58 int thirdRow = secondRow + rowDiff; 59 int thirdColumn = secondColumn + columnDiff; 60 61 62 draw3dSquare(g, firstColumn+1, thirdRow+1); 64 65 draw3dSquare(g, secondColumn+1, secondRow+1); 66 draw3dSquare(g, secondColumn+1, thirdRow+1); 67 68 draw3dSquare(g, thirdColumn+1, firstRow+1); 69 draw3dSquare(g, thirdColumn+1, secondRow+1); 70 draw3dSquare(g, thirdColumn+1, thirdRow+1); 71 72 drawSquare(g, firstColumn, thirdRow); 74 75 drawSquare(g, secondColumn, secondRow); 76 drawSquare(g, secondColumn, thirdRow); 77 78 drawSquare(g, thirdColumn, firstRow); 79 drawSquare(g, thirdColumn, secondRow); 80 drawSquare(g, thirdColumn, thirdRow); 81 82 } 83 84 private void draw3dSquare(Graphics g, int x, int y){ 85 Color oldColor = g.getColor(); g.setColor(THREE_D_EFFECT_COLOR); g.fillRect(x,y,2,2); g.setColor(oldColor); } 90 91 92 private void drawSquare(Graphics g, int x, int y){ 93 Color oldColor = g.getColor(); 94 g.setColor(SQUARE_COLOR_LEFT); 95 g.drawLine(x,y, x,y+1); 96 g.setColor(SQUARE_COLOR_TOP_RIGHT); 97 g.drawLine(x+1,y, x+1,y); 98 g.setColor(SQUARE_COLOR_BOTTOM_RIGHT); 99 g.drawLine(x+1,y+1, x+1,y+1); 100 g.setColor(oldColor); 101 } 102 103 } | Popular Tags |