use of org.jfree.ui.RectangleInsets in project processdash by dtuma.
the class RadarPlot method draw.
/**
* Draws the plot on a Java 2D graphics device (such as the screen
* or a printer).
* @param g2 The graphics device.
* @param plotArea The area within which the plot should be drawn.
*/
@Override
public void draw(Graphics2D g2, Rectangle2D plotArea, Point2D anchor, PlotState state, PlotRenderingInfo info) {
// adjust for insets...
RectangleInsets insets = getInsets();
if (insets != null) {
plotArea.setRect(plotArea.getX() + insets.getLeft(), plotArea.getY() + insets.getTop(), plotArea.getWidth() - insets.getLeft() - insets.getRight(), plotArea.getHeight() - insets.getTop() - insets.getBottom());
}
if (info != null) {
info.setPlotArea(plotArea);
info.setDataArea(plotArea);
}
drawBackground(g2, plotArea);
drawOutline(g2, plotArea);
Shape savedClip = g2.getClip();
g2.clip(plotArea);
Composite originalComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha()));
if (this.dataset != null) {
drawRadar(g2, plotArea, info, 0, this.dataset);
} else {
drawNoDataMessage(g2, plotArea);
}
g2.clip(savedClip);
g2.setComposite(originalComposite);
drawOutline(g2, plotArea);
}
use of org.jfree.ui.RectangleInsets in project processdash by dtuma.
the class DiscChart method createDiscChart.
public static JFreeChart createDiscChart(ResultSet data, Map parameters) {
// data.sortBy(1, true);
CategoryDataset catData = data.catDataSource();
PieDataset pieData = null;
if (catData.getColumnCount() == 1)
pieData = DatasetUtilities.createPieDatasetForColumn(catData, 0);
else
pieData = DatasetUtilities.createPieDatasetForRow(catData, 0);
DiscPlot plot = new DiscPlot(pieData);
plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
plot.setDrawingSupplier(DRAWING_SUPPLIER_FACTORY.newDrawingSupplier());
JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
if (parameters.get("skipItemLabels") != null || parameters.get("skipDiscLabels") != null)
plot.setLabelGenerator(null);
else if (parameters.get("discLabelFontSize") != null)
try {
float fontSize = Float.parseFloat((String) parameters.get("discLabelFontSize"));
plot.setLabelFont(plot.getLabelFont().deriveFont(fontSize));
} catch (Exception lfe) {
}
if (parameters.get("ellipse") != null)
((StandardDiscItemDistributor) plot.getDiscDistributor()).setCircular(false);
String interiorGap = (String) parameters.get("interiorGap");
if (interiorGap != null)
try {
plot.setInteriorGap(Integer.parseInt(interiorGap) / 100.0);
} catch (NumberFormatException e) {
}
String interiorSpacing = (String) parameters.get("interiorSpacing");
if (interiorSpacing != null)
try {
plot.setInteriorGap(Integer.parseInt(interiorSpacing) / 200.0);
} catch (NumberFormatException e) {
}
return chart;
}
use of org.jfree.ui.RectangleInsets in project processdash by dtuma.
the class CGIChartBase method setupCategoryChart.
protected void setupCategoryChart(JFreeChart chart) {
if (!(chart.getPlot() instanceof CategoryPlot))
return;
CategoryPlot cp = chart.getCategoryPlot();
CategoryAxis catAxis = cp.getDomainAxis();
ValueAxis otherAxis = cp.getRangeAxis();
if (!chromeless) {
String catAxisLabel = data.getColName(0);
if (catAxisLabel == null)
catAxisLabel = Translator.translate("Project/Task");
String otherAxisLabel = Translator.translate(getSetting("units"));
if ((otherAxisLabel == null || otherAxisLabel.length() == 0) && data.numCols() == 1)
otherAxisLabel = data.getColName(1);
if (otherAxisLabel == null)
otherAxisLabel = Translator.translate("Value");
String catLabels = getParameter("categoryLabels");
catAxis.setLabel(catAxisLabel);
otherAxis.setLabel(otherAxisLabel);
if ("vertical".equalsIgnoreCase(catLabels))
catAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
else if ("none".equalsIgnoreCase(catLabels))
catAxis.setTickLabelsVisible(false);
}
if (data.numCols() == 1 && getParameter("noSkipLegend") == null) {
chart.removeLegend();
chart.getPlot().setInsets(new RectangleInsets(5, 2, 2, 5));
}
}
use of org.jfree.ui.RectangleInsets in project processdash by dtuma.
the class DiscPlot method draw.
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) {
// adjust for insets...
RectangleInsets insets = getInsets();
insets.trim(area);
if (info != null) {
info.setPlotArea(area);
info.setDataArea(area);
}
drawBackground(g2, area);
drawOutline(g2, area);
Shape savedClip = g2.getClip();
g2.clip(area);
Composite originalComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha()));
if (!getDiscDistributor().isDatasetEmpty()) {
Rectangle2D dataArea = getDataArea(area);
drawDiscs(g2, dataArea, info);
drawLegendAxis(g2, dataArea, info);
} else {
drawNoDataMessage(g2, area);
}
g2.setClip(savedClip);
g2.setComposite(originalComposite);
drawOutline(g2, area);
}
use of org.jfree.ui.RectangleInsets in project hudson-2.x by hudson.
the class LoadStatistics method createChart.
/**
* Creates a trend chart.
*/
public JFreeChart createChart(CategoryDataset ds) {
final JFreeChart chart = // chart title
ChartFactory.createLineChart(// chart title
null, // unused
null, // range axis label
null, // data
ds, // orientation
PlotOrientation.VERTICAL, // include legend
true, // tooltips
true, // urls
false);
chart.setBackgroundPaint(Color.white);
final CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.WHITE);
plot.setOutlinePaint(null);
plot.setRangeGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.black);
final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
renderer.setBaseStroke(new BasicStroke(3));
configureRenderer(renderer);
final CategoryAxis domainAxis = new NoOverlapCategoryAxis(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());
// crop extra space around the graph
plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));
return chart;
}
Aggregations