001: /*
002: * ThinInternalFrameBorder.java
003: *
004: * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
019: *
020: */
021:
022: package org.underworldlabs.swing.plaf;
023:
024: import java.awt.Color;
025: import java.awt.Component;
026: import java.awt.Graphics;
027: import java.awt.Insets;
028:
029: import javax.swing.JInternalFrame;
030: import javax.swing.border.AbstractBorder;
031: import javax.swing.plaf.UIResource;
032: import javax.swing.plaf.metal.MetalLookAndFeel;
033:
034: /* ----------------------------------------------------------------------------------
035: * Modified from Java class javax.swing.plaf.metal.MetalBorders.InternalFrameBorder.
036: *
037: * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
038: * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
039: *
040: *----------------------------------------------------------------------------------
041: */
042:
043: /* ----------------------------------------------------------
044: * CVS NOTE: Changes to the CVS repository prior to the
045: * release of version 3.0.0beta1 has meant a
046: * resetting of CVS revision numbers.
047: * ----------------------------------------------------------
048: */
049:
050: /**
051: *
052: * @author Takis Diakoumis
053: * @version $Revision: 1.4 $
054: * @date $Date: 2006/05/14 06:56:07 $
055: */
056: public class ThinInternalFrameBorder extends AbstractBorder implements
057: UIResource {
058:
059: private static final Insets insets = new Insets(3, 3, 3, 3);
060:
061: private static final int corner = 14;
062:
063: public void paintBorder(Component c, Graphics g, int x, int y,
064: int w, int h) {
065:
066: Color background;
067: Color highlight;
068: Color shadow;
069:
070: if (c instanceof JInternalFrame
071: && ((JInternalFrame) c).isSelected()) {
072: background = MetalLookAndFeel.getPrimaryControlDarkShadow();
073: highlight = MetalLookAndFeel.getPrimaryControlShadow();
074: shadow = MetalLookAndFeel.getPrimaryControlInfo();
075: }
076:
077: else {
078: background = MetalLookAndFeel.getControlDarkShadow();
079: highlight = MetalLookAndFeel.getControlShadow();
080: shadow = MetalLookAndFeel.getControlInfo();
081: }
082:
083: g.setColor(background);
084: // Draw outermost lines
085: g.drawLine(1, 0, w - 2, 0);
086: g.drawLine(0, 1, 0, h - 2);
087: g.drawLine(w - 1, 1, w - 1, h - 2);
088: g.drawLine(1, h - 1, w - 2, h - 1);
089:
090: // Draw the bulk of the border
091: for (int i = 1; i < 5; i++) {
092: g.drawRect(x + i, y + i, w - (i * 2) - 1, h - (i * 2) - 1);
093: }
094:
095: if (c instanceof JInternalFrame
096: && ((JInternalFrame) c).isResizable()) {
097: g.setColor(highlight);
098: // Draw the Long highlight lines
099: g.drawLine(corner + 1, 3, w - corner, 3);
100: g.drawLine(3, corner + 1, 3, h - corner);
101: g.drawLine(w - 2, corner + 1, w - 2, h - corner);
102: g.drawLine(corner + 1, h - 2, w - corner, h - 2);
103:
104: g.setColor(shadow);
105: // Draw the Long shadow lines
106: g.drawLine(corner, 2, w - corner - 1, 2);
107: g.drawLine(2, corner, 2, h - corner - 1);
108: g.drawLine(w - 3, corner, w - 3, h - corner - 1);
109: g.drawLine(corner, h - 3, w - corner - 1, h - 3);
110: }
111:
112: }
113:
114: public Insets getBorderInsets(Component c) {
115: return insets;
116: }
117:
118: public Insets getBorderInsets(Component c, Insets newInsets) {
119: newInsets.top = insets.top;
120: newInsets.left = insets.left;
121: newInsets.bottom = insets.bottom;
122: newInsets.right = insets.right;
123: return newInsets;
124: }
125:
126: } // class
|