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

From: Butler, Jason <Jason.Butler_at_dsto.defence.gov.au>
Date: Fri, 4 Aug 2006 09:48:55 +1000

Hi Øystein,

I never tried setting the shape back to an OMGraphic object. Once I had generated the shape from the projection, I just painted it directly on to the Graphics object.
E.g.

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);
                //set paint and fill in g directly here.
                ((Graphics2D)g).draw(or1.getShape()); //try to use shape of or1
        }

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

As to your error, or2 has no coordinates, or rendertype set, so when it tries to generate a new shape, (overwriting the one you just set), it fails.

I hope this helps,

Jason.
 

-----Original Message-----
From: Oystein E. Thorvaldsen [mailto:oysteine_at_pvv.org]
Sent: Friday, 4 August 2006 2:36 AM
To: Butler, Jason
Cc: openmap-users_at_bbn.com
Subject: Re: [OpenMap Users] Creating a shape from intersecting circles?

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 - 19:56:48 EDT

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