List of usage examples for org.jfree.chart.axis NumberAxis NumberAxis
public NumberAxis(String label)
From source file:org.openmicroscopy.shoola.util.ui.graphutils.ChartObject.java
/** * Sets the name of the x axis to axisName. * //from www. j a v a 2 s . c o m * @param axisName The name to set. */ public void setXAxisName(String axisName) { if (axisName == null || axisName.trim().length() == 0) axisName = X_AXIS; domainAxis = new NumberAxis(axisName); }
From source file:net.sf.mzmine.modules.visualization.ida.IDAPlot.java
IDAPlot(final ActionListener listener, RawDataFile rawDataFile, IDAVisualizerWindow visualizer, IDADataSet dataset, Range<Double> rtRange, Range<Double> mzRange) { super(null, true); this.visualizer = visualizer; this.rawDataFile = rawDataFile; this.rtRange = rtRange; this.mzRange = mzRange; // initialize the chart by default time series chart from factory chart = ChartFactory.createXYLineChart("", // title "", // x-axis label "", // y-axis label null, // data set PlotOrientation.VERTICAL, // orientation true, // create legend false, // generate tooltips false // generate URLs );/*w w w . j ava 2s .c o m*/ chart.setBackgroundPaint(Color.white); setChart(chart); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // Set the domain log axis xAxis = new NumberAxis("Retention time (min)"); xAxis.setAutoRangeIncludesZero(false); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0.01); xAxis.setLowerMargin(0.01); plot.setDomainAxis(xAxis); // Set the range log axis yAxis = new NumberAxis("Precursor m/z"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0.1); yAxis.setLowerMargin(0.1); plot.setRangeAxis(yAxis); // Set crosshair properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); // Create renderers mainRenderer = new IDAPlotRenderer(); plot.setRenderer(0, mainRenderer); // 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); // Add data sets; plot.setDataset(0, dataset); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); peakDataRenderer = new PeakDataRenderer(); // Add EMF and EPS options to the save as menu JPopupMenu popupMenu = getPopupMenu(); JMenuItem saveAsMenu = (JMenuItem) popupMenu.getComponent(3); GUIUtils.addMenuItem(saveAsMenu, "EMF...", this, "SAVE_EMF"); GUIUtils.addMenuItem(saveAsMenu, "EPS...", this, "SAVE_EPS"); // Register for mouse-wheel events addMouseWheelListener(this); }
From source file:net.sf.mzmine.modules.visualization.msms.MsMsPlot.java
MsMsPlot(final ActionListener listener, RawDataFile rawDataFile, MsMsVisualizerWindow visualizer, MsMsDataSet dataset, Range<Double> rtRange, Range<Double> mzRange) { super(null, true); this.visualizer = visualizer; this.rawDataFile = rawDataFile; this.rtRange = rtRange; this.mzRange = mzRange; // initialize the chart by default time series chart from factory chart = ChartFactory.createXYLineChart("", // title "", // x-axis label "", // y-axis label null, // data set PlotOrientation.VERTICAL, // orientation true, // create legend false, // generate tooltips false // generate URLs );//from w w w . j ava 2 s. c o m chart.setBackgroundPaint(Color.white); setChart(chart); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // Set the domain log axis xAxis = new NumberAxis("Retention time (min)"); xAxis.setAutoRangeIncludesZero(false); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0.01); xAxis.setLowerMargin(0.01); plot.setDomainAxis(xAxis); // Set the range log axis yAxis = new NumberAxis("Precursor m/z"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0.1); yAxis.setLowerMargin(0.1); plot.setRangeAxis(yAxis); // Set crosshair properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); // Create renderers mainRenderer = new MsMsPlotRenderer(); plot.setRenderer(0, mainRenderer); // 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); // Add data sets; plot.setDataset(0, dataset); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); peakDataRenderer = new PeakDataRenderer(); // Add EMF and EPS options to the save as menu JPopupMenu popupMenu = getPopupMenu(); JMenuItem saveAsMenu = (JMenuItem) popupMenu.getComponent(3); GUIUtils.addMenuItem(saveAsMenu, "EMF...", this, "SAVE_EMF"); GUIUtils.addMenuItem(saveAsMenu, "EPS...", this, "SAVE_EPS"); // Register for mouse-wheel events addMouseWheelListener(this); }
From source file:GenAppStoreSales.java
/** * Creates a chart.//from w w w . ja va2s . co m * * @return A chart. */ private static JFreeChart createChart(ArrayList<String> cLabels, ArrayList<ArrayList<Integer>> cUnits) { CategoryDataset dataset1 = createDataset1(cLabels, cUnits); NumberAxis rangeAxis1 = new NumberAxis("Value"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer renderer1 = new LineAndShapeRenderer(); renderer1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1, renderer1); subplot1.setDomainGridlinesVisible(true); CategoryDataset dataset2 = createDataset2(cLabels, cUnits); NumberAxis rangeAxis2 = new NumberAxis("Value"); rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer2 = new BarRenderer(); renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2, renderer2); subplot2.setDomainGridlinesVisible(true); CategoryAxis domainAxis = new CategoryAxis("Time"); CombinedCategoryPlot plot = new CombinedCategoryPlot(domainAxis, new NumberAxis("Units")); plot.add(subplot1, 2); plot.add(subplot2, 1); JFreeChart result = new JFreeChart(chartTitle, new Font("SansSerif", Font.BOLD, 22), plot, true); return result; }
From source file:org.gvsig.remotesensing.scatterplot.gui.ChartScaterPlotPanel.java
/** * Metodo que construye el grafico inicialmente. Antes de construirlo, llama a * setDataChart() para cargar los datos a representar * * *///from w w w.ja v a 2 s . c o m private void createChart(Color colorChart, Color colorBackground, Color colorExternal) { NumberAxis domainAxis = new NumberAxis(PluginServices.getText(this, "banda") + " " + (bandaX + 1)); domainAxis.setAutoRangeIncludesZero(false); NumberAxis rangeAxis = new NumberAxis(PluginServices.getText(this, "banda") + " " + (bandaY + 1)); rangeAxis.setAutoRangeIncludesZero(false); // Se cargan los datos antes de construir el grafico setDataChart(fLayer); plot = new ScatterPlotChart(this.data, domainAxis, rangeAxis); chart = new JFreeChart(PluginServices.getText(this, "diagrama_dispersion"), plot); data = null; chart.getRenderingHints().clear(); chart.setBackgroundPaint(colorExternal); plot.setPaint(colorChart); plot.setBackgroundPaint(colorBackground); }
From source file:org.jtotus.gui.graph.GraphPrinter.java
private XYPlot createSubPlot(String plotName, GraphSeriesType type) { final TimeSeriesCollection collection = new TimeSeriesCollection(); final NumberAxis range = new NumberAxis("Value"); final XYPlot newSubPlot = new XYPlot(collection, null, range, this.getRenderer(type)); newSubPlot.setDomainCrosshairVisible(true); newSubPlot.setRangeCrosshairVisible(true); newSubPlot.setDomainGridlinesVisible(true); if (!plotMap.containsKey(plotName)) { plotMap.put(plotName, newSubPlot); mainPlot.add(newSubPlot);//from www . j a v a 2 s . c o m return newSubPlot; } return null; }
From source file:es.bsc.autonomic.powermodeller.graphics.TotalPowerVsPredictionDecomposed.java
private static JFreeChart createChart() { ///* w ww . j av a 2 s. c o m*/ DefaultCategoryDataset Pactual = jFreeChartDataSets.get(CoreConfiguration.PACTUAL_LABEL); DefaultCategoryDataset Ppredicted = jFreeChartDataSets.get(CoreConfiguration.PPREDICTED_LABEL); StandardCategoryItemLabelGenerator standardcategoryitemlabelgenerator = new StandardCategoryItemLabelGenerator(); LineAndShapeRenderer renderer1 = new LineAndShapeRenderer(); /*renderer1.setBaseItemLabelGenerator(standardcategoryitemlabelgenerator); renderer1.setBaseItemLabelsVisible(true);*/ StackedAreaRenderer renderer2 = new StackedAreaRenderer(); //plot CategoryPlot plot = new CategoryPlot(); plot.setDataset(Ppredicted); plot.setRenderer(renderer2); plot.setDataset(1, Pactual); plot.setRenderer(1, renderer1); CategoryAxis axis = new CategoryAxis("Sample"); axis.setTickLabelsVisible(false); axis.setCategoryMargin(0.0); plot.setDomainAxis(axis); //more rangeAxis plot.setRangeAxis(new NumberAxis("Power (Watts)")); plot.mapDatasetToRangeAxis(2, 1); // plot.setOrientation(PlotOrientation.VERTICAL); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); //chart JFreeChart chart = new JFreeChart(plot); chart.setTitle(NAME); return chart; }
From source file:org.hammurapi.inspectors.metrics.reporting.LocCharts.java
private JFreeChart copyDeepXYSeries(IntVector distinctValues, IntVector frequencies) { IntervalXYDataset dataset = new LocIntervalXYDataset(); // create the chart... JFreeChart chart = ChartFactory.createXYBarChart(chartName, // chart // title "NCSS", // domain axis label "Occurance", // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, false);/*from ww w.j a va 2 s . c o m*/ // get a reference to the plot for further customisation... XYPlot plot = chart.getXYPlot(); plot.setDomainAxis(new NumberAxis("Not Commented Source Statements")); // add the chart to a panel... ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(graphicDimX, graphicDimY)); setContentPane(chartPanel); return chart; }
From source file:org.graphstream.algorithm.measure.ChartMinMaxAverageSeriesMeasure.java
public JFreeChart createChart(PlotParameters params) throws PlotException { XYSeriesCollection minMax = new XYSeriesCollection(); XYSeriesCollection avgCol = new XYSeriesCollection(); XYPlot plot;/* w ww. j ava2 s. c o m*/ XYBarRenderer r = new XYBarRenderer(); r.setBarPainter(new StandardXYBarPainter()); r.setMargin(0.35); minMax.addSeries(min); avgCol.addSeries(series); minMax.addSeries(max); JFreeChart chart = ChartFactory.createXYLineChart(params.title, params.xAxisLabel, params.yAxisLabel, avgCol, params.orientation, params.showLegend, true, false); plot = ((XYPlot) chart.getPlot()); plot.setDataset(1, minMax); plot.setRenderer(1, r); if (separateMinMaxAxis) { NumberAxis minMaxAxis = new NumberAxis("min/max"); plot.setRangeAxis(1, minMaxAxis); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); plot.mapDatasetToRangeAxis(1, 1); } return chart; }
From source file:com.projity.pm.graphic.chart.ChartHelper.java
public static JFreeChart createLineChart(final XYDataset dataset) { NumberAxis xAxis = new NumberAxis(null); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(null); XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false); removeAxisAndInsets(chart);// w w w .j a v a2 s .c om return chart; }