Revision 1418

View differences:

org.gvsig.legend.graduatedsymbols.app.mainplugin/tags/org.gvsig.legend.graduatedsymbols.app.mainplugin-1.0.44/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4

  
5
	<modelVersion>4.0.0</modelVersion>
6
	<artifactId>org.gvsig.legend.graduatedsymbols.app.mainplugin</artifactId>
7
	<name>Vector legend: Graduated symbols</name>
8
	<version>1.0.44</version>
9

  
10
  <parent>
11
      <groupId>org.gvsig</groupId>
12
      <artifactId>org.gvsig.desktop</artifactId>
13
      <version>2.0.184</version>
14
  </parent>
15

  
16
	<url>https://devel.gvsig.org/redmine/projects/gvsig-base-legends</url>
17

  
18
    <scm>
19
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-base-legends/org.gvsig.legend.graduatedsymbols.app.mainplugin/tags/org.gvsig.legend.graduatedsymbols.app.mainplugin-1.0.44</connection>
20
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-base-legends/org.gvsig.legend.graduatedsymbols.app.mainplugin/tags/org.gvsig.legend.graduatedsymbols.app.mainplugin-1.0.44</developerConnection>
21
        <url>scm:svn:https://devel.gvsig.org/svn/gvsig-base-legends/org.gvsig.legend.graduatedsymbols.app.mainplugin/tags/org.gvsig.legend.graduatedsymbols.app.mainplugin-1.0.44</url>
22
    </scm>
23

  
24
    <repositories>
25
      <repository>
26
        <id>gvsig-public-http-repository</id>
27
        <name>gvSIG maven public HTTP repository</name>
28
        <url>http://devel.gvsig.org/m2repo/j2se</url>
29
        <releases>
30
          <enabled>true</enabled>
31
          <updatePolicy>daily</updatePolicy>
32
          <checksumPolicy>warn</checksumPolicy>
33
        </releases>
34
        <snapshots>
35
          <enabled>true</enabled>
36
          <updatePolicy>daily</updatePolicy>
37
          <checksumPolicy>warn</checksumPolicy>
38
        </snapshots>
39
      </repository>
40
    </repositories>
41

  
42
	<description>Vector legend: Graduated symbols. Symbol size depends on numeric value but uses a limited number of different symbol sizes.</description>
43
	<build>
44

  
45
        <plugins>
46

  
47
		    <plugin>
48
		      <artifactId>maven-release-plugin</artifactId>
49
		      <version>2.0</version>
50
		      <configuration>
51
		        <tagBase>https://devel.gvsig.org/svn/gvsig-base-legends/org.gvsig.legend.graduatedsymbols.app.mainplugin/tags</tagBase>
52
		      </configuration>
53
		    </plugin>
54

  
55
        </plugins>
56
	</build>
57
	<dependencies>
58
		<dependency>
59
			<groupId>org.gvsig</groupId>
60
			<artifactId>org.gvsig.app.mainplugin</artifactId>
61
		</dependency>
62
        <dependency>
63
            <groupId>org.gvsig</groupId>
64
            <artifactId>org.gvsig.andami</artifactId>
65
        </dependency>
66
        <dependency>
67
            <groupId>org.gvsig</groupId>
68
            <artifactId>org.gvsig.symbology.lib.api</artifactId>
69
        </dependency>
70
        <dependency>
71
            <groupId>org.gvsig</groupId>
72
            <artifactId>org.gvsig.symbology.lib.impl</artifactId>
73
        </dependency>
74
        <dependency>
75
            <groupId>org.gvsig</groupId>
76
            <artifactId>org.gvsig.symbology.swing.api</artifactId>
77
        </dependency>
78
        <dependency>
79
            <groupId>org.gvsig</groupId>
80
            <artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
81
        </dependency>
82
        <dependency>
83
            <groupId>org.gvsig</groupId>
84
            <artifactId>org.gvsig.utils</artifactId>
85
        </dependency>
86
        <dependency>
87
            <groupId>org.gvsig</groupId>
88
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
89
        </dependency>
90

  
91
        <dependency>
92
            <groupId>org.gvsig</groupId>
93
            <artifactId>org.gvsig.i18n</artifactId>
94
        </dependency>
95

  
96
		<dependency>
97
            <groupId>org.gvsig</groupId>
98
            <artifactId>org.gvsig.fmap.geometry.api</artifactId>
99
        </dependency>
100

  
101
        <dependency>
102
            <groupId>org.gvsig</groupId>
103
            <artifactId>org.gvsig.tools.lib</artifactId>
104
        </dependency>
105
        <dependency>
106
            <groupId>org.gvsig</groupId>
107
            <artifactId>org.gvsig.ui</artifactId>
108
        </dependency>
109
        <dependency>
110
            <groupId>org.gvsig</groupId>
111
            <artifactId>org.gvsig.projection.api</artifactId>
112
        </dependency>
113
        <dependency>
114
            <groupId>org.gvsig</groupId>
115
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
116
        </dependency>
117

  
118
	</dependencies>
119

  
120
	<properties>
121
	    <gvsig.package.info.categories>View,Vector,Symbology</gvsig.package.info.categories>
122
        <gvsig.package.info.official>true</gvsig.package.info.official>
123
        <gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2.1.0-A</gvsig.package.info.dependencies>
124
        <gvsig.package.info.state>testing</gvsig.package.info.state>
125
		<gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-base-legends/pool</gvsig.package.info.poolURL>
126
	</properties>
127
</project>
org.gvsig.legend.graduatedsymbols.app.mainplugin/tags/org.gvsig.legend.graduatedsymbols.app.mainplugin-1.0.44/buildNumber.properties
1
#Wed May 31 09:20:36 CEST 2017
2
buildNumber=47
org.gvsig.legend.graduatedsymbols.app.mainplugin/tags/org.gvsig.legend.graduatedsymbols.app.mainplugin-1.0.44/src/main/assembly/gvsig-plugin-package.xml
1
<!--
2

  
3
    gvSIG. Desktop Geographic Information System.
4

  
5
    Copyright (C) 2007-2013 gvSIG Association.
6

  
7
    This program is free software; you can redistribute it and/or
8
    modify it under the terms of the GNU General Public License
9
    as published by the Free Software Foundation; either version 3
10
    of the License, or (at your option) any later version.
11

  
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16

  
17
    You should have received a copy of the GNU General Public License
18
    along with this program; if not, write to the Free Software
19
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
    MA  02110-1301, USA.
21

  
22
    For any additional information, do not hesitate to contact us
23
    at info AT gvsig.com, or visit our website www.gvsig.com.
24

  
25
-->
26
<assembly>
27
  <id>gvsig-plugin-package</id>
28
  <formats>
29
    <format>zip</format>
30
  </formats>
31
  <baseDirectory>${project.artifactId}</baseDirectory>
32
  <includeBaseDirectory>true</includeBaseDirectory>
33
  <files>
34
    <file>
35
      <source>target/${project.artifactId}-${project.version}.jar</source>
36
      <outputDirectory>lib</outputDirectory>
37
    </file>
38
    <file>
39
      <source>target/package.info</source>
40
    </file>
41
  </files>
42

  
43
  <fileSets>
44
    <fileSet>
45
      <directory>src/main/resources-plugin</directory>
46
      <outputDirectory>.</outputDirectory>
47
    </fileSet>
48
  </fileSets>
49

  
50
<!-- No dependencies
51
  <dependencySets>
52
    <dependencySet>
53
      <useProjectArtifact>false</useProjectArtifact>
54
      <useTransitiveDependencies>false</useTransitiveDependencies>
55
      <outputDirectory>lib</outputDirectory>
56
      <includes>
57
		<include>...</include>
58
      </includes>
59
    </dependencySet>
60
  </dependencySets>
61
-->
62

  
63
</assembly>
64

  
org.gvsig.legend.graduatedsymbols.app.mainplugin/tags/org.gvsig.legend.graduatedsymbols.app.mainplugin-1.0.44/src/main/java/org/gvsig/symbology/fmap/rendering/GraduatedSymbolsLegend.java
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

  
42
/* CVS MESSAGES:
43
 *
44
 * $Id: GraduatedSymbolLegend.java 16187 2007-11-08 16:13:44Z jdominguez $
45
 * $Log$
46
 * Revision 1.3  2007-05-17 09:32:06  jaume
47
 * *** empty log message ***
48
 *
49
 * Revision 1.2  2007/03/09 11:20:56  jaume
50
 * Advanced symbology (start committing)
51
 *
52
 * Revision 1.1.2.4  2007/02/15 16:23:44  jaume
53
 * *** empty log message ***
54
 *
55
 * Revision 1.1.2.3  2007/02/14 15:53:35  jaume
56
 * *** empty log message ***
57
 *
58
 * Revision 1.1.2.2  2007/02/13 16:19:19  jaume
59
 * graduated symbol legends (start commiting)
60
 *
61
 * Revision 1.1.2.1  2007/02/12 15:15:20  jaume
62
 * refactored interval legend and added graduated symbol legend
63
 *
64
 *
65
 */
66
package org.gvsig.symbology.fmap.rendering;
67

  
68
import org.slf4j.Logger;
69
import org.slf4j.LoggerFactory;
70

  
71
import org.gvsig.fmap.dal.feature.Feature;
72
import org.gvsig.fmap.geom.Geometry;
73
import org.gvsig.fmap.mapcontext.MapContextException;
74
import org.gvsig.fmap.mapcontext.MapContextLocator;
75
import org.gvsig.fmap.mapcontext.MapContextManager;
76
import org.gvsig.fmap.mapcontext.rendering.legend.IInterval;
77
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
78
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialIntervalLegend;
79
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol;
80
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.MarkerFillSymbol;
81
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.MultiLayerFillSymbol;
82
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol;
83
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.SimpleMarkerFillPropertiesStyle;
84
import org.gvsig.tools.ToolsLocator;
85
import org.gvsig.tools.dynobject.DynStruct;
86
import org.gvsig.tools.persistence.PersistenceManager;
87
import org.gvsig.tools.persistence.PersistentState;
88
import org.gvsig.tools.persistence.exception.PersistenceException;
89
import org.gvsig.tools.util.Callable;
90

  
91
/**
92
 * <p>GraduatedSymbolLegend is a legend that allows to classify ranges of
93
 * values using a value with symbol sizes.<b>
94
 * </p>
95
 * <p>
96
 * The symbol size will be calculated according the min size, the
97
 * max size and the amount of intervals. So for a min size of 1, a max size
98
 * of 5, and 5 intervals, symbol sizes will be [1, 2, 3, 4, 5].
99
 * </p>
100
 * @author  jaume dominguez faus - jaume.dominguez@iver.es
101
 */
102
public class GraduatedSymbolsLegend extends VectorialIntervalLegend {
103
    
104
    private static Logger logger = LoggerFactory.getLogger(
105
        GraduatedSymbolsLegend.class);
106
    
107
    public static final String
108
    GRADUATED_SYMBOL_LEGEND_NAME =
109
        "GRADUATED_SYMBOL_LEGEND";  
110
    public static final String
111
    GRADUATED_SYMBOL_LEGEND_PERSISTENCE_DEFINITION_NAME =
112
        "GRADUATED_SYMBOL_LEGEND_PERSISTENCE_DEFINITION";  
113

  
114
    
115
	private double maxSymbolSize;
116
	private double minSymbolSize;
117
	private ISymbol backgroundSymbol;
118
	private int templateShapeType;
119
	/**
120
	 * DefaultConstructor
121
	 */
122
	public GraduatedSymbolsLegend() {
123
		super();
124
	}
125

  
126
	/**
127
	 * Convenience constructor.
128
	 *
129
	 * Creates a new instance of GraduatedSymbolLegend from a VectorialIntervalLegend by
130
	 * taking the same fields.
131
	 * @param leg
132
	 */
133
	public GraduatedSymbolsLegend(VectorialIntervalLegend leg) {
134
		this();
135
		
136
        this.setShapeType(leg.getShapeType());
137
        Object[] _keys = leg.getValues();
138
        ISymbol[] _syms = leg.getSymbols();
139
        
140
        if (_keys == null || _syms == null) {
141
            logger.info("Warning: inconsistent VectorialIntervalLegend (keys or syms is null)");
142
        } else {
143
            if (_keys.length != _syms.length) {
144
                logger.info("Warning: inconsistent VectorialIntervalLegend (keys and syms have dif length)");
145
            } else {
146
                for (int i=0; i<_keys.length; i++) {
147
                    this.addSymbol(_keys[i], _syms[i]);
148
                }
149
            }
150
        }
151
        
152
        this.setClassifyingFieldNames(leg.getClassifyingFieldNames());
153
        this.setClassifyingFieldTypes(leg.getClassifyingFieldTypes());
154
        this.setDefaultSymbol(leg.getDefaultSymbol());
155
        this.setIntervalType(leg.getIntervalType());
156
        this.useDefaultSymbol(leg.isUseDefaultSymbol());
157
	}
158

  
159
	/**
160
	 * Returns the max symbol size. Combined with the min symbol size and
161
	 * the interval count, will produce the symbol sizes.
162
	 * @return double, the max size.
163
	 */
164
	public double getMaxSymbolSize() {
165
		return maxSymbolSize;
166
	}
167

  
168
	/**
169
	 * Returns the min symbol size. Combined with the max symbol size and
170
	 * the interval count, will produce the symbol sizes.
171
	 * @return double, the min size.
172
	 */
173
	public double getMinSymbolSize() {
174
		return minSymbolSize;
175
	}
176

  
177
	/**
178
	 * Sets the max symbol size. Combined with the min symbol size and
179
	 * the interval count, will produce the symbol sizes.
180
	 */
181
	public void setMaxSymbolSize(double size) {
182
		this.maxSymbolSize = size;
183
	}
184

  
185
	/**
186
	 * Sets the min symbol size. Combined with the max symbol size and
187
	 * the interval count, will produce the symbol sizes.
188
	 */
189
	public void setMinSymbolSize(double size) {
190
		this.minSymbolSize = size;
191
	}
192

  
193
	
194
	public ISymbol getSymbolByFeature(Feature feat) throws MapContextException {
195
	    
196
		ISymbol theSymbol = super.getSymbolByFeature(feat);
197

  
198
		if (isPolygonal(getShapeType()) && theSymbol instanceof IMarkerSymbol) {
199
			// transform it to a fill symbol
200
            theSymbol = toFillSymbol(theSymbol);
201
		}
202

  
203
		if (backgroundSymbol != null) {
204
			MultiLayerFillSymbol multi = new MultiLayerFillSymbol() ;
205
			multi.addLayer(backgroundSymbol);
206
			multi.addLayer(theSymbol);
207
			return multi;
208
		}
209
		return theSymbol;
210
	}
211

  
212
	@Override
213
	public ISymbol getSymbolByInterval(IInterval key) {
214
	    
215
		ISymbol theSymbol = super.getSymbolByInterval(key);
216
        if (isPolygonal(getShapeType()) && theSymbol instanceof IMarkerSymbol) {
217
			// transform it to a fill symbol
218
			theSymbol = toFillSymbol(theSymbol);
219
		}
220
		return theSymbol;
221
	}
222

  
223
	/**
224
	 * Obtains the background symbol
225
	 */
226
	public ISymbol getBackgroundSymbol() {
227
		return backgroundSymbol;
228
	}
229

  
230
	/**
231
	 * Sets the background symbol.
232
	 * @param symbol
233
	 */
234
	public void setBackgroundSymbol(ISymbol symbol) {
235
		this.backgroundSymbol = symbol;
236
	}
237

  
238
	public ISymbol getDefaultSymbol() {
239
		return defaultSymbol;
240
	}
241

  
242
	@Override
243
	public boolean isSuitableForShapeType(int st) {
244
		return areSameBasicType(getShapeType(), st)
245
		    ||
246
		    (isPoint(getTemplateShapeType()) && isPolygonal(st));
247
	}
248

  
249

  
250

  
251
	/**
252
	 * Obtains the shapetype of the background symbol
253
	 */
254
	public int getTemplateShapeType() {
255
		return templateShapeType;
256
	}
257
	/**
258
	 * Sets the shapetype of the background symbol
259
	 */
260
	public void setTemplateShapeType(int tst) {
261
		if (isPolygonal(getShapeType())) {
262
			if(isPoint(tst))
263
				this.templateShapeType = tst;
264
		}
265
		else if(areSameBasicType(tst, getShapeType())) {
266
			this.templateShapeType = tst;
267
		}
268
	}
269
	
270
    public static boolean isPolygonal(int ty) {
271
        if (ty == Geometry.TYPES.MULTISURFACE
272
            || ty == Geometry.TYPES.SURFACE
273
            ) {
274
            return true;
275
        } else {
276
            return false;
277
        }
278
    }
279

  
280

  
281
    public static boolean isLinear(int ty) {
282
        if (ty == Geometry.TYPES.CIRCLE
283
            || ty == Geometry.TYPES.ARC
284
            || ty == Geometry.TYPES.CURVE
285
            || ty == Geometry.TYPES.ELLIPSE
286
            || ty == Geometry.TYPES.ELLIPTICARC
287
            || ty == Geometry.TYPES.SPLINE
288
            || ty == Geometry.TYPES.MULTICURVE
289
            ) {
290
            return true;
291
        } else {
292
            return false;
293
        }
294
    }
295
    
296
    public static boolean isPoint(int ty) {
297
        if (ty == Geometry.TYPES.POINT
298
            || ty == Geometry.TYPES.MULTIPOINT
299
            ) {
300
            return true;
301
        } else {
302
            return false;
303
        }
304
    }
305
    
306
    public static boolean areSameBasicType(int ta, int tb) {
307
        
308
        if (isPoint(ta) && isPoint(tb)) {
309
            return true;
310
        }
311
        if (isLinear(ta) && isLinear(tb)) {
312
            return true;
313
        }
314
        if (isPolygonal(ta) && isPolygonal(tb)) {
315
            return true;
316
        }
317
        return false;
318
    }
319
    
320
    public void loadFromState(PersistentState state)
321
        throws PersistenceException {
322
        
323
        super.loadFromState(state);
324
        
325
        this.templateShapeType = state.getInt("templateShapeType");
326
        this.maxSymbolSize = state.getDouble("maxSymbolSize");
327
        this.minSymbolSize = state.getDouble("minSymbolSize");
328
        
329
        if (state.hasValue("backgroundSymbol")) {
330
            this.backgroundSymbol = (ISymbol) state.get("backgroundSymbol");
331
        }
332
    }
333

  
334
    public void saveToState(PersistentState state) throws PersistenceException {
335

  
336
        super.saveToState(state);
337
        state.set("templateShapeType", this.templateShapeType);
338
        state.set("maxSymbolSize", this.maxSymbolSize);
339
        state.set("minSymbolSize", this.minSymbolSize);
340
        if (this.backgroundSymbol != null) {
341
            state.set("backgroundSymbol", this.backgroundSymbol);
342
        }
343
        
344
    }
345
    
346

  
347
    public static class RegisterPersistence implements Callable {
348

  
349
        public Object call() throws Exception {
350
            
351
            PersistenceManager manager = ToolsLocator.getPersistenceManager();
352
            if (manager
353
                .getDefinition(GRADUATED_SYMBOL_LEGEND_PERSISTENCE_DEFINITION_NAME) == null) {
354
                DynStruct definition =
355
                    manager
356
                        .addDefinition(
357
                            GraduatedSymbolsLegend.class,
358
                            GRADUATED_SYMBOL_LEGEND_PERSISTENCE_DEFINITION_NAME,
359
                            GRADUATED_SYMBOL_LEGEND_PERSISTENCE_DEFINITION_NAME
360
                                + " Persistence definition", null, null);
361
                
362
                definition.extend(
363
                    manager.getDefinition(
364
                        VectorialIntervalLegend.
365
                        VECTORIAL_INTERVAL_LEGEND_PERSISTENCE_DEFINITION_NAME));
366

  
367
                definition.addDynFieldInt("templateShapeType").setMandatory(true);
368
                definition.addDynFieldDouble("maxSymbolSize").setMandatory(true);
369
                definition.addDynFieldDouble("minSymbolSize").setMandatory(true);
370
                definition.addDynFieldObject("backgroundSymbol")
371
                .setClassOfValue(ISymbol.class).setMandatory(false);
372
            }
373
            return Boolean.TRUE;
374
        }
375

  
376
    }
377

  
378
    public static class RegisterLegend implements Callable {
379

  
380
        public Object call() throws Exception {
381
            MapContextManager manager =
382
                MapContextLocator.getMapContextManager();
383

  
384
            manager.registerLegend(
385
                GRADUATED_SYMBOL_LEGEND_NAME,
386
                GraduatedSymbolsLegend.class);
387

  
388
            return Boolean.TRUE;
389
        }
390

  
391
    }
392
    
393
    public static IFillSymbol toFillSymbol(ISymbol sym) {
394
        
395
        if (sym instanceof IFillSymbol) {
396
            return (IFillSymbol) sym;
397
        } else {
398
            if (sym instanceof IMarkerSymbol) {
399
                MarkerFillSymbol aux = new MarkerFillSymbol();
400
                aux.setMarker((IMarkerSymbol) sym);
401
                SimpleMarkerFillPropertiesStyle p =
402
                    new SimpleMarkerFillPropertiesStyle();
403
                p.setFillStyle(
404
                    SimpleMarkerFillPropertiesStyle.SINGLE_CENTERED_SYMBOL);
405
                aux.setMarkerFillProperties(p);
406
                return aux;
407
            } else {
408
                return null;
409
            }
410
        }
411
    }
412

  
413

  
414

  
415

  
416
}
org.gvsig.legend.graduatedsymbols.app.mainplugin/tags/org.gvsig.legend.graduatedsymbols.app.mainplugin-1.0.44/src/main/java/org/gvsig/symbology/gui/layerproperties/GraduatedSymbolsPanel.java
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

  
42
/* CVS MESSAGES:
43
 *
44
 * $Id: GraduatedSymbols.java 16232 2007-11-09 13:36:35Z jdominguez $
45
 * $Log$
46
 * Revision 1.8  2007-09-19 15:44:44  jaume
47
 * new signal catched (legend error)
48
 *
49
 * Revision 1.7  2007/05/21 10:38:27  jaume
50
 * *** empty log message ***
51
 *
52
 * Revision 1.6  2007/05/17 09:32:37  jaume
53
 * *** empty log message ***
54
 *
55
 * Revision 1.5  2007/05/10 09:46:45  jaume
56
 * Refactored legend interface names
57
 *
58
 * Revision 1.4  2007/05/08 15:45:31  jaume
59
 * *** empty log message ***
60
 *
61
 * Revision 1.3  2007/03/21 08:03:03  jaume
62
 * refactored to use ISymbol instead of FSymbol
63
 *
64
 * Revision 1.2  2007/03/09 11:25:00  jaume
65
 * Advanced symbology (start committing)
66
 *
67
 * Revision 1.1.2.4  2007/02/21 07:35:14  jaume
68
 * *** empty log message ***
69
 *
70
 * Revision 1.1.2.3  2007/02/14 09:59:17  jaume
71
 * *** empty log message ***
72
 *
73
 * Revision 1.1.2.2  2007/02/13 16:19:19  jaume
74
 * graduated symbol legends (start commiting)
75
 *
76
 * Revision 1.1.2.1  2007/02/12 15:14:41  jaume
77
 * refactored interval legend and added graduated symbol legend
78
 *
79
 *
80
 */
81
package org.gvsig.symbology.gui.layerproperties;
82

  
83
import java.awt.Color;
84
import java.awt.Dimension;
85
import java.awt.FlowLayout;
86
import java.text.NumberFormat;
87
import java.util.ArrayList;
88
import java.util.List;
89

  
90
import javax.swing.BorderFactory;
91
import javax.swing.ImageIcon;
92
import javax.swing.JLabel;
93
import javax.swing.JOptionPane;
94
import javax.swing.JPanel;
95

  
96
import org.slf4j.Logger;
97
import org.slf4j.LoggerFactory;
98

  
99
import org.gvsig.andami.IconThemeHelper;
100
import org.gvsig.app.ApplicationLocator;
101
import org.gvsig.app.project.documents.view.legend.gui.ILegendPanel;
102
import org.gvsig.app.project.documents.view.legend.gui.JSymbolPreviewButton;
103
import org.gvsig.app.project.documents.view.legend.gui.Quantities;
104
import org.gvsig.app.project.documents.view.legend.gui.SymbolTable;
105
import org.gvsig.app.project.documents.view.legend.gui.VectorialInterval;
106
import org.gvsig.fmap.dal.exception.ReadException;
107
import org.gvsig.fmap.geom.Geometry;
108
import org.gvsig.fmap.mapcontext.MapContextLocator;
109
import org.gvsig.fmap.mapcontext.MapContextManager;
110
import org.gvsig.fmap.mapcontext.exceptions.LegendLayerException;
111
import org.gvsig.fmap.mapcontext.layers.FLayer;
112
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
113
import org.gvsig.fmap.mapcontext.rendering.legend.IInterval;
114
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
115
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorialIntervalLegend;
116
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
117
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
118
import org.gvsig.gui.beans.swing.JNumberSpinner;
119
import org.gvsig.i18n.Messages;
120
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialIntervalLegend;
121
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.MarkerFillSymbol;
122
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol;
123
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.impl.SimpleLineSymbol;
124
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol;
125
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.SimpleMarkerSymbol;
126
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.IMarkerFillPropertiesStyle;
127
import org.gvsig.symbology.fmap.rendering.GraduatedSymbolsLegend;
128

  
129

  
130
/**
131
 * Implements the interface that shows the information of a legend which
132
 * draws quantities using symbol size to show relative values.
133
 *
134
 * @author Pepe Vidal Salvador - jose.vidal.salvador@iver.es
135
 *
136
 */
137

  
138
public class GraduatedSymbolsPanel extends VectorialInterval implements ILegendPanel {
139

  
140
    private static Logger logger = LoggerFactory.getLogger(GraduatedSymbolsPanel.class);
141

  
142
	private static final long serialVersionUID = -263195536343912694L;
143
	static final double DEFAULT_SYMBOL_MAX_SIZE = 7;
144
	private static final double DEFAULT_SYMBOL_MIN_SIZE = 1;
145
	private JNumberSpinner txtMinSize;
146
	private JNumberSpinner txtMaxSize;
147
	private JSymbolPreviewButton btnTemplate;
148
	private JSymbolPreviewButton btnBackground;
149
	private int shapeType;
150
	private GridBagLayoutPanel aux;
151
	private int templateShapeType = 0 ;
152
	private boolean showBackground = true;
153

  
154
	public GraduatedSymbolsPanel() {
155
		super();
156
		this.showBackground = true;
157
	}
158

  
159
	public GraduatedSymbolsPanel(boolean showBackground) {
160
		super();
161
		this.showBackground = showBackground;
162
	}
163

  
164
	@Override
165
	public JPanel getOptionPanel() {
166

  
167
		if (optionPanel == null) {
168
			optionPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
169
			optionPanel.setBorder(BorderFactory.
170
					createTitledBorder(null,
171
					    Messages.getText("symbol")));
172

  
173
			aux = new GridBagLayoutPanel();
174
			aux.addComponent(new JLabel(Messages.getText("size")));
175
			aux.addComponent(Messages.getText("from")+":",
176
					getTxtMinSize());
177
			aux.addComponent(Messages.getText("to")+":",
178
					getTxtMaxSize());
179
			aux.addComponent(Messages.getText("template"), getBtnTemplate());
180
			optionPanel.add(aux);
181

  
182
		}
183
		return optionPanel;
184
	}
185

  
186
	/**
187
	 * Adds the button that allows the user to select a background for the graduated symbol.
188
	 */
189
	private void getBackgroundPanel() {
190
		aux.addComponent(Messages.getText("background"), getBtnBackground());
191
	}
192
	/**
193
	 * Creates the JSymbolPreviewButton for the background of the graduated symbol.
194
	 */
195
	private JSymbolPreviewButton getBtnBackground() {
196
		if (btnBackground == null) {
197
			btnBackground = new JSymbolPreviewButton(Geometry.TYPES.SURFACE);
198
			btnBackground.setPreferredSize(new Dimension(100, 35));
199

  
200
			ISymbol fillsym = MapContextLocator.getSymbolManager().createSymbol(
201
			    Geometry.TYPES.SURFACE, Color.ORANGE);
202
			btnBackground.setSymbol(fillsym);
203
		}
204
		return btnBackground;
205
	}
206
	/**
207
	 * Creates the JSymbolPreviewButton for the graduated symbol.
208
	 */
209
	private JSymbolPreviewButton getBtnTemplate() {
210
		if (btnTemplate == null) {
211
			templateShapeType =
212
			    GraduatedSymbolsLegend.isPolygonal(shapeType) ?
213
			        Geometry.TYPES.POINT : shapeType;
214
			btnTemplate = new JSymbolPreviewButton(templateShapeType);
215
			btnTemplate.setPreferredSize(new Dimension(100, 35));
216

  
217
		}
218
		return btnTemplate;
219
	}
220
	/**
221
	 * Creates the JIncrementalNumberField which is used to specify the maximum size of the
222
	 * graduated symbol
223
	 */
224
	private JNumberSpinner getTxtMaxSize() {
225
		if (txtMaxSize == null) {
226
			txtMaxSize = new JNumberSpinner(25.0,7,0.0,100.0,1.0,2);
227

  
228
		}
229
		return txtMaxSize;
230
	}
231
	/**
232
	 * Creates the JIncrementalNumberField which is used to specify the minimum size of the
233
	 * graduated symbol
234
	 */
235
	private JNumberSpinner getTxtMinSize() {
236
		if (txtMinSize == null) {
237
			txtMinSize = new JNumberSpinner(3.0,7,0.0,100.0,1.0,2);
238
		}
239
		return txtMinSize;
240
	}
241

  
242
	@Override
243
	public void setData(FLayer lyr, ILegend legend) {
244
		this.layer = (FLyrVect) lyr;
245

  
246
		try {
247
            shapeType = this.layer.getGeometryType().getType();
248
        } catch (ReadException e) {
249
            logger.info("Unable to get shapetype while setting data", e);
250
            ApplicationLocator.getManager().messageDialog(
251
                Messages.getText("_Unable_to_set_legend"),
252
                Messages.getText("error"),
253
                JOptionPane.ERROR_MESSAGE);
254
        }
255

  
256
        templateShapeType =
257
            GraduatedSymbolsLegend.isPolygonal(shapeType) ?
258
                Geometry.TYPES.POINT : shapeType;
259

  
260
		getBtnTemplate().setShapeType(templateShapeType);
261
		if(showBackground){
262
			if(GraduatedSymbolsLegend.isPolygonal(shapeType) && btnBackground == null) {
263
				getBackgroundPanel();
264
				getBtnBackground().setShapeType(Geometry.TYPES.SURFACE);
265
			}
266
		}
267

  
268
		if (symbolTable != null)
269
			pnlCenter.remove(symbolTable);
270

  
271
		getDefaultSymbolPrev(templateShapeType);
272

  
273
		symbolTable = new SymbolTable(
274
		    this, SymbolTable.INTERVALS_TYPE, templateShapeType);
275
		pnlCenter.add(symbolTable);
276

  
277
		fillFieldNames();
278

  
279
		if (legend instanceof GraduatedSymbolsLegend) {
280
            auxLegend = (GraduatedSymbolsLegend) legend.cloneLegend();
281

  
282
			getChkDefaultvalues().setSelected(auxLegend.isUseDefaultSymbol());
283
			cmbField.setSelectedItem(auxLegend.getClassifyingFieldNames()[0]);
284

  
285
			fillTableSkipDefault(auxLegend);
286

  
287
			getTxtMaxSize().setDouble(((GraduatedSymbolsLegend) auxLegend).getMaxSymbolSize());
288
			getTxtMinSize().setDouble(((GraduatedSymbolsLegend) auxLegend).getMinSymbolSize());
289
			if (auxLegend.getSymbols().length > 0){
290
				getBtnTemplate().setSymbol(((GraduatedSymbolsLegend) auxLegend).getSymbols()[auxLegend.getSymbols().length-1]);
291
			} else {
292
				getBtnTemplate().setSymbol(newSymbol(shapeType,
293
				    GraduatedSymbolsLegend.isLinear(shapeType) ? 3 : 10));
294
			}
295
			if(showBackground){
296

  
297
				if (GraduatedSymbolsLegend.isPolygonal(shapeType))
298
					getBtnBackground().setSymbol(((GraduatedSymbolsLegend) auxLegend).getBackgroundSymbol());
299
			}
300
			if (auxLegend.isUseDefaultSymbol())
301
				txtNumIntervals.setText(String.valueOf(auxLegend.getSymbols().length - 1));
302
			else
303
				txtNumIntervals.setText(String.valueOf(auxLegend.getSymbols().length));
304

  
305
		} else {
306
			// Si la capa viene con otro tipo de leyenda, creamos
307
			// una nueva del tipo que maneja este panel
308
			auxLegend = new GraduatedSymbolsLegend();
309
			getTxtMaxSize().setDouble(DEFAULT_SYMBOL_MAX_SIZE);
310
			getTxtMinSize().setDouble(DEFAULT_SYMBOL_MIN_SIZE);
311
			auxLegend.setDefaultSymbol(newSymbol(shapeType,
312
			    GraduatedSymbolsLegend.isLinear(shapeType) ? 3 : 10));
313
			getBtnTemplate().setSymbol(auxLegend.getDefaultSymbol());
314
			((GraduatedSymbolsLegend) auxLegend).setTemplateShapeType(templateShapeType);
315

  
316
		}
317
		cmbIntervalType.setSelectedIndex(auxLegend.getIntervalType());
318
		defaultSymbolPrev.setSymbol(auxLegend.getDefaultSymbol());
319
	}
320

  
321

  
322
	@Override
323
	public String getDescription() {
324
		return Messages.getText(
325
		    "draw_quantities_using_symbol_size_to_show_relative_values");
326
	}
327

  
328
	@Override
329
	public ILegend getLegend() {
330

  
331
	    GraduatedSymbolsLegend gsl =
332
		    new GraduatedSymbolsLegend((VectorialIntervalLegend) super.getLegend());
333

  
334
		double minSize = getTxtMinSize().getDouble();
335
		gsl.setMinSymbolSize(minSize);
336
		gsl.setMaxSymbolSize(getTxtMaxSize().getDouble());
337

  
338
        try {
339
            gsl.setShapeType(layer.getGeometryType().getType());
340
        } catch (ReadException e) {
341

  
342
            logger.info("Unable to get shapetype while getting legend", e);
343
            ApplicationLocator.getManager().messageDialog(
344
                Messages.getText("_Unable_to_get_legend"),
345
                Messages.getText("error"),
346
                JOptionPane.ERROR_MESSAGE);
347
        }
348

  
349
		ISymbol sym = getBtnTemplate().getSymbol();
350

  
351
		if (sym != null){
352
			gsl.setTemplateShapeType(sym.getSymbolType());
353
			gsl.setDefaultSymbol(sym);
354
		} else {
355
			gsl.setTemplateShapeType(templateShapeType);
356
		}
357

  
358
		gsl.useDefaultSymbol(getChkDefaultvalues().isSelected());
359
		if(defaultSymbolPrev.getSymbol() != null)
360
			gsl.setDefaultSymbol(defaultSymbolPrev.getSymbol());
361

  
362
		if (this.showBackground){
363

  
364
			if (GraduatedSymbolsLegend.isPolygonal(shapeType))
365
				gsl.setBackgroundSymbol(btnBackground.getSymbol());
366
		}
367

  
368
		return gsl;
369
	}
370

  
371
	@Override
372
	public ImageIcon getIcon() {
373
	    return
374
	        IconThemeHelper.getImageIcon("legend-overview-graduated-symbols");
375
	}
376

  
377
	@Override
378
	public Class getParentClass() {
379
		return Quantities.class;
380
	}
381

  
382
	@Override
383
	public String getTitle() {
384
		return Messages.getText("graduated_symbols");
385
	}
386

  
387
	@Override
388
	public JPanel getPanel() {
389
		return this;
390
	}
391

  
392
	@Override
393
	public Class getLegendClass() {
394
		return GraduatedSymbolsLegend.class;
395
	}
396

  
397
	@Override
398
	public boolean isSuitableFor(FLayer layer) {
399
		if ( super.isSuitableFor(layer)) {
400
			FLyrVect lVect = (FLyrVect) layer;
401
            try {
402
                return lVect.getGeometryType().getType()
403
                    != Geometry.TYPES.GEOMETRY;
404
            } catch (ReadException e) {
405

  
406
                ApplicationLocator.getManager().message(
407
                    Messages.getText("error_trying_to_access_to_the_layer"),
408
                    JOptionPane.ERROR_MESSAGE);
409
                return false;
410
            }
411
		}
412
		return false;
413
	}
414

  
415
	private ISymbol newSymbol(int st, double size) {
416
		if (getBtnTemplate().getSymbol() == null) {
417
			ISymbol templateSymbol = null;
418

  
419
			if (GraduatedSymbolsLegend.isPoint(st)
420
			    || GraduatedSymbolsLegend.isPolygonal(st)) {
421

  
422
                templateSymbol = new SimpleMarkerSymbol();
423
                ((SimpleMarkerSymbol) templateSymbol).setSize(size);
424
                ((SimpleMarkerSymbol) templateSymbol).setColor(Color.DARK_GRAY);
425
			} else {
426
	            if (GraduatedSymbolsLegend.isLinear(st)) {
427

  
428
	                templateSymbol = new SimpleLineSymbol();
429
	                ((SimpleLineSymbol) templateSymbol).setLineWidth(size);
430
	                ((SimpleLineSymbol) templateSymbol).setLineColor(Color.DARK_GRAY);
431
	            } else {
432

  
433
	                ApplicationLocator.getManager().message(
434
	                    Messages.getText("usupported_layer_type"),
435
	                    JOptionPane.ERROR_MESSAGE);
436
	                logger.info("Error: Unknown symbol type");
437

  
438
	            }
439
			}
440
			getBtnTemplate().setSymbol(templateSymbol);
441
			return newSymbol(st, size);
442
		} else {
443
			// clone symbol
444
			ISymbol mySymbol = null;
445

  
446
			try {
447
                mySymbol = (ISymbol) getBtnTemplate().getSymbol().clone();
448
            } catch (CloneNotSupportedException e) {
449

  
450
                ApplicationLocator.getManager().message(
451
                    Messages.getText("_Unable_to_get_symbol"),
452
                    JOptionPane.ERROR_MESSAGE);
453
                logger.info("Error: Could not clone symbol", e);
454
            }
455

  
456
			if (mySymbol instanceof ILineSymbol) {
457
				ILineSymbol lSym = (ILineSymbol) mySymbol;
458
				lSym.setLineWidth(size);
459
			}
460

  
461
			if (mySymbol instanceof IMarkerSymbol) {
462
				IMarkerSymbol mSym = (IMarkerSymbol) mySymbol;
463
				mSym.setSize(size);
464
				if (GraduatedSymbolsLegend.isPolygonal(st)) {
465
					// this is to allow using in Polygon layers
466
					MarkerFillSymbol fillSymbol = new MarkerFillSymbol();
467
					fillSymbol.setOutline(null);
468
					fillSymbol.setFillColor(null);
469
					fillSymbol.getMarkerFillProperties().
470
					setFillStyle(IMarkerFillPropertiesStyle.
471
					    SINGLE_CENTERED_SYMBOL);
472
					fillSymbol.setMarker(mSym);
473
				}
474
			}
475
			return mySymbol;
476
		}
477
	}
478

  
479
	@Override
480
	protected void fillTableValues() {
481

  
482
		symbolTable.removeAllItems();
483

  
484
		try {
485
		    IInterval[] arrayIntervalos = calculateIntervals();
486
			if (arrayIntervalos == null)
487
				return;
488

  
489
			IInterval interval;
490
			NumberFormat.getInstance().setMaximumFractionDigits(2);
491
			auxLegend.clear();
492

  
493
			float minSize = (float) getTxtMinSize().getDouble();
494
			float maxSize = (float) getTxtMaxSize().getDouble();
495
			ISymbol theSymbol;
496

  
497
			this.shapeType = layer.getGeometryType().getType();
498

  
499
			if (GraduatedSymbolsLegend.isPolygonal(this.shapeType)) {
500
			    this.templateShapeType = Geometry.TYPES.POINT;
501
			}
502

  
503
			MapContextManager mcm =
504
			    MapContextLocator.getMapContextManager();
505
			auxLegend = (IVectorialIntervalLegend)
506
			    mcm.createLegend(
507
			    IVectorialIntervalLegend.LEGEND_NAME);
508
			auxLegend.setShapeType(this.shapeType);
509
			auxLegend.setIntervalType(this.cmbIntervalType.getSelectedIndex());
510

  
511
			if (chkdefaultvalues.isSelected()) {
512
				auxLegend.getDefaultSymbol().setDescription("Default");
513
				auxLegend.addSymbol("Default",
514
				    mcm.getSymbolManager().createSymbol(
515
				        this.templateShapeType));
516
			}
517

  
518
			int symbolType;
519
			symbolType = layer.getGeometryType().getType();
520
			int numSymbols = 0;
521

  
522
			double step = (maxSize - minSize) / arrayIntervalos.length;
523
			double size = minSize;
524
			for (int k = 0; k < arrayIntervalos.length; k++) {
525
				interval = arrayIntervalos[k];
526
				theSymbol = newSymbol(symbolType, size);
527

  
528
				auxLegend.addSymbol(interval, theSymbol);
529
				numSymbols++;
530

  
531
				if (numSymbols > 100) {
532
					int resp = JOptionPane.showConfirmDialog(this,
533
					    Messages.getText("mas_de_100_simbolos"),
534
					    Messages.getText("quiere_continuar"),
535
					    JOptionPane.YES_NO_OPTION,
536
					    JOptionPane.WARNING_MESSAGE);
537

  
538
					if ((resp == JOptionPane.NO_OPTION) ||
539
							(resp == JOptionPane.DEFAULT_OPTION)) {
540
						return;
541
					}
542
				}
543

  
544

  
545
				theSymbol.setDescription(NumberFormat.getInstance().format(interval.getMin()) +
546
						" - " +
547
						NumberFormat.getInstance().format(interval.getMax()));
548

  
549
				size = size + step;
550
			} // for
551

  
552
			fillTableSkipDefault(auxLegend);
553

  
554
		} catch (ReadException re) {
555
		    logger.info("Error could_not_get_shape_type", re);
556
            ApplicationLocator.getManager().messageDialog(
557
                Messages.getText("could_not_get_shape_type"),
558
                Messages.getText("error"),
559
                JOptionPane.ERROR_MESSAGE);
560

  
561
		} catch (LegendLayerException lle) {
562
            logger.info("Error failed_computing_intervals", lle);
563
            ApplicationLocator.getManager().messageDialog(
564
                Messages.getText("failed_computing_intervals"),
565
                Messages.getText("error"),
566
                JOptionPane.ERROR_MESSAGE);
567
		}
568

  
569
		bDelAll.setEnabled(true);
570
		bDel.setEnabled(true);
571

  
572
	}
573

  
574
	public void setShowBackground(boolean sb){
575
		this.showBackground = sb;
576
	}
577

  
578
	public boolean getShowBackground(){
579
		return this.showBackground;
580
	}
581

  
582
    private void fillTableSkipDefault(IVectorialIntervalLegend leg) {
583

  
584
        Object[] src_expr = leg.getValues();
585
        ISymbol[] src_syms = leg.getSymbols();
586
        String[] src_descs = leg.getDescriptions();
587

  
588
        List syms = new ArrayList();
589
        List vals = new ArrayList();
590
        List descs = new ArrayList();
591
        for (int i=0; i<src_expr.length; i++) {
592
            if (src_expr[i] instanceof IInterval) {
593
                syms.add(src_syms[i]);
594
                vals.add(src_expr[i]);
595
                descs.add(src_descs[i]);
596
            }
597
        }
598
        symbolTable.fillTableFromSymbolList(
599
            (ISymbol[]) syms.toArray(new ISymbol[0]),
600
            (Object[]) vals.toArray(new Object[0]),
601
            (String[]) descs.toArray(new String[0]));
602
    }
603

  
604

  
605

  
606

  
607
}  //  @jve:decl-index=0:visual-constraint="10,10"
org.gvsig.legend.graduatedsymbols.app.mainplugin/tags/org.gvsig.legend.graduatedsymbols.app.mainplugin-1.0.44/src/main/java/org/gvsig/symbology/library/GraduatedSymbolsLibrary.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2013 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.symbology.library;
24

  
25
import org.gvsig.andami.IconThemeHelper;
26
import org.gvsig.app.project.documents.view.legend.gui.LegendManager;
27
import org.gvsig.symbology.SymbologyLibrary;
28
import org.gvsig.symbology.fmap.rendering.GraduatedSymbolsLegend;
29
import org.gvsig.symbology.gui.layerproperties.GraduatedSymbolsPanel;
30
import org.gvsig.tools.library.AbstractLibrary;
31
import org.gvsig.tools.library.LibraryException;
32
import org.gvsig.tools.persistence.xml.XMLPersistenceLibrary;
33
import org.gvsig.tools.util.Caller;
34
import org.gvsig.tools.util.impl.DefaultCaller;
35

  
36

  
37
/**
38
 * Simple library to register graduated symbols legend
39
 * 
40
 * @author jldominguez
41
 *
42
 */
43
public class GraduatedSymbolsLibrary extends AbstractLibrary {
44

  
45

  
46
    public void doRegistration() {
47
        registerAsImplementationOf(GraduatedSymbolsLibrary.class);
48
        /*
49
         * This checks map context library registration
50
         */
51
        require(SymbologyLibrary.class);
52
        /*
53
         * This is because we need to use persistence manager
54
         */
55
        require(XMLPersistenceLibrary.class);
56
    }
57

  
58
    protected void doInitialize() throws LibraryException {
59
        
60
    }
61

  
62

  
63
    protected void doPostInitialize() throws LibraryException {
64
        
65
        IconThemeHelper.registerIcon(
66
            "legend", "legend-overview-graduated-symbols", this);
67

  
68
        Caller caller = new DefaultCaller();
69
        
70
        caller.add(new GraduatedSymbolsLegend.RegisterLegend());
71
        caller.add(new GraduatedSymbolsLegend.RegisterPersistence());
72
        
73
        /*
74
         * Do register of all
75
         */
76
        if( !caller.call() ) {
77
            throw new LibraryException(
78
                GraduatedSymbolsLibrary.class,
79
                caller.getExceptions());
80
        }
81
        
82
        LegendManager.addLegendPage(GraduatedSymbolsPanel.class);
83
    }
84

  
85
}
org.gvsig.legend.graduatedsymbols.app.mainplugin/tags/org.gvsig.legend.graduatedsymbols.app.mainplugin-1.0.44/src/main/resources-plugin/i18n/text_tr.properties
1
#Translations for language [tr]
2
#Mon Sep 21 10:02:12 CEST 2009
3
a_default_symbol_will_be_used=
4
above=\u00dcst
5
accept=Kabul et
6
accessing_file_structure=Dosya yap\u0131s\u0131na eri\u015filiyor
7
add=Ekle
8
add_class=S\u0131n\u0131f ekle
9
add_expression=\u0130fade ekle
10
add_field=Alan ekle
11
add_operator=\u0130\u015fletmen ekle
12
add_text_area=Metin alan\u0131 ekle
13
all_features=T\u00fcm objeler
14
all_supported_background_image_formats=T\u00fcm desteklenen arkaplan g\u00f6r\u00fcnt\u00fc bi\u00e7imleri
15
allow_label_overlapping=Etiketleri \u00fcst\u00fcne bindir
16
always_circular=
17
always_horizontal=Daima yatay
18
always_straight=
19
angle=A\u00e7\u0131
20
anticlockwise=
21
apply_visual_correction_to_glyph_for_precise_size_and_position=
22
arguments_added_to_a_costant=
23
at_begin=Ba\u015flang\u0131\u00e7ta
24
at_best=En iyisi
25
at_end=Sonunda
26
at_fields=alanlarda
27
background=
28
background_color=Artalan rengi
29
background_style=Artalan bi\u00e7emi
30
barchar3d_legend=
31
barchar3d_legend_desc=
32
barchart_3D=
33
below=Alt\u0131nda
34
bitmap_and_svg_image_files=Bite\u015flem ve SVG g\u00f6r\u00fcnt\u00fc dosyalar\u0131
35
boolean_value=Boole de\u011feri
36
browse=G\u00f6zat
37
buffered=Tamponlanm\u0131\u015f
38
cancel=\u0130ptal
39
cannot_apply_to_a_non_polygon_layer=Poligon olmayan katmana uygulanam\u0131yor
40
cannot_be_null=Bo\u015f de\u011fer olamaz
41
cannot_exist_two_label_classes_with_the_same_name=\u0130ki etiket s\u0131n\u0131f\u0131 ayn\u0131 isimde olamaz
42
cannot_install_labeling_method=Etiketleme y\u00f6ntemi y\u00fcklenemiyor
43
cant_draw_preview=\u00d6ng\u00f6r\u00fcn\u00fc\u015f \u00e7izilemiyor
44
change_location=Konumu de\u011fi\u015ftir
45
character_marker=\u0130\u015faretleyiciyi de\u011fi\u015ftir
46
character_marker_symbol=\u0130\u015faretleyici simgesini de\u011fi\u015ftir
47
choose_marker=\u0130\u015faretleyiciyi se\u00e7
48
circular=Dairesel
49
class=S\u0131n\u0131f
50
classes=S\u0131n\u0131flar
51
classifying_field_name_not_found=S\u0131n\u0131fland\u0131r\u0131lan alan ad\u0131 bulunamad\u0131
52
clear=Sil
53
color=Renk
54
color_field=Renk alan\u0131
55
color_ramp=
56
confirmation_dialog=Onaylama diyalo\u011fu
57
constant=Sabit
58
correct_expression=Do\u011fru ifade
59
could_not_get_shape_type=
60
could_not_retreive_layer_field_names=
61
could_not_setup_legend=Lejand ayarlanamad\u0131
62
date_value=Tarih de\u011feri
63
default=Varsay\u0131lan
64
define_classes_of_features_and_label_each_differently=
65
Defines_a_dot_density_symbol_based_on_a_field_value=
66
delete=Sil
67
delete_class=S\u0131n\u0131f sil
68
delete_filter_expression=S\u00fczge\u00e7 ifadesini sil
69
densities=Yo\u011funluklar
70
depth_factor=
71
description=Tan\u0131m
72
divided_by_0=
73
dont_show_labels_when_zoomed=Yak\u0131nla\u015ft\u0131r\u0131ld\u0131\u011f\u0131nda etiketleri g\u00f6sterme
74
dot_density=Nokta yo\u011funlu\u011fu
75
dot_size=Nokta boyutu
76
dot_value=Nokta de\u011feri
77
draw_quantities_for_each_category=Her kategorinin say\u0131s\u0131n\u0131 \u00e7iz.
78
draw_quantities_using_symbol_size_to_show_exact_values=
79
draw_quantities_using_symbol_size_to_show_relative_values=
80
duplicate_labels=Tekrarl\u0131 etiketler
81
edit_expression=\u0130fadeyi d\u00fczenle
82
Enable_layer_preview=Katman \u00f6ng\u00f6r\u00fcn\u00fc\u015f\u00fcn\u00fc etkinle\u015ftir
83
enter_new_name=Yeni isim gir
84
error=Hata
85
error\ accessing\ to\ the\ layer=
86
error_coding_filter_query=
87
error_trying_to_access_to_the_layer=Katmana eri\u015fmede hata
88
error_validating_filter_query=
89
expression=\u0130fade
90
expression_creator=\u0130fade olu\u015fturucu
91
expressions=\u0130fadeler
92
failed_acessing_files=
93
failed_applying_following_line_will_use_default_confg=
94
failed_computing_intervals=
95
features=Objeler
96
field_number=Alan numaras\u0131
97
fields=Alanlar
98
fields_exp=Alanlar
99
fill_color=Doldurma rengi
100
fill_properties=Doldurma \u00f6zellikleri
101
filter=S\u00fczge\u00e7
102
filtered_features=S\u00fczge\u00e7lenen objeler
103
fit_inside_polygon=
104
fit_on_text_area=
105
fixed_text_size=Sabit metin boyutu
106
following_line=
107
font=Yaz\u0131 tipi
108
foreground_alpha=
109
format=Bi\u00e7im
110
from=
111
fuente=Yaz\u0131 tipi
112
GeneralLabeling.sample_text=
113
generating_intervals=
114
getting_layer_shape_type=
115
gradient_color=
116
gradient_fill=
117
gradient_fill_symbol=
118
graduated_symbols=Derecelenmi\u015f simgeler
119
grid=Grid
120
high=Y\u00fcksek
121
horizontal=Yatay
122
ignore_zero_values=
123
in_beyond=
124
in_layer=katman\u0131n i\u00e7inde
125
in_the_middle=ortas\u0131nda
126
incompatible_types_to_calculate_the_normalization=
127
incorrect_expression=Hatal\u0131 ifade
128
intervals=Aral\u0131klar
129
invalid_filter_expression=
130
invalid_url=
131
it_will_not_be_added=Eklenemeyecek
132
label-point-priority-help=\u00d6ncelik\: 0 \= Bloklanm\u0131\u015f, 1 \= En y\u00fcksek, 3 \= En d\u00fc\u015f\u00fck
133
label_class_properties=Etiket s\u0131n\u0131f \u00f6zellikleri
134
label_expression=Etiket ifadesi
135
label_expression_editor=Etiket ifadesi d\u00fczenleyici
136
label_expression_help=
137
label_features_in_the_same_way=Objeleri ayn\u0131 \u015fekilde etiketle
138
label_features_in_this_class=bu s\u0131n\u0131ftaki etiket objeleri
139
label_only_when_selected=Sadece obje se\u00e7ildi\u011finde etiketle
140
label_priority=
141
label_style_could_not_be_painted=
142
label_styles=Etiket bi\u00e7emleri
143
labeled_point=
144
labeling=Etiketleme
145
labeling_field=Etiketleme alan\u0131
146
layer_name=Katman ad\u0131
147
line=\u00c7izgi
148
line_fill=\u00c7izgi doldur
149
line_fill_symbol=\u00c7izgi doldurma simgesi
150
line_settings=\u00c7izgi ayarlar\u0131
151
lineal=
152
lines=\u00c7izgiler
153
location=Mevki
154
location_along_the_lines=
155
looks_like_too_low_value_for_this_field_may_cause_system_to_run_slow=
156
low=
157
malformed_or_empty_expression=
158
marker_fill=\u0130\u015faretleyici doldurma
159
marker_fill_symbol=\u0130\u015faretleyici doldurma simgesi
160
marker_line=\u0130\u015faretleyici \u00e7izgi
161
marker_line_symbol=\u0130\u015faretleyici \u00e7izgi simgesi
162
mas_de_100_simbolos=Bir haritada 100 den fazla simge genellikle herhangi bir bilgi vermez
163
max_scale=En b\u00fcy\u00fck \u00f6l\u00e7ek
164
medium=
165
method=Y\u00f6ntem
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff