/*******************************************************************************
 * 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.utils;

import ol.Collection;
import ol.Coordinate;
import ol.OLFactory;
import ol.OLUtil;
import ol.control.Control;
import ol.control.MousePosition;
import ol.geom.Polygon;
import ol.layer.Base;
import ol.layer.LayerOptions;
import ol.layer.Tile;
import ol.source.Osm;
import ol.source.XyzOptions;

/**
 * 
 * @author Tino Desjardins
 *
 */
public final class DemoUtils {

    private DemoUtils() {
        throw new AssertionError();
    }

    /**
     * Creates some default controls.
     * 
     * @param controls
     */
    public static void addDefaultControls(final Collection<Control> controls) {

        controls.push(OLFactory.createFullScreen());
        controls.push(OLFactory.createZoomSlider());
        MousePosition mousePosition = new MousePosition();
        mousePosition.setCoordinateFormat(Coordinate.createStringXY(5));
        controls.push(mousePosition);
        controls.push(OLFactory.createZoomToExtent());

    }
    
    /**
     * Creates a test polygon geometry (triangle).
     * 
     * @return test polygon geometry (EPSG:3857)
     */
    public static Polygon createTestPolygon() {

        Coordinate[][] coordinates = new Coordinate[1][4];

        Coordinate point1 = OLFactory.createCoordinate(13.36, 52.53);
        Coordinate point2 = OLFactory.createCoordinate(13.36, 52.51);
        Coordinate point3 = OLFactory.createCoordinate(13.37, 52.52);
        Coordinate point4 = OLFactory.createCoordinate(13.36, 52.53);

        coordinates[0][0] = point1;
        coordinates[0][1] = point2;
        coordinates[0][2] = point3;
        coordinates[0][3] = point4;

        Coordinate[][] tranformedCoordinates = new Coordinate[coordinates.length][];

        tranformedCoordinates[0] = OLUtil.transform(coordinates[0], "EPSG:4326", "EPSG:3857");
        return OLFactory.createPolygon(tranformedCoordinates);

    }

    public static Base createOsmLayer() {
        XyzOptions osmSourceOptions = OLFactory.createOptions();

        Osm osmSource = new Osm(osmSourceOptions);
        LayerOptions osmLayerOptions = OLFactory.createOptions();
        osmLayerOptions.setSource(osmSource);

        return new Tile(osmLayerOptions);
    }

}

@@ -950,29 +950,124 @@
 control.
-MousePosition
+FullScreen;%0D%0Aimport ol.control.MousePosition;%0D%0Aimport ol.control.ZoomSlider;%0D%0Aimport ol.control.ZoomToExtent
 ;%0D%0Aimpor
@@ -1567,32 +1567,20 @@
 ls.push(
-OLFactory.create
+new 
 FullScre
@@ -1609,32 +1609,20 @@
 ls.push(
-OLFactory.create
+new 
 ZoomSlid
@@ -1824,32 +1824,20 @@
 ls.push(
-OLFactory.create
+new 
 ZoomToEx
@@ -1859,14 +1859,10 @@
  %7D%0D%0A
-    
 %0D%0A
+
     
@@ -2127,32 +2127,20 @@
 oint1 = 
-OLFactory.create
+new 
 Coordina
@@ -2186,32 +2186,20 @@
 oint2 = 
-OLFactory.create
+new 
 Coordina
@@ -2245,32 +2245,20 @@
 oint3 = 
-OLFactory.create
+new 
 Coordina
@@ -2304,32 +2304,20 @@
 oint4 = 
-OLFactory.create
+new 
 Coordina

Refactor DemoUtils