Statistics
| Revision:

svn-document-layout / trunk / org.gvsig.app.document.layout.app / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / fframes / gui / dialogs / FFrameGroupDialog.java @ 5

History | View | Annotate | Download (6.61 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.project.documents.layout.fframes.gui.dialogs;
23

    
24
import java.awt.geom.Rectangle2D;
25

    
26
import org.gvsig.andami.PluginServices;
27
import org.gvsig.andami.ui.mdiManager.WindowInfo;
28
import org.gvsig.app.project.documents.layout.FLayoutUtilities;
29
import org.gvsig.app.project.documents.layout.fframes.FFrameGroup;
30
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
31
import org.gvsig.app.project.documents.layout.fframes.gui.JPRotation;
32
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
33

    
34
/**
35
 * Di?logo de un grupo de fframe del Layout.
36
 * 
37
 * @author Vicente Caballero Navarro
38
 */
39
public class FFrameGroupDialog extends AbstractFFrameDialog implements
40
    IFFrameDialog {
41

    
42
    private static final long serialVersionUID = -7614158074124712725L;
43
    private javax.swing.JPanel jContentPane = null;
44
    private javax.swing.JButton bAceptar = null;
45
    private javax.swing.JButton bCancelar = null;
46
    private Rectangle2D rect = new Rectangle2D.Double();
47
    private FFrameGroup fframegroup = null;
48
    private boolean isAcepted = false;
49
    private JPRotation pRotation = null;
50
    private FFrameGroup newFFrameGroup;
51

    
52
    /**
53
     * This is the default constructor
54
     * 
55
     * @param layoutPanel
56
     *            Referencia al Layout.
57
     * @param fframe
58
     *            Referencia al fframe de imagen.
59
     */
60
    public FFrameGroupDialog(LayoutPanel layoutPanel, IFFrame frame) {
61
        super(layoutPanel, frame);
62
        fframegroup = (FFrameGroup) frame;
63
        initialize();
64
    }
65

    
66
    /**
67
     * Inserta el rect?ngulo que ocupar? el fframe de imagen.
68
     * 
69
     * @param r
70
     *            Rect?ngulo.
71
     */
72
    public void setRectangle(Rectangle2D r) {
73
        rect.setRect(r);
74
    }
75

    
76
    /**
77
     * This method initializes this
78
     */
79
    private void initialize() {
80
        this.setLayout(null);
81
        this.add(getJContentPane(), null);
82
        this.setSize(196, 191);
83
        getPRotation().setRotation(fframegroup.getRotation());
84
    }
85

    
86
    /**
87
     * This method initializes jContentPane
88
     * 
89
     * @return javax.swing.JPanel
90
     */
91
    private javax.swing.JPanel getJContentPane() {
92
        if (jContentPane == null) {
93
            jContentPane = new javax.swing.JPanel();
94
            jContentPane.setLayout(null);
95
            jContentPane.add(getBAceptar(), null);
96
            jContentPane.add(getBCancelar(), null);
97
            jContentPane.setSize(192, 186);
98
            jContentPane.setLocation(0, 0);
99
            jContentPane.add(getPRotation(), null);
100
        }
101

    
102
        return jContentPane;
103
    }
104

    
105
    /**
106
     * This method initializes bAceptar
107
     * 
108
     * @return javax.swing.JButton
109
     */
110
    private javax.swing.JButton getBAceptar() {
111
        if (bAceptar == null) {
112
            bAceptar = new javax.swing.JButton();
113
            bAceptar.setSize(85, 26);
114
            bAceptar.setText(PluginServices.getText(this, "Aceptar"));
115
            bAceptar.setLocation(7, 147);
116
            bAceptar.addActionListener(new java.awt.event.ActionListener() {
117

    
118
                public void actionPerformed(java.awt.event.ActionEvent e) {
119
                    try {
120
                        newFFrameGroup = (FFrameGroup) fframegroup.clone();
121
                        newFFrameGroup.setBoundBox(FLayoutUtilities
122
                            .toSheetRect(rect, layoutPanel.getLayoutControl()
123
                                .getAT()));
124
                        newFFrameGroup
125
                            .setRotation(getPRotation().getRotation());
126
                    } catch (CloneNotSupportedException e1) {
127
                        LOG.error("It is not possible clonate the object", e);
128
                    }
129
                    PluginServices.getMDIManager().closeWindow(
130
                        FFrameGroupDialog.this);
131
                    // m_layout.refresh();
132
                    isAcepted = true;
133
                }
134
            });
135
        }
136

    
137
        return bAceptar;
138
    }
139

    
140
    /**
141
     * This method initializes bCancelar
142
     * 
143
     * @return javax.swing.JButton
144
     */
145
    private javax.swing.JButton getBCancelar() {
146
        if (bCancelar == null) {
147
            bCancelar = new javax.swing.JButton();
148
            bCancelar.setSize(85, 26);
149
            bCancelar.setText(PluginServices.getText(this, "Cancelar"));
150
            bCancelar.setLocation(99, 147);
151
            bCancelar.addActionListener(new java.awt.event.ActionListener() {
152

    
153
                public void actionPerformed(java.awt.event.ActionEvent e) {
154
                    PluginServices.getMDIManager().closeWindow(
155
                        FFrameGroupDialog.this);
156
                }
157
            });
158
        }
159

    
160
        return bCancelar;
161
    }
162

    
163
    /*
164
     * (non-Javadoc)
165
     * 
166
     * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
167
     */
168
    public WindowInfo getWindowInfo() {
169
        WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
170
        m_viewinfo.setTitle(PluginServices.getText(this,
171
            "propiedades_marco_imagenes"));
172

    
173
        return m_viewinfo;
174
    }
175

    
176
    /**
177
     * @see org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog#getIsAcepted()
178
     */
179
    public boolean getIsAcepted() {
180
        return isAcepted;
181
    }
182

    
183
    /**
184
     * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
185
     */
186
    public void viewActivated() {
187
    }
188

    
189
    /**
190
     * This method initializes pRotation
191
     * 
192
     * @return javax.swing.JPanel
193
     */
194
    private JPRotation getPRotation() {
195
        if (pRotation == null) {
196
            pRotation = new JPRotation();
197
            pRotation.setBounds(30, 10, 120, 120);
198
        }
199
        return pRotation;
200
    }
201

    
202
    public IFFrame getFFrame() {
203
        return newFFrameGroup;
204
    }
205

    
206
    public Object getWindowProfile() {
207
        return WindowInfo.DIALOG_PROFILE;
208
    }
209

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