List of usage examples for org.jfree.chart.entity CategoryItemEntity setURLText
public void setURLText(String text)
From source file:org.pentaho.platform.uifoundation.chart.CategoryDatasetChartComponent.java
private void populateCategoryItemEntity(CategoryItemEntity categoryItemEntity, List seriesListArray) { if (seriesListArray == null) { seriesListArray = new ArrayList(categoryItemEntity.getDataset().getRowKeys()); }/*from w w w. ja va2 s . c om*/ String category = categoryItemEntity.getCategory().toString(); if (paramName == null) { categoryItemEntity.setURLText(category); } else { try { String encodedVal = URLEncoder.encode(category, LocaleHelper.getSystemEncoding()); String drillURL = TemplateUtil.applyTemplate(urlTemplate, paramName, encodedVal); /********** * PLATFORM-841: get series name from categoryItemEntity tooltip ******** * * The entity collection generated by JFreeChartEngine will not always be fully populated (i.e., the entity * collection WILL NOT contain items for values that are zero (0)), because items with zero value do not * need to be drawn! So, we cannot iterate through the seriseListArray and apply values from there to the * values in the entity collection. Instead, we must use the series index contained in the entity record to * access the appropriate series name. */ // ... get the series index and use it to find the series name in // the seriesListArray ... // int seriesIndex = categoryItemEntity.getSeries(); encodedVal = Messages.getInstance().getString("CategoryDatasetChartComponent.UNKNOWN_SERIES"); //$NON-NLS-1$ if ((seriesIndex >= 0) && (seriesIndex < seriesListArray.size())) { encodedVal = URLEncoder.encode(seriesListArray.get(seriesIndex).toString(), LocaleHelper.getSystemEncoding()); } else { error(Messages.getInstance().getErrorString( "CategoryDatasetChartComponent.ERROR_0002_INVALID_SERIES_INDEX", //$NON-NLS-1$ String.valueOf(seriesIndex))); } /********** PLATFORM-841 change end **********/ if (seriesName == null) { drillURL = TemplateUtil.applyTemplate(drillURL, "SERIES", encodedVal); //$NON-NLS-1$ } else { drillURL = TemplateUtil.applyTemplate(drillURL, seriesName, encodedVal); } categoryItemEntity.setURLText(drillURL); } catch (UnsupportedEncodingException ignored) { // TODO Auto-generated catch block this.getLogger().debug(ignored); } } }
From source file:org.pentaho.platform.uifoundation.chart.PieDatasetChartComponent.java
private void populateInfo(final ChartRenderingInfo info) { ArrayList keyListArray = null; int keyListIndex = 0; Iterator iter = info.getEntityCollection().iterator(); while (iter.hasNext()) { ChartEntity entity = (ChartEntity) iter.next(); if (entity instanceof PieSectionEntity) { PieSectionEntity pieSectionEntity = (PieSectionEntity) entity; String value = pieSectionEntity.getSectionKey().toString(); if (paramName == null) { pieSectionEntity.setURLText(value); } else { try { String encodedVal = URLEncoder.encode(value, LocaleHelper.getSystemEncoding()); String drillURL = TemplateUtil.applyTemplate(urlTemplate, paramName, encodedVal); pieSectionEntity.setURLText(drillURL); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); }/*from w w w . java 2s. c o m*/ } } else if (entity instanceof CategoryItemEntity) { CategoryItemEntity categoryItemEntity = (CategoryItemEntity) entity; if (keyListArray == null) { keyListArray = new ArrayList(categoryItemEntity.getDataset().getRowKeys()); } String category = categoryItemEntity.getCategory().toString(); if (paramName == null) { categoryItemEntity.setURLText(category); } else { try { String encodedVal = URLEncoder.encode(category, LocaleHelper.getSystemEncoding()); String drillURL = TemplateUtil.applyTemplate(urlTemplate, paramName, encodedVal); if (keyListIndex >= keyListArray.size()) { keyListIndex = 0; } encodedVal = URLEncoder.encode(keyListArray.get(keyListIndex).toString(), LocaleHelper.getSystemEncoding()); keyListIndex++; drillURL = TemplateUtil.applyTemplate(drillURL, paramName2, encodedVal); categoryItemEntity.setURLText(drillURL); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }