List of usage examples for org.jfree.chart.entity CategoryItemEntity getCategory
public Object getCategory()
From source file:de.laures.cewolf.taglib.tags.ChartMapTag.java
private String generateLink(Dataset dataset, ChartEntity ce) { String link = null;/* w w w .ja v a2 s . c o m*/ if (useJFreeChartLinkGenerator) { link = ce.getURLText(); } else if (linkGenerator instanceof CategoryItemLinkGenerator || linkGenerator instanceof XYItemLinkGenerator || linkGenerator instanceof PieSectionLinkGenerator) { if (linkGenerator instanceof CategoryItemLinkGenerator) { if (ce instanceof CategoryItemEntity) { CategoryItemEntity catEnt = (CategoryItemEntity) ce; link = ((CategoryItemLinkGenerator) linkGenerator).generateLink(dataset, catEnt.getSeries(), catEnt.getCategory()); } } if (linkGenerator instanceof XYItemLinkGenerator) { if (ce instanceof XYItemEntity) { XYItemEntity xyEnt = (XYItemEntity) ce; link = ((XYItemLinkGenerator) linkGenerator).generateLink(dataset, xyEnt.getSeriesIndex(), xyEnt.getItem()); } else { // Note; there is a simple ChartEntity also passed since Jfreechart 1.0rc1, that is ignored LOG.debug("Link entity skipped, not XYItemEntity.class:" + ce); } } if (linkGenerator instanceof PieSectionLinkGenerator) { if (ce instanceof PieSectionEntity) { PieSectionEntity pieEnt = (PieSectionEntity) ce; link = ((PieSectionLinkGenerator) linkGenerator).generateLink(dataset, pieEnt.getSectionKey()); } } } return link; }
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. j av a2 s . 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(); } } } } }
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()); }//www . j a va 2 s.c o m 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.bhavaya.ui.view.ChartView.java
public Object[] getBeansForEntity(ChartEntity entity) { int series = 0; Object category = null;//ww w. j a v a 2 s .c om if (entity instanceof CategoryItemEntity) { CategoryItemEntity itemEntity = (CategoryItemEntity) entity; category = itemEntity.getCategory(); series = itemEntity.getSeries(); } else if (entity instanceof PieSectionEntity) { PieSectionEntity sectionEntity = (PieSectionEntity) entity; category = sectionEntity.getSectionKey(); series = 0; } if (category != null) { return tableModelDataSet.getBeansForLocation(series, category); } else { return EMPTY_OBJECT_ARRAY; } }