List of usage examples for org.jfree.chart.axis NumberAxis NumberAxis
public NumberAxis()
From source file:org.pentaho.plugin.jfreereport.reportcharts.CategoricalChartExpressionTest.java
@Test public void configureRangeAxis_AnyValues() { final double lower = -20; final double upper = 20; NumberAxis axis = new NumberAxis(); axis.setRange(lower, upper);/*from ww w . java 2s . c om*/ expression.configureRangeAxis(createCategoryPlotWith(axis), createFont()); Assert.assertTrue(axis.getLowerBound() < lower); Assert.assertTrue(axis.getUpperBound() > upper); }
From source file:com.stableapps.anglewraparounddemo.AngleWrapDemoMain.java
/** * Creates a sample chart./* ww w . ja va 2s .co m*/ * * @return a sample chart. */ private JFreeChart createChart() { final XYDataset direction = createAngleDataset(600); final JFreeChart chart = ChartFactory.createTimeSeriesChart("Time", "Date", "Direction", direction, true, true, false); final XYPlot plot = chart.getXYPlot(); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setUpperMargin(0.0); // configure the range axis to provide a fix set of TickUnits depending on size of chart NumberAxis rangeAxis = new NumberAxis() { /** * */ private static final long serialVersionUID = 1L; @Override public NumberTickUnit getTickUnit() { NumberTickUnit tickUnit = super.getTickUnit(); if (tickUnit.getSize() < 15) { return tickUnit; } else if (tickUnit.getSize() < 45) { return new NumberTickUnit(45); } else if (tickUnit.getSize() < 90) { return new NumberTickUnit(90); } else if (tickUnit.getSize() < 180) { return new NumberTickUnit(180); } else { return new NumberTickUnit(360); } } }; rangeAxis.setAutoRangeIncludesZero(false); plot.setRangeAxis(rangeAxis); final OverflowCondition overflowCondition = new OverflowCondition() { @Override public boolean isOverflow(double y0, double x0, double y1, double x1) { return Math.abs(y1 - y0) > 180; } }; XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false) { /** * */ private static final long serialVersionUID = 1L; double min = 0; double max = 360; LinearInterpolator interpolator = new LinearInterpolator(); @Override protected void drawPrimaryLine(XYItemRendererState state, Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, int series, int item, ValueAxis domainAxis, ValueAxis rangeAxis, Rectangle2D dataArea) { if (item == 0) { return; } // get the data point... double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); if (Double.isNaN(y1) || Double.isNaN(x1)) { return; } double x0 = dataset.getXValue(series, item - 1); double y0 = dataset.getYValue(series, item - 1); if (Double.isNaN(y0) || Double.isNaN(x0)) { return; } if (overflowCondition.isOverflow(y0, x0, y1, x1)) { boolean overflowAtMax = y1 < y0; if (overflowAtMax) { LinearFunction lf = interpolator.interpolate(new double[] { y0, y1 + (max - min) }, new double[] { x0, x1 }); double xmid = lf.value(max); drawPrimaryLine(state, g2, plot, x0, y0, xmid, max, pass, series, item, domainAxis, rangeAxis, dataArea); drawPrimaryLine(state, g2, plot, xmid, min, x1, y1, pass, series, item, domainAxis, rangeAxis, dataArea); } else { LinearFunction lf = interpolator.interpolate(new double[] { y1 - (max - min), y0 }, new double[] { x1, x0 }); double xmid = lf.value(min); drawPrimaryLine(state, g2, plot, x0, y0, xmid, min, pass, series, item, domainAxis, rangeAxis, dataArea); drawPrimaryLine(state, g2, plot, xmid, max, x1, y1, pass, series, item, domainAxis, rangeAxis, dataArea); } } else { drawPrimaryLine(state, g2, plot, x0, y0, x1, y1, pass, series, item, domainAxis, rangeAxis, dataArea); } } private void drawPrimaryLine(XYItemRendererState state, Graphics2D g2, XYPlot plot, double x0, double y0, double x1, double y1, int pass, int series, int item, ValueAxis domainAxis, ValueAxis rangeAxis, Rectangle2D dataArea) { RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation); double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation); double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); // only draw if we have good values if (Double.isNaN(transX0) || Double.isNaN(transY0) || Double.isNaN(transX1) || Double.isNaN(transY1)) { return; } PlotOrientation orientation = plot.getOrientation(); boolean visible; if (orientation == PlotOrientation.HORIZONTAL) { state.workingLine.setLine(transY0, transX0, transY1, transX1); } else if (orientation == PlotOrientation.VERTICAL) { state.workingLine.setLine(transX0, transY0, transX1, transY1); } visible = LineUtilities.clipLine(state.workingLine, dataArea); if (visible) { drawFirstPassShape(g2, pass, series, item, state.workingLine); } } @Override protected void drawPrimaryLineAsPath(XYItemRendererState state, Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, int series, int item, ValueAxis domainAxis, ValueAxis rangeAxis, Rectangle2D dataArea) { // get the data point... State s = (State) state; try { double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); if (Double.isNaN(x1) && Double.isNaN(y1)) { s.setLastPointGood(false); return; } if (!s.isLastPointGood()) { ImmutablePair<Float, Float> xy = translate(plot, domainAxis, rangeAxis, dataArea, x1, y1); s.seriesPath.moveTo(xy.getLeft(), xy.getRight()); s.setLastPointGood(true); return; } double x0 = dataset.getXValue(series, item - 1); double y0 = dataset.getYValue(series, item - 1); if (overflowCondition.isOverflow(y0, x0, y1, x1)) { boolean overflowAtMax = y1 < y0; if (overflowAtMax) { LinearFunction lf = interpolator.interpolate(new double[] { y0, y1 + (max - min) }, new double[] { x0, x1 }); double xmid = lf.value(max); ImmutablePair<Float, Float> xy = translate(plot, domainAxis, rangeAxis, dataArea, xmid, max); s.seriesPath.lineTo(xy.getLeft(), xy.getRight()); xy = translate(plot, domainAxis, rangeAxis, dataArea, xmid, min); s.seriesPath.moveTo(xy.getLeft(), xy.getRight()); xy = translate(plot, domainAxis, rangeAxis, dataArea, x1, y1); s.seriesPath.lineTo(xy.getLeft(), xy.getRight()); } else { LinearFunction lf = interpolator.interpolate(new double[] { y1 - (max - min), y0 }, new double[] { x1, x0 }); double xmid = lf.value(min); ImmutablePair<Float, Float> xy = translate(plot, domainAxis, rangeAxis, dataArea, xmid, min); s.seriesPath.lineTo(xy.getLeft(), xy.getRight()); xy = translate(plot, domainAxis, rangeAxis, dataArea, xmid, max); s.seriesPath.moveTo(xy.getLeft(), xy.getRight()); xy = translate(plot, domainAxis, rangeAxis, dataArea, x1, y1); s.seriesPath.lineTo(xy.getLeft(), xy.getRight()); } } else { ImmutablePair<Float, Float> xy = translate(plot, domainAxis, rangeAxis, dataArea, x1, y1); s.seriesPath.lineTo(xy.getLeft(), xy.getRight()); } s.setLastPointGood(true); } finally { // if this is the last item, draw the path ... if (item == s.getLastItemIndex()) { // draw path drawFirstPassShape(g2, pass, series, item, s.seriesPath); } } } private ImmutablePair<Float, Float> translate(XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, Rectangle2D dataArea, double x, double y) { RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double transX1 = domainAxis.valueToJava2D(x, dataArea, xAxisLocation); double transY1 = rangeAxis.valueToJava2D(y, dataArea, yAxisLocation); // update path to reflect latest point float xtrans = (float) transX1; float ytrans = (float) transY1; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { xtrans = (float) transY1; ytrans = (float) transX1; } return new ImmutablePair<>(xtrans, ytrans); } }; renderer.setDrawSeriesLineAsPath(true); plot.setRenderer(0, renderer); return chart; }
From source file:org.fhcrc.cpl.viewer.gui.SpectrumChartFactory.java
protected static XYPlot createXYPlot(XYDataset dataset, Color[] colors) { // break up into two datasets, one for bars one for lines //LinkedList lines =new LinkedList(); //LinkedList bars = new LinkedList(); XYDataset seriesLines = new XYSeriesCollection(); XYDataset seriesBars = new XYSeriesCollection(); ((XYSeriesCollection) seriesBars).setIntervalWidth(0.0); if (dataset instanceof XYSeriesCollection) { while (0 < dataset.getSeriesCount()) { XYSeries s = ((XYSeriesCollection) dataset).getSeries(0); ((XYSeriesCollection) dataset).removeSeries(0); Comparable key = s.getKey(); boolean lines = false; if (key instanceof String) lines = ((String) key).startsWith("-"); if (lines) ((XYSeriesCollection) seriesLines).addSeries(s); else//from w w w . j ava 2 s. c o m ((XYSeriesCollection) seriesBars).addSeries(s); } } else { seriesBars = dataset; } NumberAxis axisDomain = new NumberAxis(); axisDomain.setAutoRange(true); axisDomain.setAutoRangeIncludesZero(false); // axisDomain.setRange(400.0, 1600.0); // NOTE: zooming in too far kills the chart, prevent this axisDomain.addChangeListener(new AxisChangeListener() { public void axisChanged(AxisChangeEvent event) { NumberAxis axis = (NumberAxis) event.getSource(); Range range = axis.getRange(); if (range.getLength() < 2.0) { //_log.info("AxisChangeListener " + range.getLength() + " " + range.toString()); double middle = range.getLowerBound() + range.getLength() / 2.0; axis.setRange(new Range(middle - 1.1, middle + 1.1)); } } }); NumberAxis axisRange = new NumberAxis(); axisRange.setAutoRange(true); axisRange.setAutoRangeIncludesZero(true); XYToolTipGenerator toolTipGenerator = new XYToolTipGenerator() { public String generateToolTip(XYDataset xyDataset, int s, int i) { double X = Math.round(xyDataset.getXValue(s, i) * 1000.0) / 1000.0; double Y = Math.round(xyDataset.getYValue(s, i) * 1000.0) / 1000.0; return "(" + X + ", " + Y + ")"; } }; XYBarRenderer barRenderer = new XYBarRenderer(); //dhmay adding 2009/09/14. As of jfree 1.0.13, shadows on by default barRenderer.setShadowVisible(false); //dhmay adding for jfreechart 1.0.6 upgrade. If this isn't here, we get a //nullPointerException in XYBarRenderer.drawItemLabel barRenderer.setBaseItemLabelGenerator(new NullLabelGenerator()); barRenderer.setSeriesItemLabelsVisible(0, true); barRenderer.setBaseToolTipGenerator(toolTipGenerator); XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(); lineRenderer.setBaseToolTipGenerator(toolTipGenerator); XYPlot xy = new XYPlot(null, axisDomain, axisRange, null); int ds = 0; if (seriesLines.getSeriesCount() > 0) { xy.setDataset(ds, seriesLines); xy.setRenderer(ds, lineRenderer); xy.mapDatasetToRangeAxis(ds, 0); ds++; for (int i = 0; i < seriesLines.getSeriesCount(); i++) { Comparable key = ((XYSeriesCollection) seriesLines).getSeriesKey(i); boolean lines = false; if (key instanceof String) lines = ((String) key).startsWith("-"); lineRenderer.setSeriesLinesVisible(i, lines); lineRenderer.setSeriesShapesVisible(i, !lines); } } if (seriesBars.getSeriesCount() > 0) { xy.setDataset(ds, seriesBars); xy.setRenderer(ds, barRenderer); xy.mapDatasetToRangeAxis(ds, 0); ds++; } setColors(xy, colors); return xy; }
From source file:com.sixrr.metrics.ui.charts.HistogramDialog.java
private JFreeChart createChart(IntervalXYDataset dataset, boolean isIntegral) { final String title = getTitle(); final NumberAxis xAxis = new NumberAxis(); if (isIntegral) { xAxis.setTickUnit(new NumberTickUnit(1.0)); }/*from w w w . j ava 2s. c o m*/ if (metricType == MetricType.Ratio || metricType == MetricType.RecursiveRatio) { xAxis.setNumberFormatOverride(new PercentFormatter()); } final XYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator(); final XYItemRenderer renderer = new XYBarRenderer(); renderer.setToolTipGenerator(tooltipGenerator); renderer.setURLGenerator(null); final ValueAxis yAxis = new NumberAxis(); final XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); plot.setRenderer(renderer); plot.setOrientation(PlotOrientation.VERTICAL); return new JFreeChart(title, JFreeChartConstants.DEFAULT_TITLE_FONT, plot, true); }
From source file:com.marvelution.jira.plugins.hudson.charts.BuildResultsRatioChartGenerator.java
/** * {@inheritDoc}//from w w w . j a va2s .c o m */ @Override public ChartHelper generateChart() { final Map<Integer, Build> buildMap = new HashMap<Integer, Build>(); final CategoryTableXYDataset dataSet = new CategoryTableXYDataset(); for (Build build : builds) { buildMap.put(Integer.valueOf(build.getBuildNumber()), build); dataSet.add(Double.valueOf(build.getBuildNumber()), Double.valueOf(build.getDuration()), getI18n().getText("hudson.charts.duration")); } final JFreeChart chart = ChartFactory.createXYBarChart("", "", false, getI18n().getText("hudson.charts.duration"), dataSet, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.WHITE); chart.setBorderVisible(false); final BuildResultRenderer renderer = new BuildResultRenderer(server, buildMap); renderer.setBaseItemLabelFont(ChartDefaults.defaultFont); renderer.setBaseItemLabelsVisible(false); renderer.setMargin(0.0D); renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER)); renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); renderer.setBaseToolTipGenerator(renderer); renderer.setURLGenerator(renderer); final XYPlot xyPlot = chart.getXYPlot(); xyPlot.setAxisOffset(new RectangleInsets(1.0D, 1.0D, 1.0D, 1.0D)); xyPlot.setRenderer(renderer); final NumberAxis domainAxis = new NumberAxis(); domainAxis.setLowerBound(Collections.min(buildMap.keySet())); domainAxis.setUpperBound(Collections.max(buildMap.keySet())); final TickUnitSource ticks = NumberAxis.createIntegerTickUnits(); domainAxis.setStandardTickUnits(ticks); xyPlot.setDomainAxis(domainAxis); final DateAxis rangeAxis = new DateAxis(); final DurationFormat durationFormat = new DurationFormat(); rangeAxis.setDateFormatOverride(durationFormat); rangeAxis.setLabel(getI18n().getText("hudson.charts.duration")); xyPlot.setRangeAxis(rangeAxis); ChartUtil.setupPlot(xyPlot); return new ChartHelper(chart); }
From source file:org.hxzon.demo.jfreechart.PolarChartDemo.java
private static JFreeChart createPolarChart(XYDataset dataset) { boolean legend = true; PolarPlot plot = new PolarPlot(); plot.setDataset(dataset);/*from www . j ava 2 s . c o m*/ NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAxisLineVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart("Polar Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setAngleGridlinesVisible(true); plot.setAngleLabelsVisible(true); plot.setAngleTickUnit(new NumberTickUnit(5)); return chart; }
From source file:com.att.aro.ui.view.diagnostictab.CreateBarPlot.java
public XYPlot drawXYItemPlot() { // Set up renderer XYItemRenderer throughputRenderer = new StandardXYItemRenderer(); throughputRenderer.setSeriesPaint(0, Color.red); // Normalize the throughput axis so that it represents max value NumberAxis axis = new NumberAxis(); axis.setVisible(false);/*from ww w. j a v a 2 s . com*/ // Create plot XYPlot throughputPlot = new XYPlot(null, null, axis, throughputRenderer); throughputPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); throughputPlot.getRangeAxis().setVisible(false); return throughputPlot; }
From source file:net.sf.mzmine.modules.visualization.histogram.HistogramChart.java
public HistogramChart() { super(null, true); // initialize the chart by default time series chart from factory chart = ChartFactory.createHistogram("", // 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 a v a2s. co m // title chartTitle = chart.getTitle(); chartTitle.setFont(titleFont); chartTitle.setMargin(5, 0, 0, 0); chartSubTitle = new TextTitle(); chartSubTitle.setFont(subTitleFont); chartSubTitle.setMargin(5, 0, 0, 0); chart.addSubtitle(chartSubTitle); // legend constructed by ChartFactory LegendTitle legend = chart.getLegend(); legend.setItemFont(legendFont); legend.setFrame(BlockBorder.NONE); 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.REVERSE); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(true); // set the logarithmic axis NumberAxis axisDomain = new HistogramDomainAxis(); axisDomain.setMinorTickCount(1); axisDomain.setAutoRange(true); NumberAxis axisRange = new NumberAxis(); axisRange.setMinorTickCount(1); axisRange.setAutoRange(true); plot.setDomainAxis(axisDomain); plot.setRangeAxis(axisRange); ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer(); renderer.setMargin(marginSize); renderer.setShadowVisible(false); plot.setRenderer(renderer); this.setMinimumSize(new Dimension(400, 400)); this.setDismissDelay(Integer.MAX_VALUE); this.setInitialDelay(0); }
From source file:no.met.jtimeseries.marinogram.MarinogramPressurePlot.java
private XYPlot createPlot(TimeZone timezone, boolean plotPressure) { ChartPlotter plotter = null;/*from w w w . j a v a 2 s . co m*/ if (plotPressure) { plotter = new ChartPlotter(); // default setting plotter.setHeight(this.getHeight()); plotter.setWidth(this.getWidth()); plotter.setPlotDefaultProperties("", ""); NumberPhenomenon pressure = getLocationForecastDataModel() .getPhenomenen(PhenomenonName.Pressure.toString(), NumberPhenomenon.class); List<Date> shortTermTime = pressure.getTime(); Color pressureColor = new Color(11, 164, 42); PlotStyle.Builder pressureStyleBuilder = new PlotStyle.Builder( messages.getString("parameter.pressure") + " (hPa)"); PlotStyle plotStyle = pressureStyleBuilder.spline(SplineStyle.HYBRID).ticks(4).difference(50.0d) .seriesColor(pressureColor).labelColor(pressureColor).build(); plotter.addLineChart(TimeBase.SECOND, pressure, plotStyle); //plotter.formalizeRangeAxisWithMargins(plotter.getRangeAxisIndex() - 1, 950, 1050); double tick = (pressure.getMaxValue() - pressure.getMinValue()) / 2; tick = Math.ceil(tick / 10) * 10; double lowBound = Math.floor(pressure.getMinValue() / (tick)) * (tick); lowBound = lowBound - tick / 2; double upperBound = lowBound + tick * 4; //replicate the range axis NumberAxis referenceAxis = (NumberAxis) plotter.getPlot().getRangeAxis(); referenceAxis.setTickUnit(new NumberTickUnit(tick)); referenceAxis.setLowerBound(lowBound); referenceAxis.setUpperBound(upperBound); NumberAxis numberAxis = new NumberAxis(); numberAxis.setLabelPaint(pressureColor); numberAxis.setTickLabelPaint(referenceAxis.getTickLabelPaint()); //numberAxis.setLowerMargin(ChartPlotter.LOWER_PLOT_MARGIN); numberAxis.setRange(referenceAxis.getLowerBound(), referenceAxis.getUpperBound()); numberAxis.setTickUnit(referenceAxis.getTickUnit()); //numberAxis.setRangeWithMargins(950, 1050); plotter.getPlot().setRangeAxis(1, numberAxis); //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() >= 48 ? 48 : shortTermTime.size() - 1); plotter.setDomainRange(minDate, maxDate); plotter.setDomainDateFormat(timezone, "HH"); plotter.getPlot().setOutlineVisible(true); //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); } 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 w w . j av a 2s . c om 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(); }