use of org.opennms.netmgt.config.charts.ImageSize in project opennms by OpenNMS.
the class ChartUtils method getChartAsBufferedImage.
/**
* Helper method used to return a JFreeChart as a buffered Image.
*
* @param chartName a {@link java.lang.String} object.
* @return a <code>BufferedImage</code>
* @throws java.io.IOException if any.
* @throws java.sql.SQLException if any.
*/
public static BufferedImage getChartAsBufferedImage(String chartName) throws IOException, SQLException {
BarChart chartConfig = getBarChartConfigByName(chartName);
JFreeChart chart = getBarChart(chartName);
ImageSize imageSize = chartConfig.getImageSize();
int hzPixels;
int vtPixels;
if (imageSize == null) {
hzPixels = 400;
vtPixels = 400;
} else {
hzPixels = imageSize.getHzSize().getPixels();
vtPixels = imageSize.getVtSize().getPixels();
}
return chart.createBufferedImage(hzPixels, vtPixels);
}
use of org.opennms.netmgt.config.charts.ImageSize in project opennms by OpenNMS.
the class ChartUtils method getBarChart.
/**
* Helper method that returns the JFreeChart to an output stream written in JPEG format.
*
* @param chartName a {@link java.lang.String} object.
* @param out a {@link java.io.OutputStream} object.
* @throws java.io.IOException if any.
* @throws java.sql.SQLException if any.
*/
public static void getBarChart(String chartName, OutputStream out) throws IOException, SQLException {
BarChart chartConfig = getBarChartConfigByName(chartName);
JFreeChart chart = getBarChart(chartName);
ImageSize imageSize = chartConfig.getImageSize();
int hzPixels;
int vtPixels;
if (imageSize == null) {
hzPixels = 400;
vtPixels = 400;
} else {
hzPixels = imageSize.getHzSize().getPixels();
vtPixels = imageSize.getVtSize().getPixels();
}
ChartUtilities.writeChartAsJPEG(out, chart, hzPixels, vtPixels);
}
use of org.opennms.netmgt.config.charts.ImageSize in project opennms by OpenNMS.
the class ChartUtils method getBarChartAsPNGByteArray.
/**
* Helper method that returns the JFreeChart as a PNG byte array.
*
* @param chartName a {@link java.lang.String} object.
* @return a byte array
* @throws java.io.IOException if any.
* @throws java.sql.SQLException if any.
*/
public static byte[] getBarChartAsPNGByteArray(String chartName) throws IOException, SQLException {
BarChart chartConfig = getBarChartConfigByName(chartName);
JFreeChart chart = getBarChart(chartName);
ImageSize imageSize = chartConfig.getImageSize();
int hzPixels;
int vtPixels;
if (imageSize == null) {
hzPixels = 400;
vtPixels = 400;
} else {
hzPixels = imageSize.getHzSize().getPixels();
vtPixels = imageSize.getVtSize().getPixels();
}
return ChartUtilities.encodeAsPNG(chart.createBufferedImage(hzPixels, vtPixels));
}
use of org.opennms.netmgt.config.charts.ImageSize in project opennms by OpenNMS.
the class ChartUtils method getBarChartPNG.
/**
* Helper method that returns the JFreeChart to an output stream written in JPEG format.
*
* @param chartName a {@link java.lang.String} object.
* @param out a {@link java.io.OutputStream} object.
* @throws java.io.IOException if any.
* @throws java.sql.SQLException if any.
*/
public static void getBarChartPNG(String chartName, OutputStream out) throws IOException, SQLException {
ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
BarChart chartConfig = getBarChartConfigByName(chartName);
JFreeChart chart = getBarChart(chartName);
if (chartConfig.getChartBackgroundColor() != null) {
setChartBackgroundColor(chartConfig, chart);
}
if (chartConfig.getPlotBackgroundColor() != null) {
setPlotBackgroundColor(chartConfig, chart);
}
ImageSize imageSize = chartConfig.getImageSize();
int hzPixels;
int vtPixels;
if (imageSize == null) {
hzPixels = 400;
vtPixels = 400;
} else {
hzPixels = imageSize.getHzSize().getPixels();
vtPixels = imageSize.getVtSize().getPixels();
}
ChartUtilities.writeChartAsPNG(out, chart, hzPixels, vtPixels, false, 6);
}
Aggregations