use of org.jfree.ui.RectangleInsets in project hudson-2.x by hudson.
the class AbstractTestResultAction method createChart.
private JFreeChart createChart(StaplerRequest req, CategoryDataset dataset) {
final String relPath = getRelPath(req);
final JFreeChart chart = ChartFactory.createStackedAreaChart(// chart title
null, // unused
null, // range axis label
"count", // data
dataset, // orientation
PlotOrientation.VERTICAL, // include legend
false, // tooltips
true, // urls
false);
// NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
// set the background color for the chart...
// final StandardLegend legend = (StandardLegend) chart.getLegend();
// legend.setAnchor(StandardLegend.SOUTH);
chart.setBackgroundPaint(Color.white);
final CategoryPlot plot = chart.getCategoryPlot();
// plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
plot.setBackgroundPaint(Color.WHITE);
plot.setOutlinePaint(null);
plot.setForegroundAlpha(0.8f);
// plot.setDomainGridlinesVisible(true);
// plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.black);
CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
plot.setDomainAxis(domainAxis);
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
domainAxis.setLowerMargin(0.0);
domainAxis.setUpperMargin(0.0);
domainAxis.setCategoryMargin(0.0);
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
StackedAreaRenderer ar = new StackedAreaRenderer2() {
@Override
public String generateURL(CategoryDataset dataset, int row, int column) {
NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
return relPath + label.build.getNumber() + "/testReport/";
}
@Override
public String generateToolTip(CategoryDataset dataset, int row, int column) {
NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
AbstractTestResultAction a = label.build.getAction(AbstractTestResultAction.class);
switch(row) {
case 0:
return String.valueOf(Messages.AbstractTestResultAction_fail(label.build.getDisplayName(), a.getFailCount()));
case 1:
return String.valueOf(Messages.AbstractTestResultAction_skip(label.build.getDisplayName(), a.getSkipCount()));
default:
return String.valueOf(Messages.AbstractTestResultAction_test(label.build.getDisplayName(), a.getTotalCount()));
}
}
};
plot.setRenderer(ar);
// Failures.
ar.setSeriesPaint(0, ColorPalette.RED);
// Skips.
ar.setSeriesPaint(1, ColorPalette.YELLOW);
// Total.
ar.setSeriesPaint(2, ColorPalette.BLUE);
// crop extra space around the graph
plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));
return chart;
}
use of org.jfree.ui.RectangleInsets in project violations-plugin by jenkinsci.
the class AbstractViolationsBuildAction method createChart.
// FIXME this should be in a utility class
protected JFreeChart createChart(CategoryDataset dataset) {
final JFreeChart chart = // chart
ChartFactory.createLineChart(// chart
null, // unused
null, // range axis label
"count", // data
dataset, // orientation
PlotOrientation.VERTICAL, // include legend
true, // tooltips
true, // urls
false);
// NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
final LegendTitle legend = chart.getLegend();
legend.setPosition(RectangleEdge.RIGHT);
chart.setBackgroundPaint(Color.white);
final CategoryPlot plot = chart.getCategoryPlot();
if (useLog) {
final NumberAxis rangeAxis2 = new LogarithmicAxis("Log(y)");
plot.setRangeAxis(rangeAxis2);
}
// plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
plot.setBackgroundPaint(Color.WHITE);
plot.setOutlinePaint(null);
plot.setRangeGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.black);
CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
plot.setDomainAxis(domainAxis);
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
domainAxis.setLowerMargin(0.0);
domainAxis.setUpperMargin(0.0);
domainAxis.setCategoryMargin(0.0);
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// rangeAxis.setUpperBound(100);
if (Boolean.getBoolean(VIOLATIONS_PLUGIN_CHART_AUTORANGE_PROPERTY)) {
rangeAxis.setAutoRange(true);
rangeAxis.setAutoRangeIncludesZero(false);
rangeAxis.setAutoRangeMinimumSize(50);
} else {
rangeAxis.setLowerBound(0);
}
final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
renderer.setStroke(new BasicStroke(2.0f));
ColorPalette.apply(renderer);
// crop extra space around the graph
plot.setInsets(new RectangleInsets(PADDING, 0, 0, PADDING));
return chart;
}
use of org.jfree.ui.RectangleInsets in project EnrichmentMapApp by BaderLab.
the class RadialHeatMapLayer method createChart.
@Override
protected JFreeChart createChart(final PieDataset dataset) {
JFreeChart chart = ChartFactory.createPieChart(// chart title
null, // data
dataset, // include legend
false, // tooltips
false, // urls
false);
chart.setAntiAlias(true);
chart.setBorderVisible(false);
chart.setBackgroundPaint(TRANSPARENT_COLOR);
chart.setBackgroundImageAlpha(0.0f);
chart.setPadding(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
final PiePlot plot = (PiePlot) chart.getPlot();
plot.setCircular(true);
plot.setStartAngle(startAngle);
plot.setDirection(rotation == Rotation.ANTICLOCKWISE ? org.jfree.util.Rotation.ANTICLOCKWISE : org.jfree.util.Rotation.CLOCKWISE);
plot.setOutlineVisible(false);
plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
plot.setInteriorGap(INTERIOR_GAP);
plot.setBackgroundPaint(TRANSPARENT_COLOR);
plot.setBackgroundAlpha(0.0f);
plot.setShadowPaint(TRANSPARENT_COLOR);
plot.setShadowXOffset(0.0);
plot.setShadowYOffset(0.0);
plot.setLabelGenerator(showItemLabels ? new CustomPieSectionLabelGenerator(labels) : null);
plot.setSimpleLabels(true);
plot.setLabelFont(plot.getLabelFont().deriveFont(itemFontSize));
plot.setLabelBackgroundPaint(TRANSPARENT_COLOR);
plot.setLabelOutlinePaint(TRANSPARENT_COLOR);
plot.setLabelShadowPaint(TRANSPARENT_COLOR);
plot.setLabelPaint(labelColor);
final BasicStroke stroke = new BasicStroke(borderWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
Color upperColor = Color.BLUE;
Color zeroColor = Color.WHITE;
Color lowerColor = Color.RED;
Color nanColor = DEFAULT_ITEM_BG_COLOR;
if (range != null && range.size() >= 2 && range.get(0) != null && range.get(1) != null) {
final int colorsSize = colors != null ? colors.size() : 0;
if (colorsSize > 0)
upperColor = colors.get(0);
if (colorsSize > 1)
zeroColor = colors.get(1);
if (colorsSize > 2)
lowerColor = colors.get(2);
if (colorsSize > 3)
nanColor = colors.get(3);
}
final List<?> keys = dataset.getKeys();
final List<Double> values = data.isEmpty() ? null : data.values().iterator().next();
for (int i = 0; i < keys.size(); i++) {
String k = (String) keys.get(i);
Double v = values.size() > i ? values.get(i) : null;
final Color c;
if (v == null)
c = nanColor;
else
c = ColorUtil.getColor(v, range.get(0), range.get(1), lowerColor, zeroColor, upperColor);
plot.setSectionPaint(k, c);
plot.setSectionOutlinePaint(k, borderWidth > 0 ? borderColor : TRANSPARENT_COLOR);
plot.setSectionOutlineStroke(k, stroke);
}
return chart;
}
use of org.jfree.ui.RectangleInsets in project EnrichmentMapApp by BaderLab.
the class ChartUtil method createRadialHeatMapLegend.
public static JFreeChart createRadialHeatMapLegend(List<EMDataSet> dataSets, ChartOptions options) {
// All the slices must have the same size
final DefaultPieDataset pieDataset = new DefaultPieDataset();
for (EMDataSet ds : dataSets) pieDataset.setValue(ds.getName(), 1);
JFreeChart chart = ChartFactory.createPieChart(// chart title
null, // data
pieDataset, // include legend
false, // tooltips
true, // urls
false);
chart.setAntiAlias(true);
chart.setBorderVisible(false);
chart.setBackgroundPaint(UIManager.getColor("Table.background"));
chart.setBackgroundImageAlpha(0.0f);
chart.setPadding(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
final PiePlot plot = (PiePlot) chart.getPlot();
plot.setCircular(true);
plot.setOutlineVisible(false);
plot.setBackgroundPaint(UIManager.getColor("Table.background"));
plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
plot.setShadowPaint(TRANSPARENT_COLOR);
plot.setShadowXOffset(0.0);
plot.setShadowYOffset(0.0);
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}"));
plot.setLabelFont(UIManager.getFont("Label.font").deriveFont(LookAndFeelUtil.getSmallFontSize()));
plot.setLabelPaint(UIManager.getColor("Label.foreground"));
plot.setLabelBackgroundPaint(TRANSPARENT_COLOR);
plot.setLabelOutlinePaint(TRANSPARENT_COLOR);
plot.setLabelShadowPaint(TRANSPARENT_COLOR);
plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0}"));
ColorScheme colorScheme = options != null ? options.getColorScheme() : null;
List<Color> colors = colorScheme != null ? colorScheme.getColors() : null;
if (// UP, ZERO, DOWN:
colors == null || colors.size() < 3)
colors = Arrays.asList(new Color[] { Color.LIGHT_GRAY, Color.WHITE, Color.DARK_GRAY });
int total = dataSets.size();
int v = total / -2;
for (EMDataSet ds : dataSets) {
plot.setSectionPaint(ds.getName(), ColorUtil.getColor(v, -total, total, colors.get(2), colors.get(1), colors.get(0)));
v++;
}
return chart;
}
use of org.jfree.ui.RectangleInsets in project EnrichmentMapApp by BaderLab.
the class ChartUtil method createHeatMapLegend.
@SuppressWarnings("serial")
public static JFreeChart createHeatMapLegend(List<EMDataSet> dataSets, ChartOptions options) {
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (EMDataSet ds : dataSets) dataset.addValue(1, options.getData().toString(), ds.getName());
final JFreeChart chart = ChartFactory.createBarChart(// chart title
null, // domain axis label
null, // range axis label
null, // data
dataset, PlotOrientation.HORIZONTAL, // include legend
false, // tooltips
true, // urls
false);
chart.setAntiAlias(true);
chart.setBorderVisible(false);
chart.setBackgroundPaint(UIManager.getColor("Table.background"));
chart.setBackgroundImageAlpha(0.0f);
chart.setPadding(new RectangleInsets(0.0, 0.0, 0.0, 20.0));
final CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setOutlineVisible(false);
plot.setBackgroundPaint(UIManager.getColor("Table.background"));
plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
plot.setDomainGridlinesVisible(false);
plot.setRangeGridlinesVisible(false);
final CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis();
domainAxis.setVisible(true);
domainAxis.setAxisLineVisible(false);
domainAxis.setTickMarksVisible(false);
domainAxis.setTickLabelFont(UIManager.getFont("Label.font").deriveFont(LookAndFeelUtil.getSmallFontSize()));
domainAxis.setTickLabelPaint(UIManager.getColor("Label.foreground"));
domainAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 15.0));
domainAxis.setCategoryMargin(0.0);
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setVisible(false);
ColorScheme colorScheme = options != null ? options.getColorScheme() : null;
List<Color> colors = colorScheme != null ? colorScheme.getColors() : null;
if (// UP, ZERO, DOWN:
colors == null || colors.size() < 3)
colors = Arrays.asList(new Color[] { Color.LIGHT_GRAY, Color.WHITE, Color.DARK_GRAY });
List<Color> itemColors = new ArrayList<>();
int total = dataSets.size();
int v = total / 2;
for (int i = 0; i < total; i++) itemColors.add(ColorUtil.getColor(v--, -total, total, colors.get(2), colors.get(1), colors.get(0)));
final BarRenderer renderer = new BarRenderer() {
@Override
public Paint getItemPaint(int row, int column) {
return column < itemColors.size() ? itemColors.get(column) : Color.LIGHT_GRAY;
}
};
plot.setRenderer(renderer);
renderer.setBarPainter(new StandardBarPainter());
renderer.setDrawBarOutline(true);
renderer.setShadowVisible(false);
renderer.setItemMargin(0.0);
renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{1}", NumberFormat.getInstance()));
return chart;
}
Aggregations