Search in sources :

Example 11 with RectangleInsets

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);
}
Also used : Shape(java.awt.Shape) AlphaComposite(java.awt.AlphaComposite) Composite(java.awt.Composite) RectangleInsets(org.jfree.ui.RectangleInsets)

Example 12 with RectangleInsets

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;
}
Also used : DiscPlot(net.sourceforge.processdash.ui.lib.chart.DiscPlot) PieDataset(org.jfree.data.general.PieDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) RectangleInsets(org.jfree.ui.RectangleInsets) JFreeChart(org.jfree.chart.JFreeChart)

Example 13 with RectangleInsets

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));
    }
}
Also used : CategoryAxis(org.jfree.chart.axis.CategoryAxis) ValueAxis(org.jfree.chart.axis.ValueAxis) RectangleInsets(org.jfree.ui.RectangleInsets) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Example 14 with RectangleInsets

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);
}
Also used : Shape(java.awt.Shape) AlphaComposite(java.awt.AlphaComposite) Composite(java.awt.Composite) Rectangle2D(java.awt.geom.Rectangle2D) RectangleInsets(org.jfree.ui.RectangleInsets)

Example 15 with RectangleInsets

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;
}
Also used : LineAndShapeRenderer(org.jfree.chart.renderer.category.LineAndShapeRenderer) NumberAxis(org.jfree.chart.axis.NumberAxis) NoOverlapCategoryAxis(hudson.util.NoOverlapCategoryAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) RectangleInsets(org.jfree.ui.RectangleInsets) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot) NoOverlapCategoryAxis(hudson.util.NoOverlapCategoryAxis)

Aggregations

RectangleInsets (org.jfree.ui.RectangleInsets)28 JFreeChart (org.jfree.chart.JFreeChart)17 Color (java.awt.Color)10 NumberAxis (org.jfree.chart.axis.NumberAxis)10 CategoryPlot (org.jfree.chart.plot.CategoryPlot)9 XYPlot (org.jfree.chart.plot.XYPlot)9 BasicStroke (java.awt.BasicStroke)8 CategoryAxis (org.jfree.chart.axis.CategoryAxis)8 Font (java.awt.Font)5 Paint (java.awt.Paint)4 File (java.io.File)4 SimpleDateFormat (java.text.SimpleDateFormat)4 DateAxis (org.jfree.chart.axis.DateAxis)4 XYDataset (org.jfree.data.xy.XYDataset)4 ShiftedCategoryAxis (hudson.util.ShiftedCategoryAxis)3 ColorScheme (org.baderlab.csplugins.enrichmentmap.style.ColorScheme)3 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)3 StandardBarPainter (org.jfree.chart.renderer.category.StandardBarPainter)3 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)3 CategoryDataset (org.jfree.data.category.CategoryDataset)3