Example usage for org.jfree.chart.entity EntityCollection getEntity

List of usage examples for org.jfree.chart.entity EntityCollection getEntity

Introduction

In this page you can find the example usage for org.jfree.chart.entity EntityCollection getEntity.

Prototype

public ChartEntity getEntity(double x, double y);

Source Link

Document

Returns an entity whose area contains the specified point.

Usage

From source file:net.sf.mzmine.chartbasics.ChartLogicsFX.java

/**
 * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY...
 * /* ww  w .jav  a 2  s  .co m*/
 * @param chart
 * @return
 */
public static ChartEntity findChartEntity(ChartCanvas chart, double mx, double my) {
    // TODO check if insets were needed
    // coordinates to find chart entities
    int x = (int) (mx / chart.getScaleX());
    int y = (int) (my / chart.getScaleY());

    ChartRenderingInfo info = chart.getRenderingInfo();
    ChartEntity entity = null;
    if (info != null) {
        EntityCollection entities = info.getEntityCollection();
        if (entities != null) {
            entity = entities.getEntity(x, y);
        }
    }
    return entity;
}

From source file:net.sf.mzmine.chartbasics.ChartLogics.java

/**
 * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY...
 * /*from ww w. ja  v a2s  .co  m*/
 * @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;
}

From source file:biz.ixnay.pivot.charts.skin.jfree.JFreeChartViewSkin.java

protected ChartEntity getChartEntityAt(int x, int y) {
    ChartEntity result = null;/*from www  .  j  ava 2 s  . com*/

    if (chartRenderingInfo != null) {
        EntityCollection entities = chartRenderingInfo.getEntityCollection();
        result = (entities != null) ? entities.getEntity(x, y) : null;
    }

    return result;
}

From source file:de.hs.mannheim.modUro.controller.diagram.fx.interaction.TooltipHandlerFX.java

/**
 * Returns the tooltip text./*from www  . ja v  a 2s . c o m*/
 * 
 * @param canvas  the canvas that is displaying the chart.
 * @param x  the x-coordinate of the mouse pointer.
 * @param y  the y-coordinate of the mouse pointer.
 * 
 * @return String The tooltip text (possibly <code>null</code>).
  */
private String getTooltipText(ChartCanvas canvas, double x, double y) {
    ChartRenderingInfo info = canvas.getRenderingInfo();
    if (info == null) {
        return null;
    }
    EntityCollection entities = info.getEntityCollection();
    if (entities == null) {
        return null;
    }
    ChartEntity entity = entities.getEntity(x, y);
    if (entity == null) {
        return null;
    }
    return entity.getToolTipText();
}

From source file:com.diversityarrays.kdxplore.chartcommon.KDXploreChartPanel.java

@Override
public void mouseDragged(MouseEvent e) {
    if (e.isShiftDown() || shiftDownatStart) {
        super.mouseDragged(e);

    } else {// www .  jav  a 2 s  .c o  m

        Insets insets = getInsets();
        int x = (int) ((e.getX() - insets.left) / this.getScaleX());
        int y = (int) ((e.getY() - insets.top) / this.getScaleY());

        ChartEntity entity = null;
        if (this.getChartRenderingInfo() != null) {
            EntityCollection entities = this.getChartRenderingInfo().getEntityCollection();
            if (entities != null) {
                entity = entities.getEntity(x, y);
            }
        }

        if (this.getChart() != null) {
            ChartMouseEvent event = new ChartMouseEvent(getChart(), e, entity);

            EventListener[] listeners = this.getListeners(ChartMouseListener.class);

            for (int i = listeners.length - 1; i >= 0; i -= 1) {
                if (listeners[i] instanceof KDXChartMouseListener) {
                    ((KDXChartMouseListener) listeners[i]).chartMouseSelected(event);
                }
            }
        }
    }
}

From source file:com.diversityarrays.kdxplore.chartcommon.KDXploreChartPanel.java

@Override
public void mouseReleased(MouseEvent e) {
    if (e.isShiftDown() || shiftDownatStart) {
        super.mouseReleased(e);
        shiftDownatStart = false;/*from ww w .  j  av  a2  s. c o m*/

        Insets insets = getInsets();
        int x = (int) ((e.getX() - insets.left) / this.getScaleX());
        int y = (int) ((e.getY() - insets.top) / this.getScaleY());

        ChartEntity entity = null;
        if (this.getChartRenderingInfo() != null) {
            EntityCollection entities = this.getChartRenderingInfo().getEntityCollection();
            if (entities != null) {
                entity = entities.getEntity(x, y);
            }
        }

        Object[] listeners = this.getListeners(ChartMouseListener.class);

        if (this.getChart() != null) {
            ChartMouseEvent event = new ChartMouseEvent(getChart(), e, entity);
            for (int i = listeners.length - 1; i >= 0; i -= 1) {
                if (listeners[i] instanceof KDXChartMouseListener) {
                    ((KDXChartMouseListener) listeners[i]).chartMouseZoomingReleased(event);
                }
            }
        }

    } else {
        super.mouseReleased(e);

        Insets insets = getInsets();
        int x = (int) ((e.getX() - insets.left) / this.getScaleX());
        int y = (int) ((e.getY() - insets.top) / this.getScaleY());

        ChartEntity entity = null;
        if (this.getChartRenderingInfo() != null) {
            EntityCollection entities = this.getChartRenderingInfo().getEntityCollection();
            if (entities != null) {
                entity = entities.getEntity(x, y);
            }
        }

        Object[] listeners = this.getListeners(ChartMouseListener.class);

        if (this.getChart() != null) {
            ChartMouseEvent event = new ChartMouseEvent(getChart(), e, entity);
            for (int i = listeners.length - 1; i >= 0; i -= 1) {
                if (listeners[i] instanceof KDXChartMouseListener) {
                    ((KDXChartMouseListener) listeners[i]).chartMouseSelectedReleased(event);
                }
            }
        }
    }
}

From source file:net.sf.maltcms.chromaui.charts.events.ChartPanelMouseListener.java

/**
 *
 * @param arg0/*from w ww . jav  a2s .  c o  m*/
 */

@Override
public void chartMouseMoved(final ChartMouseEvent arg0) {
    final ChartPanelMouseListener cpml = this;

    if (arg0.getEntity() != null) {
        if (arg0.getEntity() instanceof XYItemEntity) {
            if (arg0.getTrigger().isAltDown()) {
                XYPlot xyp = arg0.getChart().getXYPlot();
                if (xyp != null) {
                    fireEvent(new XYItemEntityClickedEvent((XYItemEntity) arg0.getEntity(), cpml));
                }
                XYItemEntityMovedEvent xyie = new XYItemEntityMovedEvent((XYItemEntity) arg0.getEntity(), cpml);
                fireEvent(xyie);
            }
        }
        if (arg0.getEntity() instanceof XYAnnotationEntity) {
            ChartRenderingInfo cri = cp.getChartRenderingInfo();
            EntityCollection entities = cri.getEntityCollection();
            ChartEntity ce = entities.getEntity(arg0.getTrigger().getX(), arg0.getTrigger().getY());
            if (ce instanceof XYItemEntity) {
                //                    System.out.println("Entity at position: " + ce.getClass().
                //                            getName() + " " + ((XYItemEntity) ce));
                XYItemEntityMouseOverEvent xyie = new XYItemEntityMouseOverEvent((XYItemEntity) ce, cpml);
                fireEvent(xyie);
            }
        }
    }
}

From source file:net.sf.mzmine.chartbasics.gui.swing.ChartGestureMouseAdapter.java

/**
 * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY...
 * /*from w  w  w  .j a  v a 2 s  .  c  o  m*/
 * @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;
    }
}

From source file:net.sf.mzmine.chartbasics.gui.javafx.ChartGestureMouseAdapterFX.java

/**
 * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY...
 * /* w w  w.j  av a 2  s .c om*/
 * @param chartPanel
 * @param x
 * @param y
 * @return
 */
private ChartEntity findChartEntity(MouseEventWrapper e) {
    // TODO check if insets were needed
    // coordinates to find chart entities
    int x = (int) ((e.getX()) / chartViewer.getCanvas().getScaleX());
    int y = (int) ((e.getY()) / chartViewer.getCanvas().getScaleY());

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

From source file:com.ivli.roim.controls.ChartControl.java

private ChartEntity findEntity(MouseEvent e) {
    if (null != getChart()) {
        final Insets insets = getInsets();
        final int x = (int) ((e.getX() - insets.left) / this.getScaleX());
        final int y = (int) ((e.getY() - insets.top) / this.getScaleY());

        if (this.getChartRenderingInfo() != null) {
            EntityCollection entities = this.getChartRenderingInfo().getEntityCollection();

            if (entities != null)
                return entities.getEntity(x, y);
        }//from   w  w w  .  ja v a2 s .  c  o m
    }
    return null;
}