Upside down font with graphics

J

jc_usernet

Hello.
I am trying to gain experience with Java graphics (Java(TM) SE Runtime
Environment (build 1.6.0_14-b08)) and using the class Graphics2D. I
performed a transformation on the axis (with a polarity reversal of
the Y axis), then wrote text to the graph. However it is displayed
upside down. The abbreviated Java syntax is:

Graphics2D g2d = ( Graphics2D ) g;
g2d.transform( new AffineTransform( 1, 0,
0, -1, 10, 390 ) );
// float m00, float m10, float m01,
float m11, float m02, float m12
// X'= 1*X +10 Y' =
-1*Y + 390
g2d.drawString( "Mary had a little lamb.", 330, 330);
g2d.drawLine(250,250,300,300);

My line is as expected and the text is how I would not like it (upside
down).
Are three any suggestion as to the best resolution?

Regards JC......
 
J

jc_usernet

jc_usernet said:
[...]
Graphics2D g2d = (Graphics2D) g;
g2d.transform(new AffineTransform(1, 0, 0, -1, 10, 390));
[...]
g2d.drawString( "Mary had a little lamb.", 330, 330);
[...]
My line is as expected and the text is how I would not like it (upside
down).
Are three any suggestion as to the best resolution?

Can you be more specific?  It seems to me that if you don't want the
text upside down, the most obvious solution is to not draw the text
while the Graphics2D is set to draw everything upside down.

But, that solution is in fact so obvious, it's difficult to believe
someone would post a question that has that as its answer.  So you must
have some more complicated problem in mind.

It would help if you could elaborate on what that more complicated
problem is.  It's not readily apparent (*) from what you've posted so far.

Pete

(*) (well, at least not to me...I apologize if I've missed something)

Hi Peter.
I do not think you missed anything. It just seems odd to me that we
have to juggle around co-ordinate transformations to achieve simple
effects on a graphic display.

Not withstanding any further learning about Java (and the Sun
libraries), are there any good user libraries that the novice can
start with?

Regards JC.....
 
J

John B. Matthews

jc_usernet said:
jc_usernet said:
[...]
Graphics2D g2d = (Graphics2D) g;
g2d.transform(new AffineTransform(1, 0, 0, -1, 10, 390));
[...]
g2d.drawString( "Mary had a little lamb.", 330, 330);
[...]
My line is as expected and the text is how I would not like it (upside
down).
Are three any suggestion as to the best resolution?

Can you be more specific?  It seems to me that if you don't want the
text upside down, the most obvious solution is to not draw the text
while the Graphics2D is set to draw everything upside down.

But, that solution is in fact so obvious, it's difficult to believe
someone would post a question that has that as its answer.  So you must
have some more complicated problem in mind.

It would help if you could elaborate on what that more complicated
problem is.  It's not readily apparent (*) from what you've posted so far.

Pete

(*) (well, at least not to me...I apologize if I've missed something)

Hi Peter.
I do not think you missed anything. It just seems odd to me that we
have to juggle around co-ordinate transformations to achieve simple
effects on a graphic display.

Not withstanding any further learning about Java (and the Sun
libraries), are there any good user libraries that the novice can
start with?

You can't go wrong with Sun's tutorial:

<http://java.sun.com/docs/books/tutorial/uiswing/>
 
R

Roedy Green

My line is as expected and the text is how I would not like it (upside
down).
Are three any suggestion as to the best resolution?

Write your text with a co-ordinate system that is not upside down.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top