Revision 496 2.1/trunk/org.gvsig.view3d/org.gvsig.view3d.swing/org.gvsig.view3d.swing.impl/src/main/java/org/gvsig/view3d/swing/impl/DefaultMapControl3D.java
DefaultMapControl3D.java | ||
---|---|---|
33 | 33 |
import gov.nasa.worldwind.globes.Earth; |
34 | 34 |
import gov.nasa.worldwind.globes.EarthFlat; |
35 | 35 |
import gov.nasa.worldwind.globes.ElevationModel; |
36 |
import gov.nasa.worldwind.globes.Globe; |
|
37 | 36 |
import gov.nasa.worldwind.layers.CompassLayer; |
38 | 37 |
import gov.nasa.worldwind.layers.Layer; |
39 | 38 |
import gov.nasa.worldwind.layers.LayerList; |
... | ... | |
82 | 81 |
import org.gvsig.tools.visitor.VisitCanceledException; |
83 | 82 |
import org.gvsig.view3d.lib.api.View3DLocator; |
84 | 83 |
import org.gvsig.view3d.lib.api.View3DManager; |
84 |
import org.gvsig.view3d.lib.api.properties.GeneralProperties3D; |
|
85 | 85 |
import org.gvsig.view3d.lib.api.properties.LayerProperties3D; |
86 | 86 |
import org.gvsig.view3d.lib.api.properties.MapControlProperties3D; |
87 | 87 |
import org.gvsig.view3d.lib.api.properties.RasterLayerProperties3D; |
... | ... | |
180 | 180 |
|
181 | 181 |
addLayerCollectionListener(mapContext.getLayers()); |
182 | 182 |
|
183 |
setGeneral3DProperties(); |
|
184 |
|
|
183 | 185 |
View3DManager manager = View3DLocator.getManager(); |
184 | 186 |
this.properties = manager.getMapControl3DProperties(viewProperties); |
185 | 187 |
addChangePropertyListener(this.properties); |
186 | 188 |
setMapControl3DProperties(); |
187 | 189 |
} |
188 | 190 |
|
191 |
private void setGeneral3DProperties() { |
|
192 |
|
|
193 |
View3DManager manager = View3DLocator.getManager(); |
|
194 |
GeneralProperties3D general3DProperties = |
|
195 |
manager.getGeneral3DProperties(); |
|
196 |
|
|
197 |
this.setAtmosphereVisibility(general3DProperties |
|
198 |
.getAtmosphereVisibility()); |
|
199 |
this.setMiniMapVisibility(general3DProperties.getMinimapVisibility()); |
|
200 |
this.setNorthIndicatorVisibility(general3DProperties |
|
201 |
.getNorthIndicatorVisibility()); |
|
202 |
this.setStarsBackgroundVisibility(general3DProperties |
|
203 |
.getStarsBackgroundVisibility()); |
|
204 |
this.setScaleVisibility(general3DProperties.getScaleVisibility()); |
|
205 |
} |
|
206 |
|
|
189 | 207 |
private void addChangePropertyListener(MapControlProperties3D properties) { |
190 | 208 |
properties.addPropertyChangeListener(new PropertyChangeListener() { |
191 | 209 |
|
... | ... | |
400 | 418 |
|
401 | 419 |
@SuppressWarnings("rawtypes") |
402 | 420 |
private void setWWLayerVisibility(Class layerClazz, boolean visiblity) { |
403 |
LayerList layerList = getWwd().getModel().getLayers(); |
|
421 |
List<Layer> layersByClass = |
|
422 |
getWwd().getModel().getLayers().getLayersByClass(layerClazz); |
|
404 | 423 |
|
405 |
for (Layer layer : layerList) {
|
|
424 |
for (Layer layer : layersByClass) {
|
|
406 | 425 |
layer.setEnabled(visiblity); |
407 | 426 |
} |
408 | 427 |
}; |
... | ... | |
545 | 564 |
} |
546 | 565 |
} |
547 | 566 |
|
548 |
public void hideAtmosphere() { |
|
549 |
setWWLayerVisibility(SkyGradientLayer.class, false); |
|
567 |
public void setAtmosphereVisibility(boolean visibility) { |
|
568 |
if (getType() == TYPE.SPHERE) { |
|
569 |
setWWLayerVisibility(SkyGradientLayer.class, visibility); |
|
570 |
} else if (getType() == TYPE.FLAT) { |
|
571 |
setWWLayerVisibility(SkyColorLayer.class, visibility); |
|
572 |
} |
|
550 | 573 |
} |
551 | 574 |
|
552 |
// @SuppressWarnings("rawtypes") |
|
553 |
// private void hideWWLayer(Class layerClazz) { |
|
554 |
// LayerList layers = getWwd().getModel().getLayers(); |
|
555 |
// List<Layer> layersByClass = layers.getLayersByClass(layerClazz); |
|
556 |
// for (Layer layer : layersByClass) { |
|
557 |
// layer.setEnabled(false); |
|
558 |
// } |
|
559 |
// } |
|
560 |
|
|
561 |
// private void getWWLayerVisib(String layerName) { |
|
562 |
// LayerList layers = getWwd().getModel().getLayers(); |
|
563 |
// Layer layerByName = layers.getLayerByName(layerName); |
|
564 |
// if (layerByName != null) { |
|
565 |
// layerByName.setEnabled(false); |
|
566 |
// } |
|
567 |
// } |
|
568 |
|
|
569 |
public void hideMiniMap() { |
|
570 |
setWWLayerVisibility(WorldMapLayer.class, false); |
|
575 |
public void setMiniMapVisibility(boolean visiblity) { |
|
576 |
setWWLayerVisibility(WorldMapLayer.class, visiblity); |
|
571 | 577 |
} |
572 | 578 |
|
573 |
public void hideNorthIndicator() {
|
|
574 |
setWWLayerVisibility(CompassLayer.class, false);
|
|
579 |
public void setNorthIndicatorVisibility(boolean visibility) {
|
|
580 |
setWWLayerVisibility(CompassLayer.class, visibility);
|
|
575 | 581 |
} |
576 | 582 |
|
577 |
public void hideScale() {
|
|
578 |
setWWLayerVisibility(ScalebarLayer.class, false);
|
|
583 |
public void setScaleVisibility(boolean visibility) {
|
|
584 |
setWWLayerVisibility(ScalebarLayer.class, visibility);
|
|
579 | 585 |
} |
580 | 586 |
|
581 |
public void hideStarBackground() {
|
|
582 |
setWWLayerVisibility(StarsLayer.class, false);
|
|
587 |
public void setStarsBackgroundVisibility(boolean visibility) {
|
|
588 |
setWWLayerVisibility(StarsLayer.class, visibility);
|
|
583 | 589 |
} |
584 | 590 |
|
585 | 591 |
private void intializeWWPanel() { |
586 | 592 |
wwd = new WorldWindowGLJPanel(); |
587 |
wwd.setPreferredSize(new Dimension(800, 600)); |
|
588 | 593 |
|
594 |
View3DManager manager = View3DLocator.getManager(); |
|
595 |
GeneralProperties3D general3dProperties = |
|
596 |
manager.getGeneral3DProperties(); |
|
597 |
wwd.setPreferredSize(new Dimension(general3dProperties |
|
598 |
.getDefaultViewWidht(), general3dProperties.getDefaultViewHeight())); |
|
599 |
|
|
589 | 600 |
// Create the default model as described in the current worldwind |
590 | 601 |
// properties. |
591 | 602 |
Model m = |
... | ... | |
650 | 661 |
verticalExaggeration); |
651 | 662 |
} |
652 | 663 |
|
653 |
public void showAtmosphere() { |
|
654 |
Globe globe = getWwd().getModel().getGlobe(); |
|
655 |
if (globe instanceof Earth) { |
|
656 |
setWWLayerVisibility(SkyGradientLayer.class, true); |
|
657 |
} else if (globe instanceof EarthFlat) { |
|
658 |
setWWLayerVisibility(SkyColorLayer.class, true); |
|
659 |
} |
|
660 |
} |
|
661 |
|
|
662 |
public void showMiniMap() { |
|
663 |
setWWLayerVisibility(WorldMapLayer.class, true); |
|
664 |
} |
|
665 |
|
|
666 |
public void showNortIndicator() { |
|
667 |
setWWLayerVisibility(CompassLayer.class, true); |
|
668 |
} |
|
669 |
|
|
670 |
public void showScale() { |
|
671 |
setWWLayerVisibility(ScalebarLayer.class, true); |
|
672 |
} |
|
673 |
|
|
674 |
public void showStarBackgroundLayer() { |
|
675 |
setWWLayerVisibility(StarsLayer.class, true); |
|
676 |
} |
|
677 |
|
|
678 | 664 |
public void synchronizeLayers() { |
679 | 665 |
|
680 | 666 |
for (FLayer layer : drawLayerStatus.keySet()) { |
... | ... | |
750 | 736 |
} |
751 | 737 |
} |
752 | 738 |
|
753 |
public boolean isAtmosphereVisible() {
|
|
739 |
public boolean getAtmosphereVisibility() {
|
|
754 | 740 |
if (isWWLayerVisible(SkyGradientLayer.class) |
755 | 741 |
|| isWWLayerVisible(SkyColorLayer.class)) { |
756 | 742 |
return true; |
... | ... | |
758 | 744 |
return false; |
759 | 745 |
} |
760 | 746 |
|
761 |
public boolean isMinimapVisible() {
|
|
747 |
public boolean getMinimapVisibility() {
|
|
762 | 748 |
if (isWWLayerVisible(WorldMapLayer.class)) { |
763 | 749 |
return true; |
764 | 750 |
} |
765 | 751 |
return false; |
766 | 752 |
} |
767 | 753 |
|
768 |
public boolean isNorthIndicatorVisible() {
|
|
754 |
public boolean getNorthIndicatorVisibility() {
|
|
769 | 755 |
if (isWWLayerVisible(CompassLayer.class)) { |
770 | 756 |
return true; |
771 | 757 |
} |
772 | 758 |
return false; |
773 | 759 |
} |
774 | 760 |
|
775 |
public boolean isStartBackgroundVisible() {
|
|
761 |
public boolean getStarBackgroundVisibility() {
|
|
776 | 762 |
if (isWWLayerVisible(StarsLayer.class)) { |
777 | 763 |
return true; |
778 | 764 |
} |
779 | 765 |
return false; |
780 | 766 |
} |
781 | 767 |
|
782 |
public boolean isScaleVisible() {
|
|
768 |
public boolean getScaleVisibility() {
|
|
783 | 769 |
if (isWWLayerVisible(ScalebarLayer.class)) { |
784 | 770 |
return true; |
785 | 771 |
} |
Also available in: Unified diff