Click here to get back home

Java question, but GIS related

 HomeNewsGroups | Search | About
 comp.infosystems.gis    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Java question, but GIS related Paul Cooper 05-03-2004
Posted by Paul Cooper on May 3, 2004, 6:10 pm
Please log in for more thread options
Dear All,

This is a little OT, but I think people here are more likely to have
come across the problem!

I am writing a Java application to display map data. It is very
simple, written using 2D graphics, and I use the AffineTransform
object to translate the Graphics2D from world space to screen space.
This works fine except that I cannot find a way of plotting a constant
sized marker! Java doesn't have a "marker" type of graphical object -
only Shapes and Text. Now, at present I simply draw a constant sized
circle - but the size is constant in World space, not screen space. I
can't think of a way of having an object whose position is subject to
the AffineTransform but whose size is always in pixels. Can anyone
suggest a way of creating this cartographically obvious object? I am
using Java 2 version 1.4 something - the latest version, anyway.

Any ideas?

Thanks

Paul


Posted by simon_chenery on May 3, 2004, 11:58 pm
Please log in for more thread options
Paul,

> I am writing a Java application to display map data. It is very
> simple, written using 2D graphics, and I use the AffineTransform
> object to translate the Graphics2D from world space to screen space.
> This works fine except that I cannot find a way of plotting a constant
> sized marker! Java doesn't have a "marker" type of graphical object -
> [snip]

I do exactly this in my Java-based project 'Mapyrus' (freely available from
http://www.chenery.id.au/mapyrus).

To achieve constant size markers I do not apply an AffineTransform
to my Graphics2D object. I use an AffineTransform independently
to transform the map data to pixel coordinates. Then I use pass the
pixel coordinate values I have calculated to Graphics2D drawLine()
and fillPolygon() methods.

Simon.


Posted by Paul Cooper on May 4, 2004, 9:49 am
Please log in for more thread options
On 3 May 2004 23:58:38 -0700, simon_chenery@yahoo.com wrote:

>Paul,
>
>> I am writing a Java application to display map data. It is very
>> simple, written using 2D graphics, and I use the AffineTransform
>> object to translate the Graphics2D from world space to screen space.
>> This works fine except that I cannot find a way of plotting a constant
>> sized marker! Java doesn't have a "marker" type of graphical object -
>> [snip]
>
>I do exactly this in my Java-based project 'Mapyrus' (freely available from
>http://www.chenery.id.au/mapyrus).
>
>To achieve constant size markers I do not apply an AffineTransform
>to my Graphics2D object. I use an AffineTransform independently
>to transform the map data to pixel coordinates. Then I use pass the
>pixel coordinate values I have calculated to Graphics2D drawLine()
>and fillPolygon() methods.
>
>Simon.

Thanks, Simon. Unfortunately the way I have done it is pretty deeply
embedded in my code, and re-writing it this way may be too hard. I did
it that way because I suspected it would be more efficient that way -
any opinion? I should say that this is a display sub-system for what
is primarily a database browsing tool, so the object model is based
around the database contents, which only incidentally extend the
relevant graphics types.

Why did Sun not appreciate that being able to render a point as a
marker was vital for some applications? It is all very well saying
that a Point is infinitesimally small and therefore cannot be rendered
- yes, mathematically correct, but very unhelpful for real world
applications!

Thanks again.

Paul


Posted by simon_chenery on May 5, 2004, 4:25 am
Please log in for more thread options
> On 3 May 2004 23:58:38 -0700, simon_chenery@yahoo.com wrote:
>
> >Paul,
> >
> >> I am writing a Java application to display map data. It is very
> >> simple, written using 2D graphics, and I use the AffineTransform
> >> object to translate the Graphics2D from world space to screen space.
> >> This works fine except that I cannot find a way of plotting a constant
> >> sized marker! Java doesn't have a "marker" type of graphical object -
> >> [snip]
> >
> >I do exactly this in my Java-based project 'Mapyrus' (freely available from
> >http://www.chenery.id.au/mapyrus).
> >
> >To achieve constant size markers I do not apply an AffineTransform
> >to my Graphics2D object. I use an AffineTransform independently
> >to transform the map data to pixel coordinates. Then I use pass the
> >pixel coordinate values I have calculated to Graphics2D drawLine()
> >and fillPolygon() methods.
> >
> >Simon.
>
> Thanks, Simon. Unfortunately the way I have done it is pretty deeply
> embedded in my code, and re-writing it this way may be too hard. I did
> it that way because I suspected it would be more efficient that way -
> any opinion? I should say that this is a display sub-system for what

A workaround may be to draw your fixed size marker symbols to a BufferedImage
and then use Graphics2D.drawImage() to blat the image containing the
correctly sized symbols into your map image.

Or, if you can use characters from a font as symbols then you may be
able to set a font with appropriate size and Graphics2D.drawString()
to draw each symbol with the correct size.

Simon.


Posted by Paul Cooper on May 5, 2004, 1:16 pm
Please log in for more thread options
On 5 May 2004 04:25:21 -0700, simon_chenery@yahoo.com wrote:

>> On 3 May 2004 23:58:38 -0700, simon_chenery@yahoo.com wrote:
>>
>> >Paul,
>> >
>> >> I am writing a Java application to display map data. It is very
>> >> simple, written using 2D graphics, and I use the AffineTransform
>> >> object to translate the Graphics2D from world space to screen space.
>> >> This works fine except that I cannot find a way of plotting a constant
>> >> sized marker! Java doesn't have a "marker" type of graphical object -
>> >> [snip]
>> >
>> >I do exactly this in my Java-based project 'Mapyrus' (freely available from
>> >http://www.chenery.id.au/mapyrus).
>> >
>> >To achieve constant size markers I do not apply an AffineTransform
>> >to my Graphics2D object. I use an AffineTransform independently
>> >to transform the map data to pixel coordinates. Then I use pass the
>> >pixel coordinate values I have calculated to Graphics2D drawLine()
>> >and fillPolygon() methods.
>> >
>> >Simon.
>>
>> Thanks, Simon. Unfortunately the way I have done it is pretty deeply
>> embedded in my code, and re-writing it this way may be too hard. I did
>> it that way because I suspected it would be more efficient that way -
>> any opinion? I should say that this is a display sub-system for what
>
>A workaround may be to draw your fixed size marker symbols to a BufferedImage
>and then use Graphics2D.drawImage() to blat the image containing the
>correctly sized symbols into your map image.
>
>Or, if you can use characters from a font as symbols then you may be
>able to set a font with appropriate size and Graphics2D.drawString()
>to draw each symbol with the correct size.
>
>Simon.


Thanks, Simon - all good ideas! I'll have another go at it.

Paul


Similar ThreadsPosted
GIS link, java related stuff December 10, 2004, 4:19 pm
Investing in GIS-related companies? February 25, 2006, 8:59 am
good website on geograpy related math? June 7, 2006, 11:42 pm
querying multiple related feature classes in ARC EDITOR March 10, 2006, 3:38 pm
Java and GIS September 8, 2006, 12:03 pm
Java Programming on TerraServer July 9, 2004, 11:36 am
java mapping engine? November 12, 2004, 4:23 pm
To any mapxtreme/java experts.. December 14, 2006, 12:23 pm
about maprxtreme java edition February 17, 2007, 8:06 am
MapXTreme Java dot density? September 9, 2008, 2:09 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap