Update of /cvsroot/jrobin/src/org/jrobin/graph
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv329/src/org/jrobin/graph
Modified Files:
RrdGraphConstants.java RrdGraphDef.java
Log Message:
rearranged font stuff
Index: RrdGraphConstants.java
===================================================================
RCS file: /cvsroot/jrobin/src/org/jrobin/graph/RrdGraphConstants.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** RrdGraphConstants.java 29 Jul 2007 16:46:36 -0000 1.4
--- RrdGraphConstants.java 31 Jul 2007 21:04:02 -0000 1.5
***************
*** 263,272 ****
* Default graph small font
*/
! Font DEFAULT_SMALL_FONT = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 10);
!
/**
* Default graph large font
*/
! Font DEFAULT_LARGE_FONT = new Font(DEFAULT_FONT_NAME, Font.BOLD, 12);
/**
--- 263,272 ----
* Default graph small font
*/
! String DEFAULT_SMALL_FONT_FILE = "DejaVuSansMono.ttf";
!
/**
* Default graph large font
*/
! String DEFAULT_LARGE_FONT_FILE = "DejaVuSans-Bold.ttf";
/**
Index: RrdGraphDef.java
===================================================================
RCS file: /cvsroot/jrobin/src/org/jrobin/graph/RrdGraphDef.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** RrdGraphDef.java 29 Jul 2007 17:39:21 -0000 1.25
--- RrdGraphDef.java 31 Jul 2007 21:04:02 -0000 1.26
***************
*** 110,115 ****
String title = null; // ok
long step = 0; // ok
! Font smallFont = RrdGraphConstants.DEFAULT_SMALL_FONT; // ok
! Font largeFont = RrdGraphConstants.DEFAULT_LARGE_FONT; // ok
boolean drawXGrid = true; // ok
boolean drawYGrid = true; // ok
--- 110,115 ----
String title = null; // ok
long step = 0; // ok
! Font smallFont;
! Font largeFont;
boolean drawXGrid = true; // ok
boolean drawYGrid = true; // ok
***************
*** 131,150 ****
throw new RuntimeException(e);
}
try {
! InputStream fontStream = ClassLoader.getSystemClassLoader()
! .getResourceAsStream("DejaVuSansMono.ttf");
! smallFont = Font.createFont(Font.TRUETYPE_FONT, fontStream).deriveFont(11).deriveFont(Font.PLAIN);
! fontStream.close();
! fontStream = ClassLoader.getSystemClassLoader()
! .getResourceAsStream("DejaVuSans-Bold.ttf");
! largeFont = Font.createFont(Font.TRUETYPE_FONT, fontStream).deriveFont(12).deriveFont(Font.BOLD);
fontStream.close();
! } catch (Exception ioe) {
! // if we can't load custom fonts, fall back to the normal defaults
! System.err.println("An error occurred loading fonts.");
! ioe.printStackTrace();
}
}
!
/**
* Sets the signature string that runs along the right-side of the graph.
--- 131,161 ----
throw new RuntimeException(e);
}
+ smallFont = this.getSmallFont();
+ largeFont = this.getLargeFont();
+ }
+
+ protected Font getFontFromResourceName(String name) {
+ Font font;
+
try {
! InputStream fontStream = ClassLoader.getSystemClassLoader().getResourceAsStream(name);
! font = Font.createFont(Font.TRUETYPE_FONT, fontStream);
fontStream.close();
! } catch (Exception e) {
! System.err.println("An error occurred loading the font '" + name + "'. Falling back to the default.");
! e.printStackTrace();
! font = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 10);
}
+ return font;
}
!
! protected Font getSmallFont() {
! return this.getFontFromResourceName(RrdGraphConstants.DEFAULT_SMALL_FONT_FILE).deriveFont(Font.PLAIN).deriveFont(10);
! }
!
! protected Font getLargeFont() {
! return this.getFontFromResourceName(RrdGraphConstants.DEFAULT_LARGE_FONT_FILE).deriveFont(Font.BOLD).deriveFont(12);
! }
!
/**
* Sets the signature string that runs along the right-side of the graph.
|