Statistics
| Revision:

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

History | View | Annotate | Download (6.77 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.event.ActionEvent;
25
import java.awt.geom.Rectangle2D;
26

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

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

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

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

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

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

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

    
103
        return jContentPane;
104
    }
105

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

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

    
139
        return bAceptar;
140
    }
141

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

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

    
163
        return bCancelar;
164
    }
165

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

    
176
        return m_viewinfo;
177
    }
178

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

    
186
    /**
187
     * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
188
     */
189
    public void viewActivated() {
190
    }
191

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

    
205
    public IFFrame getFFrame() {
206
        return newFFrameGroup;
207
    }
208

    
209
    public Object getWindowProfile() {
210
        return WindowInfo.DIALOG_PROFILE;
211
    }
212

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