List of usage examples for org.jfree.chart.axis NumberAxis isVisible
public boolean isVisible()
true
if the axis is visible, and false
otherwise. From source file:ucar.unidata.idv.control.chart.VerticalProfileChart.java
/** * Add a series to the charts/*from w w w. ja v a2s. co m*/ * * * @param series series * @param lineState line state * @param paramIdx param index * @param renderer renderer * @param rangeVisible range visible * * @return the Axis */ protected Axis addSeries(XYSeries series, LineState lineState, int paramIdx, XYItemRenderer renderer, boolean rangeVisible) { if (lineState.getRange() != null) { addRange(lineState.getRange().getMin(), lineState.getRange().getMax(), "Fixed range from: " + lineState.getName()); } if (numberFormat == null) { numberFormat = new DecimalFormat() { public StringBuffer format(double number, StringBuffer result, FieldPosition fieldPosition) { String s = control.getDisplayConventions().format(number); result.append(s); return result; } }; } String name = lineState.getName(); Unit unit = lineState.unit; XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); NumberAxis rangeAxis; NumberAxis domainAxis = null; String axisLabel = name + ((unit != null) ? " [" + unit + "]" : ""); if (lineState.getUseLogarithmicRange() && false) { rangeAxis = new FixedWidthLogarithmicAxis(axisLabel); } else { //rangeAxis = new FixedWidthNumberAxis(axisLabel); rangeAxis = new NumberAxis(axisLabel); ((NumberAxis) rangeAxis).setAutoRangeIncludesZero(lineState.getRangeIncludesZero()); VerticalProfileInfo vpInfo = (VerticalProfileInfo) profiles.get(0); Unit altUnit = vpInfo.getAltitudeUnit(); if (altUnit != null && paramIdx == 0 && !(altUnit.equals(CommonUnit.meter))) { String dlabel = "Altitude " + "[" + altUnit + "]"; domainAxis = new NumberAxis(dlabel); if (altUnit.isConvertible(CommonUnits.HECTOPASCAL)) domainAxis.setInverted(true); } } //For now lets use the default number formatting for the range // rangeAxis.setNumberFormatOverride(numberFormat); rangeAxis.setVisible(rangeVisible); ucar.unidata.util.Range r = lineState.getRange(); if (r != null) { rangeAxis.setRange(new org.jfree.data.Range(r.getMin(), r.getMax())); } if (renderer == null) { renderer = getRenderer(lineState); } Paint c = lineState.getColor(paramIdx); rangeAxis.setLabelPaint(Color.black); renderer.setSeriesPaint(0, c); renderer.setSeriesStroke(0, lineState.getStroke()); if (!lineState.getAxisVisible()) { rangeAxis.setVisible(false); } AxisLocation side = null; ChartHolder chartHolder = getChartHolder(lineState); if (rangeAxis.isVisible()) { if (lineState.getSide() == LineState.SIDE_UNDEFINED) { side = AxisLocation.BOTTOM_OR_RIGHT; } else if (lineState.getSide() == LineState.SIDE_LEFT) { side = AxisLocation.TOP_OR_LEFT; } else { side = AxisLocation.BOTTOM_OR_RIGHT; } chartHolder.lastSide = side; } synchronized (MUTEX) { if (domainAxis == null) { if (isConservedSounding) chartHolder.add(dataset, renderer, side); else chartHolder.add(dataset, rangeAxis, renderer, side); } else chartHolder.add(dataset, rangeAxis, domainAxis, renderer, side); } return rangeAxis; }
From source file:ucar.unidata.idv.control.chart.TimeSeriesChart.java
/** * Add the series//from ww w .ja va2s. com * * * @param series The data * @param lineState describes how to draw the line * @param paramIdx which parameter * @param renderer renderer * @param rangeVisible do we show range axis * @param addAxis include the axis * * @return the newly created range axis */ protected Axis addSeries(TimeSeries series, LineState lineState, int paramIdx, XYItemRenderer renderer, boolean rangeVisible, boolean addAxis) { if (series instanceof MyTimeSeries) { ((MyTimeSeries) series).finish(); } if (addAxis && (lineState.getRange() != null)) { addRange(lineState.getRange().getMin(), lineState.getRange().getMax(), "Fixed range from: " + lineState.getName()); } if (numberFormat == null) { numberFormat = new DecimalFormat() { public StringBuffer format(double number, StringBuffer result, FieldPosition fieldPosition) { String s = control.getDisplayConventions().format(number); result.append(s); return result; } }; } String name = lineState.getName(); Unit unit = lineState.unit; TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.setDomainIsPointsInTime(true); dataset.addSeries(series); String axisLabel = lineState.getAxisLabel(); if (axisLabel == null) { axisLabel = name + ((unit != null) ? " [" + unit + "]" : ""); } NumberAxis rangeAxis; if (lineState.getUseLogarithmicRange() && false) { rangeAxis = new FixedWidthLogarithmicAxis(axisLabel); } else { rangeAxis = new FixedWidthNumberAxis(axisLabel); ((NumberAxis) rangeAxis).setAutoRangeIncludesZero(lineState.getRangeIncludesZero()); } //For now lets use the default number formatting for the range // rangeAxis.setNumberFormatOverride(numberFormat); rangeAxis.setVisible(rangeVisible); ucar.unidata.util.Range r = lineState.getRange(); if (r != null) { rangeAxis.setRange(new org.jfree.data.Range(r.getMin(), r.getMax())); } if (renderer == null) { renderer = getRenderer(lineState, addAxis); } Paint c = lineState.getColor(paramIdx); rangeAxis.setLabelPaint(Color.black); renderer.setSeriesPaint(0, c); renderer.setSeriesStroke(0, lineState.getStroke()); renderer.setSeriesVisibleInLegend(0, lineState.getVisibleInLegend()); if (!lineState.getAxisVisible()) { rangeAxis.setVisible(false); } else { rangeAxis.setVisible(addAxis); } ChartHolder chartHolder = getChartHolder(lineState); AxisLocation side = null; if (rangeAxis.isVisible()) { if (lineState.getSide() == LineState.SIDE_UNDEFINED) { if (chartHolder.lastSide == AxisLocation.TOP_OR_LEFT) { side = AxisLocation.BOTTOM_OR_RIGHT; } else { side = AxisLocation.TOP_OR_LEFT; } } else if (lineState.getSide() == LineState.SIDE_LEFT) { side = AxisLocation.TOP_OR_LEFT; } else { side = AxisLocation.BOTTOM_OR_RIGHT; } chartHolder.lastSide = side; } synchronized (MUTEX) { chartHolder.add(dataset, rangeAxis, renderer, side); } return rangeAxis; }