Console: Move JRobin default color and font changes into SummaryRenderer

This ensures these changes are applied to Debian installs, where we get JRobin
from the package manager instead of our bundled source.

The padding and grid stroke changes to RrdGraphConstants have not been reverted,
because there is no API provided to alter those values. This will result in a
minor difference between Debian and non-Debian graphs, and if a user shares
those graphs, it will reveal the fact that they have installed the Debian
package. This is acceptable, given that the graphs themselves inherently reveal
significantly more private information than that.
This commit is contained in:
str4d
2017-07-25 10:13:36 +00:00
parent 70393fd2d9
commit b8f5c956e6
4 changed files with 26 additions and 9 deletions

View File

@ -161,12 +161,12 @@ public interface RrdGraphConstants {
/**
* Default minor grid color
*/
Color DEFAULT_GRID_COLOR = new Color(100, 100, 100, 75);
Color DEFAULT_GRID_COLOR = new Color(171, 171, 171, 95);
// Color DEFAULT_GRID_COLOR = new Color(140, 140, 140);
/**
* Default major grid color
*/
Color DEFAULT_MGRID_COLOR = new Color(255, 91, 91, 110);
Color DEFAULT_MGRID_COLOR = new Color(255, 91, 91, 95);
// Color DEFAULT_MGRID_COLOR = new Color(130, 30, 30);
/**
* Default font color
@ -251,7 +251,7 @@ public interface RrdGraphConstants {
* Default font name, determined based on the current operating system
*/
String DEFAULT_FONT_NAME = System.getProperty("os.name").toLowerCase().contains("windows") ?
"Lucida Console" : "Monospaced";
"Lucida Sans Typewriter" : "Monospaced";
/**
* Default graph small font

View File

@ -132,11 +132,11 @@ public class RrdGraphDef implements RrdGraphConstants {
fontDir = new File(fontdirProperty);
}
fonts[FONTTAG_DEFAULT] = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 10);
fonts[FONTTAG_TITLE] = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 10);
fonts[FONTTAG_AXIS] = new Font("Droid Sans Mono", Font.PLAIN, 10);
fonts[FONTTAG_UNIT] = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 10);
fonts[FONTTAG_LEGEND] = new Font("Droid Sans Mono", Font.PLAIN, 10);
fonts[FONTTAG_DEFAULT] = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 8);
fonts[FONTTAG_TITLE] = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 9);
fonts[FONTTAG_AXIS] = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 7);
fonts[FONTTAG_UNIT] = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 8);
fonts[FONTTAG_LEGEND] = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 8);
fonts[FONTTAG_WATERMARK] = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 1).deriveFont(5.5F);
}
@ -173,7 +173,7 @@ public class RrdGraphDef implements RrdGraphConstants {
if (exception != null) {
System.err.println(exception.getLocalizedMessage());
}
font = new Font("Monospaced", Font.PLAIN, 10);
font = new Font(DEFAULT_FONT_NAME, Font.PLAIN, 10);
}
if (font == null) {

View File

@ -35,9 +35,13 @@ class SummaryRenderer {
private final Log _log;
private final SummaryListener _listener;
private final I2PAppContext _context;
private static final Color GRID_COLOR = new Color(100, 100, 100, 75);
private static final Color MGRID_COLOR = new Color(255, 91, 91, 110);
private static final Color AREA_COLOR = new Color(100, 160, 200, 200);
private static final Color LINE_COLOR = new Color(0, 30, 110, 255);
private static final Color RESTART_BAR_COLOR = new Color(223, 13, 13, 255);
private static final String DEFAULT_FONT_NAME = System.getProperty("os.name").toLowerCase().contains("windows") ?
"Lucida Console" : "Monospaced";
public SummaryRenderer(I2PAppContext ctx, SummaryListener lsnr) {
_log = ctx.logManager().getLog(SummaryRenderer.class);
@ -125,6 +129,16 @@ class SummaryRenderer {
ImageOutputStream ios = null;
try {
RrdGraphDef def = new RrdGraphDef();
// Override defaults
def.setColor(RrdGraphDef.COLOR_GRID, GRID_COLOR);
def.setColor(RrdGraphDef.COLOR_MGRID, MGRID_COLOR);
def.setFont(RrdGraphDef.FONTTAG_DEFAULT, new Font(DEFAULT_FONT_NAME, Font.PLAIN, 10));
def.setFont(RrdGraphDef.FONTTAG_TITLE, new Font(DEFAULT_FONT_NAME, Font.PLAIN, 10));
def.setFont(RrdGraphDef.FONTTAG_AXIS, new Font("Droid Sans Mono", Font.PLAIN, 10));
def.setFont(RrdGraphDef.FONTTAG_UNIT, new Font(DEFAULT_FONT_NAME, Font.PLAIN, 10));
def.setFont(RrdGraphDef.FONTTAG_LEGEND, new Font("Droid Sans Mono", Font.PLAIN, 10));
// improve text legibility
String lang = Messages.getLanguage(_context);
Font small = def.getSmallFont();

View File

@ -1,3 +1,6 @@
2017-07-25 str4d
* Console: Move JRobin default color and font changes into SummaryRenderer
2017-07-15 zzz
* Console: Fix compile error with Jetty 9.2.22 (ticket #2019)