1 package edu.psu.geovista.category;
2
3 /***
4 * <p>Title: Studio applications</p>
5 * <p>Description: </p>
6 * <p>Copyright: Copyright (c) 2002</p>
7 * <p>Company: GeoVSITA Center</p>
8 * @author Xiping Dai
9 * @version 1.0
10 */
11
12 import java.awt.*;
13 import javax.swing.*;
14 import java.awt.event.*;
15
16 public class CategoryConcept extends JPanel{
17
18 private BorderLayout allPaneLayout;
19 private JPanel idPane;
20 private GridLayout idPaneLayout;
21 private JPanel conceptDspPane;
22 private GridLayout dspPaneLayout;
23 private JPanel classParametersPane;
24 private GridLayout classParaPaneLayout;
25 private JPanel buttonPane = new JPanel();
26 private Color currentColor;
27
28 private String[] variableNames;
29 private int[] preferedVarID;
30
31
32
33 public CategoryConcept() {
34 super();
35 this.setPreferredSize(new Dimension(100, 200));
36 this.setMinimumSize(new Dimension (100,200));
37 paneInit();
38 }
39
40 public void setPreferedVars(int[] preferedVars){
41 this.preferedVarID = preferedVars;
42 }
43
44 public int[] getPreferedVars(){
45 return this.preferedVarID;
46 }
47
48 private void paneInit(){
49 this.allPaneLayout = new BorderLayout();
50 this.setLayout(this.allPaneLayout);
51 //construct id panel
52 idPaneLayout = new GridLayout(2,2);
53 this.idPane = new JPanel(this.idPaneLayout);
54 JLabel idLabel = new JLabel("Category ID:");
55 JTextField idField = new JTextField (16);
56 JLabel shortNameLabel = new JLabel("Name:");
57 JTextField shortNameField = new JTextField(16);
58 this.idPane.add(idLabel);
59 this.idPane.add(idField);
60 this.idPane.add(shortNameLabel);
61 this.idPane.add(shortNameField);
62 //Construct description panel
63 dspPaneLayout = new GridLayout(3,1);
64 this.conceptDspPane = new JPanel(this.dspPaneLayout);
65 JLabel dspLabel = new JLabel("Description:");
66 JTextArea dspArea = new JTextArea();
67 JPanel indicatedColor = new JPanel(new GridLayout(1,2));
68 JLabel colorLabel = new JLabel("Prefered Color:");
69 final JButton colorButton = new JButton();
70 colorButton.setBackground(Color.lightGray);
71 colorButton.setBorderPainted(true);
72 colorButton.setMargin(new Insets(2,2,2,2));
73 //Now create an editor to encapsulate the button, and
74 //set it up as the editor for all Color cells.
75 //Set up the dialog that the button brings up.
76 final JColorChooser colorChooser = new JColorChooser();
77 currentColor = Color.white;
78 ActionListener okListener = new ActionListener() {
79 public void actionPerformed(ActionEvent e) {
80 currentColor = colorChooser.getColor();
81 colorButton.setBackground(currentColor);
82 }
83 };
84 final JDialog dialog = JColorChooser.createDialog(colorButton,
85 "Pick a Color",
86 true,
87 colorChooser,
88 okListener,
89 null); //XXXDoublecheck this is OK
90
91 //Here's the code that brings up the dialog.
92 colorButton.addActionListener(new ActionListener() {
93 public void actionPerformed(ActionEvent e) {
94 //colorButton.setBackground(currentColor);
95 //colorChooser.setColor(currentColor);
96 //Without the following line, the dialog comes up
97 //in the middle of the screen.
98 dialog.setLocationRelativeTo(colorButton);
99 dialog.show();
100 }
101 });
102 indicatedColor.add(colorLabel);
103 indicatedColor.add(colorButton);
104 this.conceptDspPane.add(dspLabel);
105 this.conceptDspPane.add(dspArea);
106 this.conceptDspPane.add(indicatedColor);
107 //Construct classification preference panel
108 classParaPaneLayout = new GridLayout(6,1);
109 this.classParametersPane = new JPanel(this.classParaPaneLayout);
110 JLabel methodLabel = new JLabel("Application Context:");
111 JTextField methodField = new JTextField(30);
112 JLabel variableLabel = new JLabel("Prefered Classification method:");
113 JTextField variableField = new JTextField(30);
114 JLabel exampleLabel = new JLabel("Examples for This Category:");
115 JTextField exampleField = new JTextField(30);
116 this.classParametersPane.add(methodLabel);
117 this.classParametersPane.add(methodField);
118 this.classParametersPane.add(variableLabel);
119 this.classParametersPane.add(variableField);
120 this.classParametersPane.add(exampleLabel);
121 this.classParametersPane.add(exampleField);
122
123 //add these sub panels to class panel
124 this.add(this.idPane, BorderLayout.NORTH);
125 this.add(this.conceptDspPane, BorderLayout.CENTER);
126 this.add(this.classParametersPane, BorderLayout.SOUTH);
127 this.validate();
128 }
129
130
131 }
This page was automatically generated by Maven