Revision 3191

View differences:

org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/DefaultFLyrRaster.java
1330 1330
	}
1331 1331

  
1332 1332
	public void addLegendListener(LegendListener listener) {
1333
		layerChangeSupport.addLayerListener(listener);
1333
		if(layerChangeSupport != null){
1334
			layerChangeSupport.addLayerListener(listener);
1335
		}
1334 1336
	}
1335 1337

  
1336 1338
	public int getShapeType() {
......
1405 1407
				return false;
1406 1408
			case IRasterLayerActions.TAILTRIM:
1407 1409
			case IRasterLayerActions.GEOLOCATION:
1410
				if(getDataStore() == null){
1411
					return false;
1412
				}
1408 1413
				return !(getDataStore().isTiled());
1409 1414
		}
1410 1415
		return true;
1411 1416
	}
1412 1417

  
1413 1418
	public void setVisible(boolean visibility) {
1414
		if(visibility)
1415
			state.disableStopped();
1416
		else
1417
			enableStopped();
1418

  
1419
		if(isAwake() || isClosed())
1420
			try {
1421
				this.load();
1422
			} catch (LoadLayerException e) {
1423
				e.printStackTrace();
1419
			if((state != null) && visibility)
1420
				state.disableStopped();
1421
			else
1422
				enableStopped();
1423
	
1424
			if(isAwake() || isClosed())
1425
				try {
1426
					this.load();
1427
				} catch (LoadLayerException e) {
1428
					e.printStackTrace();
1429
				}
1430
	
1431
			/*
1432
			 * Cuando se modifica la visibilidad de una capa raster se hace un updateDrawVersion de todas las
1433
			 * capas raster de ese MapContext. Esto es porque la estrategia utilizada por RasterDrawStrategy hace
1434
			 * que se cacheen en blanco las capas raster que est?n ocultas debajo de otras. Al hacer invisibles las
1435
			 * de arriba la cache que estaba en blanco hace que no se pinte nada. Para evitar esto las marcamos todas
1436
			 * como que han sido modificadas para que se vuelvan a leer.
1437
			 */
1438
			if(getMapContext() != null) {
1439
				ArrayList<FLayer> listLayers = new ArrayList<FLayer>();
1440
				listLayers = RasterDrawStrategy.getLayerList(getMapContext().getLayers(), listLayers);
1441
				for (int i = 0; i < listLayers.size(); i++)
1442
					if(listLayers.get(i) instanceof DefaultFLyrRaster)
1443
						((DefaultFLyrRaster)listLayers.get(i)).updateDrawVersion();
1424 1444
			}
1425

  
1426
		/*
1427
		 * Cuando se modifica la visibilidad de una capa raster se hace un updateDrawVersion de todas las
1428
		 * capas raster de ese MapContext. Esto es porque la estrategia utilizada por RasterDrawStrategy hace
1429
		 * que se cacheen en blanco las capas raster que est?n ocultas debajo de otras. Al hacer invisibles las
1430
		 * de arriba la cache que estaba en blanco hace que no se pinte nada. Para evitar esto las marcamos todas
1431
		 * como que han sido modificadas para que se vuelvan a leer.
1432
		 */
1433
		if(getMapContext() != null) {
1434
			ArrayList<FLayer> listLayers = new ArrayList<FLayer>();
1435
			listLayers = RasterDrawStrategy.getLayerList(getMapContext().getLayers(), listLayers);
1436
			for (int i = 0; i < listLayers.size(); i++)
1437
				if(listLayers.get(i) instanceof DefaultFLyrRaster)
1438
					((DefaultFLyrRaster)listLayers.get(i)).updateDrawVersion();
1439
		}
1440

  
1441
		super.setVisible(visibility);
1445
	
1446
			super.setVisible(visibility);
1442 1447
	}
1443 1448

  
1444 1449
	/**
......
1626 1631
			state.enableClosed();
1627 1632
	}
1628 1633

  
1629
	public void enableOpen() throws NotAvailableStateException {state.enableOpen();}
1634
	public void enableOpen() throws NotAvailableStateException {
1635
		if(state != null){
1636
			state.enableOpen();
1637
		}
1638
	}
1630 1639

  
1631
	public void enableStopped() {state.enableStopped();}
1640
	public void enableStopped() {
1641
		if(state != null) {
1642
			state.enableStopped();
1643
		}
1644
	}
1632 1645

  
1633
	public boolean isAwake() {return state.isAwake();}
1646
	public boolean isAwake() {
1647
		return (state != null) && state.isAwake();
1648
	}
1634 1649

  
1635
	public boolean isClosed() {return state.isClosed();}
1650
	public boolean isClosed() {
1651
		return (state != null) && state.isClosed();
1652
	}
1636 1653

  
1637
	public boolean isOpen() {return state.isOpen();}
1654
	public boolean isOpen() {
1655
		return (state != null) && state.isOpen();
1656
	}
1638 1657

  
1639
	public boolean isStopped() {return state.isStopped();}
1658
	public boolean isStopped() {
1659
		return (state != null) && (state.isStopped());
1660
	}
1640 1661

  
1641 1662

  
1642 1663
	@SuppressWarnings("rawtypes")
......
1663 1684
	}
1664 1685
	
1665 1686
	public IProjection getProjection() {
1687
		if(getDataStore() == null)
1688
			return null;
1689
		
1666 1690
		RasterDataParameters p = (RasterDataParameters)getDataStore().getParameters();
1667 1691
		if(p.getReprojectionOption() == RasterDataParameters.DONT_CHANGE_PROJECTION)
1668 1692
			return null;

Also available in: Unified diff