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


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

Vertical Text - part 3

Started byMartin Gregorie <martin@address-in-sig.invalid>
First post2015-07-01 16:54 +0000
Last post2015-07-03 10:01 -0400
Articles 20 on this page of 21 — 5 participants

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


Contents

  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

Page 1 of 2  [1] 2  Next page →


#31908 — Vertical Text - part 3

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2015-07-01 16:54 +0000
SubjectVertical Text - part 3
Message-ID<mn160m$anb$1@dont-email.me>
First off, apologies for starting a new thread. I fat fingered 'Ignore 
thread' in Pan when I was intending to toggle a marker on one of the 
posts in the thread (hay fever is bad today  -at least that's my excuse 
and I'm sticking to it)

Fortunately I managed to find that Jeff's and Knute's last posts were 
still in Pan's cache so I was able to recover their example source and 
try it out. Jeff's last trick (using an AffineTransform to rotate the 
Font so it prints vertically does everything I asked for, so I'll go with 
that: many thanks, Jeff. In fact, because its a modified Font rather than 
an image, it should do one other thing I forgot to mention as well. 

To explain: this is a rostering application with two rows of JLabels 
across the top and down the left side of a matrix. The JLabels along the 
top list people to be rostered while those down the side of the matrix 
list dates. To roster somebody (or cancel a roster assignment) you click 
a name JLabel and a date JLabel in either order. To make this a bit 
easier in case you get interrupted, the JLabels act like illuminated push 
on/push off switches so that when either type of label is clicked its 
background changes colour to show that it is selected. This is cleared 
either by clicking the other type of label to complete the rostering 
action or by a second click on the selected one to cancel its selection. 
Needless to say, rostering a person or cancelling an assignment affects 
the body of the matrix, which is simply a display area showing the 
current state of play.

Anyway, many thanks to all of you who were kind enough to post code. It 
was interesting to see how this sort of task can be tackled and and I've 
learnt quite a bit about uses of the Affine transform.
  

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

[toc] | [next] | [standalone]


#31913

FromJeff Higgins <jeff@invalid.invalid>
Date2015-07-01 18:25 -0400
Message-ID<mn1pfb$rqt$1@dont-email.me>
In reply to#31908
On 07/01/2015 12:54 PM, Martin Gregorie wrote:
> First off, apologies for starting a new thread. I fat fingered 'Ignore
> thread' in Pan when I was intending to toggle a marker on one of the
> posts in the thread (hay fever is bad today  -at least that's my excuse
> and I'm sticking to it)
>
> Fortunately I managed to find that Jeff's and Knute's last posts were
> still in Pan's cache so I was able to recover their example source and
> try it out. Jeff's last trick (using an AffineTransform to rotate the
> Font so it prints vertically does everything I asked for, so I'll go with
> that: many thanks, Jeff. In fact, because its a modified Font rather than
> an image, it should do one other thing I forgot to mention as well.

I'd love to take credit but I didn't post any code using AT.
Perhaps e.d.programmer - who I just dinged for not matching
your requirements. Or FredK.

>
> To explain: this is a rostering application with two rows of JLabels
> across the top and down the left side of a matrix. The JLabels along the
> top list people to be rostered while those down the side of the matrix
> list dates. To roster somebody (or cancel a roster assignment) you click
> a name JLabel and a date JLabel in either order. To make this a bit
> easier in case you get interrupted, the JLabels act like illuminated push
> on/push off switches so that when either type of label is clicked its
> background changes colour to show that it is selected. This is cleared
> either by clicking the other type of label to complete the rostering
> action or by a second click on the selected one to cancel its selection.
> Needless to say, rostering a person or cancelling an assignment affects
> the body of the matrix, which is simply a display area showing the
> current state of play.
>
> Anyway, many thanks to all of you who were kind enough to post code. It
> was interesting to see how this sort of task can be tackled and and I've
> learnt quite a bit about uses of the Affine transform.
>
>

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


#31914

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2015-07-01 23:09 +0000
Message-ID<mn1s02$2kl$1@dont-email.me>
In reply to#31913
On Wed, 01 Jul 2015 18:25:12 -0400, Jeff Higgins wrote:

> I'd love to take credit but I didn't post any code using AT.
> Perhaps e.d.programmer - who I just dinged for not matching your
> requirements. Or FredK.
>
I'm referring to the example that used an AT to rotate a Font and then 
derive an modified Font from that.

I apologise to the actual author if I mis-attributed it and would like to 
know who this was because I have a question or two...



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

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


#31915

FromJeff Higgins <jeff@invalid.invalid>
Date2015-07-01 19:44 -0400
Message-ID<mn1u4i$a63$1@dont-email.me>
In reply to#31914
On 07/01/2015 07:09 PM, Martin Gregorie wrote:
> On Wed, 01 Jul 2015 18:25:12 -0400, Jeff Higgins wrote:
>
>> I'd love to take credit but I didn't post any code using AT.
>> Perhaps e.d.programmer - who I just dinged for not matching your
>> requirements. Or FredK.
>>
> I'm referring to the example that used an AT to rotate a Font and then
> derive an modified Font from that.

That would be e.d.programmer's example.
>
> I apologise to the actual author if I mis-attributed it and would like to
> know who this was because I have a question or two...
>

Message-ID: <31e57656-27e3-46a4-abbd-a793c463adba@googlegroups.com>
From: e.d.programmer@gmail.com

Message-ID: <028164e2-9cba-4ba3-ad34-0cf46ae7210b@googlegroups.com>
From: FredK <fred.l.kleinschmidt@gmail.com>

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


#31916

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2015-07-02 00:19 +0000
Message-ID<mn2030$bpm$1@dont-email.me>
In reply to#31915
On Wed, 01 Jul 2015 19:44:46 -0400, Jeff Higgins wrote:

> Message-ID: <31e57656-27e3-46a4-abbd-a793c463adba@googlegroups.com>
> From: e.d.programmer@gmail.com
> 
> Message-ID: <028164e2-9cba-4ba3-ad34-0cf46ae7210b@googlegroups.com>
> From: FredK <fred.l.kleinschmidt@gmail.com>
>
Those don't work at all: not true URIs. Annoyingly, the first one gets 
expanded to  /home/myuser/31e57656-27e3-46a4-abbd-
a793c463adba@googlegroups.com
and is reported as such in the resulting error message, but diving in to 
googlegroups from the top found the thread easily enough and you're 
right: it was e.d.programmer's second example that pressed all the right 
buttons. 

Its late, so I'll scratch my head over a clean method of incorporating it 
into an existing subclass of JLabel tomorrow. Currently I'm considering 
making it into a Font creation class so I can hand its output to the 
JLabel subclass instances via setFont().


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

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


#31952

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2015-07-04 18:18 +0000
Message-ID<mn9828$i1q$1@dont-email.me>
In reply to#31916
On Thu, 02 Jul 2015 00:19:44 +0000, Martin Gregorie wrote:

> On Wed, 01 Jul 2015 19:44:46 -0400, Jeff Higgins wrote:
> 
>> Message-ID: <31e57656-27e3-46a4-abbd-a793c463adba@googlegroups.com>
>> From: e.d.programmer@gmail.com
>> 
>> Message-ID: <028164e2-9cba-4ba3-ad34-0cf46ae7210b@googlegroups.com>
>> From: FredK <fred.l.kleinschmidt@gmail.com>
>>
> Those don't work at all: not true URIs. Annoyingly, the first one gets
> expanded to  /home/myuser/31e57656-27e3-46a4-abbd-
> a793c463adba@googlegroups.com and is reported as such in the resulting
> error message, but diving in to googlegroups from the top found the
> thread easily enough and you're right: it was e.d.programmer's second
> example that pressed all the right buttons.
> 
> Its late, so I'll scratch my head over a clean method of incorporating
> it into an existing subclass of JLabel tomorrow. Currently I'm
> considering making it into a Font creation class so I can hand its
> output to the JLabel subclass instances via setFont().

Following up: I already had a standard font I was using for this screen 
(monospaced, plain, 60pt) so I derived a font from it by applying 
e.d.programmer's Affine transform. The NameButton, which is the class 
that displays vertically formatted names was modified by removing the 
HTML formatting method, using the derived font in place of the standard 
font, and changing the vertical alignment from BOTTOM to TOP (otherwise 
the vertical font put all the text off the bottom of the display area. 
Everything is now working as before but now the row of names is only 60% 
of the height it previously occupied and is at least as readable as 
before. 

In case anybody is interested, the code to create the derived font is:

Font base = new Font(Font.MONOSPACED, Font.PLAIN, REFont.FONTSIZE);
AffineTransform a = new AffineTransform();
a.rotate(Math.PI / 2.0);
Font f = base.deriveFont(a);

where REFont.FONTSIZE us defined as:

public static int FONTSIZE = 10;


In case you want to see the effect of making this change, the original 
HTML-verticalised screenshot is here: 

http://www.gregorie.org/temp/Screenshot%20-%20020715.jpg

and the new, improved screenshot is here:

http://www.gregorie.org/temp/Screenshot%20-%20040715.png
 
This time round the screenshot shows how the screen looks on start-up 
because I didn't bother to light up all the pretty colours in the matrix, 
but they all work exactly as before and so does the click on/click off 
background colouring behind the names.

Thanks again to all who helped with example code and suggestions: the end 
result is exactly what I hoped for and, as a bonus, I've learnt another 
way to modify fonts.


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

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


#31920

FromJeff Higgins <jeff@invalid.invalid>
Date2015-07-02 09:09 -0400
Message-ID<mn3d9d$qha$1@dont-email.me>
In reply to#31908
On 07/01/2015 12:54 PM, Martin Gregorie wrote:
> First off, apologies for starting a new thread. I fat fingered 'Ignore
> thread' in Pan when I was intending to toggle a marker on one of the
> posts in the thread (hay fever is bad today  -at least that's my excuse
> and I'm sticking to it)
>
> Fortunately I managed to find that Jeff's and Knute's last posts were
> still in Pan's cache so I was able to recover their example source and
> try it out. Jeff's last trick (using an AffineTransform to rotate the
> Font so it prints vertically does everything I asked for, so I'll go with
> that: many thanks, Jeff. In fact, because its a modified Font rather than
> an image, it should do one other thing I forgot to mention as well.
>
> To explain: this is a rostering application with two rows of JLabels
> across the top and down the left side of a matrix. The JLabels along the
> top list people to be rostered while those down the side of the matrix
> list dates. To roster somebody (or cancel a roster assignment) you click
> a name JLabel and a date JLabel in either order. To make this a bit
> easier in case you get interrupted, the JLabels act like illuminated push
> on/push off switches so that when either type of label is clicked its
> background changes colour to show that it is selected. This is cleared
> either by clicking the other type of label to complete the rostering
> action or by a second click on the selected one to cancel its selection.
> Needless to say, rostering a person or cancelling an assignment affects
> the body of the matrix, which is simply a display area showing the
> current state of play.
>
> Anyway, many thanks to all of you who were kind enough to post code. It
> was interesting to see how this sort of task can be tackled and and I've
> learnt quite a bit about uses of the Affine transform.
>
>
Darryl Burke's Vertical Table Header Cell Renderer
<https://tips4java.wordpress.com/2009/03/06/vertical-table-header-cell-renderer/>
Note the text isn't as you requested in your OP:
V
e
r
t
i
c
a
l

T
e
x
t

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


#31921

Frome.d.programmer@gmail.com
Date2015-07-02 07:24 -0700
Message-ID<1980b894-6ca3-48f5-b70a-1628c56185e1@googlegroups.com>
In reply to#31920
On Thursday, July 2, 2015 at 9:12:44 AM UTC-4, Jeff Higgins wrote:
> On 07/01/2015 12:54 PM, Martin Gregorie wrote:
> > First off, apologies for starting a new thread. I fat fingered 'Ignore
> > thread' in Pan when I was intending to toggle a marker on one of the
> > posts in the thread (hay fever is bad today  -at least that's my excuse
> > and I'm sticking to it)
> >
> > Fortunately I managed to find that Jeff's and Knute's last posts were
> > still in Pan's cache so I was able to recover their example source and
> > try it out. Jeff's last trick (using an AffineTransform to rotate the
> > Font so it prints vertically does everything I asked for, so I'll go with
> > that: many thanks, Jeff. In fact, because its a modified Font rather than
> > an image, it should do one other thing I forgot to mention as well.
> >
> > To explain: this is a rostering application with two rows of JLabels
> > across the top and down the left side of a matrix. The JLabels along the
> > top list people to be rostered while those down the side of the matrix
> > list dates. To roster somebody (or cancel a roster assignment) you click
> > a name JLabel and a date JLabel in either order. To make this a bit
> > easier in case you get interrupted, the JLabels act like illuminated push
> > on/push off switches so that when either type of label is clicked its
> > background changes colour to show that it is selected. This is cleared
> > either by clicking the other type of label to complete the rostering
> > action or by a second click on the selected one to cancel its selection.
> > Needless to say, rostering a person or cancelling an assignment affects
> > the body of the matrix, which is simply a display area showing the
> > current state of play.
> >
> > Anyway, many thanks to all of you who were kind enough to post code. It
> > was interesting to see how this sort of task can be tackled and and I've
> > learnt quite a bit about uses of the Affine transform.
> >
> >
> Darryl Burke's Vertical Table Header Cell Renderer
> <https://tips4java.wordpress.com/2009/03/06/vertical-table-header-cell-renderer/>
> Note the text isn't as you requested in your OP:
> V
> e
> r
> t
> i
> c
> a
> l
> 
> T
> e
> x
> t

Do you have the source for that?  I click the link for the .java and my web filter blocks it as spyware.

If you want the characters upright going down like that they don't line up unless the font is fixed width.  I think it looks better if you center them.

     public void drawTextDown(final Graphics2D g2, final String s) {
          final Font theFont = g2.getFont();
          final FontMetrics fm = g2.getFontMetrics(theFont);
          for (int j = 0; j < s.length(); j++) {
               String ch = s.substring(j, j + 1);
               g2.drawString(ch, (int) (fm.getMaxAdvance() / 2 + ((fm.getMaxCharBounds(g2).getWidth() - fm.getStringBounds(ch, g2).getWidth()) / 2)), fm.getAscent() + (j * fm.getHeight()));
          }
     }

If you want the sideways text which may be hard for some to read but is easier to fit more, try this.

     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.

To make text more readable you could try displaying it on an angle.
fontAT.rotate(-Math.PI / 4.0);

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...

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


#31922

FromJeff Higgins <jeff@invalid.invalid>
Date2015-07-02 10:36 -0400
Message-ID<mn3ic8$eq3$1@dont-email.me>
In reply to#31921
On 07/02/2015 10:24 AM, e.d.programmer@gmail.com wrote:

> Do you have the source for that?  I click the link for the .java and my web filter blocks it as spyware.
Huh? It's just a Java source file as far as I can tell.

Anyway, after rereading Martin's post I see he
doesn't have a JTable so the pointer is pointless.

Another source for the source.
<https://java.net/projects/snat/sources/reposit/show/src/table?rev=69>

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


#31925

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2015-07-02 18:38 +0000
Message-ID<mn40en$ogv$3@dont-email.me>
In reply to#31922
On Thu, 02 Jul 2015 10:36:19 -0400, Jeff Higgins wrote:

> Anyway, after rereading Martin's post I see he doesn't have a JTable so
> the pointer is pointless.
>
Yep: using a JTable was the first idea I thought of, but the screen 
layout doesn't match the JTable convention of a single header line 
followed by a set of identical data rows.

Just so you know what I've been trying to describe, there's a screen shot 
of the rostering tool displaying some test data (only three instructors 
plus the special [NA] 'name') and four days) at: 

http://www.gregorie.org/temp/Screenshot%20-%20020715.jpg

I've sliced out some blank screen area between the matrix and the error 
message and also a chunk on the right of the matrix - that's to make 
image a bit easier to read. This version is using Knute's HTML trick to 
display the list of instructor names above the matrix: you can see how 
tall even quite a small name becomes.

The error message and associated red matrix cell describes why Barney 
RUBBLE can't be rostered on the 12th of April: the blue and green cells 
show successful duty allocations and the black one is an unrosterable day 
(also shown by all the duty slots being marked [NA]).

In real life this screen would be showing 25 instructors and 57 rosterable 
days, i.e. the matrix would be 26 x 57 rather than 4 x 4 you're seeing. 


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

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


#31929

Frome.d.programmer@gmail.com
Date2015-07-02 12:54 -0700
Message-ID<ebc01b74-ef2b-49be-bff1-746035119740@googlegroups.com>
In reply to#31925
On Thursday, July 2, 2015 at 2:39:52 PM UTC-4, Martin Gregorie wrote:
> On Thu, 02 Jul 2015 10:36:19 -0400, Jeff Higgins wrote:
> 
> > Anyway, after rereading Martin's post I see he doesn't have a JTable so
> > the pointer is pointless.
> >
> Yep: using a JTable was the first idea I thought of, but the screen 
> layout doesn't match the JTable convention of a single header line 
> followed by a set of identical data rows.
> 
> Just so you know what I've been trying to describe, there's a screen shot 
> of the rostering tool displaying some test data (only three instructors 
> plus the special [NA] 'name') and four days) at: 
> 
> http://www.gregorie.org/temp/Screenshot%20-%20020715.jpg
> 
> I've sliced out some blank screen area between the matrix and the error 
> message and also a chunk on the right of the matrix - that's to make 
> image a bit easier to read. This version is using Knute's HTML trick to 
> display the list of instructor names above the matrix: you can see how 
> tall even quite a small name becomes.
> 
> The error message and associated red matrix cell describes why Barney 
> RUBBLE can't be rostered on the 12th of April: the blue and green cells 
> show successful duty allocations and the black one is an unrosterable day 
> (also shown by all the duty slots being marked [NA]).
> 
> In real life this screen would be showing 25 instructors and 57 rosterable 
> days, i.e. the matrix would be 26 x 57 rather than 4 x 4 you're seeing. 
> 
> 
> -- 
> martin@   | Martin Gregorie
> gregorie. | Essex, UK
> org       |

That screenshot is confusing.  Are you attempting to render everything on that window in a single JTable?  It looks like several linked tables.

You can literally make a JTable do anything if you extend the classes to make your own renderers and/or UIs.  I did.

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


#31931

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2015-07-02 21:55 +0000
Message-ID<mn4c18$du3$1@dont-email.me>
In reply to#31929
On Thu, 02 Jul 2015 12:54:41 -0700, e.d.programmer wrote:

> That screenshot is confusing.  Are you attempting to render everything
> on that window in a single JTable?  It looks like several linked tables.
>
No JTables are used at all. Its quite a different structure, based on 
se.datadosen.component.ControlPanel instances which are laid out using 
the se.dosen.component.RiverLayout layout manager and switched with the 
Roles menu, which is dynamically built when the program starts up and 
reads its configuration.

For starters, there are one or more rosters, each on a different 
ControlPanel instance, managed and switched with the CardLayout layout 
manager and an ArrayList of ControlPanel instances. Each ControlPanel 
instance is laid out with rows of display classes which have a 1:N 
relationship with the data classes in the Model - 1:N because some data 
classes (e.g. the ones above the row of names, display different aspects 
of the same underlying class. And its normal for each named person to 
take part in more than one roster, so their N associated display classes 
appear on more than one 'card' as well.

User actions (allocate/deallocate/swap duties) are applied directly to 
the the class instances in Model as you'd expect. Each 'card' has a list 
of all the display classes on the card, so refreshing the display merely 
involves walking the list and calling the refresh() method of each 
display class instance in the list, which causes it to retrieve its 
displayed value from the Model. If you think that makes the Model sound 
like an in-memory database plus database procedures you'd be right and, 
yes, I did draw an Entity Relationship Diagram (ERD) as the first step in 
designing this tool. The data structure and its internal relationships 
are surprisingly complex and would have been quite difficult to get right 
without drawing a ERD in 3rd normal form.
    

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

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


#31932

FromJeff Higgins <jeff@invalid.invalid>
Date2015-07-02 18:46 -0400
Message-ID<mn4f45$4eb$1@dont-email.me>
In reply to#31931
On 07/02/2015 05:55 PM, Martin Gregorie wrote:

> No JTables are used at all. Its quite a different structure, based on
> se.datadosen.component.ControlPanel instances which are laid out using
> the se.dosen.component.RiverLayout layout manager

Interesting layout manager. Thanks for the tip.

I type the term "roster" into Google and he provides me a link to
"Images for roster" and "More images for roster"
Wow, a real GUI Smörgåsbord!

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


#31938

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2015-07-03 10:38 +0000
Message-ID<mn5on7$vj8$1@dont-email.me>
In reply to#31932
On Thu, 02 Jul 2015 18:46:55 -0400, Jeff Higgins wrote:

> On 07/02/2015 05:55 PM, Martin Gregorie wrote:
> 
>> No JTables are used at all. Its quite a different structure, based on
>> se.datadosen.component.ControlPanel instances which are laid out using
>> the se.dosen.component.RiverLayout layout manager
> 
> Interesting layout manager. Thanks for the tip.
> 
> I type the term "roster" into Google and he provides me a link to
> "Images for roster" and "More images for roster"
> Wow, a real GUI Smörgåsbord!

I think the term 'roster' has been somewhat hijacked. I only know it as 
meaning a list of people scheduled to do a task.



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

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


#31941

FromEternal Hope <laughingspam99@gmail.com>
Date2015-07-03 16:44 +0100
Message-ID<mn6ah7$g06$1@dont-email.me>
In reply to#31938
On 03/07/2015 11:38, Martin Gregorie wrote:
> On Thu, 02 Jul 2015 18:46:55 -0400, Jeff Higgins wrote:
>
>> On 07/02/2015 05:55 PM, Martin Gregorie wrote:
>>
>>> No JTables are used at all. Its quite a different structure, based on
>>> se.datadosen.component.ControlPanel instances which are laid out using
>>> the se.dosen.component.RiverLayout layout manager
>>
>> Interesting layout manager. Thanks for the tip.
>>
>> I type the term "roster" into Google and he provides me a link to
>> "Images for roster" and "More images for roster"
>> Wow, a real GUI Smörgåsbord!
>
> I think the term 'roster' has been somewhat hijacked. I only know it as
> meaning a list of people scheduled to do a task.
>

A raster is a grid of x and y coordinates on a display space.

A roster is a list or plan showing turns of duty or leave for 
individuals or groups in an organization.

A rasta is a dude who smokes way too much weed and worships
Haile Selassie I, (former) emperor of Ethiopia

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


#31933

FromKnute Johnson <nospam@rabbitbrush.frazmtn.com>
Date2015-07-02 16:21 -0700
Message-ID<mn4h04$a17$1@dont-email.me>
In reply to#31925
On 7/2/2015 11:38, Martin Gregorie wrote:
> On Thu, 02 Jul 2015 10:36:19 -0400, Jeff Higgins wrote:
>
>> Anyway, after rereading Martin's post I see he doesn't have a JTable so
>> the pointer is pointless.
>>
> Yep: using a JTable was the first idea I thought of, but the screen
> layout doesn't match the JTable convention of a single header line
> followed by a set of identical data rows.
>
> Just so you know what I've been trying to describe, there's a screen shot
> of the rostering tool displaying some test data (only three instructors
> plus the special [NA] 'name') and four days) at:
>
> http://www.gregorie.org/temp/Screenshot%20-%20020715.jpg
>
> I've sliced out some blank screen area between the matrix and the error
> message and also a chunk on the right of the matrix - that's to make
> image a bit easier to read. This version is using Knute's HTML trick to
> display the list of instructor names above the matrix: you can see how
> tall even quite a small name becomes.
>
> The error message and associated red matrix cell describes why Barney
> RUBBLE can't be rostered on the 12th of April: the blue and green cells
> show successful duty allocations and the black one is an unrosterable day
> (also shown by all the duty slots being marked [NA]).
>
> In real life this screen would be showing 25 instructors and 57 rosterable
> days, i.e. the matrix would be 26 x 57 rather than 4 x 4 you're seeing.
>
>

If only Swing supported the line-height style!


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

public class test4 extends JPanel {
     String[] names = { "Charlie HORSE", "Martin GREGORIE", "Barney RUBBLE",
      "[NA]" };

     public test4() {
         super(new GridBagLayout());

         GridBagConstraints c = new GridBagConstraints();
         c.gridy = 0;

         for (String name : names) {
             VerticalText vt = new VerticalText(name,20,300);
             add(vt,c);
         }
     }

     class VerticalText extends JComponent {
         private final String message;
         private final int width;
         private final int height;

         public VerticalText(String message, int width, int height) {
             this.message = message.replaceAll("[\\[\\]]","");
             this.width = width;
             this.height = height;

             setFont(new Font("Monospaced",Font.BOLD,16));
             setPreferredSize(new Dimension(width,height));
         }

         public void paintComponent(Graphics g2d) {
             Graphics2D g = (Graphics2D)g2d;
             g.setColor(Color.LIGHT_GRAY);
             g.fillRect(0,0,getWidth(),getHeight());
             g.setColor(Color.BLACK);
             g.drawRect(0,0,getWidth()-1,getHeight()-1);
             String str = new StringBuilder(message).reverse().toString();
             char[] chars = str.toCharArray();
             FontMetrics metrics = g.getFontMetrics();
             double charHeight = metrics.getHeight();
             g.translate(
              (getWidth() - metrics.charWidth(' '))/2.0,
              getHeight()-5);
             for (int i=0; i<chars.length; i++) {
                 g.drawChars(chars,i,1,0,0);
                 g.translate(0,-charHeight+10);
             }
         }
     }

     public static void main(String... args) {
         EventQueue.invokeLater(() -> {
             JFrame f = new JFrame();
             f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
             f.add(new test4(),BorderLayout.CENTER);
             f.pack();
             f.setVisible(true);
         });
     }
}

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


#31935

FromKnute Johnson <nospam@rabbitbrush.frazmtn.com>
Date2015-07-02 16:43 -0700
Message-ID<mn4i8b$dee$1@dont-email.me>
In reply to#31933
On 7/2/2015 16:32, Stefan Ram wrote:
> Knute Johnson <nospam@rabbitbrush.frazmtn.com> writes:
>> g.translate(0,-charHeight+10);
>
>    Today, I asked an old lady, and she told me that /her/
>    grandmother still used javax.swing when she was young.
>    Good old Swing!
>
> public class Main extends javafx.application.Application
> { @java.lang.Override
>    public void start( final javafx.stage.Stage primaryStage)
>    { final javafx.scene.control.Label text
>      = new javafx.scene.control.Label( "text" );
>      text.setRotate( 90 );
>      primaryStage.setScene( new javafx.scene.Scene( text ));
>      primaryStage.show(); }}
>
>    Disclaimer: I wanted the source code to be simplistic,
>    so it is possible that one has to manually adjust the
>    window to actually see the rotated label.
>

I thought he didn't want it rotated?  I thought he just wanted the text 
spaced closer together.

Us dinos still use Swing, what can I say?  I've got a lot of synapses 
invested in it.

knute...

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


#31924

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2015-07-02 18:01 +0000
Message-ID<mn3u99$ogv$2@dont-email.me>
In reply to#31921
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       |

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


#31923

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2015-07-02 17:44 +0000
Message-ID<mn3tab$ogv$1@dont-email.me>
In reply to#31920
On Thu, 02 Jul 2015 09:09:27 -0400, Jeff Higgins wrote:

> Darryl Burke's Vertical Table Header Cell Renderer
> <https://tips4java.wordpress.com/2009/03/06/vertical-table-header-cell-
renderer/>
> Note the text isn't as you requested in your OP:
> V
> e
> r
> t
> i
> c
> a
> l
> 
> T
> e
> x
> t
That looks very much like what I was seeing with Knute's HTML trick. It 
thought it looked OK with most names: they are passed to the rostering 
tool as 'Forename SURNAME', but with the letters all upright and the 
fairly wide newline gap added by <br> I'd always thought that the much 
shorter name that rotating normal text through 90 degrees clockwise would 
make the complete screen a bit easier to use. The trigger point was that 
I need to mark any half-days that must not be rostered by putting the 
special name [NA] in them and this looks terrible when rendered as:

 [
 N
 A
 ]


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

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


#31939

FromJeff Higgins <jeff@invalid.invalid>
Date2015-07-03 08:20 -0400
Message-ID<mn5upb$pg5$1@dont-email.me>
In reply to#31908
On 07/01/2015 12:54 PM, Martin Gregorie wrote:
> First off, apologies for starting a new thread.

Not a problem for me.

Just a memento for me.
A wonderfully complex set of topics.

JEP 258: HarfBuzz Font-Layout Engine
<http://openjdk.java.net/jeps/258>

State of Text Rendering
<http://behdad.org/text/>

The Raster Tragedy at Low-Resolution Revisited:
<http://www.rastertragedy.com/>



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


Page 1 of 2  [1] 2  Next page →

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


csiph-web