Revision 37846

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/legend/gui/General.java
75 75
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
76 76
import org.gvsig.gui.beans.swing.JBlank;
77 77

  
78
import com.hardcode.driverManager.Driver;
79 78
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
80 79
import com.hardcode.gdbms.engine.data.driver.DriverException;
81 80
import com.iver.andami.PluginServices;
......
162 161
                getJCheckBoxSpatialIndex().setSelected(true);
163 162
            }
164 163
        }
165
		if (layer.getMinScale() != -1)
164
		if (layer.getMinScale() != -1) {
166 165
		    getTxtMaxScale().setText(nf.format(layer.getMinScale()));
167
		if (layer.getMaxScale() != -1)
166
		}
167
		if (layer.getMaxScale() != -1) {
168 168
		    getTxtMinScale().setText(nf.format(layer.getMaxScale()));
169
		}
169 170
		if (layer.getMinScale() == -1 && layer.getMaxScale() == -1) {
170 171
			getRdBtnShowAlways().setSelected(true);
171 172
			txtMaxScale.setEnabled(false);
......
235 236
		}
236 237
		return pnlScale;
237 238
	}
238
	
239

  
239 240
    /**
240 241
     * This method initializes pnlProperties, the jpanel which contains the
241 242
     * ScrollPane with the properties.
......
274 275
		}
275 276
		return txtMaxScale;
276 277
	}
277
	
278

  
278 279
    /**
279 280
     * This method initializes propertiesTextArea, where are display the
280 281
     * properties of the layer
......
359 360
     * Add the information of the layer to the textArea
360 361
     */
361 362
    private void showLayerInfo() {
362
		try {
363
			String info = ((FLyrDefault)layer).getInfoString();
364
			if (info == null) {
365
				Rectangle2D fullExtentViewPort = layer.getFullExtent();
366
				IProjection viewPortProj = layer.getMapContext().getProjection();
367
				info = PluginServices.getText(this,"Extent") + " " +
368
				viewPortProj.getAbrev() +
369
				" (" + PluginServices.getText(this, "view_projection") + "):\n\t" +
370
				PluginServices.getText(this,"Superior") + ":\t" + fullExtentViewPort.getMaxY() + "\n\t" +
371
				PluginServices.getText(this,"Inferior") + ":\t" + fullExtentViewPort.getMinY() + "\n\t" +
372
				PluginServices.getText(this,"Izquierda") + ":\t" + fullExtentViewPort.getMinX() + "\n\t" +
373
				PluginServices.getText(this,"Derecha") + ":\t" + fullExtentViewPort.getMaxX() + "\n";
363
	try {
364
	    String info = ((FLyrDefault) layer).getInfoString();
365
	    if (info == null) {
366
		Rectangle2D layerExtentOnView = layer.getFullExtent();
367
		IProjection viewProj = layer.getMapContext().getProjection();
368
		info = getLayerInfoExtent(layerExtentOnView, viewProj,
369
			"view_projection");
374 370

  
375
				// show layer native projection
376
				if (!layer.getProjection().getAbrev().equals(viewPortProj.getAbrev())) {
377
					IProjection nativeLayerProj = layer.getProjection();
378
					ICoordTrans ct = viewPortProj.getCT(nativeLayerProj);
379
					Rectangle2D nativeLayerExtent = ct.convert(fullExtentViewPort);
380
					info += PluginServices.getText(this,"Extent") + " " +
381
					nativeLayerProj.getAbrev() +
382
					" (" + PluginServices.getText(this, "layer_native_projection") + "):\n\t" +
383
					PluginServices.getText(this,"Superior") + ":\t" + nativeLayerExtent.getMaxY() + "\n\t" +
384
					PluginServices.getText(this,"Inferior") + ":\t" + nativeLayerExtent.getMinY() + "\n\t" +
385
					PluginServices.getText(this,"Izquierda") + ":\t" + nativeLayerExtent.getMinX() + "\n\t" +
386
					PluginServices.getText(this,"Derecha") + ":\t" + nativeLayerExtent.getMaxX() + "\n";
387

  
388
				}
389
				if (layer instanceof FLyrVect) {
390
					ReadableVectorial rv=((FLyrVect)layer).getSource();
391
					if (rv instanceof VectorialEditableAdapter) {
392
						rv=((VectorialEditableAdapter) ((FLyrVect)layer).getSource()).getOriginalAdapter();
393
					}
394

  
395
					info = info + PluginServices.getText(this,"Origen_de_datos") + ": ";
396
					if (rv instanceof VectorialFileAdapter) {
397
						Driver driver=rv.getDriver();
398
						info = info + "\n" + driver.getName() + "\n" +
399
						PluginServices.getText(this,"fichero") +": " + ((VectorialFileAdapter)rv).getFile();
400
					} else if (rv instanceof VectorialDBAdapter) {
401
						DBLayerDefinition dbdef = ((VectorialDBAdapter) rv).getLyrDef();
402
						info = info + "\n" + rv.getDriver().getName() + "\n";
403

  
404
						try {
405
							info = info +
406
							PluginServices.getText(this,"url") +": " + dbdef.getConnection().getURL() + "\n";
407
						} catch (Exception e) {
408
							e.printStackTrace();
409
						}
410

  
411
						info = info +
412
						PluginServices.getText(this,"Tabla") +": " + dbdef.getTableName() + "\n";
413
					} else if (rv instanceof VectorialAdapter){
414
						info = info + "\n" + rv.getDriver().getName() + "\n";
415
					}
416

  
417
					info+="\n" + PluginServices.getText(this,"type")+ ": "+((FLyrVect)layer).getTypeStringVectorLayer() + "\n";
418

  
419

  
420

  
421

  
422
				} else {
423
					info = info + PluginServices.getText(this,"Origen_de_datos") + ": " + layer.getName();
424
				}
425

  
426
			}
427
			getPropertiesTextArea().setText(info);
428

  
429
		} catch (ReadDriverException e) {
430
			NotificationManager.addError(e.getMessage(), e);
371
		// show layer native projection
372
		if (!layer.getProjection().getAbrev()
373
			.equals(viewProj.getAbrev())) {
374
		    IProjection layerNativeProj = layer.getProjection();
375
		    ICoordTrans ct = viewProj.getCT(layerNativeProj);
376
		    Rectangle2D layerNativeExtent = ct
377
			    .convert(layerExtentOnView);
378
		    info += getLayerInfoExtent(layerNativeExtent,
379
			    layerNativeProj, "layer_native_projection");
431 380
		}
432

  
381
		if (layer instanceof FLyrVect) {
382
		    info += getLayerVectorialInfo();
383
		} else {
384
		    info = info
385
			    + PluginServices.getText(this, "Origen_de_datos")
386
			    + ": " + layer.getName();
387
		}
388
	    }
389
	    getPropertiesTextArea().setText(info);
390
	} catch (ReadDriverException e) {
391
	    NotificationManager.addError(e.getMessage(), e);
392
	}
433 393
    }
434 394

  
435 395
    /**
......
443 403
     * Instantiates a ITask (@see com.iver.utiles.swing.threads.ITask) to create
444 404
     * a spatial index for the selected layer in background. This task also
445 405
     * allow to monitor process evolution, and to cancel this process.
446
     * 
406
     *
447 407
     * @throws DriverException
448 408
     * @throws DriverIOException
449 409
     */
......
469 429
			try	{
470 430
				layer.setMinScale((nf.parse(getTxtMaxScale().getText())).doubleValue());
471 431
			} catch (ParseException ex)	{
472
			    if (getTxtMaxScale().getText().compareTo("") == 0)
473
			        layer.setMinScale(-1);
474
			    else
475
			        System.err.print(ex.getLocalizedMessage());
432
			    if (getTxtMaxScale().getText().compareTo("") == 0) {
433
				layer.setMinScale(-1);
434
			    } else {
435
				System.err.print(ex.getLocalizedMessage());
436
			    }
476 437
			}
477 438

  
478 439
			try	{
479 440
			    layer.setMaxScale((nf.parse(getTxtMinScale().getText())).doubleValue());
480 441
			} catch (ParseException ex)	{
481
			    if (getTxtMinScale().getText().compareTo("") == 0)
482
			        layer.setMaxScale(-1);
483
			    else
484
			        System.err.print(ex.getLocalizedMessage());
442
			    if (getTxtMinScale().getText().compareTo("") == 0) {
443
				layer.setMaxScale(-1);
444
			    } else {
445
				System.err.print(ex.getLocalizedMessage());
446
			    }
485 447
			}
486 448

  
487 449
		} else {
......
525 487
	public String getName() {
526 488
		return PluginServices.getText(this,"General");
527 489
	}
490

  
491
    private String getLayerVectorialInfo() throws ReadDriverException {
492
	final FLyrVect lv = (FLyrVect) layer;
493
	ReadableVectorial rv = lv.getSource();
494
	if (rv instanceof VectorialEditableAdapter) {
495
	    rv = ((VectorialEditableAdapter) lv.getSource())
496
		    .getOriginalAdapter();
497
	}
498

  
499
	String info = PluginServices.getText(this, "Origen_de_datos") + ": ";
500

  
501
	if (rv instanceof VectorialAdapter) {
502
	    info += "\n" + rv.getDriver().getName() + "\n";
503

  
504
	    if (rv instanceof VectorialFileAdapter) {
505
		info += PluginServices.getText(this, "fichero") + ": "
506
			+ ((VectorialFileAdapter) rv).getFile();
507
	    } else if (rv instanceof VectorialDBAdapter) {
508
		DBLayerDefinition dbdef = ((VectorialDBAdapter) rv).getLyrDef();
509
		try {
510
		    info += PluginServices.getText(this, "url") + ": "
511
			    + dbdef.getConnection().getURL() + "\n";
512
		} catch (Exception e) {
513
		    e.printStackTrace();
514
		}
515

  
516
		info += PluginServices.getText(this, "Tabla") + ": "
517
			+ dbdef.getComposedTableName() + "\n";
518

  
519
		info += PluginServices.getText(this, "sql_restriction") + ": "
520
			+ ((VectorialDBAdapter) rv).getWhereClause() + "\n";
521
	    }
522
	}
523

  
524
	info += "\n" + PluginServices.getText(this, "type") + ": "
525
		+ lv.getTypeStringVectorLayer() + "\n";
526
	return info;
527
    }
528

  
529
    private String getLayerInfoExtent(Rectangle2D extent, IProjection proj,
530
	    String extentName) {
531
	String info;
532
	info = PluginServices.getText(this, "Extent") + " " + proj.getAbrev()
533
		+ " (" + PluginServices.getText(this, extentName) + "):\n\t"
534
		+ PluginServices.getText(this, "Superior") + ":\t"
535
		+ extent.getMaxY() + "\n\t"
536
		+ PluginServices.getText(this, "Inferior") + ":\t"
537
		+ extent.getMinY() + "\n\t"
538
		+ PluginServices.getText(this, "Izquierda") + ":\t"
539
		+ extent.getMinX() + "\n\t"
540
		+ PluginServices.getText(this, "Derecha") + ":\t"
541
		+ extent.getMaxX() + "\n";
542
	return info;
543
    }
528 544
}

Also available in: Unified diff