root / trunk / extensions / extAnnotations / src / org / gvsig / tools / annotations / labeling / gui / SingleLabelingToolUI.java @ 24994
History | View | Annotate | Download (5.87 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2008 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Lerida 20
|
35 |
* 46009 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.tools.annotations.labeling.gui; |
42 |
|
43 |
import java.awt.Dimension; |
44 |
import java.awt.GridBagConstraints; |
45 |
import java.awt.GridBagLayout; |
46 |
import java.awt.Insets; |
47 |
import java.awt.event.ActionEvent; |
48 |
import java.awt.event.ActionListener; |
49 |
|
50 |
import javax.swing.BorderFactory; |
51 |
import javax.swing.JButton; |
52 |
import javax.swing.JLabel; |
53 |
import javax.swing.JPanel; |
54 |
import javax.swing.JTextField; |
55 |
import javax.swing.border.Border; |
56 |
|
57 |
import com.iver.andami.PluginServices; |
58 |
import com.iver.andami.ui.mdiManager.IWindow; |
59 |
import com.iver.andami.ui.mdiManager.IWindowListener; |
60 |
import com.iver.andami.ui.mdiManager.SingletonWindow; |
61 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
62 |
import com.iver.cit.gvsig.fmap.layers.Annotation_Layer; |
63 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
64 |
import com.iver.cit.gvsig.project.documents.view.tool.gui.TextPropertiesPanel; |
65 |
|
66 |
/**
|
67 |
*
|
68 |
* @author Cesar Martinez Izquierdo <cesar.martinez@iver.es> Oct 2008
|
69 |
*
|
70 |
*/
|
71 |
public class SingleLabelingToolUI extends JPanel implements IWindow, IWindowListener, SingletonWindow { |
72 |
private static final long serialVersionUID = 1L; |
73 |
public static final String TOOL_CLOSED_PROP = "toolClosed"; |
74 |
public static final String TARGET_LAYER_CHANGED_PROP = "targetLayerChanged"; |
75 |
|
76 |
private WindowInfo wInfo = null; |
77 |
private BaseView view;
|
78 |
private JTextField targetLayerField; |
79 |
private Annotation_Layer targetLayer;
|
80 |
private TextPropertiesPanel textPropPanel = null; |
81 |
|
82 |
public SingleLabelingToolUI(BaseView view) {
|
83 |
super();
|
84 |
this.view = view;
|
85 |
initialize(); |
86 |
} |
87 |
|
88 |
private void initialize() { |
89 |
this.setLayout(new GridBagLayout()); |
90 |
JLabel label = new JLabel( |
91 |
PluginServices.getText(this, "Target_annotation_layer")); |
92 |
GridBagConstraints constraints = new GridBagConstraints(); |
93 |
constraints.gridy = 0;
|
94 |
constraints.gridx = 0;
|
95 |
constraints.insets = new Insets(4, 4, 4, 4); |
96 |
this.add(label, constraints);
|
97 |
|
98 |
targetLayerField = new JTextField(9); |
99 |
targetLayerField.setEditable(false);
|
100 |
constraints.gridy = 0;
|
101 |
constraints.gridx = 1;
|
102 |
targetLayerField.setMinimumSize(new Dimension(20,6)); |
103 |
this.add(targetLayerField, constraints);
|
104 |
|
105 |
JButton labExpressionBtn = new JButton("..."); |
106 |
labExpressionBtn.addActionListener(new ActionListener() { |
107 |
|
108 |
public void actionPerformed(ActionEvent e) { |
109 |
PluginServices.getMDIManager().addCentredWindow(new ConfigTargetLayer(view, SingleLabelingToolUI.this));
|
110 |
} |
111 |
}); |
112 |
constraints.gridy = 0;
|
113 |
constraints.gridx = 2;
|
114 |
this.add(labExpressionBtn, constraints);
|
115 |
|
116 |
constraints.gridy = 0;
|
117 |
constraints.gridx = 0;
|
118 |
constraints.gridwidth = 1;
|
119 |
constraints.anchor = GridBagConstraints.EAST;
|
120 |
JPanel panel = new JPanel(); // required to give some insets to the textProp panel |
121 |
panel.add(getTextPropertiesPanel(), constraints); |
122 |
|
123 |
constraints.gridy = 1;
|
124 |
constraints.gridx = 0;
|
125 |
constraints.gridwidth = 3;
|
126 |
constraints.anchor = GridBagConstraints.CENTER;
|
127 |
constraints.fill = GridBagConstraints.BOTH;
|
128 |
Border border = BorderFactory.createTitledBorder(PluginServices.getText(this, "Label_properties")); |
129 |
panel.setBorder(border); |
130 |
this.add(panel, constraints);
|
131 |
|
132 |
labExpressionBtn = new JButton(PluginServices.getText(this, "Set_labeling_expression")); |
133 |
labExpressionBtn.addActionListener(new ActionListener() { |
134 |
public void actionPerformed(ActionEvent e) { |
135 |
PluginServices.getMDIManager().addCentredWindow(new ConfigLabelingExpression(view));
|
136 |
|
137 |
} |
138 |
}); |
139 |
constraints.gridy = 2;
|
140 |
constraints.gridx = 0;
|
141 |
constraints.gridwidth = 3;
|
142 |
constraints.fill = GridBagConstraints.NONE;
|
143 |
constraints.anchor = GridBagConstraints.CENTER;
|
144 |
this.add(labExpressionBtn, constraints);
|
145 |
|
146 |
} |
147 |
|
148 |
public WindowInfo getWindowInfo() {
|
149 |
if (wInfo==null) { |
150 |
wInfo = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE);
|
151 |
wInfo.setWidth(330);
|
152 |
wInfo.setHeight(280);
|
153 |
wInfo.setTitle(PluginServices.getText(this, "SingleLabelingTool")+" -- "+ |
154 |
PluginServices.getMDIManager().getWindowInfo(view).getTitle()); |
155 |
wInfo.setY(200);
|
156 |
} |
157 |
return wInfo;
|
158 |
} |
159 |
|
160 |
public void windowActivated() { |
161 |
} |
162 |
|
163 |
public void windowClosed() { |
164 |
firePropertyChange(TOOL_CLOSED_PROP, null, "closed"); |
165 |
} |
166 |
|
167 |
public Object getWindowModel() { |
168 |
return view;
|
169 |
} |
170 |
|
171 |
public TextPropertiesPanel getTextPropertiesPanel() {
|
172 |
if (textPropPanel==null) { |
173 |
textPropPanel = new TextPropertiesPanel();
|
174 |
} |
175 |
return textPropPanel;
|
176 |
} |
177 |
|
178 |
public void setTargetLayer(Annotation_Layer newTargetLayer) { |
179 |
if (this.targetLayer!=newTargetLayer) { |
180 |
Annotation_Layer oldLayer = this.targetLayer;
|
181 |
this.targetLayer = newTargetLayer;
|
182 |
targetLayerField.setText(newTargetLayer.getName()); |
183 |
firePropertyChange(TARGET_LAYER_CHANGED_PROP, oldLayer, newTargetLayer); |
184 |
} |
185 |
} |
186 |
|
187 |
public Annotation_Layer getTargetLayer() {
|
188 |
return targetLayer;
|
189 |
} |
190 |
|
191 |
public Object getWindowProfile() { |
192 |
return WindowInfo.TOOL_PROFILE;
|
193 |
} |
194 |
} |