/*******************************************************************************
 * Copyright 2014, 2017 gwt-ol3
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package com.github.tdesjardins.ol3.demo.client.example;

import com.github.tdesjardins.ol3.demo.client.utils.DemoUtils;

import ol.Collection;
import ol.Coordinate;
import ol.Extent;
import ol.Map;
import ol.MapOptions;
import ol.OLFactory;
import ol.View;
import ol.ViewOptions;
import ol.layer.Base;
import ol.layer.Image;
import ol.layer.LayerOptions;
import ol.proj.Projection;
import ol.source.ImageMapGuide;
import ol.source.ImageMapGuideOptions;
import ol.source.ImageMapGuideParams;

/**
 * Example with MapGuide layers.
 *
 * @author Tobias Lochmann
 *
 */
public class MapGuideExample implements Example {

    /* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show()
     */
    @Override
    public void show(String exampleId) {

    	// create a projection
        Projection projection = Projection.get("EPSG:4326");

        // create a MapGuide params
        ImageMapGuideParams imageMapGuideParams = OLFactory.createOptions();
        imageMapGuideParams.setFormat("PNG");
        imageMapGuideParams.setMapDefinition("Library://Public/Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
        imageMapGuideParams.setUserName("OpenLayers");
        imageMapGuideParams.setPassword("OpenLayers");

    	// create a MapGuide image
        ImageMapGuideOptions imageMapGuideOptions = OLFactory.createOptions();
        imageMapGuideOptions.setParams(imageMapGuideParams);
        imageMapGuideOptions.setUrl("http://www.buoyshark.com/mapguide/mapagent/mapagent.fcgi?");
        imageMapGuideOptions.setUseOverlay(false);
        imageMapGuideOptions.setMetersPerUnit(111319.4908d);
        imageMapGuideOptions.setRatio(2.0f);

        ImageMapGuide imageMapGuideSource = OLFactory.createImageMapGuideSource(imageMapGuideOptions);
        LayerOptions layerOptions = OLFactory.createOptions();
        Extent bounds = Extent.create(-87.865114442365922d,43.665065564837931d,-87.595394059497067d,43.823852564430069d);
        layerOptions.setExtent(bounds);
        layerOptions.setSource(imageMapGuideSource);
        Image MapGuideLayer = OLFactory.createImageLayer(layerOptions);


        // create a view
        ViewOptions viewOptions = OLFactory.createOptions();
        viewOptions.setProjection(projection);
        viewOptions.setZoom(12.0d);
        Coordinate centerCoordinate = OLFactory.createCoordinate(-87.7302542509315d, 43.744459064634d);
        viewOptions.setCenter(centerCoordinate);
        View view = OLFactory.createView(viewOptions);

        // create the map
        MapOptions mapOptions = OLFactory.createOptions();
        mapOptions.setTarget(exampleId);
        mapOptions.setView(view);
        Collection<Base> lstLayer = OLFactory.createCollection();
        lstLayer.push(MapGuideLayer);
        mapOptions.setLayers(lstLayer);
        Map map = OLFactory.createMap(mapOptions);

        // add some controls
        map.addControl(OLFactory.createScaleLine());
        DemoUtils.addDefaultControls(map.getControls());

        // add some interactions
        map.addInteraction(OLFactory.createKeyboardPan());
        map.addInteraction(OLFactory.createKeyboardZoom());
        map.addControl(OLFactory.createRotate());

    }

}


@@ -969,29 +969,8 @@
 ns;%0A
-import ol.OLFactory;%0A
 impo
@@ -996,32 +996,158 @@
 ol.ViewOptions;%0A
+import ol.control.Rotate;%0Aimport ol.control.ScaleLine;%0Aimport ol.interaction.KeyboardPan;%0Aimport ol.interaction.KeyboardZoom;%0A
 import ol.layer.
@@ -1617,25 +1617,28 @@
 eId) %7B%0A%0A    
-%09
+    
 // create a 
@@ -1796,38 +1796,38 @@
 arams = 
-OLFactory.createOption
+new ImageMapGuideParam
 s();%0A   
@@ -2173,39 +2173,40 @@
 deOptions = 
-OLFactory.creat
+new ImageMapGuid
 eOptions();%0A
@@ -2566,32 +2566,20 @@
 ource = 
-OLFactory.create
+new 
 ImageMap
@@ -2583,22 +2583,16 @@
 MapGuide
-Source
 (imageMa
@@ -2643,32 +2643,25 @@
 tions = 
-OLFactory.create
+new Layer
 Options(
@@ -2690,22 +2690,19 @@
 ds =
+ new
  Extent
-.create
 (-87
@@ -2889,17 +2889,17 @@
   Image 
-M
+m
 apGuideL
@@ -2909,34 +2909,17 @@
 r = 
-OLFactory.createImageLayer
+new Image
 (lay
@@ -2931,17 +2931,16 @@
 ions);%0A%0A
-%0A
         
@@ -2990,32 +2990,24 @@
 tions = 
-OLFactory.create
+new View
 Options(
@@ -3130,32 +3130,20 @@
 inate = 
-OLFactory.create
+new 
 Coordina
@@ -3253,32 +3253,20 @@
  view = 
-OLFactory.create
+new 
 View(vie
@@ -3335,32 +3335,23 @@
 tions = 
-OLFactory.create
+new Map
 Options(
@@ -3464,32 +3464,20 @@
 Layer = 
-OLFactory.create
+new 
 Collecti
@@ -3478,16 +3478,22 @@
 llection
+%3CBase%3E
 ();%0A    
@@ -3510,17 +3510,17 @@
 er.push(
-M
+m
 apGuideL
@@ -3584,32 +3584,20 @@
 p map = 
-OLFactory.create
+new 
 Map(mapO
@@ -3658,32 +3658,20 @@
 Control(
-OLFactory.create
+new 
 ScaleLin
@@ -3794,32 +3794,20 @@
 raction(
-OLFactory.create
+new 
 Keyboard
@@ -3841,32 +3841,20 @@
 raction(
-OLFactory.create
+new 
 Keyboard
@@ -3889,24 +3889,12 @@
 rol(
-OLFactory.create
+new 
 Rota

Refactor MapGuideExample