org.jfree.data.xy.XYZDataset Java Examples

The following examples show how to use org.jfree.data.xy.XYZDataset. 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: XYShapeRenderer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the paint for a given series and item from a dataset.
 *
 * @param dataset  the dataset..
 * @param series  the series index.
 * @param item  the item index.
 * @param selected  is the data item selected?
 *
 * @return The paint.
 *
 * @since 1.2.0
 */
protected Paint getPaint(XYDataset dataset, int series, int item,
        boolean selected) {
    Paint p = null;
    if (dataset instanceof XYZDataset) {
        double z = ((XYZDataset) dataset).getZValue(series, item);
        p = this.paintScale.getPaint(z);
    }
    else {
        if (this.useFillPaint) {
            p = getItemFillPaint(series, item, selected);
        }
        else {
            p = getItemPaint(series, item, selected);
        }
    }
    return p;
}
 
Example #2
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 #3
Source File: DatasetUtilities.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Iterates over the data items of the xyz dataset to find
 * the z-dimension bounds.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param includeInterval  include the z-interval (if the dataset has a
 *     z-interval.
 *
 * @return The range (possibly <code>null</code>).
 */
public static Range iterateZBounds(XYZDataset dataset,
        boolean includeInterval) {
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int seriesCount = dataset.getSeriesCount();

    for (int series = 0; series < seriesCount; series++) {
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            double value = dataset.getZValue(series, item);
            if (!Double.isNaN(value)) {
                minimum = Math.min(minimum, value);
                maximum = Math.max(maximum, value);
            }
        }
    }

    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
Example #4
Source File: XYShapeRenderer.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Get the paint for a given series and item from a dataset.
 *
 * @param dataset  the dataset..
 * @param series  the series index.
 * @param item  the item index.
 *
 * @return The paint.
 */
protected Paint getPaint(XYDataset dataset, int series, int item) {
    Paint p;
    if (dataset instanceof XYZDataset) {
        double z = ((XYZDataset) dataset).getZValue(series, item);
        p = this.paintScale.getPaint(z);
    }
    else {
        if (this.useFillPaint) {
            p = getItemFillPaint(series, item);
        }
        else {
            p = getItemPaint(series, item);
        }
    }
    return p;
}
 
Example #5
Source File: DatasetUtilities.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Iterates over the data items of the xyz dataset to find
 * the z-dimension bounds.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param includeInterval  include the z-interval (if the dataset has a
 *     z-interval.
 *
 * @return The range (possibly <code>null</code>).
 */
public static Range iterateZBounds(XYZDataset dataset,
        boolean includeInterval) {
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int seriesCount = dataset.getSeriesCount();

    for (int series = 0; series < seriesCount; series++) {
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            double value = dataset.getZValue(series, item);
            if (!Double.isNaN(value)) {
                minimum = Math.min(minimum, value);
                maximum = Math.max(maximum, value);
            }
        }
    }

    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
Example #6
Source File: FormulaXYZTooltipGenerator.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Generates a tool tip text item for a particular item within a series.
 *
 * @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 XYZDataset dataset, final int series, final int item ) {
  try {
    final Object[] values = new Object[] {
      dataset.getX( series, item ), dataset.getY( series, item ), dataset.getZ( series, item ),
      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 #7
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a bubble chart with default settings.  The chart is composed of
 * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis,
 * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer}
 * to draw the data items.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A bubble chart.
 */
public static JFreeChart createBubbleChart(String title, String xAxisLabel,
        String yAxisLabel, XYZDataset dataset, boolean legend) {

    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
    XYItemRenderer renderer = new XYBubbleRenderer(
            XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
    renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
    plot.setRenderer(renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #8
Source File: DatasetUtilities.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Iterates over the data items of the xyz dataset to find
 * the z-dimension bounds.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param includeInterval  include the z-interval (if the dataset has a
 *     z-interval.
 *
 * @return The range (possibly <code>null</code>).
 */
public static Range iterateZBounds(XYZDataset dataset,
        boolean includeInterval) {
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int seriesCount = dataset.getSeriesCount();

    for (int series = 0; series < seriesCount; series++) {
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            double value = dataset.getZValue(series, item);
            if (!Double.isNaN(value)) {
                minimum = Math.min(minimum, value);
                maximum = Math.max(maximum, value);
            }
        }
    }

    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
Example #9
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. As a guideline, the URL should be valid within the context
 * of an XHTML 1.0 document.
 *
 * @param dataset the dataset (<code>null</code> not permitted).
 * @param series  the series index (zero-based).
 * @param item    the item index (zero-based).
 * @return A string containing the generated URL.
 */
public String generateURL( final XYZDataset dataset, final int series, final int item ) {
  try {
    final Object[] values = new Object[] {
      dataset.getX( series, item ), dataset.getY( series, item ), dataset.getZ( series, item ),
      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 #10
Source File: BubbleXYItemLabelGenerator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates a label string for an item in the dataset.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param series  the series (zero-based index).
 * @param item  the item (zero-based index).
 *
 * @return The label (possibly <code>null</code>).
 */
public String generateLabelString(XYDataset dataset, int series, int item) {
    String result = null;    
    Object[] items = null;
    if (dataset instanceof XYZDataset) {
        items = createItemArray((XYZDataset) dataset, series, item);
    }
    else {
        items = createItemArray(dataset, series, item);
    }
    result = MessageFormat.format(getFormatString(), items);
    return result;
}
 
Example #11
Source File: StandardXYZToolTipGenerator.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates the array of items that can be passed to the
 * {@link MessageFormat} class for creating labels.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param series  the series (zero-based index).
 * @param item  the item (zero-based index).
 *
 * @return The items (never <code>null</code>).
 */
protected Object[] createItemArray(XYZDataset dataset,
                                   int series, int item) {

    Object[] result = new Object[4];
    result[0] = dataset.getSeriesKey(series).toString();

    Number x = dataset.getX(series, item);
    DateFormat xf = getXDateFormat();
    if (xf != null) {
        result[1] = xf.format(x);
    }
    else {
        result[1] = getXFormat().format(x);
    }

    Number y = dataset.getY(series, item);
    DateFormat yf = getYDateFormat();
    if (yf != null) {
        result[2] = yf.format(y);
    }
    else {
        result[2] = getYFormat().format(y);
    }

    Number z = dataset.getZ(series, item);
    if (this.zDateFormat != null) {
        result[3] = this.zDateFormat.format(z);
    }
    else {
        result[3] = this.zFormat.format(z);
    }

    return result;

}
 
Example #12
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a bubble chart with default settings.  The chart is composed of
 * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis,
 * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer}
 * to draw the data items.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the orientation (horizontal or vertical) 
 *                     (<code>null</code> NOT permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A bubble chart.
 */
public static JFreeChart createBubbleChart(String title,
                                           String xAxisLabel,
                                           String yAxisLabel,
                                           XYZDataset dataset,
                                           PlotOrientation orientation,
                                           boolean legend,
                                           boolean tooltips,
                                           boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);

    XYItemRenderer renderer = new XYBubbleRenderer(
            XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseURLGenerator(new StandardXYZURLGenerator());
    }
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);

    return chart;

}
 
Example #13
Source File: StandardXYZToolTipGenerator.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates the array of items that can be passed to the
 * {@link MessageFormat} class for creating labels.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param series  the series (zero-based index).
 * @param item  the item (zero-based index).
 *
 * @return The items (never <code>null</code>).
 */
protected Object[] createItemArray(XYZDataset dataset,
                                   int series, int item) {

    Object[] result = new Object[4];
    result[0] = dataset.getSeriesKey(series).toString();

    Number x = dataset.getX(series, item);
    DateFormat xf = getXDateFormat();
    if (xf != null) {
        result[1] = xf.format(x);
    }
    else {
        result[1] = getXFormat().format(x);
    }

    Number y = dataset.getY(series, item);
    DateFormat yf = getYDateFormat();
    if (yf != null) {
        result[2] = yf.format(y);
    }
    else {
        result[2] = getYFormat().format(y);
    }

    Number z = dataset.getZ(series, item);
    if (this.zDateFormat != null) {
        result[3] = this.zDateFormat.format(z);
    }
    else {
        result[3] = this.zFormat.format(z);
    }

    return result;

}
 
Example #14
Source File: BubbleXYItemLabelGenerator.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates a label string for an item in the dataset.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param series  the series (zero-based index).
 * @param item  the item (zero-based index).
 *
 * @return The label (possibly <code>null</code>).
 */
@Override
public String generateLabelString(XYDataset dataset, int series, int item) {
    String result;
    Object[] items;
    if (dataset instanceof XYZDataset) {
        items = createItemArray((XYZDataset) dataset, series, item);
    }
    else {
        items = createItemArray(dataset, series, item);
    }
    result = MessageFormat.format(getFormatString(), items);
    return result;
}
 
Example #15
Source File: ChartFactory.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a bubble chart with default settings.  The chart is composed of
 * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis,
 * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer}
 * to draw the data items.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the orientation (horizontal or vertical) 
 *                     (<code>null</code> NOT permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A bubble chart.
 */
public static JFreeChart createBubbleChart(String title,
                                           String xAxisLabel,
                                           String yAxisLabel,
                                           XYZDataset dataset,
                                           PlotOrientation orientation,
                                           boolean legend,
                                           boolean tooltips,
                                           boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);

    XYItemRenderer renderer = new XYBubbleRenderer(
            XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYZURLGenerator());
    }
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);

    return chart;

}
 
Example #16
Source File: StandardXYZToolTipGenerator.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates the array of items that can be passed to the
 * {@link MessageFormat} class for creating labels.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param series  the series (zero-based index).
 * @param item  the item (zero-based index).
 *
 * @return The items (never <code>null</code>).
 */
protected Object[] createItemArray(XYZDataset dataset,
                                   int series, int item) {

    Object[] result = new Object[4];
    result[0] = dataset.getSeriesKey(series).toString();

    Number x = dataset.getX(series, item);
    DateFormat xf = getXDateFormat();
    if (xf != null) {
        result[1] = xf.format(x);
    }
    else {
        result[1] = getXFormat().format(x);
    }

    Number y = dataset.getY(series, item);
    DateFormat yf = getYDateFormat();
    if (yf != null) {
        result[2] = yf.format(y);
    }
    else {
        result[2] = getYFormat().format(y);
    }

    Number z = dataset.getZ(series, item);
    if (this.zDateFormat != null) {
        result[3] = this.zDateFormat.format(z);
    }
    else {
        result[3] = this.zFormat.format(z);
    }

    return result;

}
 
Example #17
Source File: LegacyChartType.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private XYZDataset createXYZDataset() {
  final DefaultXYZDataset xyzDataset = new DefaultXYZDataset();
  final double bs = 3;
  xyzDataset
    .addSeries( "First", new double[][] { { 1, 2, 3 }, { 2, 1, 3 }, { 0.1 * bs, 0.2 * bs, 0.1 * bs } } );// NON-NLS
  xyzDataset
    .addSeries( "Second", new double[][] { { 1, 2, 3 }, { 3, 0, 1 }, { 0.2 * bs, 0.1 * bs, 0.15 * bs } } );// NON-NLS
  return xyzDataset;
}
 
Example #18
Source File: BubbleXYItemLabelGenerator.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates the array of items that can be passed to the
 * {@link MessageFormat} class for creating labels.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param series  the series (zero-based index).
 * @param item  the item (zero-based index).
 *
 * @return The items (never <code>null</code>).
 */
protected Object[] createItemArray(XYZDataset dataset,
                                   int series, int item) {

    Object[] result = new Object[4];
    result[0] = dataset.getSeriesKey(series).toString();

    Number x = dataset.getX(series, item);
    DateFormat xf = getXDateFormat();
    if (xf != null) {
        result[1] = xf.format(x);
    }
    else {
        result[1] = getXFormat().format(x);
    }

    Number y = dataset.getY(series, item);
    DateFormat yf = getYDateFormat();
    if (yf != null) {
        result[2] = yf.format(y);
    }
    else {
        result[2] = getYFormat().format(y);
    }

    Number z = dataset.getZ(series, item);
    if (this.zDateFormat != null) {
        result[3] = this.zDateFormat.format(z);
    }
    else {
        result[3] = this.zFormat.format(z);
    }

    return result;

}
 
Example #19
Source File: ScatterPlotToolTipGenerator.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String generateToolTip(XYZDataset dataset, int series, int item) {
  if (rows[item].getPreferredPeakIdentity() != null) {
    featureIdentity = rows[item].getPreferredPeakIdentity().getName();
    return String.valueOf(featureIdentity + "\n" + xAxisLabel + ": "
        + numberFormat.format(dataset.getXValue(series, item)) + " " + yAxisLabel + ": "
        + numberFormat.format(dataset.getYValue(series, item)) + " " + zAxisLabel + ": "
        + numberFormat.format(dataset.getZValue(series, item)));
  } else {
    return String.valueOf(xAxisLabel + ": " + numberFormat.format(dataset.getXValue(series, item))
        + " " + yAxisLabel + ": " + numberFormat.format(dataset.getYValue(series, item)) + " "
        + zAxisLabel + ": " + numberFormat.format(dataset.getZValue(series, item)));
  }
}
 
Example #20
Source File: BubbleXYItemLabelGenerator.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Generates a label string for an item in the dataset.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param series  the series (zero-based index).
 * @param item  the item (zero-based index).
 *
 * @return The label (possibly <code>null</code>).
 */
@Override
public String generateLabelString(XYDataset dataset, int series, int item) {
    String result;
    Object[] items;
    if (dataset instanceof XYZDataset) {
        items = createItemArray((XYZDataset) dataset, series, item);
    }
    else {
        items = createItemArray(dataset, series, item);
    }
    result = MessageFormat.format(getFormatString(), items);
    return result;
}
 
Example #21
Source File: ChartFactory.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a bubble chart with default settings.  The chart is composed of
 * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis,
 * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer}
 * to draw the data items.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the orientation (horizontal or vertical)
 *                     (<code>null</code> NOT permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A bubble chart.
 */
public static JFreeChart createBubbleChart(String title, String xAxisLabel,
        String yAxisLabel, XYZDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);

    XYItemRenderer renderer = new XYBubbleRenderer(
            XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYZURLGenerator());
    }
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #22
Source File: StandardXYZToolTipGenerator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates the array of items that can be passed to the
 * {@link MessageFormat} class for creating labels.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param series  the series (zero-based index).
 * @param item  the item (zero-based index).
 *
 * @return The items (never <code>null</code>).
 */
protected Object[] createItemArray(XYZDataset dataset,
                                   int series, int item) {

    Object[] result = new Object[4];
    result[0] = dataset.getSeriesKey(series).toString();

    Number x = dataset.getX(series, item);
    DateFormat xf = getXDateFormat();
    if (xf != null) {
        result[1] = xf.format(x);
    }
    else {
        result[1] = getXFormat().format(x);
    }

    Number y = dataset.getY(series, item);
    DateFormat yf = getYDateFormat();
    if (yf != null) {
        result[2] = yf.format(y);
    }
    else {
        result[2] = getYFormat().format(y);
    }

    Number z = dataset.getZ(series, item);
    if (this.zDateFormat != null) {
        result[3] = this.zDateFormat.format(z);
    }
    else {
        result[3] = this.zFormat.format(z);
    }

    return result;

}
 
Example #23
Source File: DatasetUtilities.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the range of z-values in the specified dataset for the
 * data items belonging to the visible series and with x-values in the
 * given range.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param visibleSeriesKeys  the visible series keys (<code>null</code> not
 *     permitted).
 * @param xRange  the x-range (<code>null</code> not permitted).
 * @param includeInterval  a flag that determines whether or not the
 *     z-interval for the dataset is included (this only applies if the
 *     dataset has an interval, which is currently not supported).
 *
 * @return The y-range (possibly <code>null</code>).
 */
public static Range iterateToFindZBounds(XYZDataset dataset,
        List visibleSeriesKeys, Range xRange, boolean includeInterval) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    ParamChecks.nullNotPermitted(visibleSeriesKeys, "visibleSeriesKeys");
    ParamChecks.nullNotPermitted(xRange, "xRange");

    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;

    Iterator iterator = visibleSeriesKeys.iterator();
    while (iterator.hasNext()) {
        Comparable seriesKey = (Comparable) iterator.next();
        int series = dataset.indexOf(seriesKey);
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            double x = dataset.getXValue(series, item);
            double z = dataset.getZValue(series, item);
            if (xRange.contains(x)) {
                if (!Double.isNaN(z)) {
                    minimum = Math.min(minimum, z);
                    maximum = Math.max(maximum, z);
                }
            }
        }
    }

    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
Example #24
Source File: DefaultChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected JFreeChart createBubbleChart() throws JRException 
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart = ChartFactory.createBubbleChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression(((JRBubblePlot)getPlot()).getXAxisLabelExpression()),
			evaluateTextExpression(((JRBubblePlot)getPlot()).getYAxisLabelExpression()),
			 (XYZDataset)getDataset(),
			 getPlot().getOrientationValue().getOrientation(),
			 isShowLegend(),
			 true,
			 false);

	configureChart(jfreeChart);

	XYPlot xyPlot = (XYPlot)jfreeChart.getPlot();
	JRBubblePlot bubblePlot = (JRBubblePlot)getPlot();
	int scaleType = bubblePlot.getScaleTypeValue() == null ? ScaleTypeEnum.ON_RANGE_AXIS.getValue() : bubblePlot.getScaleTypeValue().getValue();
	XYBubbleRenderer bubbleRenderer = new XYBubbleRenderer( scaleType );
	xyPlot.setRenderer( bubbleRenderer );

	// Handle the axis formating for the category axis
	configureAxis(xyPlot.getDomainAxis(), bubblePlot.getXAxisLabelFont(),
			bubblePlot.getXAxisLabelColor(), bubblePlot.getXAxisTickLabelFont(),
			bubblePlot.getXAxisTickLabelColor(), bubblePlot.getXAxisTickLabelMask(), bubblePlot.getXAxisVerticalTickLabels(),
			bubblePlot.getXAxisLineColor(), false,
			(Comparable<?>)evaluateExpression(bubblePlot.getDomainAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(bubblePlot.getDomainAxisMaxValueExpression()));

	// Handle the axis formating for the value axis
	configureAxis(xyPlot.getRangeAxis(), bubblePlot.getYAxisLabelFont(),
			bubblePlot.getYAxisLabelColor(), bubblePlot.getYAxisTickLabelFont(),
			bubblePlot.getYAxisTickLabelColor(), bubblePlot.getYAxisTickLabelMask(), bubblePlot.getYAxisVerticalTickLabels(),
			bubblePlot.getYAxisLineColor(), true,
			(Comparable<?>)evaluateExpression(bubblePlot.getRangeAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(bubblePlot.getRangeAxisMaxValueExpression()));

	return jfreeChart;
}
 
Example #25
Source File: ChartFactory.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a bubble chart with default settings.  The chart is composed of
 * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis,
 * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer}
 * to draw the data items.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the orientation (horizontal or vertical)
 *                     (<code>null</code> NOT permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A bubble chart.
 */
public static JFreeChart createBubbleChart(String title, String xAxisLabel,
        String yAxisLabel, XYZDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);

    XYItemRenderer renderer = new XYBubbleRenderer(
            XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYZURLGenerator());
    }
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #26
Source File: XYShapeRenderer.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Return the range of z-values in the specified dataset.
 *  
 * @param dataset  the dataset (<code>null</code> permitted).
 * 
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 */
public Range findZBounds(XYZDataset dataset) {
    if (dataset != null) {
        return DatasetUtilities.findZBounds(dataset);
    }
    else {
        return null;
    }
}
 
Example #27
Source File: XYShapeRenderer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Return the range of z-values in the specified dataset.
 *  
 * @param dataset  the dataset (<code>null</code> permitted).
 * 
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 */
public Range findZBounds(XYZDataset dataset) {
    if (dataset != null) {
        return DatasetUtilities.findZBounds(dataset);
    }
    else {
        return null;
    }
}
 
Example #28
Source File: BubbleXYItemLabelGenerator.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Generates a label string for an item in the dataset.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param series  the series (zero-based index).
 * @param item  the item (zero-based index).
 *
 * @return The label (possibly <code>null</code>).
 */
@Override
public String generateLabelString(XYDataset dataset, int series, int item) {
    String result;
    Object[] items;
    if (dataset instanceof XYZDataset) {
        items = createItemArray((XYZDataset) dataset, series, item);
    }
    else {
        items = createItemArray(dataset, series, item);
    }
    result = MessageFormat.format(getFormatString(), items);
    return result;
}
 
Example #29
Source File: ChartFactory.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a bubble chart with default settings.  The chart is composed of
 * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis,
 * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer}
 * to draw the data items.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the orientation (horizontal or vertical)
 *                     (<code>null</code> NOT permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A bubble chart.
 */
public static JFreeChart createBubbleChart(String title, String xAxisLabel,
        String yAxisLabel, XYZDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);

    XYItemRenderer renderer = new XYBubbleRenderer(
            XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYZURLGenerator());
    }
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #30
Source File: DatasetUtilities.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the range of z-values in the specified dataset for the
 * data items belonging to the visible series and with x-values in the
 * given range.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param visibleSeriesKeys  the visible series keys (<code>null</code> not
 *     permitted).
 * @param xRange  the x-range (<code>null</code> not permitted).
 * @param includeInterval  a flag that determines whether or not the
 *     z-interval for the dataset is included (this only applies if the
 *     dataset has an interval, which is currently not supported).
 *
 * @return The y-range (possibly <code>null</code>).
 */
public static Range iterateToFindZBounds(XYZDataset dataset,
        List visibleSeriesKeys, Range xRange, boolean includeInterval) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    ParamChecks.nullNotPermitted(visibleSeriesKeys, "visibleSeriesKeys");
    ParamChecks.nullNotPermitted(xRange, "xRange");

    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;

    Iterator iterator = visibleSeriesKeys.iterator();
    while (iterator.hasNext()) {
        Comparable seriesKey = (Comparable) iterator.next();
        int series = dataset.indexOf(seriesKey);
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            double x = dataset.getXValue(series, item);
            double z = dataset.getZValue(series, item);
            if (xRange.contains(x)) {
                if (!Double.isNaN(z)) {
                    minimum = Math.min(minimum, z);
                    maximum = Math.max(maximum, z);
                }
            }
        }
    }

    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}