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

From: Don Dietrick <dietrick_at_bbn.com>
Date: Wed, 9 Aug 2006 18:36:25 -0400

Hi Řystein,

You probably have to set needsToRegenerate == false for or2. Since
it's not creating anything internally, it thinks it doesn't have
anything to do. Also, since or2 doesn't have any coordinates to base
a generate() call on, it will zero out the Shape you've given it when
you call generate() on it.

On Aug 3, 2006, at 12:35 PM, Oystein E. Thorvaldsen wrote:

> 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

Yep

> Projection.forwardRect()? explains the invalid rendertype error

Yep

> Calling or2.getNeedToRegenerate() returns true

It hasn't generated anything with the projection, true by default
until it thinks it has something made for a projection.

> Calling or2.isRenderable()) returns FALSE (WHY?)

needsToRegenerate - it thinks it's in a bad state.

- Don





=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, dietrick_at_bbn.com
BBN Technologies, Cambridge, MA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


--
[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 Wed Aug 09 2006 - 18:36:37 EDT

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