Update of /cvsroot/rails/18xx/rails/ui/swing
In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv28308/rails/ui/swing
Modified Files:
GUIToken.java
Log Message:
Addes larger token font for short names (1 or 2 chars)
Index: GUIToken.java
===================================================================
RCS file: /cvsroot/rails/18xx/rails/ui/swing/GUIToken.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** GUIToken.java 4 Jun 2008 19:00:32 -0000 1.7
--- GUIToken.java 13 Dec 2009 21:13:39 -0000 1.8
***************
*** 21,26 ****
public static final int DEFAULT_Y_COORD = 1;
! private static Font smallTokenFont = new Font("Helvetica", Font.BOLD, 8);
! private static Font tokenFont = new Font("Helvetica", Font.BOLD, 10);
public void paintComponent(Graphics g) {
--- 21,27 ----
public static final int DEFAULT_Y_COORD = 1;
! private static final Font smallTokenFont = new Font("Helvetica", Font.BOLD, 8);
! private static final Font tokenFont = new Font("Helvetica", Font.BOLD, 10);
! private static final Font largeTokenFont = new Font("Helvetica", Font.BOLD, 12);
public void paintComponent(Graphics g) {
***************
*** 42,51 ****
g2d.fill(circle);
! Font font = name.length() > 3 ? smallTokenFont : tokenFont;
g2d.setFont(new Font("Helvetica", Font.BOLD,
(int) (font.getSize() * tokenScale)));
g2d.setColor(fgColor);
// g2d.drawString(name, 3, 14);
! g2d.drawString(name, (int) (circle.x + 2 * tokenScale),
(int) (circle.y + 14 * tokenScale));
--- 43,52 ----
g2d.fill(circle);
! Font font = getTokenFont(name.length());
g2d.setFont(new Font("Helvetica", Font.BOLD,
(int) (font.getSize() * tokenScale)));
g2d.setColor(fgColor);
// g2d.drawString(name, 3, 14);
! g2d.drawString(name, (int) (circle.x + (12 - 3*name.length()) * tokenScale),
(int) (circle.y + 14 * tokenScale));
***************
*** 107,109 ****
--- 108,119 ----
}
+ public static Font getTokenFont (int size) {
+ if (size <= 2) {
+ return largeTokenFont;
+ } else if (size <= 4) {
+ return tokenFont;
+ } else {
+ return smallTokenFont;
+ }
+ }
}
|