001
002/* ----------------------------------------------------------------------
003 * 
004 * Copyright (c) 2002-2009 The MITRE Corporation
005 * 
006 * Except as permitted below
007 * ALL RIGHTS RESERVED
008 * 
009 * The MITRE Corporation (MITRE) provides this software to you without
010 * charge to use for your internal purposes only. Any copy you make for
011 * such purposes is authorized provided you reproduce MITRE's copyright
012 * designation and this License in any such copy. You may not give or
013 * sell this software to any other party without the prior written
014 * permission of the MITRE Corporation.
015 * 
016 * The government of the United States of America may make unrestricted
017 * use of this software.
018 * 
019 * This software is the copyright work of MITRE. No ownership or other
020 * proprietary interest in this software is granted you other than what
021 * is granted in this license.
022 * 
023 * Any modification or enhancement of this software must inherit this
024 * license, including its warranty disclaimers. You hereby agree to
025 * provide to MITRE, at no charge, a copy of any such modification or
026 * enhancement without limitation.
027 * 
028 * MITRE IS PROVIDING THE PRODUCT "AS IS" AND MAKES NO WARRANTY, EXPRESS
029 * OR IMPLIED, AS TO THE ACCURACY, CAPABILITY, EFFICIENCY,
030 * MERCHANTABILITY, OR FUNCTIONING OF THIS SOFTWARE AND DOCUMENTATION. IN
031 * NO EVENT WILL MITRE BE LIABLE FOR ANY GENERAL, CONSEQUENTIAL,
032 * INDIRECT, INCIDENTAL, EXEMPLARY OR SPECIAL DAMAGES, EVEN IF MITRE HAS
033 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
034 * 
035 * You accept this software on the condition that you indemnify and hold
036 * harmless MITRE, its Board of Trustees, officers, agents, and
037 * employees, from any and all liability or damages to third parties,
038 * including attorneys' fees, court costs, and other related costs and
039 * expenses, arising out of your use of this software irrespective of the
040 * cause of said liability.
041 * 
042 * The export from the United States or the subsequent reexport of this
043 * software is subject to compliance with United States export control
044 * and munitions control restrictions. You agree that in the event you
045 * seek to export this software you assume full responsibility for
046 * obtaining all necessary export licenses and approvals and for assuring
047 * compliance with applicable reexport restrictions.
048 * 
049 * ----------------------------------------------------------------------
050 * 
051 * NOTICE
052 * 
053 * This software was produced for the U. S. Government
054 * under Contract No. W15P7T-09-C-F600, and is
055 * subject to the Rights in Noncommercial Computer Software
056 * and Noncommercial Computer Software Documentation
057 * Clause 252.227-7014 (JUN 1995).
058 * 
059 * (c) 2009 The MITRE Corporation. All Rights Reserved.
060 * 
061 * ----------------------------------------------------------------------
062 *
063 */
064/*
065 * Copyright (c) 2002-2006 The MITRE Corporation
066 * 
067 * Except as permitted below
068 * ALL RIGHTS RESERVED
069 * 
070 * The MITRE Corporation (MITRE) provides this software to you without
071 * charge to use for your internal purposes only. Any copy you make for
072 * such purposes is authorized provided you reproduce MITRE's copyright
073 * designation and this License in any such copy. You may not give or
074 * sell this software to any other party without the prior written
075 * permission of the MITRE Corporation.
076 * 
077 * The government of the United States of America may make unrestricted
078 * use of this software.
079 * 
080 * This software is the copyright work of MITRE. No ownership or other
081 * proprietary interest in this software is granted you other than what
082 * is granted in this license.
083 * 
084 * Any modification or enhancement of this software must inherit this
085 * license, including its warranty disclaimers. You hereby agree to
086 * provide to MITRE, at no charge, a copy of any such modification or
087 * enhancement without limitation.
088 * 
089 * MITRE IS PROVIDING THE PRODUCT "AS IS" AND MAKES NO WARRANTY, EXPRESS
090 * OR IMPLIED, AS TO THE ACCURACY, CAPABILITY, EFFICIENCY,
091 * MERCHANTABILITY, OR FUNCTIONING OF THIS SOFTWARE AND DOCUMENTATION. IN
092 * NO EVENT WILL MITRE BE LIABLE FOR ANY GENERAL, CONSEQUENTIAL,
093 * INDIRECT, INCIDENTAL, EXEMPLARY OR SPECIAL DAMAGES, EVEN IF MITRE HAS
094 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
095 * 
096 * You accept this software on the condition that you indemnify and hold
097 * harmless MITRE, its Board of Trustees, officers, agents, and
098 * employees, from any and all liability or damages to third parties,
099 * including attorneys' fees, court costs, and other related costs and
100 * expenses, arising out of your use of this software irrespective of the
101 * cause of said liability.
102 * 
103 * The export from the United States or the subsequent reexport of this
104 * software is subject to compliance with United States export control
105 * and munitions control restrictions. You agree that in the event you
106 * seek to export this software you assume full responsibility for
107 * obtaining all necessary export licenses and approvals and for assuring
108 * compliance with applicable reexport restrictions.
109 */
110
111package jmri.util.org.mitre.jawb.swing;
112
113import java.awt.*;
114import javax.swing.*;
115
116/**
117 * @version 1.0 02/26/99
118 */
119public class DetachPanelIcon implements Icon {
120  
121  private static final int WIDTH = 13;
122  private static final int HEIGHT = 13;
123
124  private boolean pressed;
125  private Color highlight;
126  private Color shadow;
127  private Color fill;
128
129  public DetachPanelIcon(boolean isPressedView) {
130    pressed = isPressedView;
131    if (isPressedView) {
132      init( UIManager.getColor("controlDkShadow"),
133            UIManager.getColor("controlLtHighlight"),
134            UIManager.getColor("controlShadow"));
135    } else {
136      init( UIManager.getColor("controlShadow"),
137            UIManager.getColor("controlHighlight"),
138            UIManager.getColor("control"));
139    }
140  }
141  
142  // The following ctor from the original file is never used locally
143  // We're commenting it out, instead of deleting it, because it was present there.
144  // private DetachPanelIcon(Color shadow, Color highlight, Color fill) {
145  //   init(shadow, highlight, fill);
146  //  }
147
148  private void init(Color shadow, Color highlight, Color fill) {
149    this.highlight = highlight;
150    this.shadow = shadow;
151    this.fill = fill;
152  }
153
154  public void paintIcon(Component c, Graphics g, int x, int y) {
155    if (pressed)
156      g.setColor(highlight);
157    else
158      g.setColor(fill);
159    g.drawRect(x,y,WIDTH,HEIGHT); // background
160    
161    g.setColor(highlight);
162    g.drawRect(x+2,y+6,2,4); // main highlight
163    g.setColor(fill);
164    g.fillRect(x+3,y+7,5,3); // main fill
165    g.setColor(shadow);
166    g.drawLine(x+11,y+3,x+11,y+7); // aux shadow
167    g.drawLine(x+5,y+8,x+11,y+8); // aux shadow
168    g.setColor(Color.black);
169    g.drawRect(x+1,y+4,7,6);
170    g.drawLine(x+1,y+5,x+5,y+5); // main frame
171    g.setColor(highlight);
172    g.fillRect(x+5,y+4,5,3); // aux highlight
173    g.setColor(fill);
174    g.fillRect(x+6,y+5,4,2); // aux fill
175    g.setColor(Color.black);
176    g.drawRect(x+4,y+2,6,5);
177    g.drawLine(x+5,y+3,x+10,y+3); // aux frame
178  }
179
180  public int getIconWidth() {
181    return WIDTH;
182  }
183
184  public int getIconHeight() {
185    return HEIGHT;
186  }
187 
188}