From: Edwin C. <com...@gm...> - 2009-08-21 15:35:31
|
Hi Michel, What exactly are the doubts you have about OpenLayersObjectWrapper? It extends JSObjectWrapper and wraps JSObject. JSObject is a class that adds some functionality to JavaScriptObject. JavaScriptObject is the handle GWT provides on Javascript objects (makes sense :-)....). For a deeper understanding of JavaScriptObject and interacting with Javascript from GWT, I would have to refer you to the GWT documentation. JSObject and other classes from util help dealing with the Javascript/Java communication. There are two ways to "wrap" a Javascript object: a) provide a wrapper class that holds on to the Javascript object via the handles GWT provides (in our case JSObject) b) extend JavaScriptObject/JSObject directly, which GWT calls Overlay types In GWT we have choosen for the first option. The only difference is that in option (a) you do getJSObject() to get at the handle on the Javascript object you are wrapping, while in option (b) you can access the handle on your Javascript object via this. Overlay types were not available when GWT-OL was created and I have a slight favor for the explicit wrapping, as it makes it more clear that you are "wrapping" something. It is a case of favoring Composition over Inheritance. Also, then we do not need to do anything to hide methods defined on JSObject to users. OpenLayersObjectWrapper simply defines methods/properties that every OpenLayers object will have, so these can be share by all classes wrapping OpenLayers objects. Currently I it only has getClassName() and getEvents(). The latter is defined there because you also might want to test if a class has an Events object (and fires events). If you are wrapping a Javascript object and it is an OpenLayers object, then you should extend OpenLayersObjectWrapper. If it is an OpenLayers object that fires event, then you should extend OpenLayersEObjectWrapper. Otherwise, you shouldn't extend OpenLayers(E)ObjectWrapper StyleMap is an OpenLayers object so it would extend OpenLayersObjectWrapper. If you do: var sm = new OpenLayers.StyleMap(); Then you get an object with a CLASS_NAME. That is why it should be wrapped by OpenLayersObjectWrapper. Greetings, Edwin 2009/8/21 Michel vitor <mic...@gm...> > Dear Edwin, > > I'm trying to make a function in Measure OL but I have a doubt about the > class OpenLayersObjectWrapper and > you could give me a description of their functionality > because I need to create a class StyleMap.js. > > -- > Michel Vitor A Rodrigues > 6° Periodo de Computação > Grupo Intec,Viçosa MG > > |