List of usage examples for org.jfree.chart.axis NumberAxis NumberAxis
public NumberAxis(String label)
From source file:com.wattzap.view.graphs.MMPGraph.java
public MMPGraph(XYSeries series) { super();//from ww w. j a va 2 s. c o m NumberAxis yAxis = new NumberAxis(userPrefs.messages.getString("poWtt")); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); double maxY = series.getMaxY(); yAxis.setRange(0, maxY + 20); yAxis.setTickLabelPaint(Color.white); yAxis.setLabelPaint(Color.white); LogAxis xAxis = new LogAxis(userPrefs.messages.getString("time")); xAxis.setTickLabelPaint(Color.white); xAxis.setBase(4); xAxis.setAutoRange(false); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setRange(1, series.getMaxX() + 500); xAxis.setNumberFormatOverride(new NumberFormat() { @Override public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) { long millis = (long) number * 1000; if (millis >= 60000) { return new StringBuffer(String.format("%d m %d s", TimeUnit.MILLISECONDS.toMinutes((long) millis), TimeUnit.MILLISECONDS.toSeconds((long) millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis)))); } else { return new StringBuffer(String.format("%d s", TimeUnit.MILLISECONDS.toSeconds((long) millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis)))); } } @Override public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) { return new StringBuffer(String.format("%s", number)); } @Override public Number parse(String source, ParsePosition parsePosition) { return null; } }); XYPlot plot = new XYPlot(new XYSeriesCollection(series), xAxis, yAxis, new XYLineAndShapeRenderer(true, false)); JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(Color.gray); plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.darkGray); /*plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray);*/ ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setTickLabelPaint(Color.white); domainAxis.setLabelPaint(Color.white); chartPanel = new ChartPanel(chart); chartPanel.setSize(100, 800); chartPanel.setFillZoomRectangle(true); chartPanel.setMouseWheelEnabled(true); chartPanel.setBackground(Color.gray); setLayout(new BorderLayout()); add(chartPanel, BorderLayout.CENTER); setBackground(Color.black); chartPanel.revalidate(); setVisible(true); }
From source file:gui.Plotter1D.java
private ChartPanel createChartPanel1(String grapheName) { XYSplineRenderer xysplinerenderer = new XYSplineRenderer(); ValueAxis valueAxis = new NumberAxis("X"); valueAxis.setRange(0.0, 1.0);/*ww w . j av a 2s .c om*/ ValueAxis valueAxisy = new NumberAxis("Y"); valueAxis.setRange(0.0, 1.0); XYPlot xyplot; xyplot = new XYPlot(xyseriescollection, valueAxis, valueAxisy, xysplinerenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); JFreeChart jfreechart = new JFreeChart(grapheName, JFreeChart.DEFAULT_TITLE_FONT, xyplot, true); jfreechart.setBackgroundPaint(Color.white); ChartPanel chartpanel = new ChartPanel(jfreechart, false); return chartpanel; }
From source file:org.mustbe.consulo.xprofiler.ui.mainPanel.MemoryPlotPanel.java
public MemoryPlotPanel(int maxAge, String title) { super(new BorderLayout()); totalSeries = new TimeSeries("Committed Memory"); totalSeries.setMaximumItemAge(maxAge); usedSeries = new TimeSeries("Used Memory"); usedSeries.setMaximumItemAge(maxAge); TimeSeriesCollection seriesCollection = new TimeSeriesCollection(); seriesCollection.addSeries(totalSeries); seriesCollection.addSeries(usedSeries); NumberAxis numberAxis = new NumberAxis("Memory (KB)"); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); DateAxis dateAxis = new DateAxis("Time"); dateAxis.setAutoRange(true);/* w ww . j ava 2s .co m*/ 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, JBColor.RED); lineRenderer.setSeriesPaint(1, JBColor.GREEN); lineRenderer.setDefaultStroke(new BasicStroke(2F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); XYPlot xyplot = new XYPlot(seriesCollection, dateAxis, numberAxis, lineRenderer); xyplot.setBackgroundPainter(new ColorPainter(JBColor.white)); xyplot.setDomainGridlinePaint(JBColor.LIGHT_GRAY); xyplot.setRangeGridlinePaint(JBColor.LIGHT_GRAY); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); JFreeChart chart = new JFreeChart(title, new Font("SansSerif", Font.PLAIN, 14), xyplot, true); chart.setBackgroundPainter(new ColorPainter(JBColor.white)); add(new ChartPanel(chart, 300, 300, 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, false, false, false), BorderLayout.CENTER); }
From source file:scheduler.benchmarker.manager.CreateCombinedSplineChart.java
public ChartPanel createChartPanel() { XYDataset dataset = createDataset(); NumberAxis numberaxis = new NumberAxis("EMAILS"); numberaxis.setAutoRangeIncludesZero(true); numberaxis.setRange(0, dataset.getItemCount(1)); numberaxis.setVisible(false);/* www . j ava 2 s . com*/ NumberAxis numberaxis1 = new NumberAxis("TIME CONSUMED"); numberaxis.setAutoRangeIncludesZero(false); XYSplineRenderer xysplinerenderer = new XYSplineRenderer(); XYPlot xyplot = new XYPlot(dataset, numberaxis, numberaxis1, xysplinerenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setFixedLegendItems(null); JFreeChart jfreechart = new JFreeChart( "PLAN VALUES FOR '" + sName[0] + "' AND '" + sName[1] + "' SCHEDULERS", new Font(Font.SANS_SERIF, Font.PLAIN, 11), xyplot, true); chartPanel = new ChartPanel(jfreechart, true); //Creating listener chartPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent e) { ChartEntity entity = e.getEntity(); if (entity != null && (entity instanceof XYItemEntity)) { XYItemEntity item = (XYItemEntity) entity; String chartTitle = "COMPARISON OF '" + sName[0] + "' AND '" + sName[1] + "' BEHAVIOUR FOR EMAIL '" + dataSource.get(0).getPlanningResult().get(item.getItem()).getEmailName() + "'"; createSubChart(new CreateCombinedCategoryPlot( new PlanningResult[] { dataSource.get(0).getPlanningResult().get(item.getItem()), dataSource.get(1).getPlanningResult().get(item.getItem()) }, pluginColor, chartTitle, new String[] { dataSource.get(0).getSchedulerUsed(), dataSource.get(1).getSchedulerUsed() }).createChartPanel()); } } @Override public void chartMouseMoved(ChartMouseEvent e) { //DO NOTHING } }); return chartPanel; }
From source file:peakmlviewer.dialog.PCADialog.java
public PCADialog(MainWnd mainwnd, Shell parent, String title) { super(parent, SWT.NONE); // save the parent pointer this.title = title; this.parent = parent; this.mainwnd = mainwnd; // create the window and set its properties shell = new Shell(parent, SWT.EMBEDDED | SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); shell.setSize(500, 300);/*from w w w. j a v a 2 s .co m*/ shell.setText(title); // create the jfreechart plot = new XYPlot(collection, new NumberAxis("principal component 1"), new NumberAxis("principal component 2"), new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES)); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); plot.getRenderer().setBaseItemLabelsVisible(true); plot.getRenderer().setBaseItemLabelGenerator(new XYItemLabelGenerator() { public String generateLabel(XYDataset dataset, int series, int item) { return labels[item]; } }); chart = new JFreeChart("Principle Component Analysis", plot); chart.removeLegend(); chart.setBackgroundPaint(Color.WHITE); chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // add the components // -------------------------------------------------------------------------------- // This uses the SWT-trick for embedding awt-controls in an SWT-Composit. try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { ; } java.awt.Frame frame = org.eclipse.swt.awt.SWT_AWT.new_Frame(shell); // create a new ChartPanel, without the popup-menu (5x false) frame.add(new ChartPanel(chart, false, false, false, false, false)); // -------------------------------------------------------------------------------- }
From source file:org.csml.tommo.sugar.heatmap.MeanQualityMatrixChart.java
public static MeanQualityMatrixChart createSimpleChart(MeanQualityMatrixDataset dataset, PaintScale paintScale) {// www. ja v a2 s . co m NumberAxis xAxis = new NumberAxis(""); // xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setTickLabelsVisible(false); xAxis.setTickMarksVisible(false); // xAxis.setLowerMargin(0.0); // xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(""); // yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); // yAxis.setLowerMargin(0.0); // yAxis.setUpperMargin(0.0); MeanQualityMatrixChart chart = createChart(dataset, xAxis, yAxis, paintScale); chart.getPlot().setOutlineVisible(false); chart.getPlot().setInsets(new RectangleInsets(0, 0, 0, 0)); return chart; }
From source file:org.openimaj.demos.sandbox.flickr.geo.PlotFlickrGeo.java
public static void main(String[] args) throws IOException { final File inputcsv = new File("/Volumes/SSD/training_latlng"); final List<double[]> data = new ArrayList<double[]>(10000000); // read in images final BufferedReader br = new BufferedReader(new FileReader(inputcsv)); String line;/*from w w w. j av a2 s .c o m*/ int i = 0; br.readLine(); while ((line = br.readLine()) != null) { final String[] parts = line.split(" "); final double longitude = Double.parseDouble(parts[2]); final double latitude = Double.parseDouble(parts[1]); data.add(new double[] { longitude, latitude }); if (longitude >= -0.1 && longitude < 0 && latitude > 50 && latitude < 54) System.out.println(parts[0] + " " + latitude + " " + longitude); // if (i++ % 10000 == 0) // System.out.println(i); } br.close(); System.out.println("Done reading"); final float[][] dataArr = new float[2][data.size()]; for (i = 0; i < data.size(); i++) { dataArr[0][i] = (float) data.get(i)[0]; dataArr[1][i] = (float) data.get(i)[1]; } final NumberAxis domainAxis = new NumberAxis("X"); domainAxis.setRange(-180, 180); final NumberAxis rangeAxis = new NumberAxis("Y"); rangeAxis.setRange(-90, 90); final FastScatterPlot plot = new FastScatterPlot(dataArr, domainAxis, rangeAxis); final JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot); chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); final ApplicationFrame frame = new ApplicationFrame("Title"); frame.setContentPane(chartPanel); frame.pack(); frame.setVisible(true); }
From source file:org.fhcrc.cpl.toolbox.gui.chart.PanelWithBoxAndWhiskerChart.java
protected void init() { dataset = new DefaultBoxAndWhiskerCategoryDataset(); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false);//from w ww.j av a2 s . c om renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); final CategoryAxis xAxis = new CategoryAxis("Type"); final NumberAxis yAxis = new NumberAxis("Value"); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); final JFreeChart chart = new JFreeChart(getName(), new Font("SansSerif", Font.BOLD, 14), plot, true); init(chart.getPlot()); }
From source file:org.csml.tommo.sugar.heatmap.MappingQualityMatrixChart.java
public static MappingQualityMatrixChart createSimpleChart(MappingQualityMatrixDataset dataset, PaintScale paintScale) {//w ww .j a v a2 s . c o m NumberAxis xAxis = new NumberAxis(""); // xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setTickLabelsVisible(false); xAxis.setTickMarksVisible(false); // xAxis.setLowerMargin(0.0); // xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(""); // yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); // yAxis.setLowerMargin(0.0); // yAxis.setUpperMargin(0.0); MappingQualityMatrixChart chart = createChart(dataset, xAxis, yAxis, paintScale); chart.getPlot().setOutlineVisible(false); chart.getPlot().setInsets(new RectangleInsets(0, 0, 0, 0)); return chart; }
From source file:graph.jfreecharts.GraphFunction.java
/** * A custom xyerror renderer because jfreecharts does not * have it supported in the api./*from ww w . j a v a2 s. co m*/ * @param title the graph title * @param xAxisLabel the xaxis title * @param yAxisLabel the yaxis title * @param dataset the xydataset * @param orientation the plot orientation * @param legend true to turn on legend * @param tooltips true to turn on tooltips (the pop up when right click) * @param urls // no idea what this is for * @return */ private static JFreeChart createXYIntervalChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYErrorRenderer renderer = new XYErrorRenderer(); renderer.setDrawXError(true); renderer.setDrawYError(true); xAxis.setNumberFormatOverride(new DecimalFormat("0.######E0")); yAxis.setNumberFormatOverride(new DecimalFormat("0.######E0")); xAxis.setAutoRangeIncludesZero(false); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }