Example usage for org.jfree.chart.axis DateAxis setTickLabelsVisible

List of usage examples for org.jfree.chart.axis DateAxis setTickLabelsVisible

Introduction

In this page you can find the example usage for org.jfree.chart.axis DateAxis setTickLabelsVisible.

Prototype

public void setTickLabelsVisible(boolean flag) 

Source Link

Document

Sets the flag that determines whether or not the tick labels are visible and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:es.bsc.autonomic.powermodeller.graphics.TotalPowerAndPredictionDifference.java

private static JFreeChart createChart() {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(NAME, "Power (Watts)", "Power (Watts)", data,
            true, true, false);/*from  w  ww . j  a  v a2  s. co m*/
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    XYDifferenceRenderer xydifferencerenderer = new XYDifferenceRenderer(Color.green, Color.yellow, false);
    xydifferencerenderer.setRoundXCoordinates(true);
    xyplot.setDomainCrosshairLockedOnData(true);
    xyplot.setRangeCrosshairLockedOnData(true);
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    xyplot.setRenderer(xydifferencerenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    DateAxis dateaxis = new DateAxis("Samples");
    dateaxis.setTickLabelsVisible(false);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    xyplot.setDomainAxis(dateaxis);
    xyplot.setForegroundAlpha(0.5F);
    return jfreechart;
}

From source file:eu.kprod.gui.chart.MwChartFactory.java

public static MwChartPanel createChart(MwConfiguration conf, final XYDataset xyDataset) {
    final JFreeChart chart;

    chart = ChartFactory.createTimeSeriesChart(null, null, null, xyDataset, false, true, true);

    chart.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR));
    chart.setBorderVisible(false);/*from   w w w  .  ja  v  a  2  s.  c o  m*/
    final XYPlot plot = chart.getXYPlot();

    plot.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR));

    plot.setDomainGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    plot.setRangeGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    plot.setDomainGridlinesVisible(false);
    plot.setDomainCrosshairPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    // axis.setDateFormatOverride(new SimpleDateFormat("mm''ss''''SSS"));
    axis.setAxisLineVisible(false);
    axis.setTickLabelsVisible(false);
    axis.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));

    // force integer display
    final ValueAxis va = plot.getRangeAxis();
    va.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    va.setLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    va.setAxisLinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    va.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));

    //        va.setRange(-280,280);
    //        va.setFixedAutoRange(560);
    //        va.setLowerBound(-280);
    //        va.setUpperBound(280);
    //        va.setAutoRange(false);
    va.setRangeWithMargins(-280, 280);

    final MwChartPanel chartPanel = new MwChartPanel(chart, conf);
    chartPanel.setMouseWheelEnabled(false);
    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);

    return chartPanel;

}

From source file:org.multiwii.swingui.gui.chart.MwChartFactory.java

public static MwChartPanel createChart(MwConfiguration conf, final XYDataset xyDataset) {
    final JFreeChart chart;

    chart = ChartFactory.createTimeSeriesChart(null, null, null, xyDataset, false, true, true);

    chart.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR));
    chart.setBorderVisible(false);//w  w w . j av  a  2s  . c  o m
    final XYPlot plot = chart.getXYPlot();

    plot.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR));

    plot.setDomainGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    plot.setRangeGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    plot.setDomainGridlinesVisible(false);
    plot.setDomainCrosshairPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    // axis.setDateFormatOverride(new SimpleDateFormat("mm''ss''''SSS"));
    axis.setAxisLineVisible(false);
    axis.setTickLabelsVisible(false);
    axis.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));

    // force integer display
    final ValueAxis va = plot.getRangeAxis();
    va.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    va.setLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    va.setAxisLinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR));
    va.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR));

    // va.setRange(-280,280);
    // va.setFixedAutoRange(560);
    // va.setLowerBound(-280);
    // va.setUpperBound(280);
    // va.setAutoRange(false);
    va.setRangeWithMargins(-280, 280);

    final MwChartPanel chartPanel = new MwChartPanel(chart, conf);
    chartPanel.setMouseWheelEnabled(false);
    chartPanel.setDomainZoomable(false);
    chartPanel.setRangeZoomable(false);

    return chartPanel;

}

From source file:scrum.server.common.BurndownChart.java

private static JFreeChart createSprintBurndownChart(List<BurndownSnapshot> snapshots, Date firstDay,
        Date lastDay, Date originallyLastDay, WeekdaySelector freeDays, int dateMarkTickUnit,
        float widthPerDay) {
    DefaultXYDataset data = createSprintBurndownChartDataset(snapshots, firstDay, lastDay, originallyLastDay,
            freeDays);/*from w ww .  j a v a2 s .co m*/

    double tick = 1.0;
    double max = BurndownChart.getMaximum(data);

    while (max / tick > 25) {
        tick *= 2;
        if (max / tick <= 25)
            break;
        tick *= 2.5;
        if (max / tick <= 25)
            break;
        tick *= 2;
    }
    double valueLabelTickUnit = tick;
    double upperBoundary = Math.min(max * 1.1f, max + 3);

    if (!Sys.isHeadless())
        LOG.warn("GraphicsEnvironment is not headless");
    JFreeChart chart = ChartFactory.createXYLineChart("", "", "", data, PlotOrientation.VERTICAL, false, true,
            false);

    chart.setBackgroundPaint(Color.WHITE);

    XYPlot plot = chart.getXYPlot();
    // plot.setInsets(new RectangleInsets(0, 0, 0, 0));
    plot.setAxisOffset(RectangleInsets.ZERO_INSETS);
    // plot.setOutlineVisible(false);

    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.lightGray);
    // plot.setRangeCrosshairPaint(Color.lightGray);
    // plot.setRangeMinorGridlinePaint(Color.lightGray);
    // plot.setDomainCrosshairPaint(Color.blue);
    // plot.setDomainMinorGridlinePaint(Color.green);
    // plot.setDomainTickBandPaint(Color.green);

    XYItemRenderer renderer = plot.getRenderer();
    renderer.setBaseStroke(new BasicStroke(2f));

    renderer.setSeriesPaint(0, COLOR_PAST_LINE);
    renderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer.setSeriesPaint(1, COLOR_PROJECTION_LINE);
    renderer.setSeriesStroke(1,
            new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL, 1.0f, new float[] { 3f }, 0));
    renderer.setSeriesPaint(2, COLOR_OPTIMUM_LINE);
    renderer.setSeriesStroke(2, new BasicStroke(2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));

    DateAxis domainAxis1 = new DateAxis();
    String dateFormat = "d.";
    widthPerDay -= 5;
    if (widthPerDay > 40) {
        dateFormat = "EE " + dateFormat;
    }
    if (widthPerDay > 10) {
        float spaces = widthPerDay / 2.7f;
        dateFormat = Str.multiply(" ", (int) spaces) + dateFormat;
    }
    domainAxis1.setDateFormatOverride(new SimpleDateFormat(dateFormat, Locale.US));
    domainAxis1.setTickUnit(new DateTickUnit(DateTickUnit.DAY, dateMarkTickUnit));
    domainAxis1.setAxisLineVisible(false);
    Range range = new Range(firstDay.toMillis(), lastDay.nextDay().toMillis());
    domainAxis1.setRange(range);

    DateAxis domainAxis2 = new DateAxis();
    domainAxis2.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 1));
    domainAxis2.setTickMarksVisible(false);
    domainAxis2.setTickLabelsVisible(false);
    domainAxis2.setRange(range);

    plot.setDomainAxis(0, domainAxis2);
    plot.setDomainAxis(1, domainAxis1);
    plot.setDomainAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setNumberFormatOverride(NumberFormat.getIntegerInstance());
    rangeAxis.setTickUnit(new NumberTickUnit(valueLabelTickUnit));

    rangeAxis.setLowerBound(0);
    rangeAxis.setUpperBound(upperBoundary);

    plot.setRangeAxis(rangeAxis);

    return chart;
}

From source file:ec.util.chart.swing.JTimeSeriesRendererSupportDemo.java

private static JFreeChart createTsChart() {
    XYPlot plot = new XYPlot();

    plot.setAxisOffset(RectangleInsets.ZERO_INSETS);

    DateAxis domainAxis = new DateAxis();
    domainAxis.setTickLabelsVisible(false);
    domainAxis.setLowerMargin(0.02);/*from  w  w w  .  j  ava  2 s  .  co  m*/
    domainAxis.setUpperMargin(0.02);
    plot.setDomainAxis(domainAxis);

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setTickLabelsVisible(false);
    rangeAxis.setLowerMargin(0.02);
    rangeAxis.setUpperMargin(0.02);
    plot.setRangeAxis(rangeAxis);

    JFreeChart result = new JFreeChart("", null, plot, true);
    result.setPadding(new RectangleInsets(5, 5, 5, 5));
    result.getLegend().setFrame(BlockBorder.NONE);
    result.getLegend().setBackgroundPaint(null);

    return result;
}

From source file:org.mustbe.consulo.xprofiler.ui.mainPanel.MemoryPlotPanel.java

public MemoryPlotPanel(int maxAge, String title) {
    super(new BorderLayout());

    totalSeries = new TimeSeries("Committed Memory");
    totalSeries.setMaximumItemAge(maxAge);
    usedSeries = new TimeSeries("Used Memory");
    usedSeries.setMaximumItemAge(maxAge);
    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    seriesCollection.addSeries(totalSeries);
    seriesCollection.addSeries(usedSeries);

    NumberAxis numberAxis = new NumberAxis("Memory (KB)");

    numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    DateAxis dateAxis = new DateAxis("Time");

    dateAxis.setAutoRange(true);/* ww w.j a  v  a  2 s . c om*/
    dateAxis.setLowerMargin(0);
    dateAxis.setUpperMargin(0);
    dateAxis.setTickLabelsVisible(true);
    dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));

    XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false);
    lineRenderer.setSeriesPaint(0, JBColor.RED);
    lineRenderer.setSeriesPaint(1, JBColor.GREEN);
    lineRenderer.setDefaultStroke(new BasicStroke(2F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

    XYPlot xyplot = new XYPlot(seriesCollection, dateAxis, numberAxis, lineRenderer);
    xyplot.setBackgroundPainter(new ColorPainter(JBColor.white));
    xyplot.setDomainGridlinePaint(JBColor.LIGHT_GRAY);
    xyplot.setRangeGridlinePaint(JBColor.LIGHT_GRAY);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));

    JFreeChart chart = new JFreeChart(title, new Font("SansSerif", Font.PLAIN, 14), xyplot, true);
    chart.setBackgroundPainter(new ColorPainter(JBColor.white));

    add(new ChartPanel(chart, 300, 300, 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, false,
            false, false), BorderLayout.CENTER);
}

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

public static JFreeChart createXYAreaSparkline(XYDataset dataset) {
    JFreeChart jfreechart = ChartFactory.createXYAreaChart(null, null, null, dataset, PlotOrientation.VERTICAL,
            false, false, false);/* ww w .j ava  2  s  .  com*/
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setDomainPannable(true);
    xyplot.setBackgroundPaint(null);
    xyplot.setOutlinePaint(null);
    xyplot.setForegroundAlpha(0.8F);
    xyplot.setDomainGridlinesVisible(false);
    xyplot.setDomainCrosshairVisible(false);
    xyplot.setRangeGridlinesVisible(false);
    xyplot.setRangeCrosshairVisible(false);

    DateAxis dateaxis = new DateAxis("");
    dateaxis.setTickLabelsVisible(false);
    dateaxis.setTickMarksVisible(false);
    dateaxis.setAxisLineVisible(false);
    dateaxis.setNegativeArrowVisible(false);
    dateaxis.setPositiveArrowVisible(false);
    dateaxis.setVisible(false);
    xyplot.setDomainAxis(dateaxis);

    ValueAxis rangeAxis = xyplot.getRangeAxis();
    rangeAxis.setTickLabelsVisible(false);
    rangeAxis.setTickMarksVisible(false);
    rangeAxis.setAxisLineVisible(false);
    rangeAxis.setNegativeArrowVisible(false);
    rangeAxis.setPositiveArrowVisible(false);
    rangeAxis.setVisible(false);

    XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    xyitemrenderer.setSeriesPaint(1, UIConstants.INTEL_DARK_GRAY);
    xyitemrenderer.setSeriesPaint(0, NodeTypeViz.SWITCH.getColor());
    return jfreechart;
}

From source file:greenapi.ui.charts.ChartPanelSupport.java

/**
 * Clean the value of the chart./*from   w  ww  .  j a v a  2s .co m*/
 * 
 * @see #createChart()
 */
public void cleanChart() {
    this.chart.removeLegend();
    this.chartPanel.setBorder(null);

    cleanLabels();

    DateAxis localDateAxis = (DateAxis) ((XYPlot) this.chart.getPlot()).getDomainAxis();
    localDateAxis.setTickLabelsVisible(false);
    localDateAxis.setTickMarksVisible(false);
    localDateAxis.setAxisLineVisible(false);

    ValueAxis localValueAxis = ((XYPlot) this.chart.getPlot()).getRangeAxis();
    localValueAxis.setTickLabelsVisible(false);
    localValueAxis.setTickMarksVisible(false);
    localValueAxis.setAxisLineVisible(false);

    XYPlot localXYPlot = (XYPlot) this.chart.getPlot();
    localXYPlot.setDomainGridlineStroke(this.defaultLineStroke);
    localXYPlot.setDomainGridlinesVisible(true);
    localXYPlot.setRangeGridlineStroke(this.defaultLineStroke);
    localXYPlot.setRangeGridlinesVisible(true);

    localXYPlot.setAxisOffset(new RectangleInsets(0.0D, 0.0D, 0.0D, 0.0D));
    localXYPlot.setInsets(new RectangleInsets(0.0D, 0.0D, 0.0D, 0.0D), true);
}

From source file:wattsup.jsdk.ui.ChartPanelSupport.java

/**
 * Clean the values of the chart./*from www.  j a  va  2  s .c om*/
 * 
 * @see #createChart()
 */
public void cleanChart() {
    this.chart_.removeLegend();
    this.chartPanel_.setBorder(null);

    cleanLabels();

    DateAxis localDateAxis = (DateAxis) ((XYPlot) this.chart_.getPlot()).getDomainAxis();
    localDateAxis.setTickLabelsVisible(false);
    localDateAxis.setTickMarksVisible(false);
    localDateAxis.setAxisLineVisible(false);

    ValueAxis localValueAxis = ((XYPlot) this.chart_.getPlot()).getRangeAxis();
    localValueAxis.setTickLabelsVisible(false);
    localValueAxis.setTickMarksVisible(false);
    localValueAxis.setAxisLineVisible(false);

    XYPlot localXYPlot = (XYPlot) this.chart_.getPlot();
    localXYPlot.setDomainGridlineStroke(this.defaultLineStroke_);
    localXYPlot.setDomainGridlinesVisible(true);
    localXYPlot.setRangeGridlineStroke(this.defaultLineStroke_);
    localXYPlot.setRangeGridlinesVisible(true);

    localXYPlot.setAxisOffset(new RectangleInsets(0.0D, 0.0D, 0.0D, 0.0D));
    localXYPlot.setInsets(new RectangleInsets(0.0D, 0.0D, 0.0D, 0.0D), true);
}

From source file:net.sf.profiler4j.console.AllocDiffPanel.java

public AllocDiffPanel(int maxAgeMillis) {
    super(new BorderLayout());

    totalSeries = new TimeSeries("Allocs/Sec", Millisecond.class);
    totalSeries.setMaximumItemAge(maxAgeMillis);

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    seriesCollection.addSeries(totalSeries);

    NumberAxis numberAxis = new NumberAxis("Allocs/Sec");
    numberAxis.setLabelFont(new Font("SansSerif", 0, 14));
    numberAxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    DateAxis dateAxis = new DateAxis("Time");
    dateAxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    dateAxis.setLabelFont(new Font("SansSerif", 0, 14));
    dateAxis.setAutoRange(true);//  ww  w .  j a  v  a2 s.  c  o m
    dateAxis.setLowerMargin(0);
    dateAxis.setUpperMargin(0);
    dateAxis.setTickLabelsVisible(true);
    dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));

    XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false);
    lineRenderer.setSeriesPaint(0, Color.RED);
    lineRenderer.setSeriesPaint(1, Color.GREEN.darker());
    lineRenderer.setStroke(new BasicStroke(2F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

    XYPlot xyplot = new XYPlot(seriesCollection, dateAxis, numberAxis, lineRenderer);
    xyplot.setBackgroundPaint(Color.WHITE);
    xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));

    JFreeChart chart = new JFreeChart("Object Allocactions in Remote JVM",
            new Font("SansSerif", Font.PLAIN, 18), xyplot, true);
    chart.setBackgroundPaint(Color.white);

    ChartPanel panel = new ChartPanel(chart);
    panel.setBorder(createCompoundBorder(createEmptyBorder(8, 8, 8, 8), createLineBorder(Color.LIGHT_GRAY)));
    add(panel);
    setBorder(createEmptyBorder(8, 8, 8, 8));
}