org.jfree.chart.JFreeChart.removeLegend()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(13.4k)|赞(0)|评价(0)|浏览(216)

本文整理了Java中org.jfree.chart.JFreeChart.removeLegend()方法的一些代码示例,展示了JFreeChart.removeLegend()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFreeChart.removeLegend()方法的具体详情如下:
包路径:org.jfree.chart.JFreeChart
类名称:JFreeChart
方法名:removeLegend

JFreeChart.removeLegend介绍

[英]Removes the first legend in the chart and sends a ChartChangeEvent to all registered listeners.
[中]删除图表中的第一个图例,并向所有注册的侦听器发送ChartChangeEvent。

代码示例

代码示例来源:origin: graphhopper/jsprit

private BufferedImage plot(VehicleRoutingProblem vrp, final Collection<VehicleRoute> routes, String pngFile, String title) {
  log.info("plot to {}", pngFile);
  XYSeriesCollection problem;
  XYSeriesCollection solution = null;
  final XYSeriesCollection shipments;
  try {
    retrieveActivities(vrp);
    problem = new XYSeriesCollection(activities);
    shipments = makeShipmentSeries(vrp.getJobs().values());
    if (routes != null) solution = makeSolutionSeries(vrp, routes);
  } catch (NoLocationFoundException e) {
    log.warn("cannot plot vrp, since coord is missing");
    return null;
  }
  final XYPlot plot = createPlot(problem, shipments, solution);
  JFreeChart chart = new JFreeChart(title, plot);
  LegendTitle legend = createLegend(routes, shipments, plot);
  chart.removeLegend();
  chart.addLegend(legend);
  save(chart, pngFile);
  return chart.createBufferedImage(1024, 1024);
}

代码示例来源:origin: stackoverflow.com

JFreeChart chart = // your chart 
chart.removeLegend();
LegendTitle legend = new LegendTitle(new LineLegendItemSource());
chart.addLegend(legend);

代码示例来源:origin: org.n52.sensorweb/sensorwebclient-api

public String createChart(DesignOptions options, ChartRenderingInfo renderingInfo) throws Exception {
  Map<String, OXFFeatureCollection> entireCollMap = getFeatureCollectionFor(options, true);
  JFreeChart chart = producePresentation(entireCollMap, options);
  chart.removeLegend();
  
  String chartFileName = createAndSaveImage(options, chart, renderingInfo);
  return ConfigurationContext.IMAGE_SERVICE + chartFileName; 
}

代码示例来源:origin: net.sourceforge.jadex/jadex-tools-comanalyzer

/**
 * @param showLegend <code>true</code> if the legend is to be shown.
 */
public void setShowLegend(boolean showLegend)
{
  this.showLegend = showLegend;
  if(showLegend)
  {
    chart.addLegend(createLegend(chart.getPlot()));
  }
  else
  {
    chart.removeLegend();
  }
}

代码示例来源:origin: org.codehaus.sonar/sonar-deprecated

private void improveChart(JFreeChart jfrechart, ChartParameters params) {
 Color background = Color.decode("#" + params.getValue(ChartParameters.PARAM_BACKGROUND_COLOR, "FFFFFF", false));
 jfrechart.setBackgroundPaint(background);
 jfrechart.setBorderVisible(false);
 jfrechart.setAntiAlias(true);
 jfrechart.setTextAntiAlias(true);
 jfrechart.removeLegend();
}

代码示例来源:origin: org.n52.sensorweb/sensorwebclient-api

public void createChartToOutputStream(DesignOptions options,
    ChartRenderingInfo renderingInfo, OutputStream outputStream) {
  try {
    Map<String, OXFFeatureCollection> entireCollMap = getFeatureCollectionFor(options, true);
    JFreeChart chart = producePresentation(entireCollMap, options);
    chart.removeLegend();
    int width = options.getWidth();
    int height = options.getHeight();
    ChartUtilities.writeChartAsPNG(outputStream, chart, width, height, renderingInfo);
  } catch (Exception e) {
    LOGGER.warn("Error while rendering chart.", e);
  }
}

代码示例来源:origin: jfree/jfreechart

/**
 * Creates a new plot.
 *
 * @param dataset  the dataset ({@code null} permitted).
 */
public MultiplePiePlot(CategoryDataset dataset) {
  super();
  setDataset(dataset);
  PiePlot piePlot = new PiePlot(null);
  piePlot.setIgnoreNullValues(true);
  this.pieChart = new JFreeChart(piePlot);
  this.pieChart.removeLegend();
  this.dataExtractOrder = TableOrder.BY_COLUMN;
  this.pieChart.setBackgroundPaint(null);
  TextTitle seriesTitle = new TextTitle("Series Title",
      new Font("SansSerif", Font.BOLD, 12));
  seriesTitle.setPosition(RectangleEdge.BOTTOM);
  this.pieChart.setTitle(seriesTitle);
  this.aggregatedItemsKey = "Other";
  this.aggregatedItemsPaint = Color.lightGray;
  this.sectionPaints = new HashMap();
  this.legendItemShape = new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0);
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-chart

/**
 * Creates a new plot.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 */
public MultiplePiePlot(CategoryDataset dataset) {
  super();
  setDataset(dataset);
  PiePlot piePlot = new PiePlot(null);
  piePlot.setIgnoreNullValues(true);
  this.pieChart = new JFreeChart(piePlot);
  this.pieChart.removeLegend();
  this.dataExtractOrder = TableOrder.BY_COLUMN;
  this.pieChart.setBackgroundPaint(null);
  TextTitle seriesTitle = new TextTitle("Series Title",
      new Font("SansSerif", Font.BOLD, 12));
  seriesTitle.setPosition(RectangleEdge.BOTTOM);
  this.pieChart.setTitle(seriesTitle);
  this.aggregatedItemsKey = "Other";
  this.aggregatedItemsPaint = Color.lightGray;
  this.sectionPaints = new HashMap();
  this.legendItemShape = new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0);
}

代码示例来源:origin: senbox-org/snap-desktop

private void setLegend(JFreeChart chart) {
  chart.removeLegend();
  final LegendTitle legend = new LegendTitle(new SpectrumLegendItemSource());
  legend.setPosition(RectangleEdge.BOTTOM);
  LineBorder border = new LineBorder(Color.BLACK, new BasicStroke(), new RectangleInsets(2, 2, 2, 2));
  legend.setFrame(border);
  chart.addLegend(legend);
}

代码示例来源:origin: bcdev/beam

private void setLegend(JFreeChart chart) {
  chart.removeLegend();
  final LegendTitle legend = new LegendTitle(new SpectrumLegendItemSource());
  legend.setPosition(RectangleEdge.BOTTOM);
  LineBorder border = new LineBorder(Color.BLACK, new BasicStroke(), new RectangleInsets(2, 2, 2, 2));
  legend.setFrame(border);
  chart.addLegend(legend);
}

代码示例来源:origin: jenkinsci/build-failure-analyzer-plugin

@Override
protected JFreeChart createGraph() {
  TimeTableXYDataset dataset = createDataset();
  ValueAxis xAxis = new DateAxis();
  xAxis.setLowerMargin(0.0);
  xAxis.setUpperMargin(0.0);
  Calendar lowerBound = getLowerGraphBound();
  xAxis.setRange(lowerBound.getTimeInMillis(), Calendar.getInstance().getTimeInMillis());
  NumberAxis yAxis = new NumberAxis(Y_AXIS_LABEL);
  yAxis.setRange(0, HUNDRED_PERCENT);
  XYItemRenderer renderer = new XYBarRenderer();
  XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
  JFreeChart chart = new JFreeChart(graphTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
  chart.removeLegend();
  return chart;
}

代码示例来源:origin: com.graphhopper/jsprit-analysis

private void plot(VehicleRoutingProblem vrp, final Collection<VehicleRoute> routes, String pngFile, String title) {
  log.info("plot to {}", pngFile);
  XYSeriesCollection problem;
  XYSeriesCollection solution = null;
  final XYSeriesCollection shipments;
  try {
    retrieveActivities(vrp);
    problem = new XYSeriesCollection(activities);
    shipments = makeShipmentSeries(vrp.getJobs().values());
    if (routes != null) solution = makeSolutionSeries(vrp, routes);
  } catch (NoLocationFoundException e) {
    log.warn("cannot plot vrp, since coord is missing");
    return;
  }
  final XYPlot plot = createPlot(problem, shipments, solution);
  JFreeChart chart = new JFreeChart(title, plot);
  LegendTitle legend = createLegend(routes, shipments, plot);
  chart.removeLegend();
  chart.addLegend(legend);
  save(chart, pngFile);
}

代码示例来源:origin: stackoverflow.com

private static JFreeChart createChart() {
  CombinedDomainXYPlot localCombinedDomainXYPlot = new CombinedDomainXYPlot(new DateAxis("Time"));

  JFreeChart localJFreeChart = new JFreeChart("Sample", localCombinedDomainXYPlot);
  localCombinedDomainXYPlot.add(createSubplot1(createDataset1()), 1);
  ChartUtilities.applyCurrentTheme(localJFreeChart);
  localJFreeChart.setBackgroundPaint(Color.white);

  final LegendItemCollection legendItemsOld = localCombinedDomainXYPlot.getLegendItems();
  LegendItemSource source = new LegendItemSource() {
   public LegendItemCollection getLegendItems() {
     LegendItemCollection lic = new LegendItemCollection();
     int itemCount = legendItemsOld.getItemCount();
     for (int i = 0; i < itemCount; i++) {
      lic.add(legendItemsOld.get(i));
     }
     return lic;
   }
  };
  localJFreeChart.removeLegend();
  localJFreeChart.addLegend(new LegendTitle(source));
  localJFreeChart.getLegend().setPosition(RectangleEdge.TOP);
  localJFreeChart.getLegend().getItemContainer().getBlocks();

  return localJFreeChart;
}

代码示例来源:origin: MegaMek/mekhq

private JFreeChart createAmountChart(XYDataset dataset) {
  JFreeChart chart = ChartFactory.createTimeSeriesChart(
    "", // title
    resourceMap.getString("graphDate.text"), // x-axis label
    resourceMap.getString("graphCBills.text"), // y-axis label
    dataset);
  chart.setBackgroundPaint(Color.WHITE);
  XYPlot plot = (XYPlot) chart.getPlot();
  plot.setBackgroundPaint(Color.LIGHT_GRAY);
  plot.setDomainGridlinePaint(Color.WHITE);
  plot.setRangeGridlinePaint(Color.WHITE);
  plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
  plot.setDomainCrosshairVisible(true);
  plot.setRangeCrosshairVisible(true);
  XYItemRenderer r = plot.getRenderer();
  if (r instanceof XYLineAndShapeRenderer) {
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
    renderer.setDefaultShapesVisible(true);
    renderer.setDefaultShapesFilled(true);
    renderer.setDrawSeriesLineAsPath(true);
  }
  DateAxis axis = (DateAxis) plot.getDomainAxis();
  axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
  
  chart.removeLegend();
  return chart;
}

代码示例来源:origin: inspectIT/inspectIT

chart.removeLegend();

代码示例来源:origin: org.renci/charts

public JFreeChart createStackedBarChart(String title, XYDataset dataset) {
  DateAxis domainAxis = new DateAxis("Date");
  domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
  domainAxis.setLowerMargin(0.01);
  domainAxis.setUpperMargin(0.01);
  NumberAxis rangeAxis = new NumberAxis("Hours");
  rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
  rangeAxis.setUpperMargin(0.10); // leave some space for item labels
  StackedXYBarRenderer renderer = new StackedXYBarRenderer(0.15);
  // StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
  renderer.setDrawBarOutline(false);
  renderer.setBaseItemLabelsVisible(true);
  renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
  renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
      TextAnchor.BOTTOM_CENTER));
  renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} : {1} = {2}",
      new SimpleDateFormat("yyyy"), new DecimalFormat("0")));
  XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, renderer);
  JFreeChart chart = new JFreeChart(title, plot);
  chart.removeLegend();
  chart.setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
  LegendTitle legend = new LegendTitle(plot);
  legend.setBackgroundPaint(Color.white);
  legend.setFrame(new BlockBorder());
  legend.setPosition(RectangleEdge.BOTTOM);
  chart.addSubtitle(legend);
  return chart;
}

代码示例来源:origin: jfree/eastwood

/**
 * Creates a sparkline chart.
 *
 * @return A sparkline chart.
 */
private static JFreeChart createSparklineChart() {
  GXYPlot plot = new GXYPlot();
  plot.setInsets(RectangleInsets.ZERO_INSETS);
  XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
  renderer.setBaseShapesVisible(false);
  plot.setRenderer(renderer);
  JFreeChart chart = new JFreeChart(plot);
  chart.setPadding(RectangleInsets.ZERO_INSETS);
  chart.removeLegend();
  chart.setBackgroundPaint(Color.white);
  renderer.setBasePaint(new Color(0xFF9900));
  renderer.setBaseStroke(new BasicStroke(1.5f, BasicStroke.CAP_ROUND,
      BasicStroke.JOIN_ROUND));
  renderer.setAutoPopulateSeriesPaint(false);
  GValueAxis xAxis = new GValueAxis();
  xAxis.setVisible(false);
  plot.setDomainAxis(xAxis);
  GValueAxis yAxis = new GValueAxis();
  yAxis.setVisible(false);
  plot.setRangeAxis(yAxis);
  plot.setDomainGridlinesVisible(false);
  plot.setRangeGridlinesVisible(false);
  return chart;
}

代码示例来源:origin: dhis2/dhis2-core

private JFreeChart getGaugeChart( BaseChart chart, ValueDataset dataSet )
{
  MeterPlot meterPlot = new MeterPlot( dataSet );
  meterPlot.setUnits( "" );
  meterPlot.setRange( new Range( 0.0d, 100d ) );
  for ( int i = 0; i < 10; i++ )
  {
    double start = i * 10d;
    double end = start + 10d;
    String label = String.valueOf( start );
    meterPlot.addInterval( new MeterInterval( label, new Range( start, end ), COLOR_LIGHT_GRAY, null, COLOR_LIGHT_GRAY ) );
  }
  meterPlot.setMeterAngle(180);
  meterPlot.setDialBackgroundPaint( COLOR_LIGHT_GRAY );
  meterPlot.setDialShape( DialShape.CHORD );
  meterPlot.setNeedlePaint( COLORS[0] );
  meterPlot.setTickLabelsVisible( true );
  meterPlot.setTickLabelFont( LABEL_FONT );
  meterPlot.setTickLabelPaint( Color.BLACK );
  meterPlot.setTickPaint( COLOR_LIGHTER_GRAY );
  meterPlot.setValueFont( TITLE_FONT );
  meterPlot.setValuePaint( Color.BLACK );
  JFreeChart meterChart = new JFreeChart( chart.getName(), meterPlot );
  setBasicConfig( meterChart, chart );
  meterChart.removeLegend();
  return meterChart;
}

代码示例来源:origin: bcdev/beam

private void createUI() {
  plot = new XYImagePlot();
  plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
  NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
  NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
  domainAxis.setAutoRangeIncludesZero(false);
  rangeAxis.setAutoRangeIncludesZero(false);
  domainAxis.setUpperMargin(0);
  domainAxis.setLowerMargin(0);
  rangeAxis.setUpperMargin(0);
  rangeAxis.setLowerMargin(0);
  plot.setNoDataMessage(NO_DATA_MESSAGE);
  plot.getRenderer().setBaseToolTipGenerator(new XYPlotToolTipGenerator());
  JFreeChart chart = new JFreeChart(CHART_TITLE, plot);
  ChartFactory.getChartTheme().apply(chart);
  chart.removeLegend();
  createUI(createChartPanel(chart), createOptionsPanel(), bindingContext);
  updateUIState();
}

代码示例来源:origin: senbox-org/snap-desktop

private void createUI() {
  plot = new XYImagePlot();
  plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
  NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
  NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
  domainAxis.setAutoRangeIncludesZero(false);
  rangeAxis.setAutoRangeIncludesZero(false);
  domainAxis.setUpperMargin(0);
  domainAxis.setLowerMargin(0);
  rangeAxis.setUpperMargin(0);
  rangeAxis.setLowerMargin(0);
  plot.setNoDataMessage(NO_DATA_MESSAGE);
  plot.getRenderer().setBaseToolTipGenerator(new XYPlotToolTipGenerator());
  JFreeChart chart = new JFreeChart(CHART_TITLE, plot);
  ChartFactory.getChartTheme().apply(chart);
  chart.removeLegend();
  createUI(createChartPanel(chart), createOptionsPanel(), bindingContext);
  updateUIState();
}

相关文章