Example usage for org.jfree.chart.axis NumberAxis setLabelInsets

List of usage examples for org.jfree.chart.axis NumberAxis setLabelInsets

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis setLabelInsets.

Prototype

public void setLabelInsets(RectangleInsets insets) 

Source Link

Document

Sets the insets for the axis label, and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static JFreeChart createXYAreaChart(String xAxisLabel, String yAxisLabel, XYDataset dataset,
        boolean includeLegend) {
    JFreeChart jfreechart = ChartFactory.createXYAreaChart(null, xAxisLabel, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setDomainPannable(true);//w ww  .  j  a v a  2 s  .  co m
    xyplot.setBackgroundPaint(null);
    xyplot.setOutlinePaint(null);
    xyplot.setForegroundAlpha(0.8F);
    xyplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY);
    DateAxis dateaxis = new DateAxis(xAxisLabel);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    xyplot.setDomainAxis(dateaxis);
    NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis();
    rangeAxis.setRangeType(RangeType.POSITIVE);
    rangeAxis.setLabelFont(UIConstants.H5_FONT);
    rangeAxis.setLabelInsets(new RectangleInsets(0, 0, 0, 0));

    if (includeLegend) {
        LegendTitle legendtitle = new LegendTitle(xyplot);
        legendtitle.setItemFont(UIConstants.H5_FONT);
        legendtitle.setBackgroundPaint(UIConstants.INTEL_WHITE);
        legendtitle.setFrame(new BlockBorder(UIConstants.INTEL_BLUE));
        legendtitle.setPosition(RectangleEdge.BOTTOM);
        XYTitleAnnotation xytitleannotation = new XYTitleAnnotation(0.97999999999999998D, 0.99999999999999998D,
                legendtitle, RectangleAnchor.TOP_RIGHT);
        // xytitleannotation.setMaxWidth(0.47999999999999998D);
        xyplot.addAnnotation(xytitleannotation);
    }

    XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    xyitemrenderer.setSeriesPaint(1, UIConstants.INTEL_DARK_GRAY);
    xyitemrenderer.setSeriesPaint(0, NodeTypeViz.SWITCH.getColor());
    xyitemrenderer.setBaseToolTipGenerator(
            new StandardXYToolTipGenerator("<html><b>{0}</b><br> Time: {1}<br> Data: {2}</html>",
                    Util.getHHMMSS(), new DecimalFormat("#,##0.00")));
    return jfreechart;
}

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static JFreeChart createTopNBarChart(String yAxisLabel, CategoryDataset dataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart(null, null, yAxisLabel, dataset,
            PlotOrientation.HORIZONTAL, true, true, false);
    CategoryPlot categoryplot = jfreechart.getCategoryPlot();
    categoryplot.setBackgroundPaint(null);
    categoryplot.setOutlinePaint(null);//from  www .j  av  a 2s . c o m
    categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    categoryplot.setRangePannable(true);
    categoryplot.setRangeGridlinesVisible(true);
    categoryplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY);

    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setBarPainter(new StandardBarPainter());
    barrenderer.setShadowVisible(false);
    barrenderer.setItemMargin(0.015);
    barrenderer.setSeriesPaint(0, UIConstants.INTEL_BLUE);
    barrenderer.setSeriesPaint(1, UIConstants.INTEL_LIGHT_BLUE);

    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryMargin(0.15D);
    categoryaxis.setUpperMargin(0.02D);
    categoryaxis.setLowerMargin(0.02D);
    categoryaxis.setMaximumCategoryLabelWidthRatio(0.5F);

    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setRangeType(RangeType.POSITIVE);
    numberaxis.setStandardTickUnits(createLargeNumberTickUnits());
    numberaxis.setUpperMargin(0.20000000000000001D);
    numberaxis.setLabelFont(UIConstants.H5_FONT);
    numberaxis.setLabelInsets(new RectangleInsets(0, 0, 0, 0));
    numberaxis.setTickMarksVisible(true);
    numberaxis.setTickLabelsVisible(true);

    LegendTitle legend = jfreechart.getLegend();
    legend.setFrame(BlockBorder.NONE);
    legend.setItemFont(barrenderer.getBaseItemLabelFont().deriveFont(10.0f));

    return jfreechart;
}

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static JFreeChart createStackedXYBarChart(XYDataset dataset, String title, String domainAxisLabel,
        String rangeAxisLabel, boolean legend) {
    DateAxis dateaxis = new DateAxis(domainAxisLabel);
    NumberAxis numberaxis = new NumberAxis(rangeAxisLabel);
    StackedXYBarRenderer stackedxybarrenderer = new StackedXYBarRenderer(0.10000000000000001D);
    XYPlot xyplot = new XYPlot(dataset, dateaxis, numberaxis, stackedxybarrenderer);
    JFreeChart jfreechart = new JFreeChart(title, UIConstants.H5_FONT, xyplot, legend);
    ChartUtilities.applyCurrentTheme(jfreechart);

    stackedxybarrenderer.setShadowVisible(false);
    stackedxybarrenderer.setDrawBarOutline(false);
    stackedxybarrenderer.setBarPainter(new StandardXYBarPainter());
    stackedxybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
            "<html><b>{0}</b><br> Time: {1}<br> Data: {2}</html>", Util.getHHMMSS(), new DecimalFormat("###")));

    xyplot.setBackgroundPaint(null);/*from w  w w  .  jav  a 2  s  .c o m*/
    xyplot.setOutlinePaint(null);
    xyplot.setRangeGridlinePaint(UIConstants.INTEL_BORDER_GRAY);

    dateaxis.setLabelFont(UIConstants.H5_FONT);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);

    numberaxis.setRangeType(RangeType.POSITIVE);
    numberaxis.setLabelFont(UIConstants.H5_FONT);
    numberaxis.setLabelInsets(new RectangleInsets(0, 0, 0, 0));
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return jfreechart;
}