List of usage examples for org.jfree.chart ChartRenderingInfo getEntityCollection
public EntityCollection getEntityCollection()
From source file:gov.nih.nci.caintegrator.ui.graphing.util.ImageMapUtil.java
public static String getBoundingRectImageMapTag(String name, boolean useOverlibToolTip, ChartRenderingInfo info) { 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;/*from w w w. ja va 2s.c om*/ 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: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.//from w ww . j a v a 2 s . co m * @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:net.sf.jasperreports.charts.util.ChartUtil.java
/** * /*from w ww . ja v a2s . c o m*/ */ public static List<JRPrintImageAreaHyperlink> getImageAreaHyperlinks(JFreeChart chart, ChartHyperlinkProvider chartHyperlinkProvider, Graphics2D grx, Rectangle2D renderingArea)// throws JRException { List<JRPrintImageAreaHyperlink> areaHyperlinks = null; if (chartHyperlinkProvider != null && chartHyperlinkProvider.hasHyperlinks()) { ChartRenderingInfo renderingInfo = new ChartRenderingInfo(); if (grx == null) { chart.createBufferedImage((int) renderingArea.getWidth(), (int) renderingArea.getHeight(), renderingInfo); } else { chart.draw(grx, renderingArea, renderingInfo); } EntityCollection entityCollection = renderingInfo.getEntityCollection(); if (entityCollection != null && entityCollection.getEntityCount() > 0) { areaHyperlinks = new ArrayList<JRPrintImageAreaHyperlink>(entityCollection.getEntityCount()); for (@SuppressWarnings("unchecked") Iterator<ChartEntity> it = entityCollection.iterator(); it.hasNext();) { ChartEntity entity = it.next(); JRPrintHyperlink printHyperlink = chartHyperlinkProvider.getEntityHyperlink(entity); if (printHyperlink != null) { JRPrintImageArea area = getImageArea(entity); JRPrintImageAreaHyperlink areaHyperlink = new JRPrintImageAreaHyperlink(); areaHyperlink.setArea(area); areaHyperlink.setHyperlink(printHyperlink); areaHyperlinks.add(areaHyperlink); } } } } return areaHyperlinks; }
From source file:net.sf.mzmine.chartbasics.ChartLogicsFX.java
/** * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY... * /* w w w . j a v 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 w w w . ja v a 2s. c o 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:org.openfaces.component.chart.impl.helpers.MapRenderUtilities.java
public static String getImageMapExt(Chart chart, String name, ChartRenderingInfo info, ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, URLTagFragmentGenerator urlTagFragmentGenerator) { StringBuilder sb = new StringBuilder(); sb.append("<map id=\"").append(name).append("\" name=\"").append(name).append("\">"); sb.append(StringUtils.getLineSeparator()); // the following is needed for displaying tooltips under IE (doesn't display tooltips if there's no area with href) String fakeArea = "<area shape=\"rect\" coords=\"0,0,0,0\" href=\"fake.jsp\" alt=\"\" title=\"\" />"; sb.append(fakeArea);/*from www. j av a 2 s . c o m*/ sb.append(StringUtils.getLineSeparator()); EntityCollection entities = info.getEntityCollection(); if (entities != null) { int count = entities.getEntityCount(); ChartView view = chart.getChartView(); for (int i = count - 1; i >= 0; i--) { ChartEntity entity = entities.getEntity(i); if (entity.getToolTipText() == null && entity.getURLText() == null && getOnClick(chart, chart.getChartView(), entity) == null && !viewHasAction(view) && !viewHasPopup(view) && chart.getChartSelection() == null) continue; String area; if (i == 0) { area = getTitleImageMapAreaTag(chart, new StandardToolTipTagFragmentGenerator(), new StandardURLTagFragmentGenerator(), entity); } else { if (entity instanceof PieSectionEntity) { area = getImageMapAreaTag(chart, view, toolTipTagFragmentGenerator, urlTagFragmentGenerator, entity, i); } else if (entity instanceof CategoryItemEntity) { area = getImageMapAreaTag(chart, view, toolTipTagFragmentGenerator, urlTagFragmentGenerator, entity, i); } else if (entity instanceof XYItemEntity) { area = getImageMapAreaTag(chart, view, toolTipTagFragmentGenerator, urlTagFragmentGenerator, entity, i); } else { area = ""; } } if (area.length() > 0) { sb.append(area); sb.append(StringUtils.getLineSeparator()); } } } sb.append("</map>"); return sb.toString(); }
From source file:de.hs.mannheim.modUro.controller.diagram.fx.interaction.TooltipHandlerFX.java
/** * Returns the tooltip text./*from ww w . ja v a 2 s . 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:net.sf.jsfcomp.chartcreator.renderkit.ChartRenderer.java
private void renderImageMapSupport(FacesContext context, UIChart uichart, ChartRenderingInfo chartRenderingInfo) { ResponseWriter writer = context.getResponseWriter(); try {/*from w w w.ja v a 2s . c om*/ Iterator entities = chartRenderingInfo.getEntityCollection().iterator(); while (entities.hasNext()) { ChartEntity entity = (ChartEntity) entities.next(); if (entity instanceof CategoryLabelEntity) { CategoryLabelEntity categoryEntity = (CategoryLabelEntity) entity; if (categoryEntity.getKey() != null) { categoryEntity.setToolTipText(categoryEntity.getKey().toString()); categoryEntity.setURLText("?category=" + categoryEntity.getKey().toString()); } } } writer.write("<script>"); writer.write("function chart" + uichart.getId() + "Click(data) {"); if (uichart.getOngeneratedimagemapclick() != null) writer.write(" " + uichart.getOngeneratedimagemapclick() + "(data);"); writer.write("}"); writer.write("</script>"); } catch (IOException error) { error.printStackTrace(); } }
From source file:org.openfaces.renderkit.chart.ChartRenderer.java
private void encodeChartPopup(FacesContext facesContext, Chart chart, ChartView view, ChartRenderingInfo renderingInfo) throws IOException { EntityCollection entities = renderingInfo.getEntityCollection(); if (entities != null) { int count = entities.getEntityCount(); for (int i = count - 1; i >= 0; i--) { ChartEntity entity = entities.getEntity(i); Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap(); chart.setEntityIndex(i);//from w w w . java2 s . c om if (view instanceof GridChartView) { final GridPointInfo pointInfo = ChartInfoUtil.getGridPointInfo(entity, chart); if (pointInfo != null) { Object oldAttributeValue = requestMap.put("point", pointInfo); renderChartPopup(facesContext, view); requestMap.put("point", oldAttributeValue); } } else if (view instanceof PieChartView) { final PieSectorInfo pieSectorInfo = ChartInfoUtil.getPieSectorInfo(entity); if (pieSectorInfo != null) { Object oldAttributeValue = requestMap.put("sector", pieSectorInfo); renderChartPopup(facesContext, view); requestMap.put("sector", oldAttributeValue); } } } } }
From source file:org.pentaho.platform.uifoundation.chart.XYSeriesCollectionChartComponent.java
private void populateInfo(final ChartRenderingInfo info) { if (urlTemplate == null) { return;//from w w w . j a v a 2 s .c om } Iterator iter = info.getEntityCollection().iterator(); while (iter.hasNext()) { ChartEntity entity = (ChartEntity) iter.next(); if (entity instanceof XYItemEntity) { if (urlTemplate != null) { XYItemEntity xyItemEntity = (XYItemEntity) entity; if (paramName == null) { xyItemEntity.setURLText(urlTemplate); } else { try { int seriesIndex = xyItemEntity.getSeriesIndex(); int itemIndex = xyItemEntity.getItem(); String xySeriesKey = (String) ((XYSeriesCollection) xyItemEntity.getDataset()) .getSeriesKey(seriesIndex); String encodedVal = URLEncoder.encode(xySeriesKey, LocaleHelper.getSystemEncoding()); String drillURL = TemplateUtil.applyTemplate(urlTemplate, paramName, encodedVal); String itemValueStr = ((XYSeriesCollection) xyItemEntity.getDataset()) .getX(seriesIndex, itemIndex).toString(); encodedVal = URLEncoder.encode(itemValueStr, LocaleHelper.getSystemEncoding()); if (seriesName == null) { drillURL = TemplateUtil.applyTemplate(drillURL, "SERIES", encodedVal); //$NON-NLS-1$ } else { drillURL = TemplateUtil.applyTemplate(drillURL, seriesName, encodedVal); } xyItemEntity.setURLText(drillURL); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } } }