This is just asking for some design help to determine the best way of implementing my own surface shape. I have a shape, such as an oval, that needs to have squares placed at various locations on its border. I want to be able to move the surface shape by selecting either the oval or any of the squares.
Can I mash an oval and quad surface shapes together to gain this functionality, or do I need to roll my own custom shape by implementing a base surface shape class?
Any suggestions would be extremely helpful.
Thanks in advance,
If all you need are 'regular' shapes that can be handled with the actual surface shape collection, then the best approach is probably to create a prerenderable/renderable 'compounded' object that will internally use one ellipse and four quads.
What you should care about is to make sure all those surface shapes are handled by the same renderer, so that they will share the same tile pyramid. However, you could as well just have those shapes in a surface shape layer which will pipe them all to the same renderer.
How many of those ovals are you planning to display?
The number of ovals will be undetermined based on the users needs, as well as the attached quads.
Also, when you say "regular" shapes, what exactly do you mean? Do you mean the set of shapes that are currently supported in WWJ ?
Thanks for the help.
Also, I have tried to wrap the ellipse and quads into a class that implements SurfaceShape, and add it to a SurfaceShapeLayer.
When I render the shapes, prerender() or render() never get called, but renderToRegion() seems to be the only one that gets executed. Can you explain how this process works ?
Surface shapes are sent to a surface object renderer by the surface shape layer. Pre render and render will not be called in that situation. However, the surface object renderer will call getLastModifiedTime(), getSectors() and renderToRegion() on each surface object it has to deal with.
The simplest path is to implement pre render and render and just pipe the shapes that make up your custom object to a tiled surface object renderer of your choice. In that situation you create a plain renderable. To share the same renderer among several of these compounded objects, implement a setRenderer() so that your application can direct them to one single renderer instance.
You can also implement surface object. But that would be a little more involved as you would have to call the surface object interface on each of your shapes and 'combine' the results. In fact it is probably easy too.
If you have a recent build, have a look at the experimental section examples.SurfaceObjects.java - there is a CustomMarker in there you may want to look at. You can also look at experimental...render.SurfaceIcon and SurfaceText.
PS: by regular shapes i meant those actually available in the SDK yes.
Last edited by patmurris; 05-07-2009 at 08:45 PM.