Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extGridViewLayout / src / com / iver / cit / gvsig / project / documents / layout / fframes / gui / dialogs / FFrameGridDialog.java @ 9534

History | View | Annotate | Download (10.9 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.fframes.FFrameGrid;
22
import com.iver.cit.gvsig.project.documents.layout.fframes.FFrameView;
23
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame;
24
import com.iver.cit.gvsig.project.documents.layout.fframes.ListViewModel;
25
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
26

    
27
public class FFrameGridDialog extends JPanel implements IFFrameDialog{
28

    
29
        private JPanel pMarcoVista=null;
30
        private JScrollPane jScrollPane;
31
        private JList liVistas;
32
        private Layout layout;
33
        private FFrameGrid fframegrid;
34
        private FFrameView fframeview;
35
        private JLabel lblInterval = null;
36
        private JTextField txtInterval = null;
37
        private JRadioButton rbPoints = null;
38
        private JRadioButton rbLines = null;
39
        private JLabel lblWight = null;
40
        private JTextField txtWidth = null;
41
        private JLabel lblColor = null;
42
        private ColorChooserPanel m_colorFont=null;
43
        private JLabel lblColorLine = null;
44
        private ColorChooserPanel m_colorLine=null;  //  @jve:decl-index=0:visual-constraint="441,177"
45
        private AcceptCancelPanel accept;
46
        private FFrameGrid newFFrameGrid;
47
        private Rectangle2D rect;
48
        private Color textcolor;
49
        private Color linecolor;
50
        private boolean isAcepted;
51
        private JLabel lblFontSize = null;
52
        private JTextField txtFontSize = null;
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
                linecolor=fframegrid.getLineColor();
66
                textcolor=fframegrid.getFontColor();
67
                initialize();
68
        }
69
        /**
70
         * This method initializes pMarcoVista
71
         *
72
         * @return javax.swing.JPanel
73
         */
74
        private JPanel getPMarcoVista() {
75
                if (pMarcoVista == null) {
76
                        pMarcoVista = new JPanel();
77
                        pMarcoVista.setBorder(javax.swing.BorderFactory.createTitledBorder(
78
                                        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));
79
                        pMarcoVista.setBounds(new java.awt.Rectangle(12,12,270,91));
80
                        pMarcoVista.add(getJScrollPane(), null);
81
                }
82

    
83
                return pMarcoVista;
84
        }
85
        private javax.swing.JScrollPane getJScrollPane() {
86
                if (jScrollPane == null) {
87
                        jScrollPane = new javax.swing.JScrollPane();
88
                        jScrollPane.setPreferredSize(new java.awt.Dimension(250,55));
89
                        jScrollPane.setViewportView(getLiVistas());
90
                }
91
                return jScrollPane;
92
        }
93
        private javax.swing.JList getLiVistas() {
94
                if (liVistas == null) {
95
                        ListViewModel listmodel = new ListViewModel();
96
                        listmodel.addViews(layout);
97

    
98
                        ///ArrayList list = listmodel.getViews();
99

    
100
                        liVistas = new javax.swing.JList();
101

    
102
                        liVistas.setSize(new java.awt.Dimension(250,52));
103
                        liVistas.setModel(listmodel);
104

    
105
                        for (int i = 0; i < liVistas.getModel().getSize(); i++) {
106
                                if (fframegrid.getFFrameDependence() != null) {
107
                                        fframeview = (FFrameView) liVistas.getModel().getElementAt(i);
108

    
109
                                        if (fframeview == fframegrid.getFFrameDependence()) {
110
                                                liVistas.setSelectedIndex(i);
111
                                        }
112
                                }
113
                        }
114

    
115
                        liVistas.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
116
                                        private int selectIndex=-1;
117
                                        public void valueChanged(
118
                                                                javax.swing.event.ListSelectionEvent e) {
119
                                                IFFrame[] fframes=layout.getLayoutContext().getFFrames();
120
                                                        int selectInt = ((JList) e.getSource())
121
                                                                        .getSelectedIndex();
122
                                                        if (selectInt != selectIndex) {
123
                                                                selectIndex = selectInt;
124
                                                                if (selectIndex == -1)
125
                                                                        return;
126
                                                                fframeview = (FFrameView) liVistas.getModel()
127
                                                                                .getElementAt(selectInt);
128

    
129
                                                                for (int i = 0; i < fframes.length; i++) {
130
                                                                        IFFrame f = fframes[i];
131

    
132
                                                                        if (f instanceof FFrameView) {
133
                                                                                if (((FFrameView) f).getView() == fframeview
134
                                                                                                .getView()) {
135
                                                                                        fframegrid
136
                                                                                                        .setFFrameDependence(fframeview);
137
                                                                                }
138
                                                                        }
139
                                                                }
140

    
141
//                                                                getTNumIntervalos().setText(
142
//                                                                                String.valueOf(fframescalebar
143
//                                                                                                .getNumInterval()));
144
//                                                                getTDivIzquierda().setText(
145
//                                                                                String.valueOf(fframescalebar
146
//                                                                                                .getNumLeft()));
147
//                                                                getTIntervalo().setText(
148
//                                                                                fframescalebar.obtainInterval());
149
//                                                                getTfNumberScale().setText(
150
//                                                                                fframescalebar.getDescription());
151
                                                        }
152
                                                }
153
                                        });
154
                }
155

    
156
                return liVistas;
157
        }
158

    
159
        /**
160
         * This method initializes this
161
         *
162
         * @return void
163
         */
164
        private void initialize() {
165
                lblFontSize = new JLabel();
166
                lblFontSize.setBounds(new java.awt.Rectangle(13,177,98,24));
167
                lblFontSize.setText("font_size");
168
                lblColorLine = new JLabel();
169
                lblColorLine.setBounds(new java.awt.Rectangle(204,207,87,27));
170
                lblColorLine.setText("color_linea");
171
                lblColor = new JLabel();
172
                lblColor.setBounds(new java.awt.Rectangle(15,210,96,21));
173
                lblColor.setText("color_fuente");
174
                lblWight = new JLabel();
175
                lblWight.setBounds(new java.awt.Rectangle(205,111,88,24));
176
                lblWight.setText("grosor_linea");
177
                lblInterval = new JLabel();
178
                lblInterval.setBounds(new java.awt.Rectangle(13,111,89,23));
179
                lblInterval.setText("intervalo");
180
                this.setLayout(null);
181
                this.setSize(426, 295);
182
                this.add(getPMarcoVista(), null);
183
                this.add(lblInterval, null);
184
                this.add(getTxtInterval(), null);
185

    
186
                this.add(getRbPoints(), null);
187
                this.add(getRbLines(), null);
188
                this.add(lblWight, null);
189
                this.add(getTxtWidth(), null);
190
                this.add(lblColor, null);
191
                this.add(getColorFont(), null);
192
                this.add(lblColorLine, null);
193
                this.add(getColorLine(), null);
194
                this.add(getAcceptCancelPanel(), null);
195
                this.add(lblFontSize, null);
196
                this.add(getTxtFontSize(), null);
197
                ButtonGroup group = new ButtonGroup();
198
            group.add(getRbPoints());
199
            group.add(getRbLines());
200
        }
201

    
202
        public void setRectangle(Rectangle2D r) {
203
                rect=r;
204
        }
205
        private ColorChooserPanel getColorFont() {
206
                if (m_colorFont == null) {
207
                        m_colorFont = new ColorChooserPanel();
208
                        m_colorFont.setAlpha(255);
209
                        m_colorFont.setBounds(new java.awt.Rectangle(126,208,63,25));
210
                        m_colorFont.setColor(fframegrid.getFontColor());
211
                        m_colorFont.addActionListener(new java.awt.event.ActionListener() {
212
                                public void actionPerformed(ActionEvent e) {
213
                                        textcolor=m_colorFont.getColor();
214
                                }
215
                        });
216
                }
217
                return m_colorFont;
218
        }
219
        private ColorChooserPanel getColorLine() {
220
                if (m_colorLine == null) {
221
                        m_colorLine = new ColorChooserPanel();
222
                        m_colorLine.setAlpha(255);
223
                        m_colorLine.setBounds(new java.awt.Rectangle(304,208,61,25));
224
                        m_colorLine.setSize(new java.awt.Dimension(80,25));
225
                        m_colorLine.setColor(fframegrid.getLineColor());
226
                        m_colorLine.addActionListener(new java.awt.event.ActionListener() {
227
                                public void actionPerformed(ActionEvent e) {
228
                                        linecolor=m_colorLine.getColor();
229
                                }
230
                        });
231
                }
232
                return m_colorLine;
233
        }
234
        public WindowInfo getWindowInfo() {
235
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG|WindowInfo.RESIZABLE);
236
                m_viewinfo.setTitle(PluginServices.getText(this,
237
                                "cuadricula"));
238

    
239
                return m_viewinfo;
240
        }
241

    
242
        public boolean getIsAcepted() {
243
                // TODO Auto-generated method stub
244
                return false;
245
        }
246

    
247
        public IFFrame getFFrame() {
248
                return newFFrameGrid;
249
        }
250
        /**
251
         * This method initializes txtInterval
252
         *
253
         * @return javax.swing.JTextField
254
         */
255
        private JTextField getTxtInterval() {
256
                if (txtInterval == null) {
257
                        txtInterval = new JTextField();
258
                        txtInterval.setBounds(new java.awt.Rectangle(115,111,85,23));
259
                        txtInterval.setText(String.valueOf(fframegrid.getInterval()));
260
                }
261
                return txtInterval;
262
        }
263
        /**
264
         * This method initializes rbPoints
265
         *
266
         * @return javax.swing.JRadioButton
267
         */
268
        private JRadioButton getRbPoints() {
269
                if (rbPoints == null) {
270
                        rbPoints = new JRadioButton();
271
                        rbPoints.setBounds(new java.awt.Rectangle(17,148,120,21));
272
                        rbPoints.setText("puntos");
273
                        rbPoints.setSelected(!fframegrid.isLine());
274
                }
275
                return rbPoints;
276
        }
277
        /**
278
         * This method initializes rbLines
279
         *
280
         * @return javax.swing.JRadioButton
281
         */
282
        private JRadioButton getRbLines() {
283
                if (rbLines == null) {
284
                        rbLines = new JRadioButton();
285
                        rbLines.setBounds(new java.awt.Rectangle(149,146,154,25));
286
                        rbLines.setText("lineas");
287
                        rbLines.setSelected(fframegrid.isLine());
288
                }
289
                return rbLines;
290
        }
291
        /**
292
         * This method initializes txtWidth
293
         *
294
         * @return javax.swing.JTextField
295
         */
296
        private JTextField getTxtWidth() {
297
                if (txtWidth == null) {
298
                        txtWidth = new JTextField();
299
                        txtWidth.setBounds(new java.awt.Rectangle(298,112,47,23));
300
                        txtWidth.setText(String.valueOf(fframegrid.getLineWidth()));
301
                }
302
                return txtWidth;
303
        }
304
        private AcceptCancelPanel getAcceptCancelPanel() {
305
                if (accept == null) {
306
                        ActionListener okAction, cancelAction;
307
                        okAction = new java.awt.event.ActionListener() {
308

    
309
                                public void actionPerformed(java.awt.event.ActionEvent e) {
310
                                        newFFrameGrid = (FFrameGrid) fframegrid
311
                                                        .cloneFFrame(layout);
312
                                        newFFrameGrid.setFFrameDependence(fframeview);
313
                                        newFFrameGrid.setBoundBox();
314
                                        newFFrameGrid.setInterval(Double.parseDouble(getTxtInterval().getText().toString()));
315
                                        newFFrameGrid.setLineWidth((Double.parseDouble(getTxtWidth().getText().toString())));
316

    
317
                                        newFFrameGrid.setTextColor(textcolor);
318
                                        newFFrameGrid.setLineColor(linecolor);
319

    
320
                                        newFFrameGrid.setIsLine(getRbLines().isSelected());
321
                                        newFFrameGrid.setSizeFont(Integer.parseInt(getTxtFontSize().getText()));
322

    
323
                                        newFFrameGrid.setRotation(fframeview.getRotation());
324
                                        PluginServices.getMDIManager().closeWindow(
325
                                                        FFrameGridDialog.this);
326
                                        // m_layout.refresh();
327
                                        isAcepted = true;
328
                                }
329
                        };
330
                        cancelAction = new java.awt.event.ActionListener() {
331
                                public void actionPerformed(java.awt.event.ActionEvent e) {
332
                                        newFFrameGrid=null;
333
                                        PluginServices.getMDIManager().closeWindow(
334
                                                        FFrameGridDialog.this);
335
                                }
336
                        };
337
                        accept = new AcceptCancelPanel(okAction, cancelAction);
338
                        accept.setPreferredSize(new java.awt.Dimension(300, 300));
339
                        // accept.setBounds(new java.awt.Rectangle(243,387,160,28));
340
                        accept.setEnabled(true);
341
                        accept.setBounds(new java.awt.Rectangle(45, 250, 300, 32));
342
                        accept.setVisible(true);
343
                }
344
                return accept;
345
        }
346
        /**
347
         * This method initializes txtFontSize
348
         *
349
         * @return javax.swing.JTextField
350
         */
351
        private JTextField getTxtFontSize() {
352
                if (txtFontSize == null) {
353
                        txtFontSize = new JTextField();
354
                        txtFontSize.setBounds(new java.awt.Rectangle(127,176,52,26));
355
                        txtFontSize.setText(String.valueOf(fframegrid.getSizeFont()));
356
                }
357
                return txtFontSize;
358
        }
359

    
360
}  //  @jve:decl-index=0:visual-constraint="10,10"