Revision 45523 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.swing/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/app/gui/styling/PictureMarker.java
PictureMarker.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.app.gui.styling; |
25 | 25 |
|
26 |
import java.awt.FlowLayout; |
|
27 |
import java.awt.Font; |
|
26 |
import java.awt.Color; |
|
28 | 27 |
import java.awt.event.ActionEvent; |
29 | 28 |
import java.awt.event.ActionListener; |
30 | 29 |
import java.awt.geom.Point2D; |
31 | 30 |
import java.io.File; |
32 |
import java.io.IOException; |
|
33 |
import java.net.URISyntaxException; |
|
34 | 31 |
import java.net.URL; |
35 | 32 |
import java.util.ArrayList; |
33 |
import java.util.List; |
|
36 | 34 |
|
37 |
import javax.swing.JButton; |
|
38 |
import javax.swing.JFileChooser; |
|
39 |
import javax.swing.JLabel; |
|
40 | 35 |
import javax.swing.JPanel; |
41 |
import javax.swing.filechooser.FileFilter; |
|
42 |
|
|
43 |
import org.gvsig.andami.messages.NotificationManager; |
|
36 |
import javax.swing.SpinnerNumberModel; |
|
37 |
import javax.swing.event.ChangeEvent; |
|
38 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
|
39 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
|
40 |
import org.gvsig.expressionevaluator.swing.ExpressionPickerController; |
|
41 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
42 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
|
43 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
|
44 | 44 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
45 | 45 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
46 | 46 |
import org.gvsig.fmap.mapcontext.rendering.symbols.IWarningSymbol; |
47 | 47 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException; |
48 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
|
49 |
import org.gvsig.gui.beans.swing.JNumberSpinner; |
|
50 | 48 |
import org.gvsig.i18n.Messages; |
51 | 49 |
import org.gvsig.symbology.SymbologyLocator; |
50 |
import org.gvsig.symbology.SymbologyManager; |
|
52 | 51 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IPictureMarkerSymbol; |
52 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
53 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
54 |
import org.gvsig.tools.swing.api.pickercontroller.ColorPickerController; |
|
55 |
import org.gvsig.tools.swing.api.pickercontroller.FilePickerController; |
|
56 |
import org.gvsig.tools.util.URLUtils; |
|
57 |
import org.slf4j.Logger; |
|
58 |
import org.slf4j.LoggerFactory; |
|
53 | 59 |
|
54 | 60 |
/** |
55 |
* PictureMarker allows the user to store and modify the properties that define a |
|
61 |
* PictureMarker allows the user to store and modify the properties that define |
|
62 |
* a |
|
56 | 63 |
* <b>picture marker symbol</b>.<p> |
57 | 64 |
* <p> |
58 | 65 |
* This functionality is carried out thanks to a tab (simple marker)which is |
59 |
* included in the panel to edit the properities of a symbol (SymbolEditor)how is
|
|
60 |
* explained in AbstractTypeSymbolEditor. |
|
66 |
* included in the panel to edit the properities of a symbol (SymbolEditor)how |
|
67 |
* is explained in AbstractTypeSymbolEditor.
|
|
61 | 68 |
* <p> |
62 | 69 |
* First of all, in the above mentioned tab the user will have options to change |
63 |
* the files from where the pictures for the symbol are taken (one for the symbol |
|
64 |
* when it is not selected in the map and the other when it is done).<p> |
|
70 |
* the files from where the pictures for the symbol are taken (one for the |
|
71 |
* symbol when it is not selected in the map and the other when it is done) |
|
72 |
* .<p> |
|
65 | 73 |
* <p> |
66 | 74 |
* Secondly, the user will have options to modify the pictures which had been |
67 |
* selected before (width and offset) .
|
|
75 |
* selected before (width and offset) . |
|
68 | 76 |
* |
69 |
*@see AbstractTypeSymbolEditor |
|
70 |
*@author jaume dominguez faus - jaume.dominguez@iver.es
|
|
77 |
* @see AbstractTypeSymbolEditor
|
|
78 |
* @author gvSIG Team
|
|
71 | 79 |
*/ |
72 |
public class PictureMarker extends AbstractTypeSymbolEditor implements |
|
73 |
ActionListener { |
|
80 |
@SuppressWarnings("UseSpecificCatch") |
|
81 |
public class PictureMarker |
|
82 |
extends AbstractTypeSymbolEditor |
|
83 |
implements ActionListener { |
|
84 |
|
|
85 |
protected static final Logger LOGGER = LoggerFactory.getLogger(PictureMarker.class); |
|
74 | 86 |
|
75 | 87 |
public static final double MARKER_IMAGE_DEFAULT_WIDTH = 18; |
76 |
|
|
77 |
protected ArrayList<JPanel> tabs = new ArrayList<JPanel>(); |
|
78 |
protected JNumberSpinner txtSize; |
|
79 |
protected JNumberSpinner txtX; |
|
80 |
protected JNumberSpinner txtY; |
|
81 |
//TODO: Comentarizado hasta que mask est? acabado |
|
82 |
// protected Mask mask; |
|
83 |
protected JLabel lblFileName; |
|
84 |
protected JLabel lblSelFileName; |
|
85 |
private File picFile; |
|
86 |
protected JLabel lblSize = new JLabel(Messages.getText("width")+":"); |
|
87 |
protected JLabel lblX = new JLabel(Messages.getText("x_offset")+":"); |
|
88 |
protected JLabel lblY = new JLabel(Messages.getText("y_offset")+":"); |
|
89 |
private JButton btn; |
|
90 |
private JButton btnSel; |
|
91 | 88 |
|
92 |
private ActionListener chooseAction = new ActionListener() {
|
|
89 |
private PictureMarkerView view = new PictureMarkerView();
|
|
93 | 90 |
|
94 |
public void actionPerformed(ActionEvent e) {
|
|
91 |
protected List<JPanel> tabs = new ArrayList<>();
|
|
95 | 92 |
|
96 |
JLabel targetLbl; |
|
97 |
if (e.getSource().equals(btn)) { |
|
98 |
targetLbl = lblFileName; |
|
99 |
} else { |
|
100 |
targetLbl = lblSelFileName; |
|
101 |
} |
|
102 |
FileFilter ff = new FileFilter() { |
|
103 |
public boolean accept(File f) { |
|
104 |
if (f.isDirectory()) return true; |
|
105 |
String fName = f.getAbsolutePath(); |
|
106 |
if (fName!=null) { |
|
107 |
fName = fName.toLowerCase(); |
|
108 |
return fName.endsWith(".png") |
|
109 |
|| fName.endsWith(".gif") |
|
110 |
|| fName.endsWith(".jpg") |
|
111 |
|| fName.endsWith(".jpeg") |
|
112 |
|| fName.endsWith(".bmp") |
|
113 |
|| fName.endsWith(".svg"); |
|
114 |
} |
|
115 |
return false; |
|
116 |
} |
|
93 |
//TODO: Comentarizado hasta que mask est? acabado |
|
94 |
// protected Mask mask; |
|
95 |
private FilePickerController picturePicker; |
|
96 |
private FilePickerController selectedPicturePicker; |
|
97 |
private ColorPickerController colorLinePicker; |
|
98 |
private ExpressionPickerController xoffsetExpPicker; |
|
99 |
private ExpressionPickerController yoffsetExpPicker; |
|
100 |
private ExpressionPickerController rotationExpPicker; |
|
101 |
private ExpressionPickerController colorExpPicker; |
|
117 | 102 |
|
118 |
public String getDescription() { |
|
119 |
return Messages.getText("bitmap_and_svg_image_files"); |
|
120 |
} |
|
121 |
}; |
|
122 |
JUrlFileChooser jfc = new JUrlFileChooser(getName(), null); |
|
123 |
jfc.setFileFilter(ff); |
|
124 |
jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); |
|
125 |
jfc.setSelectedFile(picFile); |
|
126 |
jfc.setMultiSelectionEnabled(false); |
|
127 |
int returnVal = jfc.showOpenDialog(PictureMarker.this.owner); |
|
128 |
if(returnVal == JFileChooser.APPROVE_OPTION) { |
|
103 |
public PictureMarker(SymbolEditor owner) { |
|
104 |
super(owner); |
|
105 |
initComponents(); |
|
106 |
} |
|
129 | 107 |
|
130 |
URL url = jfc.getSelectedURL(); |
|
131 |
if (url == null) return; |
|
132 |
try { |
|
133 |
targetLbl.setText(url.toURI().getPath()); |
|
134 |
} catch (URISyntaxException e1) { |
|
135 |
NotificationManager.addWarning("URI Syntax error", e1); |
|
136 |
} //.toString()); |
|
137 |
fireSymbolChangedEvent(); |
|
138 |
} |
|
139 |
// if(returnVal == JFileChooser.APPROVE_OPTION) { |
|
140 |
// File myFile = jfc.getSelectedFile(); |
|
141 |
// lastDir = jfc.getCurrentDirectory(); |
|
142 |
// if (myFile != null && myFile.exists()) { |
|
143 |
// if (isSelection) { |
|
144 |
// selPicFile = myFile; |
|
145 |
// } else { |
|
146 |
// picFile = myFile; |
|
147 |
// } |
|
148 |
// try { |
|
149 |
// targetLbl.setText(myFile.toURL().toString()); |
|
150 |
// } catch (MalformedURLException e1) { |
|
151 |
// NotificationManager.addError(PluginServices.getText(this, "Error en la creaci?n" + |
|
152 |
// "de la URL"), e1); |
|
153 |
// } |
|
154 |
// fireSymbolChangedEvent(); |
|
155 |
// } |
|
156 |
// } |
|
108 |
private void translate() { |
|
109 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
|
110 |
toolsSwingManager.translate(view.lblLabelFileName); |
|
111 |
toolsSwingManager.translate(view.lblLabelRotationExpression); |
|
112 |
toolsSwingManager.translate(view.lblLabelSelFileName); |
|
113 |
toolsSwingManager.translate(view.lblLabelSize); |
|
114 |
toolsSwingManager.translate(view.lblLabelX); |
|
115 |
toolsSwingManager.translate(view.lblLabelXExpression); |
|
116 |
toolsSwingManager.translate(view.lblLabelY); |
|
117 |
toolsSwingManager.translate(view.lblLabelYExpression); |
|
118 |
} |
|
157 | 119 |
|
158 |
btnSel.setEnabled(lblFileName.getText()!=""); |
|
120 |
/** |
|
121 |
* Initializes the parameters that define a picturmarker.To do it, a tab is |
|
122 |
* created inside the SymbolEditor panel with default values for the |
|
123 |
* different attributes of the picture marker. |
|
124 |
*/ |
|
125 |
private void initComponents() { |
|
159 | 126 |
|
160 |
} |
|
127 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
|
128 |
ExpressionEvaluatorSwingManager expressionSwingManager = ExpressionEvaluatorSwingLocator.getManager(); |
|
161 | 129 |
|
162 |
}; |
|
130 |
this.translate(); |
|
131 |
|
|
132 |
this.picturePicker = toolsSwingManager.createFilePickerController(view.txtPictureFile, view.btnPictureFile); |
|
133 |
this.selectedPicturePicker = toolsSwingManager.createFilePickerController(view.txtSelPictureFile, view.btnSelPictureFile); |
|
134 |
this.picturePicker.addChangeListener((ChangeEvent e) -> { |
|
135 |
if (this.picturePicker.get() == null) { |
|
136 |
this.selectedPicturePicker.setEnabled(false); |
|
137 |
} |
|
138 |
}); |
|
139 |
view.txtSize.setModel(new SpinnerNumberModel(5, 0d, Double.POSITIVE_INFINITY, 0.5)); |
|
140 |
view.txtX.setModel(new SpinnerNumberModel(0, Integer.MIN_VALUE, Integer.MAX_VALUE, 1)); |
|
141 |
view.txtY.setModel(new SpinnerNumberModel(0, Integer.MIN_VALUE, Integer.MAX_VALUE, 1)); |
|
163 | 142 |
|
143 |
// view.txtSize.addActionListener(() -> {fireSymbolChangedEvent();}); |
|
144 |
// view.txtX.addActionListener(() -> {fireSymbolChangedEvent();}); |
|
145 |
// view.txtY.addActionListener(() -> {fireSymbolChangedEvent();}); |
|
164 | 146 |
|
165 |
public PictureMarker(SymbolEditor owner) { |
|
166 |
super(owner); |
|
167 |
initialize(); |
|
168 |
} |
|
147 |
this.colorLinePicker = toolsSwingManager.createColorPickerController(view.txtColorLine, view.btnColorLine); |
|
169 | 148 |
|
170 |
/** |
|
171 |
* Initializes the parameters that define a picturmarker.To do it, |
|
172 |
* a tab is created inside the SymbolEditor panel with default values |
|
173 |
* for the different attributes of the picture marker. |
|
174 |
*/ |
|
149 |
this.xoffsetExpPicker = expressionSwingManager.createExpressionPickerController( |
|
150 |
view.txtXOffset, |
|
151 |
view.btnXOffsetExpression, |
|
152 |
view.btnXOffsetExpressionBookmarks, |
|
153 |
view.btnXOffsetExpressionHistory |
|
154 |
); |
|
155 |
this.yoffsetExpPicker = expressionSwingManager.createExpressionPickerController( |
|
156 |
view.txtYOffset, |
|
157 |
view.btnYOffsetExpression, |
|
158 |
view.btnYOffsetExpressionBookmarks, |
|
159 |
view.btnYOffsetExpressionHistory |
|
160 |
); |
|
161 |
this.rotationExpPicker = expressionSwingManager.createExpressionPickerController( |
|
162 |
view.txtRotation, |
|
163 |
view.btnRotationExpression, |
|
164 |
view.btnRotationExpressionBookmarks, |
|
165 |
view.btnRotationExpressionHistory |
|
166 |
); |
|
167 |
this.colorExpPicker = expressionSwingManager.createExpressionPickerController( |
|
168 |
view.txtColorLineExp, |
|
169 |
view.btnColorLineExpression, |
|
170 |
view.btnColorLineExpressionBookmarks, |
|
171 |
view.btnColorLineExpressionHistory |
|
172 |
); |
|
173 |
tabs.add(view); |
|
174 |
} |
|
175 | 175 |
|
176 |
private void initialize() {
|
|
177 |
JPanel myTab = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5));
|
|
178 |
myTab.setName(Messages.getText("picture_marker"));
|
|
179 |
GridBagLayoutPanel aux = new GridBagLayoutPanel();
|
|
176 |
@Override
|
|
177 |
public ISymbol getLayer() {
|
|
178 |
try {
|
|
179 |
IPictureMarkerSymbol layer = null;
|
|
180 | 180 |
|
181 |
// picture file label |
|
182 |
lblFileName = new JLabel(); |
|
183 |
lblFileName.setFont(lblFileName.getFont().deriveFont(Font.BOLD)); |
|
184 |
aux.addComponent(Messages.getText("picture_file")+":", |
|
185 |
lblFileName); |
|
181 |
if (this.getPictureFile()!=null ) { |
|
182 |
SymbologyManager symbologyManager = SymbologyLocator.getSymbologyManager(); |
|
183 |
layer = symbologyManager.createPictureMarkerSymbol( |
|
184 |
this.getPictureURL(), |
|
185 |
this.getSelectedPictureURL() |
|
186 |
); |
|
187 |
layer.setSize(getSize()); |
|
188 |
layer.setOffset(new Point2D.Double(getX(),getY())); |
|
189 |
} |
|
186 | 190 |
|
187 |
// button browse |
|
188 |
btn = new JButton(Messages.getText("browse")); |
|
189 |
btn.addActionListener(chooseAction); |
|
191 |
return layer; |
|
192 |
} catch (Exception e) { |
|
193 |
IWarningSymbol warning |
|
194 |
= (IWarningSymbol) MapContextLocator.getSymbolManager() |
|
195 |
.getWarningSymbol( |
|
196 |
SymbolDrawingException.STR_UNSUPPORTED_SET_OF_SETTINGS, |
|
197 |
Messages.getText("failed_acessing_files"), |
|
198 |
SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS); |
|
199 |
return warning; |
|
190 | 200 |
|
191 |
JPanel aux2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
|
192 |
aux2.add(btn); |
|
193 |
aux.addComponent("", aux2); |
|
201 |
} |
|
194 | 202 |
|
195 |
// selection picture file |
|
196 |
lblSelFileName = new JLabel(); |
|
197 |
lblSelFileName.setFont(lblSelFileName.getFont().deriveFont(Font.BOLD)); |
|
198 |
aux.addComponent(Messages.getText("selection_picture_file")+":", |
|
199 |
lblSelFileName); |
|
203 |
} |
|
200 | 204 |
|
201 |
// button browse |
|
202 |
btnSel = new JButton(Messages.getText("browse")); |
|
203 |
btnSel.addActionListener(chooseAction); |
|
204 |
btnSel.setEnabled(false); |
|
205 |
aux2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
|
206 |
aux2.add(btnSel); |
|
207 |
aux.addComponent("", aux2); |
|
205 |
@Override |
|
206 |
public String getName() { |
|
207 |
return Messages.getText("picture_marker_symbol"); |
|
208 |
} |
|
208 | 209 |
|
209 |
// picture width |
|
210 |
txtSize = new JNumberSpinner(5, 25, 0, Double.POSITIVE_INFINITY, 0.5); |
|
211 |
aux2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
|
212 |
aux2.add(txtSize); |
|
213 |
aux.addComponent(lblSize, aux2 ); |
|
214 |
txtSize.setDouble(MARKER_IMAGE_DEFAULT_WIDTH); |
|
210 |
@Override |
|
211 |
public JPanel[] getTabs() { |
|
212 |
return tabs.toArray(new JPanel[tabs.size()]); |
|
213 |
} |
|
215 | 214 |
|
215 |
@Override |
|
216 |
public void refreshControls(ISymbol layer) { |
|
217 |
try { |
|
218 |
if (layer == null) { |
|
219 |
setValues(1d, 0d, 0d, null, null); |
|
220 |
} else { |
|
221 |
IPictureMarkerSymbol sym = (IPictureMarkerSymbol) layer; |
|
222 |
setValues( |
|
223 |
sym.getSize(), |
|
224 |
sym.getOffset().getX(), |
|
225 |
sym.getOffset().getY(), |
|
226 |
sym.getSource(), |
|
227 |
sym.getSelectedSource() |
|
228 |
); |
|
229 |
} |
|
230 |
} catch (Exception ex) { |
|
231 |
LOGGER.warn("Can't refresh picture marker symbol panel.", ex); |
|
232 |
} |
|
233 |
} |
|
216 | 234 |
|
217 |
// picture xOffset |
|
218 |
txtX = new JNumberSpinner(0, 25); |
|
219 |
aux2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
|
220 |
aux2.add(txtX); |
|
221 |
aux.addComponent(lblX, aux2); |
|
235 |
protected void setValues(double size, double xOffset, double yOffset, URL picture, URL selectedPicture) { |
|
236 |
setSize(size); |
|
237 |
setX(xOffset); |
|
238 |
setY(yOffset); |
|
239 |
|
|
240 |
setPicture(picture); |
|
241 |
setSelectedPicture(selectedPicture); |
|
242 |
} |
|
222 | 243 |
|
244 |
@Override |
|
245 |
public EditorTool[] getEditorTools() { |
|
246 |
return null; |
|
223 | 247 |
|
224 |
// picture width |
|
225 |
txtY = new JNumberSpinner(0, 25); |
|
226 |
aux2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
|
227 |
aux2.add(txtY); |
|
228 |
aux.addComponent(lblY, |
|
229 |
aux2 ); |
|
248 |
} |
|
230 | 249 |
|
250 |
@Override |
|
251 |
public void actionPerformed(ActionEvent e) { |
|
252 |
} |
|
231 | 253 |
|
232 |
// initialize defaults |
|
233 |
txtSize.addActionListener(this); |
|
234 |
txtX.addActionListener(this); |
|
235 |
txtY.addActionListener(this); |
|
236 |
// buttons have their own listener!!!! |
|
254 |
@Override |
|
255 |
public boolean canManageSymbol(ISymbol symbol) { |
|
256 |
return symbol instanceof IPictureMarkerSymbol; |
|
257 |
} |
|
237 | 258 |
|
238 |
myTab.add(aux); |
|
239 |
tabs.add(myTab); |
|
259 |
protected String getPictureFileName() { |
|
260 |
File f = this.picturePicker.get(); |
|
261 |
if( f == null ) { |
|
262 |
return null; |
|
263 |
} |
|
264 |
return f.getAbsolutePath(); |
|
265 |
} |
|
240 | 266 |
|
241 |
// mask = new Mask(this); |
|
242 |
// tabs.add(mask); |
|
243 |
} |
|
267 |
protected String getSelectedPictureFileName() { |
|
268 |
File f = this.selectedPicturePicker.get(); |
|
269 |
if( f == null ) { |
|
270 |
return null; |
|
271 |
} |
|
272 |
return f.getAbsolutePath(); |
|
273 |
} |
|
244 | 274 |
|
245 |
public ISymbol getLayer() {
|
|
246 |
try {
|
|
247 |
IPictureMarkerSymbol layer = null;
|
|
275 |
protected URL getPictureURL() {
|
|
276 |
return URLUtils.toURL(this.picturePicker.get());
|
|
277 |
}
|
|
248 | 278 |
|
249 |
if( lblFileName.getText().equals("")) |
|
250 |
layer=null; |
|
279 |
protected URL getSelectedPictureURL() { |
|
280 |
return URLUtils.toURL(this.selectedPicturePicker.get()); |
|
281 |
} |
|
251 | 282 |
|
252 |
else { |
|
253 |
if (lblSelFileName.getText().equals("")){ |
|
254 |
layer = SymbologyLocator.getSymbologyManager().createPictureMarkerSymbol(new File(lblFileName.getText()).toURI().toURL(),null); |
|
255 |
}else { |
|
256 |
layer = SymbologyLocator.getSymbologyManager().createPictureMarkerSymbol(new File(lblFileName.getText()).toURI().toURL(),new File(lblSelFileName.getText()).toURI().toURL()); |
|
257 |
} |
|
258 |
// layer.setIsShapeVisible(true); //True is the default value of this property |
|
259 |
layer.setSize(txtSize.getDouble()); |
|
260 |
layer.setOffset(new Point2D.Double( |
|
261 |
txtX.getDouble(), |
|
262 |
txtY.getDouble())); |
|
263 |
// layer.setMask(mask.getMask()); |
|
264 |
} |
|
283 |
protected File getPictureFile() { |
|
284 |
File f = this.picturePicker.get(); |
|
285 |
return f; |
|
286 |
} |
|
265 | 287 |
|
266 |
return layer; |
|
267 |
} catch (IOException e) { |
|
268 |
IWarningSymbol warning = |
|
269 |
(IWarningSymbol) MapContextLocator.getSymbolManager() |
|
270 |
.getWarningSymbol( |
|
271 |
SymbolDrawingException.STR_UNSUPPORTED_SET_OF_SETTINGS, |
|
272 |
Messages.getText("failed_acessing_files"), |
|
273 |
SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS); |
|
274 |
return warning; |
|
288 |
protected File getSelectedPictureFile() { |
|
289 |
File f = this.selectedPicturePicker.get(); |
|
290 |
return f; |
|
291 |
} |
|
275 | 292 |
|
276 |
} |
|
293 |
protected double getSize() { |
|
294 |
SpinnerNumberModel model = (SpinnerNumberModel) view.txtSize.getModel(); |
|
295 |
return model.getNumber().doubleValue(); |
|
296 |
} |
|
277 | 297 |
|
298 |
protected double getX() { |
|
299 |
SpinnerNumberModel model = (SpinnerNumberModel) view.txtX.getModel(); |
|
300 |
return model.getNumber().doubleValue(); |
|
301 |
} |
|
278 | 302 |
|
279 |
} |
|
303 |
protected double getY() { |
|
304 |
SpinnerNumberModel model = (SpinnerNumberModel) view.txtY.getModel(); |
|
305 |
return model.getNumber().doubleValue(); |
|
306 |
} |
|
280 | 307 |
|
281 |
public String getName() { |
|
282 |
return Messages.getText("picture_marker_symbol"); |
|
308 |
protected void setPicture(URL picture) { |
|
309 |
this.picturePicker.set(URLUtils.toFile(picture)); |
|
310 |
} |
|
283 | 311 |
|
284 |
} |
|
312 |
protected void setSelectedPicture(URL selectedPicture) { |
|
313 |
this.selectedPicturePicker.set(URLUtils.toFile(selectedPicture)); |
|
314 |
} |
|
285 | 315 |
|
286 |
public JPanel[] getTabs() { |
|
287 |
return tabs.toArray(new JPanel[tabs.size()]); |
|
288 |
} |
|
316 |
protected void setSize(double d) { |
|
317 |
SpinnerNumberModel model = (SpinnerNumberModel) view.txtSize.getModel(); |
|
318 |
model.setValue(d); |
|
319 |
} |
|
289 | 320 |
|
290 |
public void refreshControls(ISymbol layer) { |
|
291 |
IPictureMarkerSymbol sym; |
|
292 |
try { |
|
293 |
double size, xOffset, yOffset; |
|
294 |
String fileName = null, selectionFileName = null; |
|
295 |
if (layer == null) { |
|
296 |
// initialize defaults |
|
297 |
System.err.println(getClass().getName()+":: should be unreachable code"); |
|
321 |
protected void setX(double d) { |
|
322 |
SpinnerNumberModel model = (SpinnerNumberModel) view.txtX.getModel(); |
|
323 |
model.setValue(d); |
|
324 |
} |
|
298 | 325 |
|
299 |
size = 1D; |
|
300 |
xOffset = 0D; |
|
301 |
yOffset = 0D; |
|
302 |
fileName = "-"; |
|
303 |
selectionFileName = "-"; |
|
304 |
} else { |
|
305 |
sym = (IPictureMarkerSymbol) layer; |
|
326 |
protected void setY(double d) { |
|
327 |
SpinnerNumberModel model = (SpinnerNumberModel) view.txtY.getModel(); |
|
328 |
model.setValue(d); |
|
329 |
} |
|
306 | 330 |
|
307 |
size = sym.getSize(); |
|
308 |
xOffset = sym.getOffset().getX(); |
|
309 |
yOffset = sym.getOffset().getY(); |
|
331 |
protected Color getColorLine() { |
|
332 |
return this.colorLinePicker.get(); |
|
333 |
} |
|
334 |
|
|
335 |
protected void setColorLine(Color color) { |
|
336 |
this.colorLinePicker.set(color); |
|
337 |
|
|
338 |
} |
|
310 | 339 |
|
311 |
fileName = sym.getSource().toURI().getPath(); //.toString(); |
|
312 |
selectionFileName = sym.getSelectedSource().toURI().getPath(); //.toString(); |
|
313 |
} |
|
314 |
|
|
315 |
setValues(size, xOffset, yOffset, fileName, selectionFileName); |
|
316 |
} catch (IndexOutOfBoundsException ioEx) { |
|
317 |
NotificationManager.addWarning("Symbol layer index out of bounds", ioEx); |
|
318 |
} catch (ClassCastException ccEx) { |
|
319 |
NotificationManager.addWarning("Illegal casting from " + |
|
320 |
layer.getClass().getName() + " to IPictureMarkerSymbol.", ccEx); |
|
321 |
} catch (URISyntaxException e) { |
|
322 |
NotificationManager.addWarning("URI Syntax error", e); |
|
323 |
} |
|
324 |
} |
|
325 |
|
|
326 |
protected void setValues(double size, double xOffset, double yOffset, String fileName, String selectionFileName) { |
|
327 |
txtSize.setDouble(size); |
|
328 |
txtX.setDouble(xOffset); |
|
329 |
txtY.setDouble(yOffset); |
|
330 |
lblFileName.setText(fileName); |
|
331 |
lblSelFileName.setText(selectionFileName); |
|
332 |
btnSel.setEnabled(lblFileName.getText()!=""); |
|
333 |
} |
|
334 |
|
|
335 |
public EditorTool[] getEditorTools() { |
|
336 |
return null; |
|
337 |
|
|
338 |
} |
|
339 |
|
|
340 |
public void actionPerformed(ActionEvent e) { |
|
341 |
fireSymbolChangedEvent(); |
|
342 |
} |
|
343 |
|
|
344 |
public boolean canManageSymbol(ISymbol symbol) { |
|
345 |
return symbol instanceof IPictureMarkerSymbol; |
|
346 |
} |
|
347 |
|
|
348 |
} |
|
340 |
@Override |
|
341 |
public void setFeatureStore(FeatureStore store) { |
|
342 |
super.setFeatureStore(store); |
|
343 |
DataSwingManager dataSwingManager = DALSwingLocator.getDataSwingManager(); |
|
344 |
dataSwingManager.configureExpressionBuilder(this.xoffsetExpPicker, store); |
|
345 |
dataSwingManager.configureExpressionBuilder(this.yoffsetExpPicker, store); |
|
346 |
dataSwingManager.configureExpressionBuilder(this.rotationExpPicker, store); |
|
347 |
} |
|
348 |
|
|
349 |
|
|
350 |
} |
Also available in: Unified diff