Index: DefaultView3DPanel.java
===================================================================
--- DefaultView3DPanel.java	(revision 442)
+++ DefaultView3DPanel.java	(revision 443)
@@ -24,226 +24,56 @@
 
 package org.gvsig.view3d.swing.impl;
 
-import gov.nasa.worldwind.globes.Earth;
-import gov.nasa.worldwind.globes.EarthFlat;
-import gov.nasa.worldwind.globes.Globe;
-import gov.nasa.worldwind.layers.CompassLayer;
-import gov.nasa.worldwind.layers.Layer;
-import gov.nasa.worldwind.layers.LayerList;
-import gov.nasa.worldwind.layers.ScalebarLayer;
-import gov.nasa.worldwind.layers.SkyColorLayer;
-import gov.nasa.worldwind.layers.SkyGradientLayer;
-import gov.nasa.worldwind.layers.StarsLayer;
-import gov.nasa.worldwind.layers.WorldMapLayer;
-
 import java.awt.BorderLayout;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
 
 import javax.swing.JComponent;
+import javax.swing.JPanel;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import org.gvsig.fmap.mapcontext.MapContext;
-import org.gvsig.fmap.mapcontext.layers.FLayer;
-import org.gvsig.fmap.mapcontext.layers.FLayers;
 import org.gvsig.tools.swing.api.ToolsSwingLocator;
 import org.gvsig.tools.swing.api.windowmanager.WindowManager;
-import org.gvsig.view3d.swing.api.AbstractView3DPanel;
+import org.gvsig.view3d.swing.api.MapControl3D;
+import org.gvsig.view3d.swing.api.View3DPanel;
+import org.gvsig.view3d.swing.api.View3DSwingLocator;
+import org.gvsig.view3d.swing.api.View3DSwingManager;
+import org.gvsig.view3d.swing.api.View3DSwingManager.TYPE;
 
 /**
  * @author llmarques
  *
  */
-public class DefaultView3DPanel extends AbstractView3DPanel {
+public class DefaultView3DPanel extends JPanel implements View3DPanel {
 
-    private static final Logger logger = LoggerFactory
-        .getLogger(DefaultView3DPanel.class);
-
     private static final long serialVersionUID = -87105248886531868L;
 
-    private MapContext mapContext;
-    
-    private TYPE type;
+    private MapControl3D mapControl3D;
 
+    /**
+     * @param theMapContext
+     * @param type
+     */
     public DefaultView3DPanel(MapContext theMapContext, TYPE type) {
+        super(new BorderLayout());
+                
+        View3DSwingManager swingManager = View3DSwingLocator.getManager();
+        this.mapControl3D =
+            swingManager.createMapControl3D(theMapContext, type);
 
-        super(new BorderLayout(), type);
-
-        this.mapContext = theMapContext;
-        this.type = type;
-
-        // add(this.mapContext.getLayers());
-
+        this.add(mapControl3D.asJComponent(), BorderLayout.CENTER);
     }
 
-    public void add(FLayer layer) {
-        // TODO
-        throw new UnsupportedOperationException();
+    public JComponent asJComponent() {
+        return this;
     }
 
-    public void add(FLayers layer) {
-        // TODO
-        throw new UnsupportedOperationException();
+    public MapControl3D getMapControl3D() {
+        return this.mapControl3D;
     }
 
-    public MapContext getMapContext() {
-        return this.mapContext;
-    }
-    
-    public TYPE getType() {
-        // TODO Auto-generated method stub
-        return this.type;
-    }
-
-    public double getVerticalExaggeration() {
-        return getWwd().getSceneController().getVerticalExaggeration();
-    }
-
-    public void hideAtmosphere() {
-        hideLayer(SkyGradientLayer.class);
-    }
-
-    public void hideMiniMap() {
-        hideLayer(WorldMapLayer.class);
-    }
-
-    public void hideNorthIndicator() {
-        hideLayer(CompassLayer.class);
-    }
-
-    public void hideScale() {
-        hideLayer(ScalebarLayer.class);
-    }
-
-    public void hideStarBackground() {
-        hideLayer(StarsLayer.class);
-    }
-
-    public void reloadLayers() {
-        // TODO
-        throw new UnsupportedOperationException();
-    }
-
-    public void remove(FLayer layer) {
-        // TODO
-        throw new UnsupportedOperationException();
-    }
-
-    public void removeAllLayers() {
-        getWwd().getModel().getLayers().removeAll();
-    }
-
-    public void setMapContext(MapContext theMapContext) {
-        this.mapContext = theMapContext;
-    }
-
-    public void setVerticalExaggeration(double verticalExaggeration) {
-        getWwd().getSceneController().setVerticalExaggeration(
-            verticalExaggeration);
-    }
-
     public void show() {
         WindowManager wm = ToolsSwingLocator.getWindowManager();
-        wm.showWindow(this, "_View3D_window", WindowManager.MODE.WINDOW);
+        wm.showWindow(this, "_View3D_window",
+            WindowManager.MODE.WINDOW);
     }
 
-    public void showAtmosphere() {
-        try {
-            Globe globe = getWwd().getModel().getGlobe();
-            if (globe instanceof Earth) {
-                getWwd().getModel().getLayers().add(new SkyGradientLayer());
-                addLayer(SkyGradientLayer.class);
-            } else if (globe instanceof EarthFlat) {
-                getWwd().getModel().getLayers().add(new SkyColorLayer());
-                addLayer(SkyColorLayer.class);
-            }
-        } catch (Exception e) {
-            logger.warn(
-                "Can't add " + SkyGradientLayer.class.getCanonicalName()
-                    + " or " + SkyColorLayer.class.getCanonicalName() + " to "
-                    + getWwd().getModel().toString(), e);
-        }
-    }
-
-    public void showMiniMap() {
-        try {
-            addLayer(WorldMapLayer.class);
-        } catch (Exception e) {
-            logger.warn("Can't add " + WorldMapLayer.class.getCanonicalName()
-                + "to " + getWwd().getModel().toString(), e);
-        }
-    }
-
-    public void showNortIndicator() {
-        try {
-            addLayer(CompassLayer.class);
-        } catch (Exception e) {
-            logger.warn("Can't add " + CompassLayer.class.getCanonicalName()
-                + " to " + getWwd().getModel().toString(), e);
-        }
-    }
-
-    public void showScale() {
-        try {
-            addLayer(ScalebarLayer.class);
-        } catch (Exception e) {
-            logger.warn("Can't add " + ScalebarLayer.class.getCanonicalName()
-                + " to " + getWwd().getModel().toString(), e);
-        }
-    }
-
-    public void showStarBackgroundLayer() {
-        try {
-            addLayer(StarsLayer.class);
-        } catch (Exception e) {
-            logger.warn("Can't add " + StarsLayer.class.getCanonicalName()
-                + " to " + getWwd().getModel().toString(), e);
-        }
-    }
-
-    public void synchronizeViewPorts() {
-        // TODO
-        throw new UnsupportedOperationException();
-    }
-
-    private boolean isAlreadyAdded(LayerList layerList,
-        @SuppressWarnings("rawtypes") Class clazz) {
-
-        List<Layer> layersByClass = layerList.getLayersByClass(clazz);
-
-        return layersByClass.size() > 0;
-    }
-
-    @SuppressWarnings("rawtypes")
-    private void hideLayer(Class layerClazz) {
-        LayerList layers = getWwd().getModel().getLayers();
-        List<Layer> layersByClass = layers.getLayersByClass(layerClazz);
-        layers.removeAll(layersByClass);
-    }
-
-    @SuppressWarnings("rawtypes")
-    private void addLayer(Class layerClazz) throws InstantiationException,
-        IllegalAccessException, IllegalArgumentException,
-        InvocationTargetException {
-        LayerList layerList = getWwd().getModel().getLayers();
-
-        if (isAlreadyAdded(layerList, layerClazz)) {
-            return;
-        }
-
-        Constructor[] constructors = layerClazz.getConstructors();
-        for (int i = 0; i < constructors.length; i++) {
-            if (constructors[i].getParameterTypes().length == 0) {
-                layerList.add((Layer) constructors[i].newInstance());
-            }
-        }
-    }
-
-    public JComponent asJComponent() {
-        return this;
-    }
-
 }
