001    package com.google.gwt.maps.client.drawinglib;
002    
003    import com.google.gwt.ajaxloader.client.ArrayHelper;
004    import com.google.gwt.core.client.JavaScriptObject;
005    import com.google.gwt.core.client.JsArrayString;
006    import com.google.gwt.maps.client.controls.ControlPosition;
007    
008    /**
009     * Options for the rendering of the drawing control.
010     * <br><br>
011     * See <a href="https://developers.google.com/maps/documentation/javascript/reference#DrawingControlOptions">DrawingControlOptions API Doc</a>
012     */
013    public class DrawingControlOptions extends JavaScriptObject {
014      
015      /**
016       * use newInstance();
017       */
018      protected DrawingControlOptions() {}
019      
020      /**
021       * Options for the rendering of the drawing control.
022       */
023      public static final DrawingControlOptions newInstance() {
024        return JavaScriptObject.createObject().cast();
025      }
026      
027      /**
028       * The drawing modes to display in the drawing control, in the order in which they are to be displayed. The hand icon (which corresponds to the null drawing mode) is always available and is not to be specified in this array. Defaults to [MARKER, POLYLINE, RECTANGLE, CIRCLE, POLYGON].
029       * hmmmm, this seems a bit overlay iterative 
030       * @param overlayTypes
031       */
032      public final void setDrawingModes(OverlayType... overlayTypes) {
033        if (overlayTypes == null) {
034          return;
035        }
036        String[] types = new String[overlayTypes.length];
037        for (int i=0; i < overlayTypes.length; i++) {
038          types[i] = overlayTypes[i].value(); 
039        }
040        JsArrayString drawingModes = ArrayHelper.toJsArrayString(types);
041        setDrawingModesImpl(drawingModes);
042      }
043      
044      private final native void setDrawingModesImpl(JsArrayString drawingModes) /*-{
045        this.drawingModes = drawingModes;
046      }-*/;
047    
048      /**
049       * The drawing modes to display in the drawing control, in the order in which they are to be displayed. The hand icon (which corresponds to the null drawing mode) is always available and is not to be specified in this array. Defaults to [MARKER, POLYLINE, RECTANGLE, CIRCLE, POLYGON].
050       */
051      public final OverlayType[] getDrawingModes() {
052        JsArrayString types = getDrawingModesImpl();
053        if (types == null) {
054          return null;
055        }
056        OverlayType[] r = new OverlayType[types.length()];
057        for (int i=0; i < types.length(); i++) {
058          r[i] = OverlayType.fromValue(types.get(i));
059        }
060        return r;
061      }
062    
063      private final native JsArrayString getDrawingModesImpl() /*-{
064        return this.drawingModes;
065      }-*/; 
066      
067      /**
068       * Position id. Used to specify the position of the control on the map. The default position is TOP_LEFT.
069       * @param position
070       */
071      public final void setPosition(ControlPosition position) {
072        setPositionImpl(position.value());
073      }
074      
075      private final native void setPositionImpl(int position) /*-{
076        this.position = position;
077      }-*/;
078      
079      /**
080       * Position id. Used to specify the position of the control on the map. The default position is TOP_LEFT.
081       */
082      public final ControlPosition getPosition() {
083        return ControlPosition.fromValue(getPositionImpl());
084      }
085    
086      private final native int getPositionImpl() /*-{
087        return this.position;
088      }-*/;
089    }