org.jfree.util.SortOrder Java Examples

The following examples show how to use org.jfree.util.SortOrder. 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: DefaultKeyedValues.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sorts the items in the list by key.
 *
 * @param order  the sort order (<code>null</code> not permitted).
 */
public void sortByKeys(SortOrder order) {
    final int size = this.keys.size();
    final DefaultKeyedValue[] data = new DefaultKeyedValue[size];

    for (int i = 0; i < size; i++) {
        data[i] = new DefaultKeyedValue((Comparable) this.keys.get(i),
                (Number) this.values.get(i));
    }

    Comparator comparator = new KeyedValueComparator(
            KeyedValueComparatorType.BY_KEY, order);
    Arrays.sort(data, comparator);
    clear();

    for (int i = 0; i < data.length; i++) {
        final DefaultKeyedValue value = data[i];
        addValue(value.getKey(), value.getValue());
    }
}
 
Example #2
Source File: LegendTitle.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new legend title with the specified arrangement.
 *
 * @param source  the source.
 * @param hLayout  the horizontal item arrangement (<code>null</code> not
 *                 permitted).
 * @param vLayout  the vertical item arrangement (<code>null</code> not
 *                 permitted).
 */
public LegendTitle(LegendItemSource source,
                   Arrangement hLayout, Arrangement vLayout) {
    this.sources = new LegendItemSource[] {source};
    this.items = new BlockContainer(hLayout);
    this.hLayout = hLayout;
    this.vLayout = vLayout;
    this.backgroundPaint = null;
    this.legendItemGraphicEdge = RectangleEdge.LEFT;
    this.legendItemGraphicAnchor = RectangleAnchor.CENTER;
    this.legendItemGraphicLocation = RectangleAnchor.CENTER;
    this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.itemFont = DEFAULT_ITEM_FONT;
    this.itemPaint = DEFAULT_ITEM_PAINT;
    this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.sortOrder = SortOrder.ASCENDING;
}
 
Example #3
Source File: DefaultKeyedValues.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sorts the items in the list by key.
 *
 * @param order  the sort order (<code>null</code> not permitted).
 */
public void sortByKeys(SortOrder order) {
    final int size = this.keys.size();
    final DefaultKeyedValue[] data = new DefaultKeyedValue[size];

    for (int i = 0; i < size; i++) {
        data[i] = new DefaultKeyedValue((Comparable) this.keys.get(i),
                (Number) this.values.get(i));
    }

    Comparator comparator = new KeyedValueComparator(
            KeyedValueComparatorType.BY_KEY, order);
    Arrays.sort(data, comparator);
    clear();

    for (int i = 0; i < data.length; i++) {
        final DefaultKeyedValue value = data[i];
        addValue(value.getKey(), value.getValue());
    }
}
 
Example #4
Source File: DefaultKeyedValues.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sorts the items in the list by value.  If the list contains
 * <code>null</code> values, they will sort to the end of the list,
 * irrespective of the sort order.
 *
 * @param order  the sort order (<code>null</code> not permitted).
 */
public void sortByValues(SortOrder order) {
    final int size = this.keys.size();
    final DefaultKeyedValue[] data = new DefaultKeyedValue[size];
    for (int i = 0; i < size; i++) {
        data[i] = new DefaultKeyedValue((Comparable) this.keys.get(i),
                (Number) this.values.get(i));
    }

    Comparator comparator = new KeyedValueComparator(
            KeyedValueComparatorType.BY_VALUE, order);
    Arrays.sort(data, comparator);

    clear();
    for (int i = 0; i < data.length; i++) {
        final DefaultKeyedValue value = data[i];
        addValue(value.getKey(), value.getValue());
    }
}
 
Example #5
Source File: DefaultKeyedValues.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sorts the items in the list by key.
 *
 * @param order  the sort order (<code>null</code> not permitted).
 */
public void sortByKeys(SortOrder order) {
    final int size = this.keys.size();
    final DefaultKeyedValue[] data = new DefaultKeyedValue[size];

    for (int i = 0; i < size; i++) {
        data[i] = new DefaultKeyedValue((Comparable) this.keys.get(i),
                (Number) this.values.get(i));
    }

    Comparator comparator = new KeyedValueComparator(
            KeyedValueComparatorType.BY_KEY, order);
    Arrays.sort(data, comparator);
    clear();

    for (int i = 0; i < data.length; i++) {
        final DefaultKeyedValue value = data[i];
        addValue(value.getKey(), value.getValue());
    }
}
 
Example #6
Source File: DefaultKeyedValues.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sorts the items in the list by value.  If the list contains
 * <code>null</code> values, they will sort to the end of the list,
 * irrespective of the sort order.
 *
 * @param order  the sort order (<code>null</code> not permitted).
 */
public void sortByValues(SortOrder order) {
    final int size = this.keys.size();
    final DefaultKeyedValue[] data = new DefaultKeyedValue[size];
    for (int i = 0; i < size; i++) {
        data[i] = new DefaultKeyedValue((Comparable) this.keys.get(i),
                (Number) this.values.get(i));
    }

    Comparator comparator = new KeyedValueComparator(
            KeyedValueComparatorType.BY_VALUE, order);
    Arrays.sort(data, comparator);

    clear();
    for (int i = 0; i < data.length; i++) {
        final DefaultKeyedValue value = data[i];
        addValue(value.getKey(), value.getValue());
    }
}
 
Example #7
Source File: DefaultKeyedValues.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Sorts the items in the list by key.
 *
 * @param order  the sort order (<code>null</code> not permitted).
 */
public void sortByKeys(SortOrder order) {
    final int size = this.keys.size();
    final DefaultKeyedValue[] data = new DefaultKeyedValue[size];

    for (int i = 0; i < size; i++) {
        data[i] = new DefaultKeyedValue((Comparable) this.keys.get(i),
                (Number) this.values.get(i));
    }

    Comparator comparator = new KeyedValueComparator(
            KeyedValueComparatorType.BY_KEY, order);
    Arrays.sort(data, comparator);
    clear();

    for (int i = 0; i < data.length; i++) {
        final DefaultKeyedValue value = data[i];
        addValue(value.getKey(), value.getValue());
    }
}
 
Example #8
Source File: LegendTitle.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new legend title with the specified arrangement.
 *
 * @param source  the source.
 * @param hLayout  the horizontal item arrangement (<code>null</code> not
 *                 permitted).
 * @param vLayout  the vertical item arrangement (<code>null</code> not
 *                 permitted).
 */
public LegendTitle(LegendItemSource source,
                   Arrangement hLayout, Arrangement vLayout) {
    this.sources = new LegendItemSource[] {source};
    this.items = new BlockContainer(hLayout);
    this.hLayout = hLayout;
    this.vLayout = vLayout;
    this.backgroundPaint = null;
    this.legendItemGraphicEdge = RectangleEdge.LEFT;
    this.legendItemGraphicAnchor = RectangleAnchor.CENTER;
    this.legendItemGraphicLocation = RectangleAnchor.CENTER;
    this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.itemFont = DEFAULT_ITEM_FONT;
    this.itemPaint = DEFAULT_ITEM_PAINT;
    this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.sortOrder = SortOrder.ASCENDING;
}
 
Example #9
Source File: LegendTitle.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new legend title with the specified arrangement.
 *
 * @param source  the source.
 * @param hLayout  the horizontal item arrangement (<code>null</code> not
 *                 permitted).
 * @param vLayout  the vertical item arrangement (<code>null</code> not
 *                 permitted).
 */
public LegendTitle(LegendItemSource source,
                   Arrangement hLayout, Arrangement vLayout) {
    this.sources = new LegendItemSource[] {source};
    this.items = new BlockContainer(hLayout);
    this.hLayout = hLayout;
    this.vLayout = vLayout;
    this.backgroundPaint = null;
    this.legendItemGraphicEdge = RectangleEdge.LEFT;
    this.legendItemGraphicAnchor = RectangleAnchor.CENTER;
    this.legendItemGraphicLocation = RectangleAnchor.CENTER;
    this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.itemFont = DEFAULT_ITEM_FONT;
    this.itemPaint = DEFAULT_ITEM_PAINT;
    this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.sortOrder = SortOrder.ASCENDING;
}
 
Example #10
Source File: DefaultKeyedValues.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sorts the items in the list by value.  If the list contains
 * <code>null</code> values, they will sort to the end of the list,
 * irrespective of the sort order.
 *
 * @param order  the sort order (<code>null</code> not permitted).
 */
public void sortByValues(SortOrder order) {
    final int size = this.keys.size();
    final DefaultKeyedValue[] data = new DefaultKeyedValue[size];
    for (int i = 0; i < size; i++) {
        data[i] = new DefaultKeyedValue((Comparable) this.keys.get(i),
                (Number) this.values.get(i));
    }

    Comparator comparator = new KeyedValueComparator(
            KeyedValueComparatorType.BY_VALUE, order);
    Arrays.sort(data, comparator);

    clear();
    for (int i = 0; i < data.length; i++) {
        final DefaultKeyedValue value = data[i];
        addValue(value.getKey(), value.getValue());
    }
}
 
Example #11
Source File: DefaultKeyedValuesTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Tests sorting of data by key (ascending).
 */
@Test
public void testSortByKeyAscending() {

    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("C", new Double(1.0));
    data.addValue("B", null);
    data.addValue("D", new Double(3.0));
    data.addValue("A", new Double(2.0));

    data.sortByKeys(SortOrder.ASCENDING);

    // check key order
    assertEquals(data.getKey(0), "A");
    assertEquals(data.getKey(1), "B");
    assertEquals(data.getKey(2), "C");
    assertEquals(data.getKey(3), "D");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(2.0));
    assertEquals(data.getValue("B"), null);
    assertEquals(data.getValue("C"), new Double(1.0));
    assertEquals(data.getValue("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(2.0));
    assertEquals(data.getValue(1), null);
    assertEquals(data.getValue(2), new Double(1.0));
    assertEquals(data.getValue(3), new Double(3.0));

}
 
Example #12
Source File: DefaultKeyedValuesTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests sorting of data by key (descending).
 */
@Test
public void testSortByValueDescending() {

    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("C", new Double(1.0));
    data.addValue("B", null);
    data.addValue("D", new Double(3.0));
    data.addValue("A", new Double(2.0));

    data.sortByValues(SortOrder.DESCENDING);

    // check key order
    assertEquals(data.getKey(0), "D");
    assertEquals(data.getKey(1), "A");
    assertEquals(data.getKey(2), "C");
    assertEquals(data.getKey(3), "B");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(2.0));
    assertEquals(data.getValue("B"), null);
    assertEquals(data.getValue("C"), new Double(1.0));
    assertEquals(data.getValue("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(3.0));
    assertEquals(data.getValue(1), new Double(2.0));
    assertEquals(data.getValue(2), new Double(1.0));
    assertEquals(data.getValue(3), null);

}
 
Example #13
Source File: ChartFactory.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a bar chart with a 3D effect. The chart object returned by this
 * method uses a {@link CategoryPlot} instance as the plot, with a
 * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as
 * the range axis, and a {@link BarRenderer3D} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the plot orientation (horizontal or vertical)
 *                     (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A bar chart with a 3D effect.
 */
public static JFreeChart createBarChart3D(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    BarRenderer3D renderer = new BarRenderer3D();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(
                new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    plot.setOrientation(orientation);
    if (orientation == PlotOrientation.HORIZONTAL) {
        // change rendering order to ensure that bar overlapping is the
        // right way around
        plot.setRowRenderingOrder(SortOrder.DESCENDING);
        plot.setColumnRenderingOrder(SortOrder.DESCENDING);
    }
    plot.setForegroundAlpha(0.75f);

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

}
 
Example #14
Source File: DefaultKeyedValuesTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Tests sorting of data by key (descending).
 */
@Test
public void testSortByKeyDescending() {

    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("C", new Double(1.0));
    data.addValue("B", null);
    data.addValue("D", new Double(3.0));
    data.addValue("A", new Double(2.0));

    data.sortByKeys(SortOrder.DESCENDING);

    // check key order
    assertEquals(data.getKey(0), "D");
    assertEquals(data.getKey(1), "C");
    assertEquals(data.getKey(2), "B");
    assertEquals(data.getKey(3), "A");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(2.0));
    assertEquals(data.getValue("B"), null);
    assertEquals(data.getValue("C"), new Double(1.0));
    assertEquals(data.getValue("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(3.0));
    assertEquals(data.getValue(1), new Double(1.0));
    assertEquals(data.getValue(2), null);
    assertEquals(data.getValue(3), new Double(2.0));

}
 
Example #15
Source File: ChartFactory.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a stacked bar chart with a 3D effect and default settings. The
 * chart object returned by this method uses a {@link CategoryPlot}
 * instance as the plot, with a {@link CategoryAxis3D} for the domain axis,
 * a {@link NumberAxis3D} as the range axis, and a
 * {@link StackedBarRenderer3D} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the orientation (horizontal or vertical)
 *                     (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A stacked bar chart with a 3D effect.
 */
public static JFreeChart createStackedBarChart3D(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    // create the renderer...
    CategoryItemRenderer renderer = new StackedBarRenderer3D();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(
                new StandardCategoryURLGenerator());
    }

    // create the plot...
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    plot.setOrientation(orientation);
    if (orientation == PlotOrientation.HORIZONTAL) {
        // change rendering order to ensure that bar overlapping is the
        // right way around
        plot.setColumnRenderingOrder(SortOrder.DESCENDING);
    }

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

}
 
Example #16
Source File: DefaultKeyedValuesTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Tests sorting of data by value (ascending).
 */
@Test
public void testSortByValueAscending() {

    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("C", new Double(1.0));
    data.addValue("B", null);
    data.addValue("D", new Double(3.0));
    data.addValue("A", new Double(2.0));

    data.sortByValues(SortOrder.ASCENDING);

    // check key order
    assertEquals(data.getKey(0), "C");
    assertEquals(data.getKey(1), "A");
    assertEquals(data.getKey(2), "D");
    assertEquals(data.getKey(3), "B");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(2.0));
    assertEquals(data.getValue("B"), null);
    assertEquals(data.getValue("C"), new Double(1.0));
    assertEquals(data.getValue("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(1.0));
    assertEquals(data.getValue(1), new Double(2.0));
    assertEquals(data.getValue(2), new Double(3.0));
    assertEquals(data.getValue(3), null);

}
 
Example #17
Source File: DefaultKeyedValuesTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Tests sorting of data by key (descending).
 */
@Test
public void testSortByValueDescending() {

    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("C", new Double(1.0));
    data.addValue("B", null);
    data.addValue("D", new Double(3.0));
    data.addValue("A", new Double(2.0));

    data.sortByValues(SortOrder.DESCENDING);

    // check key order
    assertEquals(data.getKey(0), "D");
    assertEquals(data.getKey(1), "A");
    assertEquals(data.getKey(2), "C");
    assertEquals(data.getKey(3), "B");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(2.0));
    assertEquals(data.getValue("B"), null);
    assertEquals(data.getValue("C"), new Double(1.0));
    assertEquals(data.getValue("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(3.0));
    assertEquals(data.getValue(1), new Double(2.0));
    assertEquals(data.getValue(2), new Double(1.0));
    assertEquals(data.getValue(3), null);

}
 
Example #18
Source File: DefaultKeyedValuesTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Tests sorting of data by key (ascending).
 */
@Test
public void testSortByKeyAscending() {

    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("C", new Double(1.0));
    data.addValue("B", null);
    data.addValue("D", new Double(3.0));
    data.addValue("A", new Double(2.0));

    data.sortByKeys(SortOrder.ASCENDING);

    // check key order
    assertEquals(data.getKey(0), "A");
    assertEquals(data.getKey(1), "B");
    assertEquals(data.getKey(2), "C");
    assertEquals(data.getKey(3), "D");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(2.0));
    assertEquals(data.getValue("B"), null);
    assertEquals(data.getValue("C"), new Double(1.0));
    assertEquals(data.getValue("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(2.0));
    assertEquals(data.getValue(1), null);
    assertEquals(data.getValue(2), new Double(1.0));
    assertEquals(data.getValue(3), new Double(3.0));

}
 
Example #19
Source File: ChartFactory.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a stacked bar chart with a 3D effect and default settings. The
 * chart object returned by this method uses a {@link CategoryPlot}
 * instance as the plot, with a {@link CategoryAxis3D} for the domain axis,
 * a {@link NumberAxis3D} as the range axis, and a
 * {@link StackedBarRenderer3D} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the orientation (horizontal or vertical)
 *                     (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A stacked bar chart with a 3D effect.
 */
public static JFreeChart createStackedBarChart3D(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    // create the renderer...
    CategoryItemRenderer renderer = new StackedBarRenderer3D();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(
                new StandardCategoryURLGenerator());
    }

    // create the plot...
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    plot.setOrientation(orientation);
    if (orientation == PlotOrientation.HORIZONTAL) {
        // change rendering order to ensure that bar overlapping is the
        // right way around
        plot.setColumnRenderingOrder(SortOrder.DESCENDING);
    }

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

}
 
Example #20
Source File: DefaultKeyedValuesTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests sorting of data by key (descending).
 */
@Test
public void testSortByKeyDescending() {

    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("C", new Double(1.0));
    data.addValue("B", null);
    data.addValue("D", new Double(3.0));
    data.addValue("A", new Double(2.0));

    data.sortByKeys(SortOrder.DESCENDING);

    // check key order
    assertEquals(data.getKey(0), "D");
    assertEquals(data.getKey(1), "C");
    assertEquals(data.getKey(2), "B");
    assertEquals(data.getKey(3), "A");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(2.0));
    assertEquals(data.getValue("B"), null);
    assertEquals(data.getValue("C"), new Double(1.0));
    assertEquals(data.getValue("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(3.0));
    assertEquals(data.getValue(1), new Double(1.0));
    assertEquals(data.getValue(2), null);
    assertEquals(data.getValue(3), new Double(2.0));

}
 
Example #21
Source File: DefaultKeyedValuesTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests sorting of data by key (ascending).
 */
@Test
public void testSortByKeyAscending() {

    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("C", new Double(1.0));
    data.addValue("B", null);
    data.addValue("D", new Double(3.0));
    data.addValue("A", new Double(2.0));

    data.sortByKeys(SortOrder.ASCENDING);

    // check key order
    assertEquals(data.getKey(0), "A");
    assertEquals(data.getKey(1), "B");
    assertEquals(data.getKey(2), "C");
    assertEquals(data.getKey(3), "D");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(2.0));
    assertEquals(data.getValue("B"), null);
    assertEquals(data.getValue("C"), new Double(1.0));
    assertEquals(data.getValue("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(2.0));
    assertEquals(data.getValue(1), null);
    assertEquals(data.getValue(2), new Double(1.0));
    assertEquals(data.getValue(3), new Double(3.0));

}
 
Example #22
Source File: ChartFactory.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a bar chart with a 3D effect. The chart object returned by this
 * method uses a {@link CategoryPlot} instance as the plot, with a
 * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as
 * the range axis, and a {@link BarRenderer3D} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the plot orientation (horizontal or vertical)
 *                     (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A bar chart with a 3D effect.
 */
public static JFreeChart createBarChart3D(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    BarRenderer3D renderer = new BarRenderer3D();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(
                new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    plot.setOrientation(orientation);
    if (orientation == PlotOrientation.HORIZONTAL) {
        // change rendering order to ensure that bar overlapping is the
        // right way around
        plot.setRowRenderingOrder(SortOrder.DESCENDING);
        plot.setColumnRenderingOrder(SortOrder.DESCENDING);
    }
    plot.setForegroundAlpha(0.75f);

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

}
 
Example #23
Source File: KeyedValueComparator.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new comparator.
 *
 * @param type  the type (<code>BY_KEY</code> or <code>BY_VALUE</code>,
 *              <code>null</code> not permitted).
 * @param order  the order (<code>null</code> not permitted).
 */
public KeyedValueComparator(KeyedValueComparatorType type,
                            SortOrder order) {
    ParamChecks.nullNotPermitted(type, "type");
    ParamChecks.nullNotPermitted(order, "order");
    this.type = type;
    this.order = order;
}
 
Example #24
Source File: KeyedValueComparator.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new comparator.
 *
 * @param type  the type (<code>BY_KEY</code> or <code>BY_VALUE</code>,
 *              <code>null</code> not permitted).
 * @param order  the order (<code>null</code> not permitted).
 */
public KeyedValueComparator(KeyedValueComparatorType type,
                            SortOrder order) {
    ParamChecks.nullNotPermitted(type, "type");
    ParamChecks.nullNotPermitted(order, "order");
    this.type = type;
    this.order = order;
}
 
Example #25
Source File: ChartFactory.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a bar chart with a 3D effect. The chart object returned by this
 * method uses a {@link CategoryPlot} instance as the plot, with a
 * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as
 * the range axis, and a {@link BarRenderer3D} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the plot orientation (horizontal or vertical)
 *                     (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A bar chart with a 3D effect.
 */
public static JFreeChart createBarChart3D(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    BarRenderer3D renderer = new BarRenderer3D();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(
                new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    plot.setOrientation(orientation);
    if (orientation == PlotOrientation.HORIZONTAL) {
        // change rendering order to ensure that bar overlapping is the
        // right way around
        plot.setRowRenderingOrder(SortOrder.DESCENDING);
        plot.setColumnRenderingOrder(SortOrder.DESCENDING);
    }
    plot.setForegroundAlpha(0.75f);

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

}
 
Example #26
Source File: KeyedValueComparator.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new comparator.
 *
 * @param type  the type (<code>BY_KEY</code> or <code>BY_VALUE</code>,
 *              <code>null</code> not permitted).
 * @param order  the order (<code>null</code> not permitted).
 */
public KeyedValueComparator(KeyedValueComparatorType type,
                            SortOrder order) {
    ParamChecks.nullNotPermitted(type, "type");
    ParamChecks.nullNotPermitted(order, "order");
    this.type = type;
    this.order = order;
}
 
Example #27
Source File: DefaultKeyedValuesTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Tests sorting of data by key (ascending).
 */
@Test
public void testSortByKeyAscending() {

    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("C", new Double(1.0));
    data.addValue("B", null);
    data.addValue("D", new Double(3.0));
    data.addValue("A", new Double(2.0));

    data.sortByKeys(SortOrder.ASCENDING);

    // check key order
    assertEquals(data.getKey(0), "A");
    assertEquals(data.getKey(1), "B");
    assertEquals(data.getKey(2), "C");
    assertEquals(data.getKey(3), "D");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(2.0));
    assertEquals(data.getValue("B"), null);
    assertEquals(data.getValue("C"), new Double(1.0));
    assertEquals(data.getValue("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(2.0));
    assertEquals(data.getValue(1), null);
    assertEquals(data.getValue(2), new Double(1.0));
    assertEquals(data.getValue(3), new Double(3.0));

}
 
Example #28
Source File: DefaultKeyedValuesTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Tests sorting of data by key (descending).
 */
@Test
public void testSortByKeyDescending() {

    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("C", new Double(1.0));
    data.addValue("B", null);
    data.addValue("D", new Double(3.0));
    data.addValue("A", new Double(2.0));

    data.sortByKeys(SortOrder.DESCENDING);

    // check key order
    assertEquals(data.getKey(0), "D");
    assertEquals(data.getKey(1), "C");
    assertEquals(data.getKey(2), "B");
    assertEquals(data.getKey(3), "A");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(2.0));
    assertEquals(data.getValue("B"), null);
    assertEquals(data.getValue("C"), new Double(1.0));
    assertEquals(data.getValue("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(3.0));
    assertEquals(data.getValue(1), new Double(1.0));
    assertEquals(data.getValue(2), null);
    assertEquals(data.getValue(3), new Double(2.0));

}
 
Example #29
Source File: DefaultKeyedValuesTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Tests sorting of data by value (ascending).
 */
@Test
public void testSortByValueAscending() {

    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("C", new Double(1.0));
    data.addValue("B", null);
    data.addValue("D", new Double(3.0));
    data.addValue("A", new Double(2.0));

    data.sortByValues(SortOrder.ASCENDING);

    // check key order
    assertEquals(data.getKey(0), "C");
    assertEquals(data.getKey(1), "A");
    assertEquals(data.getKey(2), "D");
    assertEquals(data.getKey(3), "B");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(2.0));
    assertEquals(data.getValue("B"), null);
    assertEquals(data.getValue("C"), new Double(1.0));
    assertEquals(data.getValue("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(1.0));
    assertEquals(data.getValue(1), new Double(2.0));
    assertEquals(data.getValue(2), new Double(3.0));
    assertEquals(data.getValue(3), null);

}
 
Example #30
Source File: ChartFactory.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a bar chart with a 3D effect. The chart object returned by this
 * method uses a {@link CategoryPlot} instance as the plot, with a
 * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as
 * the range axis, and a {@link BarRenderer3D} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the plot orientation (horizontal or vertical)
 *                     (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A bar chart with a 3D effect.
 */
public static JFreeChart createBarChart3D(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    BarRenderer3D renderer = new BarRenderer3D();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(
                new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    plot.setOrientation(orientation);
    if (orientation == PlotOrientation.HORIZONTAL) {
        // change rendering order to ensure that bar overlapping is the
        // right way around
        plot.setRowRenderingOrder(SortOrder.DESCENDING);
        plot.setColumnRenderingOrder(SortOrder.DESCENDING);
    }
    plot.setForegroundAlpha(0.75f);

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

}