org.jfree.data.general.DatasetUtils Java Examples

The following examples show how to use org.jfree.data.general.DatasetUtils. 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: CrosshairOverlayFXDemo1.java    From jfree-fxdemos with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void chartMouseMoved(ChartMouseEventFX event) {
    Rectangle2D dataArea = this.chartViewer.getCanvas().getRenderingInfo().getPlotInfo().getDataArea();
    JFreeChart chart = event.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();
    ValueAxis xAxis = plot.getDomainAxis();
    double x = xAxis.java2DToValue(event.getTrigger().getX(), dataArea, 
            RectangleEdge.BOTTOM);
    // make the crosshairs disappear if the mouse is out of range
    if (!xAxis.getRange().contains(x)) { 
        x = Double.NaN;                  
    }
    double y = DatasetUtils.findYValue(plot.getDataset(), 0, x);
    this.xCrosshair.setValue(x);
    this.yCrosshair.setValue(y);
}
 
Example #2
Source File: MsMsPlot.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void mouseClicked(final MouseEvent event) {

  // Let the parent handle the event (selection etc.)
  super.mouseClicked(event);

  if (event.getX() < 70) { // User clicked on Y-axis
    if (event.getClickCount() == 2) { // Reset zoom on Y-axis
      XYDataset data = ((XYPlot) getChart().getPlot()).getDataset();
      Number maximum = DatasetUtils.findMaximumRangeValue(data);
      getXYPlot().getRangeAxis().setRange(0, 1.05 * maximum.floatValue());
    } else if (event.getClickCount() == 1) {
      // Auto range on Y-axis
      getXYPlot().getRangeAxis().setAutoTickUnitSelection(true);
      getXYPlot().getRangeAxis().setAutoRange(true);
    }
  } else if (event.getY() > this.getChartRenderingInfo().getPlotInfo().getPlotArea().getMaxY()
      - 41 && event.getClickCount() == 2) {
    // Reset zoom on X-axis
    getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
    restoreAutoDomainBounds();
  } else if (event.getClickCount() == 2) {
    visualizer.actionPerformed(
        new ActionEvent(event.getSource(), ActionEvent.ACTION_PERFORMED, "SHOW_SPECTRUM"));
  }
}
 
Example #3
Source File: TICPlot.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public void mouseClicked(final MouseEvent event) {

    // Let the parent handle the event (selection etc.)
    // super.mouseClicked(event);

    // Request focus to receive key events.
    requestFocus();

    // Handle mouse click events
    if (event.getButton() == MouseEvent.BUTTON1) {

      System.out.println("mouse " + event);
      if (event.getX() < 70) { // User clicked on Y-axis
        if (event.getClickCount() == 2) { // Reset zoom on Y-axis
          XYDataset data = ((XYPlot) getChart().getPlot()).getDataset();
          Number maximum = DatasetUtils.findMaximumRangeValue(data);
          getXYPlot().getRangeAxis().setRange(0, 1.05 * maximum.floatValue());
        } else if (event.getClickCount() == 1) { // Auto range on Y-axis
          getXYPlot().getRangeAxis().setAutoTickUnitSelection(true);
          getXYPlot().getRangeAxis().setAutoRange(true);
        }
      } else if (event.getY() > this.getRenderingInfo().getPlotInfo().getPlotArea().getMaxY() - 41
          && event.getClickCount() == 2) {
        // Reset zoom on X-axis
        getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
        // restoreAutoDomainBounds();
      } else if (event.getClickCount() == 2) { // If user double-clicked
        // left button, place a
        // request to open a
        // spectrum.
        showSpectrumRequest = true;
      }
    }

  }
 
Example #4
Source File: XYBlockPixelSizeRenderer.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the lower and upper bounds (range) of the x-values in the specified dataset.
 *
 * @param dataset the dataset ({@code null} permitted).
 *
 * @return The range ({@code null} if the dataset is {@code null} or empty).
 *
 * @see #findRangeBounds(XYDataset)
 */
@Override
public Range findDomainBounds(XYDataset dataset) {
  if (dataset == null) {
    return null;
  }
  Range r = DatasetUtils.findDomainBounds(dataset, false);
  if (r == null) {
    return null;
  }
  return new Range(r.getLowerBound() + this.xOffset,
      r.getUpperBound() + this.blockWidth + this.xOffset);
}
 
Example #5
Source File: XYBlockPixelSizeRenderer.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the range of values the renderer requires to display all the items from the specified
 * dataset.
 *
 * @param dataset the dataset ({@code null} permitted).
 *
 * @return The range ({@code null} if the dataset is {@code null} or empty).
 *
 * @see #findDomainBounds(XYDataset)
 */
@Override
public Range findRangeBounds(XYDataset dataset) {
  if (dataset != null) {
    Range r = DatasetUtils.findRangeBounds(dataset, false);
    if (r == null) {
      return null;
    } else {
      return new Range(r.getLowerBound() + this.yOffset,
          r.getUpperBound() + this.blockHeight + this.yOffset);
    }
  } else {
    return null;
  }
}
 
Example #6
Source File: TICPlot.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void mouseClicked(final MouseEvent event) {

  // Let the parent handle the event (selection etc.)
  super.mouseClicked(event);

  // Request focus to receive key events.
  requestFocus();

  // Handle mouse click events
  if (event.getButton() == MouseEvent.BUTTON1) {

    if (event.getX() < 70) { // User clicked on Y-axis
      if (event.getClickCount() == 2) { // Reset zoom on Y-axis
        XYDataset data = ((XYPlot) getChart().getPlot()).getDataset();
        Number maximum = DatasetUtils.findMaximumRangeValue(data);
        getXYPlot().getRangeAxis().setRange(0, 1.05 * maximum.floatValue());
      } else if (event.getClickCount() == 1) { // Auto range on Y-axis
        getXYPlot().getRangeAxis().setAutoTickUnitSelection(true);
        getXYPlot().getRangeAxis().setAutoRange(true);
      }
    } else if (event.getY() > this.getChartRenderingInfo().getPlotInfo().getPlotArea().getMaxY()
        - 41 && event.getClickCount() == 2) {
      // Reset zoom on X-axis
      getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
      restoreAutoDomainBounds();
    } else if (event.getClickCount() == 2) { // If user double-clicked
      // left button, place a
      // request to open a
      // spectrum.
      showSpectrumRequest = true;
    }
  }

}
 
Example #7
Source File: XYBlockPixelSizeRenderer.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the lower and upper bounds (range) of the x-values in the specified dataset.
 *
 * @param dataset the dataset ({@code null} permitted).
 *
 * @return The range ({@code null} if the dataset is {@code null} or empty).
 *
 * @see #findRangeBounds(XYDataset)
 */
@Override
public Range findDomainBounds(XYDataset dataset) {
  if (dataset == null) {
    return null;
  }
  Range r = DatasetUtils.findDomainBounds(dataset, false);
  if (r == null) {
    return null;
  }
  return new Range(r.getLowerBound() + this.xOffset,
      r.getUpperBound() + this.blockWidth + this.xOffset);
}
 
Example #8
Source File: XYBlockPixelSizeRenderer.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the range of values the renderer requires to display all the items from the specified
 * dataset.
 *
 * @param dataset the dataset ({@code null} permitted).
 *
 * @return The range ({@code null} if the dataset is {@code null} or empty).
 *
 * @see #findDomainBounds(XYDataset)
 */
@Override
public Range findRangeBounds(XYDataset dataset) {
  if (dataset != null) {
    Range r = DatasetUtils.findRangeBounds(dataset, false);
    if (r == null) {
      return null;
    } else {
      return new Range(r.getLowerBound() + this.yOffset,
          r.getUpperBound() + this.blockHeight + this.yOffset);
    }
  } else {
    return null;
  }
}