root / trunk / extensions / extSymbology / src / org / gvsig / symbology / gui / styling / PictureLine.java @ 20768
History | View | Annotate | Download (4.58 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 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 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.symbology.gui.styling; |
42 |
|
43 |
import java.io.IOException; |
44 |
import java.net.MalformedURLException; |
45 |
import java.net.URL; |
46 |
|
47 |
import org.gvsig.symbology.fmap.symbols.PictureLineSymbol; |
48 |
|
49 |
import com.iver.andami.PluginServices; |
50 |
import com.iver.andami.messages.NotificationManager; |
51 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
52 |
import com.iver.cit.gvsig.gui.styling.SymbolEditor; |
53 |
|
54 |
/**
|
55 |
* PictureLine initializes the properties that define a
|
56 |
* <b>picture marker symbol</b> and are showed in the tab created by
|
57 |
* PictureMarker which is called simple marker.<p>
|
58 |
* <p>
|
59 |
* Moreover, PictureLine has other methods such as getSymbolClass,getName,
|
60 |
* refreshControls and getLayer.
|
61 |
*
|
62 |
*
|
63 |
*@author jaume dominguez faus - jaume.dominguez@iver.es
|
64 |
*/
|
65 |
public class PictureLine extends PictureMarker { |
66 |
public PictureLine(SymbolEditor owner) {
|
67 |
super(owner);
|
68 |
initialize(); |
69 |
} |
70 |
/**
|
71 |
* Initializes the values in the tab
|
72 |
*
|
73 |
*/
|
74 |
private void initialize() { |
75 |
tabs.remove(mask); |
76 |
lblSize.setText(PluginServices.getText(this, "width")+":"); |
77 |
lblX.setText(PluginServices.getText(this, "scale")+" X:"); |
78 |
lblY.setText(PluginServices.getText(this, "scale")+" Y:"); |
79 |
txtX.setMinValue(0.1);
|
80 |
txtX.setMaxValue(Double.POSITIVE_INFINITY);
|
81 |
txtX.setStep(0.1);
|
82 |
txtX.setDouble(1);
|
83 |
|
84 |
txtY.setMinValue(0.1);
|
85 |
txtY.setMaxValue(Double.POSITIVE_INFINITY);
|
86 |
txtY.setStep(0.1);
|
87 |
txtY.setDouble(1);
|
88 |
} |
89 |
|
90 |
public Class getSymbolClass() { |
91 |
return PictureLineSymbol.class;
|
92 |
} |
93 |
|
94 |
public String getName() { |
95 |
return PluginServices.getText(this, "picture_line_symbol"); |
96 |
|
97 |
} |
98 |
|
99 |
public void refreshControls(ISymbol layer) { |
100 |
PictureLineSymbol sym; |
101 |
try {
|
102 |
double size, xScale, yScale;
|
103 |
String fileName = null, selectionFileName = null; |
104 |
|
105 |
if (layer == null) { |
106 |
// initialize defaults
|
107 |
System.err.println(getClass().getName()+":: should be unreachable code"); |
108 |
|
109 |
size = 1D;
|
110 |
xScale = 1D;
|
111 |
yScale = 1D;
|
112 |
fileName = "-";
|
113 |
selectionFileName = "-";
|
114 |
} else {
|
115 |
sym = (PictureLineSymbol) layer; |
116 |
|
117 |
size = sym.getLineWidth(); |
118 |
xScale = sym.getXScale(); |
119 |
yScale = sym.getYScale(); |
120 |
|
121 |
try {
|
122 |
fileName = new URL(sym.getImagePath()).toString(); |
123 |
selectionFileName =new URL(sym.getSelImagePath()).toString(); |
124 |
} catch (MalformedURLException e) { |
125 |
NotificationManager.addError(PluginServices.getText(this, "Error en la creaci?n" + |
126 |
"de la URL"), e);
|
127 |
} |
128 |
|
129 |
} |
130 |
|
131 |
setValues(size, xScale, yScale, fileName, selectionFileName); |
132 |
} catch (IndexOutOfBoundsException ioEx) { |
133 |
NotificationManager.addWarning("Symbol layer index out of bounds", ioEx);
|
134 |
} catch (ClassCastException ccEx) { |
135 |
NotificationManager.addWarning("Illegal casting from " +
|
136 |
layer.getClassName() + " to " + getSymbolClass().
|
137 |
getName() + ".", ccEx);
|
138 |
|
139 |
} |
140 |
} |
141 |
|
142 |
public ISymbol getLayer() {
|
143 |
|
144 |
try {
|
145 |
PictureLineSymbol layer = null;
|
146 |
|
147 |
|
148 |
if(lblFileName.getText().equals("") ) |
149 |
layer=null;
|
150 |
|
151 |
else {
|
152 |
layer = new PictureLineSymbol(new URL(lblFileName.getText()),null); |
153 |
if (!lblSelFileName.getText().equals("")) |
154 |
layer = new PictureLineSymbol(new URL(lblFileName.getText()),new URL(lblSelFileName.getText())); |
155 |
|
156 |
layer.setIsShapeVisible(true);
|
157 |
layer.setLineWidth(txtSize.getDouble()); |
158 |
layer.setXScale(txtX.getDouble()); |
159 |
layer.setYScale(txtY.getDouble()); |
160 |
} |
161 |
|
162 |
return layer;
|
163 |
} catch (IOException e) { |
164 |
NotificationManager.addError(PluginServices.getText(this, "failed_accessing_file"), e); |
165 |
return null; |
166 |
} |
167 |
|
168 |
} |
169 |
} |