List of usage examples for org.jfree.chart.axis NumberAxis setVisible
public void setVisible(boolean flag)
From source file:org.openfaces.component.chart.impl.plots.GridCategoryPlotAdapter.java
public GridCategoryPlotAdapter(CategoryDataset ds, AbstractCategoryItemRenderer renderer, GridChartView chartView) {/* ww w.ja va 2s . co m*/ setDataset(ds); setRenderer(renderer); ChartAxis baseAxis = chartView.getBaseAxis(); ChartAxis keyAxis = chartView.getKeyAxis(); ChartAxis valueAxis = chartView.getValueAxis(); ChartDomain showAxes = chartView.getShowAxes(); if (showAxes == null) { showAxes = ChartDomain.BOTH; chartView.setShowAxes(showAxes); } boolean keyAxisVisible = showAxes.equals(ChartDomain.BOTH) || showAxes.equals(ChartDomain.KEY); boolean valueAxisVisible = showAxes.equals(ChartDomain.BOTH) || showAxes.equals(ChartDomain.VALUE); if (!(keyAxis instanceof ChartCategoryAxis)) keyAxis = null; if (!(valueAxis instanceof ChartNumberAxis)) valueAxis = null; CategoryAxis categoryAxis = chartView.isEnable3D() ? new CategoryAxis3DAdapter(chartView.getKeyAxisLabel(), keyAxisVisible, (ChartCategoryAxis) keyAxis, baseAxis, chartView) : new CategoryAxisAdapter(chartView.getKeyAxisLabel(), keyAxisVisible, (ChartCategoryAxis) keyAxis, baseAxis, chartView); NumberAxis numberAxis = chartView.isEnable3D() ? new NumberAxis3DAdapter(chartView.getValueAxisLabel(), valueAxisVisible, (ChartNumberAxis) valueAxis, baseAxis, chartView) : new NumberAxisAdapter(chartView.getValueAxisLabel(), valueAxisVisible, (ChartNumberAxis) valueAxis, baseAxis, chartView); if (ds == null) { categoryAxis.setVisible(false); numberAxis.setVisible(false); } setDomainAxis(categoryAxis); setRangeAxis(numberAxis); setOrientation(PropertiesConverter.toPlotOrientation(chartView.getOrientation())); addConfigurator(new PlotColorsConfigurator()); addConfigurator(new PlotGridLinesConfigurator(ds)); addConfigurator(new PlotSelectionConfigurator()); configure(chartView); }
From source file:org.jax.haplotype.analysis.visualization.GenomicGraphFactory.java
/** * Create a snp interval histogram without any axes * @param intervals//from w w w. j a va 2 s . c om * the intervals to use * @param startInBasePairs * where should we start the graph? * @param extentInBasePairs * how far should the graph extend * @param visualInterval * the visual interval to use * @return * the histogram */ public JFreeChart createSnpIntervalHistogram(final List<? extends RealValuedBasePairInterval> intervals, final long startInBasePairs, final long extentInBasePairs, final HighlightedSnpInterval visualInterval) { // create the axes NumberAxis xAxis = new NumberAxis(); xAxis.setAutoRangeIncludesZero(false); xAxis.setRange(new Range(startInBasePairs, startInBasePairs + extentInBasePairs)); NumberAxis yAxis = new NumberAxis(); // hide the axes xAxis.setVisible(false); yAxis.setVisible(false); // create the plot XYPlot plot = this.createSnpIntervalHistogramPlot(intervals, visualInterval, xAxis, yAxis); // more hiding plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); // create the final chart JFreeChart histogram = new JFreeChart(plot); histogram.removeLegend(); return histogram; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.targetcharts.SparkLine.java
@Override public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); XYDataset dataset = (XYDataset) datasets.getDatasets().get("1"); final JFreeChart sparkLineGraph = ChartFactory.createTimeSeriesChart(null, null, null, dataset, legend, false, false);// w w w .ja v a2 s.co m sparkLineGraph.setBackgroundPaint(color); TextTitle title = setStyleTitle(name, styleTitle); sparkLineGraph.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); sparkLineGraph.addSubtitle(subTitle); } sparkLineGraph.setBorderVisible(false); sparkLineGraph.setBorderPaint(Color.BLACK); XYPlot plot = sparkLineGraph.getXYPlot(); plot.setOutlineVisible(false); plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setBackgroundPaint(null); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairVisible(false); plot.setRangeGridlinesVisible(false); plot.setRangeCrosshairVisible(false); plot.setBackgroundPaint(color); // calculate the last marker color Paint colorLast = getLastPointColor(); // Calculate average, minimum and maximum to draw plot borders. boolean isFirst = true; double avg = 0, min = Double.POSITIVE_INFINITY, max = Double.NEGATIVE_INFINITY; int count = 0; for (int i = 0; i < timeSeries.getItemCount(); i++) { if (timeSeries.getValue(i) != null) { count++; if (isFirst) { min = timeSeries.getValue(i).doubleValue(); max = timeSeries.getValue(i).doubleValue(); isFirst = false; } double n = timeSeries.getValue(i).doubleValue(); //calculate avg, min, max avg += n; if (n < min) min = n; if (n > max) max = n; } } // average avg = avg / (double) count; // calculate min and max between thresholds! boolean isFirst2 = true; double lb = 0, ub = 0; for (Iterator iterator = thresholds.keySet().iterator(); iterator.hasNext();) { Double thres = (Double) iterator.next(); if (isFirst2 == true) { ub = thres.doubleValue(); lb = thres.doubleValue(); isFirst2 = false; } if (thres.doubleValue() > ub) ub = thres.doubleValue(); if (thres.doubleValue() < lb) lb = thres.doubleValue(); } plot.getRangeAxis().setRange(new Range(Math.min(lb, min - 2), Math.max(ub, max + 2) + 2)); addMarker(1, avg, Color.GRAY, 0.8f, plot); //addAvaregeSeries(series, plot); addPointSeries(timeSeries, plot); int num = 3; for (Iterator iterator = thresholds.keySet().iterator(); iterator.hasNext();) { Double thres = (Double) iterator.next(); TargetThreshold targThres = thresholds.get(thres); Color color = Color.WHITE; if (targThres != null && targThres.getColor() != null) { color = targThres.getColor(); } if (targThres.isVisible()) { addMarker(num++, thres.doubleValue(), color, 0.5f, plot); } } ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setVisible(false); domainAxis.setUpperMargin(0.2); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setVisible(false); plot.getRenderer().setSeriesPaint(0, Color.BLACK); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false) { public boolean getItemShapeVisible(int _series, int item) { TimeSeriesDataItem tsdi = timeSeries.getDataItem(item); if (tsdi == null) return false; Month period = (Month) tsdi.getPeriod(); int currMonth = period.getMonth(); int currYear = period.getYearValue(); int lastMonthFilled = lastMonth.getMonth(); int lastYearFilled = lastMonth.getYearValue(); boolean isLast = false; if (currYear == lastYearFilled && currMonth == lastMonthFilled) { isLast = true; } return isLast; } }; renderer.setSeriesPaint(0, Color.decode("0x000000")); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(colorLast); renderer.setBaseOutlinePaint(Color.BLACK); renderer.setUseOutlinePaint(true); renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0)); if (wlt_mode.doubleValue() == 0) { renderer.setBaseItemLabelsVisible(Boolean.FALSE, true); } else { renderer.setBaseItemLabelsVisible(Boolean.TRUE, true); renderer.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); renderer.setBaseItemLabelPaint(styleValueLabels.getColor()); renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator("{2}", new DecimalFormat("0.###"), new DecimalFormat("0.###")) { public String generateLabel(CategoryDataset dataset, int row, int column) { if (dataset.getValue(row, column) == null || dataset.getValue(row, column).doubleValue() == 0) return ""; String columnKey = (String) dataset.getColumnKey(column); int separator = columnKey.indexOf('-'); String month = columnKey.substring(0, separator); String year = columnKey.substring(separator + 1); int monthNum = Integer.parseInt(month); if (wlt_mode.doubleValue() >= 1 && wlt_mode.doubleValue() <= 4) { if (wlt_mode.doubleValue() == 2 && column % 2 == 0) return ""; Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, monthNum - 1); SimpleDateFormat dataFormat = new SimpleDateFormat("MMM"); return dataFormat.format(calendar.getTime()); } else return "" + monthNum; } }); } if (wlt_mode.doubleValue() == 3) { renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, org.jfree.ui.TextAnchor.BOTTOM_CENTER, org.jfree.ui.TextAnchor.BOTTOM_RIGHT, Math.PI / 2)); renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, org.jfree.ui.TextAnchor.TOP_CENTER, org.jfree.ui.TextAnchor.HALF_ASCENT_LEFT, Math.PI / 2)); } else if (wlt_mode.doubleValue() == 4) { renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, org.jfree.ui.TextAnchor.BOTTOM_CENTER, org.jfree.ui.TextAnchor.BOTTOM_RIGHT, Math.PI / 4)); renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, org.jfree.ui.TextAnchor.TOP_CENTER, org.jfree.ui.TextAnchor.HALF_ASCENT_LEFT, Math.PI / 4)); } if (legend == true) { LegendItemCollection collection = createThresholdLegend(plot); LegendItem item = new LegendItem("Avg", "Avg", "Avg", "Avg", new Rectangle(10, 10), colorAverage); collection.add(item); plot.setFixedLegendItems(collection); } plot.setRenderer(0, renderer); logger.debug("OUT"); return sparkLineGraph; }
From source file:org.objectweb.proactive.extensions.timitspmd.util.charts.MatrixChart.java
private void buildLegendChart(int nbValues) { this.legendValues = new int[nbValues + 1]; this.legendValues[0] = 0; int offset = 255 / nbValues; int step = offset; if (this.scaleMode == Chart.Scale.LOGARITHMIC) { double logStep = (Math.log(this.maxValue) / Math.log(2)) / nbValues; for (int i = 1; i < (nbValues + 1); i++) { this.legendValues[i] = (int) Math.pow(2, logStep * i); }/*w w w . jav a 2 s. c o m*/ } else { // Linear scale mode for (int i = 1; i < (nbValues + 1); i++) { this.legendValues[i] = (step * this.maxValue) / 255; step += offset; } } final MatrixSeriesCollection dataset = new MatrixSeriesCollection(this.createLegendDataSet()); final JFreeChart chart = ChartFactory.createBubbleChart("", "", "", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.WHITE)); chart.removeLegend(); // Perform customizations starts here ... final XYPlot plot1 = chart.getXYPlot(); plot1.setDomainGridlinesVisible(false); plot1.setRangeGridlinesVisible(false); plot1.setForegroundAlpha(0.5f); plot1.setDomainAxis(new CustomAxis(plot1.getDomainAxis().getLabel())); plot1.setRangeAxis(new CustomAxis(plot1.getRangeAxis().getLabel())); // Custumize the domain axis ( x ) final NumberAxis domainAxis = (NumberAxis) plot1.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setRange(-1, 1); domainAxis.setVisible(false); // Custumize the range axis ( y ) final NumberAxis rangeAxis = (NumberAxis) plot1.getRangeAxis(); rangeAxis.setTickUnit(new CustomTickUnit(rangeAxis.getTickUnit().getSize())); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setRange(-1, this.legendValues.length); rangeAxis.setTickLabelsVisible(true); rangeAxis.setTickMarkInsideLength(4); // Create custom renderer StandardXYItemRenderer ren = new CustomRenderer(true); ren.setSeriesItemLabelPaint(0, Color.BLUE); plot1.setRenderer(ren); plot1.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT); this.legendChart = chart; }
From source file:ecg.ecgshow.ECGShowUI.java
private void createECGData(long timeZone) { ECGData = new JPanel(new GridLayout(LEAD_COUNT, 1)); dateAxises = new DateAxis[LEAD_COUNT]; ECGSeries = new TimeSeries[LEAD_COUNT * 2]; for (int i = 0; i < LEAD_COUNT; i++) { TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); //XYDataset TimeSeriesCollection ECGSeries[i] = new TimeSeries("?" + (i + 1)); ECGSeries[i].setMaximumItemCount(500); ECGSeries[i + LEAD_COUNT] = new TimeSeries(""); ECGSeries[i + LEAD_COUNT].setMaximumItemAge(timeZone); ECGSeries[i + LEAD_COUNT].setMaximumItemCount(2); timeseriescollection.addSeries(ECGSeries[i]); timeseriescollection.addSeries(ECGSeries[i + LEAD_COUNT]); //DateAxis dateaxis = new DateAxis("Time"); dateAxises[i] = new DateAxis(""); dateAxises[i].setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016))); dateAxises[i].setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018))); dateAxises[i].setTickLabelsVisible(true); dateAxises[i].setVisible(false); //NumberAxis numberaxis = new NumberAxis("ecg"); NumberAxis numberaxis = new NumberAxis("ecg"); numberaxis.setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016))); numberaxis.setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018))); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setVisible(false); numberaxis.setLowerBound(1500D); numberaxis.setUpperBound(3000D); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false); xylineandshaperenderer.setSeriesPaint(0, Color.GREEN); // xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2)); xylineandshaperenderer.setSeriesPaint(1, Color.LIGHT_GRAY); // xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(5)); XYPlot xyplot = new XYPlot(timeseriescollection, dateAxises[i], numberaxis, xylineandshaperenderer); xyplot.setBackgroundPaint(Color.LIGHT_GRAY); xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY); xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setBackgroundPaint(Color.BLACK); JFreeChart jfreechart = new JFreeChart(xyplot); jfreechart.setBackgroundPaint(new Color(237, 237, 237));//? jfreechart.getLegend().setVisible(false); ChartPanel chartpanel = new ChartPanel(jfreechart, (int) (WIDTH * 46 / 100), (int) (HEIGHT * 17 / 100), 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false); chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0) //??0 , BorderFactory.createEmptyBorder() //???? ));/*from w w w .j a v a2 s . com*/ chartpanel.setMouseZoomable(false); //? ECGData.add(chartpanel); } }
From source file:ecg.ecgshow.ECGShowUI.java
private void createPressureData(long timeZone) { PressureData = new JPanel(); PressuredateAxises = new DateAxis[1]; SystolicPressureSeries = new TimeSeries[2]; DiastolicPressureSeries = new TimeSeries[2]; TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); SystolicPressureSeries[0] = new TimeSeries(""); SystolicPressureSeries[0].setMaximumItemAge(timeZone); SystolicPressureSeries[0].setMaximumItemCount(500); SystolicPressureSeries[1] = new TimeSeries(""); SystolicPressureSeries[1].setMaximumItemAge(timeZone); SystolicPressureSeries[1].setMaximumItemCount(2); timeseriescollection.addSeries(SystolicPressureSeries[0]); timeseriescollection.addSeries(SystolicPressureSeries[1]); PressuredateAxises[0] = new DateAxis(""); PressuredateAxises[0].setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016))); PressuredateAxises[0].setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018))); PressuredateAxises[0].setTickLabelsVisible(true); PressuredateAxises[0].setVisible(false); DiastolicPressureSeries[0] = new TimeSeries(""); DiastolicPressureSeries[0].setMaximumItemAge(timeZone); DiastolicPressureSeries[0].setMaximumItemCount(500); DiastolicPressureSeries[1] = new TimeSeries(""); DiastolicPressureSeries[1].setMaximumItemAge(timeZone); DiastolicPressureSeries[1].setMaximumItemCount(2); timeseriescollection.addSeries(DiastolicPressureSeries[0]); timeseriescollection.addSeries(DiastolicPressureSeries[1]); NumberAxis numberaxis = new NumberAxis("Pressure"); numberaxis.setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016))); numberaxis.setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018))); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setVisible(false); numberaxis.setLowerBound(0D);/*from w w w . java2s .c om*/ numberaxis.setUpperBound(200D); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false); xylineandshaperenderer.setSeriesPaint(0, Color.GREEN); // xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2)); // xylineandshaperenderer.setSeriesPaint(1, Color.LIGHT_GRAY); // xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(5)); xylineandshaperenderer.setSeriesPaint(2, Color.ORANGE); // xylineandshaperenderer.setSeriesStroke(2, new BasicStroke(2)); // xylineandshaperenderer.setSeriesPaint(3, Color.LIGHT_GRAY); // xylineandshaperenderer.setSeriesStroke(3, new BasicStroke(5)); //XYPlot xyplot = new XYPlot(timeseriescollection, PressuredateAxises[0], numberaxis, xylineandshaperenderer); XYPlot xyplot = new XYPlot(timeseriescollection, dateAxises[0], numberaxis, xylineandshaperenderer); xyplot.setBackgroundPaint(Color.LIGHT_GRAY); xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY); xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setBackgroundPaint(Color.BLACK); JFreeChart jfreechart = new JFreeChart(xyplot); jfreechart.setBackgroundPaint(new Color(237, 237, 237));//? jfreechart.getLegend().setVisible(false); ChartPanel chartpanel = new ChartPanel(jfreechart, (int) (WIDTH * 0.155), (int) (HEIGHT * 0.18), 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false); chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0) //??0 , BorderFactory.createEmptyBorder() //???? )); chartpanel.setMouseZoomable(false); PressureData.add(chartpanel); }
From source file:pipeline.parameter_cell_views.FloatRangeSlider.java
@Override protected Component getRendererOrEditorComponent(JTable table0, @NonNull Object value, boolean isSelected, boolean hasFocus, int row, int column, boolean rendererCalled) { if (currentParameter != null) { currentParameter.removeListener(this); }// w w w . j av a 2 s . c o m currentParameter = (FloatRangeParameter) value; currentParameter.addGUIListener(this); table = table0; tableRow = row; evenTableRow = (row % 2 == 0); setOpaque(true); if (evenTableRow) { this.setBackground(Utils.COLOR_FOR_EVEN_ROWS); } else this.setBackground(Utils.COLOR_FOR_ODD_ROWS); textValueFrame.setBackground(getBackground()); silenceUpdate = true; readInValuesFromParameter(); if (currentParameter.histogram == null) ;// currentParameter.histogram=new XYSeries(""); if (currentParameter.histogram instanceof XYSeries) { XYSeries xyData = (XYSeries) currentParameter.histogram; if (chart != null && chart.getXYPlot().getDataset() != null) { chart.getXYPlot().getDataset(0).removeChangeListener(chart.getXYPlot()); } chart = ChartFactory.createXYLineChart(null, // chart title null, // "Category", // domain axis label null, // "Value", // range axis label new XYSeriesCollection(xyData), // data PlotOrientation.VERTICAL, false, // include legend true, false); } else if (currentParameter.histogram != null) { // assume for now it's a histogram if (chart != null && chart.getXYPlot().getDataset() != null) { chart.getXYPlot().getDataset(0).removeChangeListener(chart.getXYPlot()); } String plotTitle = "Histogram"; String xaxis = "number"; String yaxis = "value"; PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = false; boolean urls = false; chart = ChartFactory.createHistogram(plotTitle, xaxis, yaxis, (IntervalXYDataset) currentParameter.histogram, orientation, show, toolTips, urls);// dataset } else { if (chart != null && chart.getXYPlot().getDataset() != null) { chart.getXYPlot().getDataset(0).removeChangeListener(chart.getXYPlot()); } chart = null; } if (currentParameter.histogram != null) { add(panelForHistogram, cForHistogram); final XYPlot plot = chart.getXYPlot(); final NumberAxis domainAxis = new NumberAxis(null); domainAxis.setAutoRange(false); domainAxis.setTickLabelFont(new Font("Times", 0, 20)); domainAxis.setLowerBound(minimum); domainAxis.setUpperBound(maximum); plot.setDomainAxis(domainAxis); final NumberAxis rangeAxis = new NumberAxis(null); rangeAxis.setAutoRange(true); rangeAxis.setVisible(false); plot.setRangeAxis(rangeAxis); chart.setBackgroundPaint(Color.white); chart.setPadding(new RectangleInsets(0, 0, 0, 0)); plot.setBackgroundImage(null); plot.setBackgroundPaint(Color.white); plot.setOutlinePaint(Color.black); if (chartPanel == null) { chartPanel = new ChartPanel(chart); chartPanel.addMouseListener(this); chartPanel.addMouseMotionListener(this); chartPanel.setMouseWheelEnabled(true); chartPanel.setMouseZoomable(false); chartPanel.setRangeZoomable(false); panelForHistogram.add(chartPanel); } else chartPanel.setChart(chart); chartPanel.setSize(panelForHistogram.getSize()); ((XYPlot) chart.getPlot()).getRenderer().setSeriesStroke(0, new BasicStroke(5.0f)); selectionRange = new IntervalMarker(currentValue0, currentValue1); ((XYPlot) chart.getPlot()).addDomainMarker(selectionRange); } else { remove(panelForHistogram); setMaximumSize(new Dimension(700, 50)); setPreferredSize(new Dimension(700, 50)); } updateDisplays(); silenceUpdate = false; return this; }
From source file:no.met.jtimeseries.MeteogramWrapper.java
private void plotWindSpeedDirection(GenericDataModel model, ChartPlotter plotter, boolean showWindDirection, String unit, List<Date> symbolTimes) { // plot wind speed NumberPhenomenon windSpeed = model.getNumberPhenomenon(PhenomenonName.WindSpeedMPS.toString()).clone(); Color windSpeedColor = new Color(0, 0, 0); // number axis to be used for wind speed plot NumberAxis numberAxis = new NumberAxis(); numberAxis.setLabelPaint(windSpeedColor); numberAxis.setTickLabelPaint(windSpeedColor); if (unit.equalsIgnoreCase("ms")) { numberAxis.setLabel(messages.getString("parameter.wind") + " (m/s)"); } else {// w w w . j a v a 2s . co m windSpeed.scaling(1 / MarinogramPlot.KNOT); numberAxis.setLabel( messages.getString("parameter.wind") + " (" + messages.getString("label.knots") + ")"); NumberFormat formatter = new DecimalFormat("#0.0"); numberAxis.setNumberFormatOverride(formatter); } double maxValue = windSpeed.getMaxValue(); double minValue = windSpeed.getMinValue(); ChartPlotter.setAxisBound(numberAxis, maxValue, minValue, 8, BACKGROUND_LINES); PlotStyle plotStyle = new PlotStyle.Builder("Wind").seriesColor(windSpeedColor) .plusDegreeColor(windSpeedColor).spline(SplineStyle.HYBRID).stroke(new BasicStroke(2.0f)) .numberAxis(numberAxis).nonNegative(true).build(); plotter.addLineChart(TimeBase.SECOND, windSpeed, plotStyle); // plot wind direction if (showWindDirection) { NumberPhenomenon windDirection = model .getNumberPhenomenon(PhenomenonName.WindDirectionDegree.toString()).clone(); InListFromDateFilter symbolTimesFilter = new InListFromDateFilter(symbolTimes); windDirection.filter(symbolTimesFilter); windSpeed.filter(symbolTimesFilter); // when plot wind direction, the arrow should be rotated 180 degree windDirection = windDirection.transform(180); NumberAxis numberAxisDirection = null; try { numberAxisDirection = (NumberAxis) numberAxis.clone(); } catch (CloneNotSupportedException e) { } numberAxisDirection.setVisible(false); plotter.getPlot().setRangeAxis(plotter.getPlotIndex(), numberAxisDirection); plotter.addArrowDirectionPlot(windDirection, windSpeed, 0.08, plotStyle); // transform back after plot windDirection = windDirection.transform(180); } }
From source file:no.met.jtimeseries.chart.ChartPlotter.java
/** * Add wind arrows to the bottom of the diagram (like yr) *//*from w ww. j a v a2 s . com*/ public void addWindPlot(NumberPhenomenon direction, NumberPhenomenon speed, double yPosition) { NumberAxis na = new NumberAxis(""); na.setVisible(false); XYWindArrowRenderer windRenderer = new XYWindArrowRenderer(); windRenderer.setSeriesVisibleInLegend(0, false); WindDataset dataset = Utility.toChartWindDataset(direction, speed); windPlot = new XYPlot(dataset, plot.getDomainAxis(0), na, windRenderer); windPlot.setRangeGridlinesVisible(false); windPlot.setOutlineVisible(true); windPlot.setDomainGridlinesVisible(false); //addTimeValueSeparators(direction.getTime(), windPlot); }
From source file:no.met.jtimeseries.chart.ChartPlotter.java
/** * Add cloud to the top of the diagram (like yr) *///w w w. j av a2 s. c o m public void addCloudPlot(NumberPhenomenon fog, NumberPhenomenon highClouds, NumberPhenomenon mediumClouds, NumberPhenomenon lowClouds, double yPosition, int numDomainSteps) { NumberAxis na = new NumberAxis(""); na.setVisible(false); XYCloudSymbolRenderer cloudRenderer = new XYCloudSymbolRenderer(numDomainSteps); cloudRenderer.setSeriesVisibleInLegend(0, false); CloudDataset dataset = Utility.toChartCloudDataset(fog, highClouds, mediumClouds, lowClouds); cloudPlot = new XYPlot(dataset, plot.getDomainAxis(0), na, cloudRenderer); cloudPlot.setRangeGridlinesVisible(false); cloudPlot.setOutlineVisible(false); cloudPlot.setDomainGridlinesVisible(false); }