List of usage examples for org.jfree.chart.axis NumberAxis setRange
public void setRange(double lower, double upper)
From source file:OAT.ui.BarChartFrame.java
public void addDataset(ChartDataset dataset) { if (dataset == null || dataset.getSeriesCount() == 0) { return;//w w w .j a v a 2 s. c o m } XYPlot plot = getChart().getXYPlot(); int i = plot.getDatasetCount(); for (int j = 0; j < i; j++) { if (plot.getDataset(j).equals(dataset)) { // System.out.println("eq " + i // + " " + ((ChartDataset) plot.getDataset(j)).getTitle() // + " " + dataset.getTitle()); return; } } plot.setDataset(i, dataset); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); Double[] range = dataset.getAxisRange(); //axis int axisId = 0; if (range != null) { // if (range == null || range.length < 2) { // plot.mapDatasetToRangeAxis(i, 0); // } else { //scan for equal axis range, reuse if found boolean hasSameRange = false; if (range.length > 1) { for (int j = 1; j < plot.getRangeAxisCount(); j++) { Range otherRange = plot.getRangeAxis(j).getRange(); if (otherRange != null && otherRange.getLowerBound() == range[0] && otherRange.getUpperBound() == range[1]) { axisId = j; hasSameRange = true; break; } } } if (!hasSameRange) { NumberAxis newAxis = new NumberAxis(); if (range.length > 1) { newAxis.setAutoRange(false); newAxis.setRange(range[0], range[1]); } if (range.length > 2) { newAxis.setAutoTickUnitSelection(false, false); newAxis.setTickUnit(new NumberTickUnit(range[2])); } newAxis.setNumberFormatOverride(TextUtil.SIMPLE_FORMATTER); // newAxis.setAxisLinePaint(new Color(100, 0, 0)); // newAxis.setLabelPaint(paints[i][0]); // newAxis.setTickLabelPaint(paints[i][0]); // newAxis.setTickMarkPaint(paints[i][0]); // newAxis.setTickLabelsVisible(true); axisId = plot.getRangeAxisCount(); plot.setRangeAxis(axisId, newAxis, false); plot.setRangeAxisLocation(axisId, AxisLocation.BOTTOM_OR_LEFT, false); } // plot.mapDatasetToRangeAxis(i, newAxisId); } plot.mapDatasetToRangeAxis(i, axisId); // //renderer XYLineAndShapeRenderer renderer; if (dataset instanceof TradeDataset) { renderer = new TradeRenderer(); for (int j = 0; j < dataset.getSeriesCount(); j++) { renderer.setSeriesLinesVisible(j, false); } } else { Shape shape = Main.defaultShape; Paint[][] seriesPaints; Stroke stroke; if (dataset.getSource() instanceof Stopper && !(dataset.getSource() instanceof Calculator)) { seriesPaints = Main.greyPaints; stroke = Main.dottedStoke; } else { seriesPaints = Main.defaultPaints; stroke = Main.defaultStoke; } renderer = new IndicatorRenderer(seriesPaints[(i - 1) % seriesPaints.length], shape, stroke); } plot.setRenderer(i, renderer, false); }
From source file:piilSource.BarChart.java
private JFreeChart createChart(String title, final CategoryDataset dataset, String metaLabel) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart( "Barplot of the " + metaLabel + " values for all samples - " + title, // chart title "Samples", // domain axis label metaLabel + " values", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );/*from w w w . jav a 2s .com*/ // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.red); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (metaLabel.equals("beta")) { rangeAxis.setRange(0, 1); rangeAxis.setTickUnit(new NumberTickUnit(0.2)); } // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.blue); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.green); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.red); final GradientPaint gp3 = new GradientPaint(0.0f, 0.0f, Color.yellow, 0.0f, 0.0f, Color.yellow); final GradientPaint gp4 = new GradientPaint(0.0f, 0.0f, Color.cyan, 0.0f, 0.0f, Color.cyan); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); renderer.setSeriesPaint(3, gp3); renderer.setSeriesPaint(4, gp4); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); if (dataset.getColumnCount() > 40) { domainAxis.setTickLabelFont(new Font("Serif", Font.PLAIN, 10)); domainAxis .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2)); } return chart; }
From source file:Applet.EmbeddedChart.java
public void changeBounds(double x1, double x2, double y1, double y2) { NumberAxis domain = (NumberAxis) ((XYPlot) chartPanel.getChart().getPlot()).getDomainAxis(); NumberAxis range = (NumberAxis) ((XYPlot) chartPanel.getChart().getPlot()).getRangeAxis(); domain.setRange(x1, x2); range.setRange(y1, y2);/*from w w w . jav a 2 s.c om*/ }
From source file:edu.cudenver.bios.chartsvc.resource.LegendResource.java
private XYPlot buildScatterPlot(Chart chart) throws ResourceException { // the first series is treated as the x values if (chart.getSeries() == null || chart.getSeries().size() <= 0) throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No data series specified"); // create the jfree chart series XYSeriesCollection chartData = new XYSeriesCollection(); // use a spline renderer to make the connecting lines smooth XYSplineRenderer rend = new XYSplineRenderer(); int seriesIdx = 0; for (Series series : chart.getSeries()) { XYSeries xySeries = new XYSeries(series.getLabel()); List<Double> xList = series.getXCoordinates(); List<Double> yList = series.getYCoordinates(); if (xList != null && yList != null && xList.size() == yList.size()) { for (int i = 0; i < xList.size(); i++) { xySeries.add(xList.get(i), yList.get(i)); }/*from w w w. java 2s .c om*/ } // set the line style rend.setSeriesPaint(seriesIdx, Color.BLACK); if (seriesIdx > 0) { rend.setSeriesStroke(seriesIdx, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { (float) seriesIdx, (float) 2 * seriesIdx }, 0.0f)); } // add the series to the data set chartData.addSeries(xySeries); seriesIdx++; } // turn off shapes displayed at each data point to make a smooth curve rend.setBaseShapesVisible(false); // Create the line chart NumberAxis xAxis = new NumberAxis(); xAxis.setAutoRangeIncludesZero(false); if (chart.getXAxis() != null) { Axis xAxisSpec = chart.getXAxis(); xAxis.setLabel(xAxisSpec.getLabel()); if (!Double.isNaN(xAxisSpec.getRangeMin()) && !Double.isNaN(xAxisSpec.getRangeMax())) { xAxis.setRange(xAxisSpec.getRangeMin(), xAxisSpec.getRangeMax()); } } NumberAxis yAxis = new NumberAxis(); if (chart.getYAxis() != null) { Axis yAxisSpec = chart.getYAxis(); yAxis.setLabel(chart.getYAxis().getLabel()); if (!Double.isNaN(yAxisSpec.getRangeMin()) && !Double.isNaN(yAxisSpec.getRangeMax())) { xAxis.setRange(yAxisSpec.getRangeMin(), yAxisSpec.getRangeMax()); } } XYPlot plot = new XYPlot((XYDataset) chartData, xAxis, yAxis, rend); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); return plot; }
From source file:gov.nih.nci.caintegrator.plots.kaplanmeier.JFreeChartIKMPlottermpl.java
public JFreeChart createKMPlot(Collection<GroupCoordinates> groupsToBePlotted, String title, String xAxisLabel, String yAxisLabel) {/*from w ww. java 2s .c om*/ List<KMPlotPointSeriesSet> kmPlotSets = new ArrayList<KMPlotPointSeriesSet>( convertToKaplanMeierPlotPointSeriesSet(groupsToBePlotted)); XYSeriesCollection finalDataCollection = new XYSeriesCollection(); /* Repackage all the datasets to go into the XYSeriesCollection */ for (KMPlotPointSeriesSet dataSet : kmPlotSets) { finalDataCollection.addSeries(dataSet.getCensorPlotPoints()); finalDataCollection.addSeries(dataSet.getProbabilityPlotPoints()); } JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, finalDataCollection, PlotOrientation.VERTICAL, true, //legend true, //tooltips false//urls ); XYPlot plot = (XYPlot) chart.getPlot(); /* * Ideally the actual Renderer settings should have been created * at the survivalLength of iterating KaplanMeierPlotPointSeriesSets, adding them to the actual * Data Set that is going to be going into the Chart plotter. But you have no idea how * they are going to be sitting in the Plot dataset so there is no guarantee that setting the * renderer based on a supposed index will actually work. In fact */ XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 0; i < finalDataCollection.getSeriesCount(); i++) { KMPlotPointSeries kmSeries = (KMPlotPointSeries) finalDataCollection.getSeries(i); if (kmSeries.getType() == KMPlotPointSeries.SeriesType.CENSOR) { renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, true); renderer.setSeriesShape(i, getCensorShape()); } else if (kmSeries.getType() == KMPlotPointSeries.SeriesType.PROBABILITY) { renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, false); } else { //don't show this set as it is not a known type renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, false); } renderer.setSeriesPaint(i, getKMSetColor(kmPlotSets, kmSeries.getKey(), kmSeries.getType()), true); } renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setDefaultEntityRadius(6); plot.setRenderer(renderer); /* change the auto tick unit selection to integer units only... */ NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); /* OPTIONAL CUSTOMISATION COMPLETED. */ rangeAxis.setAutoRange(true); rangeAxis.setRange(0.0, 1.0); /* set Title and Legend */ chart.setTitle(title); createLegend(chart, kmPlotSets); return chart; }
From source file:MWC.GUI.JFreeChart.StepperXYPlot.java
/** * Draws the XY plot on a Java 2D graphics device (such as the screen or a * printer), together with a current time marker * <P>//from w w w. ja va 2 s . c o m * XYPlot relies on an XYItemRenderer to draw each item in the plot. This * allows the visual representation of the data to be changed easily. * <P> * The optional info argument collects information about the rendering of the * plot (dimensions, tooltip information etc). Just pass in null if you do not * need this information. * * @param g2 * The graphics device. * @param plotArea * The area within which the plot (including axis labels) should be * drawn. * @param info * Collects chart drawing information (null permitted). */ public final void draw(final Graphics2D g2, final Rectangle2D plotArea, final Point2D anchor, final PlotState state, final PlotRenderingInfo info) { super.draw(g2, plotArea, anchor, state, info); // do we want to view the line? if (!_showLine) return; // do we have a time? if (_currentTime != null) { // find the screen area for the dataset final Rectangle2D dataArea = info.getDataArea(); // determine the time we are plotting the line at long theTime = _currentTime.getMicros(); // hmmm, how do we format the date final CanBeRelativeToTimeStepper axis = (CanBeRelativeToTimeStepper) this.getDomainAxis(); // are we working in relative time mode? if (axis.isRelativeTimes()) { if (_myStepper != null) { // yes, we now need to offset the time theTime = theTime - _myStepper.getTimeZero().getMicros(); } } // hmm, see if we are wroking with a date or number axis double linePosition = 0; if (axis instanceof DateAxis) { // ok, now scale the time to graph units final DateAxis dateAxis = (DateAxis) axis; // find the new x value linePosition = dateAxis.dateToJava2D(new Date(theTime / 1000), dataArea, this.getDomainAxisEdge()); if (_resetAxes) { dateAxis.setAutoRange(true); _resetAxes = false; } if (isGrowWithTime()) { final long endMillis = theTime / 1000; long startMillis; if (_fixedDuration != null) { startMillis = endMillis - _fixedDuration.getMillis(); } else { startMillis = (long) dateAxis.getLowerBound(); } final Date startDate = new Date(startMillis); final Date endDate = new Date(endMillis); dateAxis.setRange(startDate, endDate); } else { } } else { if (axis instanceof NumberAxis) { final NumberAxis numberAxis = (NumberAxis) axis; linePosition = numberAxis.valueToJava2D(theTime, dataArea, this.getDomainAxisEdge()); if (isGrowWithTime()) numberAxis.setRange(numberAxis.getRange().getLowerBound(), theTime); else { if (_resetAxes) { numberAxis.setAutoRange(true); _resetAxes = false; } } } } // ok, finally draw the line - if we're not showing the growing plot if (!isGrowWithTime()) plotStepperLine(g2, linePosition, dataArea); } }
From source file:org.owasp.benchmark.score.report.Scatter.java
private JFreeChart display(String title, int height, int width, OverallResults or) { JFrame f = new JFrame(title); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Note: this is a little weird, since each point is a separate series XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries series = new XYSeries("Scores"); for (OverallResult r : or.getResults()) { series.add(r.fpr * 100, r.tpr * 100); }/* w w w . j ava 2 s . c om*/ dataset.addSeries(series); chart = ChartFactory.createScatterPlot(title, "False Positive Rate", "True Positive Rate", dataset, PlotOrientation.VERTICAL, true, true, false); String fontName = "Arial"; DecimalFormat pctFormat = new DecimalFormat("0'%'"); theme = (StandardChartTheme) org.jfree.chart.StandardChartTheme.createJFreeTheme(); theme.setExtraLargeFont(new Font(fontName, Font.PLAIN, 24)); // title theme.setLargeFont(new Font(fontName, Font.PLAIN, 20)); // axis-title theme.setRegularFont(new Font(fontName, Font.PLAIN, 16)); theme.setSmallFont(new Font(fontName, Font.PLAIN, 12)); theme.setRangeGridlinePaint(Color.decode("#C0C0C0")); theme.setPlotBackgroundPaint(Color.white); theme.setChartBackgroundPaint(Color.white); theme.setGridBandPaint(Color.red); theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); theme.setBarPainter(new StandardBarPainter()); theme.setAxisLabelPaint(Color.decode("#666666")); theme.apply(chart); XYPlot xyplot = chart.getXYPlot(); NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis(); xyplot.setOutlineVisible(true); rangeAxis.setRange(-9.99, 109.99); rangeAxis.setNumberFormatOverride(pctFormat); rangeAxis.setTickLabelPaint(Color.decode("#666666")); rangeAxis.setMinorTickCount(5); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setAxisLineVisible(true); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setTickMarksVisible(true); rangeAxis.setLowerMargin(10); rangeAxis.setUpperMargin(10); xyplot.setRangeGridlineStroke(new BasicStroke()); xyplot.setRangeGridlinePaint(Color.lightGray); xyplot.setRangeMinorGridlinePaint(Color.decode("#DDDDDD")); xyplot.setRangeMinorGridlinesVisible(true); domainAxis.setRange(-5, 105); domainAxis.setNumberFormatOverride(pctFormat); domainAxis.setTickLabelPaint(Color.decode("#666666")); domainAxis.setMinorTickCount(5); domainAxis.setTickUnit(new NumberTickUnit(10)); domainAxis.setAxisLineVisible(true); domainAxis.setTickMarksVisible(true); domainAxis.setMinorTickMarksVisible(true); domainAxis.setLowerMargin(10); domainAxis.setUpperMargin(10); xyplot.setDomainGridlineStroke(new BasicStroke()); xyplot.setDomainGridlinePaint(Color.lightGray); xyplot.setDomainMinorGridlinePaint(Color.decode("#DDDDDD")); xyplot.setDomainMinorGridlinesVisible(true); chart.setTextAntiAlias(true); chart.setAntiAlias(true); chart.removeLegend(); chart.setPadding(new RectangleInsets(20, 20, 20, 20)); xyplot.getRenderer().setSeriesPaint(0, Color.decode("#4572a7")); // // setup item labels // XYItemRenderer renderer = xyplot.getRenderer(); // Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 7.0f, 7.0f); // for ( int i = 0; i < dataset.getSeriesCount(); i++ ) { // renderer.setSeriesShape(i, circle); // renderer.setSeriesPaint(i, Color.blue); // String letter = "" + ((String)dataset.getSeries(i).getKey()).charAt(0); // StandardXYItemLabelGenerator generator = new StandardXYItemLabelGenerator(letter); // renderer.setSeriesItemLabelGenerator(i, generator); // renderer.setSeriesItemLabelsVisible(i, true); // ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER ); // renderer.setSeriesPositiveItemLabelPosition(i, position); // } makeDataLabels(or, xyplot); makeLegend(or, 57, 48, dataset, xyplot); // put legend inside plot // LegendTitle lt = new LegendTitle(xyplot); // lt.setItemFont(theme.getSmallFont()); // lt.setPosition(RectangleEdge.RIGHT); // lt.setItemFont(theme.getSmallFont()); // XYTitleAnnotation ta = new XYTitleAnnotation(.7, .55, lt, RectangleAnchor.TOP_LEFT); // ta.setMaxWidth(0.48); // xyplot.addAnnotation(ta); // draw guessing line Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 6, 3 }, 0); XYLineAnnotation guessing = new XYLineAnnotation(-5, -5, 105, 105, dashed, Color.red); xyplot.addAnnotation(guessing); XYPointerAnnotation worse = makePointer(75, 0, "Worse than guessing", TextAnchor.TOP_CENTER, 90); xyplot.addAnnotation(worse); XYPointerAnnotation better = makePointer(25, 100, "Better than guessing", TextAnchor.BOTTOM_CENTER, 270); xyplot.addAnnotation(better); XYTextAnnotation time = new XYTextAnnotation("Tool run time: " + or.getTime(), 12, -5.6); time.setTextAnchor(TextAnchor.TOP_LEFT); time.setFont(theme.getRegularFont()); time.setPaint(Color.red); xyplot.addAnnotation(time); XYTextAnnotation stroketext = new XYTextAnnotation(" Random Guess", 88, 107); stroketext.setTextAnchor(TextAnchor.CENTER_RIGHT); stroketext.setBackgroundPaint(Color.white); stroketext.setPaint(Color.red); stroketext.setFont(theme.getRegularFont()); xyplot.addAnnotation(stroketext); XYLineAnnotation strokekey = new XYLineAnnotation(58, 107, 68, 107, dashed, Color.red); xyplot.setBackgroundPaint(Color.white); xyplot.addAnnotation(strokekey); ChartPanel cp = new ChartPanel(chart, height, width, 400, 400, 1200, 1200, false, false, false, false, false, false); f.add(cp); f.pack(); f.setLocationRelativeTo(null); // f.setVisible(true); return chart; }
From source file:org.jgrasstools.gears.ui.OmsMatrixCharter.java
private JFreeChart doBarChart() { XYSeriesCollection collection = getSeriesCollection(); XYBarDataset xyBarDataset = new XYBarDataset(collection, minInterval); PlotOrientation orientation = PlotOrientation.VERTICAL; if (doHorizontal) { orientation = PlotOrientation.HORIZONTAL; }//from w ww . jav a 2s . co m JFreeChart chart = ChartFactory.createHistogram(inTitle, inLabels[0], inLabels[1], xyBarDataset, orientation, doLegend, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(0.85f); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); double delta = (max - min) * 0.1; yAxis.setRange(min, max + delta); yAxis.setMinorTickCount(4); yAxis.setMinorTickMarksVisible(true); if (inFormats != null && inFormats.length > 0 && inFormats[1].trim().length() > 0) { yAxis.setNumberFormatOverride(new DecimalFormat(inFormats[1])); } if (inFormats != null && inFormats.length > 0 && inFormats[0].trim().length() > 0) { ValueAxis domainAxis = plot.getDomainAxis(); if (domainAxis instanceof NumberAxis) { NumberAxis xAxis = (NumberAxis) domainAxis; xAxis.setNumberFormatOverride(new DecimalFormat(inFormats[0])); } } XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setShadowVisible(false); if (inColors != null) { String[] colorSplit = inColors.split(";"); for (int i = 0; i < colorSplit.length; i++) { String[] split = colorSplit[i].split(","); int r = (int) Double.parseDouble(split[0]); int g = (int) Double.parseDouble(split[1]); int b = (int) Double.parseDouble(split[2]); renderer.setSeriesPaint(i, new Color(r, g, b)); } } return chart; }
From source file:org.jgrasstools.gears.ui.OmsMatrixCharter.java
@SuppressWarnings("deprecation") private JFreeChart doLineChart() { XYSeriesCollection collection = getSeriesCollection(); PlotOrientation orientation = PlotOrientation.VERTICAL; if (doHorizontal) { orientation = PlotOrientation.HORIZONTAL; }//from ww w . j a va2 s. c o m JFreeChart chart = ChartFactory.createXYLineChart(inTitle, inLabels[0], inLabels[1], collection, orientation, doLegend, true, false); XYPlot plot = (XYPlot) chart.getPlot(); // plot.setDomainGridlinePaint(Color.red); // plot.setRangeGridlinePaint(Color.cyan); // plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer plotRenderer = plot.getRenderer(); if (plotRenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plotRenderer; if (doPoints) { renderer.setShapesVisible(true); renderer.setShapesFilled(true); } if (inColors != null) { String[] colorSplit = inColors.split(";"); for (int i = 0; i < colorSplit.length; i++) { String[] split = colorSplit[i].split(","); int r = (int) Double.parseDouble(split[0]); int g = (int) Double.parseDouble(split[1]); int b = (int) Double.parseDouble(split[2]); renderer.setSeriesPaint(i, new Color(r, g, b)); } } } NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); double delta = (max - min) * 0.1; yAxis.setRange(min, max + delta); yAxis.setMinorTickCount(4); yAxis.setMinorTickMarksVisible(true); if (inFormats != null && inFormats.length > 1 && inFormats[1].trim().length() > 0) { yAxis.setNumberFormatOverride(new DecimalFormat(inFormats[1])); } if (inFormats != null && inFormats.length > 0 && inFormats[0].trim().length() > 0) { ValueAxis domainAxis = plot.getDomainAxis(); if (domainAxis instanceof NumberAxis) { NumberAxis xAxis = (NumberAxis) domainAxis; xAxis.setNumberFormatOverride(new DecimalFormat(inFormats[0])); } } return chart; }
From source file:net.sf.mzmine.modules.visualization.spectra.SpectraVisualizerWindow.java
public void setAxesRange(double xMin, double xMax, double xTickSize, double yMin, double yMax, double yTickSize) { NumberAxis xAxis = (NumberAxis) spectrumPlot.getXYPlot().getDomainAxis(); NumberAxis yAxis = (NumberAxis) spectrumPlot.getXYPlot().getRangeAxis(); xAxis.setRange(xMin, xMax); xAxis.setTickUnit(new NumberTickUnit(xTickSize)); yAxis.setRange(yMin, yMax);/*from w ww. ja va 2s. c o m*/ yAxis.setTickUnit(new NumberTickUnit(yTickSize)); }