forked from I2P_Developers/i2p.i2p
Graphs: Clean up font setting, fix bugs (ticket #2684)
Unit font now monospaced on Linux and Mac as intended Don't set Droid Sans font, not present in any platform by default Fix font scaling for Japanese Detect more RTL languages Make fonts configurable
This commit is contained in:
@ -46,8 +46,17 @@ class SummaryRenderer {
|
|||||||
private static final Color AREA_COLOR = new Color(100, 160, 200, 200);
|
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 LINE_COLOR = new Color(0, 30, 110, 255);
|
||||||
private static final Color RESTART_BAR_COLOR = new Color(223, 13, 13, 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") ?
|
private static final boolean IS_WIN = SystemVersion.isWindows();
|
||||||
|
private static final String DEFAULT_FONT_NAME = IS_WIN ?
|
||||||
"Lucida Console" : "Monospaced";
|
"Lucida Console" : "Monospaced";
|
||||||
|
private static final String DEFAULT_TITLE_FONT_NAME = "Dialog";
|
||||||
|
private static final String DEFAULT_LEGEND_FONT_NAME = "Dialog";
|
||||||
|
private static final String PROP_FONT_MONO = "routerconsole.graphFont.unit";
|
||||||
|
private static final String PROP_FONT_LEGEND = "routerconsole.graphFont.legend";
|
||||||
|
private static final String PROP_FONT_TITLE = "routerconsole.graphFont.title";
|
||||||
|
private static final int SIZE_MONO = 10;
|
||||||
|
private static final int SIZE_LEGEND = 10;
|
||||||
|
private static final int SIZE_TITLE = 13;
|
||||||
|
|
||||||
public SummaryRenderer(I2PAppContext ctx, SummaryListener lsnr) {
|
public SummaryRenderer(I2PAppContext ctx, SummaryListener lsnr) {
|
||||||
_log = ctx.logManager().getLog(SummaryRenderer.class);
|
_log = ctx.logManager().getLog(SummaryRenderer.class);
|
||||||
@ -144,28 +153,30 @@ class SummaryRenderer {
|
|||||||
def.setColor(RrdGraphDef.COLOR_MGRID, MGRID_COLOR);
|
def.setColor(RrdGraphDef.COLOR_MGRID, MGRID_COLOR);
|
||||||
def.setColor(RrdGraphDef.COLOR_FONT, FONT_COLOR);
|
def.setColor(RrdGraphDef.COLOR_FONT, FONT_COLOR);
|
||||||
def.setColor(RrdGraphDef.COLOR_FRAME, FRAME_COLOR);
|
def.setColor(RrdGraphDef.COLOR_FRAME, FRAME_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
|
// improve text legibility
|
||||||
String lang = Messages.getLanguage(_context);
|
String lang = Messages.getLanguage(_context);
|
||||||
Font small = def.getSmallFont();
|
int smallSize = SIZE_MONO;
|
||||||
Font large = def.getLargeFont();
|
int legendSize = SIZE_LEGEND;
|
||||||
if ("ar".equals(lang) || "jp".equals(lang) || ("zh".equals(lang) && !IS_WIN)) {
|
int largeSize = SIZE_TITLE;
|
||||||
small = small.deriveFont(small.getSize2D() + 2.0f);
|
if ("ar".equals(lang) || "ja".equals(lang) || ("zh".equals(lang) && !IS_WIN)) {
|
||||||
large = large.deriveFont(Font.PLAIN, large.getSize2D() + 3.0f);
|
smallSize += 2;
|
||||||
} else {
|
legendSize += 2;
|
||||||
// small = small.deriveFont(small.getSize2D() + 1.0f);
|
largeSize += 3;
|
||||||
// if specified font family is missing, jrobin will use fallback
|
|
||||||
small = new Font("Droid Sans Mono", Font.PLAIN, 10);
|
|
||||||
// large = large.deriveFont(large.getSize2D() + 1.0f);
|
|
||||||
large = new Font("Droid Sans", Font.PLAIN, 13);
|
|
||||||
}
|
}
|
||||||
def.setSmallFont(small);
|
String ssmall = _context.getProperty(PROP_FONT_MONO, DEFAULT_FONT_NAME);
|
||||||
def.setLargeFont(large);
|
String slegend = _context.getProperty(PROP_FONT_LEGEND, DEFAULT_LEGEND_FONT_NAME);
|
||||||
|
String stitle = _context.getProperty(PROP_FONT_TITLE, DEFAULT_TITLE_FONT_NAME);
|
||||||
|
Font small = new Font(ssmall, Font.PLAIN, smallSize);
|
||||||
|
Font legnd = new Font(slegend, Font.PLAIN, legendSize);
|
||||||
|
Font large = new Font(stitle, Font.PLAIN, largeSize);
|
||||||
|
// DEFAULT is unused since we set all the others
|
||||||
|
def.setFont(RrdGraphDef.FONTTAG_DEFAULT, small);
|
||||||
|
// AXIS is unused, we do not set any axis labels
|
||||||
|
def.setFont(RrdGraphDef.FONTTAG_AXIS, small);
|
||||||
|
def.setFont(RrdGraphDef.FONTTAG_UNIT, small);
|
||||||
|
def.setFont(RrdGraphDef.FONTTAG_LEGEND, legnd);
|
||||||
|
def.setFont(RrdGraphDef.FONTTAG_TITLE, large);
|
||||||
|
|
||||||
def.setTimeSpan(start/1000, end/1000);
|
def.setTimeSpan(start/1000, end/1000);
|
||||||
def.setMinValue(0d);
|
def.setMinValue(0d);
|
||||||
@ -247,13 +258,14 @@ class SummaryRenderer {
|
|||||||
long started = event.getKey().longValue();
|
long started = event.getKey().longValue();
|
||||||
if (started > start && started < end) {
|
if (started > start && started < end) {
|
||||||
// String legend = _t("Restart") + ' ' + sdf.format(new Date(started)) + " UTC " + event.getValue() + "\\l";
|
// String legend = _t("Restart") + ' ' + sdf.format(new Date(started)) + " UTC " + event.getValue() + "\\l";
|
||||||
if ("ar".equals(lang)) {
|
String legend;
|
||||||
String legend = _t("Restart") + ' ' + sdf.format(new Date(started)) + " - " + event.getValue() + "\\l";
|
if ("ar".equals(lang) || "fa".equals(lang) || "iw".equals(lang)) {
|
||||||
def.vrule(started / 1000, RESTART_BAR_COLOR, legend, 2.0f);
|
// RTL languages
|
||||||
|
legend = _t("Restart") + ' ' + sdf.format(new Date(started)) + " - " + event.getValue() + "\\l";
|
||||||
} else {
|
} else {
|
||||||
String legend = _t("Restart") + ' ' + sdf.format(new Date(started)) + " [" + event.getValue() + "]\\l";
|
legend = _t("Restart") + ' ' + sdf.format(new Date(started)) + " [" + event.getValue() + "]\\l";
|
||||||
def.vrule(started / 1000, RESTART_BAR_COLOR, legend, 2.0f);
|
|
||||||
}
|
}
|
||||||
|
def.vrule(started / 1000, RESTART_BAR_COLOR, legend, 2.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def.comment(sdf.format(new Date(start)) + " — " + sdf.format(new Date(end)) + " UTC\\r");
|
def.comment(sdf.format(new Date(start)) + " — " + sdf.format(new Date(end)) + " UTC\\r");
|
||||||
@ -322,8 +334,6 @@ class SummaryRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final boolean IS_WIN = SystemVersion.isWindows();
|
|
||||||
|
|
||||||
/** translate a string */
|
/** translate a string */
|
||||||
private String _t(String s) {
|
private String _t(String s) {
|
||||||
// the RRD font doesn't have zh chars, at least on my system
|
// the RRD font doesn't have zh chars, at least on my system
|
||||||
|
13
history.txt
13
history.txt
@ -1,6 +1,15 @@
|
|||||||
2020-01-26
|
2020-02-03 zzz
|
||||||
|
* Graphs: Clean up font setting, fix bugs (ticket #2684)
|
||||||
|
|
||||||
|
2020-01-26 idk
|
||||||
* changed many icons on both light and dark themes out for Feather equivalents.
|
* changed many icons on both light and dark themes out for Feather equivalents.
|
||||||
|
|
||||||
|
2020-01-26 zzz
|
||||||
|
* Tunnels: Don't test ECIES-only tunnels
|
||||||
|
|
||||||
|
2020-01-21 zzz
|
||||||
|
* SSU: Use same valid IP criteria for relay request and response
|
||||||
|
|
||||||
2020-01-21 zzz
|
2020-01-21 zzz
|
||||||
* Ratchet: Randomize two high bits of Elligator2 encoding
|
* Ratchet: Randomize two high bits of Elligator2 encoding
|
||||||
|
|
||||||
@ -17,7 +26,7 @@
|
|||||||
|
|
||||||
2020-01-03 zzz
|
2020-01-03 zzz
|
||||||
* Console:
|
* Console:
|
||||||
- Don't refresh bw graph unless enclosing sidebar refresh\is longer
|
- Don't refresh bw graph unless enclosing sidebar refresh is longer
|
||||||
- Remove scroll-in-scroll for wrapper logs
|
- Remove scroll-in-scroll for wrapper logs
|
||||||
- Refactor the configstats js
|
- Refactor the configstats js
|
||||||
* i2psnark:
|
* i2psnark:
|
||||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 5;
|
public final static long BUILD = 6;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
Reference in New Issue
Block a user