List of usage examples for org.jfree.chart.axis NumberAxis NumberAxis
public NumberAxis(String label)
From source file:net.sf.mzmine.modules.visualization.twod.TwoDPlot.java
TwoDPlot(RawDataFile rawDataFile, TwoDVisualizerWindow visualizer, TwoDDataSet dataset, Range rtRange, Range mzRange) {/*from www.j av a 2s. c om*/ super(null, true); this.rawDataFile = rawDataFile; this.rtRange = rtRange; this.mzRange = mzRange; setBackground(Color.white); setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); // set the X axis (retention time) properties xAxis = new NumberAxis("Retention time"); xAxis.setAutoRangeIncludesZero(false); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); // set the Y axis (intensity) properties yAxis = new NumberAxis("m/z"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); // set the plot properties plot = new TwoDXYPlot(dataset, rtRange, mzRange, xAxis, yAxis); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); // chart properties chart = new JFreeChart("", titleFont, plot, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartSubTitle = new TextTitle(); chartSubTitle.setFont(subTitleFont); chartSubTitle.setMargin(5, 0, 0, 0); chart.addSubtitle(chartSubTitle); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set crosshair (selection) properties plot.setRangeCrosshairVisible(false); plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); peakDataRenderer = new PeakDataRenderer(); JMenuItem plotTypeMenuItem = new JMenuItem("Toggle centroid/continuous mode"); plotTypeMenuItem.addActionListener(visualizer); plotTypeMenuItem.setActionCommand("SWITCH_PLOTMODE"); add(plotTypeMenuItem); JPopupMenu popupMenu = getPopupMenu(); popupMenu.addSeparator(); popupMenu.add(plotTypeMenuItem); }
From source file:org.jfree.chart.demo.selection.SelectionDemo7ScatterRenderer.java
/** * Creates a chart./*from ww w.j a va 2 s . co m*/ * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(final MultiValueCategoryDataset dataset, final DatasetSelectionExtension<CategoryCursor<String, String>> ext) { ScatterRenderer r = new ScatterRenderer(); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), r); plot.setBackgroundColor(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4)); JFreeChart chart = new JFreeChart("ScatterRendererDemo1", plot); ChartUtilities.applyCurrentTheme(chart); //register the plot ext.addChangeListener(plot); //illustrates the usage of a shape item rendering strategy final CategoryCursor<String, String> cursor = new CategoryCursor<String, String>(); r.setShapeIRS(new DefaultShapeIRS(r) { private static final long serialVersionUID = 1L; @Override public Shape getItemShape(int row, int column) { cursor.setPosition((String) dataset.getRowKey(row), (String) dataset.getColumnKey(column)); if (ext.isSelected(cursor)) { return new Rectangle2D.Double(-10.0, -10.0, 20.0, 20.0); } else { return super.getItemShape(row, column); } } }); return chart; }
From source file:unalcol.termites.boxplots.BestAgentsPercentageInfoCollected.java
/** * Creates a new demo./*from w ww . j ava 2 s .c om*/ * * @param title the frame title. * @param pf */ public BestAgentsPercentageInfoCollected(final String title, ArrayList<Double> pf) { super(title); String sDirectorio = experimentsDir; Hashtable<String, List> info = new Hashtable(); //String[] aMode = {"levywalk", "lwphevap", "hybrid", "hybrid3", "hybrid4"}; /*for (String mode : aMode) { info.put(mode, new ArrayList()); }*/ createSampleDataset(pf, info); AddDataFailingExperiments(sDirectorio, pf, info); final BoxAndWhiskerCategoryDataset dataset = addDataSet(info); final CategoryAxis xAxis = new CategoryAxis(""); //final NumberAxis yAxis = new NumberAxis("Information Collected"); final NumberAxis yAxis = new NumberAxis(""); yAxis.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); Font font = new Font("Dialog", Font.PLAIN, 13); xAxis.setTickLabelFont(font); yAxis.setTickLabelFont(font); yAxis.setLabelFont(font); final JFreeChart chart = new JFreeChart("Information Collected " + getTitle(pf), new Font("SansSerif", Font.BOLD, 18), plot, true); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(650, 370)); setContentPane(chartPanel); TextTitle legendText = null; if (pf.size() == 1) { legendText = new TextTitle("Population Size"); } else { legendText = new TextTitle("Population Size - Probability of Failure"); } legendText.setFont(font); legendText.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legendText); chart.getLegend().setItemFont(font); FileOutputStream output; try { output = new FileOutputStream("BestAgentsPercentageInfoCollected" + pf + mazeMode + ".jpg"); ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 350, 350, null); } catch (FileNotFoundException ex) { Logger.getLogger(BestAgentsPercentageInfoCollected.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(BestAgentsPercentageInfoCollected.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelDetailMatrix.java
public boolean loadData() { super.loadData(); OctetMatrixTableModel m = new OctetMatrixTableModel(app.getXmlClient()); if (aggregateEnabled) { m.load(nodes, t, a, withAggrCounts); } else {// w w w . j a v a 2 s. co m m.load(nodes, t, s, withStatusCols); } panelTab.setModel(m); panelTab.setObjektNode(objektNode); // Grafik XYDataset xyDataset = new TableModelXYDataset(m); DateAxis domainAxis = new DateAxis("Time"); XYPlot plot = new XYPlot(xyDataset, domainAxis, new NumberAxis("Values"), new DefaultItemRenderer()); panelChart.setChart(new JFreeChart(plot)); panelChart.setLegend(new StandardLegend()); return true; }
From source file:com.wattzap.view.graphs.SCHRGraph.java
public SCHRGraph(ArrayList<Telemetry> telemetry[]) { super();//from w w w . j ava 2s .c o m this.telemetry = telemetry; final NumberAxis domainAxis = new NumberAxis("Time (h:m:s)"); domainAxis.setVerticalTickLabels(true); domainAxis.setTickLabelPaint(Color.black); domainAxis.setAutoRange(true); domainAxis.setNumberFormatOverride(new NumberFormat() { @Override public StringBuffer format(double millis, StringBuffer toAppendTo, FieldPosition pos) { if (millis >= 3600000) { // hours, minutes and seconds return new StringBuffer( String.format("%d:%d:%d", TimeUnit.MILLISECONDS.toHours((long) millis), TimeUnit.MILLISECONDS.toMinutes( (long) millis - TimeUnit.MILLISECONDS.toHours((long) millis) * 3600000), TimeUnit.MILLISECONDS.toSeconds((long) millis) - TimeUnit.MINUTES .toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis)))); } else if (millis >= 60000) { // minutes and seconds return new StringBuffer(String.format("%d:%d", 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", 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; } }); // create plot ... final XYItemRenderer powerRenderer = new StandardXYItemRenderer() { Stroke regularStroke = new BasicStroke(0.7f); Color color; public void setColor(Color color) { this.color = color; } @Override public Stroke getItemStroke(int row, int column) { return regularStroke; } @Override public Paint getItemPaint(int row, int column) { return orange; } }; powerRenderer.setSeriesPaint(0, orange); plot = new XYPlot(); plot.setRenderer(0, powerRenderer); plot.setRangeAxis(0, powerAxis); plot.setDomainAxis(domainAxis); // add a second dataset and renderer... final XYItemRenderer cadenceRenderer = new StandardXYItemRenderer() { Stroke regularStroke = new BasicStroke(0.7f); Color color; public void setColor(Color color) { this.color = color; } @Override public Stroke getItemStroke(int row, int column) { return regularStroke; } @Override public Paint getItemPaint(int row, int column) { return cornflower; } public Shape lookupLegendShape(int series) { return new Rectangle(15, 15); } }; final ValueAxis cadenceAxis = new NumberAxis(userPrefs.messages.getString("cDrpm")); cadenceAxis.setRange(0, 200); // arguments of new XYLineAndShapeRenderer are to activate or deactivate // the display of points or line. Set first argument to true if you want // to draw lines between the points for e.g. plot.setRenderer(1, cadenceRenderer); plot.setRangeAxis(1, cadenceAxis); plot.mapDatasetToRangeAxis(1, 1); cadenceRenderer.setSeriesPaint(0, cornflower); // add a third dataset and renderer... final XYItemRenderer hrRenderer = new StandardXYItemRenderer() { Stroke regularStroke = new BasicStroke(0.7f); Color color; public void setColor(Color color) { this.color = color; } @Override public Stroke getItemStroke(int row, int column) { return regularStroke; } @Override public Paint getItemPaint(int row, int column) { return straw; } }; // arguments of new XYLineAndShapeRenderer are to activate or deactivate // the display of points or line. Set first argument to true if you want // to draw lines between the points for e.g. final ValueAxis heartRateAxis = new NumberAxis(userPrefs.messages.getString("hrBpm")); heartRateAxis.setRange(0, 200); plot.setRenderer(2, hrRenderer); hrRenderer.setSeriesPaint(0, straw); plot.setRangeAxis(2, heartRateAxis); plot.mapDatasetToRangeAxis(2, 2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setBackgroundPaint(Color.DARK_GRAY); // return a new chart containing the overlaid plot... JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.getLegend().setBackgroundPaint(Color.gray); chartPanel = new ChartPanel(chart); // TODO: maybe remember sizes set by user? this.setPreferredSize(new Dimension(1200, 500)); chartPanel.setFillZoomRectangle(true); chartPanel.setMouseWheelEnabled(true); chartPanel.setBackground(Color.gray); setLayout(new BorderLayout()); add(chartPanel, BorderLayout.CENTER); SmoothingPanel smoothingPanel = new SmoothingPanel(this); add(smoothingPanel, BorderLayout.SOUTH); //infoPanel = new InfoPanel(); //add(infoPanel, BorderLayout.NORTH); setVisible(true); }
From source file:smellminer.engine.JFreeChartDemo.java
/** * Creates a new demo./* ww w . j av a 2 s . c om*/ * * @param title the frame title. */ public JFreeChartDemo(final String title) { super(title); final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(); final CategoryAxis xAxis = new CategoryAxis("Type"); final NumberAxis yAxis = new NumberAxis("Value"); yAxis.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); final JFreeChart chart = new JFreeChart("Box-and-Whisker Demo", new Font("SansSerif", Font.BOLD, 14), plot, true); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(450, 270)); setContentPane(chartPanel); }
From source file:org.jfree.chart.demo.BoxAndWhiskerDemo.java
/** * Creates a new demo./*from ww w .j a v a 2 s.com*/ * * @param title the frame title. */ public BoxAndWhiskerDemo(final String title) { super(title); final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(); final CategoryAxis xAxis = new CategoryAxis("Type"); final NumberAxis yAxis = new NumberAxis("Value"); yAxis.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); final JFreeChart chart = new JFreeChart("Box-and-Whisker Demo", new Font("SansSerif", Font.BOLD, 14), plot, true); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(450, 270)); setContentPane(chartPanel); }
From source file:org.jfree.chart.demo.CombinedXYPlotDemo1.java
/** * Creates a combined chart./* w w w . j av a 2 s. c o m*/ * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create subplot 1... final XYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Range 1"); final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); // create subplot 2... final XYDataset data2 = createDataset2(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Range 2"); rangeAxis2.setAutoRangeIncludesZero(false); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart("CombinedDomainXYPlot Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:com.googlecode.jchav.chart.MinMeanMaxChart.java
/** * Construct a new chart to display the given data. * * @param title The page id, used for the title of the chart. * @param data the data to plot.//from w w w.java 2s . c om */ public MinMeanMaxChart(final String title, final SortedSet<Measurement> data) { // The renderer that does all the real work here: final MinMaxCategoryRenderer minMaxRenderer = new MinMaxCategoryRenderer(); minMaxRenderer.setObjectIcon(new FilledCircle()); // Munge the data into form JFreeChart can use: DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (Measurement m : data) { // This ordering gives max=red, min=green, mean=blue dataset.addValue(m.getMaximumTime(), "max", m.getBuildId().getBuildName()); dataset.addValue(m.getAverageTime(), "mean", m.getBuildId().getBuildName()); dataset.addValue(m.getMinimumTime(), "min", m.getBuildId().getBuildName()); } // Create the plot area: final CategoryPlot plot = new CategoryPlot(); plot.setDataset(dataset); plot.setRenderer(minMaxRenderer); plot.setDomainAxis(new CategoryAxis("Build")); // TO DO: i18n plot.setRangeAxis(new NumberAxis("RT")); // Build labels running diagonally under the bars of the chart. plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.setOrientation(PlotOrientation.VERTICAL); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(false); // the legend here would be the "min", "max", "mean" strings used when created int category data set. boolean showLegend = true; // Render the chart: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend); chart.setTitle(title); chart.setBackgroundPaint(Color.WHITE); chart.setBorderVisible(false); if (showLegend) { chart.getLegend().setBorder(BlockBorder.NONE); } this.setChart(chart); }
From source file:peakml.util.jfreechart.FastErrorBarPlot.java
public void setLogAxis(boolean v) { if (log == v) return;/* ww w .j a va 2 s . c o m*/ log = v; yaxis = log ? new LogarithmicAxis(yaxis.getLabel()) : new NumberAxis(yaxis.getLabel()); yaxis.setPlot(this); yaxis.setAutoRange(false); yaxis.addChangeListener(this); yaxis.setRange(log ? ymin : 0, ymax); }