root / org.gvsig.chart / trunk / org.gvsig.chart / org.gvsig.chart.app / org.gvsig.chart.app.layoutplugin / src / main / java / org / gvsig / project / documents / layout / frames / gui / dialogs / FFrameChartDialog.java @ 49
History | View | Annotate | Download (5.75 KB)
1 |
package org.gvsig.project.documents.layout.frames.gui.dialogs; |
---|---|
2 |
|
3 |
import java.awt.event.ActionEvent; |
4 |
import java.awt.event.ActionListener; |
5 |
import java.awt.geom.Rectangle2D; |
6 |
import java.util.List; |
7 |
|
8 |
import javax.swing.JButton; |
9 |
import javax.swing.JCheckBox; |
10 |
import javax.swing.JComboBox; |
11 |
import javax.swing.JLabel; |
12 |
|
13 |
import org.gvsig.andami.PluginServices; |
14 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
15 |
import org.gvsig.app.ApplicationLocator; |
16 |
import org.gvsig.app.ApplicationManager; |
17 |
import org.gvsig.app.project.Project; |
18 |
import org.gvsig.app.project.documents.Document; |
19 |
import org.gvsig.app.project.documents.chart.ChartDocument; |
20 |
import org.gvsig.app.project.documents.chart.ChartDocumentManager; |
21 |
import org.gvsig.app.project.documents.layout.LayoutContext; |
22 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
23 |
import org.gvsig.app.project.documents.layout.fframes.gui.JPRotation; |
24 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.AbstractFFrameDialog; |
25 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
26 |
import org.gvsig.project.documents.layout.frames.FFrameChart; |
27 |
|
28 |
public class FFrameChartDialog extends AbstractFFrameDialog { |
29 |
|
30 |
/**
|
31 |
*
|
32 |
*/
|
33 |
private static final long serialVersionUID = 8488799048881180876L; |
34 |
private FFrameChart fframechart;
|
35 |
private Rectangle2D rect = new Rectangle2D.Double(); |
36 |
private JPRotation pRotation;
|
37 |
protected JComboBox cboChartDoc; |
38 |
private JCheckBox cboChartLegendVisible; |
39 |
private JCheckBox cboChartAxisLabelsVisible; |
40 |
|
41 |
public FFrameChartDialog(LayoutPanel layoutPanel, IFFrame frame) {
|
42 |
super(layoutPanel, frame);
|
43 |
fframechart = (FFrameChart) frame; |
44 |
initialize(); |
45 |
|
46 |
} |
47 |
|
48 |
|
49 |
public FFrameChart getFFChart(){
|
50 |
return fframechart;
|
51 |
} |
52 |
|
53 |
private void initialize() { |
54 |
this.setLayout(null); |
55 |
this.setSize(505, 142); |
56 |
|
57 |
JLabel lblSelectChartDocument = new JLabel("Select Chart Document:"); |
58 |
lblSelectChartDocument.setBounds(10, 42, 159, 14); |
59 |
add(lblSelectChartDocument); |
60 |
|
61 |
cboChartDoc = new JComboBox(); |
62 |
ApplicationManager appManager = ApplicationLocator.getManager(); |
63 |
Project project = appManager.getCurrentProject(); |
64 |
|
65 |
List<Document> chartDocuments = project.getDocuments(ChartDocumentManager.TYPENAME); |
66 |
// ChartDocument[] pts = chartDocuments.toArray(new ChartDocument[chartDocuments.size()]);
|
67 |
|
68 |
for (Document t : chartDocuments) { |
69 |
cboChartDoc.addItem(t); |
70 |
} |
71 |
|
72 |
cboChartDoc.setBounds(175, 40, 164, 20); |
73 |
add(cboChartDoc); |
74 |
|
75 |
cboChartLegendVisible = new JCheckBox("legend visible"); |
76 |
cboChartLegendVisible.setSelected(true);
|
77 |
cboChartLegendVisible.setBounds(175, 70, 164, 20); |
78 |
add(cboChartLegendVisible); |
79 |
|
80 |
// cboChartAxisLabelsVisible = new JCheckBox("label axis visible");
|
81 |
// cboChartAxisLabelsVisible.setSelected(true);
|
82 |
// cboChartAxisLabelsVisible.setBounds(175, 70, 164, 20);
|
83 |
// add(cboChartAxisLabelsVisible);
|
84 |
|
85 |
JButton btnOk = new JButton("OK"); |
86 |
btnOk.addActionListener(new ActionListener() { |
87 |
public void actionPerformed(ActionEvent e) { |
88 |
ChartDocument chartSelected = (ChartDocument) cboChartDoc.getSelectedItem(); |
89 |
if (chartSelected != null){ |
90 |
// getFFChart().setChartDoc(chartSelected);
|
91 |
// getFFChart().setLegendVisible(cboChartLegendVisible.isSelected());
|
92 |
// getFFChart().setRotation(getPRotation().getRotation());
|
93 |
//fframechart.setAxisLabels(cboChartAxisLabelsVisible.isSelected());
|
94 |
|
95 |
|
96 |
LayoutPanel layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
97 |
|
98 |
getFFChart().setChartDoc(chartSelected); |
99 |
LayoutContext lctxt = layout.getLayoutContext(); |
100 |
getFFChart().setLegendVisible(cboChartLegendVisible.isSelected()); |
101 |
getFFChart().setRotation(getPRotation().getRotation()); |
102 |
|
103 |
lctxt.addFFrame(getFFChart(), true, true); |
104 |
layout.getDocument().setModified(true);
|
105 |
layout.getLayoutControl().refresh(); |
106 |
} |
107 |
PluginServices.getMDIManager().closeWindow(FFrameChartDialog.this); |
108 |
|
109 |
} |
110 |
}); |
111 |
btnOk.setBounds(130, 108, 89, 23); |
112 |
add(btnOk); |
113 |
|
114 |
JButton btnCancel = new JButton("Cancel"); |
115 |
btnCancel.addActionListener(new ActionListener() { |
116 |
public void actionPerformed(ActionEvent e) { |
117 |
PluginServices.getMDIManager().closeWindow(FFrameChartDialog.this); |
118 |
} |
119 |
}); |
120 |
btnCancel.setBounds(250, 108, 89, 23); |
121 |
add(btnCancel); |
122 |
|
123 |
add(getPRotation()); |
124 |
|
125 |
getPRotation().setRotation(fframechart.getRotation()); |
126 |
|
127 |
|
128 |
|
129 |
|
130 |
} |
131 |
|
132 |
/**
|
133 |
* This method initializes pRotation
|
134 |
*
|
135 |
* @return javax.swing.JPanel
|
136 |
*/
|
137 |
private JPRotation getPRotation() {
|
138 |
if (pRotation == null) { |
139 |
pRotation = new JPRotation();
|
140 |
pRotation.setBounds(373, 14, 120, 120); |
141 |
} |
142 |
return pRotation;
|
143 |
} |
144 |
|
145 |
|
146 |
public void setRectangle(Rectangle2D r) { |
147 |
rect .setRect(r); |
148 |
} |
149 |
|
150 |
public WindowInfo getWindowInfo() {
|
151 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
152 |
m_viewinfo.setTitle(PluginServices.getText(this,
|
153 |
"propiedades_marco_chart"));
|
154 |
|
155 |
return m_viewinfo;
|
156 |
|
157 |
} |
158 |
|
159 |
public boolean getIsAcepted() { |
160 |
// TODO Auto-generated method stub
|
161 |
return false; |
162 |
} |
163 |
|
164 |
public IFFrame getFFrame() {
|
165 |
return fframechart;
|
166 |
} |
167 |
|
168 |
public Object getWindowProfile() { |
169 |
// TODO Auto-generated method stub
|
170 |
return null; |
171 |
} |
172 |
} |