Java Code Examples for org.jfree.data.general.PieDataset#getValue()
The following examples show how to use
org.jfree.data.general.PieDataset#getValue() .
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: AbstractPieItemLabelGenerator.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. The returned array * contains four values: * <ul> * <li>result[0] = the section key converted to a <code>String</code>;</li> * <li>result[1] = the formatted data value;</li> * <li>result[2] = the formatted percentage (of the total);</li> * <li>result[3] = the formatted total value.</li> * </ul> * * @param dataset the dataset (<code>null</code> not permitted). * @param key the key (<code>null</code> not permitted). * * @return The items (never <code>null</code>). */ protected Object[] createItemArray(PieDataset dataset, Comparable key) { Object[] result = new Object[4]; double total = DatasetUtilities.calculatePieDatasetTotal(dataset); result[0] = key.toString(); Number value = dataset.getValue(key); if (value != null) { result[1] = this.numberFormat.format(value); } else { result[1] = "null"; } double percent = 0.0; if (value != null) { double v = value.doubleValue(); if (v > 0.0) { percent = v / total; } } result[2] = this.percentFormat.format(percent); result[3] = this.numberFormat.format(total); return result; }
Example 2
Source File: AbstractPieItemLabelGenerator.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. The returned array * contains four values: * <ul> * <li>result[0] = the section key converted to a <code>String</code>;</li> * <li>result[1] = the formatted data value;</li> * <li>result[2] = the formatted percentage (of the total);</li> * <li>result[3] = the formatted total value.</li> * </ul> * * @param dataset the dataset (<code>null</code> not permitted). * @param key the key (<code>null</code> not permitted). * * @return The items (never <code>null</code>). */ protected Object[] createItemArray(PieDataset dataset, Comparable key) { Object[] result = new Object[4]; double total = DatasetUtilities.calculatePieDatasetTotal(dataset); result[0] = key.toString(); Number value = dataset.getValue(key); if (value != null) { result[1] = this.numberFormat.format(value); } else { result[1] = "null"; } double percent = 0.0; if (value != null) { double v = value.doubleValue(); if (v > 0.0) { percent = v / total; } } result[2] = this.percentFormat.format(percent); result[3] = this.numberFormat.format(total); return result; }
Example 3
Source File: AbstractPieItemLabelGenerator.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. The returned array * contains four values: * <ul> * <li>result[0] = the section key converted to a <code>String</code>;</li> * <li>result[1] = the formatted data value;</li> * <li>result[2] = the formatted percentage (of the total);</li> * <li>result[3] = the formatted total value.</li> * </ul> * * @param dataset the dataset (<code>null</code> not permitted). * @param key the key (<code>null</code> not permitted). * * @return The items (never <code>null</code>). */ protected Object[] createItemArray(PieDataset dataset, Comparable key) { Object[] result = new Object[4]; double total = DatasetUtilities.calculatePieDatasetTotal(dataset); result[0] = key.toString(); Number value = dataset.getValue(key); if (value != null) { result[1] = this.numberFormat.format(value); } else { result[1] = "null"; } double percent = 0.0; if (value != null) { double v = value.doubleValue(); if (v > 0.0) { percent = v / total; } } result[2] = this.percentFormat.format(percent); result[3] = this.numberFormat.format(total); return result; }
Example 4
Source File: AbstractPieItemLabelGenerator.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. The returned array * contains four values: * <ul> * <li>result[0] = the section key converted to a <code>String</code>;</li> * <li>result[1] = the formatted data value;</li> * <li>result[2] = the formatted percentage (of the total);</li> * <li>result[3] = the formatted total value.</li> * </ul> * * @param dataset the dataset (<code>null</code> not permitted). * @param key the key (<code>null</code> not permitted). * * @return The items (never <code>null</code>). */ protected Object[] createItemArray(PieDataset dataset, Comparable key) { Object[] result = new Object[4]; double total = DatasetUtilities.calculatePieDatasetTotal(dataset); result[0] = key.toString(); Number value = dataset.getValue(key); if (value != null) { result[1] = this.numberFormat.format(value); } else { result[1] = "null"; } double percent = 0.0; if (value != null) { double v = value.doubleValue(); if (v > 0.0) { percent = v / total; } } result[2] = this.percentFormat.format(percent); result[3] = this.numberFormat.format(total); return result; }
Example 5
Source File: AbstractPieItemLabelGenerator.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. The returned array * contains four values: * <ul> * <li>result[0] = the section key converted to a <code>String</code>;</li> * <li>result[1] = the formatted data value;</li> * <li>result[2] = the formatted percentage (of the total);</li> * <li>result[3] = the formatted total value.</li> * </ul> * * @param dataset the dataset (<code>null</code> not permitted). * @param key the key (<code>null</code> not permitted). * * @return The items (never <code>null</code>). */ protected Object[] createItemArray(PieDataset dataset, Comparable key) { Object[] result = new Object[4]; double total = DatasetUtilities.calculatePieDatasetTotal(dataset); result[0] = key.toString(); Number value = dataset.getValue(key); if (value != null) { result[1] = this.numberFormat.format(value); } else { result[1] = "null"; } double percent = 0.0; if (value != null) { double v = value.doubleValue(); if (v > 0.0) { percent = v / total; } } result[2] = this.percentFormat.format(percent); result[3] = this.numberFormat.format(total); return result; }
Example 6
Source File: FormulaPieTooltipGenerator.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Generates a tool tip text item for the specified item in the dataset. This method can return <code>null</code> to * indicate that no tool tip should be displayed for an item. * * @param dataset the dataset (<code>null</code> not permitted). * @param key the section key (<code>null</code> not permitted). * @return The tool tip text (possibly <code>null</code>). */ public String generateToolTip( PieDataset dataset, Comparable key ) { try { final Object[] keys = dataset.getKeys().toArray(); final Object[] items = new Object[ keys.length ]; for ( int i = 0; i < keys.length; i++ ) { items[ i ] = dataset.getValue( i ); } final Object[] values = new Object[] { key, keys, dataset.getValue( key ), items, IntegerCache.getInteger( dataset.getIndex( key ) ) }; 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: AbstractPieItemLabelGenerator.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. The returned array * contains four values: * <ul> * <li>result[0] = the section key converted to a <code>String</code>;</li> * <li>result[1] = the formatted data value;</li> * <li>result[2] = the formatted percentage (of the total);</li> * <li>result[3] = the formatted total value.</li> * </ul> * * @param dataset the dataset (<code>null</code> not permitted). * @param key the key (<code>null</code> not permitted). * * @return The items (never <code>null</code>). */ protected Object[] createItemArray(PieDataset dataset, Comparable key) { Object[] result = new Object[4]; double total = DatasetUtilities.calculatePieDatasetTotal(dataset); result[0] = key.toString(); Number value = dataset.getValue(key); if (value != null) { result[1] = this.numberFormat.format(value); } else { result[1] = "null"; } double percent = 0.0; if (value != null) { double v = value.doubleValue(); if (v > 0.0) { percent = v / total; } } result[2] = this.percentFormat.format(percent); result[3] = this.numberFormat.format(total); return result; }
Example 8
Source File: AbstractPieItemLabelGenerator.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. The returned array * contains four values: * <ul> * <li>result[0] = the section key converted to a <code>String</code>;</li> * <li>result[1] = the formatted data value;</li> * <li>result[2] = the formatted percentage (of the total);</li> * <li>result[3] = the formatted total value.</li> * </ul> * * @param dataset the dataset (<code>null</code> not permitted). * @param key the key (<code>null</code> not permitted). * * @return The items (never <code>null</code>). */ protected Object[] createItemArray(PieDataset dataset, Comparable key) { Object[] result = new Object[4]; double total = DatasetUtilities.calculatePieDatasetTotal(dataset); result[0] = key.toString(); Number value = dataset.getValue(key); if (value != null) { result[1] = this.numberFormat.format(value); } else { result[1] = "null"; } double percent = 0.0; if (value != null) { double v = value.doubleValue(); if (v > 0.0) { percent = v / total; } } result[2] = this.percentFormat.format(percent); result[3] = this.numberFormat.format(total); return result; }
Example 9
Source File: AbstractPieItemLabelGenerator.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. The returned array * contains four values: * <ul> * <li>result[0] = the section key converted to a <code>String</code>;</li> * <li>result[1] = the formatted data value;</li> * <li>result[2] = the formatted percentage (of the total);</li> * <li>result[3] = the formatted total value.</li> * </ul> * * @param dataset the dataset (<code>null</code> not permitted). * @param key the key (<code>null</code> not permitted). * * @return The items (never <code>null</code>). */ protected Object[] createItemArray(PieDataset dataset, Comparable key) { Object[] result = new Object[4]; double total = DatasetUtilities.calculatePieDatasetTotal(dataset); result[0] = key.toString(); Number value = dataset.getValue(key); if (value != null) { result[1] = this.numberFormat.format(value); } else { result[1] = "null"; } double percent = 0.0; if (value != null) { double v = value.doubleValue(); if (v > 0.0) { percent = v / total; } } result[2] = this.percentFormat.format(percent); result[3] = this.numberFormat.format(total); return result; }
Example 10
Source File: FormulaPieURLGenerator.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Generates a URL for one item in a {@link org.jfree.data.general.PieDataset}. 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 key the item key (<code>null</code> not permitted). * @param pieIndex the pie index (differentiates between pies in a 'multi' pie chart). * @return A string containing the URL. */ public String generateURL( final PieDataset dataset, final Comparable key, final int pieIndex ) { try { final Object[] keys = dataset.getKeys().toArray(); final Object[] items = new Object[ keys.length ]; for ( int i = 0; i < keys.length; i++ ) { items[ i ] = dataset.getValue( key ); } final Object[] values = new Object[] { key, keys, dataset.getValue( key ), items, IntegerCache.getInteger( pieIndex ) }; 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 11
Source File: CategoryToPieDataset.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Tests this dataset for equality with an arbitrary object, returning * <code>true</code> if <code>obj</code> is a dataset containing the same * keys and values in the same order as this dataset. * * @param obj the object to test (<code>null</code> permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PieDataset)) { return false; } PieDataset that = (PieDataset) obj; int count = getItemCount(); if (that.getItemCount() != count) { return false; } for (int i = 0; i < count; i++) { Comparable k1 = getKey(i); Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; } Number v1 = getValue(i); Number v2 = that.getValue(i); if (v1 == null) { if (v2 != null) { return false; } } else { if (!v1.equals(v2)) { return false; } } } return true; }
Example 12
Source File: CategoryToPieDataset.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Tests this dataset for equality with an arbitrary object, returning * <code>true</code> if <code>obj</code> is a dataset containing the same * keys and values in the same order as this dataset. * * @param obj the object to test (<code>null</code> permitted). * * @return A boolean. */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PieDataset)) { return false; } PieDataset that = (PieDataset) obj; int count = getItemCount(); if (that.getItemCount() != count) { return false; } for (int i = 0; i < count; i++) { Comparable k1 = getKey(i); Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; } Number v1 = getValue(i); Number v2 = that.getValue(i); if (v1 == null) { if (v2 != null) { return false; } } else { if (!v1.equals(v2)) { return false; } } } return true; }
Example 13
Source File: CategoryToPieDataset.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Tests this dataset for equality with an arbitrary object, returning * <code>true</code> if <code>obj</code> is a dataset containing the same * keys and values in the same order as this dataset. * * @param obj the object to test (<code>null</code> permitted). * * @return A boolean. */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PieDataset)) { return false; } PieDataset that = (PieDataset) obj; int count = getItemCount(); if (that.getItemCount() != count) { return false; } for (int i = 0; i < count; i++) { Comparable k1 = getKey(i); Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; } Number v1 = getValue(i); Number v2 = that.getValue(i); if (v1 == null) { if (v2 != null) { return false; } } else { if (!v1.equals(v2)) { return false; } } } return true; }
Example 14
Source File: CategoryToPieDataset.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * Tests this dataset for equality with an arbitrary object, returning * <code>true</code> if <code>obj</code> is a dataset containing the same * keys and values in the same order as this dataset. * * @param obj the object to test (<code>null</code> permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PieDataset)) { return false; } PieDataset that = (PieDataset) obj; int count = getItemCount(); if (that.getItemCount() != count) { return false; } for (int i = 0; i < count; i++) { Comparable k1 = getKey(i); Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; } Number v1 = getValue(i); Number v2 = that.getValue(i); if (v1 == null) { if (v2 != null) { return false; } } else { if (!v1.equals(v2)) { return false; } } } return true; }
Example 15
Source File: CategoryToPieDataset.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Tests this dataset for equality with an arbitrary object, returning * <code>true</code> if <code>obj</code> is a dataset containing the same * keys and values in the same order as this dataset. * * @param obj the object to test (<code>null</code> permitted). * * @return A boolean. */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PieDataset)) { return false; } PieDataset that = (PieDataset) obj; int count = getItemCount(); if (that.getItemCount() != count) { return false; } for (int i = 0; i < count; i++) { Comparable k1 = getKey(i); Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; } Number v1 = getValue(i); Number v2 = that.getValue(i); if (v1 == null) { if (v2 != null) { return false; } } else { if (!v1.equals(v2)) { return false; } } } return true; }
Example 16
Source File: CategoryToPieDataset.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Tests this dataset for equality with an arbitrary object, returning * <code>true</code> if <code>obj</code> is a dataset containing the same * keys and values in the same order as this dataset. * * @param obj the object to test (<code>null</code> permitted). * * @return A boolean. */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PieDataset)) { return false; } PieDataset that = (PieDataset) obj; int count = getItemCount(); if (that.getItemCount() != count) { return false; } for (int i = 0; i < count; i++) { Comparable k1 = getKey(i); Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; } Number v1 = getValue(i); Number v2 = that.getValue(i); if (v1 == null) { if (v2 != null) { return false; } } else { if (!v1.equals(v2)) { return false; } } } return true; }
Example 17
Source File: CategoryToPieDataset.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Tests this dataset for equality with an arbitrary object, returning * <code>true</code> if <code>obj</code> is a dataset containing the same * keys and values in the same order as this dataset. * * @param obj the object to test (<code>null</code> permitted). * * @return A boolean. */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PieDataset)) { return false; } PieDataset that = (PieDataset) obj; int count = getItemCount(); if (that.getItemCount() != count) { return false; } for (int i = 0; i < count; i++) { Comparable k1 = getKey(i); Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; } Number v1 = getValue(i); Number v2 = that.getValue(i); if (v1 == null) { if (v2 != null) { return false; } } else { if (!v1.equals(v2)) { return false; } } } return true; }
Example 18
Source File: CategoryToPieDataset.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Tests this dataset for equality with an arbitrary object, returning * <code>true</code> if <code>obj</code> is a dataset containing the same * keys and values in the same order as this dataset. * * @param obj the object to test (<code>null</code> permitted). * * @return A boolean. */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PieDataset)) { return false; } PieDataset that = (PieDataset) obj; int count = getItemCount(); if (that.getItemCount() != count) { return false; } for (int i = 0; i < count; i++) { Comparable k1 = getKey(i); Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; } Number v1 = getValue(i); Number v2 = that.getValue(i); if (v1 == null) { if (v2 != null) { return false; } } else { if (!v1.equals(v2)) { return false; } } } return true; }
Example 19
Source File: PieChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
protected void configureExplode( final PiePlot pp ) { final PieDataset pieDS = pp.getDataset(); final int explodeType = computeExplodeType(); if ( explodeType == EXPLODE_VALUE ) { try { final int actualSegment = Integer.parseInt( explodeSegment ); if ( actualSegment >= 0 ) { pp.setExplodePercent( pieDS.getKey( actualSegment ), explodePct.doubleValue() ); } } catch ( Exception ignored ) { } return; } // Calculate min and max... if ( pieDS != null ) { final int itemCount = pieDS.getItemCount(); Number maxNum = new Double( Integer.MIN_VALUE ); Number minNum = new Double( Integer.MAX_VALUE ); int maxSegment = -1; int minSegment = -1; for ( int i = 0; i < itemCount; i++ ) { final Number nbr = pieDS.getValue( i ); if ( nbr.doubleValue() > maxNum.doubleValue() ) { maxNum = nbr; maxSegment = i; } if ( nbr.doubleValue() < minNum.doubleValue() ) { minNum = nbr; minSegment = i; } } if ( explodeType == EXPLODE_MIN ) { //$NON-NLS-1$ if ( minSegment >= 0 ) { pp.setExplodePercent( pieDS.getKey( minSegment ), explodePct.doubleValue() ); } } else { if ( maxSegment >= 0 ) { pp.setExplodePercent( pieDS.getKey( maxSegment ), explodePct.doubleValue() ); } } } }
Example 20
Source File: PieURLGenerator.java From openbd-core with GNU General Public License v3.0 | 4 votes |
/** * Generates a URL. * * @param data the dataset. * @param key the item key. * @param pieIndex the pie index (ignored). * * @return A string containing the generated URL. */ @SuppressWarnings("deprecation") public String generateURL(PieDataset data, Comparable key, int pieIndex) { String categoryKey = key.toString(); Number numberValue = data.getValue(key); String value; if ( numberValue == null ) value = ""; else if ( dateFormat != null ) value = this.dateFormat.format(numberValue); else value = this.numberFormat.format(numberValue); 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(""); i = i + "$serieslabel$".length(); } else if ( urlLower.regionMatches(i,"$itemlabel$",0, "$itemlabel$".length() ) ) { generatedURL.append(URLEncoder.encode(categoryKey)); i = i + "$itemlabel$".length(); } else if ( urlLower.regionMatches(i,"$value$",0, "$value$".length() ) ) { generatedURL.append(URLEncoder.encode(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(); }