root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / gui / dialogs / FFrameGridDialog.java @ 9392
History | View | Annotate | Download (9.81 KB)
1 |
package com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.event.ActionEvent; |
5 |
import java.awt.event.ActionListener; |
6 |
import java.awt.geom.Rectangle2D; |
7 |
|
8 |
import javax.swing.ButtonGroup; |
9 |
import javax.swing.JLabel; |
10 |
import javax.swing.JList; |
11 |
import javax.swing.JPanel; |
12 |
import javax.swing.JRadioButton; |
13 |
import javax.swing.JScrollPane; |
14 |
import javax.swing.JTextField; |
15 |
|
16 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
17 |
|
18 |
import com.iver.andami.PluginServices; |
19 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
20 |
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
21 |
import com.iver.cit.gvsig.project.documents.layout.FLayoutUtilities; |
22 |
import com.iver.cit.gvsig.project.documents.layout.fframes.FFrameGrid; |
23 |
import com.iver.cit.gvsig.project.documents.layout.fframes.FFrameText; |
24 |
import com.iver.cit.gvsig.project.documents.layout.fframes.FFrameView; |
25 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
26 |
import com.iver.cit.gvsig.project.documents.layout.fframes.ListViewModel; |
27 |
import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
28 |
|
29 |
public class FFrameGridDialog extends JPanel implements IFFrameDialog{ |
30 |
|
31 |
private JPanel pMarcoVista=null; |
32 |
private JScrollPane jScrollPane; |
33 |
private JList liVistas; |
34 |
private Layout layout;
|
35 |
private FFrameGrid fframegrid;
|
36 |
private FFrameView fframeview;
|
37 |
private JLabel lblInterval = null; |
38 |
private JTextField txtInterval = null; |
39 |
private JRadioButton rbPoints = null; |
40 |
private JRadioButton rbLines = null; |
41 |
private JLabel lblWight = null; |
42 |
private JTextField txtWigth = null; |
43 |
private JLabel lblColor = null; |
44 |
private ColorChooserPanel m_colorFont=null; |
45 |
private JLabel lblColorLine = null; |
46 |
private ColorChooserPanel m_colorLine=null; // @jve:decl-index=0:visual-constraint="441,177" |
47 |
private AcceptCancelPanel accept;
|
48 |
private FFrameGrid newFFrameGrid;
|
49 |
private Rectangle2D rect; |
50 |
private Color textcolor; |
51 |
private Color linecolor; |
52 |
private boolean isAcepted; |
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
/**
|
59 |
* This is the default constructor
|
60 |
*/
|
61 |
public FFrameGridDialog(Layout layout, FFrameGrid fframe) {
|
62 |
super();
|
63 |
this.layout=layout;
|
64 |
this.fframegrid=fframe;
|
65 |
initialize(); |
66 |
} |
67 |
/**
|
68 |
* This method initializes pMarcoVista
|
69 |
*
|
70 |
* @return javax.swing.JPanel
|
71 |
*/
|
72 |
private JPanel getPMarcoVista() { |
73 |
if (pMarcoVista == null) { |
74 |
pMarcoVista = new JPanel(); |
75 |
pMarcoVista.setBorder(javax.swing.BorderFactory.createTitledBorder( |
76 |
null, PluginServices.getText(this,PluginServices.getText(this,"marco_vista")),javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.black)); |
77 |
pMarcoVista.setBounds(new java.awt.Rectangle(12,12,270,91)); |
78 |
pMarcoVista.add(getJScrollPane(), null);
|
79 |
} |
80 |
|
81 |
return pMarcoVista;
|
82 |
} |
83 |
private javax.swing.JScrollPane getJScrollPane() {
|
84 |
if (jScrollPane == null) { |
85 |
jScrollPane = new javax.swing.JScrollPane();
|
86 |
jScrollPane.setPreferredSize(new java.awt.Dimension(250,55)); |
87 |
jScrollPane.setViewportView(getLiVistas()); |
88 |
} |
89 |
return jScrollPane;
|
90 |
} |
91 |
private javax.swing.JList getLiVistas() {
|
92 |
if (liVistas == null) { |
93 |
ListViewModel listmodel = new ListViewModel();
|
94 |
listmodel.addViews(layout); |
95 |
|
96 |
///ArrayList list = listmodel.getViews();
|
97 |
|
98 |
liVistas = new javax.swing.JList();
|
99 |
|
100 |
liVistas.setSize(new java.awt.Dimension(250,52)); |
101 |
liVistas.setModel(listmodel); |
102 |
|
103 |
for (int i = 0; i < liVistas.getModel().getSize(); i++) { |
104 |
if (fframegrid.getFFrameDependence() != null) { |
105 |
fframeview = (FFrameView) liVistas.getModel().getElementAt(i); |
106 |
|
107 |
if (fframeview == fframegrid.getFFrameDependence()) {
|
108 |
liVistas.setSelectedIndex(i); |
109 |
} |
110 |
} |
111 |
} |
112 |
|
113 |
liVistas.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
114 |
private int selectIndex=-1; |
115 |
public void valueChanged( |
116 |
javax.swing.event.ListSelectionEvent e) { |
117 |
IFFrame[] fframes=layout.getLayoutContext().getFFrames();
|
118 |
int selectInt = ((JList) e.getSource()) |
119 |
.getSelectedIndex(); |
120 |
if (selectInt != selectIndex) {
|
121 |
selectIndex = selectInt; |
122 |
if (selectIndex == -1) |
123 |
return;
|
124 |
fframeview = (FFrameView) liVistas.getModel() |
125 |
.getElementAt(selectInt); |
126 |
|
127 |
for (int i = 0; i < fframes.length; i++) { |
128 |
IFFrame f = fframes[i]; |
129 |
|
130 |
if (f instanceof FFrameView) { |
131 |
if (((FFrameView) f).getView() == fframeview
|
132 |
.getView()) { |
133 |
fframegrid |
134 |
.setFFrameDependence(fframeview); |
135 |
} |
136 |
} |
137 |
} |
138 |
|
139 |
// getTNumIntervalos().setText(
|
140 |
// String.valueOf(fframescalebar
|
141 |
// .getNumInterval()));
|
142 |
// getTDivIzquierda().setText(
|
143 |
// String.valueOf(fframescalebar
|
144 |
// .getNumLeft()));
|
145 |
// getTIntervalo().setText(
|
146 |
// fframescalebar.obtainInterval());
|
147 |
// getTfNumberScale().setText(
|
148 |
// fframescalebar.getDescription());
|
149 |
} |
150 |
} |
151 |
}); |
152 |
} |
153 |
|
154 |
return liVistas;
|
155 |
} |
156 |
|
157 |
/**
|
158 |
* This method initializes this
|
159 |
*
|
160 |
* @return void
|
161 |
*/
|
162 |
private void initialize() { |
163 |
lblColorLine = new JLabel(); |
164 |
lblColorLine.setBounds(new java.awt.Rectangle(204,207,87,27)); |
165 |
lblColorLine.setText("color_linea");
|
166 |
lblColor = new JLabel(); |
167 |
lblColor.setBounds(new java.awt.Rectangle(15,210,96,21)); |
168 |
lblColor.setText("color_fuente");
|
169 |
lblWight = new JLabel(); |
170 |
lblWight.setBounds(new java.awt.Rectangle(205,111,88,24)); |
171 |
lblWight.setText("grosor_linea");
|
172 |
lblInterval = new JLabel(); |
173 |
lblInterval.setBounds(new java.awt.Rectangle(13,111,89,23)); |
174 |
lblInterval.setText("intervalo");
|
175 |
this.setLayout(null); |
176 |
this.setSize(426, 295); |
177 |
this.add(getPMarcoVista(), null); |
178 |
this.add(lblInterval, null); |
179 |
this.add(getTxtInterval(), null); |
180 |
|
181 |
this.add(getRbPoints(), null); |
182 |
this.add(getRbLines(), null); |
183 |
this.add(lblWight, null); |
184 |
this.add(getTxtWidth(), null); |
185 |
this.add(lblColor, null); |
186 |
this.add(getColorFont(), null); |
187 |
this.add(lblColorLine, null); |
188 |
this.add(getColorLine(), null); |
189 |
this.add(getAcceptCancelPanel(), null); |
190 |
ButtonGroup group = new ButtonGroup(); |
191 |
group.add(getRbPoints()); |
192 |
group.add(getRbLines()); |
193 |
} |
194 |
|
195 |
public void setRectangle(Rectangle2D r) { |
196 |
rect=r; |
197 |
} |
198 |
private ColorChooserPanel getColorFont() {
|
199 |
if (m_colorFont == null) { |
200 |
m_colorFont = new ColorChooserPanel();
|
201 |
m_colorFont.setAlpha(255);
|
202 |
m_colorFont.setBounds(new java.awt.Rectangle(126,208,63,25)); |
203 |
m_colorFont.addActionListener(new java.awt.event.ActionListener() {
|
204 |
public void actionPerformed(ActionEvent e) { |
205 |
textcolor=m_colorFont.getColor(); |
206 |
} |
207 |
}); |
208 |
} |
209 |
return m_colorFont;
|
210 |
} |
211 |
private ColorChooserPanel getColorLine() {
|
212 |
if (m_colorLine == null) { |
213 |
m_colorLine = new ColorChooserPanel();
|
214 |
m_colorLine.setAlpha(255);
|
215 |
m_colorLine.setBounds(new java.awt.Rectangle(304,208,61,25)); |
216 |
m_colorLine.setSize(new java.awt.Dimension(80,25)); |
217 |
m_colorLine.addActionListener(new java.awt.event.ActionListener() {
|
218 |
public void actionPerformed(ActionEvent e) { |
219 |
|
220 |
} |
221 |
}); |
222 |
} |
223 |
return m_colorLine;
|
224 |
} |
225 |
public WindowInfo getWindowInfo() {
|
226 |
// TODO Auto-generated method stub
|
227 |
return null; |
228 |
} |
229 |
|
230 |
public boolean getIsAcepted() { |
231 |
// TODO Auto-generated method stub
|
232 |
return false; |
233 |
} |
234 |
|
235 |
public IFFrame getFFrame() {
|
236 |
return newFFrameGrid;
|
237 |
} |
238 |
/**
|
239 |
* This method initializes txtInterval
|
240 |
*
|
241 |
* @return javax.swing.JTextField
|
242 |
*/
|
243 |
private JTextField getTxtInterval() { |
244 |
if (txtInterval == null) { |
245 |
txtInterval = new JTextField(); |
246 |
txtInterval.setBounds(new java.awt.Rectangle(115,111,85,23)); |
247 |
} |
248 |
return txtInterval;
|
249 |
} |
250 |
/**
|
251 |
* This method initializes rbPoints
|
252 |
*
|
253 |
* @return javax.swing.JRadioButton
|
254 |
*/
|
255 |
private JRadioButton getRbPoints() { |
256 |
if (rbPoints == null) { |
257 |
rbPoints = new JRadioButton(); |
258 |
rbPoints.setBounds(new java.awt.Rectangle(17,148,120,21)); |
259 |
rbPoints.setText("puntos");
|
260 |
} |
261 |
return rbPoints;
|
262 |
} |
263 |
/**
|
264 |
* This method initializes rbLines
|
265 |
*
|
266 |
* @return javax.swing.JRadioButton
|
267 |
*/
|
268 |
private JRadioButton getRbLines() { |
269 |
if (rbLines == null) { |
270 |
rbLines = new JRadioButton(); |
271 |
rbLines.setBounds(new java.awt.Rectangle(149,146,154,25)); |
272 |
rbLines.setText("lineas");
|
273 |
} |
274 |
return rbLines;
|
275 |
} |
276 |
/**
|
277 |
* This method initializes txtWigth
|
278 |
*
|
279 |
* @return javax.swing.JTextField
|
280 |
*/
|
281 |
private JTextField getTxtWidth() { |
282 |
if (txtWigth == null) { |
283 |
txtWigth = new JTextField(); |
284 |
txtWigth.setBounds(new java.awt.Rectangle(298,112,47,23)); |
285 |
} |
286 |
return txtWigth;
|
287 |
} |
288 |
private AcceptCancelPanel getAcceptCancelPanel() {
|
289 |
if (accept == null) { |
290 |
ActionListener okAction, cancelAction;
|
291 |
okAction = new java.awt.event.ActionListener() {
|
292 |
|
293 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
294 |
newFFrameGrid = (FFrameGrid) fframegrid |
295 |
.cloneFFrame(layout); |
296 |
newFFrameGrid.setBoundBox(FLayoutUtilities.toSheetRect( |
297 |
rect, layout.getLayoutControl().getAT())); |
298 |
newFFrameGrid.setInterval(Double.parseDouble(getTxtInterval().getText().toString()));
|
299 |
newFFrameGrid.setLineWidth((Double.parseDouble(getTxtWidth().getText().toString())));
|
300 |
newFFrameGrid.setFFrameDependence(fframeview); |
301 |
newFFrameGrid.setTextColor(textcolor); |
302 |
newFFrameGrid.setLineColor(linecolor); |
303 |
|
304 |
newFFrameGrid.setIsLine(getRbLines().isSelected()); |
305 |
|
306 |
|
307 |
newFFrameGrid.setRotation(fframeview.getRotation()); |
308 |
PluginServices.getMDIManager().closeWindow( |
309 |
FFrameGridDialog.this); |
310 |
// m_layout.refresh();
|
311 |
isAcepted = true;
|
312 |
} |
313 |
}; |
314 |
cancelAction = new java.awt.event.ActionListener() {
|
315 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
316 |
newFFrameGrid=null;
|
317 |
PluginServices.getMDIManager().closeWindow( |
318 |
FFrameGridDialog.this); |
319 |
} |
320 |
}; |
321 |
accept = new AcceptCancelPanel(okAction, cancelAction);
|
322 |
accept.setPreferredSize(new java.awt.Dimension(300, 300)); |
323 |
accept.setEnabled(true);
|
324 |
accept.setSize(new java.awt.Dimension(32,32)); |
325 |
accept.setLocation(new java.awt.Point(10,400)); |
326 |
accept.setVisible(true);
|
327 |
} |
328 |
return accept;
|
329 |
} |
330 |
|
331 |
} // @jve:decl-index=0:visual-constraint="10,10"
|