forked from I2P_Developers/i2p.i2p
limit max graph size
This commit is contained in:
@@ -25,6 +25,9 @@ public class GraphHelper extends HelperBase {
|
|||||||
private static final int DEFAULT_Y = 100;
|
private static final int DEFAULT_Y = 100;
|
||||||
private static final int DEFAULT_REFRESH = 60;
|
private static final int DEFAULT_REFRESH = 60;
|
||||||
private static final int DEFAULT_PERIODS = 60;
|
private static final int DEFAULT_PERIODS = 60;
|
||||||
|
static final int MAX_X = 2048;
|
||||||
|
static final int MAX_Y = 1024;
|
||||||
|
private static final int MIN_REFRESH = 15;
|
||||||
|
|
||||||
public GraphHelper() {
|
public GraphHelper() {
|
||||||
}
|
}
|
||||||
@@ -45,13 +48,13 @@ public class GraphHelper extends HelperBase {
|
|||||||
}
|
}
|
||||||
public void setShowEvents(boolean b) { _showEvents = b; }
|
public void setShowEvents(boolean b) { _showEvents = b; }
|
||||||
public void setHeight(String str) {
|
public void setHeight(String str) {
|
||||||
try { _height = Integer.parseInt(str); } catch (NumberFormatException nfe) {}
|
try { _height = Math.min(Integer.parseInt(str), MAX_Y); } catch (NumberFormatException nfe) {}
|
||||||
}
|
}
|
||||||
public void setWidth(String str) {
|
public void setWidth(String str) {
|
||||||
try { _width = Integer.parseInt(str); } catch (NumberFormatException nfe) {}
|
try { _width = Math.min(Integer.parseInt(str), MAX_X); } catch (NumberFormatException nfe) {}
|
||||||
}
|
}
|
||||||
public void setRefreshDelay(String str) {
|
public void setRefreshDelay(String str) {
|
||||||
try { _refreshDelaySeconds = Integer.parseInt(str); } catch (NumberFormatException nfe) {}
|
try { _refreshDelaySeconds = Math.max(Integer.parseInt(str), MIN_REFRESH); } catch (NumberFormatException nfe) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getImages() {
|
public String getImages() {
|
||||||
|
@@ -119,6 +119,10 @@ public class StatSummarizer implements Runnable {
|
|||||||
return renderPng(rate, out, -1, -1, false, false, false, false, -1, true);
|
return renderPng(rate, out, -1, -1, false, false, false, false, -1, true);
|
||||||
}
|
}
|
||||||
public boolean renderPng(Rate rate, OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount, boolean showCredit) throws IOException {
|
public boolean renderPng(Rate rate, OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount, boolean showCredit) throws IOException {
|
||||||
|
if (width > GraphHelper.MAX_X)
|
||||||
|
width = GraphHelper.MAX_X;
|
||||||
|
if (height > GraphHelper.MAX_Y)
|
||||||
|
height = GraphHelper.MAX_Y;
|
||||||
for (int i = 0; i < _listeners.size(); i++) {
|
for (int i = 0; i < _listeners.size(); i++) {
|
||||||
SummaryListener lsnr = (SummaryListener)_listeners.get(i);
|
SummaryListener lsnr = (SummaryListener)_listeners.get(i);
|
||||||
if (lsnr.getRate().equals(rate)) {
|
if (lsnr.getRate().equals(rate)) {
|
||||||
@@ -147,6 +151,10 @@ public class StatSummarizer implements Runnable {
|
|||||||
|
|
||||||
public boolean renderRatePng(OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount, boolean showCredit) throws IOException {
|
public boolean renderRatePng(OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount, boolean showCredit) throws IOException {
|
||||||
long end = _context.clock().now() - 60*1000;
|
long end = _context.clock().now() - 60*1000;
|
||||||
|
if (width > GraphHelper.MAX_X)
|
||||||
|
width = GraphHelper.MAX_X;
|
||||||
|
if (height > GraphHelper.MAX_Y)
|
||||||
|
height = GraphHelper.MAX_Y;
|
||||||
if (periodCount <= 0) periodCount = SummaryListener.PERIODS;
|
if (periodCount <= 0) periodCount = SummaryListener.PERIODS;
|
||||||
if (periodCount > SummaryListener.PERIODS)
|
if (periodCount > SummaryListener.PERIODS)
|
||||||
periodCount = SummaryListener.PERIODS;
|
periodCount = SummaryListener.PERIODS;
|
||||||
|
Reference in New Issue
Block a user