List of usage examples for org.jfree.chart.axis NumberAxis setTickUnit
public void setTickUnit(NumberTickUnit unit)
From source file:com.anrisoftware.prefdialog.miscswing.multichart.freechart.FreechartXYChart.java
@OnAwt @Override//from w w w . ja v a 2s.co m public void setModel(ChartModel model) { ChartModel oldValue = this.model; if (oldValue == model) { return; } if (oldValue != null) { oldValue.removeChartModelListener(modelListener); } this.model = model; this.domainTickUnit = tickUnitFactory.create(model, model.getViewMaximum() / 10); model.addChartModelListener(modelListener); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setTickUnit((NumberTickUnit) domainTickUnit); setupNewModel(); p.firePropertyChange(MODEL_PROPERTY.toString(), oldValue, model); }
From source file:com.att.aro.ui.view.overviewtab.ConnectionStatisticsChartPanel.java
public JFreeChart initializeChart() { JFreeChart chart = ChartFactory.createBarChart( ResourceBundleHelper.getMessageString("overview.sessionoverview.title"), null, null, createDataset(), PlotOrientation.HORIZONTAL, false, false, false); chart.setBackgroundPaint(this.getBackground()); chart.getTitle().setFont(AROUIManager.HEADER_FONT); this.plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setMaximumCategoryLabelWidthRatio(1.0f); domainAxis.setMaximumCategoryLabelLines(2); domainAxis.setLabelFont(AROUIManager.LABEL_FONT); domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabel(ResourceBundleHelper.getMessageString("analysisresults.percentage")); rangeAxis.setRange(0.0, 100.0);// ww w .j a v a 2s .c o m rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabelFont(AROUIManager.LABEL_FONT); rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); BarRenderer renderer = new StackedBarRenderer(); renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseItemLabelGenerator(new PercentLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.black); // Make second bar in stack invisible renderer.setSeriesItemLabelsVisible(1, false); renderer.setSeriesPaint(1, new Color(0, 0, 0, 0)); ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setBasePositiveItemLabelPosition(insideItemlabelposition); ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition); renderer.setBarPainter(new StandardBarPainter()); renderer.setShadowVisible(false); renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) { String sessionInfo = ""; switch (arg2) { case SESSION_TERMINATION: sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionTermination"); break; case SESSION_TIGHT_CONN: sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionTightConn"); break; case SESSION_BURST: sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionBurst"); break; case SESSION_LONG_BURST: sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionLongBurst"); break; default: break; } return sessionInfo; } }); plot.setRenderer(renderer); plot.getDomainAxis().setMaximumCategoryLabelLines(2); return chart; }
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 www.ja v a 2s. c o m*/ // 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:ecosim.gui.SummaryPane.java
/** * Private method to build the binning chart. * * @return A ChartPanel containing the binning chart. *///ww w .ja v a 2 s.c o m private ChartPanel makeBinningChart() { final DefaultXYDataset binData = new DefaultXYDataset(); final NumberFormat nf = NumberFormat.getInstance(); final NumberAxis xAxis = new NumberAxis("Sequence identity criterion"); nf.setMinimumFractionDigits(2); xAxis.setLowerBound(Binning.binLevels[0]); xAxis.setUpperBound(1.0D); xAxis.setTickUnit(new NumberTickUnit(0.05D, nf)); LogAxis yAxis = new LogAxis("Number of bins"); yAxis.setBase(2.0D); yAxis.setNumberFormatOverride(NumberFormat.getInstance()); yAxis.setTickUnit(new NumberTickUnit(2.0D)); yAxis.setMinorTickMarksVisible(true); yAxis.setAutoRangeMinimumSize(4.0D); yAxis.setSmallestValue(1.0D); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); for (int i = 0; i < seriesColors.length; i++) { renderer.setSeriesPaint(i, seriesColors[i]); renderer.setSeriesStroke(i, new BasicStroke(seriesStroke[i])); } XYPlot plot = new XYPlot(binData, xAxis, yAxis, renderer); JFreeChart binChart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false); binChart.setPadding(new RectangleInsets(0.0D, 0.0D, 0.0D, 10.0D)); LegendTitle legend = new LegendTitle(plot); legend.setMargin(new RectangleInsets(1.0D, 1.0D, 1.0D, 1.0D)); legend.setFrame(new LineBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); plot.addAnnotation(new XYTitleAnnotation(0.001D, 0.999D, legend, RectangleAnchor.TOP_LEFT)); final ChartPanel pane = new ChartPanel(binChart, false, true, true, false, false); // Watch for changes to the Summary object. summary.addObserver(new Observer() { public void update(Observable o, Object obj) { Summary s = (Summary) obj; ParameterEstimate estimate = s.getEstimate(); ArrayList<BinLevel> bins = s.getBins(); if (bins.size() > 0) { double[][] values = new double[2][bins.size()]; Double low = 1.0d; for (int i = 0; i < bins.size(); i++) { BinLevel bin = bins.get(i); values[0][i] = bin.getCrit(); values[1][i] = bin.getLevel(); if (values[0][i] < low) low = values[0][i]; } binData.addSeries("sequences", values); xAxis.setLowerBound(low); if (low > 0.95d - MasterVariables.EPSILON) { xAxis.setTickUnit(new NumberTickUnit(0.005D, nf)); } else if (low > 0.90d - MasterVariables.EPSILON) { xAxis.setTickUnit(new NumberTickUnit(0.010D, nf)); } else if (low > 0.80d - MasterVariables.EPSILON) { xAxis.setTickUnit(new NumberTickUnit(0.025D, nf)); } if (estimate != null) { double[][] omega = new double[2][bins.size()]; double[][] sigma = new double[2][bins.size()]; double[] omegaLine = estimate.getOmega(); double[] sigmaLine = estimate.getSigma(); for (int i = 0; i < bins.size(); i++) { double crit = 1.0D - values[0][i]; double snp = s.getLength() * crit; omega[0][i] = values[0][i]; sigma[0][i] = values[0][i]; omega[1][i] = Math.pow(2.0D, snp * omegaLine[0] + omegaLine[1]); sigma[1][i] = Math.pow(2.0D, snp * sigmaLine[0] + sigmaLine[1]); } if (-1.0D * omegaLine[0] > MasterVariables.EPSILON) { binData.addSeries("omega", omega); } if (-1.0D * sigmaLine[0] > MasterVariables.EPSILON) { binData.addSeries("sigma", sigma); } } // Repaint the summary pane. pane.repaint(); } } }); return pane; }
From source file:ec.ui.view.StabilityView.java
private void showDetail(Graphs g) { XYPlot plot = detailChart.getXYPlot(); NumberAxis yAxis = new NumberAxis(); yAxis.setTickLabelPaint(Color.GRAY); plot.setRangeAxis(yAxis);/*from www . j av a 2 s. com*/ NumberAxis xAxis = new NumberAxis(); xAxis.setTickLabelPaint(Color.GRAY); xAxis.setTickUnit(new NumberTickUnit(1)); xAxis.setRange(-0.5, ((double) g.getMaxElements()) - 0.5); plot.setDomainAxis(xAxis); plot.setDataset(MEAN_INDEX, new BasicXYDataset(Collections.singletonList(g.S1_))); plot.setDataset(POINTS_INDEX, new BasicXYDataset(Collections.singletonList(g.S2_))); plot.setDataset(SMOOTH_INDEX, new BasicXYDataset(Collections.singletonList(g.S3_))); rescaleAxis((NumberAxis) plot.getRangeAxis()); detailChart.setTitle(g.label_); panel.setChart(detailChart); panel.setToolTipText("Right click to show complete data"); onColorSchemeChange(); }
From source file:ec.ui.view.StabilityView.java
private void configureAxis(XYPlot plot) { int nb = graphs_.size(); List<String> names = new ArrayList<>(); for (Map.Entry<Bornes, Graphs> entry : graphs_.entrySet()) { names.add(entry.getValue().label_); }/*from w w w.j a v a2 s . co m*/ NumberAxis xAxis = new NumberAxis(); xAxis.setTickLabelPaint(Color.GRAY); xAxis.setTickUnit(new StabilityTickUnit(names)); xAxis.setRange(-0.5, nb - 0.5); plot.setDomainAxis(xAxis); plot.setDomainGridlinesVisible(false); NumberAxis yaxis = new NumberAxis(); rescaleAxis(yaxis); plot.setRangeAxis(yaxis); for (int i = 0; i < nb; i++) { ValueMarker marker = new ValueMarker(i + 0.5); marker.setStroke(MARKER_STROKE); marker.setPaint(MARKER_PAINT); marker.setAlpha(MARKER_ALPHA); plot.addDomainMarker(marker); } }
From source file:stockit.ClientFrame.java
private void createChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); int row = StockInfoTable.getSelectedRow(); if (row != -1) { //dataset.setValue(, "", table.getValueAt(0,1).toString()); String selectedStock = StockInfoTable.getValueAt(row, 0).toString(); try {/*from w w w . j a v a 2 s .c om*/ DBConnection dbcon = new DBConnection(); dbcon.establishConnection(); Statement stmt = dbcon.con.createStatement(); ResultSet rs = stmt .executeQuery("Select stock_daily_performance.Closing_Price, stock_daily_performance.Date\n" + "FROM stock_daily_performance, stock\n" + "WHERE stock_daily_performance.StockID = stock.StockID AND stock.StockID = '" + selectedStock + "'" + "AND Date IN\n" + "( Select * from\n" + "(\n" + "SELECT Date \n" + "FROM stock_daily_performance \n" + "WHERE StockID = stockID \n" + "ORDER BY Date ASC\n" + ") temp_table)\n" + " "); while (rs.next()) { String formattedDate = rs.getString("Date"); int closing_price = rs.getInt("Closing_Price"); dataset.setValue(closing_price, "value", formattedDate); } dbcon.con.close(); } catch (Exception ex) { System.out.println(ex.toString()); } String stockName = StockInfoTable.getValueAt(row, 1).toString(); JFreeChart chart = ChartFactory.createBarChart3D(stockName + " Stock Performance", "Date", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); Color c = new Color(240, 240, 240, 0); chart.setBackgroundPaint(c); CategoryPlot catPlot = chart.getCategoryPlot(); catPlot.setRangeGridlinePaint(Color.BLACK); //set interval of Y-axis ticks (tick every 5 units) NumberAxis yAxis = (NumberAxis) catPlot.getRangeAxis(); yAxis.setTickUnit(new NumberTickUnit(5)); //set y-axis labels as currency types ($) NumberFormat currency = NumberFormat.getCurrencyInstance(); yAxis.setNumberFormatOverride(currency); //setting number of lines an x-axis label is displayed on CategoryAxis categoryAxis = catPlot.getDomainAxis(); categoryAxis.setMaximumCategoryLabelLines(4); ChartContainer.setLayout(new java.awt.BorderLayout()); ChartPanel chartPanel = new ChartPanel(chart); ChartContainer.removeAll(); ChartContainer.add(chartPanel, BorderLayout.CENTER); ChartContainer.validate(); ChartContainer.repaint(); } }
From source file:no.met.jtimeseries.marinogram.MarinogramWindPlot.java
private XYPlot createPlot(TimeZone timezone, boolean plotWindDirection, boolean plotWindSpeed) { ChartPlotter plotter = new ChartPlotter(); // default setting plotter.setHeight(this.getHeight()); plotter.setWidth(this.getWidth()); plotter.setPlotDefaultProperties("", ""); Color windSpeedColor = new Color(0, 0, 0); Color windDirectionColor = new Color(0, 0, 0); // plot style PlotStyle.Builder currentStyleBuilder = new PlotStyle.Builder("Wind"); PlotStyle plotStyle;//w w w . ja va 2s .co m NumberPhenomenon windDirection = getLocationForecastDataModel() .getPhenomenen(PhenomenonName.WindDirectionDegree.toString(), NumberPhenomenon.class); NumberPhenomenon windSpeed = getLocationForecastDataModel() .getPhenomenen(PhenomenonName.WindSpeedMPS.toString(), NumberPhenomenon.class); if (windSpeed == null || windDirection == null) { return null; } double tick = (windSpeed.getMaxValue() - windSpeed.getMinValue()) / 3; tick = Math.ceil(tick); double lowBound = Math.floor(windSpeed.getMinValue() / (tick)) * (tick); //The minimum scale is 0 lowBound = lowBound < 0 ? 0 : lowBound; lowBound = lowBound - tick / 2; double upperBound = lowBound + tick * 6; // reference the range axis NumberAxis leftNumberAxis = new NumberAxis(); leftNumberAxis.setLabel(messages.getString("parameter.wind") + " (m/s)"); leftNumberAxis.setLabelPaint(windSpeedColor); leftNumberAxis.setTickLabelPaint(windSpeedColor); //int tickUnit = (int) Math.ceil((upperBound - lowBound) / 6); leftNumberAxis.setTickUnit(new NumberTickUnit(tick)); leftNumberAxis.setLowerBound(lowBound); leftNumberAxis.setUpperBound(upperBound); NumberAxis rightNumberAxis = new NumberAxis(); rightNumberAxis.setLabel(messages.getString("label.knots")); rightNumberAxis.setLabelPaint(windSpeedColor); rightNumberAxis.setTickLabelPaint(windSpeedColor); lowBound = lowBound / KNOT; upperBound = upperBound / KNOT; rightNumberAxis.setLowerBound(lowBound); rightNumberAxis.setUpperBound(upperBound); rightNumberAxis.setTickUnit(new NumberTickUnit(tick / KNOT)); NumberFormat formatter = new DecimalFormat("#0.0"); rightNumberAxis.setNumberFormatOverride(formatter); List<Date> shortTermTimeList = this.getShortTermTime(windDirection.getTime().get(0)); // set thte plot current speed color to be transparent if show current // speed is false if (!plotWindSpeed) { windSpeedColor = new Color(0, 0, 0, 0); } // plot style plotStyle = currentStyleBuilder.spline(SplineStyle.HYBRID).stroke(new BasicStroke(2.0f)) .seriesColor(windSpeedColor).numberAxis(leftNumberAxis).nonNegative(true).build(); // Draw the current direction even if plotCurrentSpeed is false (but // with transparent in such a case) // for the purpose to keep the same background grid and tick label on // the y-axis // no matter the wave height is shown or not plotter.addLineChart(TimeBase.SECOND, windSpeed, plotStyle); plotter.getPlot().setRangeAxis(1, rightNumberAxis); plotter.getPlot().setOutlineVisible(true); Date minDate = shortTermTimeList.get(0); Date maxDate = shortTermTimeList.get(shortTermTimeList.size() - 1); plotter.setDomainRange(minDate, maxDate); plotter.setDomainDateFormat(timezone, "HH"); // set domain range after (must) plot all the data plotter.addHourBasedDomainGridLines(); // invisible domain axis plotter.getPlot().getDomainAxis().setTickLabelsVisible(false); // add markers plotter.addDomainMarkers(shortTermTimeList, timezone, locale); if (plotWindDirection) { List<Date> symbolTimes = Utility.filterMinimumHourInterval(windDirection.getTime(), 2, 1); InListFromDateFilter symbolTimesFilter = new InListFromDateFilter(symbolTimes); windDirection.filter(symbolTimesFilter); windSpeed = null; if (plotWindSpeed) { windSpeed = getLocationForecastDataModel().getPhenomenen(PhenomenonName.WindSpeedMPS.toString(), NumberPhenomenon.class); windSpeed.filter(symbolTimesFilter); windSpeed = windSpeed.scaling(1 / KNOT); } plotStyle = currentStyleBuilder.seriesColor(windDirectionColor).build(); // when plot wind direction, the arrow should be rotated 180 degree windDirection = windDirection.transform(180); plotter.addArrowDirectionPlot(windDirection, windSpeed, 2, plotStyle); // transform back after plot windDirection = windDirection.transform(180); } plotter.getPlot().setRangeZeroBaselineVisible(false); return plotter.getPlot(); }
From source file:no.met.jtimeseries.marinogram.MarinogramWavePlot.java
private XYPlot createPlot(TimeZone timezone, boolean plotWaveDirection, boolean plotWaveHeight) { ChartPlotter plotter = new ChartPlotter(); // default setting plotter.setHeight(this.getHeight()); plotter.setWidth(this.getWidth()); plotter.setPlotDefaultProperties("", ""); Color waveHeightColor = new Color(0, 105, 161); Color waveDirectionColor = new Color(0, 105, 161); // plot style PlotStyle.Builder waveStyleBuilder = new PlotStyle.Builder("Wave"); PlotStyle plotStyle;/*from w ww.j a va 2 s. com*/ NumberPhenomenon waveDirection = getOceanForecastDataModel() .getPhenomenen(PhenomenonName.WaveDirection.toString(), NumberPhenomenon.class); NumberPhenomenon waveHeight = getOceanForecastDataModel() .getPhenomenen(PhenomenonName.WaveHeight.toString(), NumberPhenomenon.class); if (waveHeight == null || waveDirection == null) { return null; } double tick = (waveHeight.getMaxValue() - waveHeight.getMinValue()) / 2; tick = Math.ceil(tick); double lowBound = Math.floor(waveHeight.getMinValue() / (tick)) * (tick); //The minimum scale is 0 lowBound = lowBound < 0 ? 0 : lowBound; lowBound = lowBound - tick / 2; double upperBound = lowBound + tick * 4; // reference the range axis NumberAxis leftNumberAxis = new NumberAxis(); leftNumberAxis.setLabel(messages.getString("parameter.wave") + " (m)"); leftNumberAxis.setLabelPaint(waveHeightColor); leftNumberAxis.setTickLabelPaint(waveHeightColor); leftNumberAxis.setLowerBound(lowBound); leftNumberAxis.setUpperBound(upperBound); leftNumberAxis.setTickUnit(new NumberTickUnit(tick)); NumberAxis rightNumberAxis = new NumberAxis(); rightNumberAxis.setLabelPaint(waveHeightColor); rightNumberAxis.setTickLabelPaint(waveHeightColor); rightNumberAxis.setLowerBound(lowBound); rightNumberAxis.setUpperBound(upperBound); rightNumberAxis.setTickUnit(new NumberTickUnit(tick)); List<Date> shortTermTime = this.getShortTermTime(waveDirection.getTime().get(0)); //set thte plot wave height color to be transparent if show wave height is false if (!plotWaveHeight) { waveHeightColor = new Color(0, 0, 0, 0); } // plot style plotStyle = waveStyleBuilder.spline(SplineStyle.HYBRID).stroke(new BasicStroke(2.0f)) .seriesColor(waveHeightColor).numberAxis(leftNumberAxis).nonNegative(true).build(); //Draw the wave height even if plotWaveHeight is false (but with transparent in such a case) //for the purpose to keep the same background grid and tick label on the y-axis //no matter the wave height is shown or not plotter.addLineChart(TimeBase.SECOND, waveHeight, plotStyle); plotter.getPlot().setRangeAxis(1, rightNumberAxis); plotter.getPlot().setOutlineVisible(true); // first set domain date format and then add hour based domain grid // lines // TODO: wrap this inside the addHourBasedDomainGridLines for // simplicity Date minDate = shortTermTime.get(0); Date maxDate = shortTermTime.get(shortTermTime.size() - 1); plotter.setDomainRange(minDate, maxDate); plotter.setDomainDateFormat(timezone, "HH"); // set domain range after (must) plot all the data plotter.addHourBasedDomainGridLines(); // invisible domain axis plotter.getPlot().getDomainAxis().setTickLabelsVisible(false); // add markers plotter.addDomainMarkers(shortTermTime, timezone, locale); if (plotWaveDirection) { List<Date> symbolTimes = Utility.filterMinimumHourInterval(waveDirection.getTime(), 2, 1); InListFromDateFilter symbolTimesFilter = new InListFromDateFilter(symbolTimes); waveDirection.filter(symbolTimesFilter); waveHeight = null; if (plotWaveHeight) { waveHeight = getOceanForecastDataModel().getPhenomenen(PhenomenonName.WaveHeight.toString(), NumberPhenomenon.class); waveHeight.filter(symbolTimesFilter); } plotStyle = waveStyleBuilder.seriesColor(waveDirectionColor).build(); plotter.addArrowDirectionPlot(waveDirection, waveHeight, 0.1, plotStyle); } plotter.getPlot().setRangeZeroBaselineVisible(false); return plotter.getPlot(); }
From source file:no.met.jtimeseries.chart.ChartPlotter.java
/** * Set the bound of axis/*from w w w . ja v a 2 s . c o m*/ * @param numberAxis The range axis * @param maxValue The maximum value * @param minValue The minimum value * @param span The number of lines between the maximum value and the minimum value * @param gridLines The number of background lines */ public static void setAxisBound(NumberAxis numberAxis, double maxValue, double minValue, int span, int gridLines) { double tick = (maxValue - minValue) / span; tick = Math.ceil(tick); double lowBound = Math.floor(minValue / (tick)) * (tick); double upperBound = Math.ceil(maxValue / (tick)) * (tick); int emptyLines = (int) ((lowBound + gridLines * tick - upperBound) / tick); lowBound = lowBound - (emptyLines / 2) * tick; lowBound = lowBound == minValue ? lowBound - 1 : lowBound; upperBound = lowBound + tick * gridLines; numberAxis.setTickUnit(new NumberTickUnit(tick)); numberAxis.setLowerBound(lowBound); numberAxis.setUpperBound(upperBound); }