Revision 20371
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/layout/fframes/gui/dialogs/FFrameGridDialog.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Color; |
|
5 |
import java.awt.FlowLayout; |
|
6 |
import java.awt.Font; |
|
7 |
import java.awt.event.ActionListener; |
|
8 |
import java.awt.geom.Rectangle2D; |
|
9 |
|
|
10 |
import javax.swing.BoxLayout; |
|
11 |
import javax.swing.ButtonGroup; |
|
12 |
import javax.swing.JButton; |
|
13 |
import javax.swing.JLabel; |
|
14 |
import javax.swing.JList; |
|
15 |
import javax.swing.JPanel; |
|
16 |
import javax.swing.JRadioButton; |
|
17 |
import javax.swing.JScrollPane; |
|
18 |
import javax.swing.JTextField; |
|
19 |
|
|
20 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
|
21 |
|
|
22 |
import com.iver.andami.PluginServices; |
|
23 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
|
24 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
|
25 |
import com.iver.cit.gvsig.gui.layout.Attributes; |
|
26 |
import com.iver.cit.gvsig.gui.layout.Layout; |
|
27 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGrid; |
|
28 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView; |
|
29 |
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
|
30 |
import com.iver.cit.gvsig.gui.utils.FontChooser; |
|
31 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
|
32 |
import com.iver.cit.gvsig.project.documents.layout.fframes.ListViewModel; |
|
33 |
import com.iver.cit.gvsig.project.documents.view.legend.edition.gui.PanelEditSymbol; |
|
34 |
|
|
35 |
public class FFrameGridDialog extends JPanel implements IFFrameDialog{ |
|
36 |
|
|
37 |
private JPanel jPanel = null; |
|
38 |
private JPanel jPanel1 = null; |
|
39 |
private JPanel jPanel2 = null; |
|
40 |
private JPanel jPanel3 = null; |
|
41 |
private JScrollPane jScrollPane = null; |
|
42 |
private JList liVistas = null; |
|
43 |
private JPanel jPanel4 = null; |
|
44 |
private JLabel jLabel = null; |
|
45 |
private JTextField txtIntervalX = null; |
|
46 |
private JPanel jPanel5 = null; |
|
47 |
private JPanel jPanel6 = null; |
|
48 |
private JPanel jPanel7 = null; |
|
49 |
private JLabel jLabel1 = null; |
|
50 |
private JTextField txtIntervalY = null; |
|
51 |
private JLabel lblUnitsX = null; |
|
52 |
private JLabel lblUnitsY = null; |
|
53 |
private JPanel jPanel8 = null; |
|
54 |
private JPanel jPanel9 = null; |
|
55 |
private JRadioButton rbPoints = null; |
|
56 |
private JRadioButton rbLines = null; |
|
57 |
private JButton bSymbol = null; |
|
58 |
private JPanel jPanel10 = null; |
|
59 |
private JPanel jPanel11 = null; |
|
60 |
private JButton jButton = null; |
|
61 |
private ColorChooserPanel colorChooserPanel = null; |
|
62 |
private JPanel jPanel12 = null; |
|
63 |
private JLabel jLabel2 = null; |
|
64 |
private JTextField txtSize = null; |
|
65 |
private JPanel jPanel13 = null; |
|
66 |
private JPanel jPanel14 = null; |
|
67 |
private JRadioButton rbShowCornerText = null; |
|
68 |
|
|
69 |
private FFrameGrid fframegrid; |
|
70 |
private FFrameView fframeview; |
|
71 |
private AcceptCancelPanel accept; |
|
72 |
private FFrameGrid newFFrameGrid; |
|
73 |
private Rectangle2D rect; |
|
74 |
private Layout layout; |
|
75 |
private Color textcolor; |
|
76 |
private FSymbol symbol; |
|
77 |
private Font m_font; |
|
78 |
private ButtonGroup bg=new ButtonGroup(); |
|
79 |
private JPanel jPanel15 = null; |
|
80 |
/** |
|
81 |
* This is the default constructor |
|
82 |
*/ |
|
83 |
public FFrameGridDialog(Layout layout, FFrameGrid fframe,FFrameView view) { |
|
84 |
super(); |
|
85 |
this.layout=layout; |
|
86 |
this.fframegrid=fframe; |
|
87 |
this.fframeview=view; |
|
88 |
textcolor=fframegrid.getFontColor(); |
|
89 |
initialize(); |
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* This method initializes this |
|
94 |
* |
|
95 |
* @return void |
|
96 |
*/ |
|
97 |
private void initialize() { |
|
98 |
this.setLayout(new BorderLayout()); |
|
99 |
this.setSize(384, 242); |
|
100 |
// this.add(getJPanel(), java.awt.BorderLayout.NORTH); |
|
101 |
this.add(getJPanel1(), java.awt.BorderLayout.CENTER); |
|
102 |
this.add(getJPanel2(), java.awt.BorderLayout.SOUTH); |
|
103 |
} |
|
104 |
|
|
105 |
/** |
|
106 |
* This method initializes jPanel |
|
107 |
* |
|
108 |
* @return javax.swing.JPanel |
|
109 |
*/ |
|
110 |
private JPanel getJPanel() { |
|
111 |
if (jPanel == null) { |
|
112 |
jPanel = new JPanel(); |
|
113 |
jPanel.add(getJPanel3(), null); |
|
114 |
} |
|
115 |
return jPanel; |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* This method initializes jPanel1 |
|
120 |
* |
|
121 |
* @return javax.swing.JPanel |
|
122 |
*/ |
|
123 |
private JPanel getJPanel1() { |
|
124 |
if (jPanel1 == null) { |
|
125 |
jPanel1 = new JPanel(); |
|
126 |
jPanel1.setLayout(new BorderLayout()); |
|
127 |
jPanel1.add(getJPanel5(), java.awt.BorderLayout.NORTH); |
|
128 |
jPanel1.add(getJPanel15(), java.awt.BorderLayout.CENTER); |
|
129 |
} |
|
130 |
return jPanel1; |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* This method initializes jPanel2 |
|
135 |
* |
|
136 |
* @return javax.swing.JPanel |
|
137 |
*/ |
|
138 |
private JPanel getJPanel2() { |
|
139 |
if (jPanel2 == null) { |
|
140 |
jPanel2 = new JPanel(); |
|
141 |
jPanel2.add(getAcceptCancelPanel(), null); |
|
142 |
} |
|
143 |
return jPanel2; |
|
144 |
} |
|
145 |
|
|
146 |
/** |
|
147 |
* This method initializes jPanel3 |
|
148 |
* |
|
149 |
* @return javax.swing.JPanel |
|
150 |
*/ |
|
151 |
private JPanel getJPanel3() { |
|
152 |
if (jPanel3 == null) { |
|
153 |
jPanel3 = new JPanel(); |
|
154 |
jPanel3.setPreferredSize(new java.awt.Dimension(300,90)); |
|
155 |
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Vista", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
156 |
jPanel3.add(getJScrollPane(), null); |
|
157 |
} |
|
158 |
return jPanel3; |
|
159 |
} |
|
160 |
|
|
161 |
/** |
|
162 |
* This method initializes jScrollPane |
|
163 |
* |
|
164 |
* @return javax.swing.JScrollPane |
|
165 |
*/ |
|
166 |
private JScrollPane getJScrollPane() { |
|
167 |
if (jScrollPane == null) { |
|
168 |
jScrollPane = new JScrollPane(); |
|
169 |
jScrollPane.setPreferredSize(new java.awt.Dimension(290,55)); |
|
170 |
jScrollPane.setViewportView(getJList()); |
|
171 |
} |
|
172 |
return jScrollPane; |
|
173 |
} |
|
174 |
|
|
175 |
/** |
|
176 |
* This method initializes jList |
|
177 |
* |
|
178 |
* @return javax.swing.JList |
|
179 |
*/ |
|
180 |
private JList getJList() { |
|
181 |
if (liVistas == null) { |
|
182 |
ListViewModel listmodel = new ListViewModel(); |
|
183 |
listmodel.addViews(layout); |
|
184 |
|
|
185 |
///ArrayList list = listmodel.getViews(); |
|
186 |
|
|
187 |
liVistas = new javax.swing.JList(); |
|
188 |
|
|
189 |
liVistas.setSize(new java.awt.Dimension(250,52)); |
|
190 |
liVistas.setModel(listmodel); |
|
191 |
|
|
192 |
for (int i = 0; i < liVistas.getModel().getSize(); i++) { |
|
193 |
if (fframegrid.getFFrameDependence() != null) { |
|
194 |
fframeview = (FFrameView) liVistas.getModel().getElementAt(i); |
|
195 |
|
|
196 |
if (fframeview == fframegrid.getFFrameDependence()[0]) { |
|
197 |
liVistas.setSelectedIndex(i); |
|
198 |
} |
|
199 |
} |
|
200 |
} |
|
201 |
|
|
202 |
liVistas.addListSelectionListener(new javax.swing.event.ListSelectionListener() { |
|
203 |
private int selectIndex=-1; |
|
204 |
public void valueChanged( |
|
205 |
javax.swing.event.ListSelectionEvent e) { |
|
206 |
IFFrame[] fframes=layout.getFFrames(); |
|
207 |
int selectInt = ((JList) e.getSource()) |
|
208 |
.getSelectedIndex(); |
|
209 |
if (selectInt != selectIndex) { |
|
210 |
selectIndex = selectInt; |
|
211 |
if (selectIndex == -1) |
|
212 |
return; |
|
213 |
fframeview = (FFrameView) liVistas.getModel() |
|
214 |
.getElementAt(selectInt); |
|
215 |
|
|
216 |
for (int i = 0; i < fframes.length; i++) { |
|
217 |
IFFrame f = fframes[i]; |
|
218 |
|
|
219 |
if (f instanceof FFrameView) { |
|
220 |
if (((FFrameView) f).getView() == fframeview |
|
221 |
.getView()) { |
|
222 |
fframegrid |
|
223 |
.setFFrameDependence(fframeview); |
|
224 |
} |
|
225 |
} |
|
226 |
} |
|
227 |
|
|
228 |
// getTNumIntervalos().setText( |
|
229 |
// String.valueOf(fframescalebar |
|
230 |
// .getNumInterval())); |
|
231 |
// getTDivIzquierda().setText( |
|
232 |
// String.valueOf(fframescalebar |
|
233 |
// .getNumLeft())); |
|
234 |
// getTIntervalo().setText( |
|
235 |
// fframescalebar.obtainInterval()); |
|
236 |
// getTfNumberScale().setText( |
|
237 |
// fframescalebar.getDescription()); |
|
238 |
} |
|
239 |
} |
|
240 |
}); |
|
241 |
} |
|
242 |
|
|
243 |
return liVistas; |
|
244 |
} |
|
245 |
|
|
246 |
/** |
|
247 |
* This method initializes jPanel4 |
|
248 |
* |
|
249 |
* @return javax.swing.JPanel |
|
250 |
*/ |
|
251 |
private JPanel getJPanel4() { |
|
252 |
if (jPanel4 == null) { |
|
253 |
lblUnitsX = new JLabel(); |
|
254 |
if (fframeview.getMapContext()!=null) |
|
255 |
lblUnitsX.setText(Attributes.NAMES[fframeview.getMapContext().getViewPort().getMapUnits()]); |
|
256 |
jLabel = new JLabel(); |
|
257 |
jLabel.setText("x"); |
|
258 |
jLabel.setName("jLabel"); |
|
259 |
jPanel4 = new JPanel(); |
|
260 |
jPanel4.setLayout(new FlowLayout()); |
|
261 |
jPanel4.add(jLabel, null); |
|
262 |
jPanel4.add(getTxtIntervalX(), null); |
|
263 |
jPanel4.add(lblUnitsX, null); |
|
264 |
} |
|
265 |
return jPanel4; |
|
266 |
} |
|
267 |
|
|
268 |
/** |
|
269 |
* This method initializes txtIntervalX |
|
270 |
* |
|
271 |
* @return javax.swing.JTextField |
|
272 |
*/ |
|
273 |
private JTextField getTxtIntervalX() { |
|
274 |
if (txtIntervalX == null) { |
|
275 |
txtIntervalX = new JTextField(); |
|
276 |
txtIntervalX.setText(String.valueOf(fframegrid.getIntervalX())); |
|
277 |
txtIntervalX.setPreferredSize(new java.awt.Dimension(60,20)); |
|
278 |
txtIntervalX.setName("txtIntervalX"); |
|
279 |
} |
|
280 |
return txtIntervalX; |
|
281 |
} |
|
282 |
|
|
283 |
/** |
|
284 |
* This method initializes jPanel5 |
|
285 |
* |
|
286 |
* @return javax.swing.JPanel |
|
287 |
*/ |
|
288 |
private JPanel getJPanel5() { |
|
289 |
if (jPanel5 == null) { |
|
290 |
jPanel5 = new JPanel(); |
|
291 |
jPanel5.setLayout(new FlowLayout()); |
|
292 |
jPanel5.add(getJPanel6(), null); |
|
293 |
jPanel5.add(getJPanel8(), null); |
|
294 |
} |
|
295 |
return jPanel5; |
|
296 |
} |
|
297 |
|
|
298 |
/** |
|
299 |
* This method initializes jPanel6 |
|
300 |
* |
|
301 |
* @return javax.swing.JPanel |
|
302 |
*/ |
|
303 |
private JPanel getJPanel6() { |
|
304 |
if (jPanel6 == null) { |
|
305 |
jPanel6 = new JPanel(); |
|
306 |
jPanel6.setLayout(new BoxLayout(getJPanel6(), BoxLayout.Y_AXIS)); |
|
307 |
jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "intervalos", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
308 |
jPanel6.add(getJPanel4(), null); |
|
309 |
jPanel6.add(getJPanel7(), null); |
|
310 |
} |
|
311 |
return jPanel6; |
|
312 |
} |
|
313 |
|
|
314 |
/** |
|
315 |
* This method initializes jPanel7 |
|
316 |
* |
|
317 |
* @return javax.swing.JPanel |
|
318 |
*/ |
|
319 |
private JPanel getJPanel7() { |
|
320 |
if (jPanel7 == null) { |
|
321 |
lblUnitsY = new JLabel(); |
|
322 |
if (fframeview.getMapContext()!=null) |
|
323 |
lblUnitsY.setText(Attributes.NAMES[fframeview.getMapContext().getViewPort().getMapUnits()]); |
|
324 |
jLabel1 = new JLabel(); |
|
325 |
jLabel1.setText("y"); |
|
326 |
jPanel7 = new JPanel(); |
|
327 |
jPanel7.add(jLabel1, null); |
|
328 |
jPanel7.add(getTxtIntervalY(), null); |
|
329 |
jPanel7.add(lblUnitsY, null); |
|
330 |
} |
|
331 |
return jPanel7; |
|
332 |
} |
|
333 |
|
|
334 |
/** |
|
335 |
* This method initializes txtIntervalY |
|
336 |
* |
|
337 |
* @return javax.swing.JTextField |
|
338 |
*/ |
|
339 |
private JTextField getTxtIntervalY() { |
|
340 |
if (txtIntervalY == null) { |
|
341 |
txtIntervalY = new JTextField(); |
|
342 |
txtIntervalY.setText(String.valueOf(fframegrid.getIntervalY())); |
|
343 |
txtIntervalY.setPreferredSize(new java.awt.Dimension(60,20)); |
|
344 |
} |
|
345 |
return txtIntervalY; |
|
346 |
} |
|
347 |
|
|
348 |
/** |
|
349 |
* This method initializes jPanel8 |
|
350 |
* |
|
351 |
* @return javax.swing.JPanel |
|
352 |
*/ |
|
353 |
private JPanel getJPanel8() { |
|
354 |
if (jPanel8 == null) { |
|
355 |
jPanel8 = new JPanel(); |
|
356 |
jPanel8.setLayout(new BoxLayout(getJPanel8(), BoxLayout.Y_AXIS)); |
|
357 |
jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "tipos", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
358 |
jPanel8.add(getJPanel9(), null); |
|
359 |
jPanel8.add(getBSymbol(), null); |
|
360 |
} |
|
361 |
return jPanel8; |
|
362 |
} |
|
363 |
|
|
364 |
/** |
|
365 |
* This method initializes jPanel9 |
|
366 |
* |
|
367 |
* @return javax.swing.JPanel |
|
368 |
*/ |
|
369 |
private JPanel getJPanel9() { |
|
370 |
if (jPanel9 == null) { |
|
371 |
jPanel9 = new JPanel(); |
|
372 |
jPanel9.add(getRbPoints(), null); |
|
373 |
jPanel9.add(getRbLines(), null); |
|
374 |
} |
|
375 |
return jPanel9; |
|
376 |
} |
|
377 |
|
|
378 |
/** |
|
379 |
* This method initializes rbPoints |
|
380 |
* |
|
381 |
* @return javax.swing.JRadioButton |
|
382 |
*/ |
|
383 |
private JRadioButton getRbPoints() { |
|
384 |
if (rbPoints == null) { |
|
385 |
rbPoints = new JRadioButton(); |
|
386 |
bg.add(rbPoints); |
|
387 |
rbPoints.setSelected(!fframegrid.isLine()); |
|
388 |
rbPoints.setText(PluginServices.getText(this,"puntos")); |
|
389 |
} |
|
390 |
return rbPoints; |
|
391 |
} |
|
392 |
|
|
393 |
/** |
|
394 |
* This method initializes rbLines |
|
395 |
* |
|
396 |
* @return javax.swing.JRadioButton |
|
397 |
*/ |
|
398 |
private JRadioButton getRbLines() { |
|
399 |
if (rbLines == null) { |
|
400 |
rbLines = new JRadioButton(); |
|
401 |
bg.add(rbLines); |
|
402 |
rbLines.setSelected(fframegrid.isLine()); |
|
403 |
rbLines.setText(PluginServices.getText(this,"lineas")); |
|
404 |
} |
|
405 |
return rbLines; |
|
406 |
} |
|
407 |
|
|
408 |
/** |
|
409 |
* This method initializes bSymbol |
|
410 |
* |
|
411 |
* @return javax.swing.JButton |
|
412 |
*/ |
|
413 |
private JButton getBSymbol() { |
|
414 |
if (bSymbol == null) { |
|
415 |
bSymbol = new JButton(); |
|
416 |
bSymbol.setText(PluginServices.getText(this,"symbol")); |
|
417 |
bSymbol.addActionListener(new java.awt.event.ActionListener() { |
|
418 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
419 |
PanelEditSymbol pes=new PanelEditSymbol(); |
|
420 |
if (getRbLines().isSelected()) |
|
421 |
pes.setSymbol(fframegrid.getSymbolLine()); |
|
422 |
else |
|
423 |
pes.setSymbol(fframegrid.getSymbolPoint()); |
|
424 |
PluginServices.getMDIManager().addWindow(pes); |
|
425 |
symbol=pes.getFSymbol(); |
|
426 |
// FPanelLegendDefault pld=new FPanelLegendDefault(); |
|
427 |
// pld.setFSymbol(fframegrid.getSymbolLine()); |
|
428 |
|
|
429 |
} |
|
430 |
}); |
|
431 |
} |
|
432 |
return bSymbol; |
|
433 |
} |
|
434 |
|
|
435 |
/** |
|
436 |
* This method initializes jPanel10 |
|
437 |
* |
|
438 |
* @return javax.swing.JPanel |
|
439 |
*/ |
|
440 |
private JPanel getJPanel10() { |
|
441 |
if (jPanel10 == null) { |
|
442 |
jPanel10 = new JPanel(); |
|
443 |
jPanel10.setLayout(new BorderLayout()); |
|
444 |
jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "fuente", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
445 |
jPanel10.add(getJPanel11(), java.awt.BorderLayout.NORTH); |
|
446 |
jPanel10.add(getJPanel12(), java.awt.BorderLayout.CENTER); |
|
447 |
} |
|
448 |
return jPanel10; |
|
449 |
} |
|
450 |
|
|
451 |
/** |
|
452 |
* This method initializes jPanel11 |
|
453 |
* |
|
454 |
* @return javax.swing.JPanel |
|
455 |
*/ |
|
456 |
private JPanel getJPanel11() { |
|
457 |
if (jPanel11 == null) { |
|
458 |
jPanel11 = new JPanel(); |
|
459 |
jPanel11.add(getJButton(), null); |
|
460 |
jPanel11.add(getColorChooserPanel(), null); |
|
461 |
} |
|
462 |
return jPanel11; |
|
463 |
} |
|
464 |
|
|
465 |
/** |
|
466 |
* This method initializes jButton |
|
467 |
* |
|
468 |
* @return javax.swing.JButton |
|
469 |
*/ |
|
470 |
private JButton getJButton() { |
|
471 |
if (jButton == null) { |
|
472 |
jButton = new JButton(); |
|
473 |
jButton.setText(PluginServices.getText(this, "fuente")); //$NON-NLS-1$ |
|
474 |
m_font=fframegrid.getFont(); |
|
475 |
jButton.addActionListener(new java.awt.event.ActionListener() { |
|
476 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
477 |
Font font = FontChooser.showDialog(PluginServices.getText( |
|
478 |
this, "__seleccion_de_fuente"), m_font); |
|
479 |
if (font != null) |
|
480 |
m_font=font; // fchoser=new |
|
481 |
// FontChooser(); |
|
482 |
// //$NON-NLS-1$ |
|
483 |
} |
|
484 |
}); |
|
485 |
} |
|
486 |
return jButton; |
|
487 |
} |
|
488 |
|
|
489 |
/** |
|
490 |
* This method initializes colorChooserPanel |
|
491 |
* |
|
492 |
* @return com.iver.cit.gvsig.gui.panels.ColorChooserPanel |
|
493 |
*/ |
|
494 |
private ColorChooserPanel getColorChooserPanel() { |
|
495 |
if (colorChooserPanel == null) { |
|
496 |
colorChooserPanel = new ColorChooserPanel(); |
|
497 |
colorChooserPanel.setAlpha(255); |
|
498 |
} |
|
499 |
return colorChooserPanel; |
|
500 |
} |
|
501 |
|
|
502 |
/** |
|
503 |
* This method initializes jPanel12 |
|
504 |
* |
|
505 |
* @return javax.swing.JPanel |
|
506 |
*/ |
|
507 |
private JPanel getJPanel12() { |
|
508 |
if (jPanel12 == null) { |
|
509 |
jLabel2 = new JLabel(); |
|
510 |
jLabel2.setText(PluginServices.getText(this,"size")); |
|
511 |
jPanel12 = new JPanel(); |
|
512 |
jPanel12.add(jLabel2, null); |
|
513 |
jPanel12.add(getTxtSize(), null); |
|
514 |
} |
|
515 |
return jPanel12; |
|
516 |
} |
|
517 |
|
|
518 |
/** |
|
519 |
* This method initializes txtSize |
|
520 |
* |
|
521 |
* @return javax.swing.JTextField |
|
522 |
*/ |
|
523 |
private JTextField getTxtSize() { |
|
524 |
if (txtSize == null) { |
|
525 |
txtSize = new JTextField(); |
|
526 |
txtSize.setText(String.valueOf(fframegrid.getFontSize())); |
|
527 |
txtSize.setPreferredSize(new java.awt.Dimension(40,20)); |
|
528 |
} |
|
529 |
return txtSize; |
|
530 |
} |
|
531 |
|
|
532 |
/** |
|
533 |
* This method initializes jPanel13 |
|
534 |
* |
|
535 |
* @return javax.swing.JPanel |
|
536 |
*/ |
|
537 |
private JPanel getJPanel13() { |
|
538 |
if (jPanel13 == null) { |
|
539 |
jPanel13 = new JPanel(); |
|
540 |
jPanel13.setLayout(new BorderLayout()); |
|
541 |
jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "propiedades", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
542 |
jPanel13.add(getJPanel14(), java.awt.BorderLayout.NORTH); |
|
543 |
} |
|
544 |
return jPanel13; |
|
545 |
} |
|
546 |
|
|
547 |
/** |
|
548 |
* This method initializes jPanel14 |
|
549 |
* |
|
550 |
* @return javax.swing.JPanel |
|
551 |
*/ |
|
552 |
private JPanel getJPanel14() { |
|
553 |
if (jPanel14 == null) { |
|
554 |
jPanel14 = new JPanel(); |
|
555 |
jPanel14.add(getRbShowCornerText(), null); |
|
556 |
} |
|
557 |
return jPanel14; |
|
558 |
} |
|
559 |
|
|
560 |
/** |
|
561 |
* This method initializes rbShowCornerText |
|
562 |
* |
|
563 |
* @return javax.swing.JRadioButton |
|
564 |
*/ |
|
565 |
private JRadioButton getRbShowCornerText() { |
|
566 |
if (rbShowCornerText == null) { |
|
567 |
rbShowCornerText = new JRadioButton(); |
|
568 |
rbShowCornerText.setSelected(fframegrid.isShowCornerText()); |
|
569 |
rbShowCornerText.setText(PluginServices.getText(this,"show_corner_text")); |
|
570 |
} |
|
571 |
return rbShowCornerText; |
|
572 |
} |
|
573 |
public IFFrame getFFrame() { |
|
574 |
return newFFrameGrid; |
|
575 |
} |
|
576 |
private AcceptCancelPanel getAcceptCancelPanel() { |
|
577 |
if (accept == null) { |
|
578 |
ActionListener okAction, cancelAction; |
|
579 |
okAction = new java.awt.event.ActionListener() { |
|
580 |
|
|
581 |
private boolean isAcepted; |
|
582 |
|
|
583 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
584 |
newFFrameGrid = (FFrameGrid) fframegrid |
|
585 |
.cloneFFrame(layout); |
|
586 |
newFFrameGrid.setFFrameDependence(fframeview); |
|
587 |
// newFFrameGrid.setBoundBox(); |
|
588 |
newFFrameGrid.setIntervalX(Double.parseDouble(getTxtIntervalX().getText().toString())); |
|
589 |
newFFrameGrid.setIntervalY(Double.parseDouble(getTxtIntervalY().getText().toString())); |
|
590 |
|
|
591 |
if (getRbLines().isSelected()){ |
|
592 |
if (symbol!=null) |
|
593 |
newFFrameGrid.setLineSymbol(symbol); |
|
594 |
}else{ |
|
595 |
if (symbol!=null) |
|
596 |
newFFrameGrid.setPointSymbol(symbol); |
|
597 |
} |
|
598 |
|
|
599 |
|
|
600 |
newFFrameGrid.setTextColor(textcolor); |
|
601 |
newFFrameGrid.setSizeFont(Integer.parseInt(getTxtSize().getText())); |
|
602 |
newFFrameGrid.setIsLine(getRbLines().isSelected()); |
|
603 |
newFFrameGrid.setFont(m_font); |
|
604 |
newFFrameGrid.showCornerText(getRbShowCornerText().isSelected()); |
|
605 |
newFFrameGrid.setRotation(fframeview.getRotation()); |
|
606 |
PluginServices.getMDIManager().closeWindow( |
|
607 |
FFrameGridDialog.this); |
|
608 |
// m_layout.refresh(); |
|
609 |
isAcepted = true; |
|
610 |
} |
|
611 |
}; |
|
612 |
cancelAction = new java.awt.event.ActionListener() { |
|
613 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
614 |
newFFrameGrid=null; |
|
615 |
PluginServices.getMDIManager().closeWindow( |
|
616 |
FFrameGridDialog.this); |
|
617 |
} |
|
618 |
}; |
|
619 |
accept = new AcceptCancelPanel(okAction, cancelAction); |
|
620 |
// accept.setPreferredSize(new java.awt.Dimension(300, 300)); |
|
621 |
// accept.setBounds(new java.awt.Rectangle(243,387,160,28)); |
|
622 |
accept.setEnabled(true); |
|
623 |
// accept.setBounds(new java.awt.Rectangle(45, 250, 300, 32)); |
|
624 |
accept.setVisible(true); |
|
625 |
} |
|
626 |
return accept; |
|
627 |
} |
|
628 |
|
|
629 |
public void setRectangle(Rectangle2D r) { |
|
630 |
rect=r; |
|
631 |
} |
|
632 |
|
|
633 |
public WindowInfo getWindowInfo() { |
|
634 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG|WindowInfo.RESIZABLE); |
|
635 |
m_viewinfo.setTitle(PluginServices.getText(this, |
|
636 |
"cuadricula")); |
|
637 |
|
|
638 |
return m_viewinfo; |
|
639 |
} |
|
640 |
|
|
641 |
public boolean getIsAcepted() { |
|
642 |
// TODO Auto-generated method stub |
|
643 |
return false; |
|
644 |
} |
|
645 |
|
|
646 |
/** |
|
647 |
* This method initializes jPanel15 |
|
648 |
* |
|
649 |
* @return javax.swing.JPanel |
|
650 |
*/ |
|
651 |
private JPanel getJPanel15() { |
|
652 |
if (jPanel15 == null) { |
|
653 |
jPanel15 = new JPanel(); |
|
654 |
jPanel15.add(getJPanel10(), null); |
|
655 |
jPanel15.add(getJPanel13(), null); |
|
656 |
} |
|
657 |
return jPanel15; |
|
658 |
} |
|
659 |
public void setFFrameView(FFrameView fview){ |
|
660 |
fframeview=fview; |
|
661 |
|
|
662 |
} |
|
663 |
|
|
664 |
} // @jve:decl-index=0:visual-constraint="10,10" |
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/layout/fframes/gui/dialogs/FFrameViewDialog.java | ||
---|---|---|
54 | 54 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
55 | 55 |
import com.iver.cit.gvsig.fmap.ViewPort; |
56 | 56 |
import com.iver.cit.gvsig.gui.layout.Layout; |
57 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGrid; |
|
57 | 58 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView; |
58 | 59 |
import com.iver.cit.gvsig.project.documents.layout.FLayoutUtilities; |
59 | 60 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
60 | 61 |
import com.iver.cit.gvsig.project.documents.layout.fframes.ListViewModel; |
61 | 62 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.JPRotation; |
62 | 63 |
import com.iver.cit.gvsig.project.documents.view.ProjectView; |
64 |
import javax.swing.JButton; |
|
63 | 65 |
|
64 | 66 |
|
65 | 67 |
/** |
... | ... | |
92 | 94 |
private boolean isAcepted = false; |
93 | 95 |
private JPRotation rotation = null; |
94 | 96 |
private FFrameView newFFrameView=null; |
97 |
private JButton bGrid = null; |
|
98 |
private IFFrame grid; |
|
95 | 99 |
/** |
96 | 100 |
* This is the default constructor |
97 | 101 |
* |
... | ... | |
158 | 162 |
jContentPane.setPreferredSize(new java.awt.Dimension(60, 60)); |
159 | 163 |
jContentPane.setLocation(0, 0); |
160 | 164 |
jContentPane.add(getPRotation(), null); |
165 |
jContentPane.add(getBGrid(), null); |
|
161 | 166 |
} |
162 | 167 |
|
163 | 168 |
return jContentPane; |
... | ... | |
460 | 465 |
bAceptar = new javax.swing.JButton(); |
461 | 466 |
bAceptar.setSize(85, 26); |
462 | 467 |
bAceptar.setText(PluginServices.getText(this, "Aceptar")); |
463 |
bAceptar.setLocation(55, 179);
|
|
468 |
bAceptar.setLocation(109, 179);
|
|
464 | 469 |
bAceptar.addActionListener(new java.awt.event.ActionListener() { |
465 | 470 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
466 | 471 |
newFFrameView=(FFrameView)fframeview.cloneFFrame(m_layout); |
... | ... | |
484 | 489 |
.getSelectedIndex()); |
485 | 490 |
newFFrameView.setQuality(getCbCalidad() |
486 | 491 |
.getSelectedIndex()); |
492 |
if (grid!=null){ |
|
493 |
((FFrameGrid)grid).setLayout(m_layout); |
|
494 |
((FFrameGrid)grid).setFFrameDependence(newFFrameView); |
|
495 |
// ((FFrameGrid)grid).setBoundBox(); |
|
496 |
newFFrameView.setGrid(grid); |
|
497 |
} |
|
487 | 498 |
newFFrameView.setBoundBox(FLayoutUtilities.toSheetRect( |
488 | 499 |
rect, m_layout.getAT())); |
489 | 500 |
|
... | ... | |
529 | 540 |
bCancelar = new javax.swing.JButton(); |
530 | 541 |
bCancelar.setSize(85, 26); |
531 | 542 |
bCancelar.setText(PluginServices.getText(this, "Cancelar")); |
532 |
bCancelar.setLocation(195, 179);
|
|
543 |
bCancelar.setLocation(207, 179);
|
|
533 | 544 |
bCancelar.addActionListener(new java.awt.event.ActionListener() { |
534 | 545 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
535 | 546 |
newFFrameView=null; |
... | ... | |
619 | 630 |
public IFFrame getFFrame() { |
620 | 631 |
return newFFrameView; |
621 | 632 |
} |
633 |
|
|
634 |
/** |
|
635 |
* This method initializes bGrid |
|
636 |
* |
|
637 |
* @return javax.swing.JButton |
|
638 |
*/ |
|
639 |
private JButton getBGrid() { |
|
640 |
if (bGrid == null) { |
|
641 |
bGrid = new JButton(); |
|
642 |
bGrid.setBounds(new java.awt.Rectangle(11,179,85,26)); |
|
643 |
bGrid.setText("grid"); |
|
644 |
bGrid.addActionListener(new java.awt.event.ActionListener() { |
|
645 |
|
|
646 |
|
|
647 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
648 |
FFrameGrid fframe =new FFrameGrid(); |
|
649 |
fframe.setLayout(m_layout); |
|
650 |
fframe.setFFrameDependence(fframeview); |
|
651 |
|
|
652 |
FFrameGridDialog fframedialog = new FFrameGridDialog(m_layout, fframe,fframeview); |
|
653 |
// fframedialog.setFFrameView(fframeview); |
|
654 |
if (fframedialog != null) { |
|
655 |
PluginServices.getMDIManager().addWindow(fframedialog); |
|
656 |
} |
|
657 |
IFFrame newFrame= fframedialog.getFFrame(); |
|
658 |
if (newFrame!=null) { |
|
659 |
grid=newFrame; |
|
660 |
} |
|
661 |
} |
|
662 |
}); |
|
663 |
} |
|
664 |
return bGrid; |
|
665 |
} |
|
622 | 666 |
} // @jve:decl-index=0:visual-constraint="10,10" |
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameView.java | ||
---|---|---|
54 | 54 |
import java.awt.geom.Rectangle2D; |
55 | 55 |
import java.awt.image.BufferedImage; |
56 | 56 |
import java.util.ArrayList; |
57 |
import java.util.Iterator; |
|
57 | 58 |
|
58 | 59 |
import org.cresques.cts.IProjection; |
59 | 60 |
|
... | ... | |
72 | 73 |
import com.iver.cit.gvsig.fmap.rendering.LegendChangedEvent; |
73 | 74 |
import com.iver.cit.gvsig.gui.layout.Layout; |
74 | 75 |
import com.iver.cit.gvsig.project.Project; |
76 |
import com.iver.cit.gvsig.project.documents.exceptions.OpenException; |
|
75 | 77 |
import com.iver.cit.gvsig.project.documents.exceptions.SaveException; |
76 | 78 |
import com.iver.cit.gvsig.project.documents.layout.FLayoutUtilities; |
77 | 79 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
... | ... | |
114 | 116 |
private Point origin; |
115 | 117 |
private Point2D p1; |
116 | 118 |
private Point2D p2; |
119 |
private IFFrame grid; |
|
117 | 120 |
/** |
118 | 121 |
* Creates a new FFrameView object. |
119 | 122 |
*/ |
... | ... | |
449 | 452 |
.getAffineTransform()); |
450 | 453 |
|
451 | 454 |
} |
455 |
if (grid!=null){ |
|
456 |
((FFrameGrid)grid).setFFrameDependence(this); |
|
457 |
grid.draw(g,at,rv,imgBase); |
|
458 |
} |
|
452 | 459 |
} |
453 | 460 |
private Rectangle2D calculateExtent() { |
454 | 461 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
... | ... | |
658 | 665 |
|
659 | 666 |
xml.addChild(getMapContext().getXMLEntity()); |
660 | 667 |
} |
668 |
if (grid!=null) |
|
669 |
xml.addChild(grid.getXMLEntity()); |
|
661 | 670 |
} catch (Exception e) { |
662 | 671 |
throw new SaveException(e, this.getClass().getName()); |
663 | 672 |
} |
... | ... | |
904 | 913 |
e.printStackTrace(); |
905 | 914 |
} |
906 | 915 |
} |
916 |
Iterator iterator=xml.findChildren("fframegrid","fframegrid"); |
|
917 |
while (iterator.hasNext()) { |
|
918 |
XMLEntity element = (XMLEntity) iterator.next(); |
|
919 |
try { |
|
920 |
grid=createFFrame(element,project,layout); |
|
921 |
} catch (OpenException e) { |
|
922 |
NotificationManager.addError("Creando el grid asociado a la vista", |
|
923 |
e); |
|
924 |
} |
|
925 |
} |
|
907 | 926 |
} |
908 | 927 |
|
909 | 928 |
/** |
... | ... | |
1013 | 1032 |
} |
1014 | 1033 |
((FFrameView)frame).view.getMapContext().removeLayerListener((FFrameView)frame); |
1015 | 1034 |
((FFrameView)frame).view.getMapContext().getViewPort().removeViewPortListener((FFrameView)frame); |
1016 |
|
|
1017 |
|
|
1018 |
} |
|
1035 |
} |
|
1019 | 1036 |
public IFFrame cloneFFrame(Layout layout) { |
1020 | 1037 |
FFrameView frame = new FFrameView(); |
1021 | 1038 |
frame.setLevel(this.getLevel()); |
... | ... | |
1041 | 1058 |
if (frame instanceof IFFrameViewDependence) { |
1042 | 1059 |
((IFFrameViewDependence) frame).initDependence(layout.getAllFFrames()); |
1043 | 1060 |
} |
1061 |
if (grid!=null){ |
|
1062 |
FFrameGrid newGrid=(FFrameGrid)this.grid.cloneFFrame(layout); |
|
1063 |
newGrid.setFFrameDependence(frame); |
|
1064 |
frame.setGrid(newGrid); |
|
1065 |
} |
|
1044 | 1066 |
cloneActions(frame); |
1045 | 1067 |
return frame; |
1046 | 1068 |
} |
1069 |
|
|
1070 |
public void setGrid(IFFrame grid) { |
|
1071 |
this.grid=grid; |
|
1072 |
|
|
1073 |
} |
|
1047 | 1074 |
} |
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameGrid.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.gui.layout.fframes; |
|
2 |
|
|
3 |
import java.awt.BasicStroke; |
|
4 |
import java.awt.Color; |
|
5 |
import java.awt.Font; |
|
6 |
import java.awt.Graphics2D; |
|
7 |
import java.awt.font.FontRenderContext; |
|
8 |
import java.awt.font.TextLayout; |
|
9 |
import java.awt.geom.AffineTransform; |
|
10 |
import java.awt.geom.Point2D; |
|
11 |
import java.awt.geom.Rectangle2D; |
|
12 |
import java.awt.geom.Rectangle2D.Double; |
|
13 |
import java.awt.image.BufferedImage; |
|
14 |
|
|
15 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
16 |
|
|
17 |
import com.iver.andami.PluginServices; |
|
18 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
19 |
import com.iver.cit.gvsig.fmap.ViewPort; |
|
20 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
21 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
22 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
23 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
24 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
|
25 |
import com.iver.cit.gvsig.gui.layout.Layout; |
|
26 |
import com.iver.cit.gvsig.project.documents.exceptions.SaveException; |
|
27 |
import com.iver.cit.gvsig.project.documents.layout.FLayoutUtilities; |
|
28 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
|
29 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameLayoutDependence; |
|
30 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameViewDependence; |
|
31 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog; |
|
32 |
import com.iver.utiles.StringUtilities; |
|
33 |
import com.iver.utiles.XMLEntity; |
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
/** |
|
38 |
* FFrame para introducir una cuadr?cula sobre una vista en el Layout. |
|
39 |
* |
|
40 |
* @author Vicente Caballero Navarro |
|
41 |
*/ |
|
42 |
public class FFrameGrid extends FFrame implements IFFrameViewDependence,IFFrameLayoutDependence{ |
|
43 |
|
|
44 |
private FFrameView fframeview; |
|
45 |
private double intervalX=10000; |
|
46 |
private double intervalY=10000; |
|
47 |
|
|
48 |
private Color textColor=Color.black; |
|
49 |
private boolean isLine; |
|
50 |
private int sizeFont=8; |
|
51 |
private int dependenceIndex; |
|
52 |
private Layout layout; |
|
53 |
private boolean print=false; |
|
54 |
private FSymbol symbolLine=new FSymbol(FShape.LINE,Color.black); |
|
55 |
private FSymbol symbolPoint=new FSymbol(FShape.POINT,Color.black); |
|
56 |
private Font font=new Font("Arial",Font.PLAIN,sizeFont); |
|
57 |
private boolean showCornerText=false; |
|
58 |
|
|
59 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, BufferedImage imgBase) { |
|
60 |
if (print){ |
|
61 |
fframeview.refresh(); |
|
62 |
print=false; |
|
63 |
} |
|
64 |
ViewPort vp=fframeview.getMapContext().getViewPort(); |
|
65 |
// vp.setAffineTransform(at); |
|
66 |
FontRenderContext frc = g.getFontRenderContext(); |
|
67 |
double myScale = at.getScaleX() * 0.0234; //FLayoutUtilities.fromSheetDistance(folio.getAncho(),at)/rv.getWidth(); |
|
68 |
int scaledFontSize = (int) (myScale * sizeFont); |
|
69 |
Font font=new Font(this.font.getFamily(),this.font.getStyle(),scaledFontSize); |
|
70 |
Rectangle2D.Double r = getBoundingBox(at); |
|
71 |
Rectangle2D rView=fframeview.getBoundingBox(at); |
|
72 |
g.rotate(Math.toRadians(getRotation()), r.x + (r.width / 2), |
|
73 |
r.y + (r.height / 2)); |
|
74 |
// AffineTransform atView=fframeview.getATMap(); |
|
75 |
|
|
76 |
// vp.setAffineTransform(at); |
|
77 |
Rectangle2D extent=vp.getAdjustedExtent(); |
|
78 |
double extentX=extent.getMinX(); |
|
79 |
double extentY=extent.getMinY(); |
|
80 |
|
|
81 |
double restX=(extentX/intervalX) % 1; |
|
82 |
double distX=restX*intervalX; |
|
83 |
//double distPixelsX=FLayoutUtilities.fromSheetDistance(distX,atView); |
|
84 |
double restY=(extentY/intervalY) % 1; |
|
85 |
double distY=restY*intervalY; |
|
86 |
//double distPixelsY=FLayoutUtilities.fromSheetDistance(distY,atView); |
|
87 |
|
|
88 |
double x=extentX-distX; |
|
89 |
//double pixelsX = rView.getMinX()-distPixelsX; |
|
90 |
double y=extentY-distY; |
|
91 |
//double pixelsY = rView.getMinY()-distPixelsY; |
|
92 |
|
|
93 |
//fframeview.getMapContext().getViewPort().fromMapPoint(extentX,extentY); |
|
94 |
//double pixelsInterval=FLayoutUtilities.fromSheetDistance(interval,atView); |
|
95 |
|
|
96 |
g.setColor(Color.black); |
|
97 |
|
|
98 |
|
|
99 |
// Dibuja los m?rgenes |
|
100 |
double valueIntervalX=((extentX/intervalX)-restX) * intervalX-intervalX; |
|
101 |
x=x-intervalX; |
|
102 |
double topX=extentX; |
|
103 |
if (showCornerText){ |
|
104 |
x+=intervalX; |
|
105 |
topX-=intervalX; |
|
106 |
} |
|
107 |
while(x<extent.getMaxX()){ |
|
108 |
if (x>topX) { |
|
109 |
Point2D p2=vp.fromMapPoint(x,extentY); |
|
110 |
Point2D p1=vp.fromMapPoint(x,extent.getMaxY()); |
|
111 |
if (isLine()){ |
|
112 |
g.setColor(symbolLine.getColor()); |
|
113 |
g.setStroke(symbolLine.getStroke()); |
|
114 |
}else{ |
|
115 |
g.setColor(symbolPoint.getColor()); |
|
116 |
g.setStroke(new BasicStroke((int)1)); |
|
117 |
} |
|
118 |
// g.setColor(lineColor); |
|
119 |
g.drawLine((int)p1.getX(),(int)p1.getY()-5,(int)p1.getX(),(int)p1.getY()); |
|
120 |
g.drawLine((int)p2.getX(),(int)p2.getY(),(int)p2.getX(),(int)p2.getY()+5); |
|
121 |
TextLayout textaux = new TextLayout(String.valueOf(valueIntervalX), |
|
122 |
font, frc); |
|
123 |
|
|
124 |
double w=textaux.getBounds().getWidth(); |
|
125 |
double h=textaux.getBounds().getHeight(); |
|
126 |
g.setColor(textColor); |
|
127 |
textaux.draw(g,(int)(p1.getX()-w/2),(int)(p1.getY()-h)-5); |
|
128 |
textaux.draw(g,(int)(p2.getX()-w/2),(int)(p2.getY()+h*2)+5); |
|
129 |
} |
|
130 |
valueIntervalX=valueIntervalX+intervalX; |
|
131 |
x=x+intervalX; |
|
132 |
} |
|
133 |
double valueIntervalY=((extentY/intervalY)-restY) * intervalY-intervalY; |
|
134 |
y=y-intervalY; |
|
135 |
double topY=extentY; |
|
136 |
if (showCornerText){ |
|
137 |
y+=intervalY; |
|
138 |
topY-=intervalY; |
|
139 |
} |
|
140 |
while(y<extent.getMaxY()){ |
|
141 |
if (y>topY) { |
|
142 |
Point2D p1=vp.fromMapPoint(extentX,y); |
|
143 |
Point2D p2=vp.fromMapPoint(extent.getMaxX(),y); |
|
144 |
if (isLine()){ |
|
145 |
g.setColor(symbolLine.getColor()); |
|
146 |
g.setStroke(symbolLine.getStroke()); |
|
147 |
}else{ |
|
148 |
g.setColor(symbolPoint.getColor()); |
|
149 |
g.setStroke(new BasicStroke((int)1)); |
|
150 |
} |
|
151 |
// g.setColor(lineColor); |
|
152 |
g.drawLine((int)p1.getX()-5,(int)p1.getY(),(int)p1.getX(),(int)p1.getY()); |
|
153 |
g.drawLine((int)p2.getX(),(int)p2.getY(),(int)p2.getX()+5,(int)p2.getY()); |
|
154 |
TextLayout textaux = new TextLayout(String.valueOf(valueIntervalY), |
|
155 |
font, frc); |
|
156 |
double w=textaux.getBounds().getWidth(); |
|
157 |
double h=textaux.getBounds().getHeight(); |
|
158 |
g.setColor(textColor); |
|
159 |
textaux.draw(g,(int)(p1.getX()-w-10),(int)(p1.getY()+h/2)); |
|
160 |
textaux.draw(g,(int)p2.getX()+10,(int)(p2.getY()+h/2)); |
|
161 |
} |
|
162 |
valueIntervalY=valueIntervalY+intervalY; |
|
163 |
y=y+intervalY; |
|
164 |
} |
|
165 |
if (isLine()){ |
|
166 |
g.setColor(symbolLine.getColor()); |
|
167 |
g.setStroke(symbolLine.getStroke()); |
|
168 |
}else{ |
|
169 |
g.setColor(symbolPoint.getColor()); |
|
170 |
g.setStroke(new BasicStroke((int)1)); |
|
171 |
} |
|
172 |
// g.setColor(lineColor); |
|
173 |
|
|
174 |
g.draw(rView); |
|
175 |
|
|
176 |
x = extentX-distX; |
|
177 |
y = extentY-distY; |
|
178 |
|
|
179 |
if (isLine) { // Dibuja las l?neas. |
|
180 |
while(x<extent.getMaxX()){ |
|
181 |
Point2D antPoint=vp.fromMapPoint(x,extentY); |
|
182 |
if (x>extentX) { |
|
183 |
while(y<=extent.getMaxY()){ |
|
184 |
if (y>=extentY) { |
|
185 |
Point2D p=vp.fromMapPoint(x,y); |
|
186 |
IGeometry geom=createLine((int)antPoint.getX(),(int)antPoint.getY(),(int)p.getX(),(int)p.getY()); |
|
187 |
geom.draw(g,new ViewPort(null),symbolLine); |
|
188 |
antPoint=(Point2D)p.clone(); |
|
189 |
} |
|
190 |
|
|
191 |
y=y+intervalY; |
|
192 |
} |
|
193 |
Point2D p=vp.fromMapPoint(x,extent.getMaxY()); |
|
194 |
IGeometry geom=createLine((int)antPoint.getX(),(int)antPoint.getY(),(int)p.getX(),(int)p.getY()); |
|
195 |
geom.draw(g,new ViewPort(null),symbolLine); |
|
196 |
// g.drawLine((int)antPoint.getX(),(int)antPoint.getY(),(int)p.getX(),(int)p.getY()); |
|
197 |
antPoint=(Point2D)p.clone(); |
|
198 |
y=extentY-distY; |
|
199 |
|
|
200 |
} |
|
201 |
|
|
202 |
|
|
203 |
x=x+intervalX; |
|
204 |
} |
|
205 |
while(y<=extent.getMaxY()){ |
|
206 |
Point2D antPoint=vp.fromMapPoint(extentX,y); |
|
207 |
if (y>extentY) { |
|
208 |
while(x<=extent.getMaxX()){ |
|
209 |
if (x>=extentX) { |
|
210 |
Point2D p=vp.fromMapPoint(x,y); |
|
211 |
IGeometry geom=createLine((int)antPoint.getX(),(int)antPoint.getY(),(int)p.getX(),(int)p.getY()); |
|
212 |
geom.draw(g,new ViewPort(null),symbolLine); |
|
213 |
// g.drawLine((int)antPoint.getX(),(int)antPoint.getY(),(int)p.getX(),(int)p.getY()); |
|
214 |
antPoint=p; |
|
215 |
} |
|
216 |
x=x+intervalX; |
|
217 |
} |
|
218 |
Point2D p=vp.fromMapPoint(extent.getMaxX(),y); |
|
219 |
g.drawLine((int)antPoint.getX(),(int)antPoint.getY(),(int)p.getX(),(int)p.getY()); |
|
220 |
antPoint=(Point2D)p.clone(); |
|
221 |
x=extentX-distX; |
|
222 |
} |
|
223 |
y=y+intervalY; |
|
224 |
} |
|
225 |
} else { //Dibuja los puntos |
|
226 |
while(x<=extent.getMaxX()){ |
|
227 |
if (x>extentX) { |
|
228 |
while(y<=extent.getMaxY()){ |
|
229 |
if (y>=extentY) { |
|
230 |
Point2D p=vp.fromMapPoint(x,y); |
|
231 |
IGeometry geom=createPoint((int)p.getX(),(int)p.getY()); |
|
232 |
geom.draw(g,new ViewPort(null),symbolPoint); |
|
233 |
// g.drawLine((int)p.getX()-10,(int)p.getY(),(int)p.getX()+10,(int)p.getY()); |
|
234 |
// g.drawLine((int)p.getX(),(int)p.getY()-10,(int)p.getX(),(int)p.getY()+10); |
|
235 |
} |
|
236 |
y=y+intervalY; |
|
237 |
} |
|
238 |
y=extentY-distY; |
|
239 |
} |
|
240 |
x=x+intervalX; |
|
241 |
} |
|
242 |
|
|
243 |
} |
|
244 |
|
|
245 |
g.rotate(Math.toRadians(-getRotation()), r.x + (r.width / 2), |
|
246 |
r.y + (r.height / 2)); |
|
247 |
} |
|
248 |
|
|
249 |
private IGeometry createLine(int i, int j, int k, int l) { |
|
250 |
GeneralPathX gpx=new GeneralPathX(); |
|
251 |
gpx.moveTo(i,j); |
|
252 |
gpx.lineTo(k,l); |
|
253 |
return ShapeFactory.createPolyline2D(gpx); |
|
254 |
} |
|
255 |
private IGeometry createPoint(int i, int j){ |
|
256 |
return ShapeFactory.createPoint2D(i,j); |
|
257 |
} |
|
258 |
|
|
259 |
public void print(Graphics2D g, AffineTransform at) throws DriverException { |
|
260 |
print=true; |
|
261 |
draw(g,at,null,null); |
|
262 |
} |
|
263 |
|
|
264 |
public XMLEntity getXMLEntity() throws SaveException { |
|
265 |
XMLEntity xml = super.getXMLEntity(); |
|
266 |
try { |
|
267 |
|
|
268 |
xml.putProperty("fframegrid","fframegrid"); |
|
269 |
xml.addChild(this.symbolLine.getXMLEntity()); |
|
270 |
xml.addChild(this.symbolPoint.getXMLEntity()); |
|
271 |
xml.putProperty("showCornerText",this.showCornerText); |
|
272 |
xml.putProperty("familyFont",this.font.getFamily()); |
|
273 |
xml.putProperty("styleFont",this.font.getStyle()); |
|
274 |
|
|
275 |
xml.putProperty("intervalX", intervalX); |
|
276 |
xml.putProperty("intervalY", intervalY); |
|
277 |
xml.putProperty("isLine", isLine); |
|
278 |
// xml.putProperty("lineColor", StringUtilities.color2String(lineColor)); |
|
279 |
xml.putProperty("sizeFont", sizeFont); |
|
280 |
xml.putProperty("textColor", StringUtilities.color2String(textColor)); |
|
281 |
|
|
282 |
if (fframeview != null) { |
|
283 |
Layout layout = fframeview.getLayout(); |
|
284 |
IFFrame[] fframes = layout.getAllFFrames(); |
|
285 |
|
|
286 |
for (int i = 0; i < fframes.length; i++) { |
|
287 |
if (fframeview.equals(fframes[i])) { |
|
288 |
xml.putProperty("index", i); |
|
289 |
break; |
|
290 |
} |
|
291 |
} |
|
292 |
} |
|
293 |
} catch (Exception e) { |
|
294 |
throw new SaveException(e, this.getClass().getName()); |
|
295 |
} |
|
296 |
return xml; |
|
297 |
} |
|
298 |
public void setXMLEntity(XMLEntity xml) { |
|
299 |
if (xml.getIntProperty("m_Selected") != 0) { |
|
300 |
this.setSelected(true); |
|
301 |
} else { |
|
302 |
this.setSelected(false); |
|
303 |
} |
|
304 |
this.symbolLine=FSymbol.createFromXML(xml.getChild(0)); |
|
305 |
this.symbolPoint=FSymbol.createFromXML(xml.getChild(1)); |
|
306 |
this.showCornerText=xml.getBooleanProperty("showCornerText"); |
|
307 |
this.font=new Font(xml.getStringProperty("familyFont"),xml.getIntProperty("styleFont"),8); |
|
308 |
|
|
309 |
this.intervalX = xml.getDoubleProperty("intervalX"); |
|
310 |
this.intervalY = xml.getDoubleProperty("intervalY"); |
|
311 |
this.isLine = xml.getBooleanProperty("isLine"); |
|
312 |
// this.lineColor = StringUtilities.string2Color(xml |
|
313 |
// .getStringProperty("lineColor")); |
|
314 |
this.sizeFont = xml.getIntProperty("sizeFont"); |
|
315 |
this.textColor = StringUtilities.string2Color(xml |
|
316 |
.getStringProperty("textColor")); |
|
317 |
|
|
318 |
setRotation(xml.getDoubleProperty("m_rotation")); |
|
319 |
|
|
320 |
if (xml.contains("index")) { |
|
321 |
dependenceIndex = xml.getIntProperty("index"); |
|
322 |
} |
|
323 |
} |
|
324 |
|
|
325 |
public void setXMLEntity03(XMLEntity xml, Layout l) { |
|
326 |
// TODO Auto-generated method stub |
|
327 |
|
|
328 |
} |
|
329 |
|
|
330 |
public String getNameFFrame() { |
|
331 |
return PluginServices.getText(this, "cuadricula")+ num; |
|
332 |
} |
|
333 |
|
|
334 |
public void cloneActions(IFFrame frame) { |
|
335 |
// TODO Auto-generated method stub |
|
336 |
|
|
337 |
} |
|
338 |
|
|
339 |
public void setFFrameDependence(IFFrame f) { |
|
340 |
fframeview=(FFrameView)f; |
|
341 |
fframeview.refresh(); |
|
342 |
if (fframeview.getMapContext()!=null) |
|
343 |
setBoundBox(); |
|
344 |
} |
|
345 |
|
|
346 |
public IFFrame[] getFFrameDependence() { |
|
347 |
return new IFFrame[] {fframeview}; |
|
348 |
} |
|
349 |
|
|
350 |
/** |
|
351 |
* Actualiza las dependencias que tenga este FFrame con el resto. |
|
352 |
* |
|
353 |
* @param fframes Resto de FFrames. |
|
354 |
*/ |
|
355 |
public void initDependence(IFFrame[] fframes) { |
|
356 |
if ((dependenceIndex != -1) && fframes.length>dependenceIndex && |
|
357 |
fframes[dependenceIndex] instanceof FFrameView) { |
|
358 |
fframeview = (FFrameView) fframes[dependenceIndex]; |
|
359 |
} |
|
360 |
} |
|
361 |
|
|
362 |
public void setIntervalX(double d) { |
|
363 |
intervalX=d; |
|
364 |
} |
|
365 |
public void setIntervalY(double d) { |
|
366 |
intervalY=d; |
|
367 |
} |
|
368 |
public double getIntervalX() { |
|
369 |
return intervalX; |
|
370 |
} |
|
371 |
public double getIntervalY() { |
|
372 |
return intervalY; |
|
373 |
} |
|
374 |
public void setTextColor(Color textcolor) { |
|
375 |
textColor=textcolor; |
|
376 |
} |
|
377 |
|
|
378 |
public void setIsLine(boolean b) { |
|
379 |
isLine=b; |
|
380 |
} |
|
381 |
public boolean isLine() { |
|
382 |
return isLine; |
|
383 |
} |
|
384 |
|
|
385 |
// public IFFrameDialog getPropertyDialog() { |
|
386 |
// return new FFrameGridDialog(layout,this); |
|
387 |
// } |
|
388 |
|
|
389 |
public Color getFontColor() { |
|
390 |
return textColor; |
|
391 |
} |
|
392 |
|
|
393 |
public int getSizeFont() { |
|
394 |
return sizeFont; |
|
395 |
} |
|
396 |
|
|
397 |
public void setSizeFont(int sizeFont) { |
|
398 |
this.sizeFont = sizeFont; |
|
399 |
} |
|
400 |
|
|
401 |
public void setBoundBox() { |
|
402 |
Rectangle2D r=fframeview.getBoundBox(); |
|
403 |
Rectangle2D extent=fframeview.getMapContext().getViewPort().getAdjustedExtent(); |
|
404 |
double extentX=extent.getMaxX(); |
|
405 |
double extentY=extent.getMaxY(); |
|
406 |
int lengthX=String.valueOf((long)extentX).length(); |
|
407 |
double myScale = layout.getAT().getScaleX() * 0.0234; //FLayoutUtilities.fromSheetDistance(folio.getAncho(),at)/rv.getWidth(); |
|
408 |
int scaledFontSize = (int) (myScale * sizeFont); |
|
409 |
int pixelsX=(int)(lengthX*scaledFontSize*0.7); |
|
410 |
int lengthY=String.valueOf((long)extentY).length(); |
|
411 |
int pixelsY=(lengthY*scaledFontSize); |
|
412 |
double dX=FLayoutUtilities.toSheetDistance(pixelsX,layout.getAT()); |
|
413 |
double dY=FLayoutUtilities.toSheetDistance(pixelsY,layout.getAT()); |
|
414 |
Rectangle2D rBound=new Rectangle2D.Double(r.getMinX()-dY,r.getMinY()-dX,r.getWidth()+dY*2,r.getHeight()+dX*2); |
|
415 |
super.setBoundBox(rBound); |
|
416 |
} |
|
417 |
public Rectangle2D getMovieRect(int difx, int dify) { |
|
418 |
return this.getBoundingBox(null); |
|
419 |
} |
|
420 |
|
|
421 |
public void refreshDependence(IFFrame fant, IFFrame fnew) { |
|
422 |
if (fframeview.equals(fant)) { |
|
423 |
fframeview=(FFrameView)fnew; |
|
424 |
fframeview.refresh(); |
|
425 |
setBoundBox(); |
|
426 |
} |
|
427 |
|
|
428 |
} |
|
429 |
|
|
430 |
public void setLayout(Layout l) { |
|
431 |
this.layout=l; |
|
432 |
|
|
433 |
} |
|
434 |
|
|
435 |
public void drawHandlers(Graphics2D g) { |
|
436 |
g.setColor(Color.gray); |
|
437 |
super.drawHandlers(g); |
|
438 |
g.setColor(Color.black); |
|
439 |
} |
|
440 |
|
|
441 |
public Rectangle2D getLastMoveRect() { |
|
442 |
return getBoundBox(); |
|
443 |
} |
|
444 |
|
|
445 |
public void setBoundBox(Rectangle2D r) { |
|
446 |
if (fframeview!=null) |
|
447 |
setBoundBox(); |
|
448 |
else |
|
449 |
super.setBoundBox(r); |
|
450 |
} |
|
451 |
|
|
452 |
public FSymbol getSymbolLine() { |
|
453 |
return symbolLine; |
|
454 |
} |
|
455 |
|
|
456 |
public void setSymbolLine(FSymbol symbolLine) { |
|
457 |
this.symbolLine = symbolLine; |
|
458 |
} |
|
459 |
|
|
460 |
public FSymbol getSymbolPoint() { |
|
461 |
return symbolPoint; |
|
462 |
} |
|
463 |
|
|
464 |
public void setSymbolPoint(FSymbol symbolPoint) { |
|
465 |
this.symbolPoint = symbolPoint; |
|
466 |
} |
|
467 |
|
|
468 |
public Font getFont() { |
|
469 |
return font; |
|
470 |
} |
|
471 |
|
|
472 |
public void setFont(Font m_font) { |
|
473 |
this.font=m_font; |
|
474 |
} |
|
475 |
|
|
476 |
public void setLineSymbol(FSymbol symbol) { |
|
477 |
this.symbolLine=symbol; |
|
478 |
|
|
479 |
} |
|
480 |
|
|
481 |
public void setPointSymbol(FSymbol symbol) { |
|
482 |
this.symbolPoint=symbol; |
|
483 |
|
|
484 |
} |
|
485 |
|
|
486 |
public void showCornerText(boolean b) { |
|
487 |
showCornerText=b; |
|
488 |
|
|
489 |
} |
|
490 |
|
|
491 |
public int getFontSize() { |
|
492 |
return sizeFont; |
|
493 |
} |
|
494 |
|
|
495 |
public boolean isShowCornerText() { |
|
496 |
return showCornerText; |
|
497 |
} |
|
498 |
} |
Also available in: Unified diff