List of usage examples for org.jfree.chart.entity ChartEntity getToolTipText
public String getToolTipText()
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 ww w .j av a2 s. com*/ 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:gov.nih.nci.caintegrator.ui.graphing.util.ImageMapUtil.java
/** * Get a collection of entities with the area shape equal to the bounding rectangle * for the shape of original entity. This is necessary because the Javascript for the sample * selection lasso can only handle rect objects. * @param entities/*from w w w.ja va2 s . c om*/ * @return a collection of entities containing the bounding rectangles of the original entities */ private static Collection<ChartEntity> getBoundingEntities(Collection entities) { ChartEntity entity; ChartEntity boundingEntity; Shape shape; Rectangle2D boundingRect; Collection<ChartEntity> boundingEntities = new ArrayList<ChartEntity>(); for (Iterator i = entities.iterator(); i.hasNext();) { entity = (ChartEntity) i.next(); shape = entity.getArea(); boundingRect = shape.getBounds2D(); boundingEntity = new ChartEntity(boundingRect, entity.getToolTipText(), entity.getURLText()); boundingEntities.add(boundingEntity); } return boundingEntities; }
From source file:org.openfaces.component.chart.impl.helpers.MapRenderUtilities.java
private static String getImageMapAreaTag(Chart chart, ChartView view, ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, URLTagFragmentGenerator urlTagFragmentGenerator, ChartEntity entity, int entityIndex) { StringBuilder tag = new StringBuilder(); boolean hasURL = entity.getURLText() != null && !entity.getURLText().equals(""); boolean hasAction = viewHasAction(view); boolean hasPopup = viewHasPopup(view); boolean hasToolTip = entity.getToolTipText() != null && !entity.getToolTipText().equals(""); boolean hasSelection = chart.getChartSelection() != null; String onClick = getOnClick(chart, view, entity); String onMouseOut = getOnMouseOut(chart, view, entity); String onMouseOver = getOnMouseOver(chart, view, entity); boolean hasCustomOnMouseOver = onMouseOver != null && !onMouseOver.equals(""); boolean hasCustomOnMouseOut = onMouseOut != null && !onMouseOut.equals(""); boolean hasCustomClick = onClick != null && !onClick.equals(""); if (hasURL || hasToolTip || hasAction || hasPopup || hasCustomClick || hasSelection) { final FacesContext context = FacesContext.getCurrentInstance(); tag.append("<area"); if (hasAction || hasCustomClick || hasSelection) { if (hasSelection && chart.getChartMenu() != null && Environment.isChrome()) { tag.append(" oncontextmenu=\""); tag.append("O$('").append(chart.getClientId(context)) .append("')._areaContextMenuClick(event, '") .append(chart.getChartMenu().getClientId(context)).append("');"); tag.append("\""); }// w w w . jav a2s.c om tag.append(" onclick=\"O$('").append(chart.getClientId(context)).append("')._clickItem(event, '") .append(entityIndex).append("'"); tag.append(","); if (hasCustomClick) { tag.append("function(event){").append(onClick).append("}"); } else { tag.append("null"); } tag.append(",").append(hasAction); tag.append(",").append(hasSelection); tag.append(")\""); } if (hasCustomOnMouseOver || hasPopup) { StringBuilder mouseOverBuilder = new StringBuilder(); if (hasPopup) { final Integer oldEntityIndex = chart.getEntityIndex(); chart.setEntityIndex(entityIndex); mouseOverBuilder.append("O$.ChartPopup._show(event,"); mouseOverBuilder.append("'"); mouseOverBuilder.append(chart.getChartView().getChartPopup().getClientId(context)); mouseOverBuilder.append("',"); mouseOverBuilder.append("'"); mouseOverBuilder.append(entityIndex); mouseOverBuilder.append("'"); chart.setEntityIndex(oldEntityIndex); if (hasCustomOnMouseOver) { mouseOverBuilder.append(", function(){"); mouseOverBuilder.append(onMouseOver); mouseOverBuilder.append("}"); } } else { mouseOverBuilder.append(onMouseOver); } mouseOverBuilder.append(");"); tag.append(" onmouseover=\"").append(mouseOverBuilder.toString()).append("\""); } if (hasCustomOnMouseOut) { tag.append(" onmouseout=\"").append(onMouseOut).append("\""); } tag.append(" shape=\"").append(entity.getShapeType()).append("\"" + " coords=\"") .append(entity.getShapeCoords()).append("\""); if (hasToolTip) tag.append(toolTipTagFragmentGenerator.generateToolTipFragment(entity.getToolTipText())); if (hasURL && !hasAction) tag.append(urlTagFragmentGenerator.generateURLFragment(entity.getURLText())); if (!hasToolTip) tag.append(" alt=\"\""); tag.append("/>"); } return tag.toString(); }
From source file:gda.plots.SimpleLegendEntity.java
/** * Creates a SimpleLegendEntity by creating a new ChartEntity from an existing one and adding an SimpleXYSeries. * /* ww w. ja va 2 s .co m*/ * @param ce * @param sxys */ public SimpleLegendEntity(ChartEntity ce, SimpleXYSeries sxys) { super(ce.getArea(), ce.getToolTipText(), ce.getURLText()); this.sxys = sxys; }
From source file:com.swordlord.gozer.components.wicket.graph.common.GWChartPanel.java
protected DynamicImageMap constructImageMap(ChartImage image, String mapName) { DynamicImageMap imageMap = new DynamicImageMap("imageMap", mapName); EntityCollection entities = image.getRenderingInfo().getEntityCollection(); if (entities != null) { int count = entities.getEntityCount(); for (int i = count - 1; i >= 0; i--) { final ChartEntity entity = entities.getEntity(i); imageMap.addArea(entity.getShapeType(), entity.getShapeCoords(), entity.getToolTipText(), new AjaxLink<Object>("link") { private static final long serialVersionUID = -7982198051678987986L; @Override public void onClick(AjaxRequestTarget target) { onClickCallback(target, entity); }/* w ww .j a va 2 s .c o m*/ }); } } return imageMap; }
From source file:de.hs.mannheim.modUro.controller.diagram.fx.interaction.TooltipHandlerFX.java
/** * Returns the tooltip text./* w w w . j a va 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:com.manydesigns.portofino.pageactions.chart.jfreechart.JFreeChartInstance.java
public void toXhtml(@NotNull XhtmlBuffer xb) { xb.openElement("img"); xb.addAttribute("src", chartUrl); xb.addAttribute("alt", alt); xb.addAttribute("usemap", "#" + mapId); xb.addAttribute("style", "border: none;"); xb.addAttribute("class", "img-responsive"); xb.closeElement("img"); xb.openElement("map"); xb.addAttribute("id", mapId); xb.addAttribute("name", mapId); Iterator iter = renderingInfo.getEntityCollection().iterator(); while (iter.hasNext()) { ChartEntity ce = (ChartEntity) iter.next(); String shapeType = ce.getShapeType(); String shapeCoords = ce.getShapeCoords(); String tooltipText = ce.getToolTipText(); String urltext = ce.getURLText(); if (urltext == null) continue; xb.openElement("area"); xb.addAttribute("shape", shapeType); xb.addAttribute("coords", shapeCoords); xb.addAttribute("title", tooltipText); xb.addAttribute("alt", tooltipText); xb.addAttribute("href", urltext); xb.closeElement("area"); }//from ww w. j a v a 2s.c o m xb.closeElement("map"); }
From source file:com.manydesigns.portofino.pageactions.chart.JFreeChartInstance.java
public void toXhtml(@NotNull XhtmlBuffer xb) { xb.openElement("img"); xb.addAttribute("src", chartUrl); xb.addAttribute("alt", alt); xb.addAttribute("usemap", "#" + mapId); xb.addAttribute("style", "border: none;"); xb.closeElement("img"); xb.openElement("map"); xb.addAttribute("id", mapId); xb.addAttribute("name", mapId); Iterator iter = renderingInfo.getEntityCollection().iterator(); while (iter.hasNext()) { ChartEntity ce = (ChartEntity) iter.next(); String shapeType = ce.getShapeType(); String shapeCoords = ce.getShapeCoords(); String tooltipText = ce.getToolTipText(); String urltext = ce.getURLText(); if (urltext == null) continue; xb.openElement("area"); xb.addAttribute("shape", shapeType); xb.addAttribute("coords", shapeCoords); xb.addAttribute("title", tooltipText); xb.addAttribute("alt", tooltipText); xb.addAttribute("href", urltext); //hongliangpan add xb.addAttribute("target", "_BLANK"); // xb.addAttribute("onclick", // "window.open(this.href, '_blank', 'scrollbars=0,resizable=0;width=300');return false"); xb.closeElement("area"); }// w ww . ja va 2 s . c o m xb.closeElement("map"); }
From source file:org.openfaces.component.chart.impl.helpers.MapRenderUtilities.java
private static String getTitleImageMapAreaTag(Chart chart, ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, URLTagFragmentGenerator urlTagFragmentGenerator, ChartEntity entity) { StringBuilder tag = new StringBuilder(); ChartTitle title = chart.getTitle(); if (title == null) return ""; boolean hasURL = entity.getURLText() != null && !entity.getURLText().equals(""); boolean hasAction = title.getActionExpression() != null || title.getActionListeners().length > 0; boolean hasToolTip = title.getTooltip() != null && !title.getTooltip().equals(""); if (!hasURL && !hasToolTip && !hasAction) return ""; String fieldId = chart.getClientId(FacesContext.getCurrentInstance()) + ACTION_FIELD_SUFFIX; tag.append("<area"); if (hasAction) tag.append(" onclick=\"O$.setValue('").append(fieldId).append("','title'); O$.submitById('") .append(fieldId).append("');\""); tag.append(" shape=\"").append(entity.getShapeType()).append("\"" + " coords=\"") .append(entity.getShapeCoords()).append("\""); if (hasToolTip) { String toolTipText = entity.getToolTipText(); if (toolTipText != null) tag.append(toolTipTagFragmentGenerator.generateToolTipFragment(toolTipText)); }/*from www.ja v a2 s. c om*/ if (hasURL && !hasAction) tag.append(urlTagFragmentGenerator.generateURLFragment(entity.getURLText())); if (!hasToolTip) tag.append(" alt=\"\""); tag.append("/>"); return tag.toString(); }
From source file:de.laures.cewolf.taglib.tags.ChartMapTag.java
private String generateToolTip(Dataset dataset, ChartEntity ce) throws JspException { String tooltip = null;//from ww w . j ava 2 s . c o m if (useJFreeChartTooltipGenerator) { tooltip = ce.getToolTipText(); } else if (toolTipGenerator instanceof CategoryToolTipGenerator || toolTipGenerator instanceof XYToolTipGenerator || toolTipGenerator instanceof PieToolTipGenerator) { if (toolTipGenerator instanceof CategoryToolTipGenerator) { if (ce instanceof CategoryItemEntity) { CategoryItemEntity catEnt = (CategoryItemEntity) ce; tooltip = ((CategoryToolTipGenerator) toolTipGenerator).generateToolTip( (CategoryDataset) dataset, catEnt.getSeries(), catEnt.getCategoryIndex()); } } if (toolTipGenerator instanceof XYToolTipGenerator) { if (ce instanceof XYItemEntity) { XYItemEntity xyEnt = (XYItemEntity) ce; tooltip = ((XYToolTipGenerator) toolTipGenerator).generateToolTip((XYDataset) dataset, xyEnt.getSeriesIndex(), xyEnt.getItem()); } } if (toolTipGenerator instanceof PieToolTipGenerator) { if (ce instanceof PieSectionEntity) { PieSectionEntity pieEnt = (PieSectionEntity) ce; PieDataset ds = (PieDataset) dataset; final int index = pieEnt.getSectionIndex(); tooltip = ((PieToolTipGenerator) toolTipGenerator).generateToolTip(ds, ds.getKey(index), index); } } } else { // throw because category is unknown throw new JspException("TooltipgGenerator of class " + toolTipGenerator.getClass().getName() + " does not implement the appropriate TooltipGenerator interface for entity type " + ce.getClass().getName()); } return tooltip; }