001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.core.gui.base;
019:
020: import java.awt.Color;
021: import java.awt.Component;
022: import java.awt.Graphics;
023:
024: import javax.swing.Icon;
025:
026: public class TriangleSquareWindowsCornerIcon implements Icon {
027:
028: //RGB values discovered using ZoomIn
029: private static final Color THREE_D_EFFECT_COLOR = new Color(255,
030: 255, 255);
031: private static final Color SQUARE_COLOR_LEFT = new Color(184, 180,
032: 163);
033: private static final Color SQUARE_COLOR_TOP_RIGHT = new Color(184,
034: 180, 161);
035: private static final Color SQUARE_COLOR_BOTTOM_RIGHT = new Color(
036: 184, 181, 161);
037:
038: //Dimensions
039: private static final int WIDTH = 12;
040: private static final int HEIGHT = 12;
041:
042: public int getIconHeight() {
043: return WIDTH;
044: }
045:
046: public int getIconWidth() {
047: return HEIGHT;
048: }
049:
050: public void paintIcon(Component c, Graphics g, int x, int y) {
051:
052: //Layout a row and column "grid"
053: int firstRow = 0;
054: int firstColumn = 0;
055: int rowDiff = 4;
056: int columnDiff = 4;
057:
058: int secondRow = firstRow + rowDiff;
059: int secondColumn = firstColumn + columnDiff;
060: int thirdRow = secondRow + rowDiff;
061: int thirdColumn = secondColumn + columnDiff;
062:
063: //Draw the white squares first, so the gray squares will overlap
064: draw3dSquare(g, firstColumn + 1, thirdRow + 1);
065:
066: draw3dSquare(g, secondColumn + 1, secondRow + 1);
067: draw3dSquare(g, secondColumn + 1, thirdRow + 1);
068:
069: draw3dSquare(g, thirdColumn + 1, firstRow + 1);
070: draw3dSquare(g, thirdColumn + 1, secondRow + 1);
071: draw3dSquare(g, thirdColumn + 1, thirdRow + 1);
072:
073: //draw the gray squares overlapping the white background squares
074: drawSquare(g, firstColumn, thirdRow);
075:
076: drawSquare(g, secondColumn, secondRow);
077: drawSquare(g, secondColumn, thirdRow);
078:
079: drawSquare(g, thirdColumn, firstRow);
080: drawSquare(g, thirdColumn, secondRow);
081: drawSquare(g, thirdColumn, thirdRow);
082:
083: }
084:
085: private void draw3dSquare(Graphics g, int x, int y) {
086: Color oldColor = g.getColor(); //cache the old color
087: g.setColor(THREE_D_EFFECT_COLOR); //set the white color
088: g.fillRect(x, y, 2, 2); //draw the square
089: g.setColor(oldColor); //reset the old color
090: }
091:
092: private void drawSquare(Graphics g, int x, int y) {
093: Color oldColor = g.getColor();
094: g.setColor(SQUARE_COLOR_LEFT);
095: g.drawLine(x, y, x, y + 1);
096: g.setColor(SQUARE_COLOR_TOP_RIGHT);
097: g.drawLine(x + 1, y, x + 1, y);
098: g.setColor(SQUARE_COLOR_BOTTOM_RIGHT);
099: g.drawLine(x + 1, y + 1, x + 1, y + 1);
100: g.setColor(oldColor);
101: }
102:
103: }
|