org.jfree.chart.axis.TickUnits Java Examples
The following examples show how to use
org.jfree.chart.axis.TickUnits.
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: TickUnitsTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { TickUnits t1 = (TickUnits) NumberAxis.createIntegerTickUnits(); TickUnits t2 = (TickUnits) NumberAxis.createIntegerTickUnits(); assertTrue(t1.equals(t2)); assertTrue(t2.equals(t1)); }
Example #2
Source File: TickUnitsTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { TickUnits t1 = (TickUnits) NumberAxis.createIntegerTickUnits(); TickUnits t2 = (TickUnits) NumberAxis.createIntegerTickUnits(); assertTrue(t1.equals(t2)); assertTrue(t2.equals(t1)); }
Example #3
Source File: AbstractChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Reduces standard tick unit array to meet formatting precision and avoid duplicated values (PRD-5821) * * @return */ protected void standardTickUnitsApplyFormat( NumberAxis numberAxis, NumberFormat format ) { final TickUnits standardTickUnits = (TickUnits) numberAxis.getStandardTickUnits(); TickUnits cutTickUnits = new TickUnits(); double formatterMinSize = 1 / Math.pow( 10, format.getMaximumFractionDigits() ); for ( int i = 0; i < standardTickUnits.size(); i++ ) { if ( Double.compare( standardTickUnits.get( i ).getSize(), formatterMinSize ) >= 0 ) { cutTickUnits.add( new NumberTickUnit( standardTickUnits.get( i ).getSize() ) ); } } numberAxis.setStandardTickUnits( cutTickUnits ); }
Example #4
Source File: CategoricalChartExpressionTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testStandardTickUnitsApplyFormat() throws Exception{ NumberAxis axis = new NumberAxis(); final TickUnits standardTickUnits = (TickUnits)axis.getStandardTickUnits(); final double initialFirstTickUnitSize = standardTickUnits.get( 0 ).getSize(); assertTickUnitSizeByPattern( "", initialFirstTickUnitSize); assertTickUnitSizeByPattern( "#,###", 1.0 ); assertTickUnitSizeByPattern( "#", 1.0 ); assertTickUnitSizeByPattern( "#.#", 0.1 ); assertTickUnitSizeByPattern( "#.####", 1.0E-4 ); }
Example #5
Source File: CategoricalChartExpressionTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private void assertTickUnitSizeByPattern( String pattern, double tickUnitSize) { NumberAxis axis = new NumberAxis(); DecimalFormat formatter = new DecimalFormat( pattern, new DecimalFormatSymbols(new Locale( "en_US" ) ) ); expression.standardTickUnitsApplyFormat( axis, formatter ); final TickUnits standardTickUnits = (TickUnits)axis.getStandardTickUnits(); // first n standard tick unit elements should be removed Assert.assertEquals( tickUnitSize, standardTickUnits.get( 0 ).getSize(), 0.0000000001 ); }
Example #6
Source File: ChartUtil.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
public TickUnitSource createIntegerTickUnits(Locale locale) { DecimalFormatSymbols formatSymbols = DecimalFormatSymbols.getInstance(locale); // copied from NumberAxis.createIntegerTickUnits() to preserve backward behaviour TickUnits units = new TickUnits(); DecimalFormat df0 = new DecimalFormat("0", formatSymbols); DecimalFormat df1 = new DecimalFormat("#,##0", formatSymbols); units.add(new NumberTickUnit(1, df0)); units.add(new NumberTickUnit(2, df0)); units.add(new NumberTickUnit(5, df0)); units.add(new NumberTickUnit(10, df0)); units.add(new NumberTickUnit(20, df0)); units.add(new NumberTickUnit(50, df0)); units.add(new NumberTickUnit(100, df0)); units.add(new NumberTickUnit(200, df0)); units.add(new NumberTickUnit(500, df0)); units.add(new NumberTickUnit(1000, df1)); units.add(new NumberTickUnit(2000, df1)); units.add(new NumberTickUnit(5000, df1)); units.add(new NumberTickUnit(10000, df1)); units.add(new NumberTickUnit(20000, df1)); units.add(new NumberTickUnit(50000, df1)); units.add(new NumberTickUnit(100000, df1)); units.add(new NumberTickUnit(200000, df1)); units.add(new NumberTickUnit(500000, df1)); units.add(new NumberTickUnit(1000000, df1)); units.add(new NumberTickUnit(2000000, df1)); units.add(new NumberTickUnit(5000000, df1)); units.add(new NumberTickUnit(10000000, df1)); units.add(new NumberTickUnit(20000000, df1)); units.add(new NumberTickUnit(50000000, df1)); units.add(new NumberTickUnit(100000000, df1)); units.add(new NumberTickUnit(200000000, df1)); units.add(new NumberTickUnit(500000000, df1)); units.add(new NumberTickUnit(1000000000, df1)); units.add(new NumberTickUnit(2000000000, df1)); units.add(new NumberTickUnit(5000000000.0, df1)); units.add(new NumberTickUnit(10000000000.0, df1)); // adding further values by default because 1E10 is not enough for some people // using getNumberInstance because that's what NumberAxis.createIntegerTickUnits does units.add(new NumberTickUnit(20000000000L, df1)); units.add(new NumberTickUnit(50000000000L, df1)); units.add(new NumberTickUnit(100000000000L, df1)); units.add(new NumberTickUnit(200000000000L, df1)); units.add(new NumberTickUnit(500000000000L, df1)); units.add(new NumberTickUnit(1000000000000L, df1)); units.add(new NumberTickUnit(2000000000000L, df1)); units.add(new NumberTickUnit(5000000000000L, df1)); units.add(new NumberTickUnit(10000000000000L, df1)); units.add(new NumberTickUnit(20000000000000L, df1)); units.add(new NumberTickUnit(50000000000000L, df1)); units.add(new NumberTickUnit(100000000000000L, df1)); units.add(new NumberTickUnit(200000000000000L, df1)); units.add(new NumberTickUnit(500000000000000L, df1)); units.add(new NumberTickUnit(1000000000000000L, df1)); units.add(new NumberTickUnit(2000000000000000L, df1)); units.add(new NumberTickUnit(5000000000000000L, df1)); units.add(new NumberTickUnit(10000000000000000L, df1)); units.add(new NumberTickUnit(20000000000000000L, df1)); units.add(new NumberTickUnit(50000000000000000L, df1)); units.add(new NumberTickUnit(100000000000000000L, df1)); units.add(new NumberTickUnit(200000000000000000L, df1)); units.add(new NumberTickUnit(500000000000000000L, df1)); units.add(new NumberTickUnit(1000000000000000000L, df1)); units.add(new NumberTickUnit(2000000000000000000L, df1)); units.add(new NumberTickUnit(5000000000000000000L, df1)); return units; }
Example #7
Source File: SchedulePlanningPanel.java From opencards with BSD 2-Clause "Simplified" License | 4 votes |
public SchedulePlanningPanel() { setLayout(new BorderLayout()); // setup the stacked bar chart dataset = new DefaultCategoryDataset(); final JFreeChart chart = ChartFactory.createStackedBarChart( null, // chart title Utils.getRB().getString("CardTableModel.stats.weekSchedule"), // domain axis label // "# cards", // range axis label null, // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation false, // legend true, // tooltips false // urls ); StackedBarRenderer renderer = new StackedBarRenderer(); renderer.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); //green renderer.setItemMargin(0.0); Paint greenPaint = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88)); renderer.setSeriesPaint(1, greenPaint); renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); //blue Paint bluePaint = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x88, 0x88, 0xFF)); renderer.setSeriesPaint(0, bluePaint); renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); // Paint p2 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x88, 0x88)); // renderer.setSeriesPaint(1, p2); // renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); // // Paint p3 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88)); // renderer.setSeriesPaint(2, p3); // renderer.setSeriesToolTipGenerator(2, new StandardCategoryToolTipGenerator()); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRenderer(renderer); valueAxis = plot.getRangeAxis(); TickUnits units = (TickUnits) NumberAxis.createIntegerTickUnits(); valueAxis.setStandardTickUnits(units); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPopupMenu(null); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); add(chartPanel, BorderLayout.CENTER); rebuildPanel(new HashSet<CardFile>()); }
Example #8
Source File: LTMStateGraphPanel.java From opencards with BSD 2-Clause "Simplified" License | 4 votes |
public LTMStateGraphPanel() { setLayout(new BorderLayout()); // setup the stacked bar chart dataset = new DefaultCategoryDataset(); final JFreeChart chart = ChartFactory.createStackedBarChart( null, // chart title Utils.getRB().getString("CardTableModel.stats.learnsuccess"), // domain axis label // "# cards", // range axis label null, // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation false, // legend true, // tooltips false // urls ); StackedBarRenderer renderer = new StackedBarRenderer(); renderer.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); renderer.setItemMargin(0.0); Paint bluePaint = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x88, 0x88, 0xFF)); renderer.setSeriesPaint(0, bluePaint); renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); // Paint p2 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x88, 0x88)); // renderer.setSeriesPaint(1, p2); // renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); // // Paint p3 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88)); // renderer.setSeriesPaint(2, p3); // renderer.setSeriesToolTipGenerator(2, new StandardCategoryToolTipGenerator()); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRenderer(renderer); valueAxis = plot.getRangeAxis(); TickUnits units = (TickUnits) NumberAxis.createIntegerTickUnits(); valueAxis.setStandardTickUnits(units); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPopupMenu(null); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); add(chartPanel, BorderLayout.CENTER); rebuildPanel(new HashSet<CardFile>()); learnedPerfectly = Utils.getRB().getString("CardTableModel.stats.perfect"); learnedNotYet = Utils.getRB().getString("CardTableModel.stats.notatall"); learnedNaJa = Utils.getRB().getString("CardTableModel.stats.well"); }
Example #9
Source File: MonitoringPage.java From webanno with Apache License 2.0 | 4 votes |
private JFreeChart createProgressChart(Map<String, Integer> chartValues, int aMaxValue, boolean aIsPercentage) { // fill dataset DefaultCategoryDataset dataset = new DefaultCategoryDataset(); if (aMaxValue > 0) { for (String chartValue : chartValues.keySet()) { dataset.setValue(chartValues.get(chartValue), "Completion", chartValue); } } // create chart JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setOutlineVisible(false); plot.setBackgroundPaint(null); plot.setNoDataMessage("No data"); plot.setInsets(new RectangleInsets(0, 20, 0, 20)); if (aMaxValue > 0) { plot.getRangeAxis().setRange(0.0, aMaxValue); ((NumberAxis) plot.getRangeAxis()).setNumberFormatOverride(new DecimalFormat("0")); // For documents less than 10, avoid repeating the number of documents such // as 0 0 1 1 1 - NumberTickUnit automatically determines the range if (!aIsPercentage && aMaxValue <= 10) { TickUnits standardUnits = new TickUnits(); NumberAxis tick = new NumberAxis(); tick.setTickUnit(new NumberTickUnit(1)); standardUnits.add(tick.getTickUnit()); plot.getRangeAxis().setStandardTickUnits(standardUnits); } } else { plot.getRangeAxis().setVisible(false); plot.getDomainAxis().setVisible(false); } BarRenderer renderer = new BarRenderer(); renderer.setBarPainter(new StandardBarPainter()); renderer.setShadowVisible(false); // renderer.setGradientPaintTransformer(new // StandardGradientPaintTransformer( // GradientPaintTransformType.HORIZONTAL)); renderer.setSeriesPaint(0, Color.BLUE); chart.getCategoryPlot().setRenderer(renderer); return chart; }