Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #29845 > unrolled thread

Text orientation

Started byMartin Gregorie <martin@address-in-sig.invalid>
First post2014-08-25 00:40 +0000
Last post2014-08-25 12:11 +0000
Articles 7 — 4 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Text orientation Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-25 00:40 +0000
    Re: Text orientation Knute Johnson <eternal@knutejohnson.com> - 2014-08-24 20:29 -0700
      Re: Text orientation Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-25 11:56 +0000
    Re: Text orientation Roedy Green <see_website@mindprod.com.invalid> - 2014-08-24 22:33 -0700
    Re: Text orientation Jeff Higgins <jeff@invalid.invalid> - 2014-08-25 04:02 -0400
      Re: Text orientation Jeff Higgins <jeff@invalid.invalid> - 2014-08-25 04:44 -0400
        Re: Text orientation Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-25 12:11 +0000

#29845 — Text orientation

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2014-08-25 00:40 +0000
SubjectText orientation
Message-ID<lte0mj$jc$2@dont-email.me>
I will soon need to write a scheduling program that manipulates a 
rectangular matrix with a list of personal names labelling the columns 
and dates labelling the rows. This aspect, along with the processes 
needed to load data into the matrix, manipulate it and save it are well -
understood, but I have a display formatting issue with the column labels: 
is there any way that a Java program can align these labels vertically 
like most spreadsheets can, i.e. display the names vertically with the 
first letter at the top? The matrix I need to display can run to 25 or so 
rows and columns but each cell can be quite small (think of holding two 
10pt characters), which means the whole matrix should easily fit onto a 
display if the column labels can be painted as vertically aligned text.

I can't find any hint that this may be possible with AWT/Swing, but did I 
miss something? Alternatively, is it possible with JavaFX?
 

-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

[toc] | [next] | [standalone]


#29846

FromKnute Johnson <eternal@knutejohnson.com>
Date2014-08-24 20:29 -0700
Message-ID<lteajd$331$1@dont-email.me>
In reply to#29845
On 8/24/2014 17:40, Martin Gregorie wrote:
> I will soon need to write a scheduling program that manipulates a
> rectangular matrix with a list of personal names labelling the columns
> and dates labelling the rows. This aspect, along with the processes
> needed to load data into the matrix, manipulate it and save it are well -
> understood, but I have a display formatting issue with the column labels:
> is there any way that a Java program can align these labels vertically
> like most spreadsheets can, i.e. display the names vertically with the
> first letter at the top? The matrix I need to display can run to 25 or so
> rows and columns but each cell can be quite small (think of holding two
> 10pt characters), which means the whole matrix should easily fit onto a
> display if the column labels can be painted as vertically aligned text.
>
> I can't find any hint that this may be possible with AWT/Swing, but did I
> miss something? Alternatively, is it possible with JavaFX?

Something like this work?

import java.awt.*;
import javax.swing.*;

public class test3 extends JFrame {
     private static final String vertText =
      "<html><body>V<br>e<br>r<br>t<br>i<br>c<br>a<br>l<br> <br>" +
      "T<br>e<br>x<br>t</body></html>";
     public test3() {
         setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
         add(new JLabel(vertText,JLabel.CENTER),BorderLayout.CENTER);
         pack();
         setVisible(true);
     }

     public static void main(String... args) {
         EventQueue.invokeLater(new Runnable() {
             public void run() {
                 new test3();
             }
         });
     }
}


-- 

Knute Johnson

[toc] | [prev] | [next] | [standalone]


#29852

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2014-08-25 11:56 +0000
Message-ID<ltf88j$5e3$1@dont-email.me>
In reply to#29846
On Sun, 24 Aug 2014 20:29:52 -0700, Knute Johnson wrote:

> Something like this work?
> 
> import java.awt.*;
> import javax.swing.*;
> 
> public class test3 extends JFrame {
>      private static final String vertText =
>       "<html><body>V<br>e<br>r<br>t<br>i<br>c<br>a<br>l<br> <br>" +
>       "T<br>e<br>x<br>t</body></html>";
>      public test3() {
>          setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
>          add(new JLabel(vertText,JLabel.CENTER),BorderLayout.CENTER);
>          pack();
>          setVisible(true);
>      }
> 
>      public static void main(String... args) {
>          EventQueue.invokeLater(new Runnable() {
>              public void run() {
>                  new test3();
>              }
>          });
>      }
> }
>
Cute, and more readable than I expected until I ran it. Thats' certainly 
a possibility since, transforming name strings into that HTML format can 
certainly be automated and included in data loading code.

Thanks for the idea, which I must admit hadn't occurred to me, and the 
SSCE.


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

[toc] | [prev] | [next] | [standalone]


#29847

FromRoedy Green <see_website@mindprod.com.invalid>
Date2014-08-24 22:33 -0700
Message-ID<egilv9ttimdl60ksprdf0aodeve2usgj05@4ax.com>
In reply to#29845
On Mon, 25 Aug 2014 00:40:51 +0000 (UTC), Martin Gregorie
<martin@address-in-sig.invalid> wrote, quoted or indirectly quoted
someone who said :

>
>I can't find any hint that this may be possible with AWT/Swing, but did I 
>miss something? Alternatively, is it possible with JavaFX?

If you are willing to have the letters sideways, you can do it with
Affine Transform.  

Otherwise you will need FontMetrics and place each letter centered,
and fixed vertical spacing.

You paint each letter at centre line - width/2.

see http://mindprod.com/jgloss/fontmatrics.html

-- 
Roedy Green Canadian Mind Products http://mindprod.com
Errors using inadequate data are much less than those using no data at all. 
~ Charles Babbage (born: 1791-12-26 died: 1871-10-18 at age: 79)

[toc] | [prev] | [next] | [standalone]


#29850

FromJeff Higgins <jeff@invalid.invalid>
Date2014-08-25 04:02 -0400
Message-ID<lteqk2$i81$1@dont-email.me>
In reply to#29845
On 08/24/2014 08:40 PM, Martin Gregorie wrote:
> I will soon need to write a scheduling program that manipulates a
> rectangular matrix with a list of personal names labelling the columns
> and dates labelling the rows. This aspect, along with the processes
> needed to load data into the matrix, manipulate it and save it are well -
> understood, but I have a display formatting issue with the column labels:
> is there any way that a Java program can align these labels vertically
> like most spreadsheets can, i.e. display the names vertically with the
> first letter at the top? The matrix I need to display can run to 25 or so
> rows and columns but each cell can be quite small (think of holding two
> 10pt characters), which means the whole matrix should easily fit onto a
> display if the column labels can be painted as vertically aligned text.
>
> I can't find any hint that this may be possible with AWT/Swing, but did I
> miss something? Alternatively, is it possible with JavaFX?
>
>
You may find some ideas here.
Swing, but JavaFX should face similar issues.
<http://macdevcenter.com/pub/a/mac/2002/03/22/vertical_text.html>

[toc] | [prev] | [next] | [standalone]


#29851

FromJeff Higgins <jeff@invalid.invalid>
Date2014-08-25 04:44 -0400
Message-ID<ltet1u$hv$1@dont-email.me>
In reply to#29850
On 08/25/2014 04:02 AM, Jeff Higgins wrote:

> You may find some ideas here.
> Swing, but JavaFX should face similar issues.
> <http://macdevcenter.com/pub/a/mac/2002/03/22/vertical_text.html>
>
And this, just because I like it so much.
<http://explodingpixels.wordpress.com/2009/01/29/drawing-text-about-its-visual-center/>

[toc] | [prev] | [next] | [standalone]


#29853

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2014-08-25 12:11 +0000
Message-ID<ltf952$5e3$2@dont-email.me>
In reply to#29851
On Mon, 25 Aug 2014 04:44:15 -0400, Jeff Higgins wrote:

> On 08/25/2014 04:02 AM, Jeff Higgins wrote:
> 
>> You may find some ideas here.
>> Swing, but JavaFX should face similar issues.
>> <http://macdevcenter.com/pub/a/mac/2002/03/22/vertical_text.html>
>>
> And this, just because I like it so much.
> <http://explodingpixels.wordpress.com/2009/01/29/drawing-text-about-its-
visual-center/>

Thanks. That's useful information.


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web