Java Code Examples for org.jfree.data.xy.XYDataset#getX()
The following examples show how to use
org.jfree.data.xy.XYDataset#getX() .
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: BoxAndWhiskerXYToolTipGenerator.java From astor with GNU General Public License v2.0 | 6 votes |
/** * 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(XYDataset dataset, int series, int item) { Object[] result = new Object[8]; result[0] = dataset.getSeriesKey(series).toString(); Number x = dataset.getX(series, item); if (getXDateFormat() != null) { result[1] = getXDateFormat().format(new Date(x.longValue())); } else { result[1] = getXFormat().format(x); } NumberFormat formatter = getYFormat(); if (dataset instanceof BoxAndWhiskerXYDataset) { BoxAndWhiskerXYDataset d = (BoxAndWhiskerXYDataset) dataset; result[2] = formatter.format(d.getMeanValue(series, item)); result[3] = formatter.format(d.getMedianValue(series, item)); result[4] = formatter.format(d.getMinRegularValue(series, item)); result[5] = formatter.format(d.getMaxRegularValue(series, item)); result[6] = formatter.format(d.getQ1Value(series, item)); result[7] = formatter.format(d.getQ3Value(series, item)); } return result; }
Example 2
Source File: BoxAndWhiskerXYToolTipGenerator.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * 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>). */ @Override protected Object[] createItemArray(XYDataset dataset, int series, int item) { Object[] result = new Object[8]; result[0] = dataset.getSeriesKey(series).toString(); Number x = dataset.getX(series, item); if (getXDateFormat() != null) { result[1] = getXDateFormat().format(new Date(x.longValue())); } else { result[1] = getXFormat().format(x); } NumberFormat formatter = getYFormat(); if (dataset instanceof BoxAndWhiskerXYDataset) { BoxAndWhiskerXYDataset d = (BoxAndWhiskerXYDataset) dataset; result[2] = formatter.format(d.getMeanValue(series, item)); result[3] = formatter.format(d.getMedianValue(series, item)); result[4] = formatter.format(d.getMinRegularValue(series, item)); result[5] = formatter.format(d.getMaxRegularValue(series, item)); result[6] = formatter.format(d.getQ1Value(series, item)); result[7] = formatter.format(d.getQ3Value(series, item)); } return result; }
Example 3
Source File: BoxAndWhiskerXYToolTipGenerator.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * 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>). */ @Override protected Object[] createItemArray(XYDataset dataset, int series, int item) { Object[] result = new Object[8]; result[0] = dataset.getSeriesKey(series).toString(); Number x = dataset.getX(series, item); if (getXDateFormat() != null) { result[1] = getXDateFormat().format(new Date(x.longValue())); } else { result[1] = getXFormat().format(x); } NumberFormat formatter = getYFormat(); if (dataset instanceof BoxAndWhiskerXYDataset) { BoxAndWhiskerXYDataset d = (BoxAndWhiskerXYDataset) dataset; result[2] = formatter.format(d.getMeanValue(series, item)); result[3] = formatter.format(d.getMedianValue(series, item)); result[4] = formatter.format(d.getMinRegularValue(series, item)); result[5] = formatter.format(d.getMaxRegularValue(series, item)); result[6] = formatter.format(d.getQ1Value(series, item)); result[7] = formatter.format(d.getQ3Value(series, item)); } return result; }
Example 4
Source File: FormulaXYZURLGenerator.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * 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: FormulaXYZTooltipGenerator.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * 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 6
Source File: BoxAndWhiskerXYToolTipGenerator.java From opensim-gui with Apache License 2.0 | 6 votes |
/** * 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(XYDataset dataset, int series, int item) { Object[] result = new Object[8]; result[0] = dataset.getSeriesKey(series).toString(); Number x = dataset.getX(series, item); if (getXDateFormat() != null) { result[1] = getXDateFormat().format(new Date(x.longValue())); } else { result[1] = getXFormat().format(x); } NumberFormat formatter = getYFormat(); if (dataset instanceof BoxAndWhiskerXYDataset) { BoxAndWhiskerXYDataset d = (BoxAndWhiskerXYDataset) dataset; result[2] = formatter.format(d.getMeanValue(series, item)); result[3] = formatter.format(d.getMedianValue(series, item)); result[4] = formatter.format(d.getMinRegularValue(series, item)); result[5] = formatter.format(d.getMaxRegularValue(series, item)); result[6] = formatter.format(d.getQ1Value(series, item)); result[7] = formatter.format(d.getQ3Value(series, item)); } return result; }
Example 7
Source File: BoxAndWhiskerXYToolTipGenerator.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * 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>). */ @Override protected Object[] createItemArray(XYDataset dataset, int series, int item) { Object[] result = new Object[8]; result[0] = dataset.getSeriesKey(series).toString(); Number x = dataset.getX(series, item); if (getXDateFormat() != null) { result[1] = getXDateFormat().format(new Date(x.longValue())); } else { result[1] = getXFormat().format(x); } NumberFormat formatter = getYFormat(); if (dataset instanceof BoxAndWhiskerXYDataset) { BoxAndWhiskerXYDataset d = (BoxAndWhiskerXYDataset) dataset; result[2] = formatter.format(d.getMeanValue(series, item)); result[3] = formatter.format(d.getMedianValue(series, item)); result[4] = formatter.format(d.getMinRegularValue(series, item)); result[5] = formatter.format(d.getMaxRegularValue(series, item)); result[6] = formatter.format(d.getQ1Value(series, item)); result[7] = formatter.format(d.getQ3Value(series, item)); } return result; }
Example 8
Source File: BoxAndWhiskerXYToolTipGenerator.java From astor with GNU General Public License v2.0 | 6 votes |
/** * 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(XYDataset dataset, int series, int item) { Object[] result = new Object[8]; result[0] = dataset.getSeriesKey(series).toString(); Number x = dataset.getX(series, item); if (getXDateFormat() != null) { result[1] = getXDateFormat().format(new Date(x.longValue())); } else { result[1] = getXFormat().format(x); } NumberFormat formatter = getYFormat(); if (dataset instanceof BoxAndWhiskerXYDataset) { BoxAndWhiskerXYDataset d = (BoxAndWhiskerXYDataset) dataset; result[2] = formatter.format(d.getMeanValue(series, item)); result[3] = formatter.format(d.getMedianValue(series, item)); result[4] = formatter.format(d.getMinRegularValue(series, item)); result[5] = formatter.format(d.getMaxRegularValue(series, item)); result[6] = formatter.format(d.getQ1Value(series, item)); result[7] = formatter.format(d.getQ3Value(series, item)); } return result; }
Example 9
Source File: BoxAndWhiskerXYToolTipGenerator.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * 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>). */ @Override protected Object[] createItemArray(XYDataset dataset, int series, int item) { Object[] result = new Object[8]; result[0] = dataset.getSeriesKey(series).toString(); Number x = dataset.getX(series, item); if (getXDateFormat() != null) { result[1] = getXDateFormat().format(new Date(x.longValue())); } else { result[1] = getXFormat().format(x); } NumberFormat formatter = getYFormat(); if (dataset instanceof BoxAndWhiskerXYDataset) { BoxAndWhiskerXYDataset d = (BoxAndWhiskerXYDataset) dataset; result[2] = formatter.format(d.getMeanValue(series, item)); result[3] = formatter.format(d.getMedianValue(series, item)); result[4] = formatter.format(d.getMinRegularValue(series, item)); result[5] = formatter.format(d.getMaxRegularValue(series, item)); result[6] = formatter.format(d.getQ1Value(series, item)); result[7] = formatter.format(d.getQ3Value(series, item)); } return result; }
Example 10
Source File: BoxAndWhiskerXYToolTipGenerator.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * 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>). */ @Override protected Object[] createItemArray(XYDataset dataset, int series, int item) { Object[] result = new Object[8]; result[0] = dataset.getSeriesKey(series).toString(); Number x = dataset.getX(series, item); if (getXDateFormat() != null) { result[1] = getXDateFormat().format(new Date(x.longValue())); } else { result[1] = getXFormat().format(x); } NumberFormat formatter = getYFormat(); if (dataset instanceof BoxAndWhiskerXYDataset) { BoxAndWhiskerXYDataset d = (BoxAndWhiskerXYDataset) dataset; result[2] = formatter.format(d.getMeanValue(series, item)); result[3] = formatter.format(d.getMedianValue(series, item)); result[4] = formatter.format(d.getMinRegularValue(series, item)); result[5] = formatter.format(d.getMaxRegularValue(series, item)); result[6] = formatter.format(d.getQ1Value(series, item)); result[7] = formatter.format(d.getQ3Value(series, item)); } return result; }
Example 11
Source File: XYChartHyperlinkProvider.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
@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 12
Source File: BoxAndWhiskerXYToolTipGenerator.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * 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>). */ @Override protected Object[] createItemArray(XYDataset dataset, int series, int item) { Object[] result = new Object[8]; result[0] = dataset.getSeriesKey(series).toString(); Number x = dataset.getX(series, item); if (getXDateFormat() != null) { result[1] = getXDateFormat().format(new Date(x.longValue())); } else { result[1] = getXFormat().format(x); } NumberFormat formatter = getYFormat(); if (dataset instanceof BoxAndWhiskerXYDataset) { BoxAndWhiskerXYDataset d = (BoxAndWhiskerXYDataset) dataset; result[2] = formatter.format(d.getMeanValue(series, item)); result[3] = formatter.format(d.getMedianValue(series, item)); result[4] = formatter.format(d.getMinRegularValue(series, item)); result[5] = formatter.format(d.getMaxRegularValue(series, item)); result[6] = formatter.format(d.getQ1Value(series, item)); result[7] = formatter.format(d.getQ3Value(series, item)); } return result; }
Example 13
Source File: AbstractXYItemLabelGenerator.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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 An array of three items from the dataset formatted as * <code>String</code> objects (never <code>null</code>). */ protected Object[] createItemArray(XYDataset dataset, int series, int item) { Object[] result = new Object[3]; result[0] = dataset.getSeriesKey(series).toString(); double x = dataset.getXValue(series, item); if (Double.isNaN(x) && dataset.getX(series, item) == null) { result[1] = this.nullXString; } else { if (this.xDateFormat != null) { result[1] = this.xDateFormat.format(new Date((long) x)); } else { result[1] = this.xFormat.format(x); } } double y = dataset.getYValue(series, item); if (Double.isNaN(y) && dataset.getY(series, item) == null) { result[2] = this.nullYString; } else { if (this.yDateFormat != null) { result[2] = this.yDateFormat.format(new Date((long) y)); } else { result[2] = this.yFormat.format(y); } } return result; }
Example 14
Source File: XYURLGenerator.java From openbd-core with GNU General Public License v3.0 | 5 votes |
/** * Generates a URL for a particular item within a series. * * @param dataset * the dataset. * @param series * the series index (zero-based). * @param category * the category index (zero-based). * * @return The generated URL. */ @SuppressWarnings("deprecation") public String generateURL(XYDataset dataset, int series, int item) { String seriesKey = dataset.getSeriesKey(series).toString(); Number xValue = dataset.getX(series, item); Number yValue = dataset.getY(series, item); String value; if (yValue == null) value = ""; else if (dateFormat != null) value = this.dateFormat.format(yValue); else value = this.numberFormat.format(yValue); StringBuilder generatedURL = new StringBuilder(urlLower.length()); for (int i = 0; i < urlLower.length();) { char ch = urlLower.charAt(i); if (ch == '$') { if (urlLower.regionMatches(i, "$serieslabel$", 0, "$serieslabel$".length())) { generatedURL.append(URLEncoder.encode(seriesKey)); i = i + "$serieslabel$".length(); } else if (urlLower.regionMatches(i, "$itemlabel$", 0, "$itemlabel$".length())) { generatedURL.append(xValue); i = i + "$itemlabel$".length(); } else if (urlLower.regionMatches(i, "$value$", 0, "$value$".length())) { generatedURL.append(value); i = i + "$value$".length(); } else { // Preserve case by retrieving char from original URL generatedURL.append(url.charAt(i)); i++; } } else { // Preserve case by retrieving char from original URL generatedURL.append(url.charAt(i)); i++; } } return generatedURL.toString(); }
Example 15
Source File: AbstractXYItemLabelGenerator.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * 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 An array of three items from the dataset formatted as * <code>String</code> objects (never <code>null</code>). */ protected Object[] createItemArray(XYDataset dataset, int series, int item) { Object[] result = new Object[3]; result[0] = dataset.getSeriesKey(series).toString(); double x = dataset.getXValue(series, item); if (Double.isNaN(x) && dataset.getX(series, item) == null) { result[1] = this.nullXString; } else { if (this.xDateFormat != null) { result[1] = this.xDateFormat.format(new Date((long) x)); } else { result[1] = this.xFormat.format(x); } } double y = dataset.getYValue(series, item); if (Double.isNaN(y) && dataset.getY(series, item) == null) { result[2] = this.nullYString; } else { if (this.yDateFormat != null) { result[2] = this.yDateFormat.format(new Date((long) y)); } else { result[2] = this.yFormat.format(y); } } return result; }
Example 16
Source File: KafkaFT.java From flink-perf with Apache License 2.0 | 5 votes |
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Flink Exactly-Once on Kafka with YARN Chaos Monkey", "Date", "Value", xydataset, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYLineAndShapeRenderer r0 = (XYLineAndShapeRenderer) xyplot.getRenderer(0); // draw data points as points r0.setSeriesShapesVisible(2, true); r0.setSeriesLinesVisible(2, true); // order elements as assed xyplot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); Number first = xydataset.getX(0, 0); Minute minute = new Minute(new Date((Long)first)); System.out.println("first = "+first); RelativeDateFormat relativedateformat = new RelativeDateFormat(minute.getFirstMillisecond()); relativedateformat.setSecondFormatter(new DecimalFormat("00")); dateaxis.setDateFormatOverride(relativedateformat); //dateaxis.setDateFormatOverride(new SimpleDateFormat("mm:ss")); ValueAxis valueaxis = xyplot.getRangeAxis(); valueaxis.setAutoRangeMinimumSize(1.0D); valueaxis.setLabel("Elements/Core"); xyplot.getRenderer().setSeriesPaint(2, ChartColor.DARK_MAGENTA); return jfreechart; }
Example 17
Source File: XYItemLabelGenerator.java From openbd-core with GNU General Public License v3.0 | 5 votes |
protected Object[] createItemArray(XYDataset dataset, int series, int item) { Object[] result = new Object[5]; result[0] = dataset.getSeriesKey(series).toString(); double x = dataset.getXValue(series, item); if (Double.isNaN(x) && dataset.getX(series, item) == null) { result[1] = "null"; //this.nullXString; } else { if (this.getXDateFormat() != null) { result[1] = this.getXDateFormat().format(new Date((long) x)); } else { result[1] = this.getXFormat().format(x); } } double y = dataset.getYValue(series, item); if (Double.isNaN(y) && dataset.getY(series, item) == null) { result[2] = "null"; //this.nullYString; } else { if (this.getYDateFormat() != null) { result[2] = this.getYDateFormat().format(new Date((long) y)); } else { result[2] = this.getYFormat().format(y); } double total = calculateYTotal(dataset, series); double percent = y / total; result[3] = NumberFormat.getPercentInstance().format(percent); if (this.getYFormat() != null) { result[4] = this.getYFormat().format(total); } else if (this.getYDateFormat() != null) { //result[4] = this.getDateFormat().format(total); } } return result; }