Hello Miguel,

I would like for you to review this patch.  It converts the PolyStyleOptions
object to a JS overlay.

M
maps/samples/hellomaps/src/com/google/gwt/maps/sample/hellomaps/client/DrawingOverlayDemo.java
M
maps/maps/src/com/google/gwt/maps/client/overlay/PolyStyleOptions.java

-- 
Eric Z. Ayers - GWT Team - Atlanta, GA USA
http://code.google.com/webtoolkit/

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

M      maps/samples/hellomaps/src/com/google/gwt/maps/sample/hellomaps/client/DrawingOverlayDemo.java
M      maps/maps/src/com/google/gwt/maps/client/overlay/PolyStyleOptions.java

Index: maps/samples/hellomaps/src/com/google/gwt/maps/sample/hellomaps/client/DrawingOverlayDemo.java
===================================================================
--- maps/samples/hellomaps/src/com/google/gwt/maps/sample/hellomaps/client/DrawingOverlayDemo.java	(revision 760)
+++ maps/samples/hellomaps/src/com/google/gwt/maps/sample/hellomaps/client/DrawingOverlayDemo.java	(working copy)
@@ -104,7 +104,7 @@
   }
 
   private void createPolyline() {
-    PolyStyleOptions style = new PolyStyleOptions(color, weight, opacity);
+    PolyStyleOptions style = PolyStyleOptions.getInstance(color, weight, opacity);
 
     final Polyline poly = new Polyline(new LatLng[0]);
     lastPolyline = poly;
@@ -138,7 +138,7 @@
   }
 
   private void createPolygon() {
-    PolyStyleOptions style = new PolyStyleOptions(color, weight, opacity);
+    PolyStyleOptions style = PolyStyleOptions.getInstance(color, weight, opacity);
 
     final Polygon poly = new Polygon(new LatLng[0], color, weight, opacity,
         color, fillFlag ? .7 : 0.0);
Index: maps/maps/src/com/google/gwt/maps/client/overlay/PolyStyleOptions.java
===================================================================
--- maps/maps/src/com/google/gwt/maps/client/overlay/PolyStyleOptions.java	(revision 760)
+++ maps/maps/src/com/google/gwt/maps/client/overlay/PolyStyleOptions.java	(working copy)
@@ -16,44 +16,40 @@
 package com.google.gwt.maps.client.overlay;
 
 import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.maps.client.impl.PolyStyleOptionsImpl;
 
 /**
  * Options to pass to the [EMAIL PROTECTED] Polyline} drawing routines.
  */
-public class PolyStyleOptions {
+public class PolyStyleOptions extends JavaScriptObject {
 
-  private final JavaScriptObject jsoPeer;
-
   /**
-   * Create an empty PolyStyleOptions object. Used as a parameter to the
-   * [EMAIL PROTECTED] Polyline} constructor.
+   * Creates a new PolyStyleOptions object. 
    */
-  public PolyStyleOptions() {
-    jsoPeer = PolyStyleOptionsImpl.impl.construct();
+  public static PolyStyleOptions getInstance() {
+    return (PolyStyleOptions) PolyStyleOptions.createObject();
   }
-
+  
   /**
-   * Create a PolyStyleOptions object. Used as a parameter to the
-   * [EMAIL PROTECTED] Polyline} constructor.
+   * Create a new PolyStyleOptions object. 
    * 
    * @param weightInPixels the width of the line to create.
    */
-  public PolyStyleOptions(int weightInPixels) {
-    this();
-    setWeight(weightInPixels);
+  public static PolyStyleOptions getInstance(int weightInPixels) {
+    PolyStyleOptions instance = getInstance();
+    instance.setWeight(weightInPixels);
+    return instance;
   }
 
   /**
-   * Create a PolyStyleOptions object. Used as a parameter to the
-   * [EMAIL PROTECTED] Polyline} constructor.
+   * Create a new PolyStyleOptions object. 
    * 
    * @param colorSpec color of the line. See [EMAIL PROTECTED] #setColor(String)} for the
    *          format of the string.
    */
-  public PolyStyleOptions(String colorSpec) {
-    this();
-    setColor(colorSpec);
+  public static PolyStyleOptions getInstance(String colorSpec) {
+    PolyStyleOptions instance = getInstance();
+    instance.setColor(colorSpec);
+    return instance;
   }
 
   /**
@@ -64,22 +60,27 @@
    * @param colorSpec color of the line. See [EMAIL PROTECTED] #setColor(String)} for the
    *          format of the string.
    */
-  public PolyStyleOptions(String colorSpec, int weightInPixels, double opacity) {
-    this();
-    setColor(colorSpec);
-    setWeight(weightInPixels);
-    setOpacity(opacity);
+  public static PolyStyleOptions getInstance(String colorSpec, int weightInPixels, double opacity) {
+    PolyStyleOptions instance = getInstance();
+    instance.setColor(colorSpec);
+    instance.setWeight(weightInPixels);
+    instance.setOpacity(opacity);
+    return instance;
   }
 
+  protected PolyStyleOptions() {
+    // Required for a JS overlay.
+  }
+
   /**
    * Specifies a string that contains a hexadecimal numeric HTML style, i.e.
    * #RRGGBB.
    * 
    * @param colorSpec specifies a color in hex format.
    */
-  void setColor(String colorSpec) {
-    PolyStyleOptionsImpl.impl.setColor(jsoPeer, colorSpec);
-  }
+  public final native void setColor(String colorSpec) /*-{
+    this.color = colorSpec;
+  }-*/;
 
   /**
    * Specifies the opacity of the polyline.
@@ -87,17 +88,17 @@
    * @param opacity specifies the opacity of the polyline as a fractional value
    *          between 0 (transparent) and 1 (opaque).
    */
-  void setOpacity(double opacity) {
-    PolyStyleOptionsImpl.impl.setOpacity(jsoPeer, opacity);
-  }
+  public final native void setOpacity(double opacity) /*-{
+    this.opacity = opacity;
+  }-*/;
 
   /**
    * Specifies the width of the line in pixels.
    * 
    * @param weightInPixels specifies the width of the line in pixels.
    */
-  void setWeight(int weightInPixels) {
-    PolyStyleOptionsImpl.impl.setWeight(jsoPeer, weightInPixels);
-  }
+  public final native void setWeight(int weightInPixels) /*-{
+    this.weight = weightInPixels;
+  }-*/;
 
 }

Reply via email to