Revision 105 org.gvsig.legend.graduatedsymbols.app.mainplugin/trunk/org.gvsig.legend.graduatedsymbols.app.mainplugin/src/main/java/org/gvsig/symbology/gui/layerproperties/GraduatedSymbolsPanel.java

View differences:

GraduatedSymbolsPanel.java
115 115
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorialIntervalLegend;
116 116
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
117 117
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
118
import org.gvsig.gui.beans.swing.JIncrementalNumberField;
118
import org.gvsig.gui.beans.swing.JNumberSpinner;
119 119
import org.gvsig.i18n.Messages;
120 120
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialIntervalLegend;
121 121
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.MarkerFillSymbol;
......
136 136
 */
137 137

  
138 138
public class GraduatedSymbolsPanel extends VectorialInterval implements ILegendPanel {
139
    
139

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

  
142 142
	private static final long serialVersionUID = -263195536343912694L;
143 143
	static final double DEFAULT_SYMBOL_MAX_SIZE = 7;
144 144
	private static final double DEFAULT_SYMBOL_MIN_SIZE = 1;
145
	private JIncrementalNumberField txtMinSize;
146
	private JIncrementalNumberField txtMaxSize;
145
	private JNumberSpinner txtMinSize;
146
	private JNumberSpinner txtMaxSize;
147 147
	private JSymbolPreviewButton btnTemplate;
148 148
	private JSymbolPreviewButton btnBackground;
149 149
	private int shapeType;
......
196 196
		if (btnBackground == null) {
197 197
			btnBackground = new JSymbolPreviewButton(Geometry.TYPES.SURFACE);
198 198
			btnBackground.setPreferredSize(new Dimension(100, 35));
199
			
199

  
200 200
			ISymbol fillsym = MapContextLocator.getSymbolManager().createSymbol(
201 201
			    Geometry.TYPES.SURFACE, Color.ORANGE);
202 202
			btnBackground.setSymbol(fillsym);
......
221 221
	 * Creates the JIncrementalNumberField which is used to specify the maximum size of the
222 222
	 * graduated symbol
223 223
	 */
224
	private JIncrementalNumberField getTxtMaxSize() {
224
	private JNumberSpinner getTxtMaxSize() {
225 225
		if (txtMaxSize == null) {
226
			txtMaxSize = new JIncrementalNumberField(String.valueOf(25), 7,0,100,1);
226
			txtMaxSize = new JNumberSpinner(25.0,7,0.0,100.0,1.0,2);
227 227

  
228 228
		}
229 229
		return txtMaxSize;
......
232 232
	 * Creates the JIncrementalNumberField which is used to specify the minimum size of the
233 233
	 * graduated symbol
234 234
	 */
235
	private JIncrementalNumberField getTxtMinSize() {
235
	private JNumberSpinner getTxtMinSize() {
236 236
		if (txtMinSize == null) {
237
			txtMinSize = new JIncrementalNumberField(String.valueOf(3), 7,0,100,1);
237
			txtMinSize = new JNumberSpinner(3.0,7,0.0,100.0,1.0,2);
238 238
		}
239 239
		return txtMinSize;
240 240
	}
......
252 252
                Messages.getText("error"),
253 253
                JOptionPane.ERROR_MESSAGE);
254 254
        }
255
		
255

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

  
260 260
		getBtnTemplate().setShapeType(templateShapeType);
261 261
		if(showBackground){
262 262
			if(GraduatedSymbolsLegend.isPolygonal(shapeType) && btnBackground == null) {
......
281 281

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

  
285 285
			fillTableSkipDefault(auxLegend);
286
			
286

  
287 287
			getTxtMaxSize().setDouble(((GraduatedSymbolsLegend) auxLegend).getMaxSymbolSize());
288 288
			getTxtMinSize().setDouble(((GraduatedSymbolsLegend) auxLegend).getMinSymbolSize());
289 289
			if (auxLegend.getSymbols().length > 0){
......
338 338
        try {
339 339
            gsl.setShapeType(layer.getGeometryType().getType());
340 340
        } catch (ReadException e) {
341
            
341

  
342 342
            logger.info("Unable to get shapetype while getting legend", e);
343 343
            ApplicationLocator.getManager().messageDialog(
344 344
                Messages.getText("_Unable_to_get_legend"),
......
360 360
			gsl.setDefaultSymbol(defaultSymbolPrev.getSymbol());
361 361

  
362 362
		if (this.showBackground){
363
		    
363

  
364 364
			if (GraduatedSymbolsLegend.isPolygonal(shapeType))
365 365
				gsl.setBackgroundSymbol(btnBackground.getSymbol());
366 366
		}
......
402 402
                return lVect.getGeometryType().getType()
403 403
                    != Geometry.TYPES.GEOMETRY;
404 404
            } catch (ReadException e) {
405
                
405

  
406 406
                ApplicationLocator.getManager().message(
407 407
                    Messages.getText("error_trying_to_access_to_the_layer"),
408 408
                    JOptionPane.ERROR_MESSAGE);
......
415 415
	private ISymbol newSymbol(int st, double size) {
416 416
		if (getBtnTemplate().getSymbol() == null) {
417 417
			ISymbol templateSymbol = null;
418
			
418

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

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

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

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

  
450 450
                ApplicationLocator.getManager().message(
451 451
                    Messages.getText("_Unable_to_get_symbol"),
452 452
                    JOptionPane.ERROR_MESSAGE);
......
457 457
				ILineSymbol lSym = (ILineSymbol) mySymbol;
458 458
				lSym.setLineWidth(size);
459 459
			}
460
			
460

  
461 461
			if (mySymbol instanceof IMarkerSymbol) {
462 462
				IMarkerSymbol mSym = (IMarkerSymbol) mySymbol;
463 463
				mSym.setSize(size);
......
499 499
			if (GraduatedSymbolsLegend.isPolygonal(this.shapeType)) {
500 500
			    this.templateShapeType = Geometry.TYPES.POINT;
501 501
			}
502
			
502

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

  
511 511
			if (chkdefaultvalues.isSelected()) {
512 512
				auxLegend.getDefaultSymbol().setDescription("Default");
513 513
				auxLegend.addSymbol("Default",
......
557 557
                Messages.getText("could_not_get_shape_type"),
558 558
                Messages.getText("error"),
559 559
                JOptionPane.ERROR_MESSAGE);
560
		    
560

  
561 561
		} catch (LegendLayerException lle) {
562 562
            logger.info("Error failed_computing_intervals", lle);
563 563
            ApplicationLocator.getManager().messageDialog(
......
578 578
	public boolean getShowBackground(){
579 579
		return this.showBackground;
580 580
	}
581
	
581

  
582 582
    private void fillTableSkipDefault(IVectorialIntervalLegend leg) {
583
        
583

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

  
588 588
        List syms = new ArrayList();
589 589
        List vals = new ArrayList();
590 590
        List descs = new ArrayList();

Also available in: Unified diff