Java 类org.jfree.chart.entity.ChartEntity 实例源码

项目:rapidminer    文件:AbstractChartPanel.java   
/**
 * Returns a string for the tooltip.
 * 
 * @param e
 *            the mouse event.
 * 
 * @return A tool tip or <code>null</code> if no tooltip is available.
 */

@Override
public String getToolTipText(MouseEvent e) {

    String result = null;
    if (this.info != null) {
        EntityCollection entities = this.info.getEntityCollection();
        if (entities != null) {
            Insets insets = getInsets();
            ChartEntity entity = entities.getEntity((int) ((e.getX() - insets.left) / this.scaleX),
                    (int) ((e.getY() - insets.top) / this.scaleY));
            if (entity != null) {
                result = entity.getToolTipText();
            }
        }
    }
    return result;

}
项目:rapidminer    文件:AbstractChartPanel.java   
/**
 * Returns the chart entity at a given point.
 * <P>
 * This method will return null if there is (a) no entity at the given point, or (b) no entity
 * collection has been generated.
 * 
 * @param viewX
 *            the x-coordinate.
 * @param viewY
 *            the y-coordinate.
 * 
 * @return The chart entity (possibly <code>null</code>).
 */

@Override
public ChartEntity getEntityForPoint(int viewX, int viewY) {

    ChartEntity result = null;
    if (this.info != null) {
        Insets insets = getInsets();
        double x = (viewX - insets.left) / this.scaleX;
        double y = (viewY - insets.top) / this.scaleY;
        EntityCollection entities = this.info.getEntityCollection();
        result = entities != null ? entities.getEntity(x, y) : null;
    }
    return result;

}
项目:jfreechart-fx    文件:TooltipHandlerFX.java   
/**
 * Returns the tooltip text.
 * 
 * @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}).
  */
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();
}
项目:parabuild-ci    文件:ChartPanel.java   
/**
 * Returns a string for the tooltip.
 *
 * @param e  the mouse event.
 *
 * @return a tool tip or <code>null</code> if no tooltip is available.
 */
public String getToolTipText(MouseEvent e) {

    String result = null;

    if (this.info != null) {
        EntityCollection entities = this.info.getEntityCollection();
        if (entities != null) {
            Insets insets = getInsets();
            ChartEntity entity = entities.getEntity(
                (int) ((e.getX() - insets.left) / this.scaleX),
                (int) ((e.getY() - insets.top) / this.scaleY)
            );
            if (entity != null) {
                result = entity.getToolTipText();
            }
        }
    }

    return result;

}
项目:parabuild-ci    文件:ImageMapUtil.java   
/**
 * Creates an HTML image map.
 *
 * @param name  the map name (<code>null</code> not permitted).
 * @param info  the chart rendering info (<code>null</code> not permitted).
 * @param toolTipTagFragmentGenerator  the tool tip generator.
 * @param urlTagFragmentGenerator  the url generator.
 *
 * @return the map tag.
 */
public static String getImageMap(String name,
                                 ChartRenderingInfo info,
                                 ToolTipTagFragmentGenerator toolTipTagFragmentGenerator,
                                 URLTagFragmentGenerator urlTagFragmentGenerator) {

    StringBuffer sb = new StringBuffer();
    sb.append("<MAP NAME=\"" + name + "\">");
    sb.append(System.getProperty("line.separator"));
    EntityCollection entities = info.getEntityCollection();
    if (entities != null) {
        Iterator iterator = entities.iterator();
        while (iterator.hasNext()) {
            ChartEntity entity = (ChartEntity) iterator.next();
            String area = entity.getImageMapAreaTag(toolTipTagFragmentGenerator,
                                                    urlTagFragmentGenerator);
            if (area.length() > 0) {
                sb.append(area);
                sb.append(System.getProperty("line.separator"));
            }
        }
    }
    sb.append("</MAP>");

    return sb.toString();
}
项目:parabuild-ci    文件:ChartComposite.java   
/**
 * Returns a string for the tooltip.
 *
 * @param e  the mouse event.
 *
 * @return A tool tip or <code>null</code> if no tooltip is available.
 */
public String getToolTipText(org.eclipse.swt.events.MouseEvent e) {
    String result = null;
    if (this.info != null) {
        EntityCollection entities = this.info.getEntityCollection();
        if (entities != null) {
            Rectangle insets = getBounds();
            ChartEntity entity = entities.getEntity(
                    (int) ((e.x - insets.x) / this.scaleX),
                    (int) ((e.y - insets.y) / this.scaleY));
            if (entity != null) {
                result = entity.getToolTipText();
            }
        }
    }
    return result;

}
项目:parabuild-ci    文件:ChartRenderingInfoTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    ChartRenderingInfo i1 = new ChartRenderingInfo();
    ChartRenderingInfo i2 = new ChartRenderingInfo();
    assertTrue(i1.equals(i2));

    i1.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertFalse(i1.equals(i2));
    i2.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertTrue(i1.equals(i2));

    i1.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertFalse(i1.equals(i2));
    i2.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertTrue(i1.equals(i2));

    StandardEntityCollection e1 = new StandardEntityCollection();
    e1.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i1.setEntityCollection(e1);
    assertFalse(i1.equals(i2));
    StandardEntityCollection e2 = new StandardEntityCollection();
    e2.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i2.setEntityCollection(e2); 
}
项目:parabuild-ci    文件:ChartPanel.java   
/**
 * Returns a string for the tooltip.
 *
 * @param e  the mouse event.
 *
 * @return A tool tip or <code>null</code> if no tooltip is available.
 */
public String getToolTipText(MouseEvent e) {

    String result = null;
    if (this.info != null) {
        EntityCollection entities = this.info.getEntityCollection();
        if (entities != null) {
            Insets insets = getInsets();
            ChartEntity entity = entities.getEntity(
                    (int) ((e.getX() - insets.left) / this.scaleX),
                    (int) ((e.getY() - insets.top) / this.scaleY));
            if (entity != null) {
                result = entity.getToolTipText();
            }
        }
    }
    return result;

}
项目:ccu-historian    文件:ChartComposite.java   
/**
 * Returns a string for the tooltip.
 *
 * @param e  the mouse event.
 *
 * @return A tool tip or <code>null</code> if no tooltip is available.
 */
public String getToolTipText(org.eclipse.swt.events.MouseEvent e) {
    String result = null;
    if (this.info != null) {
        EntityCollection entities = this.info.getEntityCollection();
        if (entities != null) {
            Rectangle insets = getClientArea();
            ChartEntity entity = entities.getEntity(
                    (int) ((e.x - insets.x) / this.scaleX),
                    (int) ((e.y - insets.y) / this.scaleY));
            if (entity != null) {
                result = entity.getToolTipText();
            }
        }
    }
    return result;

}
项目:ccu-historian    文件:ChartRenderingInfoTest.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    ChartRenderingInfo i1 = new ChartRenderingInfo();
    ChartRenderingInfo i2 = new ChartRenderingInfo();
    assertEquals(i1, i2);

    i1.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertFalse(i1.equals(i2));
    i2.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertEquals(i1, i2);

    i1.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertFalse(i1.equals(i2));
    i2.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertEquals(i1, i2);

    StandardEntityCollection e1 = new StandardEntityCollection();
    e1.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i1.setEntityCollection(e1);
    assertFalse(i1.equals(i2));
    StandardEntityCollection e2 = new StandardEntityCollection();
    e2.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i2.setEntityCollection(e2);
}
项目:ccu-historian    文件:ChartRenderingInfoTest.java   
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    ChartRenderingInfo i1 = new ChartRenderingInfo();
    ChartRenderingInfo i2 = (ChartRenderingInfo) i1.clone();

    assertNotSame(i1, i2);
    assertSame(i1.getClass(), i2.getClass());
    assertEquals(i1, i2);

    // check independence
    i1.getChartArea().setRect(4.0, 3.0, 2.0, 1.0);
    assertFalse(i1.equals(i2));
    i2.getChartArea().setRect(4.0, 3.0, 2.0, 1.0);
    assertEquals(i1, i2);

    i1.getEntityCollection().add(new ChartEntity(new Rectangle(1, 2, 2,
            1)));
    assertFalse(i1.equals(i2));
    i2.getEntityCollection().add(new ChartEntity(new Rectangle(1, 2, 2,
            1)));
    assertEquals(i1, i2);

}
项目:ccu-historian    文件:TooltipHandlerFX.java   
/**
 * Returns the tooltip text.
 * 
 * @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();
}
项目:ccu-historian    文件:ChartPanel.java   
/**
 * Returns a string for the tooltip.
 *
 * @param e  the mouse event.
 *
 * @return A tool tip or <code>null</code> if no tooltip is available.
 */
@Override
public String getToolTipText(MouseEvent e) {
    String result = null;
    if (this.info != null) {
        EntityCollection entities = this.info.getEntityCollection();
        if (entities != null) {
            Insets insets = getInsets();
            ChartEntity entity = entities.getEntity(
                    (int) ((e.getX() - insets.left) / this.scaleX),
                    (int) ((e.getY() - insets.top) / this.scaleY));
            if (entity != null) {
                result = entity.getToolTipText();
            }
        }
    }
    return result;
}
项目:jfreechart    文件:ChartPanel.java   
/**
 * Returns a string for the tooltip.
 *
 * @param e  the mouse event.
 *
 * @return A tool tip or {@code null} if no tooltip is available.
 */
@Override
public String getToolTipText(MouseEvent e) {
    String result = null;
    if (this.info != null) {
        EntityCollection entities = this.info.getEntityCollection();
        if (entities != null) {
            Insets insets = getInsets();
            ChartEntity entity = entities.getEntity(
                    (int) ((e.getX() - insets.left) / this.scaleX),
                    (int) ((e.getY() - insets.top) / this.scaleY));
            if (entity != null) {
                result = entity.getToolTipText();
            }
        }
    }
    return result;
}
项目:jfreechart    文件:ChartRenderingInfoTest.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    ChartRenderingInfo i1 = new ChartRenderingInfo();
    ChartRenderingInfo i2 = new ChartRenderingInfo();
    assertEquals(i1, i2);

    i1.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertFalse(i1.equals(i2));
    i2.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertEquals(i1, i2);

    i1.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertFalse(i1.equals(i2));
    i2.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertEquals(i1, i2);

    StandardEntityCollection e1 = new StandardEntityCollection();
    e1.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i1.setEntityCollection(e1);
    assertFalse(i1.equals(i2));
    StandardEntityCollection e2 = new StandardEntityCollection();
    e2.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i2.setEntityCollection(e2);
}
项目:jfreechart    文件:ChartRenderingInfoTest.java   
/**
 * Confirm that cloning works.
 * @throws java.lang.CloneNotSupportedException
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    ChartRenderingInfo i1 = new ChartRenderingInfo();
    ChartRenderingInfo i2 = (ChartRenderingInfo) i1.clone();

    assertNotSame(i1, i2);
    assertSame(i1.getClass(), i2.getClass());
    assertEquals(i1, i2);

    // check independence
    i1.getChartArea().setRect(4.0, 3.0, 2.0, 1.0);
    assertFalse(i1.equals(i2));
    i2.getChartArea().setRect(4.0, 3.0, 2.0, 1.0);
    assertEquals(i1, i2);

    i1.getEntityCollection().add(new ChartEntity(new Rectangle(1, 2, 2,
            1)));
    assertFalse(i1.equals(i2));
    i2.getEntityCollection().add(new ChartEntity(new Rectangle(1, 2, 2,
            1)));
    assertEquals(i1, i2);

}
项目:jasperreports    文件:XYChartHyperlinkProvider.java   
@Override
public JRPrintHyperlink getEntityHyperlink(ChartEntity entity)
{
    JRPrintHyperlink printHyperlink = null;
    if (hasHyperlinks() && entity instanceof XYItemEntity)
    {
        XYItemEntity itemEntity = (XYItemEntity) entity;
        XYDataset dataset = itemEntity.getDataset();
        Comparable<?> serie = dataset.getSeriesKey(itemEntity.getSeriesIndex());
        Map<Pair, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(serie);
        if (serieHyperlinks != null)
        {
            Number x = dataset.getX(itemEntity.getSeriesIndex(), itemEntity.getItem());
            Number y = dataset.getY(itemEntity.getSeriesIndex(), itemEntity.getItem());
            Pair<Number,Number> xyKey = new Pair<Number,Number>(x, y);
            printHyperlink = serieHyperlinks.get(xyKey);
        }
    }
    return printHyperlink;
}
项目:jasperreports    文件:TimeSeriesChartHyperlinkProvider.java   
@Override
public JRPrintHyperlink getEntityHyperlink(ChartEntity entity)
{
    JRPrintHyperlink printHyperlink = null;
    if (hasHyperlinks() && entity instanceof XYItemEntity)
    {
        XYItemEntity itemEntity = (XYItemEntity) entity;
        TimeSeriesCollection dataset = (TimeSeriesCollection) itemEntity.getDataset();
        TimeSeries series = dataset.getSeries(itemEntity.getSeriesIndex());
        Map<RegularTimePeriod, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(series.getKey());
        if (serieHyperlinks != null)
        {
            RegularTimePeriod timePeriod = series.getTimePeriod(itemEntity.getItem());
            printHyperlink = serieHyperlinks.get(timePeriod);
        }
    }
    return printHyperlink;
}
项目:jasperreports    文件:TimePeriodChartHyperlinkProvider.java   
@Override
public JRPrintHyperlink getEntityHyperlink(ChartEntity entity)
{
    JRPrintHyperlink printHyperlink = null;
    if (hasHyperlinks() && entity instanceof XYItemEntity)
    {
        XYItemEntity itemEntity = (XYItemEntity) entity;
        TimePeriodValuesCollection dataset = (TimePeriodValuesCollection) itemEntity.getDataset();
        TimePeriodValues series = dataset.getSeries(itemEntity.getSeriesIndex());
        Map<TimePeriod, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(series.getKey());
        if (serieHyperlinks != null)
        {
            TimePeriod timePeriod = series.getTimePeriod(itemEntity.getItem());
            printHyperlink = serieHyperlinks.get(timePeriod);
        }
    }
    return printHyperlink;
}
项目:jasperreports    文件:CategoryChartHyperlinkProvider.java   
@Override
public JRPrintHyperlink getEntityHyperlink(ChartEntity entity)
{
    JRPrintHyperlink printHyperlink = null;
    if (hasHyperlinks() && entity instanceof CategoryItemEntity)
    {
        CategoryItemEntity itemEntity = (CategoryItemEntity) entity;
        Comparable<?> serie = itemEntity.getRowKey();
        Map<Comparable<?>,JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(serie);
        if (serieHyperlinks != null)
        {
            Comparable<?> category = itemEntity.getColumnKey();
            printHyperlink = serieHyperlinks.get(category);
        }
    }
    return printHyperlink;
}
项目:jasperreports    文件:ChartUtil.java   
private static int[] getCoordinates(ChartEntity entity)
{
    int[] coordinates = null;
    String shapeCoords = entity.getShapeCoords();
    if (shapeCoords != null && shapeCoords.length() > 0)
    {
        StringTokenizer tokens = new StringTokenizer(shapeCoords, ",");
        coordinates = new int[tokens.countTokens()];
        int idx = 0;
        while (tokens.hasMoreTokens())
        {
            String coord = tokens.nextToken();
            coordinates[idx] = Integer.parseInt(coord);
            ++idx;
        }
    }
    return coordinates;
}
项目:aya-lang    文件:ChartComposite.java   
/**
 * Returns a string for the tooltip.
 *
 * @param e  the mouse event.
 *
 * @return A tool tip or <code>null</code> if no tooltip is available.
 */
public String getToolTipText(org.eclipse.swt.events.MouseEvent e) {
    String result = null;
    if (this.info != null) {
        EntityCollection entities = this.info.getEntityCollection();
        if (entities != null) {
            Rectangle insets = getClientArea();
            ChartEntity entity = entities.getEntity(
                    (int) ((e.x - insets.x) / this.scaleX),
                    (int) ((e.y - insets.y) / this.scaleY));
            if (entity != null) {
                result = entity.getToolTipText();
            }
        }
    }
    return result;

}
项目:aya-lang    文件:ChartRenderingInfoTest.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    ChartRenderingInfo i1 = new ChartRenderingInfo();
    ChartRenderingInfo i2 = new ChartRenderingInfo();
    assertEquals(i1, i2);

    i1.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertFalse(i1.equals(i2));
    i2.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertEquals(i1, i2);

    i1.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertFalse(i1.equals(i2));
    i2.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4));
    assertEquals(i1, i2);

    StandardEntityCollection e1 = new StandardEntityCollection();
    e1.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i1.setEntityCollection(e1);
    assertFalse(i1.equals(i2));
    StandardEntityCollection e2 = new StandardEntityCollection();
    e2.add(new ChartEntity(new Rectangle(1, 2, 3, 4)));
    i2.setEntityCollection(e2);
}
项目:aya-lang    文件:ChartRenderingInfoTest.java   
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    ChartRenderingInfo i1 = new ChartRenderingInfo();
    ChartRenderingInfo i2 = (ChartRenderingInfo) i1.clone();

    assertNotSame(i1, i2);
    assertSame(i1.getClass(), i2.getClass());
    assertEquals(i1, i2);

    // check independence
    i1.getChartArea().setRect(4.0, 3.0, 2.0, 1.0);
    assertFalse(i1.equals(i2));
    i2.getChartArea().setRect(4.0, 3.0, 2.0, 1.0);
    assertEquals(i1, i2);

    i1.getEntityCollection().add(new ChartEntity(new Rectangle(1, 2, 2,
            1)));
    assertFalse(i1.equals(i2));
    i2.getEntityCollection().add(new ChartEntity(new Rectangle(1, 2, 2,
            1)));
    assertEquals(i1, i2);

}
项目:aya-lang    文件:TooltipHandlerFX.java   
/**
 * Returns the tooltip text.
 * 
 * @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();
}
项目:aya-lang    文件:ChartPanel.java   
/**
 * Returns a string for the tooltip.
 *
 * @param e  the mouse event.
 *
 * @return A tool tip or <code>null</code> if no tooltip is available.
 */
@Override
public String getToolTipText(MouseEvent e) {
    String result = null;
    if (this.info != null) {
        EntityCollection entities = this.info.getEntityCollection();
        if (entities != null) {
            Insets insets = getInsets();
            ChartEntity entity = entities.getEntity(
                    (int) ((e.getX() - insets.left) / this.scaleX),
                    (int) ((e.getY() - insets.top) / this.scaleY));
            if (entity != null) {
                result = entity.getToolTipText();
            }
        }
    }
    return result;
}
项目:rapidminer-studio    文件:AbstractChartPanel.java   
/**
 * Returns a string for the tooltip.
 * 
 * @param e
 *            the mouse event.
 * 
 * @return A tool tip or <code>null</code> if no tooltip is available.
 */

@Override
public String getToolTipText(MouseEvent e) {

    String result = null;
    if (this.info != null) {
        EntityCollection entities = this.info.getEntityCollection();
        if (entities != null) {
            Insets insets = getInsets();
            ChartEntity entity = entities.getEntity((int) ((e.getX() - insets.left) / this.scaleX),
                    (int) ((e.getY() - insets.top) / this.scaleY));
            if (entity != null) {
                result = entity.getToolTipText();
            }
        }
    }
    return result;

}
项目:rapidminer-studio    文件:AbstractChartPanel.java   
/**
 * Returns the chart entity at a given point.
 * <P>
 * This method will return null if there is (a) no entity at the given point, or (b) no entity
 * collection has been generated.
 * 
 * @param viewX
 *            the x-coordinate.
 * @param viewY
 *            the y-coordinate.
 * 
 * @return The chart entity (possibly <code>null</code>).
 */

@Override
public ChartEntity getEntityForPoint(int viewX, int viewY) {

    ChartEntity result = null;
    if (this.info != null) {
        Insets insets = getInsets();
        double x = (viewX - insets.left) / this.scaleX;
        double y = (viewY - insets.top) / this.scaleY;
        EntityCollection entities = this.info.getEntityCollection();
        result = entities != null ? entities.getEntity(x, y) : null;
    }
    return result;

}
项目:mzmine2    文件:ChartGestureEvent.java   
public ChartGestureEvent(ChartPanel cp, MouseEvent mouseEvent, ChartEntity entity,
    ChartGesture gesture) {
  super();
  this.cp = cp;
  this.mouseEvent = mouseEvent;
  this.gesture = gesture;
  this.entity = entity;

  if (mouseEvent != null) {
    // extract keys and set to gesture
    ArrayList<Key> keys = new ArrayList<Key>();
    if (mouseEvent.isAltDown())
      keys.add(Key.ALT);
    if (mouseEvent.isControlDown())
      keys.add(Key.CTRL);
    if (mouseEvent.isShiftDown())
      keys.add(Key.SHIFT);
    gesture.setKey(Key.fromList(keys));
  }
}
项目:mzmine2    文件:ChartGestureDragDiffHandler.java   
/**
 * use default orientation or orientation of axis
 * 
 * @param event
 * @return
 */
public Orientation getOrientation(ChartGestureEvent event) {
  ChartEntity ce = event.getEntity();
  if (ce instanceof AxisEntity) {
    JFreeChart chart = event.getChartPanel().getChart();
    PlotOrientation orient = PlotOrientation.HORIZONTAL;
    if (chart.getXYPlot() != null)
      orient = chart.getXYPlot().getOrientation();
    else if (chart.getCategoryPlot() != null)
      orient = chart.getCategoryPlot().getOrientation();

    Entity entity = event.getGesture().getEntity();
    if ((entity.equals(Entity.DOMAIN_AXIS) && orient.equals(PlotOrientation.VERTICAL))
        || (entity.equals(Entity.RANGE_AXIS) && orient.equals(PlotOrientation.HORIZONTAL)))
      return Orientation.HORIZONTAL;
    else
      return Orientation.VERTICAL;
  }
  return orient;
}
项目:mzmine2    文件:ChartGestureMouseAdapter.java   
/**
 * 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;
  }
}
项目:mzmine2    文件:ChartGestureMouseAdapter.java   
@Override
public void mouseReleased(MouseEvent e) {
  if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.RELEASED))
    return;

  if (e.getComponent() instanceof ChartPanel) {
    ChartPanel chartPanel = (ChartPanel) e.getComponent();
    ChartEntity entity = findChartEntity(chartPanel, e);
    ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
    Button button = Button.getButton(e.getButton());

    // last gesture was dragged? keep the same chartEntity
    if (lastDragEvent != null) {
      entity = lastDragEvent.getEntity();
      gestureEntity = lastDragEvent.getGesture().getEntity();
    }
    // handle event
    handleEvent(new ChartGestureEvent(chartPanel, e, entity,
        new ChartGesture(gestureEntity, Event.RELEASED, button)));

    // reset drag
    lastDragEvent = null;
  }
}
项目:mzmine2    文件:ChartGestureMouseAdapter.java   
@Override
public void mousePressed(MouseEvent e) {
  if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.PRESSED))
    return;

  if (e.getComponent() instanceof ChartPanel) {
    ChartPanel chartPanel = (ChartPanel) e.getComponent();
    ChartEntity entity = findChartEntity(chartPanel, e);
    ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
    Button button = Button.getButton(e.getButton());
    // handle event
    lastDragEvent = new ChartGestureEvent(chartPanel, e, entity,
        new ChartGesture(gestureEntity, Event.PRESSED, button));
    handleEvent(lastDragEvent);
  }
}
项目:mzmine2    文件:ChartGestureMouseAdapter.java   
@Override
public void mouseDragged(MouseEvent e) {
  if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.DRAGGED))
    return;

  if (e.getComponent() instanceof ChartPanel) {
    ChartPanel chartPanel = (ChartPanel) e.getComponent();
    // keep the same chartEntity
    ChartEntity entity = lastDragEvent.getEntity();
    ChartGesture.Entity gestureEntity = lastDragEvent.getGesture().getEntity();
    Button button = lastDragEvent.getGesture().getButton();

    // handle event
    lastDragEvent = new ChartGestureEvent(chartPanel, e, entity,
        new ChartGesture(gestureEntity, Event.DRAGGED, button));
    handleEvent(lastDragEvent);
  }
}
项目:mzmine2    文件:ChartGestureMouseAdapter.java   
@Override
public void mouseMoved(MouseEvent e) {
  if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.MOVED))
    return;

  if (e.getComponent() instanceof ChartPanel) {
    ChartPanel chartPanel = (ChartPanel) e.getComponent();
    ChartEntity entity = findChartEntity(chartPanel, e);
    ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
    Button button = Button.getButton(e.getButton());

    // handle event
    handleEvent(new ChartGestureEvent(chartPanel, e, entity,
        new ChartGesture(gestureEntity, Event.MOVED, button)));
  }
}
项目:mzmine2    文件:ChartGestureMouseAdapter.java   
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
  if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.MOUSE_WHEEL))
    return;

  if (e.getComponent() instanceof ChartPanel) {
    ChartPanel chartPanel = (ChartPanel) e.getComponent();
    ChartEntity entity = findChartEntity(chartPanel, e);
    ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
    Button button = Button.getButton(e.getButton());

    // handle event
    handleEvent(new ChartGestureEvent(chartPanel, e, entity,
        new ChartGesture(gestureEntity, Event.MOUSE_WHEEL, button)));
  }
}
项目:mzmine2    文件:ChartGestureMouseAdapter.java   
@Override
public void mouseEntered(MouseEvent e) {
  if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.ENTERED))
    return;

  if (e.getComponent() instanceof ChartPanel) {
    ChartPanel chartPanel = (ChartPanel) e.getComponent();
    ChartEntity entity = findChartEntity(chartPanel, e);
    ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
    Button button = Button.getButton(e.getButton());

    // handle event
    handleEvent(new ChartGestureEvent(chartPanel, e, entity,
        new ChartGesture(gestureEntity, Event.ENTERED, button)));
  }
}
项目:mzmine2    文件:ChartGestureMouseAdapter.java   
@Override
public void mouseExited(MouseEvent e) {
  if (gestureHandlers == null || gestureHandlers.isEmpty() || !listensFor(Event.EXITED))
    return;

  if (e.getComponent() instanceof ChartPanel) {
    ChartPanel chartPanel = (ChartPanel) e.getComponent();
    ChartEntity entity = findChartEntity(chartPanel, e);
    ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
    Button button = Button.getButton(e.getButton());

    // handle event
    handleEvent(new ChartGestureEvent(chartPanel, e, entity,
        new ChartGesture(gestureEntity, Event.EXITED, button)));
  }
}
项目:compomics-utilities    文件:VennDiagramPanel.java   
/**
 * Handles mouse clicks in the chart panel.
 *
 * @param event the chart mouse event
 */
private void mouseClickedInChart(ChartMouseEvent event) {

    ArrayList<ChartEntity> entities = getEntitiesForPoint(event.getTrigger().getPoint().x, event.getTrigger().getPoint().y);

    if (entities.isEmpty()) {
        return;
    }

    boolean dataPointFound = false;
    String dataPointTooltip = "";

    for (ChartEntity tempEntity : entities) {
        if (tempEntity instanceof XYAnnotationEntity) {
            if (((XYAnnotationEntity) tempEntity).getToolTipText() != null) {
                dataPointFound = true;
                dataPointTooltip = ((XYAnnotationEntity) tempEntity).getToolTipText();
            }
        }
    }

    if (dataPointFound) {
        String dataset = tooltipToDatasetMap.get(dataPointTooltip);
        JOptionPane.showMessageDialog(this, dataPointTooltip + ":\n" + vennDiagramResults.get(dataset), "Selected Values", JOptionPane.INFORMATION_MESSAGE);
    }
}
项目:compomics-utilities    文件:VennDiagramPanel.java   
/**
 * Handles mouse movements in the chart panel.
 *
 * @param event the chart mouse event
 */
private void mouseMovedInChart(ChartMouseEvent event) {

    ArrayList<ChartEntity> entities = getEntitiesForPoint(event.getTrigger().getPoint().x, event.getTrigger().getPoint().y);

    boolean dataPointFound = false;

    for (ChartEntity tempEntity : entities) {
        if (tempEntity instanceof XYAnnotationEntity) {
            if (((XYAnnotationEntity) tempEntity).getToolTipText() != null) {
                dataPointFound = true;
            }
        }
    }

    if (dataPointFound) {
        chartPanel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
    } else {
        chartPanel.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    }
}