List of usage examples for org.jfree.chart.axis NumberAxis setStandardTickUnits
public void setStandardTickUnits(TickUnitSource source)
From source file:net.sourceforge.atunes.kernel.controllers.stats.StatsDialogController.java
private void setSongsChart() { DefaultCategoryDataset dataset = getDataSet(HandlerProxy.getRepositoryHandler().getMostPlayedSongs(10)); JFreeChart chart = ChartFactory.createStackedBarChart3D(LanguageTool.getString("SONG_MOST_PLAYED"), null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false); chart.getTitle().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); chart.setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR, 0, 200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR)); chart.setPadding(new RectangleInsets(5, 0, 0, 0)); NumberAxis axis = new NumberAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); axis.setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10)); chart.getCategoryPlot().setRangeAxis(axis); chart.getCategoryPlot().setForegroundAlpha(0.6f); chart.getCategoryPlot().getRenderer().setPaint(Color.GREEN); ((StatsDialog) frameControlled).getSongsChart().setIcon(new ImageIcon(chart.createBufferedImage(710, 250))); }
From source file:Chart.JFreeChartDemo.java
/** * Create a chart./*from w ww . j av a 2 s. co m*/ * * @param dataset the dataset * @return the chart */ private JFreeChart createChart(XYDataset dataset) { // WHAT IS THIS LINE??? // JFreeChart chart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, rootPaneCheckingEnabled, rootPaneCheckingEnabled, rootPaneCheckingEnabled) // create the chart... JFreeChart chart = ChartFactory.createXYLineChart("", // chart title "Time", // domain axis label "Range", // range axis label dataset, // initial series PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // set chart background chart.setBackgroundPaint(Color.white); // set a few custom plot features XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(0xffffe0)); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // set the plot's axes to display integers TickUnitSource ticks = NumberAxis.createIntegerTickUnits(); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setStandardTickUnits(ticks); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setStandardTickUnits(ticks); // render shapes and lines // XYLineAndShapeRenderer renderer = // new XYLineAndShapeRenderer(true, true); // plot.setRenderer(renderer); // renderer.setBaseShapesVisible(true); // renderer.setBaseShapesFilled(true); // // // set the renderer's stroke // Stroke stroke = new BasicStroke( // 3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); // // renderer.setBaseOutlineStroke(stroke); // //Shape theshape = ShapeUtilities.createDiamond(1); //renderer.setSeriesShape(5, theshape); // label the points // NumberFormat format = NumberFormat.getNumberInstance(); // format.setMaximumFractionDigits(2); // XYItemLabelGenerator generator = // new StandardXYItemLabelGenerator( // StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, // format, format); // renderer.setBaseItemLabelGenerator(generator); // renderer.setBaseItemLabelsVisible(true); return chart; }
From source file:net.sourceforge.atunes.kernel.controllers.stats.StatsDialogController.java
private void setArtistsChart() { DefaultCategoryDataset dataset = getDataSet(HandlerProxy.getRepositoryHandler().getMostPlayedArtists(10)); JFreeChart chart = ChartFactory.createStackedBarChart3D(LanguageTool.getString("ARTIST_MOST_PLAYED"), null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false); chart.getTitle().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); chart.setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR, 0, 200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR)); chart.setPadding(new RectangleInsets(5, 0, 0, 0)); NumberAxis axis = new NumberAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); axis.setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10)); chart.getCategoryPlot().setRangeAxis(axis); chart.getCategoryPlot().setForegroundAlpha(0.6f); chart.getCategoryPlot().getRenderer().setPaint(Color.GREEN); ((StatsDialog) frameControlled).getArtistsChart() .setIcon(new ImageIcon(chart.createBufferedImage(710, 250))); }
From source file:net.sourceforge.atunes.kernel.controllers.stats.StatsDialogController.java
private void setAlbumsChart() { DefaultCategoryDataset dataset = getDataSet(HandlerProxy.getRepositoryHandler().getMostPlayedAlbums(10)); JFreeChart chart = ChartFactory.createStackedBarChart3D(LanguageTool.getString("ALBUM_MOST_PLAYED"), null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false); chart.getTitle().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); chart.setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR, 0, 200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR)); chart.setPadding(new RectangleInsets(5, 0, 0, 0)); NumberAxis axis = new NumberAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); axis.setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10)); chart.getCategoryPlot().setRangeAxis(axis); chart.getCategoryPlot().setForegroundAlpha(0.6f); chart.getCategoryPlot().getRenderer().setPaint(Color.GREEN); ((StatsDialog) frameControlled).getAlbumsChart() .setIcon(new ImageIcon(chart.createBufferedImage(710, 250))); }
From source file:org.bench4Q.console.ui.section.R_RealSessionShowSection.java
private JPanel printPic() throws IOException { double[][] value = new double[2][testduring]; for (int i = 0; i < value[0].length; ++i) { value[0][i] = i;/* ww w.ja v a 2 s . c om*/ value[1][i] = loadStart[i]; } // calculate the avrg load start every second. int avrgLoad = 0; for (int i = 0; i < loadStart.length; i++) { avrgLoad += loadStart[i]; } avrgLoad /= testduring; DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); String series1 = "real"; for (int i = 0; i < value[0].length; ++i) { defaultcategorydataset.addValue(value[1][i], series1, new Integer((int) value[0][i])); } JFreeChart chart = ChartFactory.createLineChart("REAL LOAD:" + avrgLoad, "time", "load", defaultcategorydataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) chart.getPlot(); categoryplot.setBackgroundPaint(Color.WHITE); categoryplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setAutoRangeIncludesZero(true); LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setShapesVisible(false); lineandshaperenderer.setSeriesStroke(0, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 1F, 1F }, 0.0F)); return new ChartPanel(chart); }
From source file:org.ow2.clif.jenkins.chart.FixedSliceNumberDistributionChart.java
@Override protected JFreeChart createChart() { JFreeChart chart = ChartFactory.createHistogram(getBasicTitle(), Messages.FixedSliceNumberDistributionChart_ResponseTime(), Messages.FixedSliceNumberDistributionChart_NumberOfCalls(), data, PlotOrientation.VERTICAL, true, true, false);//from w w w.ja v a 2 s .c o m if (data.getSeriesCount() != 0) { double rangeStart = data.getStartX(0, 0).doubleValue(); double rangeEnd = data.getEndX(0, data.getItemCount(0) - 1).doubleValue(); NumberAxis domainAxis = new HistogramAxis(data, 0); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setVerticalTickLabels(true); domainAxis.setTickLabelsVisible(true); domainAxis.setTickMarksVisible(true); domainAxis.setRange(rangeStart, rangeEnd); chart.getXYPlot().setDomainAxis(domainAxis); NumberAxis rangeAxis = (NumberAxis) chart.getXYPlot().getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(true); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } chart.getXYPlot().setRangeGridlinesVisible(true); chart.getXYPlot().setDomainGridlinesVisible(false); return chart; }
From source file:com.idealista.solrmeter.view.statistic.QueryTimeHistoryPanel.java
/** * Creates and initializes the chart panel. *//*from w ww. j a v a 2s . c o m*/ public ChartPanel createChartPanel() { XYBarDataset barDataset = new XYBarDataset(dataset, BAR_WIDTH); NumberAxis xaxis = new NumberAxis(I18n.get("statistic.queryTimeHistoryPanel.time")); NumberAxis yaxis = new NumberAxis(I18n.get("statistic.queryTimeHistoryPanel.averageQueryTime")); xaxis.setStandardTickUnits( new ChartUtils.LowerBoundedTickUnitSource(xaxis.getStandardTickUnits(), LOWER_TICK_UNIT)); XYPlot plot = new XYPlot(barDataset, xaxis, yaxis, new XYBarRenderer()); JFreeChart chart = new JFreeChart(I18n.get("statistic.queryTimeHistoryPanel.queryHistory"), null, plot, false); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(CHART_BORDER); chartPanel.setMinimumDrawHeight(0); chartPanel.setMinimumDrawWidth(0); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); return chartPanel; }
From source file:net.sqs2.omr.result.export.chart.ChartImageWriter.java
private void setSectionPaint(DefaultCategoryDataset dataSet, CategoryPlot plot) { BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(true);/* www . j a v a 2 s . com*/ renderer.setItemLabelAnchorOffset(10); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (this.itemBackgroundImages != null && 0 < this.itemBackgroundImages.length) { int index = 0; Paint outlinePaint = Color.BLACK; Stroke outlineStroke = new BasicStroke(1.0f); for (@SuppressWarnings("unused") Object key : dataSet.getColumnKeys()) { int imageIndex = index % this.itemBackgroundImages.length; BufferedImage texture = this.itemBackgroundImages[imageIndex]; Rectangle2D anchor = new Rectangle2D.Double(0, 0, texture.getWidth(), texture.getHeight()); TexturePaint fillPaint = new TexturePaint(texture, anchor); renderer.setSeriesFillPaint(index, fillPaint); renderer.setSeriesPaint(index, fillPaint); renderer.setSeriesOutlinePaint(index, outlinePaint); renderer.setSeriesOutlineStroke(index, outlineStroke); // renderer.setBasePaint(fillPaint); // renderer.setBaseOutlineStroke(outlineStroke); // renderer.setBaseOutlinePaint(outlinePaint); } } }
From source file:net.sf.profiler4j.console.AllocDiffPanel.java
public AllocDiffPanel(int maxAgeMillis) { super(new BorderLayout()); totalSeries = new TimeSeries("Allocs/Sec", Millisecond.class); totalSeries.setMaximumItemAge(maxAgeMillis); TimeSeriesCollection seriesCollection = new TimeSeriesCollection(); seriesCollection.addSeries(totalSeries); NumberAxis numberAxis = new NumberAxis("Allocs/Sec"); numberAxis.setLabelFont(new Font("SansSerif", 0, 14)); numberAxis.setTickLabelFont(new Font("SansSerif", 0, 12)); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); DateAxis dateAxis = new DateAxis("Time"); dateAxis.setTickLabelFont(new Font("SansSerif", 0, 12)); dateAxis.setLabelFont(new Font("SansSerif", 0, 14)); dateAxis.setAutoRange(true);/* ww w. java2 s. c om*/ dateAxis.setLowerMargin(0); dateAxis.setUpperMargin(0); dateAxis.setTickLabelsVisible(true); dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false); lineRenderer.setSeriesPaint(0, Color.RED); lineRenderer.setSeriesPaint(1, Color.GREEN.darker()); lineRenderer.setStroke(new BasicStroke(2F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); XYPlot xyplot = new XYPlot(seriesCollection, dateAxis, numberAxis, lineRenderer); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY); xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); JFreeChart chart = new JFreeChart("Object Allocactions in Remote JVM", new Font("SansSerif", Font.PLAIN, 18), xyplot, true); chart.setBackgroundPaint(Color.white); ChartPanel panel = new ChartPanel(chart); panel.setBorder(createCompoundBorder(createEmptyBorder(8, 8, 8, 8), createLineBorder(Color.LIGHT_GRAY))); add(panel); setBorder(createEmptyBorder(8, 8, 8, 8)); }
From source file:no.ntnu.mmfplanner.ui.graph.NpvChart.java
/** * Creates the main chart, but does not fill inn any data *//*from ww w .j a v a 2 s . co m*/ private void createChart() { JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title "Period", // x axis label "Discounted Cash", // y axis label null, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); XYPlot plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setUpperMargin(0.0); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getDomainAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.getDomainAxis().setTickMarksVisible(false); setChart(chart); setMouseZoomable(false); }