List of usage examples for org.jfree.chart.axis NumberAxis setVisible
public void setVisible(boolean flag)
From source file:com.att.aro.diagnostics.GraphPanel.java
/** * Returns a XYPlot for Radio info//from w w w. ja v a2 s. c om * * @return XYPlot. */ private static XYPlot createRadioPlot() { // Set up renderer StandardXYItemRenderer radioRenderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES); radioRenderer.setAutoPopulateSeriesShape(false); radioRenderer.setBaseShape(DEFAULT_POINT_SHAPE); radioRenderer.setSeriesPaint(0, Color.red); // Normalize the throughput axis so that it represents max value NumberAxis axis = new NumberAxis(); axis.setVisible(false); axis.setAutoRange(false); axis.setRange(MIN_SIGNAL, MAX_SIGNAL); // Create plot XYPlot radioPlot = new XYPlot(null, null, axis, radioRenderer); radioPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); radioPlot.getRangeAxis().setVisible(false); return radioPlot; }
From source file:com.att.aro.diagnostics.GraphPanel.java
/** * Returns a XYPlot for Battery Info//from w ww .ja va 2 s.com * * @return XYPlot. */ private static XYPlot createBatteryPlot() { // Set up renderer StandardXYItemRenderer batteryRenderer = new StandardXYItemRenderer( StandardXYItemRenderer.SHAPES_AND_LINES); batteryRenderer.setAutoPopulateSeriesShape(false); batteryRenderer.setBaseShape(DEFAULT_POINT_SHAPE); batteryRenderer.setSeriesPaint(0, Color.red); // Normalize the throughput axis so that it represents max value NumberAxis axis = new NumberAxis(); axis.setVisible(false); axis.setAutoRange(false); axis.setRange(0, 110); // Create plot XYPlot batteryPlot = new XYPlot(null, null, axis, batteryRenderer); batteryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); batteryPlot.getRangeAxis().setVisible(false); return batteryPlot; }
From source file:com.att.aro.diagnostics.GraphPanel.java
/** * Returns a XYPlot for Alarm triggering info * * @return XYPlot./*from w ww . j a va 2s.c o m*/ */ private static XYPlot createAlarmPlot() { // Create renderer XYBarRenderer alarmRenderer = new XYBarRenderer(); alarmRenderer.setDrawBarOutline(false); alarmRenderer.setUseYInterval(true); alarmRenderer.setBasePaint(Color.gray); alarmRenderer.setAutoPopulateSeriesPaint(false); alarmRenderer.setShadowVisible(false); alarmRenderer.setGradientPaintTransformer(null); alarmRenderer.setBarPainter(new StandardXYBarPainter()); // Normalize the throughput axis so that it represents max value NumberAxis axis = new NumberAxis(); axis.setVisible(false); axis.setAutoRange(false); axis.setRange(0, 1); // Create result plot XYPlot alarmPlot = new XYPlot(null, null, axis, alarmRenderer); alarmPlot.getRangeAxis().setVisible(false); return alarmPlot; }
From source file:ucar.unidata.idv.control.chart.TimeSeriesChart.java
/** * Add the series//w ww. j av a 2 s . co m * * * @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; }
From source file:org.jax.haplotype.analysis.visualization.GenomicGraphFactory.java
/** * Create a SNP block graph for the given parameters. This graph * will show where the intervals do and don't exist. Interval lists * are organized with the X axis label matching the list's key * @param snpIntervals//from w w w .ja va 2s . c o m * the blocks * @param startInBasePairs * the x location to start the graph at * @param extentInBasePairs * the extent to use for the graph * @param maximumImageBlockCount * the max # of separate image blocks to use * @param renderAxes * if true render the axes... otherwise dont * @param legendText * the text to use for the legend * @param yAxisText * the text to use for the y axis * @param trueColor * the color to use for true * @param falseColor * the color to use for false * @return * the graph */ public JFreeChart createSnpIntervalGraph( final Map<String, ? extends List<? extends BasePairInterval>> snpIntervals, final long startInBasePairs, final long extentInBasePairs, final int maximumImageBlockCount, final boolean renderAxes, final String legendText, final String yAxisText, final Color trueColor, final Color falseColor) { XYDataset dataset = snpIntervalsToDataset(snpIntervals, startInBasePairs, extentInBasePairs, maximumImageBlockCount); NumberAxis xAxis = new NumberAxis("SNP Position (Base Pairs)"); xAxis.setAutoRangeIncludesZero(false); xAxis.setRange(new Range(startInBasePairs, startInBasePairs + extentInBasePairs)); String[] sortedStrainNames = extractSortedStrainNames(snpIntervals); for (int strainIndex = 0; strainIndex < sortedStrainNames.length; strainIndex++) { LOG.info("Strain Name: " + sortedStrainNames[strainIndex]); } SymbolAxis yAxis = new SymbolAxis(yAxisText == null ? "" : yAxisText, sortedStrainNames); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); LegendItemCollection items = new LegendItemCollection(); if (legendText != null) { items.add(new LegendItem(legendText, null, null, null, new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0), trueColor, new BasicStroke(), Color.BLACK)); } plot.setFixedLegendItems(items); XYBlockRenderer r = new XYBlockRenderer(); SmoothPaintScale ps = new SmoothPaintScale(0.0, 1.0, falseColor, trueColor); r.setPaintScale(ps); r.setBlockHeight(1.0); r.setBlockWidth(1.0); plot.setRenderer(r); final JFreeChart chart; if (renderAxes) { chart = new JFreeChart("Identical By State Blocks", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } else { xAxis.setVisible(false); yAxis.setVisible(false); plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); chart = new JFreeChart(plot); } chart.setBackgroundPaint(Color.WHITE); return chart; }
From source file:org.ramadda.data.services.PointFormHandler.java
/** * _more_//ww w . jav a 2 s .c o m * * @param request _more_ * @param pointEntry _more_ * @param plotInfo _more_ * * @return _more_ * * @throws Exception _more_ */ public BufferedImage makeTimeseriesImage(Request request, PointEntry pointEntry, final PlotInfo plotInfo) throws Exception { Entry entry = pointEntry.getEntry(); int width = TIMESERIES_WIDTH; int height = TIMESERIES_HEIGHT; long numRecords = pointEntry.getNumRecords(); final int numPointsToPlot = request.get(ARG_NUMPOINTS, TIMESERIES_POINTS); final int[] cnt = { 0 }; final List<TimeSeries> series = new ArrayList<TimeSeries>(); final List<RecordField> tmpFields = pointEntry.getRecordFile().getChartableFields(); final List<RecordField> fields = new ArrayList<RecordField>(); if (request.get(ARG_CHART_SHOW + FIELD_ALTITUDE, false)) { fields.add(new RecordField(FIELD_ALTITUDE, LABEL_ALTITUDE, "", -1, UNIT_M)); } for (RecordField attr : tmpFields) { if (request.get(ARG_CHART_SHOW + attr.getName(), false)) { fields.add(attr); } } if ((fields.size() == 0) && (tmpFields.size() > 0)) { fields.add(tmpFields.get(0)); request.put(ARG_CHART_SHOW + tmpFields.get(0).getName(), "true"); } for (RecordField attr : fields) { series.add(new TimeSeries(attr.getLabel())); } RecordVisitor visitor = new BridgeRecordVisitor(getOutputHandler()) { public boolean doVisitRecord(RecordFile file, VisitInfo visitInfo, Record record) { PointRecord pointRecord = (PointRecord) record; for (int fieldCnt = 0; fieldCnt < fields.size(); fieldCnt++) { RecordField field = fields.get(fieldCnt); double value; //Check for altitude if (field.getParamId() < 0) { value = pointRecord.getAltitude(); } else { value = record.getValue(field.getParamId()); } long time = record.getRecordTime(); series.get(fieldCnt).add(new FixedMillisecond(time), value); } plotInfo.setIndex(pointRecord.index); cnt[0]++; return true; } }; long t1 = System.currentTimeMillis(); int skip = (int) (numRecords / numPointsToPlot); getRecordJobManager().visitSequential(request, pointEntry, visitor, new VisitInfo(skip)); long t2 = System.currentTimeMillis(); JFreeChart chart = createTimeseriesChart(request, entry, new TimeSeriesCollection(), null); long t3 = System.currentTimeMillis(); XYPlot plot = (XYPlot) chart.getPlot(); int lineCnt = 0; int[] colorCnt = { 0 }; int numberOfAxisLegends = 0; Hashtable<String, double[]> valueRanges = new Hashtable<String, double[]>(); for (int extraCnt = 0; extraCnt < series.size(); extraCnt++) { TimeSeries timeSeries = series.get(extraCnt); RecordField field = fields.get(extraCnt); String unit = field.getUnit(); if ((unit != null) && (unit.length() == 0)) { unit = null; } if (unit == null) { unit = extraCnt + ""; } if (unit == null) { continue; } double max = timeSeries.getMaxY(); double min = timeSeries.getMinY(); double[] range = valueRanges.get(unit); if (range == null) { range = new double[] { min, max }; valueRanges.put(unit, range); } else { range[0] = Math.min(range[0], min); range[1] = Math.max(range[1], max); } } Hashtable<String, NumberAxis> seenAxis = new Hashtable<String, NumberAxis>(); for (int extraCnt = 0; extraCnt < series.size(); extraCnt++) { TimeSeries timeSeries = series.get(extraCnt); RecordField field = fields.get(extraCnt); String unit = field.getUnit(); if ((unit != null) && (unit.length() == 0)) { unit = null; } TimeSeriesCollection dataset2 = new TimeSeriesCollection(); dataset2.addSeries(timeSeries); NumberAxis axis = new NumberAxis(field.getLabel()); numberOfAxisLegends++; if (unit != null) { double[] range = valueRanges.get(unit); axis.setRange(range[0], range[1]); NumberAxis seenOne = seenAxis.get(unit); if (seenOne == null) { seenAxis.put(unit, axis); } else { seenOne.setLabel(seenOne.getLabel() + "/" + field.getLabel()); axis.setVisible(false); numberOfAxisLegends--; } } else { axis.setAutoRange(true); axis.setAutoRangeIncludesZero(true); } plot.setRangeAxis(lineCnt, axis); plot.setDataset(lineCnt, dataset2); plot.mapDatasetToRangeAxis(lineCnt, lineCnt); plot.setRangeAxisLocation(lineCnt, AxisLocation.BOTTOM_OR_RIGHT); StandardXYItemRenderer renderer = new MyStandardXYItemRenderer(plotInfo); renderer.setSeriesPaint(0, getColor(request, ARG_CHART_COLOR + field.getName(), colorCnt)); plot.setRenderer(lineCnt, renderer); lineCnt++; } AxisSpace axisSpace = new AxisSpace(); axisSpace.setRight(TIMESERIES_AXIS_WIDTHPER * numberOfAxisLegends); plot.setFixedRangeAxisSpace(axisSpace); long t4 = System.currentTimeMillis(); BufferedImage newImage = chart.createBufferedImage(width + (numberOfAxisLegends * TIMESERIES_AXIS_WIDTHPER), height); long t5 = System.currentTimeMillis(); // System.err.println("Time series cnt:" + cnt[0] + " " + (t2 - t1) + " " + (t3 - t2) + " " + (t4 - t3) + " " + (t5 - t4)); return newImage; }
From source file:com.appnativa.rare.ui.chart.jfreechart.ChartHandler.java
private void customizeAxis(ChartDefinition cd, ChartAxis ai, NumberAxis axis) { customizeAxisEx(cd, ai, axis);/* www . j ava 2 s . c o m*/ ChartInfo ci = (ChartInfo) cd.getChartHandlerInfo(); double[] bounds = null; if (cd.getSeriesCount() > 0) { if (ai.isRangeAxis()) { bounds = ci.yAxisValues; } else { bounds = ci.xAxisValues; } } if (bounds != null) { axis.setLowerBound(bounds[0]); axis.setUpperBound(bounds[1]); axis.setTickUnit(new NumberTickUnit(bounds[2])); } else { RenderableDataItem u = ai.getUpperBounds(); RenderableDataItem l = ai.getLowerBounds(); double inc = ai.getIncrement(); if (u != null) { axis.setUpperBound(u.doubleValue()); } if (l != null) { axis.setLowerBound(l.doubleValue()); } if (inc > 0) { axis.setTickUnit(new NumberTickUnit(inc)); } } axis.setVisible(ai.isVisible()); }