Java Code Examples for org.jfree.chart.title.LegendTitle#setVisible()

The following examples show how to use org.jfree.chart.title.LegendTitle#setVisible() . 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: HistogramPanel.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Toggles visibility of legends
 */
private void toggleLegends() {
  if (pnHisto != null) {
    LegendTitle legend = pnHisto.getChart().getLegend();
    if (legend != null) {
      legend.setVisible(!legend.isVisible());
    }
  }
}
 
Example 2
Source File: HistogramPanel.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Toggles visibility of legends
 */
private void toggleLegends() {
  if (pnHisto != null) {
    LegendTitle legend = pnHisto.getChart().getLegend();
    if (legend != null)
      legend.setVisible(!legend.isVisible());
  }
}
 
Example 3
Source File: EStandardChartTheme.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Fixes the legend item's colour after the colours of the datasets/series in the plot were
 * changed.
 * 
 * @param chart The chart.
 */
public static void fixLegend(JFreeChart chart) {
  XYPlot plot = chart.getXYPlot();
  LegendTitle oldLegend = chart.getLegend();
  RectangleEdge pos = oldLegend.getPosition();
  chart.removeLegend();
  
  LegendTitle newLegend = new LegendTitle(plot);
  newLegend.setPosition(pos);
  newLegend.setItemFont(oldLegend.getItemFont());
  chart.addLegend(newLegend);
  newLegend.setVisible(oldLegend.isVisible());
}
 
Example 4
Source File: TICPlot.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public void switchLegendVisible() {
  // Toggle legend visibility.
  final LegendTitle legend = getChart().getLegend();
  legend.setVisible(!legend.isVisible());

}
 
Example 5
Source File: KendrickMassPlotTask.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
  setStatus(TaskStatus.PROCESSING);
  logger.info("Create Kendrick mass plot of " + peakList);
  // Task canceled?
  if (isCanceled())
    return;

  JFreeChart chart = null;
  // 2D, if no third dimension was selected
  if (zAxisLabel.equals("none")) {
    chart = create2DKendrickMassPlot();
  }
  // 3D, if a third dimension was selected
  else {
    chart = create3DKendrickMassPlot();
  }
  chart.setBackgroundPaint(Color.white);

  // create chart JPanel
  EChartPanel chartPanel = new EChartPanel(chart, true, true, true, true, false);

  // Create Kendrick mass plot Window
  KendrickMassPlotWindow frame = new KendrickMassPlotWindow(chart, parameters, chartPanel);
  frame.add(chartPanel, BorderLayout.CENTER);

  // set title properties
  TextTitle chartTitle = chart.getTitle();
  chartTitle.setMargin(5, 0, 0, 0);
  chartTitle.setFont(titleFont);
  LegendTitle legend = chart.getLegend();
  legend.setVisible(false);
  frame.setTitle(title);
  frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  frame.setBackground(Color.white);
  frame.setVisible(true);
  frame.pack();

  setStatus(TaskStatus.FINISHED);
  logger.info("Finished creating Kendrick mass plot of " + peakList);
}
 
Example 6
Source File: VanKrevelenDiagramTask.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
  try {
    setStatus(TaskStatus.PROCESSING);
    logger.info("Create Van Krevelen diagram of " + peakList);
    // Task canceled?
    if (isCanceled())
      return;
    JFreeChart chart = null;
    // 2D, if no third dimension was selected
    if (zAxisLabel.equals("none")) {
      chart = create2DVanKrevelenDiagram();
    }
    // 3D, if a third dimension was selected
    else {
      chart = create3DVanKrevelenDiagram();
    }

    chart.setBackgroundPaint(Color.white);

    // create chart JPanel
    EChartPanel chartPanel = new EChartPanel(chart, true, true, true, true, false);

    // Create Van Krevelen Diagram window
    VanKrevelenDiagramWindow frame =
        new VanKrevelenDiagramWindow(chart, chartPanel, filteredRows);

    // create chart JPanel
    frame.add(chartPanel, BorderLayout.CENTER);

    // set title properties
    TextTitle chartTitle = chart.getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);
    LegendTitle legend = chart.getLegend();
    legend.setVisible(false);
    frame.setTitle(title);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setBackground(Color.white);
    frame.setVisible(true);
    frame.pack();
    logger.info("Finished creating van Krevelen diagram of " + peakList);
    JOptionPane.showMessageDialog(frame, "Results summary:\n" + displayedFeatures
        + " feature list rows are displayed in the Van Krevelen diagram.\n"
        + featuresWithFormulasWithoutCHO
        + " feature list rows are not displayed, because the annotated molecular formula does not contain the elements C, H, and O.\n"
        + featuresWithoutFormula
        + " feature list rows are not displayed, because no molecular formula was assigned.");
    setStatus(TaskStatus.FINISHED);
  } catch (Throwable t) {
    setErrorMessage(
        "Nothing to plot here or some peaks have other identities than molecular formulas.\n"
            + "Have you annotated your features with molecular formulas?\n"
            + "You can use the feature list method \"Formula prediction\" to handle the task.");
    setStatus(TaskStatus.ERROR);
  }
}