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