Revision 527
org.gvsig.chart/tags/org.gvsig.chart-1.0.93/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/MainContext.java | ||
---|---|---|
1 |
package org.gvsig.chart.main; |
|
2 |
|
|
3 |
import org.gvsig.chart.ChartProperties; |
|
4 |
import org.gvsig.chart.model.DefaultChartDataSet; |
|
5 |
import org.gvsig.chart.model.variables.ObservableUsedChartServices; |
|
6 |
import org.gvsig.tools.observer.Observable; |
|
7 |
import org.gvsig.tools.observer.Observer; |
|
8 |
|
|
9 |
public class MainContext implements Observable{ |
|
10 |
|
|
11 |
private ObservableUsedChartServices<ChartProperties> chartProperties; |
|
12 |
private Main mainDocument; |
|
13 |
private DefaultChartDataSet dataset; |
|
14 |
|
|
15 |
public MainContext(Main main) { |
|
16 |
chartProperties = new ObservableUsedChartServices<ChartProperties>(null); |
|
17 |
mainDocument=main; |
|
18 |
dataset = mainDocument.createDataSet(mainDocument.fields[0],mainDocument.fields[1],mainDocument.fields[2]); |
|
19 |
} |
|
20 |
|
|
21 |
public void addObserver(Observer o) { |
|
22 |
// TODO Auto-generated method stub |
|
23 |
|
|
24 |
} |
|
25 |
|
|
26 |
public void deleteObserver(Observer o) { |
|
27 |
// TODO Auto-generated method stub |
|
28 |
|
|
29 |
} |
|
30 |
|
|
31 |
public void deleteObservers() { |
|
32 |
// TODO Auto-generated method stub |
|
33 |
|
|
34 |
} |
|
35 |
|
|
36 |
public ObservableUsedChartServices<ChartProperties> getChartProperties() { |
|
37 |
return chartProperties; |
|
38 |
} |
|
39 |
|
|
40 |
public Main getMainDocument() { |
|
41 |
return mainDocument; |
|
42 |
} |
|
43 |
|
|
44 |
// public void setDataset(DefaultChartDataSet dataset) { |
|
45 |
// this.dataset = dataset; |
|
46 |
// } |
|
47 |
|
|
48 |
public DefaultChartDataSet getDataset() { |
|
49 |
return dataset; |
|
50 |
} |
|
51 |
|
|
52 |
|
|
53 |
} |
|
0 | 54 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.93/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/DefaultDataPropertiesPanel.java | ||
---|---|---|
1 |
package org.gvsig.chart.main; |
|
2 |
|
|
3 |
import java.awt.GridBagConstraints; |
|
4 |
import java.awt.GridBagLayout; |
|
5 |
import java.awt.Insets; |
|
6 |
import java.awt.event.ActionEvent; |
|
7 |
import java.awt.event.ActionListener; |
|
8 |
import java.util.ArrayList; |
|
9 |
|
|
10 |
import javax.swing.JButton; |
|
11 |
import javax.swing.JComboBox; |
|
12 |
import javax.swing.JLabel; |
|
13 |
import javax.swing.SwingConstants; |
|
14 |
|
|
15 |
import org.gvsig.chart.ChartLocator; |
|
16 |
import org.gvsig.chart.ChartProperties; |
|
17 |
import org.gvsig.chart.lib.spi.ChartServiceManager; |
|
18 |
import org.gvsig.chart.main.panels.ChartUsedFieldPropertiesPanel; |
|
19 |
import org.gvsig.chart.main.utils.ChartJPanel; |
|
20 |
import org.gvsig.chart.model.variables.ObservableUsedChartServices; |
|
21 |
import org.gvsig.chart.model.variables.RequiredField; |
|
22 |
import org.gvsig.chart.swing.ChartSwingLocator; |
|
23 |
import org.gvsig.chart.swing.spi.ChartSwingServiceManager; |
|
24 |
|
|
25 |
public class DefaultDataPropertiesPanel extends ChartJPanel{ |
|
26 |
|
|
27 |
/** |
|
28 |
* |
|
29 |
*/ |
|
30 |
private static final long serialVersionUID = 3973104135478200344L; |
|
31 |
|
|
32 |
private ArrayList<JComboBox> cbos = new ArrayList<JComboBox>(); |
|
33 |
private JButton backButton; |
|
34 |
private JButton FinishButton; |
|
35 |
private JButton cancelButton; |
|
36 |
|
|
37 |
private ChartUsedFieldPropertiesPanel previousPanel; |
|
38 |
private ChartServiceManager serviceManager; |
|
39 |
private ChartSwingServiceManager swingManager; |
|
40 |
|
|
41 |
public DefaultDataPropertiesPanel(ChartProperties props, ChartUsedFieldPropertiesPanel chartUsedFieldPropertiesPanel) { |
|
42 |
|
|
43 |
this.previousPanel = chartUsedFieldPropertiesPanel; |
|
44 |
|
|
45 |
serviceManager = ChartLocator.getServiceManager(); |
|
46 |
swingManager = ChartSwingLocator.getSwingManager(); |
|
47 |
|
|
48 |
GridBagLayout gridBagLayout = new GridBagLayout(); |
|
49 |
setLayout(gridBagLayout); |
|
50 |
|
|
51 |
JLabel lblChartDataDefinition = new JLabel("Chart Data Definition"); |
|
52 |
GridBagConstraints gbc_lblChartDataDefinition = new GridBagConstraints(); |
|
53 |
gbc_lblChartDataDefinition.gridwidth = 4; |
|
54 |
gbc_lblChartDataDefinition.anchor = GridBagConstraints.WEST; |
|
55 |
gbc_lblChartDataDefinition.insets = new Insets(0, 0, 5, 0); |
|
56 |
gbc_lblChartDataDefinition.gridx = 0; |
|
57 |
gbc_lblChartDataDefinition.gridy = 0; |
|
58 |
add(lblChartDataDefinition, gbc_lblChartDataDefinition); |
|
59 |
|
|
60 |
// JLabel lblNewLabel = new JLabel("Tabla"); |
|
61 |
// add(lblNewLabel); |
|
62 |
// JComboBox cboTable = new JComboBox(); |
|
63 |
// add(cboTable); |
|
64 |
|
|
65 |
int i = 0; |
|
66 |
for (i = 0; i < props.getRequiredFields().size(); i++) { |
|
67 |
// RequiredField f = props.getRequiredFields().get(i); |
|
68 |
// JLabel lbl = new JLabel(f.getDescription()); |
|
69 |
// add(lbl); |
|
70 |
// JComboBox cbo = new JComboBox(); |
|
71 |
// cbo.setName("cbo" + f.getName()); |
|
72 |
// cbos.add(cbo); |
|
73 |
// add(cbo); |
|
74 |
|
|
75 |
RequiredField f = props.getRequiredFields().get(i); |
|
76 |
JLabel lblNewLabel = new JLabel(f.getDescription()); |
|
77 |
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints(); |
|
78 |
gbc_lblNewLabel.fill = GridBagConstraints.BOTH; |
|
79 |
gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5); |
|
80 |
gbc_lblNewLabel.gridx = 0; |
|
81 |
gbc_lblNewLabel.gridy = 1+i; |
|
82 |
add(lblNewLabel, gbc_lblNewLabel); |
|
83 |
JComboBox cboTable = new JComboBox(); |
|
84 |
GridBagConstraints gbc_cboTable = new GridBagConstraints(); |
|
85 |
gbc_cboTable.gridwidth = 3; |
|
86 |
gbc_cboTable.insets = new Insets(0, 0, 5, 0); |
|
87 |
gbc_cboTable.fill = GridBagConstraints.BOTH; |
|
88 |
gbc_cboTable.gridx = 1; |
|
89 |
gbc_cboTable.gridy = 1+i; |
|
90 |
add(cboTable, gbc_cboTable); |
|
91 |
|
|
92 |
cbos.add(cboTable); |
|
93 |
} |
|
94 |
|
|
95 |
backButton = new JButton("< Back"); |
|
96 |
backButton.setHorizontalAlignment(SwingConstants.LEFT); |
|
97 |
GridBagConstraints gbc_backButton = new GridBagConstraints(); |
|
98 |
gbc_backButton.anchor = GridBagConstraints.EAST; |
|
99 |
gbc_backButton.insets = new Insets(0, 0, 0, 5); |
|
100 |
gbc_backButton.gridx = 1; |
|
101 |
gbc_backButton.gridy = 3+i; |
|
102 |
add(backButton, gbc_backButton); |
|
103 |
|
|
104 |
FinishButton = new JButton("Finish"); |
|
105 |
GridBagConstraints gbc_FinishButton = new GridBagConstraints(); |
|
106 |
gbc_FinishButton.insets = new Insets(0, 0, 0, 5); |
|
107 |
gbc_FinishButton.gridx = 2; |
|
108 |
gbc_FinishButton.gridy = 3+i; |
|
109 |
add(FinishButton, gbc_FinishButton); |
|
110 |
|
|
111 |
cancelButton = new JButton("Cancel"); |
|
112 |
GridBagConstraints gbc_cancelButton = new GridBagConstraints(); |
|
113 |
gbc_cancelButton.gridx = 3; |
|
114 |
gbc_cancelButton.gridy = 3+i; |
|
115 |
add(cancelButton, gbc_cancelButton); |
|
116 |
|
|
117 |
createButtons(); |
|
118 |
} |
|
119 |
|
|
120 |
private void createButtons(){ |
|
121 |
backButton.addActionListener(new ActionListener() { |
|
122 |
public void actionPerformed(ActionEvent e) { |
|
123 |
backForm(); |
|
124 |
} |
|
125 |
}); |
|
126 |
|
|
127 |
cancelButton.addActionListener(new ActionListener() { |
|
128 |
public void actionPerformed(ActionEvent e) { |
|
129 |
cancelForm(); |
|
130 |
} |
|
131 |
}); |
|
132 |
|
|
133 |
FinishButton.addActionListener(new ActionListener() { |
|
134 |
public void actionPerformed(ActionEvent e) { |
|
135 |
finishForm(); |
|
136 |
} |
|
137 |
}); |
|
138 |
} |
|
139 |
|
|
140 |
private void cancelForm() { |
|
141 |
this.setVisible(false); |
|
142 |
this.getParentWindow().setVisible(false); |
|
143 |
} |
|
144 |
|
|
145 |
private void finishForm() { |
|
146 |
this.setVisible(false); |
|
147 |
this.getParentWindow().setVisible(false); |
|
148 |
|
|
149 |
if(validateValues()){ |
|
150 |
this.getParametersToChartProperties(); |
|
151 |
|
|
152 |
ObservableUsedChartServices<ChartProperties> properties = this.getPreviousPanel().getMainContext().getChartProperties(); |
|
153 |
if(this.getPreviousPanel().getPreviousChartProperties()!=null){ |
|
154 |
int index = properties.indexOf(this.getPreviousPanel().getPreviousChartProperties()); |
|
155 |
if(index != -1){ |
|
156 |
properties.set(index, this.getPreviousPanel().getChartProperties()); |
|
157 |
} |
|
158 |
}else{ |
|
159 |
properties.add(this.getPreviousPanel().getChartProperties()); |
|
160 |
} |
|
161 |
|
|
162 |
// // TODO Provisional |
|
163 |
// try { |
|
164 |
// ChartProperties props_overlay = serviceManager.getChartManager() |
|
165 |
// .createProperties("OverlayChart"); |
|
166 |
// |
|
167 |
// ChartService service_overlay = serviceManager.getChartManager() |
|
168 |
// .createChart(props_overlay); |
|
169 |
// |
|
170 |
// ChartService service_chart = serviceManager.getChartManager() |
|
171 |
// .createChart(this.chartProperties); |
|
172 |
// |
|
173 |
// service_chart.setChartDataSet(((AbstractChart) service_chart).createDataSet()); |
|
174 |
// |
|
175 |
// ArrayList<ChartService> charts = new ArrayList<ChartService>(); |
|
176 |
// charts.add(service_chart); |
|
177 |
// |
|
178 |
// ((OverlayChartProperties) props_overlay).setCharts(charts); |
|
179 |
// |
|
180 |
// ChartSwingPanel panel = swingManager.getChartSwingManager() |
|
181 |
// .createPanel(props_overlay); |
|
182 |
// panel.setChartService(service_overlay); |
|
183 |
// |
|
184 |
// panel.setPreferredSize(new Dimension(800, 400)); |
|
185 |
// swingManager |
|
186 |
// .getChartSwingManager() |
|
187 |
// .getWindowManager() |
|
188 |
// .showWindow(panel, "Chart window", |
|
189 |
// ChartWindowManager.MODE_WINDOW); |
|
190 |
// |
|
191 |
// } catch (ServiceException e) { |
|
192 |
// // TODO Auto-generated catch block |
|
193 |
// e.printStackTrace(); |
|
194 |
// } |
|
195 |
}else{ |
|
196 |
|
|
197 |
} |
|
198 |
|
|
199 |
|
|
200 |
} |
|
201 |
|
|
202 |
/** |
|
203 |
* Check if the values have the correct format |
|
204 |
* @return boolean |
|
205 |
*/ |
|
206 |
private boolean validateValues() { |
|
207 |
// TODO Auto-generated method stub |
|
208 |
return true; |
|
209 |
} |
|
210 |
|
|
211 |
// Rellena el ChartProperties con el contenido de los 2 paneles |
|
212 |
private void getParametersToChartProperties() { |
|
213 |
this.getPreviousPanel().getChartProperties(); |
|
214 |
this.getChartProperties(); |
|
215 |
} |
|
216 |
|
|
217 |
private void backForm() { |
|
218 |
this.setVisible(false); |
|
219 |
this.getParentWindow().setVisible(false); |
|
220 |
|
|
221 |
this.getPreviousPanel().setVisible(true); |
|
222 |
this.getPreviousPanel().getParentWindow().setVisible(true); |
|
223 |
|
|
224 |
} |
|
225 |
|
|
226 |
public void getChartProperties(){ |
|
227 |
ChartProperties chartProperties = this.getPreviousPanel().getChartProperties(); |
|
228 |
for (int i = 0; i < chartProperties.getRequiredFields().size(); i++) { |
|
229 |
RequiredField f = chartProperties.getRequiredFields().get(i); |
|
230 |
JComboBox cbo = cbos.get(i); |
|
231 |
f.setValue(cbo.getSelectedItem().toString()); |
|
232 |
} |
|
233 |
} |
|
234 |
|
|
235 |
public ChartUsedFieldPropertiesPanel getPreviousPanel() { |
|
236 |
return previousPanel; |
|
237 |
} |
|
238 |
} |
|
0 | 239 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.93/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
4 |
<head> |
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
6 |
<title>org.gvsig.construc package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>Construc library testing and demo application.</p> |
|
11 |
|
|
12 |
</body> |
|
13 |
</html> |
|
0 | 14 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.93/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/utils/CheckBoxRenderer.java | ||
---|---|---|
1 |
package org.gvsig.chart.main.utils; |
|
2 |
|
|
3 |
import java.awt.Component; |
|
4 |
|
|
5 |
import javax.swing.JCheckBox; |
|
6 |
import javax.swing.JLabel; |
|
7 |
import javax.swing.JTable; |
|
8 |
import javax.swing.table.TableCellRenderer; |
|
9 |
|
|
10 |
public class CheckBoxRenderer extends JCheckBox implements TableCellRenderer { |
|
11 |
|
|
12 |
/** |
|
13 |
* |
|
14 |
*/ |
|
15 |
private static final long serialVersionUID = 3586418802127664068L; |
|
16 |
|
|
17 |
public CheckBoxRenderer() { |
|
18 |
setHorizontalAlignment(JLabel.CENTER); |
|
19 |
} |
|
20 |
|
|
21 |
public Component getTableCellRendererComponent(JTable table, Object value, |
|
22 |
boolean isSelected, boolean hasFocus, int row, int column) { |
|
23 |
if (isSelected) { |
|
24 |
setForeground(table.getSelectionForeground()); |
|
25 |
//super.setBackground(table.getSelectionBackground()); |
|
26 |
setBackground(table.getSelectionBackground()); |
|
27 |
} else { |
|
28 |
setForeground(table.getForeground()); |
|
29 |
setBackground(table.getBackground()); |
|
30 |
} |
|
31 |
setSelected((value != null && ((Boolean) value).booleanValue())); |
|
32 |
return this; |
|
33 |
} |
|
34 |
} |
|
35 |
|
|
0 | 36 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.93/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/utils/ChartEntry.java | ||
---|---|---|
1 |
package org.gvsig.chart.main.utils; |
|
2 |
|
|
3 |
import javax.swing.ImageIcon; |
|
4 |
|
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.chart.swing.ChartSwingLocator; |
|
7 |
import org.gvsig.chart.swing.spi.panels.ChartServiceTypePanel; |
|
8 |
import org.gvsig.fmap.IconThemeHelper; |
|
9 |
|
|
10 |
/** |
|
11 |
* Clase que define una entrada de la lista de Charts registrados. |
|
12 |
* Contiene el identificador, el nombre, icono y la preview. |
|
13 |
*/ |
|
14 |
public class ChartEntry { |
|
15 |
private final String id; |
|
16 |
private final String title; |
|
17 |
private ImageIcon icon; |
|
18 |
private ImageIcon image; |
|
19 |
|
|
20 |
public ChartEntry(String id, String title) { |
|
21 |
this.id = id; |
|
22 |
this.title = title; |
|
23 |
} |
|
24 |
|
|
25 |
public String getChartType() { |
|
26 |
return id; |
|
27 |
} |
|
28 |
|
|
29 |
public String getChartPanelType() { |
|
30 |
return id + "Panel"; |
|
31 |
} |
|
32 |
|
|
33 |
public String getTitle() { |
|
34 |
return title; |
|
35 |
} |
|
36 |
|
|
37 |
public ImageIcon getIcon() { |
|
38 |
if (icon == null) { |
|
39 |
ChartServiceTypePanel panel = ChartSwingLocator.getSwingManager().getSwingServices().get(this.getChartPanelType()); |
|
40 |
if(panel!=null) |
|
41 |
icon = panel.getChartIcon(); |
|
42 |
} |
|
43 |
if (icon==null) |
|
44 |
icon = IconThemeHelper.getImageIcon("no-chart-icon"); |
|
45 |
return icon; |
|
46 |
} |
|
47 |
|
|
48 |
|
|
49 |
public String toString() { |
|
50 |
return title; |
|
51 |
} |
|
52 |
|
|
53 |
public ImageIcon getExampleImage() { |
|
54 |
if (image == null) { |
|
55 |
ChartServiceTypePanel panel = ChartSwingLocator.getSwingManager().getSwingServices().get(this.getChartPanelType()); |
|
56 |
if(panel!=null) |
|
57 |
image = panel.getChartExample(); |
|
58 |
} |
|
59 |
if (image==null) |
|
60 |
image = IconThemeHelper.getImageIcon("no-chart-example"); |
|
61 |
return image; |
|
62 |
} |
|
63 |
} |
|
0 | 64 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.93/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/utils/ChartCellRenderer.java | ||
---|---|---|
1 |
package org.gvsig.chart.main.utils; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.Component; |
|
5 |
|
|
6 |
import javax.swing.JLabel; |
|
7 |
import javax.swing.JList; |
|
8 |
import javax.swing.JPanel; |
|
9 |
import javax.swing.JTable; |
|
10 |
import javax.swing.ListCellRenderer; |
|
11 |
import javax.swing.table.TableCellRenderer; |
|
12 |
|
|
13 |
|
|
14 |
public class ChartCellRenderer extends JLabel implements ListCellRenderer, TableCellRenderer { |
|
15 |
/** |
|
16 |
* |
|
17 |
*/ |
|
18 |
private static final long serialVersionUID = 1493992436327160367L; |
|
19 |
private final Color HIGHLIGHT_COLOR = new Color(195, 212, 232); |
|
20 |
private JPanel parentPanel; |
|
21 |
|
|
22 |
public ChartCellRenderer(JPanel parentPanel) { |
|
23 |
setOpaque(true); |
|
24 |
setIconTextGap(12); |
|
25 |
this.parentPanel = parentPanel; |
|
26 |
} |
|
27 |
|
|
28 |
public Component getListCellRendererComponent(JList list, Object value, |
|
29 |
int index, boolean isSelected, boolean cellHasFocus) { |
|
30 |
ChartEntry entry = (ChartEntry) value; |
|
31 |
setText(entry.getTitle()); |
|
32 |
setIcon(entry.getIcon()); |
|
33 |
if (isSelected) { |
|
34 |
setBackground(HIGHLIGHT_COLOR); |
|
35 |
setForeground(Color.black); |
|
36 |
} else { |
|
37 |
setBackground(Color.white); |
|
38 |
setForeground(Color.black); |
|
39 |
} |
|
40 |
return this; |
|
41 |
} |
|
42 |
|
|
43 |
public JPanel getParentPanel() { |
|
44 |
return parentPanel; |
|
45 |
} |
|
46 |
|
|
47 |
public Component getTableCellRendererComponent(JTable table, Object value, |
|
48 |
boolean isSelected, boolean arg3, int arg4, int arg5) { |
|
49 |
if(value==null) |
|
50 |
return null; |
|
51 |
ChartEntry entry = (ChartEntry) value; |
|
52 |
setText(entry.getTitle()); |
|
53 |
setIcon(entry.getIcon()); |
|
54 |
if (isSelected) { |
|
55 |
setBackground(HIGHLIGHT_COLOR); |
|
56 |
setForeground(Color.black); |
|
57 |
} else { |
|
58 |
setBackground(Color.white); |
|
59 |
setForeground(Color.black); |
|
60 |
} |
|
61 |
return this; |
|
62 |
} |
|
63 |
} |
|
0 | 64 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.93/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/utils/ChartJDialog.java | ||
---|---|---|
1 |
package org.gvsig.chart.main.utils; |
|
2 |
|
|
3 |
import java.awt.event.ComponentEvent; |
|
4 |
import java.awt.event.ComponentListener; |
|
5 |
|
|
6 |
import javax.swing.JDialog; |
|
7 |
import javax.swing.JPanel; |
|
8 |
|
|
9 |
public class ChartJDialog extends JDialog implements ComponentListener{ |
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
*/ |
|
14 |
private static final long serialVersionUID = -1850855026936065122L; |
|
15 |
|
|
16 |
private ChartJPanel panel; |
|
17 |
|
|
18 |
public ChartJDialog(ChartJPanel panel){ |
|
19 |
this.panel = panel; |
|
20 |
this.panel.setParentWindow(this); |
|
21 |
panel.addComponentListener(this); |
|
22 |
getContentPane().add(panel); |
|
23 |
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); |
|
24 |
setModal(true); |
|
25 |
|
|
26 |
pack(); |
|
27 |
setVisible(true); |
|
28 |
} |
|
29 |
|
|
30 |
public void componentHidden(ComponentEvent e) { |
|
31 |
this.dispose(); |
|
32 |
} |
|
33 |
|
|
34 |
public void componentMoved(ComponentEvent e) { |
|
35 |
// TODO Auto-generated method stub |
|
36 |
|
|
37 |
} |
|
38 |
|
|
39 |
public void componentResized(ComponentEvent e) { |
|
40 |
// TODO Auto-generated method stub |
|
41 |
|
|
42 |
} |
|
43 |
|
|
44 |
public void componentShown(ComponentEvent e) { |
|
45 |
// TODO Auto-generated method stub |
|
46 |
|
|
47 |
} |
|
48 |
|
|
49 |
public JPanel getContentPanel() { |
|
50 |
return panel; |
|
51 |
} |
|
52 |
|
|
53 |
} |
|
0 | 54 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.93/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/utils/ChartJPanel.java | ||
---|---|---|
1 |
package org.gvsig.chart.main.utils; |
|
2 |
|
|
3 |
import javax.swing.JPanel; |
|
4 |
|
|
5 |
public class ChartJPanel extends JPanel{ |
|
6 |
|
|
7 |
/** |
|
8 |
* |
|
9 |
*/ |
|
10 |
private static final long serialVersionUID = 1L; |
|
11 |
private ChartJDialog chartParentWindow; |
|
12 |
|
|
13 |
public void setParentWindow(ChartJDialog jDialog){ |
|
14 |
this.chartParentWindow = jDialog; |
|
15 |
} |
|
16 |
|
|
17 |
public ChartJDialog getParentWindow(){ |
|
18 |
return chartParentWindow; |
|
19 |
} |
|
20 |
} |
|
0 | 21 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.93/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/panels/ChooseWindow.java | ||
---|---|---|
1 |
package org.gvsig.chart.main.panels; |
|
2 |
|
|
3 |
import java.awt.GridBagConstraints; |
|
4 |
import java.awt.GridBagLayout; |
|
5 |
import java.awt.Insets; |
|
6 |
|
|
7 |
import javax.swing.ButtonGroup; |
|
8 |
import javax.swing.JComboBox; |
|
9 |
import javax.swing.JLabel; |
|
10 |
import javax.swing.JPanel; |
|
11 |
import javax.swing.JRadioButton; |
|
12 |
|
|
13 |
public class ChooseWindow extends JPanel{ |
|
14 |
|
|
15 |
private JRadioButton xyPlotChart; |
|
16 |
private JRadioButton barsChart; |
|
17 |
private JRadioButton pieChart; |
|
18 |
|
|
19 |
private JComboBox keysComboBox; |
|
20 |
private JComboBox colsComboBox; |
|
21 |
private JComboBox rowsComboBox; |
|
22 |
|
|
23 |
public String[] fields = {"Compa??a","facturaci?n","n? empleados"}; |
|
24 |
|
|
25 |
public JRadioButton getXyPlotChart() { |
|
26 |
return xyPlotChart; |
|
27 |
} |
|
28 |
|
|
29 |
|
|
30 |
public void setXyPlotChart(JRadioButton xyPlotChart) { |
|
31 |
this.xyPlotChart = xyPlotChart; |
|
32 |
} |
|
33 |
|
|
34 |
|
|
35 |
public JRadioButton getBarsChart() { |
|
36 |
return barsChart; |
|
37 |
} |
|
38 |
|
|
39 |
|
|
40 |
public void setBarsChart(JRadioButton barsChart) { |
|
41 |
this.barsChart = barsChart; |
|
42 |
} |
|
43 |
|
|
44 |
|
|
45 |
public JRadioButton getPieChart() { |
|
46 |
return pieChart; |
|
47 |
} |
|
48 |
|
|
49 |
|
|
50 |
public void setPieChart(JRadioButton pieChart) { |
|
51 |
this.pieChart = pieChart; |
|
52 |
} |
|
53 |
|
|
54 |
|
|
55 |
public JComboBox getKeysComboBox() { |
|
56 |
return keysComboBox; |
|
57 |
} |
|
58 |
|
|
59 |
|
|
60 |
public void setKeysComboBox(JComboBox keysComboBox) { |
|
61 |
this.keysComboBox = keysComboBox; |
|
62 |
} |
|
63 |
|
|
64 |
|
|
65 |
public JComboBox getColsComboBox() { |
|
66 |
return colsComboBox; |
|
67 |
} |
|
68 |
|
|
69 |
|
|
70 |
public void setColsComboBox(JComboBox colsComboBox) { |
|
71 |
this.colsComboBox = colsComboBox; |
|
72 |
} |
|
73 |
|
|
74 |
|
|
75 |
public JComboBox getRowsComboBox() { |
|
76 |
return rowsComboBox; |
|
77 |
} |
|
78 |
|
|
79 |
|
|
80 |
public void setRowsComboBox(JComboBox rowsComboBox) { |
|
81 |
this.rowsComboBox = rowsComboBox; |
|
82 |
} |
|
83 |
|
|
84 |
public ChooseWindow() { |
|
85 |
|
|
86 |
GridBagLayout gridBagLayout = new GridBagLayout(); |
|
87 |
gridBagLayout.columnWidths = new int[]{0, 0, 143, 0, 0}; |
|
88 |
gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
|
89 |
gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE}; |
|
90 |
gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; |
|
91 |
setLayout(gridBagLayout); |
|
92 |
|
|
93 |
JLabel lblChooseYourChart = new JLabel("Choose your chart type:"); |
|
94 |
GridBagConstraints gbc_lblChooseYourChart = new GridBagConstraints(); |
|
95 |
gbc_lblChooseYourChart.anchor = GridBagConstraints.WEST; |
|
96 |
gbc_lblChooseYourChart.gridwidth = 3; |
|
97 |
gbc_lblChooseYourChart.insets = new Insets(0, 0, 5, 0); |
|
98 |
gbc_lblChooseYourChart.gridx = 1; |
|
99 |
gbc_lblChooseYourChart.gridy = 0; |
|
100 |
add(lblChooseYourChart, gbc_lblChooseYourChart); |
|
101 |
|
|
102 |
xyPlotChart = new JRadioButton("XYPlot Chart"); |
|
103 |
xyPlotChart.setSelected(true); |
|
104 |
GridBagConstraints gbc_xyPlotChart = new GridBagConstraints(); |
|
105 |
gbc_xyPlotChart.gridwidth = 3; |
|
106 |
gbc_xyPlotChart.anchor = GridBagConstraints.WEST; |
|
107 |
gbc_xyPlotChart.insets = new Insets(0, 0, 5, 0); |
|
108 |
gbc_xyPlotChart.gridx = 1; |
|
109 |
gbc_xyPlotChart.gridy = 1; |
|
110 |
add(xyPlotChart, gbc_xyPlotChart); |
|
111 |
|
|
112 |
barsChart = new JRadioButton("Bars Chart"); |
|
113 |
GridBagConstraints gbc_barsChart = new GridBagConstraints(); |
|
114 |
gbc_barsChart.gridwidth = 3; |
|
115 |
gbc_barsChart.anchor = GridBagConstraints.WEST; |
|
116 |
gbc_barsChart.insets = new Insets(0, 0, 5, 0); |
|
117 |
gbc_barsChart.gridx = 1; |
|
118 |
gbc_barsChart.gridy = 2; |
|
119 |
add(barsChart, gbc_barsChart); |
|
120 |
|
|
121 |
pieChart = new JRadioButton("Pie Chart"); |
|
122 |
GridBagConstraints gbc_pieChart = new GridBagConstraints(); |
|
123 |
gbc_pieChart.gridwidth = 3; |
|
124 |
gbc_pieChart.insets = new Insets(0, 0, 5, 0); |
|
125 |
gbc_pieChart.anchor = GridBagConstraints.WEST; |
|
126 |
gbc_pieChart.gridx = 1; |
|
127 |
gbc_pieChart.gridy = 3; |
|
128 |
add(pieChart, gbc_pieChart); |
|
129 |
|
|
130 |
ButtonGroup bg = new ButtonGroup(); |
|
131 |
bg.add(xyPlotChart); |
|
132 |
bg.add(barsChart); |
|
133 |
bg.add(pieChart); |
|
134 |
|
|
135 |
JLabel lblSelectTheDataset = new JLabel("Select the dataset values:"); |
|
136 |
GridBagConstraints gbc_lblSelectTheDataset = new GridBagConstraints(); |
|
137 |
gbc_lblSelectTheDataset.anchor = GridBagConstraints.WEST; |
|
138 |
gbc_lblSelectTheDataset.gridwidth = 3; |
|
139 |
gbc_lblSelectTheDataset.insets = new Insets(0, 0, 5, 0); |
|
140 |
gbc_lblSelectTheDataset.gridx = 1; |
|
141 |
gbc_lblSelectTheDataset.gridy = 5; |
|
142 |
add(lblSelectTheDataset, gbc_lblSelectTheDataset); |
|
143 |
|
|
144 |
JLabel lblKeys = new JLabel("keys:"); |
|
145 |
GridBagConstraints gbc_lblKeys = new GridBagConstraints(); |
|
146 |
gbc_lblKeys.insets = new Insets(0, 0, 5, 5); |
|
147 |
gbc_lblKeys.anchor = GridBagConstraints.EAST; |
|
148 |
gbc_lblKeys.gridx = 1; |
|
149 |
gbc_lblKeys.gridy = 6; |
|
150 |
add(lblKeys, gbc_lblKeys); |
|
151 |
|
|
152 |
keysComboBox = new JComboBox(fields); |
|
153 |
GridBagConstraints gbc_keysComboBox = new GridBagConstraints(); |
|
154 |
gbc_keysComboBox.insets = new Insets(0, 0, 5, 5); |
|
155 |
gbc_keysComboBox.fill = GridBagConstraints.HORIZONTAL; |
|
156 |
gbc_keysComboBox.gridx = 2; |
|
157 |
gbc_keysComboBox.gridy = 6; |
|
158 |
add(keysComboBox, gbc_keysComboBox); |
|
159 |
|
|
160 |
JLabel lblColumns = new JLabel("Columns:"); |
|
161 |
GridBagConstraints gbc_lblColumns = new GridBagConstraints(); |
|
162 |
gbc_lblColumns.insets = new Insets(0, 0, 5, 5); |
|
163 |
gbc_lblColumns.anchor = GridBagConstraints.EAST; |
|
164 |
gbc_lblColumns.gridx = 1; |
|
165 |
gbc_lblColumns.gridy = 7; |
|
166 |
add(lblColumns, gbc_lblColumns); |
|
167 |
|
|
168 |
colsComboBox = new JComboBox(fields); |
|
169 |
colsComboBox.setSelectedIndex(1); |
|
170 |
GridBagConstraints gbc_colsComboBox = new GridBagConstraints(); |
|
171 |
gbc_colsComboBox.insets = new Insets(0, 0, 5, 5); |
|
172 |
gbc_colsComboBox.fill = GridBagConstraints.HORIZONTAL; |
|
173 |
gbc_colsComboBox.gridx = 2; |
|
174 |
gbc_colsComboBox.gridy = 7; |
|
175 |
add(colsComboBox, gbc_colsComboBox); |
|
176 |
|
|
177 |
JLabel lblRows = new JLabel("Rows"); |
|
178 |
GridBagConstraints gbc_lblRows = new GridBagConstraints(); |
|
179 |
gbc_lblRows.insets = new Insets(0, 0, 5, 5); |
|
180 |
gbc_lblRows.anchor = GridBagConstraints.EAST; |
|
181 |
gbc_lblRows.gridx = 1; |
|
182 |
gbc_lblRows.gridy = 8; |
|
183 |
add(lblRows, gbc_lblRows); |
|
184 |
|
|
185 |
rowsComboBox = new JComboBox(fields); |
|
186 |
rowsComboBox.setSelectedIndex(2); |
|
187 |
GridBagConstraints gbc_rowsComboBox = new GridBagConstraints(); |
|
188 |
gbc_rowsComboBox.insets = new Insets(0, 0, 5, 5); |
|
189 |
gbc_rowsComboBox.fill = GridBagConstraints.HORIZONTAL; |
|
190 |
gbc_rowsComboBox.gridx = 2; |
|
191 |
gbc_rowsComboBox.gridy = 8; |
|
192 |
add(rowsComboBox, gbc_rowsComboBox); |
|
193 |
} |
|
194 |
|
|
195 |
} |
|
0 | 196 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.93/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/panels/ChartPropertiesPanel.java | ||
---|---|---|
1 |
package org.gvsig.chart.main.panels; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
import java.awt.GridBagConstraints; |
|
5 |
import java.awt.GridBagLayout; |
|
6 |
import java.awt.Insets; |
|
7 |
import java.awt.event.ActionEvent; |
|
8 |
import java.awt.event.ActionListener; |
|
9 |
import java.awt.event.MouseEvent; |
|
10 |
import java.util.ArrayList; |
|
11 |
import java.util.Iterator; |
|
12 |
import java.util.List; |
|
13 |
|
|
14 |
import javax.swing.DefaultListModel; |
|
15 |
import javax.swing.ImageIcon; |
|
16 |
import javax.swing.JButton; |
|
17 |
import javax.swing.JLabel; |
|
18 |
import javax.swing.JList; |
|
19 |
import javax.swing.JPanel; |
|
20 |
import javax.swing.JScrollPane; |
|
21 |
import javax.swing.JTable; |
|
22 |
import javax.swing.ListSelectionModel; |
|
23 |
import javax.swing.event.ListSelectionEvent; |
|
24 |
import javax.swing.event.ListSelectionListener; |
|
25 |
import javax.swing.table.DefaultTableModel; |
|
26 |
|
|
27 |
import org.gvsig.andami.PluginServices; |
|
28 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
29 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
30 |
import org.gvsig.chart.ChartLocator; |
|
31 |
import org.gvsig.chart.ChartProperties; |
|
32 |
import org.gvsig.chart.ChartService; |
|
33 |
import org.gvsig.chart.base.overlay.OverlayChartProperties; |
|
34 |
import org.gvsig.chart.lib.spi.ChartServiceManager; |
|
35 |
import org.gvsig.chart.main.MainContext; |
|
36 |
import org.gvsig.chart.main.utils.ChartCellRenderer; |
|
37 |
import org.gvsig.chart.main.utils.ChartEntry; |
|
38 |
import org.gvsig.chart.main.utils.ChartJDialog; |
|
39 |
import org.gvsig.chart.main.utils.CheckBoxRenderer; |
|
40 |
import org.gvsig.chart.model.DefaultChartDataSet; |
|
41 |
import org.gvsig.chart.model.variables.ObservableUsedChartServices; |
|
42 |
import org.gvsig.chart.swing.ChartSwingLocator; |
|
43 |
import org.gvsig.chart.swing.ChartSwingPanel; |
|
44 |
import org.gvsig.chart.swing.ChartWindowManager; |
|
45 |
import org.gvsig.chart.swing.spi.ChartSwingServiceManager; |
|
46 |
import org.gvsig.fmap.IconThemeHelper; |
|
47 |
import org.gvsig.tools.service.ServiceException; |
|
48 |
import javax.swing.border.LineBorder; |
|
49 |
import java.awt.Color; |
|
50 |
|
|
51 |
public class ChartPropertiesPanel extends JPanel implements IWindow, ActionListener, ListSelectionListener{ |
|
52 |
|
|
53 |
/** |
|
54 |
* |
|
55 |
*/ |
|
56 |
private static final long serialVersionUID = -301224990996378683L; |
|
57 |
private MainContext chartDocument; |
|
58 |
private JButton accept; |
|
59 |
private JButton cancel; |
|
60 |
|
|
61 |
private String selectedChartType = null; |
|
62 |
|
|
63 |
private JPanel panel_chartType = null; |
|
64 |
|
|
65 |
private JLabel previewImageLabel = new JLabel(); |
|
66 |
private JLabel chartOptionsLabel; |
|
67 |
|
|
68 |
private DefaultListModel listModel; |
|
69 |
|
|
70 |
private JButton addButton; |
|
71 |
private JTable table; |
|
72 |
private DefaultTableModel tableModel; |
|
73 |
private JButton editButton; |
|
74 |
private JButton deleteButton; |
|
75 |
|
|
76 |
private ChartPropertiesPanelObserver<ChartProperties> chartPropertiesObserver; |
|
77 |
private JList list; |
|
78 |
private ChartSwingServiceManager swingManager; |
|
79 |
private ChartServiceManager serviceManager; |
|
80 |
private JButton upButton; |
|
81 |
private JButton downButton; |
|
82 |
private JLabel lblChartPreview; |
|
83 |
private JPanel previewPanel; |
|
84 |
|
|
85 |
public ChartPropertiesPanel(MainContext doc) { |
|
86 |
serviceManager = ChartLocator.getServiceManager(); |
|
87 |
swingManager = ChartSwingLocator.getSwingManager(); |
|
88 |
|
|
89 |
chartDocument = doc; |
|
90 |
listModel = getCharts(); |
|
91 |
|
|
92 |
chartPropertiesObserver = new ChartPropertiesPanelObserver<ChartProperties>(this); |
|
93 |
doc.getChartProperties().registerObserver(chartPropertiesObserver); |
|
94 |
|
|
95 |
createMainPanel(); |
|
96 |
createButtonPanelEvents(); |
|
97 |
|
|
98 |
initializeChartList(); |
|
99 |
initialize(); |
|
100 |
} |
|
101 |
|
|
102 |
private void createMainPanel(){ |
|
103 |
GridBagLayout gridBagLayout = new GridBagLayout(); |
|
104 |
gridBagLayout.columnWidths = new int[]{303, 0, 0, 445, 102}; |
|
105 |
|
|
106 |
setLayout(gridBagLayout); |
|
107 |
|
|
108 |
lblChartPreview = new JLabel("Chart preview"); |
|
109 |
GridBagConstraints gbc_lblChartPreview = new GridBagConstraints(); |
|
110 |
gbc_lblChartPreview.gridwidth = 4; |
|
111 |
gbc_lblChartPreview.anchor = GridBagConstraints.WEST; |
|
112 |
gbc_lblChartPreview.insets = new Insets(0, 0, 5, 5); |
|
113 |
gbc_lblChartPreview.gridx = 0; |
|
114 |
gbc_lblChartPreview.gridy = 0; |
|
115 |
add(lblChartPreview, gbc_lblChartPreview); |
|
116 |
|
|
117 |
GridBagConstraints gbc_panel_chartType = new GridBagConstraints(); |
|
118 |
gbc_panel_chartType.gridheight = 2; |
|
119 |
gbc_panel_chartType.insets = new Insets(0, 0, 5, 0); |
|
120 |
gbc_panel_chartType.gridy = 1; |
|
121 |
gbc_panel_chartType.gridwidth = 5; |
|
122 |
gbc_panel_chartType.gridx = 0; |
|
123 |
add(getTypePanel(), gbc_panel_chartType); |
|
124 |
|
|
125 |
accept = new JButton("accept"); |
|
126 |
GridBagConstraints gbc_accept = new GridBagConstraints(); |
|
127 |
gbc_accept.anchor = GridBagConstraints.EAST; |
|
128 |
gbc_accept.insets = new Insets(0, 0, 0, 5); |
|
129 |
gbc_accept.gridx = 3; |
|
130 |
gbc_accept.gridy = 4; |
|
131 |
add(accept, gbc_accept); |
|
132 |
|
|
133 |
cancel = new JButton("Cancel"); |
|
134 |
GridBagConstraints gbc_cancel = new GridBagConstraints(); |
|
135 |
gbc_cancel.anchor = GridBagConstraints.WEST; |
|
136 |
gbc_cancel.gridx = 4; |
|
137 |
gbc_cancel.gridy = 4; |
|
138 |
add(cancel, gbc_cancel); |
|
139 |
|
|
140 |
} |
|
141 |
|
|
142 |
private JPanel getTypePanel(){ |
|
143 |
if (panel_chartType==null){ |
|
144 |
panel_chartType = new JPanel(); |
|
145 |
|
|
146 |
GridBagLayout gbl_panel_chartType = new GridBagLayout(); |
|
147 |
gbl_panel_chartType.columnWidths = new int[]{540, 0, 0, 210, 198, 56, 0}; |
|
148 |
gbl_panel_chartType.rowHeights = new int[]{0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
|
149 |
gbl_panel_chartType.columnWeights = new double[]{1.0, 0.0, 0.0, 1.0, 0.0, 0.0, Double.MIN_VALUE}; |
|
150 |
gbl_panel_chartType.rowWeights = new double[]{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; |
|
151 |
panel_chartType.setLayout(gbl_panel_chartType); |
|
152 |
|
|
153 |
previewPanel = new JPanel(); |
|
154 |
previewPanel.setBackground(Color.WHITE); |
|
155 |
previewPanel.setBorder(new LineBorder(new Color(0, 0, 0))); |
|
156 |
GridBagConstraints gbc_previewPanel = new GridBagConstraints(); |
|
157 |
gbc_previewPanel.gridheight = 2; |
|
158 |
gbc_previewPanel.gridwidth = 6; |
|
159 |
gbc_previewPanel.insets = new Insets(0, 0, 5, 5); |
|
160 |
gbc_previewPanel.fill = GridBagConstraints.BOTH; |
|
161 |
gbc_previewPanel.gridx = 0; |
|
162 |
gbc_previewPanel.gridy = 0; |
|
163 |
panel_chartType.add(previewPanel, gbc_previewPanel); |
|
164 |
|
|
165 |
|
|
166 |
chartOptionsLabel= new JLabel("Chart variables"); |
|
167 |
GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints(); |
|
168 |
gbc_lblNewLabel_3.anchor = GridBagConstraints.WEST; |
|
169 |
gbc_lblNewLabel_3.gridwidth = 4; |
|
170 |
gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5); |
|
171 |
gbc_lblNewLabel_3.gridx = 0; |
|
172 |
gbc_lblNewLabel_3.gridy = 3; |
|
173 |
panel_chartType.add(chartOptionsLabel, gbc_lblNewLabel_3); |
|
174 |
|
|
175 |
table = new JTable(){ |
|
176 |
/** |
|
177 |
* |
|
178 |
*/ |
|
179 |
private static final long serialVersionUID = -352323096347454258L; |
|
180 |
|
|
181 |
public boolean isCellEditable(int rowIndex, int colIndex) { |
|
182 |
if(colIndex==0) |
|
183 |
return true; |
|
184 |
return false; //Disallow the editing of any cell |
|
185 |
} |
|
186 |
|
|
187 |
public String getToolTipText(MouseEvent e) { |
|
188 |
String tip = null; |
|
189 |
List<ChartProperties> usedFields = getDocument().getChartProperties(); |
|
190 |
|
|
191 |
java.awt.Point p = e.getPoint(); |
|
192 |
int rowIndex = rowAtPoint(p); |
|
193 |
int colIndex = columnAtPoint(p); |
|
194 |
int realColumnIndex = convertColumnIndexToModel(colIndex); |
|
195 |
|
|
196 |
if (realColumnIndex == 0) { //Sport column |
|
197 |
tip = usedFields.get(rowIndex).getChartName(); |
|
198 |
} |
|
199 |
return tip; |
|
200 |
} |
|
201 |
}; |
|
202 |
|
|
203 |
GridBagConstraints gbc_table = new GridBagConstraints(); |
|
204 |
gbc_table.gridheight = 6; |
|
205 |
gbc_table.gridwidth = 5; |
|
206 |
gbc_table.insets = new Insets(0, 0, 0, 5); |
|
207 |
gbc_table.fill = GridBagConstraints.BOTH; |
|
208 |
gbc_table.gridx = 0; |
|
209 |
gbc_table.gridy = 4; |
|
210 |
//panel_chartType.add(table, gbc_table); |
|
211 |
JScrollPane scrollPane = new JScrollPane(table); |
|
212 |
panel_chartType.add(scrollPane, gbc_table); |
|
213 |
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
214 |
|
|
215 |
upButton = new JButton(""); |
|
216 |
upButton.setIcon(new ImageIcon(ChartPropertiesPanel.class.getResource("/icons/arrow_up.png"))); |
|
217 |
GridBagConstraints gbc_upButton = new GridBagConstraints(); |
|
218 |
gbc_upButton.insets = new Insets(0, 0, 5, 0); |
|
219 |
gbc_upButton.gridx = 5; |
|
220 |
gbc_upButton.gridy = 4; |
|
221 |
panel_chartType.add(upButton, gbc_upButton); |
|
222 |
|
|
223 |
downButton = new JButton(""); |
|
224 |
downButton.setIcon(new ImageIcon(ChartPropertiesPanel.class.getResource("/icons/arrow_down.png"))); |
|
225 |
GridBagConstraints gbc_downButton = new GridBagConstraints(); |
|
226 |
gbc_downButton.insets = new Insets(0, 0, 5, 0); |
|
227 |
gbc_downButton.gridx = 5; |
|
228 |
gbc_downButton.gridy = 5; |
|
229 |
panel_chartType.add(downButton, gbc_downButton); |
|
230 |
|
|
231 |
|
|
232 |
addButton = new JButton(""); |
|
233 |
addButton.setIcon(new ImageIcon(ChartPropertiesPanel.class.getResource("/icons/add.png"))); |
|
234 |
GridBagConstraints gbc_addButton = new GridBagConstraints(); |
|
235 |
gbc_addButton.insets = new Insets(0, 0, 5, 0); |
|
236 |
gbc_addButton.gridx = 5; |
|
237 |
gbc_addButton.gridy = 7; |
|
238 |
panel_chartType.add(addButton, gbc_addButton); |
|
239 |
|
|
240 |
editButton = new JButton(""); |
|
241 |
editButton.setIcon(new ImageIcon(ChartPropertiesPanel.class.getResource("/icons/edit.png"))); |
|
242 |
GridBagConstraints gbc_editButton = new GridBagConstraints(); |
|
243 |
gbc_editButton.insets = new Insets(0, 0, 5, 0); |
|
244 |
gbc_editButton.gridx = 5; |
|
245 |
gbc_editButton.gridy = 8; |
|
246 |
panel_chartType.add(editButton, gbc_editButton); |
|
247 |
|
|
248 |
deleteButton = new JButton(""); |
|
249 |
deleteButton.setIcon(new ImageIcon(ChartPropertiesPanel.class.getResource("/icons/delete.png"))); |
|
250 |
GridBagConstraints gbc_deleteButton = new GridBagConstraints(); |
|
251 |
gbc_deleteButton.anchor = GridBagConstraints.NORTH; |
|
252 |
gbc_deleteButton.gridx = 5; |
|
253 |
gbc_deleteButton.gridy = 9; |
|
254 |
panel_chartType.add(deleteButton, gbc_deleteButton); |
|
255 |
} |
|
256 |
return panel_chartType; |
|
257 |
|
|
258 |
} |
|
259 |
|
|
260 |
/** |
|
261 |
* |
|
262 |
* Inicializa los elementos para el manejo de los Chart |
|
263 |
*/ |
|
264 |
private void initialize() { |
|
265 |
String[] colName = {"Visible", "Variable (units)", "Chart Type", "Render type" }; |
|
266 |
|
|
267 |
tableModel = (DefaultTableModel) table.getModel(); |
|
268 |
tableModel.setColumnIdentifiers(colName); |
|
269 |
|
|
270 |
fillTableData(); |
|
271 |
table.getColumnModel().getColumn(0).setPreferredWidth(45); |
|
272 |
table.getColumnModel().getColumn(2).setPreferredWidth(150); |
|
273 |
table.getColumnModel().getColumn(3).setPreferredWidth(150); |
|
274 |
|
|
275 |
|
|
276 |
table.getColumnModel().getColumn(0).setCellRenderer(new CheckBoxRenderer()); |
|
277 |
table.getColumnModel().getColumn(2).setCellRenderer(new ChartCellRenderer(this)); |
|
278 |
|
|
279 |
|
|
280 |
} |
|
281 |
|
|
282 |
public void fillTableData(){ |
|
283 |
List<ChartProperties> chartProperties = getDocument().getChartProperties(); |
|
284 |
removeTable(); |
|
285 |
for (int i = 0; i < chartProperties.size(); i++) { |
|
286 |
Object[] data = new Object[4]; |
|
287 |
data[0] = true; |
|
288 |
data[1] = chartProperties.get(i).getChartTitle(); |
|
289 |
data[2] = getChartCellType(chartProperties.get(i).getChartType()); |
|
290 |
data[3] = chartProperties.get(i).getChartRenderer(); |
|
291 |
|
|
292 |
((DefaultTableModel) tableModel).addRow(data); |
|
293 |
} |
|
294 |
// tableModel.fireTableDataChanged(); |
|
295 |
table.revalidate(); |
|
296 |
table.repaint(); |
|
297 |
} |
|
298 |
|
|
299 |
private ChartEntry getChartCellType(String type){ |
|
300 |
for(int i=0;i<listModel.getSize(); i++){ |
|
301 |
ChartEntry entry = (ChartEntry)listModel.get(i); |
|
302 |
String entryID = entry.getChartType().toString(); |
|
303 |
if(entryID.compareToIgnoreCase(type.toString())==0) |
|
304 |
return entry; |
|
305 |
} |
|
306 |
return null; |
|
307 |
} |
|
308 |
|
|
309 |
public void removeTable(){ |
|
310 |
int numRows = tableModel.getRowCount(); |
|
311 |
for(int i=numRows-1; i>=0; i--){ |
|
312 |
tableModel.removeRow(i); |
|
313 |
} |
|
314 |
} |
|
315 |
|
|
316 |
public WindowInfo getWindowInfo() { |
|
317 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE); |
|
318 |
m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_grafico")); |
|
319 |
m_viewinfo.setWidth(1000); |
|
320 |
m_viewinfo.setHeight(460); |
|
321 |
return m_viewinfo; |
|
322 |
} |
|
323 |
|
|
324 |
public Object getWindowProfile() { |
|
325 |
return WindowInfo.PROPERTIES_PROFILE; |
|
326 |
} |
|
327 |
|
|
328 |
public Object getWindowModel() { |
|
329 |
return chartDocument; |
|
330 |
} |
|
331 |
|
|
332 |
public String getSelectedChartType(){ |
|
333 |
return selectedChartType; |
|
334 |
} |
|
335 |
|
|
336 |
/** |
|
337 |
* Crea el panel de la ChartPropertiesPanel usando un dise?o de Abeille |
|
338 |
*/ |
|
339 |
private void createButtonPanelEvents(){ |
|
340 |
|
|
341 |
addButton.addActionListener(new ActionListener() { |
|
342 |
public void actionPerformed(ActionEvent e) { |
|
343 |
new ChartJDialog(new ChartUsedFieldPropertiesPanel(getDocument())); |
|
344 |
} |
|
345 |
}); |
|
346 |
|
|
347 |
editButton.addActionListener(new ActionListener() { |
|
348 |
public void actionPerformed(ActionEvent e) { |
|
349 |
int index = table.getSelectedRow(); |
|
350 |
if(index != -1){ |
|
351 |
ChartProperties variable = getDocument().getChartProperties().get(index); |
|
352 |
new ChartJDialog(new ChartUsedFieldPropertiesPanel(getDocument(),variable)); |
|
353 |
}else{ |
|
354 |
System.out.println("No row selected"); |
|
355 |
} |
|
356 |
} |
|
357 |
}); |
|
358 |
|
|
359 |
deleteButton.addActionListener(new ActionListener() { |
|
360 |
public void actionPerformed(ActionEvent e) { |
|
361 |
int index = table.getSelectedRow(); |
|
362 |
if(index != -1){ |
|
363 |
ObservableUsedChartServices<ChartProperties> usedFields = getDocument().getChartProperties(); |
|
364 |
usedFields.remove(usedFields.get(index)); |
|
365 |
refreshTableData(); |
|
366 |
}else{ |
|
367 |
System.out.println("No row selected"); |
|
368 |
} |
|
369 |
} |
|
370 |
}); |
|
371 |
|
|
372 |
upButton.addActionListener(new ActionListener() { |
|
373 |
public void actionPerformed(ActionEvent e) { |
|
374 |
int index = table.getSelectedRow(); |
|
375 |
if(index != -1){ |
|
376 |
if(index > 0){ |
|
377 |
ChartProperties variable = getDocument().getChartProperties().get(index); |
|
378 |
ChartProperties variable_ant = getDocument().getChartProperties().get(index-1); |
|
379 |
getDocument().getChartProperties().set(index - 1, variable); |
|
380 |
getDocument().getChartProperties().set(index, variable_ant); |
|
381 |
} |
|
382 |
|
|
383 |
}else{ |
|
384 |
System.out.println("No row selected"); |
|
385 |
} |
|
386 |
} |
|
387 |
}); |
|
388 |
|
|
389 |
downButton.addActionListener(new ActionListener() { |
|
390 |
public void actionPerformed(ActionEvent e) { |
|
391 |
int index = table.getSelectedRow(); |
|
392 |
if(index != -1){ |
|
393 |
if(index < getDocument().getChartProperties().size()-1){ |
|
394 |
ChartProperties variable = getDocument().getChartProperties().get(index); |
|
395 |
ChartProperties variable_pos = getDocument().getChartProperties().get(index+1); |
|
396 |
getDocument().getChartProperties().set(index + 1, variable); |
|
397 |
getDocument().getChartProperties().set(index, variable_pos); |
|
398 |
} |
|
399 |
|
|
400 |
}else{ |
|
401 |
System.out.println("No row selected"); |
|
402 |
} |
|
403 |
} |
|
404 |
}); |
|
405 |
|
|
406 |
accept.addActionListener(new ActionListener() { |
|
407 |
public void actionPerformed(ActionEvent e) { |
|
408 |
acceptForm(); |
|
409 |
} |
|
410 |
}); |
|
411 |
cancel.addActionListener(new ActionListener() { |
|
412 |
public void actionPerformed(ActionEvent arg0) { |
|
413 |
cancelForm(); |
|
414 |
} |
|
415 |
}); |
|
416 |
|
|
417 |
} |
|
418 |
|
|
419 |
private void acceptForm(){ |
|
420 |
System.out.println("Button accept pressed"); |
|
421 |
|
|
422 |
try { |
|
423 |
//Create the overlayChart (base chart where the rest is superposed) |
|
424 |
ChartProperties props_overlay = swingManager.getChartSwingManager().getServiceManager().getChartManager().createProperties("OverlayChart"); |
|
425 |
ChartService service_overlay = serviceManager.getChartManager().createChart(props_overlay); |
|
426 |
|
|
427 |
ArrayList<ChartService> charts = new ArrayList<ChartService>(); |
|
428 |
|
|
429 |
for(int i = 0; i < tableModel.getRowCount(); i++){ |
|
430 |
ChartEntry entry = (ChartEntry) tableModel.getValueAt(i, 3); |
|
431 |
String chartType = entry.getChartType(); |
|
432 |
|
|
433 |
ChartProperties props = swingManager.getChartSwingManager().getServiceManager().getChartManager().createProperties(chartType); |
|
434 |
|
|
435 |
// //TODO: provisional para cambiar el render |
|
436 |
// if(i%2==0){ |
|
437 |
// ((BarsChartProperties)props).setRendererType("BarRenderer"); |
|
438 |
// } |
|
439 |
|
|
440 |
|
|
441 |
ChartService service= serviceManager.getChartManager().createChart(props); |
|
442 |
|
|
443 |
// Create new dataset from the selected fields of the main dataset |
|
444 |
String keyField = (String) tableModel.getValueAt(i, 4); |
|
445 |
String colField = (String) tableModel.getValueAt(i, 5); |
|
446 |
String rowField = (String) tableModel.getValueAt(i, 6); |
|
447 |
|
|
448 |
Iterator<Object> keys = getDocument().getDataset().getValues(keyField); |
|
449 |
Iterator<Object> cols = getDocument().getDataset().getValues(colField); |
|
450 |
Iterator<Object> rows = getDocument().getDataset().getValues(rowField); |
|
451 |
|
|
452 |
DefaultChartDataSet dataSet = new DefaultChartDataSet(); |
|
453 |
|
|
454 |
dataSet.setKeyField(keyField); |
|
455 |
dataSet.setColumnField(colField); |
|
456 |
dataSet.setRowField(rowField); |
|
457 |
|
|
458 |
dataSet.addData(keyField, keys); |
|
459 |
dataSet.addData(colField, cols); |
|
460 |
dataSet.addData(rowField, rows); |
|
461 |
service.setChartDataSet(dataSet); |
|
462 |
|
|
463 |
//Para el primer chart, fijar el Background y los ejes para que lo utilicen los siguientes. |
|
464 |
// if(i==0){ |
|
465 |
// JFreeChart chart = (JFreeChart)service.getInnerChart(); |
|
466 |
// ChartNumberAxis rangeAxis = new ChartNumberAxis(); |
|
467 |
// rangeAxis.setAxis(chart.getCategoryPlot().getRangeAxis()); |
|
468 |
// service_overlay.setRangeAxis(rangeAxis); |
|
469 |
// }else{ |
|
470 |
// JFreeChart chart = (JFreeChart)service.getInnerChart(); |
|
471 |
// chart.getCategoryPlot().setRangeAxis((ValueAxis) service_overlay.getRangeAxis()); |
|
472 |
// } |
|
473 |
|
|
474 |
charts.add(service); |
|
475 |
} |
|
476 |
|
|
477 |
((OverlayChartProperties)props_overlay).setCharts(charts); |
|
478 |
ChartSwingPanel panel = swingManager.getChartSwingManager().createPanel(props_overlay); |
|
479 |
panel.setChartService(service_overlay); |
|
480 |
|
|
481 |
panel.setPreferredSize(new Dimension(800, 400)); |
|
482 |
swingManager.getChartSwingManager().getWindowManager().showWindow(panel, "Chart window", |
|
483 |
ChartWindowManager.MODE_WINDOW); |
|
484 |
|
|
485 |
|
|
486 |
} catch (ServiceException e) { |
|
487 |
// TODO Auto-generated catch block |
|
488 |
e.printStackTrace(); |
|
489 |
} |
|
490 |
} |
|
491 |
|
|
492 |
private void cancelForm(){ |
|
493 |
System.out.println("Button cancel pressed"); |
|
494 |
setVisible(false); |
|
495 |
} |
|
496 |
|
|
497 |
private void getPreviewPanel(String type) { |
|
498 |
if(type == null){ |
|
499 |
setPreviewImage(IconThemeHelper.getImageIcon("no-chart-example")); |
|
500 |
}else{ |
|
501 |
if(!list.isSelectionEmpty()){ |
|
502 |
ChartEntry entry = (ChartEntry)list.getSelectedValue(); |
|
503 |
setPreviewImage(entry.getExampleImage()); |
|
504 |
}else{ |
|
505 |
setPreviewImage(IconThemeHelper.getImageIcon("no-chart-example")); |
|
506 |
} |
|
507 |
} |
|
508 |
} |
|
509 |
|
|
510 |
private void setPreviewImage(ImageIcon image){ |
|
511 |
previewImageLabel.setIcon(image); |
|
512 |
previewImageLabel.revalidate(); |
|
513 |
previewImageLabel.repaint(); |
|
514 |
} |
|
515 |
|
|
516 |
public void actionPerformed(ActionEvent e) { |
|
517 |
} |
|
518 |
|
|
519 |
public MainContext getDocument(){ |
|
520 |
return this.chartDocument; |
|
521 |
} |
|
522 |
|
|
523 |
public void refreshTableData() { |
|
524 |
table.removeAll(); |
|
525 |
fillTableData(); |
|
526 |
} |
|
527 |
|
|
528 |
|
|
529 |
|
|
530 |
private void initializeChartList() { |
|
531 |
// DefaultListModel charts = getCharts(); |
|
532 |
// list.setModel(charts); |
|
533 |
// list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
534 |
// list.setCellRenderer(new ChartCellRenderer(this)); |
|
535 |
// list.addListSelectionListener(this); |
|
536 |
// if(!charts.isEmpty()){ |
|
537 |
// list.setSelectedIndex(0); |
|
538 |
//// ChartEntry currentEntry = (ChartEntry)list.getSelectedValue(); |
|
539 |
//// this.setSelectedChartType(currentEntry.getChartType()); |
|
540 |
// } |
|
541 |
|
|
542 |
} |
|
543 |
|
|
544 |
/** |
|
545 |
* Obtiene los tipos de chart registrados |
|
546 |
* @return DefaultListModel listModel |
|
547 |
*/ |
|
548 |
private DefaultListModel getCharts() { |
|
549 |
listModel = new DefaultListModel(); |
|
550 |
List<ChartService> registeredServices = this.getDocument().getMainDocument().getServiceManager().getChartServices(); |
|
551 |
for(int i=0; i<registeredServices.size();i++){ |
|
552 |
String auxType = registeredServices.get(i).getChartType(); |
|
553 |
String auxName = registeredServices.get(i).getChartName(); |
|
554 |
|
|
555 |
listModel.addElement(new ChartEntry(auxType, auxName)); |
|
556 |
} |
|
557 |
|
|
558 |
return listModel; |
|
559 |
} |
|
560 |
|
|
561 |
|
|
562 |
/** |
|
563 |
* Manejador de eventos para que cuando se selecciona un tipo de gr?fica |
|
564 |
* actualice la preview y cargue el panel con los subtipos correspondientes |
|
565 |
*/ |
|
566 |
public void valueChanged(ListSelectionEvent evt) { |
|
567 |
this.setSelectedChartType(((ChartEntry)list.getSelectedValue()).getChartType()); |
|
568 |
} |
|
569 |
|
|
570 |
public void setSelectedChartType(String type){ |
|
571 |
this.selectedChartType = type; |
|
572 |
this.getPreviewPanel(type); |
|
573 |
//this.getSubtypePanel(type); |
|
574 |
} |
|
575 |
|
|
576 |
} |
|
577 |
|
|
0 | 578 |
org.gvsig.chart/tags/org.gvsig.chart-1.0.93/org.gvsig.chart.main/src/main/java/org/gvsig/chart/main/panels/ChartUsedFieldPropertiesPanel.java | ||
---|---|---|
1 |
package org.gvsig.chart.main.panels; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.Dimension; |
|
5 |
import java.awt.GridBagConstraints; |
|
6 |
import java.awt.GridBagLayout; |
|
7 |
import java.awt.Insets; |
|
8 |
import java.awt.event.ActionEvent; |
|
9 |
import java.awt.event.ActionListener; |
|
10 |
import java.util.HashMap; |
|
11 |
import java.util.List; |
|
12 |
import java.util.Map; |
|
13 |
|
|
14 |
import javax.swing.DefaultListModel; |
|
15 |
import javax.swing.JButton; |
|
16 |
import javax.swing.JLabel; |
|
17 |
import javax.swing.JList; |
|
18 |
import javax.swing.JPanel; |
|
19 |
import javax.swing.JTextField; |
|
20 |
import javax.swing.JTextPane; |
|
21 |
import javax.swing.ListSelectionModel; |
|
22 |
import javax.swing.event.ListSelectionEvent; |
|
23 |
import javax.swing.event.ListSelectionListener; |
|
24 |
|
|
25 |
import org.gvsig.andami.PluginServices; |
|
26 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
27 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
28 |
import org.gvsig.chart.ChartLocator; |
|
29 |
import org.gvsig.chart.ChartProperties; |
|
30 |
import org.gvsig.chart.ChartService; |
|
31 |
import org.gvsig.chart.lib.spi.ChartServiceManager; |
|
32 |
import org.gvsig.chart.main.DefaultDataPropertiesPanel; |
|
33 |
import org.gvsig.chart.main.MainContext; |
|
34 |
import org.gvsig.chart.main.utils.ChartCellRenderer; |
|
35 |
import org.gvsig.chart.main.utils.ChartEntry; |
|
36 |
import org.gvsig.chart.main.utils.ChartJDialog; |
|
37 |
import org.gvsig.chart.main.utils.ChartJPanel; |
|
38 |
import org.gvsig.chart.swing.ChartSwingLocator; |
|
39 |
import org.gvsig.chart.swing.spi.ChartPanel; |
|
40 |
import org.gvsig.chart.swing.spi.ChartSwingServiceManager; |
|
41 |
import org.gvsig.tools.service.ServiceException; |
|
42 |
|
|
43 |
public class ChartUsedFieldPropertiesPanel extends ChartJPanel implements IWindow, ActionListener, ListSelectionListener{ |
|
44 |
|
|
45 |
/** |
|
46 |
* |
|
47 |
*/ |
|
48 |
private static final long serialVersionUID = -301224990996378683L; |
|
49 |
|
|
50 |
private static final int SUBPANEL_WIDTH = 400; |
|
51 |
private static final int SUBPANEL_HEIGHT = 210; |
|
52 |
|
|
53 |
private JButton accept; |
|
54 |
private JButton cancel; |
|
55 |
|
|
56 |
private String selectedChartType = null; |
|
57 |
private ChartPanel currentSubtypePanel = null; |
|
58 |
|
|
59 |
private JPanel panel_chartType = null; |
|
60 |
private JPanel panelSubtype = null; |
|
61 |
private Map<String, JPanel> cardPanel = new HashMap<String, JPanel>(); |
|
62 |
private JList list = null; |
|
63 |
private DefaultListModel listModel; |
|
64 |
private JLabel chartTypesLabel; |
|
65 |
private JLabel chartOptionsLabel; |
|
66 |
|
|
67 |
private ChartServiceManager serviceManager; |
|
68 |
|
|
69 |
private ChartSwingServiceManager swingManager; |
|
70 |
private JLabel lblName; |
|
71 |
private JTextField nameTextField; |
|
72 |
private JTextField unitsTextField; |
Also available in: Unified diff