From: Benjamin R. <ran...@us...> - 2007-07-29 16:46:39
|
Update of /cvsroot/jrobin/src/org/jrobin/graph In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv12417/src/org/jrobin/graph Modified Files: RrdGraph.java RrdGraphConstants.java RrdGraphDef.java Log Message: add the ability to change the signature Index: RrdGraphConstants.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/RrdGraphConstants.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RrdGraphConstants.java 29 Jul 2007 04:19:29 -0000 1.3 --- RrdGraphConstants.java 29 Jul 2007 16:46:36 -0000 1.4 *************** *** 259,266 **** --- 259,268 ---- String DEFAULT_FONT_NAME = System.getProperty("os.name").toLowerCase().contains("windows") ? "Lucida Sans Typewriter" : "Monospaced"; + /** * Default graph small font */ Font DEFAULT_SMALL_FONT = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 10); + /** * Default graph large font Index: RrdGraphDef.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/RrdGraphDef.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** RrdGraphDef.java 29 Jul 2007 04:19:29 -0000 1.23 --- RrdGraphDef.java 29 Jul 2007 16:46:36 -0000 1.24 *************** *** 86,89 **** --- 86,90 ---- String overlayImage = null; // ok String unit = null; // ok + String signature = "Created with JRobin"; // ok boolean lazy = false; // ok double minValue = Double.NaN; // ok *************** *** 133,147 **** InputStream fontStream = ClassLoader.getSystemClassLoader() .getResourceAsStream("DejaVuSansMono.ttf"); ! smallFont = Font.createFont(Font.TRUETYPE_FONT, fontStream); fontStream.close(); fontStream = ClassLoader.getSystemClassLoader() .getResourceAsStream("DejaVuSans-Bold.ttf"); ! largeFont = Font.createFont(Font.TRUETYPE_FONT, fontStream); fontStream.close(); } catch (Exception ioe) { // if we can't load custom fonts, fall back to the normal defaults } } /** --- 134,169 ---- InputStream fontStream = ClassLoader.getSystemClassLoader() .getResourceAsStream("DejaVuSansMono.ttf"); ! smallFont = Font.createFont(Font.TRUETYPE_FONT, fontStream).deriveFont(11).deriveFont(Font.PLAIN); ! System.err.println("Created font " + smallFont.toString()); fontStream.close(); fontStream = ClassLoader.getSystemClassLoader() .getResourceAsStream("DejaVuSans-Bold.ttf"); ! largeFont = Font.createFont(Font.TRUETYPE_FONT, fontStream).deriveFont(12).deriveFont(Font.BOLD); ! System.err.println("Created font " + largeFont.toString()); 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. + * Defaults to "Created with JRobin". + * + * @param signature the string to print + */ + public void setSignature(String signature) { + this.signature = signature; + } + + /** + * Gets the signature string that runs along the right-side of the graph. + * @return the signature string + */ + public String getSignature() { + return this.signature; + } /** Index: RrdGraph.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/graph/RrdGraph.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** RrdGraph.java 21 Dec 2006 18:02:44 -0000 1.12 --- RrdGraph.java 29 Jul 2007 16:46:36 -0000 1.13 *************** *** 32,35 **** --- 32,36 ---- import java.awt.*; import java.io.IOException; + import java.io.InputStream; /** *************** *** 43,46 **** --- 44,48 ---- Mapper mapper; RrdGraphInfo info = new RrdGraphInfo(); + private String signature; /** *************** *** 53,56 **** --- 55,59 ---- public RrdGraph(RrdGraphDef gdef) throws IOException, RrdException { this.gdef = gdef; + signature = gdef.getSignature(); worker = new ImageWorker(100, 100); // Dummy worker, just to start with something try { *************** *** 136,144 **** private void gator() { if (!gdef.onlyGraph && gdef.showSignature) { ! Font font = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 9); int x = (int) (im.xgif - 2 - worker.getFontAscent(font)); int y = 4; worker.transform(x, y, Math.PI / 2); ! worker.drawString("Created with JRobin", 0, 0, font, Color.LIGHT_GRAY); worker.reset(); } --- 139,155 ---- private void gator() { if (!gdef.onlyGraph && gdef.showSignature) { ! Font font; ! try { ! InputStream fontStream = ClassLoader.getSystemClassLoader().getResourceAsStream("DejaVuSansMono.ttf"); ! font = Font.createFont(Font.TRUETYPE_FONT, fontStream).deriveFont(9).deriveFont(Font.PLAIN); ! fontStream.close(); ! } catch (Exception e) { ! // fall back to the default font ! font = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 9); ! } int x = (int) (im.xgif - 2 - worker.getFontAscent(font)); int y = 4; worker.transform(x, y, Math.PI / 2); ! worker.drawString(signature, 0, 0, font, Color.LIGHT_GRAY); worker.reset(); } |