org.jfree.data.KeyedValues Java Examples
The following examples show how to use
org.jfree.data.KeyedValues.
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: Chart_2_DatasetUtilities_t.java From coming with MIT License | 6 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (rowData == null) { throw new IllegalArgumentException("Null 'rowData' argument."); } DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #2
Source File: Chart_2_DatasetUtilities_s.java From coming with MIT License | 6 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (rowData == null) { throw new IllegalArgumentException("Null 'rowData' argument."); } DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #3
Source File: DatasetUtilities.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (rowData == null) { throw new IllegalArgumentException("Null 'rowData' argument."); } DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #4
Source File: DatasetUtilities.java From opensim-gui with Apache License 2.0 | 6 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (rowData == null) { throw new IllegalArgumentException("Null 'rowData' argument."); } DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #5
Source File: Cardumen_0079_s.java From coming with MIT License | 6 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (rowData == null) { throw new IllegalArgumentException("Null 'rowData' argument."); } DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #6
Source File: Cardumen_0079_t.java From coming with MIT License | 6 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (rowData == null) { throw new IllegalArgumentException("Null 'rowData' argument."); } DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #7
Source File: Cardumen_00194_t.java From coming with MIT License | 6 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (rowData == null) { throw new IllegalArgumentException("Null 'rowData' argument."); } DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #8
Source File: Cardumen_00194_s.java From coming with MIT License | 6 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (rowData == null) { throw new IllegalArgumentException("Null 'rowData' argument."); } DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #9
Source File: JGenProg2017_0047_s.java From coming with MIT License | 6 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (rowData == null) { throw new IllegalArgumentException("Null 'rowData' argument."); } DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #10
Source File: JGenProg2017_0047_t.java From coming with MIT License | 6 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (rowData == null) { throw new IllegalArgumentException("Null 'rowData' argument."); } DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #11
Source File: DatasetUtilities.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (rowData == null) { throw new IllegalArgumentException("Null 'rowData' argument."); } DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #12
Source File: DatasetUtilities.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { ParamChecks.nullNotPermitted(rowKey, "rowKey"); ParamChecks.nullNotPermitted(rowData, "rowData"); DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #13
Source File: DatasetUtilities.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { ParamChecks.nullNotPermitted(rowKey, "rowKey"); ParamChecks.nullNotPermitted(rowData, "rowData"); DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #14
Source File: DefaultPieDataset.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Creates a new dataset by copying data from a {@link KeyedValues} * instance. * * @param data the data (<code>null</code> not permitted). */ public DefaultPieDataset(KeyedValues data) { if (data == null) { throw new IllegalArgumentException("Null 'data' argument."); } this.data = new KeyedObjects(); for (int i = 0; i < data.getItemCount(); i++) { SelectableValue dataItem = new SelectableValue(data.getValue(i)); this.data.addObject(data.getKey(i), dataItem); } }
Example #15
Source File: DefaultPieDataset.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Creates a new dataset by copying data from a {@link KeyedValues} * instance. * * @param data the data (<code>null</code> not permitted). */ public DefaultPieDataset(KeyedValues data) { if (data == null) { throw new IllegalArgumentException("Null 'data' argument."); } this.data = new DefaultKeyedValues(); for (int i = 0; i < data.getItemCount(); i++) { this.data.addValue(data.getKey(i), data.getValue(i)); } }
Example #16
Source File: PiePlot.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * Draws the left labels. * * @param leftKeys the keys. * @param g2 the graphics device. * @param plotArea the plot area. * @param linkArea the link area. * @param maxLabelWidth the maximum label width. * @param state the state. */ protected void drawLeftLabels(KeyedValues leftKeys, Graphics2D g2, Rectangle2D plotArea, Rectangle2D linkArea, float maxLabelWidth, PiePlotState state) { PieLabelDistributor distributor1 = new PieLabelDistributor( leftKeys.getItemCount() ); double lGap = plotArea.getWidth() * this.labelGap; double verticalLinkRadius = state.getLinkArea().getHeight() / 2.0; for (int i = 0; i < leftKeys.getItemCount(); i++) { String label = this.labelGenerator.generateSectionLabel( this.dataset, leftKeys.getKey(i)); if (label != null) { TextBlock block = TextUtilities.createTextBlock(label, this.labelFont, this.labelPaint, maxLabelWidth, new G2TextMeasurer(g2)); TextBox labelBox = new TextBox(block); labelBox.setBackgroundPaint(this.labelBackgroundPaint); labelBox.setOutlinePaint(this.labelOutlinePaint); labelBox.setOutlineStroke(this.labelOutlineStroke); labelBox.setShadowPaint(this.labelShadowPaint); double theta = Math.toRadians( leftKeys.getValue(i).doubleValue()); double baseY = state.getPieCenterY() - Math.sin(theta) * verticalLinkRadius; double hh = labelBox.getHeight(g2); distributor1.addPieLabelRecord(new PieLabelRecord( leftKeys.getKey(i), theta, baseY, labelBox, hh, lGap / 2.0 + lGap / 2.0 * -Math.cos(theta), 0.9 + getExplodePercent(this.dataset.getIndex( leftKeys.getKey(i))))); } } distributor1.distributeLabels(plotArea.getMinY(), plotArea.getHeight()); for (int i = 0; i < distributor1.getItemCount(); i++) { drawLeftLabel(g2, state, distributor1.getPieLabelRecord(i)); } }
Example #17
Source File: DefaultPieDataset.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * Creates a new dataset by copying data from a {@link KeyedValues} * instance. * * @param data the data (<code>null</code> not permitted). */ public DefaultPieDataset(KeyedValues data) { if (data == null) { throw new IllegalArgumentException("Null 'data' argument."); } this.data = new DefaultKeyedValues(); for (int i = 0; i < data.getItemCount(); i++) { this.data.addValue(data.getKey(i), data.getValue(i)); } }
Example #18
Source File: DefaultPieDataset.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Creates a new dataset by copying data from a {@link KeyedValues} * instance. * * @param data the data (<code>null</code> not permitted). */ public DefaultPieDataset(KeyedValues data) { ParamChecks.nullNotPermitted(data, "data"); this.data = new DefaultKeyedValues(); for (int i = 0; i < data.getItemCount(); i++) { this.data.addValue(data.getKey(i), data.getValue(i)); } }
Example #19
Source File: DatasetUtilities.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { ParamChecks.nullNotPermitted(rowKey, "rowKey"); ParamChecks.nullNotPermitted(rowData, "rowData"); DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #20
Source File: DefaultPieDataset.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Creates a new dataset by copying data from a {@link KeyedValues} * instance. * * @param data the data (<code>null</code> not permitted). */ public DefaultPieDataset(KeyedValues data) { ParamChecks.nullNotPermitted(data, "data"); this.data = new DefaultKeyedValues(); for (int i = 0; i < data.getItemCount(); i++) { this.data.addValue(data.getKey(i), data.getValue(i)); } }
Example #21
Source File: DatasetUtilities.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { ParamChecks.nullNotPermitted(rowKey, "rowKey"); ParamChecks.nullNotPermitted(rowData, "rowData"); DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #22
Source File: DefaultPieDataset.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Creates a new dataset by copying data from a {@link KeyedValues} * instance. * * @param data the data (<code>null</code> not permitted). */ public DefaultPieDataset(KeyedValues data) { ParamChecks.nullNotPermitted(data, "data"); this.data = new DefaultKeyedValues(); for (int i = 0; i < data.getItemCount(); i++) { this.data.addValue(data.getKey(i), data.getValue(i)); } }
Example #23
Source File: Chart_15_PiePlot_t.java From coming with MIT License | 5 votes |
/** * Draws the left labels. * * @param leftKeys a collection of keys and angles (to the middle of the * section, in degrees) for the sections on the left side of the * plot. * @param g2 the graphics device. * @param plotArea the plot area. * @param linkArea the link area. * @param maxLabelWidth the maximum label width. * @param state the state. */ protected void drawLeftLabels(KeyedValues leftKeys, Graphics2D g2, Rectangle2D plotArea, Rectangle2D linkArea, float maxLabelWidth, PiePlotState state) { this.labelDistributor.clear(); double lGap = plotArea.getWidth() * this.labelGap; double verticalLinkRadius = state.getLinkArea().getHeight() / 2.0; for (int i = 0; i < leftKeys.getItemCount(); i++) { String label = this.labelGenerator.generateSectionLabel( this.dataset, leftKeys.getKey(i)); if (label != null) { TextBlock block = TextUtilities.createTextBlock(label, this.labelFont, this.labelPaint, maxLabelWidth, new G2TextMeasurer(g2)); TextBox labelBox = new TextBox(block); labelBox.setBackgroundPaint(this.labelBackgroundPaint); labelBox.setOutlinePaint(this.labelOutlinePaint); labelBox.setOutlineStroke(this.labelOutlineStroke); labelBox.setShadowPaint(this.labelShadowPaint); labelBox.setInteriorGap(this.labelPadding); double theta = Math.toRadians( leftKeys.getValue(i).doubleValue()); double baseY = state.getPieCenterY() - Math.sin(theta) * verticalLinkRadius; double hh = labelBox.getHeight(g2); this.labelDistributor.addPieLabelRecord(new PieLabelRecord( leftKeys.getKey(i), theta, baseY, labelBox, hh, lGap / 2.0 + lGap / 2.0 * -Math.cos(theta), 0.9 + getExplodePercent(leftKeys.getKey(i)))); } } this.labelDistributor.distributeLabels(plotArea.getMinY(), plotArea.getHeight()); for (int i = 0; i < this.labelDistributor.getItemCount(); i++) { drawLeftLabel(g2, state, this.labelDistributor.getPieLabelRecord(i)); } }
Example #24
Source File: Chart_15_PiePlot_s.java From coming with MIT License | 5 votes |
/** * Draws the left labels. * * @param leftKeys a collection of keys and angles (to the middle of the * section, in degrees) for the sections on the left side of the * plot. * @param g2 the graphics device. * @param plotArea the plot area. * @param linkArea the link area. * @param maxLabelWidth the maximum label width. * @param state the state. */ protected void drawLeftLabels(KeyedValues leftKeys, Graphics2D g2, Rectangle2D plotArea, Rectangle2D linkArea, float maxLabelWidth, PiePlotState state) { this.labelDistributor.clear(); double lGap = plotArea.getWidth() * this.labelGap; double verticalLinkRadius = state.getLinkArea().getHeight() / 2.0; for (int i = 0; i < leftKeys.getItemCount(); i++) { String label = this.labelGenerator.generateSectionLabel( this.dataset, leftKeys.getKey(i)); if (label != null) { TextBlock block = TextUtilities.createTextBlock(label, this.labelFont, this.labelPaint, maxLabelWidth, new G2TextMeasurer(g2)); TextBox labelBox = new TextBox(block); labelBox.setBackgroundPaint(this.labelBackgroundPaint); labelBox.setOutlinePaint(this.labelOutlinePaint); labelBox.setOutlineStroke(this.labelOutlineStroke); labelBox.setShadowPaint(this.labelShadowPaint); labelBox.setInteriorGap(this.labelPadding); double theta = Math.toRadians( leftKeys.getValue(i).doubleValue()); double baseY = state.getPieCenterY() - Math.sin(theta) * verticalLinkRadius; double hh = labelBox.getHeight(g2); this.labelDistributor.addPieLabelRecord(new PieLabelRecord( leftKeys.getKey(i), theta, baseY, labelBox, hh, lGap / 2.0 + lGap / 2.0 * -Math.cos(theta), 0.9 + getExplodePercent(leftKeys.getKey(i)))); } } this.labelDistributor.distributeLabels(plotArea.getMinY(), plotArea.getHeight()); for (int i = 0; i < this.labelDistributor.getItemCount(); i++) { drawLeftLabel(g2, state, this.labelDistributor.getPieLabelRecord(i)); } }
Example #25
Source File: DatasetUtilities.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { ParamChecks.nullNotPermitted(rowKey, "rowKey"); ParamChecks.nullNotPermitted(rowData, "rowData"); DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #26
Source File: DefaultPieDataset.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Creates a new dataset by copying data from a {@link KeyedValues} * instance. * * @param data the data (<code>null</code> not permitted). */ public DefaultPieDataset(KeyedValues data) { ParamChecks.nullNotPermitted(data, "data"); this.data = new DefaultKeyedValues(); for (int i = 0; i < data.getItemCount(); i++) { this.data.addValue(data.getKey(i), data.getValue(i)); } }
Example #27
Source File: DatasetUtilities.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (<code>null</code> not permitted). * @param rowData the row data (<code>null</code> not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { ParamChecks.nullNotPermitted(rowKey, "rowKey"); ParamChecks.nullNotPermitted(rowData, "rowData"); DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; }
Example #28
Source File: DefaultPieDataset.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Creates a new dataset by copying data from a {@link KeyedValues} * instance. * * @param data the data (<code>null</code> not permitted). */ public DefaultPieDataset(KeyedValues data) { ParamChecks.nullNotPermitted(data, "data"); this.data = new DefaultKeyedValues(); for (int i = 0; i < data.getItemCount(); i++) { this.data.addValue(data.getKey(i), data.getValue(i)); } }
Example #29
Source File: DefaultPieDataset.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Creates a new dataset by copying data from a {@link KeyedValues} * instance. * * @param data the data (<code>null</code> not permitted). */ public DefaultPieDataset(KeyedValues data) { ParamChecks.nullNotPermitted(data, "data"); this.data = new DefaultKeyedValues(); for (int i = 0; i < data.getItemCount(); i++) { this.data.addValue(data.getKey(i), data.getValue(i)); } }
Example #30
Source File: Chart_15_PiePlot_t.java From coming with MIT License | 4 votes |
/** * Draws the right labels. * * @param keys the keys. * @param g2 the graphics device. * @param plotArea the plot area. * @param linkArea the link area. * @param maxLabelWidth the maximum label width. * @param state the state. */ protected void drawRightLabels(KeyedValues keys, Graphics2D g2, Rectangle2D plotArea, Rectangle2D linkArea, float maxLabelWidth, PiePlotState state) { // draw the right labels... this.labelDistributor.clear(); double lGap = plotArea.getWidth() * this.labelGap; double verticalLinkRadius = state.getLinkArea().getHeight() / 2.0; for (int i = 0; i < keys.getItemCount(); i++) { String label = this.labelGenerator.generateSectionLabel( this.dataset, keys.getKey(i)); if (label != null) { TextBlock block = TextUtilities.createTextBlock(label, this.labelFont, this.labelPaint, maxLabelWidth, new G2TextMeasurer(g2)); TextBox labelBox = new TextBox(block); labelBox.setBackgroundPaint(this.labelBackgroundPaint); labelBox.setOutlinePaint(this.labelOutlinePaint); labelBox.setOutlineStroke(this.labelOutlineStroke); labelBox.setShadowPaint(this.labelShadowPaint); labelBox.setInteriorGap(this.labelPadding); double theta = Math.toRadians(keys.getValue(i).doubleValue()); double baseY = state.getPieCenterY() - Math.sin(theta) * verticalLinkRadius; double hh = labelBox.getHeight(g2); this.labelDistributor.addPieLabelRecord(new PieLabelRecord( keys.getKey(i), theta, baseY, labelBox, hh, lGap / 2.0 + lGap / 2.0 * Math.cos(theta), 0.9 + getExplodePercent(keys.getKey(i)))); } } this.labelDistributor.distributeLabels(plotArea.getMinY(), plotArea.getHeight()); for (int i = 0; i < this.labelDistributor.getItemCount(); i++) { drawRightLabel(g2, state, this.labelDistributor.getPieLabelRecord(i)); } }