Java Code Examples for org.jfree.data.xy.XYDataset#getSeriesKey()

The following examples show how to use org.jfree.data.xy.XYDataset#getSeriesKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XYChartHyperlinkProvider.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public JRPrintHyperlink getEntityHyperlink(ChartEntity entity)
{
	JRPrintHyperlink printHyperlink = null;
	if (hasHyperlinks() && entity instanceof XYItemEntity)
	{
		XYItemEntity itemEntity = (XYItemEntity) entity;
		XYDataset dataset = itemEntity.getDataset();
		Comparable<?> serie = dataset.getSeriesKey(itemEntity.getSeriesIndex());
		Map<Pair, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(serie);
		if (serieHyperlinks != null)
		{
			Number x = dataset.getX(itemEntity.getSeriesIndex(), itemEntity.getItem());
			Number y = dataset.getY(itemEntity.getSeriesIndex(), itemEntity.getItem());
			Pair<Number,Number> xyKey = new Pair<Number,Number>(x, y);
			printHyperlink = serieHyperlinks.get(xyKey);
		}
	}
	return printHyperlink;
}
 
Example 2
Source File: TimeSeriesURLGenerator.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Generates a URL for a particular item within a series.
 *
 * @param dataset  the dataset.
 * @param series  the series number (zero-based index).
 * @param item  the item number (zero-based index).
 *
 * @return The generated URL.
 */
public String generateURL(XYDataset dataset, int series, int item) {
    String result = this.prefix;
    boolean firstParameter = result.indexOf("?") == -1;
    Comparable seriesKey = dataset.getSeriesKey(series);
    if (seriesKey != null) {
        result += firstParameter ? "?" : "&amp;";
        result += this.seriesParameterName + "=" + seriesKey.toString();
        firstParameter = false;
    }

    long x = (long) dataset.getXValue(series, item);
    String xValue = this.dateFormat.format(new Date(x));
    result += firstParameter ? "?" : "&amp;";
    result += this.itemParameterName + "=" + xValue;

    return result;
}
 
Example 3
Source File: FormulaXYZTooltipGenerator.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Generates the tooltip text for the specified item.
 *
 * @param dataset the dataset (<code>null</code> not permitted).
 * @param series  the series index (zero-based).
 * @param item    the item index (zero-based).
 * @return The tooltip text (possibly <code>null</code>).
 */
public String generateToolTip( final XYDataset dataset, final int series, final int item ) {
  if ( dataset instanceof XYZDataset ) {
    return generateToolTip( (XYZDataset) dataset, series, item );
  }
  try {
    final Object[] values = new Object[] {
      dataset.getX( series, item ), dataset.getY( series, item ), null,
      IntegerCache.getInteger( series ), dataset.getSeriesKey( series ),
      IntegerCache.getInteger( dataset.getSeriesCount() ),
      IntegerCache.getInteger( item ), IntegerCache.getInteger( dataset.getItemCount( series ) )
    };
    formulaExpression.setRuntime( new WrapperExpressionRuntime
      ( new StaticDataRow( ADDITIONAL_COLUMN_KEYS, values ), runtime ) );
    final Object o = formulaExpression.getValue();
    if ( o == null ) {
      return null;
    }
    return String.valueOf( o );
  } finally {
    formulaExpression.setRuntime( null );
  }
}
 
Example 4
Source File: FormulaXYZURLGenerator.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Generates a URL for a particular item within a series.
 *
 * @param dataset the dataset.
 * @param series  the series number (zero-based index).
 * @param item    the item number (zero-based index).
 * @return The generated URL.
 */
public String generateURL( final XYDataset dataset, final int series, final int item ) {
  if ( dataset instanceof XYZDataset ) {
    return generateURL( (XYZDataset) dataset, series, item );
  }
  try {
    final Object[] values = new Object[] {
      dataset.getX( series, item ), dataset.getY( series, item ), null,
      IntegerCache.getInteger( series ), dataset.getSeriesKey( series ),
      IntegerCache.getInteger( dataset.getSeriesCount() ),
      IntegerCache.getInteger( item ), IntegerCache.getInteger( dataset.getItemCount( series ) )
    };
    formulaExpression.setRuntime( new WrapperExpressionRuntime
      ( new StaticDataRow( ADDITIONAL_COLUMN_KEYS, values ), runtime ) );
    final Object o = formulaExpression.getValue();
    if ( o == null ) {
      return null;
    }
    return String.valueOf( o );
  } finally {
    formulaExpression.setRuntime( null );
  }
}
 
Example 5
Source File: XYDatasetLabelGenerator.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String generateLabel(XYDataset dataset, int series, int item)
{
	Comparable<?> seriesName = dataset.getSeriesKey(series);
	Map<Number,String> labels = labelsMap.get(seriesName);
	if(labels != null)
	{
		return labels.get(((XYSeriesCollection)dataset).getX(series, item));
	}
	return super.generateLabel( dataset, series, item );
}
 
Example 6
Source File: TimeSeriesLabelGenerator.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String generateLabel(XYDataset dataset, int series, int item)
{
	Comparable<?> seriesName = dataset.getSeriesKey(series);
	Map<RegularTimePeriod, String> labels = labelsMap.get(seriesName);
	if(labels != null)
	{
		return labels.get(((TimeSeriesCollection)dataset).getSeries(series).getTimePeriod(item));
	}
	return super.generateLabel( dataset, series, item );
}
 
Example 7
Source File: TimePeriodDatasetLabelGenerator.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String generateLabel(XYDataset dataset, int series, int item)
{
	Comparable<?> seriesName = dataset.getSeriesKey(series);
	Map<TimePeriod, String> labels = labelsMap.get(seriesName);
	if(labels != null)
	{
		return labels.get(((TimePeriodValuesCollection)dataset).getSeries(series).getTimePeriod(item));
	}
	return super.generateLabel( dataset, series, item );
}
 
Example 8
Source File: XYPlotToolTipGenerator.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String generateToolTip(XYDataset data, int series, int item) {
    final Comparable key = data.getSeriesKey(series);
    final double valueX = data.getXValue(series, item);
    final double valueY = data.getYValue(series, item);
    return String.format("%s: X = %6.2f, Y = %6.2f", key, valueX, valueY);
}
 
Example 9
Source File: TimeAndValueTooltipGenerator.java    From nmonvisualizer with Apache License 2.0 4 votes vote down vote up
@Override
public String generateToolTip(XYDataset dataset, int series, int item) {
    return (dataset.getSeriesCount() > 1 ? dataset.getSeriesKey(series) + " " : "")
            + TIME_FORMAT.format(new java.util.Date((long) dataset.getXValue(series, item))) + " - "
            + NUMBER_FORMAT.format(dataset.getYValue(series, item));
}
 
Example 10
Source File: LineChartBuilder.java    From nmonvisualizer with Apache License 2.0 4 votes vote down vote up
@Override
public String generateToolTip(XYDataset dataset, int series, int item) {
    return (dataset.getSeriesCount() > 1 ? dataset.getSeriesKey(series) + " " : "")
            + DATE_FORMAT.format(new java.util.Date((long) dataset.getXValue(series, item))) + " - "
            + NUMBER_FORMAT.format(dataset.getYValue(series, item));
}
 
Example 11
Source File: MetadataInURLGenerator.java    From SensorWebClient with GNU General Public License v2.0 4 votes vote down vote up
public String generateURL(XYDataset dataset, int series, int item) {
    String seriesID = (String) dataset.getSeriesKey(series);
    RenderingDesign dd = designDescriptions.get(seriesID);
    return dd.getUomLabel() + ";" + Integer.toHexString(dd.getColor().getRGB()).substring(2); 
}