本文整理汇总了Java中org.jfree.chart.entity.XYItemEntity类的典型用法代码示例。如果您正苦于以下问题:Java XYItemEntity类的具体用法?Java XYItemEntity怎么用?Java XYItemEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XYItemEntity类属于org.jfree.chart.entity包,在下文中一共展示了XYItemEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addEntity
import org.jfree.chart.entity.XYItemEntity; //导入依赖的package包/类
/**
* Adds an entity to the collection.
*
* @param entities the entity collection being populated.
* @param area the entity area (if <code>null</code> a default will be used).
* @param entityX the entity's center x-coordinate in user space.
* @param entityY the entity's center y-coordinate in user space.
* @param dataset the dataset.
* @param series the series.
* @param item the item.
*/
protected void addEntity(EntityCollection entities, Shape area,
XYDataset dataset, int series, int item,
double entityX, double entityY) {
if (area == null) {
area = new Ellipse2D.Double(
entityX - this.defaultEntityRadius, entityY - this.defaultEntityRadius,
this.defaultEntityRadius * 2, this.defaultEntityRadius * 2
);
}
String tip = null;
XYToolTipGenerator generator = getToolTipGenerator(series, item);
if (generator != null) {
tip = generator.generateToolTip(dataset, series, item);
}
String url = null;
if (getURLGenerator() != null) {
url = getURLGenerator().generateURL(dataset, series, item);
}
XYItemEntity entity = new XYItemEntity(area, dataset, series, item, tip, url);
entities.addEntity(entity);
}
示例2: addEntity
import org.jfree.chart.entity.XYItemEntity; //导入依赖的package包/类
/**
* Adds an entity to the collection.
*
* @param entities the entity collection being populated.
* @param area the entity area (if <code>null</code> a default will be
* used).
* @param dataset the dataset.
* @param series the series.
* @param item the item.
* @param entityX the entity's center x-coordinate in user space.
* @param entityY the entity's center y-coordinate in user space.
*/
protected void addEntity(EntityCollection entities, Shape area,
XYDataset dataset, int series, int item,
double entityX, double entityY) {
if (!getItemCreateEntity(series, item)) {
return;
}
if (area == null) {
area = new Ellipse2D.Double(entityX - this.defaultEntityRadius,
entityY - this.defaultEntityRadius,
this.defaultEntityRadius * 2, this.defaultEntityRadius * 2);
}
String tip = null;
XYToolTipGenerator generator = getToolTipGenerator(series, item);
if (generator != null) {
tip = generator.generateToolTip(dataset, series, item);
}
String url = null;
if (getURLGenerator() != null) {
url = getURLGenerator().generateURL(dataset, series, item);
}
XYItemEntity entity = new XYItemEntity(area, dataset, series, item,
tip, url);
entities.add(entity);
}
示例3: testNoDisplayedItem
import org.jfree.chart.entity.XYItemEntity; //导入依赖的package包/类
/**
* A check to ensure that an item that falls outside the plot's data area
* does NOT generate an item entity.
*/
@Test
public void testNoDisplayedItem() {
XYSeriesCollection dataset = new XYSeriesCollection();
XYSeries s1 = new XYSeries("S1");
s1.add(10.0, 10.0);
dataset.addSeries(s1);
JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
dataset, PlotOrientation.VERTICAL, false, true, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StandardXYItemRenderer());
NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
xAxis.setRange(0.0, 5.0);
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setRange(0.0, 5.0);
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
ChartRenderingInfo info = new ChartRenderingInfo();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info);
g2.dispose();
EntityCollection ec = info.getEntityCollection();
assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(),
XYItemEntity.class));
}
示例4: testNoDisplayedItem
import org.jfree.chart.entity.XYItemEntity; //导入依赖的package包/类
/**
* A check to ensure that an item that falls outside the plot's data area
* does NOT generate an item entity.
*/
@Test
public void testNoDisplayedItem() {
XYSeriesCollection dataset = new XYSeriesCollection();
XYSeries s1 = new XYSeries("S1");
s1.add(10.0, 10.0);
dataset.addSeries(s1);
JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
dataset, PlotOrientation.VERTICAL, false, true, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StandardXYItemRenderer());
NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
xAxis.setRange(0.0, 5.0);
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setRange(0.0, 5.0);
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
ChartRenderingInfo info = new ChartRenderingInfo();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info);
g2.dispose();
EntityCollection ec = info.getEntityCollection();
assertFalse(TestUtils.containsInstanceOf(ec.getEntities(),
XYItemEntity.class));
}
示例5: getEntityHyperlink
import org.jfree.chart.entity.XYItemEntity; //导入依赖的package包/类
@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;
}
示例6: getEntityHyperlink
import org.jfree.chart.entity.XYItemEntity; //导入依赖的package包/类
@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;
}
示例7: getEntityHyperlink
import org.jfree.chart.entity.XYItemEntity; //导入依赖的package包/类
@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;
}
示例8: chartMouseMoved
import org.jfree.chart.entity.XYItemEntity; //导入依赖的package包/类
/**
* Callback method for receiving notification of a mouse movement on a
* chart.
*
* @param event information about the event.
*/
public void chartMouseMoved(ChartMouseEvent event)
{
if (!(event.getChart().getXYPlot().getRenderer() instanceof MotionBubbleRenderer))
{
return;
}
MotionBubbleRenderer renderer = (MotionBubbleRenderer) event.getChart().getXYPlot().getRenderer();
if (!(event.getEntity() instanceof XYItemEntity))
{
renderer.setHighlightedItem(-1, -1);
return;
}
XYItemEntity item = (XYItemEntity) event.getEntity();
renderer.setHighlightedItem(item.getSeriesIndex(), item.getItem());
}
示例9: testNoDisplayedItem
import org.jfree.chart.entity.XYItemEntity; //导入依赖的package包/类
/**
* A check to ensure that an item that falls outside the plot's data area
* does NOT generate an item entity.
*/
public void testNoDisplayedItem() {
XYSeriesCollection dataset = new XYSeriesCollection();
XYSeries s1 = new XYSeries("S1");
s1.add(10.0, 10.0);
dataset.addSeries(s1);
JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
dataset, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StandardXYItemRenderer());
NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
xAxis.setRange(0.0, 5.0);
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setRange(0.0, 5.0);
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
ChartRenderingInfo info = new ChartRenderingInfo();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info);
g2.dispose();
EntityCollection ec = info.getEntityCollection();
assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(),
XYItemEntity.class));
}
示例10: addEntity
import org.jfree.chart.entity.XYItemEntity; //导入依赖的package包/类
/**
* Adds an entity to the collection.
*
* @param entities the entity collection being populated.
* @param area the entity area (if <code>null</code> a default will be
* used).
* @param dataset the dataset.
* @param series the series.
* @param item the item.
* @param entityX the entity's center x-coordinate in user space.
* @param entityY the entity's center y-coordinate in user space.
*/
protected void addEntity(EntityCollection entities, Shape area,
XYDataset dataset, int series, int item,
double entityX, double entityY) {
if (!getItemCreateEntity(series, item)) {
return;
}
if (area == null) {
area = new Ellipse2D.Double(entityX - this.defaultEntityRadius,
entityY - this.defaultEntityRadius,
this.defaultEntityRadius * 2, this.defaultEntityRadius * 2);
}
String tip = null;
XYToolTipGenerator generator = getToolTipGenerator(series, item);
if (generator != null) {
tip = generator.generateToolTip(dataset, series, item);
}
String url = null;
if (getURLGenerator() != null) {
url = getURLGenerator().generateURL(dataset, series, item);
}
XYItemEntity entity = new XYItemEntity(area, dataset, series, item,
tip, url);
entities.add(entity);
}
示例11: mousePressed
import org.jfree.chart.entity.XYItemEntity; //导入依赖的package包/类
public void mousePressed(MouseEvent e) {
chartPanel.requestFocusInWindow();
Insets insets = chartPanel.getInsets();
int x = (int) ((e.getX() - insets.left) / chartPanel.getScaleX());
int y = (int) ((e.getY() - insets.top) / chartPanel.getScaleY());
ChartEntity entity = chartPanel.getChartRenderingInfo().getEntityCollection().getEntity(x, y);
if (entity == null || !(entity instanceof XYItemEntity))
return;
IsMovable = true;
chartPanel.setCursor(new Cursor(Cursor.HAND_CURSOR));
xyItemEntity = (XYItemEntity)entity;
XYPlot plot = chartPanel.getChart().getXYPlot();
Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea();
Point2D p = chartPanel.translateScreenToJava2D(e.getPoint());
initialMovePointY = plot.getRangeAxis().java2DToValue(p.getY(), dataArea, plot.getRangeAxisEdge());
}
示例12: testEquals
import org.jfree.chart.entity.XYItemEntity; //导入依赖的package包/类
/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
XYItemEntity e1 = new XYItemEntity(
new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0),
new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"
);
XYItemEntity e2 = new XYItemEntity(
new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0),
new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"
);
assertTrue(e1.equals(e2));
e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0));
assertFalse(e1.equals(e2));
e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0));
assertTrue(e1.equals(e2));
e1.setToolTipText("New ToolTip");
assertFalse(e1.equals(e2));
e2.setToolTipText("New ToolTip");
assertTrue(e1.equals(e2));
e1.setURLText("New URL");
assertFalse(e1.equals(e2));
e2.setURLText("New URL");
assertTrue(e1.equals(e2));
e1.setSeriesIndex(88);
assertFalse(e1.equals(e2));
e2.setSeriesIndex(88);
assertTrue(e1.equals(e2));
e1.setItem(88);
assertFalse(e1.equals(e2));
e2.setItem(88);
assertTrue(e1.equals(e2));
}
示例13: addEntity
import org.jfree.chart.entity.XYItemEntity; //导入依赖的package包/类
/**
* Adds an entity to the collection.
*
* @param entities the entity collection being populated.
* @param area the entity area (if <code>null</code> a default will be
* used).
* @param dataset the dataset.
* @param series the series.
* @param item the item.
* @param entityX the entity's center x-coordinate in user space (only
* used if <code>area</code> is <code>null</code>).
* @param entityY the entity's center y-coordinate in user space (only
* used if <code>area</code> is <code>null</code>).
*/
protected void addEntity(EntityCollection entities, Shape area,
XYDataset dataset, int series, int item,
double entityX, double entityY) {
if (!getItemCreateEntity(series, item)) {
return;
}
Shape hotspot = area;
if (hotspot == null) {
double r = getDefaultEntityRadius();
double w = r * 2;
if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
}
else {
hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
}
}
String tip = null;
XYToolTipGenerator generator = getToolTipGenerator(series, item);
if (generator != null) {
tip = generator.generateToolTip(dataset, series, item);
}
String url = null;
if (getURLGenerator() != null) {
url = getURLGenerator().generateURL(dataset, series, item);
}
XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
tip, url);
entities.add(entity);
}
示例14: addEntity
import org.jfree.chart.entity.XYItemEntity; //导入依赖的package包/类
/**
* Adds an entity to the collection. Note the the {@code entityX} and
* {@code entityY} coordinates are in Java2D space, should already be
* adjusted for the plot orientation, and will only be used if
* {@code hotspot} is {@code null}.
*
* @param entities the entity collection being populated.
* @param hotspot the entity area (if {@code null} a default will be
* used).
* @param dataset the dataset.
* @param series the series.
* @param item the item.
* @param entityX the entity x-coordinate (in Java2D space, only used if
* {@code hotspot} is {@code null}).
* @param entityY the entity y-coordinate (in Java2D space, only used if
* {@code hotspot} is {@code null}).
*/
protected void addEntity(EntityCollection entities, Shape hotspot,
XYDataset dataset, int series, int item, double entityX,
double entityY) {
if (!getItemCreateEntity(series, item)) {
return;
}
// if not hotspot is provided, we create a default based on the
// provided data coordinates (which are already in Java2D space)
if (hotspot == null) {
double r = getDefaultEntityRadius();
double w = r * 2;
hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
}
String tip = null;
XYToolTipGenerator generator = getToolTipGenerator(series, item);
if (generator != null) {
tip = generator.generateToolTip(dataset, series, item);
}
String url = null;
if (getURLGenerator() != null) {
url = getURLGenerator().generateURL(dataset, series, item);
}
XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
tip, url);
entities.add(entity);
}
示例15: addEntity
import org.jfree.chart.entity.XYItemEntity; //导入依赖的package包/类
/**
* Adds an entity to the collection.
*
* @param entities the entity collection being populated.
* @param area the entity area (if {@code null} a default will be
* used).
* @param dataset the dataset.
* @param series the series.
* @param item the item.
* @param entityX the entity's center x-coordinate in user space (only
* used if {@code area} is {@code null}).
* @param entityY the entity's center y-coordinate in user space (only
* used if {@code area} is {@code null}).
*/
protected void addEntity(EntityCollection entities, Shape area,
XYDataset dataset, int series, int item,
double entityX, double entityY) {
if (!getItemCreateEntity(series, item)) {
return;
}
Shape hotspot = area;
if (hotspot == null) {
double r = getDefaultEntityRadius();
double w = r * 2;
if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
}
else {
hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
}
}
String tip = null;
XYToolTipGenerator generator = getToolTipGenerator(series, item);
if (generator != null) {
tip = generator.generateToolTip(dataset, series, item);
}
String url = null;
if (getURLGenerator() != null) {
url = getURLGenerator().generateURL(dataset, series, item);
}
XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
tip, url);
entities.add(entity);
}