本文整理汇总了Java中org.jfree.chart.ChartMouseEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java ChartMouseEvent.getEntity方法的具体用法?Java ChartMouseEvent.getEntity怎么用?Java ChartMouseEvent.getEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.ChartMouseEvent
的用法示例。
在下文中一共展示了ChartMouseEvent.getEntity方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: chartMouseClicked
import org.jfree.chart.ChartMouseEvent; //导入方法依赖的package包/类
@Override
public void chartMouseClicked(ChartMouseEvent event)
{
if ((event.getEntity()!=null) && (event.getTrigger().getClickCount() > 1))
{
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try
{
GraphColumn bgc = getGraphColumn(event);
if (bgc == null)
{
return;
}
MQuery query = bgc.getMQuery(builder.getMGoal());
if (query != null)
AEnv.zoom(query);
else
log.warn("Nothing to zoom to - " + bgc);
}
finally
{
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
}
示例2: chartMouseMoved
import org.jfree.chart.ChartMouseEvent; //导入方法依赖的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());
}
示例3: chartMouseClicked
import org.jfree.chart.ChartMouseEvent; //导入方法依赖的package包/类
@Override
public void chartMouseClicked(ChartMouseEvent event) {
if (event.getEntity().getClass() == CategoryItemEntity.class) {
if ((getChart() != null) && (getChart().getClass() == HighlightableBarChart.class)) {
HighlightableBarChart chart = (HighlightableBarChart) getChart();
CategoryItemEntity entity = (CategoryItemEntity) event.getEntity();
// toggle highlight if already selected
if (chart.isHighlighted(entity)) {
chart.clearHighlights();
firePropertyChange("highlightedBar", getRowAndColumn(entity), null);
}
else {
chart.clearHighlights();
chart.highlightEntity(entity);
firePropertyChange("highlightedBar", null, getRowAndColumn(entity));
}
// assume whatever fired the event will repaint the chart
}
}
}
示例4: chartMouseClicked
import org.jfree.chart.ChartMouseEvent; //导入方法依赖的package包/类
public void chartMouseClicked(ChartMouseEvent e) {
if(e.getEntity() != null){
for(Area shape : areas){
//if(shape.contains(e.getTrigger().getPoint())){
if(shape.equals(e.getEntity().getArea())){
if(!e.getTrigger().isControlDown()){
selected.clear();
}
if(selected.contains(shape)){
selected.remove(shape);
} else {
selected.add(shape);
}
}
}
} else {
selected.clear();
}
setSelectedForList(true);
}
示例5: getGraphColumn
import org.jfree.chart.ChartMouseEvent; //导入方法依赖的package包/类
/**
* Get BarGraphColumn for ChartEntity
* @param event
* @return BarGraphColumn or null if not found
*/
private GraphColumn getGraphColumn(ChartMouseEvent event)
{
ChartEntity entity = event.getEntity();
String key = null;
if (entity instanceof CategoryItemEntity)
{
Comparable<?> colKey = ((CategoryItemEntity)entity).getColumnKey();
if (colKey != null)
{
key = colKey.toString();
}
}
else if (entity instanceof PieSectionEntity)
{
Comparable<?> sectionKey = ((PieSectionEntity)entity).getSectionKey();
if (sectionKey != null)
{
key = sectionKey.toString();
}
}
if (key == null)
{
return null;
}
for (int i = 0; i < list.size(); i++)
{
final String label = list.get(i).getLabel();
if (key.equals(label))
{
return list.get(i);
}
}
//
return null;
}
示例6: chartMouseClicked
import org.jfree.chart.ChartMouseEvent; //导入方法依赖的package包/类
@Override
public final void chartMouseClicked(ChartMouseEvent event) {
int series = -1;
ChartEntity entity = event.getEntity();
if (entity == null) {
return;
}
// users can click on either the line or the legend
// regardless, figure out the series index
if (entity.getClass() == XYItemEntity.class) {
series = ((XYItemEntity) event.getEntity()).getSeriesIndex();
}
else if (entity.getClass() == LegendItemEntity.class) {
LegendItemEntity legendEntity = (LegendItemEntity) event.getEntity();
XYDataset dataset = (XYDataset) legendEntity.getDataset();
for (int i = 0; i < dataset.getSeriesCount(); i++) {
if (dataset.getSeriesKey(i).equals(legendEntity.getSeriesKey())) {
series = i;
break;
}
}
}
if (series != -1) {
XYItemRenderer renderer = getChart().getXYPlot().getRenderer();
Stroke oldHighlight = renderer.getSeriesStroke(series);
// clear existing highlights
((AbstractRenderer) getChart().getXYPlot().getRenderer()).clearSeriesStrokes(false);
// toggle series stroke
if (oldHighlight != SELECTED_STROKE) {
renderer.setSeriesStroke(series, SELECTED_STROKE);
firePropertyChange("highlightedLine", null, series);
}
else {
renderer.setSeriesStroke(series, null);
firePropertyChange("highlightedLine", series, null);
}
// assume whatever fired the event will repaint the chart
}
}