List of usage examples for org.jfree.chart.entity EntityCollection getEntities
public Collection getEntities();
From source file:gov.nih.nci.caintegrator.ui.graphing.util.ImageMapUtil.java
/** * Same interface as ChartUtilities.writeImageMap. This version will find the * bounding rectangles for the entities in the ChartRenderingInfo object and will write those * to the image map.//w w w. ja v a2s. c om * @param writer * @param name * @param info * @param useOverlibToolTip */ public static void writeBoundingRectImageMap(PrintWriter writer, String name, ChartRenderingInfo info, boolean useOverlibToolTip) { EntityCollection collection = info.getEntityCollection(); Collection entities = collection.getEntities(); Collection<ChartEntity> boundingEntities = getBoundingEntities(entities); writeBoundingRectImageMap(writer, name, boundingEntities, useOverlibToolTip); }
From source file:gov.nih.nci.caintegrator.ui.graphing.util.ImageMapUtil.java
public static String getBoundingRectImageMapTag(String name, boolean useOverlibToolTip, ChartRenderingInfo info) {//from www . ja va 2 s. c om EntityCollection collection = info.getEntityCollection(); Collection entities = collection.getEntities(); Collection<ChartEntity> myBoundingEntities = getBoundingEntities(entities); System.out.println("Num entities=" + myBoundingEntities.size()); StringBuffer sb = new StringBuffer(); ChartEntity chartEntity; String areaTag; ToolTipTagFragmentGenerator ttg = null; if (useOverlibToolTip) { ttg = new CAIOverlibToolTipTagFragmentGenerator(); } else { ttg = new CAIStandardToolTipTagFragmentGenerator(); } StandardURLTagFragmentGenerator urlg = new StandardURLTagFragmentGenerator(); sb.append("\n\n<MAP name=\"" + name + "\">"); sb.append(StringUtils.getLineSeparator()); for (Iterator i = myBoundingEntities.iterator(); i.hasNext();) { chartEntity = (ChartEntity) i.next(); areaTag = chartEntity.getImageMapAreaTag(ttg, urlg).trim(); if (areaTag.length() > 0) { if (sb.indexOf(chartEntity.getImageMapAreaTag(ttg, urlg)) == -1) { sb.append(chartEntity.getImageMapAreaTag(ttg, urlg)); sb.append(StringUtils.getLineSeparator()); } } } sb.append("</MAP>\n\n"); return sb.toString(); }
From source file:org.mwc.cmap.grideditor.chart.JFreeChartComposite.java
@Override public void mouseDoubleClick(final MouseEvent event) { final Rectangle scaledDataArea = getScreenDataArea(event.x, event.y); if (scaledDataArea == null) return;//from w w w. java 2s .c om int x = (int) ((event.x - getClientArea().x) / getScaleX()); int y = (int) ((event.y - getClientArea().y) / getScaleY()); x = (int) ((event.x - getClientArea().x)); y = (int) ((event.y - getClientArea().y)); if (this.getChartRenderingInfo() != null) { final EntityCollection entities = this.getChartRenderingInfo().getEntityCollection(); if (entities != null) { for (final Object next : entities.getEntities()) { final ChartEntity nextEntity = (ChartEntity) next; if (false == nextEntity instanceof XYItemEntity) { continue; } if (nextEntity.getArea().contains(x, y)) { // sort out it's details final XYItemEntity xyEntity = (XYItemEntity) nextEntity; int theIndex = 0; if (xyEntity.getDataset() instanceof XYSeriesCollection) { theIndex = xyEntity.getItem(); // BackedChartItem backedChartItem; // XYSeries series = ((XYSeriesCollection) xyEntity.getDataset()) // .getSeries(seriesKey); // XYDataItem dataItem = series.getDataItem(xyEntity.getItem()); // if (dataItem instanceof BackedChartItem) // { // backedChartItem = (BackedChartItem) dataItem; // } } else if (xyEntity.getDataset() instanceof TimeSeriesCollection) { final TimeSeriesCollection theDataset = (TimeSeriesCollection) xyEntity.getDataset(); final TimeSeries theSeries = theDataset.getSeries(xyEntity.getSeriesIndex()); theIndex = xyEntity.getItem(); final int itemCount = theSeries.getItemCount(); // the items are in reverse order. reverse the index theIndex = itemCount - (theIndex + 1); // TimeSeries series = ((TimeSeriesCollection) // xyEntity.getDataset()) // .getSeries(seriesKey); // TimeSeriesDataItem dataItem = series // .getDataItem(xyEntity.getItem()); // if (dataItem instanceof BackedChartItem) // { // backedChartItem = (BackedChartItem) dataItem; // } } // clear the selection, as long as ctrl isn't selected if ((event.stateMask & SWT.CTRL) != 0) { // control is selected, so we don't want to clear the selection } else if ((event.stateMask & SWT.SHIFT) != 0) { // shift is selected, so we want to extend the selection } else { // we're not extending the selection, clear it, _dataGrid.getTableViewer().getTable().deselectAll(); } // try to select it _dataGrid.getTableViewer().getTable().select(theIndex); // and make sure it's visible _dataGrid.getTableViewer().getTable().showSelection(); // and tell the action buttons what's happened _dataGrid.getActionContext().setSelection(_dataGrid.getTableViewer().getSelection()); break; } } } } }
From source file:dbseer.gui.panel.DBSeerExplainChartPanel.java
@Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { displayPopupMenu(e.getX(), e.getY()); return;/*from www .ja v a 2 s. co m*/ } repaint(); int smallX = Math.min(startX, endX); int smallY = Math.min(startY, endY); int bigX = Math.max(startX, endX); int bigY = Math.max(startY, endY); XYPlot plot = this.getChart().getXYPlot(); Rectangle2D plotArea = this.getScreenDataArea(); double chartSmallX = plot.getDomainAxis().java2DToValue(smallX, plotArea, plot.getDomainAxisEdge()); double chartBigX = plot.getDomainAxis().java2DToValue(bigX, plotArea, plot.getDomainAxisEdge()); double chartSmallY = plot.getRangeAxis().java2DToValue(smallY, plotArea, plot.getRangeAxisEdge()); double chartBigY = plot.getRangeAxis().java2DToValue(bigY, plotArea, plot.getRangeAxisEdge()); double minXValue = Math.min(chartSmallX, chartBigX); double maxXValue = Math.max(chartSmallX, chartBigX); double minYValue = Math.min(chartSmallY, chartBigY); double maxYValue = Math.max(chartSmallY, chartBigY); //testLog.append("Scanning: (" + smallX + ", " + smallY + "), (" + bigX + ", " + bigY + ")\n"); //testLog.append("Scanning: X = [" + Math.min(chartSmallX, chartBigX) + ", " + Math.max(chartSmallX, chartBigX) + "]\n"); //testLog.append("Scanning: Y = [" + Math.min(chartSmallY, chartBigY) + ", " + Math.max(chartSmallY, chartBigY) + "]\n"); Set<XYItemEntity> foundItem = new HashSet<XYItemEntity>(); XYDataset dataset = this.getChart().getXYPlot().getDataset(); EntityCollection collection = this.getChartRenderingInfo().getEntityCollection(); for (Object obj : collection.getEntities()) { if (obj instanceof XYItemEntity) { XYItemEntity entity = (XYItemEntity) obj; int series = entity.getSeriesIndex(); int idx = entity.getItem(); if (dataset.getX(series, idx).doubleValue() >= minXValue && dataset.getX(series, idx).doubleValue() <= maxXValue && dataset.getY(series, idx).doubleValue() >= minYValue && dataset.getY(series, idx).doubleValue() <= maxYValue) { foundItem.add(entity); } } } // for (int x = smallX; x <= bigX; ++x) // { // for (int y = smallY; y <= bigY; ++y) // { // ChartEntity entity = this.getEntityForPoint(x, y); // if (entity instanceof XYItemEntity) // { // foundItem.add((XYItemEntity)entity); // } // } // } selectedItems = foundItem; // outlierRegion.clear(); // for (XYItemEntity entity : foundItem) // { // //testLog.append(entity.toString() + "\n"); // //testLog.append("Series = " + entity.getSeriesIndex() + ", "); // //testLog.append("X = " + entity.getDataset().getX(entity.getSeriesIndex(), entity.getItem()) + ", "); // //testLog.append("Y = " + entity.getDataset().getY(entity.getSeriesIndex(), entity.getItem()) + "\n"); // outlierRegion.add(entity.getDataset().getX(entity.getSeriesIndex(), entity.getItem()).doubleValue()); // } // // Collections.sort(outlierRegion); // if (!outlierRegion.isEmpty()) // { // testLog.setText(""); // testLog.append("Outlier time selected = ["); // for (int i = 0; i < outlierRegion.size(); ++i) // { // testLog.append(outlierRegion.get(i).toString()); // if (i < outlierRegion.size() - 1) // { // testLog.append(" "); // } // } // testLog.append("]\n"); // } }
From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.PrincipalComponentAnalysisPlot.java
/** * Same interface as ChartUtilities.writeImageMap. This version will find the * bounding rectangles for the entities in the ChartRenderingInfo object and will write those * to the image map./*from www . j av a 2 s.c o m*/ * @param writer * @param name * @param info * @param useOverlibToolTip */ public void writeBoundingRectImageMap(PrintWriter writer, String name, ChartRenderingInfo info, boolean useOverlibToolTip) { EntityCollection collection = info.getEntityCollection(); Collection entities = collection.getEntities(); Collection<ChartEntity> boundingEntities = getBoundingEntities(entities); writeBoundingRectImageMap(writer, name, boundingEntities, useOverlibToolTip); }