Java Code Examples for org.jfree.chart.ChartPanel#getScaleX()

The following examples show how to use org.jfree.chart.ChartPanel#getScaleX() . 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: ChartLogics.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY...
 * 
 * @param chart
 * @param mx mouse coordinates
 * @param my mouse coordinates
 * @return
 */
public static ChartEntity findChartEntity(ChartPanel chart, double mx, double my) {
  // TODO check if insets were needed
  // coordinates to find chart entities
  Insets insets = chart.getInsets();
  int x = (int) ((mx - insets.left) / chart.getScaleX());
  int y = (int) ((my - insets.top) / chart.getScaleY());

  ChartRenderingInfo info = chart.getChartRenderingInfo();
  ChartEntity entity = null;
  if (info != null) {
    EntityCollection entities = info.getEntityCollection();
    if (entities != null) {
      entity = entities.getEntity(x, y);
    }
  }
  return entity;
}
 
Example 2
Source File: ChartGestureMouseAdapter.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY...
 * 
 * @param chartPanel
 * @param x
 * @param y
 * @return
 */
private ChartEntity findChartEntity(ChartPanel chartPanel, MouseEvent e) {
  // coordinates to find chart entities
  Insets insets = chartPanel.getInsets();
  int x = (int) ((e.getX() - insets.left) / chartPanel.getScaleX());
  int y = (int) ((e.getY() - insets.top) / chartPanel.getScaleY());

  if (lastEntity != null && x == lastEntityX && y == lastEntityY)
    return lastEntity;
  else {
    ChartRenderingInfo info = chartPanel.getChartRenderingInfo();
    ChartEntity entity = null;
    if (info != null) {
      EntityCollection entities = info.getEntityCollection();
      if (entities != null) {
        entity = entities.getEntity(x, y);
      }
    }
    return entity;
  }
}
 
Example 3
Source File: ChartLogics.java    From old-mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY...
 * 
 * @param chart
 * @param mx mouse coordinates
 * @param my mouse coordinates
 * @return
 */
public static ChartEntity findChartEntity(ChartPanel chart, double mx, double my) {
  // TODO check if insets were needed
  // coordinates to find chart entities
  Insets insets = chart.getInsets();
  int x = (int) ((mx - insets.left) / chart.getScaleX());
  int y = (int) ((my - insets.top) / chart.getScaleY());

  ChartRenderingInfo info = chart.getChartRenderingInfo();
  ChartEntity entity = null;
  if (info != null) {
    EntityCollection entities = info.getEntityCollection();
    if (entities != null) {
      entity = entities.getEntity(x, y);
    }
  }
  return entity;
}
 
Example 4
Source File: ChartGestureMouseAdapter.java    From old-mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY...
 * 
 * @param chartPanel
 * @param x
 * @param y
 * @return
 */
private ChartEntity findChartEntity(ChartPanel chartPanel, MouseEvent e) {
  // coordinates to find chart entities
  Insets insets = chartPanel.getInsets();
  int x = (int) ((e.getX() - insets.left) / chartPanel.getScaleX());
  int y = (int) ((e.getY() - insets.top) / chartPanel.getScaleY());

  if (lastEntity != null && x == lastEntityX && y == lastEntityY)
    return lastEntity;
  else {
    ChartRenderingInfo info = chartPanel.getChartRenderingInfo();
    ChartEntity entity = null;
    if (info != null) {
      EntityCollection entities = info.getEntityCollection();
      if (entities != null) {
        entity = entities.getEntity(x, y);
      }
    }
    return entity;
  }
}
 
Example 5
Source File: ChartLogics.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY...
 * 
 * @param chart
 * @param mx mouse coordinates
 * @param my mouse coordinates
 * @return
 */
public static ChartEntity findChartEntity(ChartPanel chart, double mx, double my) {
  // TODO check if insets were needed
  // coordinates to find chart entities
  Insets insets = chart.getInsets();
  int x = (int) ((mx - insets.left) / chart.getScaleX());
  int y = (int) ((my - insets.top) / chart.getScaleY());

  ChartRenderingInfo info = chart.getChartRenderingInfo();
  ChartEntity entity = null;
  if (info != null) {
    EntityCollection entities = info.getEntityCollection();
    if (entities != null) {
      entity = entities.getEntity(x, y);
    }
  }
  return entity;
}
 
Example 6
Source File: ChartGestureMouseAdapter.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY...
 * 
 * @param chartPanel
 * @param x
 * @param y
 * @return
 */
private ChartEntity findChartEntity(ChartPanel chartPanel, MouseEvent e) {
  // coordinates to find chart entities
  Insets insets = chartPanel.getInsets();
  int x = (int) ((e.getX() - insets.left) / chartPanel.getScaleX());
  int y = (int) ((e.getY() - insets.top) / chartPanel.getScaleY());

  if (lastEntity != null && x == lastEntityX && y == lastEntityY)
    return lastEntity;
  else {
    ChartRenderingInfo info = chartPanel.getChartRenderingInfo();
    ChartEntity entity = null;
    if (info != null) {
      EntityCollection entities = info.getEntityCollection();
      if (entities != null) {
        entity = entities.getEntity(x, y);
      }
    }
    return entity;
  }
}