Re: [OpenMap Users] Creating a shape from intersecting circles?

From: Oystein E. Thorvaldsen <oysteine_at_pvv.org>
Date: Thu, 03 Aug 2006 18:35:54 +0200

Butler, Jason wrote:
> Your first idea can be used to do what you want. I think the steps are
> 1. Create the circles as OMCircles.
> 2. Project them onto the map. i.e. myOMCircle.generate(myProjection);
> This generates the shape in screen coordinates so the shapes of the circles will change, based upon the projection used.
> 3. Extract the Areas from them. java.awt.geom.Area myArea = new Area(myOMCircle.getShape());
> 4. Use Area to create the intersection. MyArea.intersect(myOtherArea)
> 5. Paint the final area into the screen in the paint section of your Layer. ((Graphics2D)g).draw(myArea);

Now I've tried a simplified version using OMRect, to get a grip on
get/setShape(); code below. I must be doing something wrong, since or2
is not shown and I get the following error message: OMRect.generate():
invalid RenderType

The Projection is the one returned by the instance of MapBean in the
class adding this layer.

public class TestLayer extends Layer {
        private Projection proj;

        public TestLayer(Projection p) {
                proj = p;}

        public void paint(java.awt.Graphics g) {
                OMRect or1 = new OMRect(40, 40, 60, 60, OMGraphic.LINETYPE_STRAIGHT);
                or1.generate(proj);
                or1.render(g);
                OMRect or2 = new OMRect();
                or2.setShape(or1.getShape()); //try to use shape of or1
                or2.setFillPaint(Color.green);
                or2.generate(proj);
                or2.render(g);
        }

        public void projectionChanged(ProjectionEvent e) {
                repaint();
        }
}

Calling or2.isVisible() returns true
Calling getRenderType() returns 0 (unknown), could this have something
to do with missing Projection.forwardRect()? explains the invalid
rendertype error
Calling or2.getNeedToRegenerate() returns true
Calling or2.isRenderable()) returns FALSE (WHY?)

Řystein

--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Thu Aug 03 2006 - 12:36:21 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:07 EDT