001: /* ====================================================================
002: * The JRefactory License, Version 1.0
003: *
004: * Copyright (c) 2001 JRefactory. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * 1. Redistributions of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * 2. Redistributions in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in
015: * the documentation and/or other materials provided with the
016: * distribution.
017: *
018: * 3. The end-user documentation included with the redistribution,
019: * if any, must include the following acknowledgment:
020: * "This product includes software developed by the
021: * JRefactory (http://www.sourceforge.org/projects/jrefactory)."
022: * Alternately, this acknowledgment may appear in the software itself,
023: * if and wherever such third-party acknowledgments normally appear.
024: *
025: * 4. The names "JRefactory" must not be used to endorse or promote
026: * products derived from this software without prior written
027: * permission. For written permission, please contact seguin@acm.org.
028: *
029: * 5. Products derived from this software may not be called "JRefactory",
030: * nor may "JRefactory" appear in their name, without prior written
031: * permission of Chris Seguin.
032: *
033: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
034: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
035: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
036: * DISCLAIMED. IN NO EVENT SHALL THE CHRIS SEGUIN OR
037: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
038: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
039: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
040: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
041: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
042: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
043: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
044: * SUCH DAMAGE.
045: * ====================================================================
046: *
047: * This software consists of voluntary contributions made by many
048: * individuals on behalf of JRefactory. For more information on
049: * JRefactory, please see
050: * <http://www.sourceforge.org/projects/jrefactory>.
051: */
052: package org.acm.seguin.ide.common;
053:
054: import java.awt.Color;
055: import java.awt.Font;
056: import java.awt.GridBagLayout;
057: import java.awt.GridBagConstraints;
058: import java.awt.Insets;
059: import javax.swing.JPanel;
060: import javax.swing.JLabel;
061: import org.acm.seguin.uml.UMLLine;
062: import org.acm.seguin.uml.ProtectionIcon;
063: import org.acm.seguin.uml.InterfaceIcon;
064: import org.acm.seguin.uml.ClassIcon;
065:
066: /**
067: * Stores the key for the UML diagram
068: *
069: *@author Chris Seguin
070: *@created October 18, 2001
071: */
072: public class KeyPanel extends JPanel {
073: /**
074: * Constructor for the KeyPanel object
075: */
076: public KeyPanel() {
077: init();
078: }
079:
080: /**
081: * Initializes the panel
082: */
083: private void init() {
084: setLayout(new GridBagLayout());
085: setBackground(Color.white);
086:
087: GridBagConstraints gbc = new GridBagConstraints();
088:
089: JLabel title = new JLabel("Key");
090: title.setFont(new Font("Dialog", Font.BOLD, 14));
091: gbc.gridx = 0;
092: gbc.gridy = 0;
093: gbc.gridwidth = 2;
094: gbc.insets = new Insets(0, 10, 0, 10);
095: add(title, gbc);
096:
097: gbc.gridwidth = 1;
098: gbc.fill = GridBagConstraints.BOTH;
099:
100: ProtectionIcon pi = new ProtectionIcon(8, 8);
101: pi.setProtection(UMLLine.PRIVATE);
102: IconPanel privatePanel = new IconPanel(pi);
103: gbc.gridx = 0;
104: gbc.gridy = 1;
105: add(privatePanel, gbc);
106:
107: JLabel privateLabel = new JLabel("Private Scope", JLabel.LEFT);
108: gbc.gridx = 1;
109: add(privateLabel, gbc);
110:
111: pi = new ProtectionIcon(8, 8);
112: pi.setProtection(UMLLine.DEFAULT);
113: IconPanel packagePanel = new IconPanel(pi);
114: gbc.gridx = 0;
115: gbc.gridy = 2;
116: add(packagePanel, gbc);
117:
118: JLabel packageLabel = new JLabel("Package or Default Scope",
119: JLabel.LEFT);
120: gbc.gridx = 1;
121: add(packageLabel, gbc);
122:
123: pi = new ProtectionIcon(8, 8);
124: pi.setProtection(UMLLine.PROTECTED);
125: IconPanel protectedPanel = new IconPanel(pi);
126: gbc.gridx = 0;
127: gbc.gridy = 3;
128: add(protectedPanel, gbc);
129:
130: JLabel protectedLabel = new JLabel("Protected Scope",
131: JLabel.LEFT);
132: gbc.gridx = 1;
133: add(protectedLabel, gbc);
134:
135: pi = new ProtectionIcon(8, 8);
136: pi.setProtection(UMLLine.PUBLIC);
137: IconPanel publicPanel = new IconPanel(pi);
138: gbc.gridx = 0;
139: gbc.gridy = 4;
140: add(publicPanel, gbc);
141:
142: JLabel publicLabel = new JLabel("Public Scope", JLabel.LEFT);
143: gbc.gridx = 1;
144: add(publicLabel, gbc);
145:
146: ClassIcon ci = new ClassIcon(8, 8);
147: IconPanel classPanel = new IconPanel(ci);
148: gbc.gridx = 0;
149: gbc.gridy = 5;
150: add(classPanel, gbc);
151:
152: JLabel classLabel = new JLabel("Class", JLabel.LEFT);
153: gbc.gridx = 1;
154: add(classLabel, gbc);
155:
156: InterfaceIcon ii = new InterfaceIcon(8, 8);
157: IconPanel interfacePanel = new IconPanel(ii);
158: gbc.gridx = 0;
159: gbc.gridy = 6;
160: add(interfacePanel, gbc);
161:
162: JLabel interfaceLabel = new JLabel("Interface", JLabel.LEFT);
163: gbc.gridx = 1;
164: add(interfaceLabel, gbc);
165:
166: JLabel instanceItem = new JLabel("plain");
167: instanceItem.setFont(new Font("Dialog", Font.PLAIN, 12));
168: gbc.gridx = 0;
169: gbc.gridy = 7;
170: add(instanceItem, gbc);
171:
172: JLabel instanceLabel = new JLabel(
173: "Instance Variable or Method", JLabel.LEFT);
174: gbc.gridx = 1;
175: add(instanceLabel, gbc);
176:
177: JLabel staticItem = new JLabel("bold");
178: staticItem.setFont(new Font("Dialog", Font.BOLD, 12));
179: gbc.gridx = 0;
180: gbc.gridy = 8;
181: add(staticItem, gbc);
182:
183: JLabel staticLabel = new JLabel("Static Variable or Method",
184: JLabel.LEFT);
185: gbc.gridx = 1;
186: add(staticLabel, gbc);
187:
188: JLabel abstractItem = new JLabel("italic");
189: abstractItem.setFont(new Font("Dialog", Font.ITALIC, 12));
190: gbc.gridx = 0;
191: gbc.gridy = 9;
192: add(abstractItem, gbc);
193:
194: JLabel abstractLabel = new JLabel("Abstract Class or Method",
195: JLabel.LEFT);
196: gbc.gridx = 1;
197: add(abstractLabel, gbc);
198: }
199:
200: /**
201: * The main program for the KeyPanel class
202: *
203: *@param args The command line arguments
204: */
205: public static void main(String[] args) {
206: javax.swing.JFrame frame = new javax.swing.JFrame("Key Panel");
207: frame.getContentPane().add(new KeyPanel());
208: frame.pack();
209: frame.setVisible(true);
210: frame.addWindowListener(new ExitOnCloseAdapter());
211: }
212: }
213: // EOF
|