Java Code Examples for org.jfree.chart.renderer.xy.XYBarRenderer#setDefaultShadowsVisible()

The following examples show how to use org.jfree.chart.renderer.xy.XYBarRenderer#setDefaultShadowsVisible() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChartJFreeChartOutputHistogram.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public static void enableFlatLook(final boolean flat) {
	if (flat) {
		BarRenderer.setDefaultBarPainter(new StandardBarPainter());
		BarRenderer.setDefaultShadowsVisible(false);
		XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter());
		XYBarRenderer.setDefaultShadowsVisible(false);
		StackedBarRenderer.setDefaultBarPainter(new StandardBarPainter());
		StackedBarRenderer.setDefaultShadowsVisible(false);
	} else {
		BarRenderer.setDefaultBarPainter(new GradientBarPainter());
		BarRenderer.setDefaultShadowsVisible(true);
		XYBarRenderer.setDefaultBarPainter(new GradientXYBarPainter());
		XYBarRenderer.setDefaultShadowsVisible(true);
		StackedBarRenderer.setDefaultBarPainter(new GradientBarPainter());
		StackedBarRenderer.setDefaultShadowsVisible(true);
	}
}
 
Example 2
Source File: Chart.java    From freeacs with MIT License 4 votes vote down vote up
/**
 * All params can be null.
 *
 * @param min - the minimum number on the left range axis (must be set if max is set)
 * @param max - the maximum number on the left range axis (must be set if min is set)
 * @param method2 - the method to run out of Record, and populates a bar series (right range axis)
 * @param highLightIndex - the index to highlight
 * @return
 * @throws Exception
 */
public JFreeChart makeTimeChart(Double min, Double max, String method2, Integer highLightIndex)
    throws Exception {
  startTms = System.currentTimeMillis();
  endTms = 0;
  XYBarRenderer.setDefaultShadowsVisible(false);
  TimeSeriesCollection data = new TimeSeriesCollection();
  Map<String, TimeSeries> timeSeriesMap = makeTimeSeriesMap(method, recordMap, keyNames);
  for (TimeSeries timeSeries : timeSeriesMap.values()) {
    data.addSeries(timeSeries);
  }
  String yAxisLabel = method;
  String denominator = Record.getDenominator(report.getRecordClass(), method.toLowerCase());
  if (denominator != null) {
    yAxisLabel += " (" + denominator + ")";
  }
  chart = ChartFactory.createTimeSeriesChart(title, "Time", yAxisLabel, data, true, true, true);
  XYPlot plot = (XYPlot) chart.getPlot();
  if (method2 != null) {
    Map<Key, R> recordMap2 = recordMap;
    TimeSeriesCollection data2 = new TimeSeriesCollection();
    if (keyNames.length > 0) {
      recordMap2 = report.getMapAggregatedOn();
    }
    Map<String, TimeSeries> timeSeriesMap2 = makeTimeSeriesMap(method2, recordMap2);
    if (timeSeriesMap2.get("Total (" + method2 + ")") != null) {
      data2.addSeries(timeSeriesMap2.get("Total (" + method2 + ")"));
    }
    String y2AxisLabel = method2;
    String demoninator2 = Record.getDenominator(report.getRecordClass(), method2.toLowerCase());
    if (demoninator2 != null) {
      y2AxisLabel += " (" + demoninator2 + ")";
    }
    NumberAxis axis2 = new NumberAxis(y2AxisLabel);
    XYBarRenderer renderer2 = new XYBarRenderer(0.20);
    plot.setRangeAxis(1, axis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);
    plot.setDataset(1, data2);
    plot.setRenderer(1, renderer2);
    plot.mapDatasetToRangeAxis(1, 1);
    renderer2.setBarPainter(new StandardXYBarPainter());
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
  }
  if (min != null && max != null) {
    plot.getRangeAxis(0).setRange(min, max);
  }

  if (highLightIndex != null) {
    chart.getXYPlot().getRenderer().setSeriesStroke(highLightIndex, new BasicStroke(5f));
  }

  XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
  renderer.setDefaultShapesVisible(true);
  renderer.setUseFillPaint(true);
  renderer.setDefaultFillPaint(Color.white);

  long diff = endTms - startTms;
  String format;
  if (diff > NINTY_DAYS) {
    format = "MMM-yyyy";
  } else if (diff > TWO_DAYS) {
    format = "dd-MMM";
  } else if (diff > TWO_MINUTES) {
    format = "HH:mm";
  } else {
    format = "HH:mm:ss";
  }
  DateAxis axis = (DateAxis) plot.getDomainAxis();
  axis.setDateFormatOverride(new SimpleDateFormat(format));

  LegendTitle lt = chart.getLegend(0);
  lt.setPosition(RectangleEdge.RIGHT);

  if (displayFrame) {
    ChartFrame frame = new ChartFrame(title, chart);
    frame.pack();
    frame.setVisible(true);
  }

  return chart;
}