AffineTransform

T

Thijs Muizelaar

For a my PhD project I'm programming a simulator in which a road network
is displayed on a small map. This happens inside an extended JPanel. The
size of the road network is larger than the size of this JPanel, so I
applied an AffineTransform, such that the road network is displayed
correctly inside the JPanel. In this network the origin and destination
of a trip is also displayed (with the letters O and D).

However, because of the large scaling, the stroke use for the lines is
too thin. The same applies to the fontsize used for O and D. Is it
possible to use the fontsize and the BasicStroke I defined in my code,
without applying the AffineTransform? I can't think of a way, because
the coordinates still have to be scaled and transformed properly. This
would make the code independent from the size of the road network that I
will use.

Thanks in advance!

Thijs
 
R

Roedy Green

However, because of the large scaling, the stroke use for the lines is
too thin. The same applies to the fontsize used for O and D. Is it
possible to use the fontsize and the BasicStroke I defined in my code,
without applying the AffineTransform? I can't think of a way, because
the coordinates still have to be scaled and transformed properly. This
would make the code independent from the size of the road network that I
will use.

I guess you have to scale up the width of your roads so they will be
fat enough to see, ditto for lettering. You know your scale, so it is
just a matter of multiplying to figure out the width you need to draw
your road lines.
 
W

Wayne

Thijs said:
For a my PhD project I'm programming a simulator in which a road network
is displayed on a small map. This happens inside an extended JPanel. The
size of the road network is larger than the size of this JPanel, so I
applied an AffineTransform, such that the road network is displayed
correctly inside the JPanel. In this network the origin and destination
of a trip is also displayed (with the letters O and D).

However, because of the large scaling, the stroke use for the lines is
too thin. The same applies to the fontsize used for O and D. Is it
possible to use the fontsize and the BasicStroke I defined in my code,
without applying the AffineTransform? I can't think of a way, because
the coordinates still have to be scaled and transformed properly. This
would make the code independent from the size of the road network that I
will use.

Thanks in advance!

Thijs

You should pick a SansSerif font that uses constant-width strokes.
Also try enabling some hinting in the Graphics2D object, e.g.:

g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON );

-Wayne
 
R

Roedy Green

You should pick a SansSerif font that uses constant-width strokes.
Also try enabling some hinting in the Graphics2D object, e.g.:

if you can use a commercial font, consider the Tiresias family.
http://mindprod.com/jgloss/tiresias.html

It was designed for the people with visual impairment, so is easy to
see at small font sizes.

Also have a look at http://mindprod.com/jgloss/browserfonts.html
to find a suitable font.

see also http://mindprod.com/jgloss/font.html#PROGRAMMER
for my recommended programmer fonts which are good at small sizes and
have distinctive glyphs.
 
W

Wayne

Roedy said:
if you can use a commercial font, consider the Tiresias family.
http://mindprod.com/jgloss/tiresias.html

That looks very useful. But from your sample on your site (and my
browser resolution) it seems the kerning between "rn" needs to
be increased. To me this looks like an 'm'.
It was designed for the people with visual impairment, so is easy to
see at small font sizes.

Microsoft also developed a font for this, Andale Mono (AndaleMo.ttf).
AFAIK it is free, however MS no longer distributes this font (or any
fonts) from their web site. Search the Internet for Andale.exe;
if you don't have a Windows system just open the .exe with zip
and extract the TTF file. It is very easy to read and all characters
and symbols are easy to differentiate.

-Wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top