List of usage examples for org.jfree.util SortOrder DESCENDING
SortOrder DESCENDING
To view the source code for org.jfree.util SortOrder DESCENDING.
Click Source Link
From source file:com.gargoylesoftware.htmlunit.general.ElementPropertiesTest.java
private static void saveChart() throws IOException { final JFreeChart chart = ChartFactory.createBarChart( "HtmlUnit implemented properties and methods for " + BROWSER_VERSION_.getNickname(), "Objects", "Count", DATASET_, PlotOrientation.HORIZONTAL, true, true, false); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); final NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final LayeredBarRenderer renderer = new LayeredBarRenderer(); plot.setRenderer(renderer);/*from w w w . j a v a 2 s .c o m*/ plot.setRowRenderingOrder(SortOrder.DESCENDING); renderer.setSeriesPaint(0, new GradientPaint(0, 0, Color.green, 0, 0, new Color(0, 64, 0))); renderer.setSeriesPaint(1, new GradientPaint(0, 0, Color.blue, 0, 0, new Color(0, 0, 64))); renderer.setSeriesPaint(2, new GradientPaint(0, 0, Color.red, 0, 0, new Color(64, 0, 0))); ImageIO.write(chart.createBufferedImage(1200, 2400), "png", new File(getTargetDirectory() + "/properties-" + BROWSER_VERSION_.getNickname() + ".png")); }
From source file:com.rapidminer.gui.plotter.charts.ParetoChartPlotter.java
private void prepareData() { synchronized (dataTable) { data.clear();/*from ww w. jav a 2 s . c om*/ if ((this.groupByColumn < 0) || (this.countColumn < 0) || (countValueIndex < 0)) { return; } if (!this.dataTable.isNominal(this.groupByColumn)) { return; } if (!this.dataTable.isNominal(this.countColumn)) { return; } Map<String, AtomicInteger> counters = new HashMap<>(); Map<String, AtomicInteger> totalCounters = new HashMap<>(); for (int v = 0; v < this.dataTable.getNumberOfValues(this.groupByColumn); v++) { String groupByValue = this.dataTable.mapIndex(this.groupByColumn, v); counters.put(groupByValue, new AtomicInteger(0)); totalCounters.put(groupByValue, new AtomicInteger(0)); } Iterator<DataTableRow> i = this.dataTable.iterator(); while (i.hasNext()) { DataTableRow row = i.next(); String groupByValue = this.dataTable.getValueAsString(row, this.groupByColumn); String countValue = this.dataTable.getValueAsString(row, this.countColumn); if (countValue != null && groupByValue != null) { if (countValue.equals(this.countValue)) { counters.get(groupByValue).getAndIncrement(); } totalCounters.get(groupByValue).getAndIncrement(); } } for (Map.Entry<String, AtomicInteger> entry : counters.entrySet()) { String category = entry.getKey(); int categoryCount = entry.getValue().intValue(); int totalCount = totalCounters.get(category).intValue(); data.addValue(category, categoryCount); totalData.addValue(category, totalCount); } // sort data switch (sortingDirectionIndex) { case KEYS_DESCENDING: data.sortByKeys(SortOrder.DESCENDING); totalData.sortByKeys(SortOrder.DESCENDING); break; case KEYS_ASCENDING: data.sortByKeys(SortOrder.ASCENDING); totalData.sortByKeys(SortOrder.ASCENDING); break; case VALUES_DESCENDING: data.sortByValues(SortOrder.DESCENDING); totalData.sortByValues(SortOrder.DESCENDING); break; case VALUES_ASCENDING: data.sortByValues(SortOrder.ASCENDING); totalData.sortByValues(SortOrder.ASCENDING); break; } } }
From source file:org.jfree.data.DefaultKeyedValuesTest.java
/** * Tests sorting of data by key (descending). *///from w w w . j a v a2 s . co m @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); }
From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo2.java
private static JFreeChart createStackedBarChart3D(CategoryDataset dataset) { CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel); ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel); CategoryItemRenderer renderer = new StackedBarRenderer3D(); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); }/*w w w .jav a 2 s . c o m*/ 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.setColumnRenderingOrder(SortOrder.DESCENDING); } // create the chart... JFreeChart chart = new JFreeChart("StackedBar Chart 3D Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); return chart; }
From source file:com.gargoylesoftware.htmlunit.javascript.host.PropertiesTest.java
private void saveChart(final DefaultCategoryDataset dataset) throws IOException { final JFreeChart chart = ChartFactory.createBarChart( "HtmlUnit implemented properties and methods for " + browserVersion_.getNickname(), "Objects", "Count", dataset, PlotOrientation.HORIZONTAL, true, true, false); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); final NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final LayeredBarRenderer renderer = new LayeredBarRenderer(); plot.setRenderer(renderer);/* w w w .j av a 2s .com*/ plot.setRowRenderingOrder(SortOrder.DESCENDING); renderer.setSeriesPaint(0, new GradientPaint(0, 0, Color.green, 0, 0, new Color(0, 64, 0))); renderer.setSeriesPaint(1, new GradientPaint(0, 0, Color.blue, 0, 0, new Color(0, 0, 64))); renderer.setSeriesPaint(2, new GradientPaint(0, 0, Color.red, 0, 0, new Color(64, 0, 0))); ImageIO.write(chart.createBufferedImage(1200, 2400), "png", new File(getArtifactsDirectory() + "/properties-" + browserVersion_.getNickname() + ".png")); }
From source file:org.gridchem.client.gui.panels.myccg.resource.HPCChartPanel.java
/** * This lays the layers over each other/*w w w .j a va 2s. co m*/ * @param chart */ private void renderLayeredBarChart(JFreeChart chart) { // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setRowRenderingOrder(SortOrder.DESCENDING); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperBound(100); // disable bar outlines... final LayeredBarRenderer renderer = (LayeredBarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.black); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.black); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.black); final GradientPaint gp3 = new GradientPaint(0.0f, 0.0f, Color.orange, 0.0f, 0.0f, Color.black); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); renderer.setSeriesPaint(3, gp3); }
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getChapterPareto(DefaultKeyedValues data, String title, String quantity, String range) { JFreeChart chart;//from w w w. j a va 2 s.c om data.sortByValues(SortOrder.DESCENDING); KeyedValues cummulative = DataUtilities.getCumulativePercentages(data); CategoryDataset dataset = DatasetUtilities.createCategoryDataset(quantity, data); // create the chart... chart = ChartFactory.createBarChart(title, // chart title "Chapter", // domain axis label range, // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, false); CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.02); domainAxis.setUpperMargin(0.02); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(); CategoryDataset dataset2 = DatasetUtilities.createCategoryDataset("Cummulative", cummulative); NumberAxis axis2 = new NumberAxis("Percent"); axis2.setNumberFormatOverride(NumberFormat.getPercentInstance()); axis2.setUpperBound(1); axis2.setLowerBound(0); plot.setRangeAxis(1, axis2); plot.setDataset(1, dataset2); plot.setRenderer(1, renderer2); plot.mapDatasetToRangeAxis(1, 1); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
From source file:org.jfree.eastwood.ChartEngine.java
/** * Creates a bar chart with the specified orientation and using the * specified renderer./*from w w w .j a v a 2 s .c o m*/ * * @param orientation the plot orientation. * @param renderer the renderer. * * @return A bar chart. */ private static JFreeChart createBarChart3D(PlotOrientation orientation, BarRenderer renderer) { GCategoryPlot plot = new GCategoryPlot(); plot.setOrientation(orientation); if (orientation.equals(PlotOrientation.HORIZONTAL)) { plot.setColumnRenderingOrder(SortOrder.DESCENDING); } JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(null); plot.setRenderer(renderer); renderer.setBasePaint(new Color(0xFFCC33)); renderer.setAutoPopulateSeriesPaint(false); renderer.setBasePaint(new Color(0xFFCC33)); renderer.setAutoPopulateSeriesPaint(false); renderer.setItemLabelsVisible(true); renderer.setItemLabelGenerator(new GCategoryPlot.LabelGenerator()); renderer.setItemLabelPaint(new Color(0x333435)); if (orientation == PlotOrientation.HORIZONTAL) { renderer.setPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT)); renderer.setPositiveItemLabelPositionFallback( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_RIGHT)); } else { renderer.setPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER)); renderer.setPositiveItemLabelPositionFallback( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER)); } GCategoryAxis3D xAxis = new GCategoryAxis3D(); xAxis.setAxisLineVisible(true); xAxis.setTickLabelsVisible(false); xAxis.setMaximumCategoryLabelLines(5); plot.setDomainAxis(xAxis); GValueAxis3D yAxis = new GValueAxis3D(); yAxis.setAxisLineVisible(true); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); plot.setRangeAxis(yAxis); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); return chart; }
From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.java
/** * 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. * //from w ww.ja va 2 s . c o m * @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) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } 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); return chart; }
From source file:KIDLYFactory.java
/** * 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).//from w w w. j a va 2s . c o m * @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) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } 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; }