List of usage examples for org.jfree.chart.entity CategoryItemEntity getSeries
public int getSeries()
From source file:org.openfaces.component.chart.impl.helpers.ChartInfoUtil.java
private static GridPointInfo getGridPointInfo(CategoryItemEntity en, Chart chart) { ChartModel model = chart.getModel(); if (model == null) return null; GridPointInfo info = new GridPointInfoImpl(); info.setSeries(new SeriesInfoImpl()); info.getSeries().setIndex(en.getSeries()); ModelInfo modelInfo = new ModelInfo(model); if (!modelInfo.isDataEmpty()) { CategoryDataset ds = ModelConverter.toCategoryDataset(modelInfo); Comparable seriesKey = ds.getRowKey(en.getSeries()); Comparable tupleKey = ds.getColumnKey(en.getCategoryIndex()); Object tupleValue = ds.getValue(seriesKey, tupleKey); info.setIndex(en.getCategoryIndex()); info.setKey(tupleKey);//w w w .j a v a 2s . c o m info.setValue(tupleValue); info.getSeries().setKey(seriesKey); } return info; }
From source file:de.laures.cewolf.taglib.tags.ChartMapTag.java
private String generateLink(Dataset dataset, ChartEntity ce) { String link = null;/*from ww w . ja v a 2s . c om*/ 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:de.laures.cewolf.taglib.tags.ChartMapTag.java
private String generateToolTip(Dataset dataset, ChartEntity ce) throws JspException { String tooltip = null;//from ww w . j a va2s. co 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; }
From source file:org.bhavaya.ui.view.ChartView.java
public Object[] getBeansForEntity(ChartEntity entity) { int series = 0; Object category = null;/*from w ww . ja v a2 s.co m*/ 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; } }
From source file:com.choicemaker.cm.modelmaker.gui.utils.HistoChartPanel.java
public HistoChartPanel(final JFreeChart chart, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips, final ModelMaker modelMaker) { super(chart, properties, save, print, zoom, tooltips); this.modelMaker = modelMaker; // horizontal zoom doesn't work, by setting false we don't get bogus menu item // setHorizontalZoom(false); // setVerticalZoom(true); final JCheckBoxMenuItem logYScale = new JCheckBoxMenuItem( ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.test.logscale.y")); logYScale.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { CategoryPlot p = (CategoryPlot) chart.getPlot(); Axis oldAxis = p.getRangeAxis(); if (logYScale.isSelected()) { LogarithmicAxis yAxis = new LogarithmicAxis(ChoiceMakerCoreMessages.m .formatMessage("train.gui.modelmaker.panel.histogram.cm.numpairs")); yAxis.setStrictValuesFlag(false); p.setRangeAxis(yAxis);/*from ww w.j a v a 2 s . c om*/ } else { p.setRangeAxis(new NumberAxis(ChoiceMakerCoreMessages.m .formatMessage("train.gui.modelmaker.panel.histogram.cm.numpairs"))); } oldAxis.setPlot(null); chartChanged(new ChartChangeEvent(this)); } }); JPopupMenu popup = getPopupMenu(); popup.addSeparator(); popup.add(logYScale); popup.addSeparator(); select = new JMenu("Select"); final JMenuItem all = new JMenuItem("All"); select.add(all); final JMenuItem cmDiffer = new JMenuItem("Human marked differ"); select.add(cmDiffer); final JMenuItem cmHold = new JMenuItem("Human marked hold"); select.add(cmHold); final JMenuItem cmMatch = new JMenuItem("Human marked match"); select.add(cmMatch); ActionListener l = new ActionListener() { public void actionPerformed(ActionEvent ev) { ListeningMarkedRecordPairFilter filter = modelMaker.getFilter(); filter.reset(); filter.setFromPercentage(rangeFrom); filter.setToPercentage(rangeTo); Object src = ev.getSource(); if (src != all) { boolean[] b = new boolean[Decision.NUM_DECISIONS]; if (src == cmDiffer) { b[Decision.DIFFER.toInt()] = true; } else if (src == cmHold) { b[Decision.HOLD.toInt()] = true; } else if (src == cmMatch) { b[Decision.MATCH.toInt()] = true; } filter.setHumanDecision(b); } modelMaker.filterMarkedRecordPairList(); } }; all.addActionListener(l); cmDiffer.addActionListener(l); cmHold.addActionListener(l); cmMatch.addActionListener(l); popup.add(select); addChartMouseListener(new ChartMouseListener() { public void chartMouseClicked(ChartMouseEvent evt) { ChartEntity e = evt.getEntity(); if (e instanceof CategoryItemEntity) { CategoryItemEntity c = (CategoryItemEntity) e; int cat = c.getCategoryIndex(); HistoCategoryDataset data = (HistoCategoryDataset) ((CategoryPlot) getChart().getPlot()) .getDataset(); int len = data.getColumnCount(); float step = 1f / len; rangeFrom = cat * step; rangeTo = rangeFrom + step; ListeningMarkedRecordPairFilter filter = modelMaker.getFilter(); filter.reset(); filter.setFromPercentage(rangeFrom); filter.setToPercentage(rangeTo); boolean[] b = new boolean[Decision.NUM_DECISIONS]; int series = c.getSeries(); if (data.isIncludeHolds() && series != 0) { if (series == 1) { series = 2; } else { series = 1; } } b[series] = true; filter.setHumanDecision(b); modelMaker.filterMarkedRecordPairList(); } } public void chartMouseMoved(ChartMouseEvent arg0) { } }); }
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 ww . j a v a2s. 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); } } }