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


Groups > comp.lang.java.programmer > #31924

Re: Vertical Text - part 3

From Martin Gregorie <martin@address-in-sig.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Vertical Text - part 3
Date 2015-07-02 18:01 +0000
Organization A noiseless patient Spider
Message-ID <mn3u99$ogv$2@dont-email.me> (permalink)
References <mn160m$anb$1@dont-email.me> <mn3d9d$qha$1@dont-email.me> <1980b894-6ca3-48f5-b70a-1628c56185e1@googlegroups.com>

Show all headers | View raw


On Thu, 02 Jul 2015 07:24:05 -0700, e.d.programmer wrote:

> If you want the sideways text which may be hard for some to read but is
> easier to fit more, try this.
>
Agreed. Thats what the spreadsheet I replaced did. Its readable enough, 
and the reduced row height is valuable enough for the tool's overall 
usability to offset any perceived difficulty on reading the rotated text. 
  
>      public void drawTextSideways(final Graphics2D g2, final String s) {
>           final Font theFont = g2.getFont();
>           final FontMetrics fm = g2.getFontMetrics(theFont);
>           // Create a rotation transformation for the font.
>           final AffineTransform fontAT = new AffineTransform();
>           fontAT.rotate(-Math.PI / 2.0);
>           final Font theDerivedFont = theFont.deriveFont(fontAT);
>           // set the derived font in the Graphics2D context
>           g2.setFont(theDerivedFont);
>           g2.drawString(s, fm.getAscent(), fm.stringWidth(s) +
>           fm.getDescent());
>      }
> 
> I just pass in the Graphics object from the paintComponent() method
> which should work on any component.  In my previous complete example I
> extended JPanel but it looks exactly the same if you replace JPanel
> references with JLabel.
>
Yes, I can always do that if push comes to shove, but I thought I'd first 
try converting that into a method that generates a derived Font that I 
can simply hand to my class, which is derived from JLabel, via its 
setFont() method. 
 
> To make text more readable you could try displaying it on an angle.
> fontAT.rotate(-Math.PI / 4.0);
>
Unfortunately that would be a non-starter: each column has a couple of 
rows on control totals above the names, then the names, and below that 
the matrix used to visualise the overall current state of the roster. As 
some of the name lists contain over 25 names and the matrix has  a date, 
then up to four roster slots to the left of the matrix (and Murphy says 
that of course the roster with the most slots per day also has the 
biggest list of people to be rostered, all columns must be as narrow as 
possible or I ending up scrolling sideways as well as up and down, this 
would make an already difficult rostering job that much harder.

> To make text in general more readable try some settings at the beginning
> of the method.
>           g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
>           RenderingHints.VALUE_ANTIALIAS_ON);
>           g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
>           RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
>           g2.setRenderingHint(RenderingHints.KEY_RENDERING,
>           RenderingHints.VALUE_RENDER_QUALITY);
>           g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
>           RenderingHints.VALUE_STROKE_PURE);
> 
> If it's still not readable enough try testing different fonts...
>
Good point. I'm currently using a Monospaced plain 10 point text which 
seems quite readable. I've already modified your code to use this font 
and the readability is pretty good - even "[NA]" looks OK.


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

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Vertical Text - part 3 Martin Gregorie <martin@address-in-sig.invalid> - 2015-07-01 16:54 +0000
  Re: Vertical Text - part 3 Jeff Higgins <jeff@invalid.invalid> - 2015-07-01 18:25 -0400
    Re: Vertical Text - part 3 Martin Gregorie <martin@address-in-sig.invalid> - 2015-07-01 23:09 +0000
      Re: Vertical Text - part 3 Jeff Higgins <jeff@invalid.invalid> - 2015-07-01 19:44 -0400
        Re: Vertical Text - part 3 Martin Gregorie <martin@address-in-sig.invalid> - 2015-07-02 00:19 +0000
          Re: Vertical Text - part 3 Martin Gregorie <martin@address-in-sig.invalid> - 2015-07-04 18:18 +0000
  Re: Vertical Text - part 3 Jeff Higgins <jeff@invalid.invalid> - 2015-07-02 09:09 -0400
    Re: Vertical Text - part 3 e.d.programmer@gmail.com - 2015-07-02 07:24 -0700
      Re: Vertical Text - part 3 Jeff Higgins <jeff@invalid.invalid> - 2015-07-02 10:36 -0400
        Re: Vertical Text - part 3 Martin Gregorie <martin@address-in-sig.invalid> - 2015-07-02 18:38 +0000
          Re: Vertical Text - part 3 e.d.programmer@gmail.com - 2015-07-02 12:54 -0700
            Re: Vertical Text - part 3 Martin Gregorie <martin@address-in-sig.invalid> - 2015-07-02 21:55 +0000
              Re: Vertical Text - part 3 Jeff Higgins <jeff@invalid.invalid> - 2015-07-02 18:46 -0400
                Re: Vertical Text - part 3 Martin Gregorie <martin@address-in-sig.invalid> - 2015-07-03 10:38 +0000
                Re: Vertical Text - part 3 Eternal Hope <laughingspam99@gmail.com> - 2015-07-03 16:44 +0100
          Re: Vertical Text - part 3 Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-07-02 16:21 -0700
            Re: Vertical Text - part 3 Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-07-02 16:43 -0700
      Re: Vertical Text - part 3 Martin Gregorie <martin@address-in-sig.invalid> - 2015-07-02 18:01 +0000
    Re: Vertical Text - part 3 Martin Gregorie <martin@address-in-sig.invalid> - 2015-07-02 17:44 +0000
  Re: Vertical Text - part 3 Jeff Higgins <jeff@invalid.invalid> - 2015-07-03 08:20 -0400
    Re: Vertical Text - part 3 Jeff Higgins <jeff@invalid.invalid> - 2015-07-03 10:01 -0400

csiph-web