Java Code Examples for org.jfree.data.KeyToGroupMap#getGroupCount()

The following examples show how to use org.jfree.data.KeyToGroupMap#getGroupCount() . 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: JGenProg2017_0047_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range 
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no 
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
                                           KeyToGroupMap map) {

    Range result = null;
    if (dataset != null) {
        
        // create an array holding the group indices...
        int[] groupIndex = new int[dataset.getRowCount()];
        for (int i = 0; i < dataset.getRowCount(); i++) {
            groupIndex[i] = map.getGroupIndex(
                map.getGroup(dataset.getRowKey(i))
            );   
        }
        
        // minimum and maximum for each group...
        int groupCount = map.getGroupCount();
        double[] minimum = new double[groupCount];
        double[] maximum = new double[groupCount];
        
        int categoryCount = dataset.getColumnCount();
        for (int item = 0; item < categoryCount; item++) {
            double[] positive = new double[groupCount];
            double[] negative = new double[groupCount];
            int seriesCount = dataset.getRowCount();
            for (int series = 0; series < seriesCount; series++) {
                Number number = dataset.getValue(series, item);
                if (number != null) {
                    double value = number.doubleValue();
                    if (value > 0.0) {
                        positive[groupIndex[series]] 
                             = positive[groupIndex[series]] + value;
                    }
                    if (value < 0.0) {
                        negative[groupIndex[series]] 
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                    }
                }
            }
            for (int g = 0; g < groupCount; g++) {
                minimum[g] = Math.min(minimum[g], negative[g]);
                maximum[g] = Math.max(maximum[g], positive[g]);
            }
        }
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(
                result, new Range(minimum[j], maximum[j])
            );
        }
    }
    return result;

}
 
Example 2
Source File: DatasetUtilities.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
        KeyToGroupMap map) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    boolean hasValidData = false;
    Range result = null;

    // create an array holding the group indices for each series...
    int[] groupIndex = new int[dataset.getRowCount()];
    for (int i = 0; i < dataset.getRowCount(); i++) {
        groupIndex[i] = map.getGroupIndex(map.getGroup(
                dataset.getRowKey(i)));
    }

    // minimum and maximum for each group...
    int groupCount = map.getGroupCount();
    double[] minimum = new double[groupCount];
    double[] maximum = new double[groupCount];

    int categoryCount = dataset.getColumnCount();
    for (int item = 0; item < categoryCount; item++) {
        double[] positive = new double[groupCount];
        double[] negative = new double[groupCount];
        int seriesCount = dataset.getRowCount();
        for (int series = 0; series < seriesCount; series++) {
            Number number = dataset.getValue(series, item);
            if (number != null) {
                hasValidData = true;
                double value = number.doubleValue();
                if (value > 0.0) {
                    positive[groupIndex[series]]
                             = positive[groupIndex[series]] + value;
                }
                if (value < 0.0) {
                    negative[groupIndex[series]]
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                }
            }
        }
        for (int g = 0; g < groupCount; g++) {
            minimum[g] = Math.min(minimum[g], negative[g]);
            maximum[g] = Math.max(maximum[g], positive[g]);
        }
    }
    if (hasValidData) {
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(result, new Range(minimum[j],
                    maximum[j]));
        }
    }
    return result;
}
 
Example 3
Source File: DatasetUtilities.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
        KeyToGroupMap map) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    boolean hasValidData = false;
    Range result = null;

    // create an array holding the group indices for each series...
    int[] groupIndex = new int[dataset.getRowCount()];
    for (int i = 0; i < dataset.getRowCount(); i++) {
        groupIndex[i] = map.getGroupIndex(map.getGroup(
                dataset.getRowKey(i)));
    }

    // minimum and maximum for each group...
    int groupCount = map.getGroupCount();
    double[] minimum = new double[groupCount];
    double[] maximum = new double[groupCount];

    int categoryCount = dataset.getColumnCount();
    for (int item = 0; item < categoryCount; item++) {
        double[] positive = new double[groupCount];
        double[] negative = new double[groupCount];
        int seriesCount = dataset.getRowCount();
        for (int series = 0; series < seriesCount; series++) {
            Number number = dataset.getValue(series, item);
            if (number != null) {
                hasValidData = true;
                double value = number.doubleValue();
                if (value > 0.0) {
                    positive[groupIndex[series]]
                             = positive[groupIndex[series]] + value;
                }
                if (value < 0.0) {
                    negative[groupIndex[series]]
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                }
            }
        }
        for (int g = 0; g < groupCount; g++) {
            minimum[g] = Math.min(minimum[g], negative[g]);
            maximum[g] = Math.max(maximum[g], positive[g]);
        }
    }
    if (hasValidData) {
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(result, new Range(minimum[j],
                    maximum[j]));
        }
    }
    return result;
}
 
Example 4
Source File: DatasetUtilities.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range 
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no 
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
                                           KeyToGroupMap map) {

    Range result = null;
    if (dataset != null) {
        
        // create an array holding the group indices...
        int[] groupIndex = new int[dataset.getRowCount()];
        for (int i = 0; i < dataset.getRowCount(); i++) {
            groupIndex[i] = map.getGroupIndex(
                map.getGroup(dataset.getRowKey(i))
            );   
        }
        
        // minimum and maximum for each group...
        int groupCount = map.getGroupCount();
        double[] minimum = new double[groupCount];
        double[] maximum = new double[groupCount];
        
        int categoryCount = dataset.getColumnCount();
        for (int item = 0; item < categoryCount; item++) {
            double[] positive = new double[groupCount];
            double[] negative = new double[groupCount];
            int seriesCount = dataset.getRowCount();
            for (int series = 0; series < seriesCount; series++) {
                Number number = dataset.getValue(series, item);
                if (number != null) {
                    double value = number.doubleValue();
                    if (value > 0.0) {
                        positive[groupIndex[series]] 
                             = positive[groupIndex[series]] + value;
                    }
                    if (value < 0.0) {
                        negative[groupIndex[series]] 
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                    }
                }
            }
            for (int g = 0; g < groupCount; g++) {
                minimum[g] = Math.min(minimum[g], negative[g]);
                maximum[g] = Math.max(maximum[g], positive[g]);
            }
        }
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(
                result, new Range(minimum[j], maximum[j])
            );
        }
    }
    return result;

}
 
Example 5
Source File: DatasetUtilities.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
                                           KeyToGroupMap map) {

    Range result = null;
    if (dataset != null) {

        // create an array holding the group indices...
        int[] groupIndex = new int[dataset.getRowCount()];
        for (int i = 0; i < dataset.getRowCount(); i++) {
            groupIndex[i] = map.getGroupIndex(
                map.getGroup(dataset.getRowKey(i))
            );
        }

        // minimum and maximum for each group...
        int groupCount = map.getGroupCount();
        double[] minimum = new double[groupCount];
        double[] maximum = new double[groupCount];

        int categoryCount = dataset.getColumnCount();
        for (int item = 0; item < categoryCount; item++) {
            double[] positive = new double[groupCount];
            double[] negative = new double[groupCount];
            int seriesCount = dataset.getRowCount();
            for (int series = 0; series < seriesCount; series++) {
                Number number = dataset.getValue(series, item);
                if (number != null) {
                    double value = number.doubleValue();
                    if (value > 0.0) {
                        positive[groupIndex[series]]
                             = positive[groupIndex[series]] + value;
                    }
                    if (value < 0.0) {
                        negative[groupIndex[series]]
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                    }
                }
            }
            for (int g = 0; g < groupCount; g++) {
                minimum[g] = Math.min(minimum[g], negative[g]);
                maximum[g] = Math.max(maximum[g], positive[g]);
            }
        }
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(
                result, new Range(minimum[j], maximum[j])
            );
        }
    }
    return result;

}
 
Example 6
Source File: DatasetUtilities.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
                                           KeyToGroupMap map) {
    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }
    boolean hasValidData = false;
    Range result = null;

    // create an array holding the group indices for each series...
    int[] groupIndex = new int[dataset.getRowCount()];
    for (int i = 0; i < dataset.getRowCount(); i++) {
        groupIndex[i] = map.getGroupIndex(map.getGroup(
                dataset.getRowKey(i)));
    }

    // minimum and maximum for each group...
    int groupCount = map.getGroupCount();
    double[] minimum = new double[groupCount];
    double[] maximum = new double[groupCount];

    int categoryCount = dataset.getColumnCount();
    for (int item = 0; item < categoryCount; item++) {
        double[] positive = new double[groupCount];
        double[] negative = new double[groupCount];
        int seriesCount = dataset.getRowCount();
        for (int series = 0; series < seriesCount; series++) {
            Number number = dataset.getValue(series, item);
            if (number != null) {
                hasValidData = true;
                double value = number.doubleValue();
                if (value > 0.0) {
                    positive[groupIndex[series]]
                             = positive[groupIndex[series]] + value;
                }
                if (value < 0.0) {
                    negative[groupIndex[series]]
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                }
            }
        }
        for (int g = 0; g < groupCount; g++) {
            minimum[g] = Math.min(minimum[g], negative[g]);
            maximum[g] = Math.max(maximum[g], positive[g]);
        }
    }
    if (hasValidData) {
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(result, new Range(minimum[j],
                    maximum[j]));
        }
    }
    return result;
}
 
Example 7
Source File: DatasetUtilities.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
        KeyToGroupMap map) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    boolean hasValidData = false;
    Range result = null;

    // create an array holding the group indices for each series...
    int[] groupIndex = new int[dataset.getRowCount()];
    for (int i = 0; i < dataset.getRowCount(); i++) {
        groupIndex[i] = map.getGroupIndex(map.getGroup(
                dataset.getRowKey(i)));
    }

    // minimum and maximum for each group...
    int groupCount = map.getGroupCount();
    double[] minimum = new double[groupCount];
    double[] maximum = new double[groupCount];

    int categoryCount = dataset.getColumnCount();
    for (int item = 0; item < categoryCount; item++) {
        double[] positive = new double[groupCount];
        double[] negative = new double[groupCount];
        int seriesCount = dataset.getRowCount();
        for (int series = 0; series < seriesCount; series++) {
            Number number = dataset.getValue(series, item);
            if (number != null) {
                hasValidData = true;
                double value = number.doubleValue();
                if (value > 0.0) {
                    positive[groupIndex[series]]
                             = positive[groupIndex[series]] + value;
                }
                if (value < 0.0) {
                    negative[groupIndex[series]]
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                }
            }
        }
        for (int g = 0; g < groupCount; g++) {
            minimum[g] = Math.min(minimum[g], negative[g]);
            maximum[g] = Math.max(maximum[g], positive[g]);
        }
    }
    if (hasValidData) {
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(result, new Range(minimum[j],
                    maximum[j]));
        }
    }
    return result;
}
 
Example 8
Source File: Chart_2_DatasetUtilities_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
                                           KeyToGroupMap map) {
    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }
    boolean hasValidData = false;
    Range result = null;

    // create an array holding the group indices for each series...
    int[] groupIndex = new int[dataset.getRowCount()];
    for (int i = 0; i < dataset.getRowCount(); i++) {
        groupIndex[i] = map.getGroupIndex(map.getGroup(
                dataset.getRowKey(i)));
    }

    // minimum and maximum for each group...
    int groupCount = map.getGroupCount();
    double[] minimum = new double[groupCount];
    double[] maximum = new double[groupCount];

    int categoryCount = dataset.getColumnCount();
    for (int item = 0; item < categoryCount; item++) {
        double[] positive = new double[groupCount];
        double[] negative = new double[groupCount];
        int seriesCount = dataset.getRowCount();
        for (int series = 0; series < seriesCount; series++) {
            Number number = dataset.getValue(series, item);
            if (number != null) {
                hasValidData = true;
                double value = number.doubleValue();
                if (value > 0.0) {
                    positive[groupIndex[series]]
                             = positive[groupIndex[series]] + value;
                }
                if (value < 0.0) {
                    negative[groupIndex[series]]
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                }
            }
        }
        for (int g = 0; g < groupCount; g++) {
            minimum[g] = Math.min(minimum[g], negative[g]);
            maximum[g] = Math.max(maximum[g], positive[g]);
        }
    }
    if (hasValidData) {
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(result, new Range(minimum[j],
                    maximum[j]));
        }
    }
    return result;
}
 
Example 9
Source File: Chart_2_DatasetUtilities_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
                                           KeyToGroupMap map) {
    if (dataset == null) {
        throw new IllegalArgumentException("Null 'dataset' argument.");
    }
    boolean hasValidData = false;
    Range result = null;

    // create an array holding the group indices for each series...
    int[] groupIndex = new int[dataset.getRowCount()];
    for (int i = 0; i < dataset.getRowCount(); i++) {
        groupIndex[i] = map.getGroupIndex(map.getGroup(
                dataset.getRowKey(i)));
    }

    // minimum and maximum for each group...
    int groupCount = map.getGroupCount();
    double[] minimum = new double[groupCount];
    double[] maximum = new double[groupCount];

    int categoryCount = dataset.getColumnCount();
    for (int item = 0; item < categoryCount; item++) {
        double[] positive = new double[groupCount];
        double[] negative = new double[groupCount];
        int seriesCount = dataset.getRowCount();
        for (int series = 0; series < seriesCount; series++) {
            Number number = dataset.getValue(series, item);
            if (number != null) {
                hasValidData = true;
                double value = number.doubleValue();
                if (value > 0.0) {
                    positive[groupIndex[series]]
                             = positive[groupIndex[series]] + value;
                }
                if (value < 0.0) {
                    negative[groupIndex[series]]
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                }
            }
        }
        for (int g = 0; g < groupCount; g++) {
            minimum[g] = Math.min(minimum[g], negative[g]);
            maximum[g] = Math.max(maximum[g], positive[g]);
        }
    }
    if (hasValidData) {
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(result, new Range(minimum[j],
                    maximum[j]));
        }
    }
    return result;
}
 
Example 10
Source File: DatasetUtilities.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
        KeyToGroupMap map) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    boolean hasValidData = false;
    Range result = null;

    // create an array holding the group indices for each series...
    int[] groupIndex = new int[dataset.getRowCount()];
    for (int i = 0; i < dataset.getRowCount(); i++) {
        groupIndex[i] = map.getGroupIndex(map.getGroup(
                dataset.getRowKey(i)));
    }

    // minimum and maximum for each group...
    int groupCount = map.getGroupCount();
    double[] minimum = new double[groupCount];
    double[] maximum = new double[groupCount];

    int categoryCount = dataset.getColumnCount();
    for (int item = 0; item < categoryCount; item++) {
        double[] positive = new double[groupCount];
        double[] negative = new double[groupCount];
        int seriesCount = dataset.getRowCount();
        for (int series = 0; series < seriesCount; series++) {
            Number number = dataset.getValue(series, item);
            if (number != null) {
                hasValidData = true;
                double value = number.doubleValue();
                if (value > 0.0) {
                    positive[groupIndex[series]]
                             = positive[groupIndex[series]] + value;
                }
                if (value < 0.0) {
                    negative[groupIndex[series]]
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                }
            }
        }
        for (int g = 0; g < groupCount; g++) {
            minimum[g] = Math.min(minimum[g], negative[g]);
            maximum[g] = Math.max(maximum[g], positive[g]);
        }
    }
    if (hasValidData) {
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(result, new Range(minimum[j],
                    maximum[j]));
        }
    }
    return result;
}
 
Example 11
Source File: JGenProg2017_0047_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range 
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no 
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
                                           KeyToGroupMap map) {

    Range result = null;
    if (dataset != null) {
        
        // create an array holding the group indices...
        int[] groupIndex = new int[dataset.getRowCount()];
        for (int i = 0; i < dataset.getRowCount(); i++) {
            groupIndex[i] = map.getGroupIndex(
                map.getGroup(dataset.getRowKey(i))
            );   
        }
        
        // minimum and maximum for each group...
        int groupCount = map.getGroupCount();
        double[] minimum = new double[groupCount];
        double[] maximum = new double[groupCount];
        
        int categoryCount = dataset.getColumnCount();
        for (int item = 0; item < categoryCount; item++) {
            double[] positive = new double[groupCount];
            double[] negative = new double[groupCount];
            int seriesCount = dataset.getRowCount();
            for (int series = 0; series < seriesCount; series++) {
                Number number = dataset.getValue(series, item);
                if (number != null) {
                    double value = number.doubleValue();
                    if (value > 0.0) {
                        positive[groupIndex[series]] 
                             = positive[groupIndex[series]] + value;
                    }
                    if (value < 0.0) {
                        negative[groupIndex[series]] 
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                    }
                }
            }
            for (int g = 0; g < groupCount; g++) {
                minimum[g] = Math.min(minimum[g], negative[g]);
                maximum[g] = Math.max(maximum[g], positive[g]);
            }
        }
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(
                result, new Range(minimum[j], maximum[j])
            );
        }
    }
    return result;

}
 
Example 12
Source File: Cardumen_00194_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range 
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no 
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
                                           KeyToGroupMap map) {

    Range result = null;
    if (dataset != null) {
        
        // create an array holding the group indices...
        int[] groupIndex = new int[dataset.getRowCount()];
        for (int i = 0; i < dataset.getRowCount(); i++) {
            groupIndex[i] = map.getGroupIndex(
                map.getGroup(dataset.getRowKey(i))
            );   
        }
        
        // minimum and maximum for each group...
        int groupCount = map.getGroupCount();
        double[] minimum = new double[groupCount];
        double[] maximum = new double[groupCount];
        
        int categoryCount = dataset.getColumnCount();
        for (int item = 0; item < categoryCount; item++) {
            double[] positive = new double[groupCount];
            double[] negative = new double[groupCount];
            int seriesCount = dataset.getRowCount();
            for (int series = 0; series < seriesCount; series++) {
                Number number = dataset.getValue(series, item);
                if (number != null) {
                    double value = number.doubleValue();
                    if (value > 0.0) {
                        positive[groupIndex[series]] 
                             = positive[groupIndex[series]] + value;
                    }
                    if (value < 0.0) {
                        negative[groupIndex[series]] 
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                    }
                }
            }
            for (int g = 0; g < groupCount; g++) {
                minimum[g] = Math.min(minimum[g], negative[g]);
                maximum[g] = Math.max(maximum[g], positive[g]);
            }
        }
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(
                result, new Range(minimum[j], maximum[j])
            );
        }
    }
    return result;

}
 
Example 13
Source File: Cardumen_00194_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range 
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no 
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
                                           KeyToGroupMap map) {

    Range result = null;
    if (dataset != null) {
        
        // create an array holding the group indices...
        int[] groupIndex = new int[dataset.getRowCount()];
        for (int i = 0; i < dataset.getRowCount(); i++) {
            groupIndex[i] = map.getGroupIndex(
                map.getGroup(dataset.getRowKey(i))
            );   
        }
        
        // minimum and maximum for each group...
        int groupCount = map.getGroupCount();
        double[] minimum = new double[groupCount];
        double[] maximum = new double[groupCount];
        
        int categoryCount = dataset.getColumnCount();
        for (int item = 0; item < categoryCount; item++) {
            double[] positive = new double[groupCount];
            double[] negative = new double[groupCount];
            int seriesCount = dataset.getRowCount();
            for (int series = 0; series < seriesCount; series++) {
                Number number = dataset.getValue(series, item);
                if (number != null) {
                    double value = number.doubleValue();
                    if (value > 0.0) {
                        positive[groupIndex[series]] 
                             = positive[groupIndex[series]] + value;
                    }
                    if (value < 0.0) {
                        negative[groupIndex[series]] 
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                    }
                }
            }
            for (int g = 0; g < groupCount; g++) {
                minimum[g] = Math.min(minimum[g], negative[g]);
                maximum[g] = Math.max(maximum[g], positive[g]);
            }
        }
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(
                result, new Range(minimum[j], maximum[j])
            );
        }
    }
    return result;

}
 
Example 14
Source File: Cardumen_0079_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range 
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no 
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
                                           KeyToGroupMap map) {

    Range result = null;
    if (dataset != null) {
        
        // create an array holding the group indices...
        int[] groupIndex = new int[dataset.getRowCount()];
        for (int i = 0; i < dataset.getRowCount(); i++) {
            groupIndex[i] = map.getGroupIndex(
                map.getGroup(dataset.getRowKey(i))
            );   
        }
        
        // minimum and maximum for each group...
        int groupCount = map.getGroupCount();
        double[] minimum = new double[groupCount];
        double[] maximum = new double[groupCount];
        
        int categoryCount = dataset.getColumnCount();
        for (int item = 0; item < categoryCount; item++) {
            double[] positive = new double[groupCount];
            double[] negative = new double[groupCount];
            int seriesCount = dataset.getRowCount();
            for (int series = 0; series < seriesCount; series++) {
                Number number = dataset.getValue(series, item);
                if (number != null) {
                    double value = number.doubleValue();
                    if (value > 0.0) {
                        positive[groupIndex[series]] 
                             = positive[groupIndex[series]] + value;
                    }
                    if (value < 0.0) {
                        negative[groupIndex[series]] 
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                    }
                }
            }
            for (int g = 0; g < groupCount; g++) {
                minimum[g] = Math.min(minimum[g], negative[g]);
                maximum[g] = Math.max(maximum[g], positive[g]);
            }
        }
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(
                result, new Range(minimum[j], maximum[j])
            );
        }
    }
    return result;

}
 
Example 15
Source File: Cardumen_0079_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range 
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no 
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
                                           KeyToGroupMap map) {

    Range result = null;
    if (dataset != null) {
        
        // create an array holding the group indices...
        int[] groupIndex = new int[dataset.getRowCount()];
        for (int i = 0; i < dataset.getRowCount(); i++) {
            groupIndex[i] = map.getGroupIndex(
                map.getGroup(dataset.getRowKey(i))
            );   
        }
        
        // minimum and maximum for each group...
        int groupCount = map.getGroupCount();
        double[] minimum = new double[groupCount];
        double[] maximum = new double[groupCount];
        
        int categoryCount = dataset.getColumnCount();
        for (int item = 0; item < categoryCount; item++) {
            double[] positive = new double[groupCount];
            double[] negative = new double[groupCount];
            int seriesCount = dataset.getRowCount();
            for (int series = 0; series < seriesCount; series++) {
                Number number = dataset.getValue(series, item);
                if (number != null) {
                    double value = number.doubleValue();
                    if (value > 0.0) {
                        positive[groupIndex[series]] 
                             = positive[groupIndex[series]] + value;
                    }
                    if (value < 0.0) {
                        negative[groupIndex[series]] 
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                    }
                }
            }
            for (int g = 0; g < groupCount; g++) {
                minimum[g] = Math.min(minimum[g], negative[g]);
                maximum[g] = Math.max(maximum[g], positive[g]);
            }
        }
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(
                result, new Range(minimum[j], maximum[j])
            );
        }
    }
    return result;

}
 
Example 16
Source File: DatasetUtilities.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
        KeyToGroupMap map) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    boolean hasValidData = false;
    Range result = null;

    // create an array holding the group indices for each series...
    int[] groupIndex = new int[dataset.getRowCount()];
    for (int i = 0; i < dataset.getRowCount(); i++) {
        groupIndex[i] = map.getGroupIndex(map.getGroup(
                dataset.getRowKey(i)));
    }

    // minimum and maximum for each group...
    int groupCount = map.getGroupCount();
    double[] minimum = new double[groupCount];
    double[] maximum = new double[groupCount];

    int categoryCount = dataset.getColumnCount();
    for (int item = 0; item < categoryCount; item++) {
        double[] positive = new double[groupCount];
        double[] negative = new double[groupCount];
        int seriesCount = dataset.getRowCount();
        for (int series = 0; series < seriesCount; series++) {
            Number number = dataset.getValue(series, item);
            if (number != null) {
                hasValidData = true;
                double value = number.doubleValue();
                if (value > 0.0) {
                    positive[groupIndex[series]]
                             = positive[groupIndex[series]] + value;
                }
                if (value < 0.0) {
                    negative[groupIndex[series]]
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                }
            }
        }
        for (int g = 0; g < groupCount; g++) {
            minimum[g] = Math.min(minimum[g], negative[g]);
            maximum[g] = Math.max(maximum[g], positive[g]);
        }
    }
    if (hasValidData) {
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(result, new Range(minimum[j],
                    maximum[j]));
        }
    }
    return result;
}
 
Example 17
Source File: DatasetUtilities.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Returns the minimum and maximum values for the dataset's range
 * (y-values), assuming that the series in one category are stacked.
 *
 * @param dataset  the dataset.
 * @param map  a structure that maps series to groups.
 *
 * @return The value range (<code>null</code> if the dataset contains no
 *         values).
 */
public static Range findStackedRangeBounds(CategoryDataset dataset,
        KeyToGroupMap map) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    boolean hasValidData = false;
    Range result = null;

    // create an array holding the group indices for each series...
    int[] groupIndex = new int[dataset.getRowCount()];
    for (int i = 0; i < dataset.getRowCount(); i++) {
        groupIndex[i] = map.getGroupIndex(map.getGroup(
                dataset.getRowKey(i)));
    }

    // minimum and maximum for each group...
    int groupCount = map.getGroupCount();
    double[] minimum = new double[groupCount];
    double[] maximum = new double[groupCount];

    int categoryCount = dataset.getColumnCount();
    for (int item = 0; item < categoryCount; item++) {
        double[] positive = new double[groupCount];
        double[] negative = new double[groupCount];
        int seriesCount = dataset.getRowCount();
        for (int series = 0; series < seriesCount; series++) {
            Number number = dataset.getValue(series, item);
            if (number != null) {
                hasValidData = true;
                double value = number.doubleValue();
                if (value > 0.0) {
                    positive[groupIndex[series]]
                             = positive[groupIndex[series]] + value;
                }
                if (value < 0.0) {
                    negative[groupIndex[series]]
                             = negative[groupIndex[series]] + value;
                             // '+', remember value is negative
                }
            }
        }
        for (int g = 0; g < groupCount; g++) {
            minimum[g] = Math.min(minimum[g], negative[g]);
            maximum[g] = Math.max(maximum[g], positive[g]);
        }
    }
    if (hasValidData) {
        for (int j = 0; j < groupCount; j++) {
            result = Range.combine(result, new Range(minimum[j],
                    maximum[j]));
        }
    }
    return result;
}