List of usage examples for org.jfree.chart.axis NumberAxis setVisible
public void setVisible(boolean flag)
From source file:no.met.jtimeseries.chart.ChartPlotter.java
/** * Hidden the series legend// ww w. jav a 2 s.c o m * * @param plotIndex * @param rangeAxisIndex */ public void hiddenSeriesLegend(int plotIndex, int rangeAxisIndex) { NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(rangeAxisIndex); numberAxis.setVisible(false); XYItemRenderer renderer = plot.getRenderer(plotIndex); renderer.setSeriesVisibleInLegend(0, false); }
From source file:no.met.jtimeseries.MeteogramWrapper.java
/** * Reset bound when both air temperature and dew point temperature are shown * @param model/* w ww. j av a 2 s . c o m*/ * @param plotter */ private void resetBoundForTemperature(GenericDataModel model, ChartPlotter plotter) { NumberPhenomenon temperature = model.getNumberPhenomenon(PhenomenonName.AirTemperature.toString()); NumberPhenomenon dewtemperature = model.getNumberPhenomenon(PhenomenonName.dewPointTemperature.toString()); double minValue = temperature.getMinValue() <= dewtemperature.getMinValue() ? temperature.getMinValue() : dewtemperature.getMinValue(); double maxValue = temperature.getMaxValue() >= dewtemperature.getMaxValue() ? temperature.getMaxValue() : dewtemperature.getMaxValue(); NumberAxis numberAxis1 = (NumberAxis) plotter.getPlot().getRangeAxis(plotter.getPlotIndex() - 2); numberAxis1.setLabel(messages.getString("parameter.temperature")); ChartPlotter.setAxisBound(numberAxis1, maxValue, minValue, 8, BACKGROUND_LINES); NumberAxis numberAxis2 = (NumberAxis) plotter.getPlot().getRangeAxis(plotter.getPlotIndex() - 1); numberAxis2.setLabel(messages.getString("parameter.temperature")); numberAxis2.setUpperBound(numberAxis1.getUpperBound()); numberAxis2.setLowerBound(numberAxis1.getLowerBound()); numberAxis2.setTickUnit(numberAxis1.getTickUnit()); numberAxis2.setVisible(false); //Add labels on the curves NumberValueItem airItem = (NumberValueItem) temperature.getItems().get(0); NumberValueItem dewpointItem = (NumberValueItem) dewtemperature.getItems().get(0); plotter.getPlot().getRenderer() .addAnnotation(ChartPlotter.createTextAnnotation(messages.getString("label.air"), temperature.getStartTime().getTime(), airItem.getValue() + 0.1d, TextAnchor.BOTTOM_LEFT, Color.RED), Layer.BACKGROUND); plotter.getPlot().getRenderer() .addAnnotation(ChartPlotter.createTextAnnotation(messages.getString("label.dewpoint"), dewtemperature.getStartTime().getTime(), dewpointItem.getValue() + 0.1d, TextAnchor.BOTTOM_LEFT, Color.ORANGE), Layer.BACKGROUND); }
From source file:no.met.jtimeseries.chart.ChartPlotter.java
/** * Adds the specified weather symbols to the chart. Symbols are excluded if * necessary to fit in the chart. Specify phenomenon to follow value curve. * Plot on top of chart if phenomenon is null. * //from w w w . j av a 2 s . co m * @return */ public void addWeatherSymbol(SymbolPhenomenon symbols, NumberPhenomenon phenomenon) { boolean followPhenomenon = (phenomenon != null); NumberAxis na; if (!followPhenomenon) { na = new NumberAxis(""); na.setVisible(false); weatherSymbolPlot = new XYPlot(); weatherSymbolPlot.setDomainAxis(plot.getDomainAxis(0)); weatherSymbolPlot.setRangeAxis(na); weatherSymbolPlot.setRangeGridlinesVisible(false); weatherSymbolPlot.setOutlineVisible(false); weatherSymbolPlot.setDomainGridlinesVisible(false); } XYImageAnnotation imageannotation; int imageSize = getWeatherSymbolImageSize(); for (SymbolValueItem symbol : symbols) { Image image = Symbols.getSymbolImage(symbol.getValue()); image = image.getScaledInstance(imageSize, imageSize, Image.SCALE_SMOOTH); if (followPhenomenon) { // plot over the phenomenon curve Double val = phenomenon.getValueByTime(symbol.getTimeFrom()); if (val != null) { double padding = 0.08; // space between curve and symbol in // phenomenon units imageannotation = new XYImageAnnotation(symbol.getTimeFrom().getTime(), val.doubleValue() + padding * (plot.getRangeAxis().getUpperBound() - plot.getRangeAxis().getLowerBound()), image, RectangleAnchor.CENTER); plot.addAnnotation(imageannotation); } } else { // plot symbols on top in separate weatherSymbolPlot imageannotation = new XYImageAnnotation(symbol.getTimeFrom().getTime(), 0.5, image); weatherSymbolPlot.addAnnotation(imageannotation); } } }
From source file:org.jivesoftware.openfire.reporting.graph.GraphEngine.java
/** * Generates a SparkLine Time Area Chart. * @param key//from w w w . jav a2 s . c om * @param stats * @param startTime * @param endTime * @return chart */ private JFreeChart generateSparklineAreaChart(String key, String color, Statistic[] stats, long startTime, long endTime, int dataPoints) { Color backgroundColor = getBackgroundColor(); XYDataset dataset = populateData(key, stats, startTime, endTime, dataPoints); JFreeChart chart = ChartFactory.createXYAreaChart(null, // chart title null, // xaxis label null, // yaxis label dataset, // data PlotOrientation.VERTICAL, false, // include legend false, // tooltips? false // URLs? ); chart.setBackgroundPaint(backgroundColor); chart.setBorderVisible(false); chart.setBorderPaint(null); XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(1.0f); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setBackgroundPaint(backgroundColor); plot.setRangeGridlinesVisible(false); GraphDefinition graphDef = GraphDefinition.getDefinition(color); Color plotColor = graphDef.getInlineColor(0); plot.getRenderer().setSeriesPaint(0, plotColor); plot.getRenderer().setBaseItemLabelsVisible(false); plot.getRenderer().setBaseOutlinePaint(backgroundColor); plot.setOutlineStroke(null); plot.setDomainGridlinePaint(null); NumberAxis xAxis = (NumberAxis) chart.getXYPlot().getDomainAxis(); xAxis.setLabel(null); xAxis.setTickLabelsVisible(true); xAxis.setTickMarksVisible(true); xAxis.setAxisLineVisible(false); xAxis.setNegativeArrowVisible(false); xAxis.setPositiveArrowVisible(false); xAxis.setVisible(false); NumberAxis yAxis = (NumberAxis) chart.getXYPlot().getRangeAxis(); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); yAxis.setAxisLineVisible(false); yAxis.setNegativeArrowVisible(false); yAxis.setPositiveArrowVisible(false); yAxis.setVisible(false); return chart; }
From source file:org.glotaran.core.datadisplayers.multispec.MultiSpecEditorTopComponent.java
private JFreeChart createChart(XYDataset dataset1) { JFreeChart chart_temp = ChartFactory.createScatterPlot(null, null, null, dataset1, PlotOrientation.VERTICAL, false, false, false);/* www.j a v a 2 s. co m*/ double range = Math.abs(data.getMaxInt() - data.getMinInt()); double dataMin, dataMax; if (range == 0.0) { dataMin = data.getMinInt() - 0.1; dataMax = data.getMaxInt() + 0.1; } else { dataMin = data.getMinInt(); dataMax = data.getMaxInt(); } PaintScale ps = new RainbowPaintScale(dataMin, dataMax); // PaintScale ps = new RedGreenPaintScale(dataMin, dataMax); BufferedImage image = ImageUtilities.createColorCodedImage(this.dataset, ps); XYDataImageAnnotation ann = new XYDataImageAnnotation(image, 0, 0, dataset.GetImageWidth(), dataset.GetImageHeigth(), true); XYPlot plot = (XYPlot) chart_temp.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); plot.getRenderer().addAnnotation(ann, Layer.BACKGROUND); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); xAxis.setVisible(false); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setLowerMargin(0.0); yAxis.setUpperMargin(0.0); yAxis.setVisible(false); return chart_temp; }
From source file:windows.sensorWindow.java
/** * creates all relevant data and adds it into the corresponding maps * //w w w .j av a 2s . com * @param UID * UID of the plotting sensor */ @SuppressWarnings("deprecation") public static void addPlot(Brick newBrick) { // create series TimeSeries newSeries = new TimeSeries("" + 0, Millisecond.class); TimeSeries newSeries2 = new TimeSeries("" + 0, Millisecond.class); TimeSeries newSeries3 = new TimeSeries("" + 0, Millisecond.class); TimeSeries newSeries4 = new TimeSeries("" + 0, Millisecond.class); TimeSeries newSeries5 = new TimeSeries("" + 0, Millisecond.class); TimeSeries newSeries6 = new TimeSeries("" + 0, Millisecond.class); Measurement m1 = new Measurement(maxValues, maxCycles, newBrick.uid, 0); valuesMap.put(newBrick.uid, m1); if (newBrick.checked3 == true) { Measurement m2 = new Measurement(maxValues, maxCycles, newBrick.uid, 1); values2Map.put(newBrick.uid, m2); } // create entry in state map plot1StateMap.put(newBrick.uid, 0); plot2StateMap.put(newBrick.uid, 0); // create index map entry tmplindex.put(newBrick.uid, 0); // create avrgCtrlEnabled maps if (newBrick.controlAverage == true) avrgCtrl1Enabled.put(newBrick.uid, true); else avrgCtrl1Enabled.put(newBrick.uid, false); if (newBrick.controlAverage2 == true) avrgCtrl2Enabled.put(newBrick.uid, true); else avrgCtrl2Enabled.put(newBrick.uid, false); // create series map entry seriesMap.put(newBrick.uid, newSeries); seriesMap2.put(newBrick.uid, newSeries2); seriesMap3.put(newBrick.uid, newSeries3); seriesMap4.put(newBrick.uid, newSeries4); seriesMap5.put(newBrick.uid, newSeries3); seriesMap6.put(newBrick.uid, newSeries4); // create collection map entry seriesCollectionMap.put(newBrick.uid, new TimeSeriesCollection(newSeries)); seriesCollectionMap2.put(newBrick.uid, new TimeSeriesCollection(newSeries2)); tmplCollection1_1.put(newBrick.uid, new TimeSeriesCollection(newSeries3)); tmplCollection1_2.put(newBrick.uid, new TimeSeriesCollection(newSeries4)); tmplCollection2_1.put(newBrick.uid, new TimeSeriesCollection(newSeries5)); tmplCollection2_2.put(newBrick.uid, new TimeSeriesCollection(newSeries6)); // create plot map entry, special case for current/voltage brick, since // it has 2 parallel measurements and therefore 2 graphs must be treated XYPlot tmpSubPlot; tmpSubPlot = new XYPlot(seriesCollectionMap.get(newBrick.uid), null, null, new StandardXYItemRenderer()); // create the 1st graph if (newBrick.checked2 == true) { // create plot map entry NumberAxis rangeAxis = new NumberAxis( String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier))); rangeAxis.setAutoRangeIncludesZero(true); tmpSubPlot.setRangeAxis(0, rangeAxis); rangeAxis.setLabelPaint(Color.BLUE); rangeAxis.setVisible(newBrick.checked2); tmpSubPlot.setDataset(0, seriesCollectionMap.get(newBrick.uid)); // set dot - shape // Shape cross = ShapeUtilities.createDiagonalCross(3, 1); // create and store renderer XYItemRenderer renderer1 = new XYLineAndShapeRenderer(); renderer1 = tmpSubPlot.getRenderer(); renderer1.setSeriesPaint(0, Color.BLUE); renderer1.setSeriesStroke(0, new BasicStroke(3)); // line = dashes: // float dash[] = {5.0f}; // renderer1.setSeriesStroke( 0, new // BasicStroke(3,BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, // 10.0f, dash, 0.0f)); // renderer1.setSeriesShape(0, cross); tmpSubPlot.setRenderer(0, renderer1); // set colors tmpSubPlot.setBackgroundPaint(Color.white); tmpSubPlot.setDomainGridlinePaint(Color.lightGray); tmpSubPlot.setRangeGridlinePaint(Color.lightGray); // tmpSubPlot.setRenderer(renderer2); // set font rangeAxis.setLabelFont(customFonts.get("axisLabelFont")); rangeAxis.setTickLabelFont(customFonts.get("axisValueFont")); // create template graph // if (newBrick.ctrlTmpl[0] == true) // { tmpSubPlot.setDataset(2, tmplCollection1_1.get(newBrick.uid)); XYItemRenderer renderer3 = new XYLineAndShapeRenderer(); int width = computeTmplPlotWidth(newBrick.tmpl1Width); BasicStroke stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND);// , 10.0f, dash, 0.0f); renderer3.setSeriesPaint(0, Color.GREEN); // renderer3.setSeriesStroke( 0, new BasicStroke( 1 ) ); renderer3.setSeriesStroke(0, stroke); renderer3.setSeriesVisible(0, newBrick.ctrlTmpl[0]); rendererMap3.put(newBrick.uid, renderer3); tmpSubPlot.setRenderer(2, rendererMap3.get(newBrick.uid)); // } // put everything to the maps rendererMap.put(newBrick.uid, renderer1); plotMap.put(newBrick.uid, tmpSubPlot); axisMap.put(newBrick.uid, rangeAxis); } // create the 2nd graph if (newBrick.checked3 == true) { // set second axis for voltage/ampere brick NumberAxis secondaryAxis = new NumberAxis( String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier))); secondaryAxis.setAutoRangeIncludesZero(true); tmpSubPlot.setRangeAxis(1, secondaryAxis); secondaryAxis.setLabelPaint(Color.RED); secondaryAxis.setVisible(newBrick.checked3); tmpSubPlot.setDataset(1, seriesCollectionMap2.get(newBrick.uid)); tmpSubPlot.mapDatasetToRangeAxis(1, 1); // set font secondaryAxis.setLabelFont(customFonts.get("axisLabelFont")); secondaryAxis.setTickLabelFont(customFonts.get("axisValueFont")); // create and store renderer XYItemRenderer renderer2 = new StandardXYItemRenderer(); // renderer2 = tmpSubPlot.getRenderer(); renderer2.setSeriesPaint(1, Color.RED); renderer2.setSeriesStroke(0, new BasicStroke(3)); tmpSubPlot.setRenderer(1, renderer2); // set colors tmpSubPlot.setBackgroundPaint(Color.white); tmpSubPlot.setDomainGridlinePaint(Color.lightGray); tmpSubPlot.setRangeGridlinePaint(Color.lightGray); // ---------------------------------------------------------------------------------- // create min1 critical map value ValueMarker vm5 = new ValueMarker(newBrick.tresholdMin2); markerMapMin2Critical.put(newBrick.uid, vm5); // set critical line markerMapMin2Critical.get(newBrick.uid).setPaint(Color.red); markerMapMin2Critical.get(newBrick.uid).setLabel( String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " critical min"); markerMapMin2Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT); markerMapMin2Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT); tmpSubPlot.addRangeMarker(1, markerMapMin2Critical.get(newBrick.uid), Layer.BACKGROUND); // create min1 warning map value ValueMarker vm6 = new ValueMarker( newBrick.tresholdMin2 + newBrick.tresholdMin2 * warningPercentage / 100); markerMapMin2Warning.put(newBrick.uid, vm6); // set warning line markerMapMin2Warning.get(newBrick.uid).setPaint(Color.orange); markerMapMin2Warning.get(newBrick.uid).setLabel( String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " warning min"); markerMapMin2Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT); markerMapMin2Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT); // tmpSubPlot.addRangeMarker(markerMapMin2Warning.get(newBrick.uid)); tmpSubPlot.addRangeMarker(1, markerMapMin2Warning.get(newBrick.uid), Layer.BACKGROUND); // create max1 critical map value ValueMarker vm7 = new ValueMarker(newBrick.tresholdMax2); markerMapMax2Critical.put(newBrick.uid, vm7); // set critical line markerMapMax2Critical.get(newBrick.uid).setPaint(Color.red); markerMapMax2Critical.get(newBrick.uid).setLabel( String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " critical max"); markerMapMax2Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT); markerMapMax2Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT); tmpSubPlot.addRangeMarker(1, markerMapMax2Critical.get(newBrick.uid), Layer.BACKGROUND); // create max1 warning map value ValueMarker vm8 = new ValueMarker( newBrick.tresholdMax2 + newBrick.tresholdMax2 * warningPercentage / 100); markerMapMax2Warning.put(newBrick.uid, vm8); // set warning line markerMapMax2Warning.get(newBrick.uid).setPaint(Color.orange); markerMapMax2Warning.get(newBrick.uid).setLabel( String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " warning max"); markerMapMax2Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT); markerMapMax2Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT); tmpSubPlot.addRangeMarker(1, markerMapMax2Warning.get(newBrick.uid), Layer.BACKGROUND); // create and add min, max and average markers // create maxima marker ValueMarker vmMax = new ValueMarker(0); vmMax.setPaint(Color.orange); vmMax.setLabel("max"); vmMax.setLabelAnchor(RectangleAnchor.TOP_RIGHT); vmMax.setLabelTextAnchor(TextAnchor.TOP_RIGHT); // create minima marker ValueMarker vmMin = new ValueMarker(0); vmMin.setPaint(Color.orange); vmMin.setLabel("min"); vmMin.setLabelAnchor(RectangleAnchor.TOP_RIGHT); vmMin.setLabelTextAnchor(TextAnchor.TOP_RIGHT); // create average marker ValueMarker vmAvg = new ValueMarker(0); vmAvg.setPaint(Color.red); vmAvg.setLabel("average"); vmAvg.setLabelAnchor(RectangleAnchor.TOP_RIGHT); vmAvg.setLabelTextAnchor(TextAnchor.TOP_RIGHT); // add to maps marker2Maxima.put(newBrick.uid, vmMax); marker2Minima.put(newBrick.uid, vmMin); marker2Average.put(newBrick.uid, vmAvg); // add to plot tmpSubPlot.addRangeMarker(1, vmMax, Layer.BACKGROUND); tmpSubPlot.addRangeMarker(1, vmMin, Layer.BACKGROUND); tmpSubPlot.addRangeMarker(1, vmAvg, Layer.BACKGROUND); // create and add avrgCntrMarkers // create upper marker ValueMarker avrgCtrl2high = new ValueMarker(newBrick.getAvg2high()); avrgCtrl2high.setPaint(Color.orange); avrgCtrl2high.setLabel("avrg high"); avrgCtrl2high.setLabelAnchor(RectangleAnchor.TOP_RIGHT); avrgCtrl2high.setLabelTextAnchor(TextAnchor.TOP_RIGHT); // create lower marker ValueMarker avrgCtrl2low = new ValueMarker(newBrick.getAvg2low()); avrgCtrl2low.setPaint(Color.orange); avrgCtrl2low.setLabel("avrg low"); avrgCtrl2low.setLabelAnchor(RectangleAnchor.TOP_RIGHT); avrgCtrl2low.setLabelTextAnchor(TextAnchor.TOP_RIGHT); // add both markers avrg2High.put(newBrick.uid, avrgCtrl2high); avrg2Low.put(newBrick.uid, avrgCtrl2low); // add both to plot if (newBrick.controlAverage2) { tmpSubPlot.addRangeMarker(1, avrgCtrl2high, Layer.BACKGROUND); tmpSubPlot.addRangeMarker(1, avrgCtrl2low, Layer.BACKGROUND); } // ---------------------------------------------------------------------------------- // put everything to the map rendererMap2.put(newBrick.uid, renderer2); plotMap.put(newBrick.uid, tmpSubPlot); axisMap2.put(newBrick.uid, secondaryAxis); } // 1st graph // markers-------------------------------------------------------------------------------------------------- // create min1 critical map value ValueMarker vm1 = new ValueMarker(newBrick.tresholdMin1); markerMapMin1Critical.put(newBrick.uid, vm1); // set critical line markerMapMin1Critical.get(newBrick.uid).setPaint(Color.red); // / .setLabel("critical"); // markerMapMin1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.BOTTOM); markerMapMin1Critical.get(newBrick.uid) .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " critical min"); markerMapMin1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT); markerMapMin1Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT); plotMap.get(newBrick.uid).addRangeMarker(markerMapMin1Critical.get(newBrick.uid)); // create min1 warning map value ValueMarker vm2 = new ValueMarker(newBrick.tresholdMin1 + newBrick.tresholdMin1 * warningPercentage / 100); markerMapMin1Warning.put(newBrick.uid, vm2); // set warning line markerMapMin1Warning.get(newBrick.uid).setPaint(Color.orange); // marker2Map.get(newBrick.uid).setPaint(Color.); // / marker2Map.get(newBrick.uid).setLabel("warning"); markerMapMin1Warning.get(newBrick.uid) .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " warning min"); markerMapMin1Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT); markerMapMin1Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT); plotMap.get(newBrick.uid).addRangeMarker(markerMapMin1Warning.get(newBrick.uid)); // create max1 critical map value ValueMarker vm3 = new ValueMarker(newBrick.tresholdMax1); markerMapMax1Critical.put(newBrick.uid, vm3); // set critical line markerMapMax1Critical.get(newBrick.uid).setPaint(Color.red); // / .setLabel("critical"); // markerMapMax1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.BOTTOM); markerMapMax1Critical.get(newBrick.uid) .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " critical max"); markerMapMax1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT); markerMapMax1Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT); plotMap.get(newBrick.uid).addRangeMarker(markerMapMax1Critical.get(newBrick.uid)); // create max1 warning map value ValueMarker vm4 = new ValueMarker(newBrick.tresholdMax1 + newBrick.tresholdMax1 * warningPercentage / 100); markerMapMax1Warning.put(newBrick.uid, vm4); // set warning line markerMapMax1Warning.get(newBrick.uid).setPaint(Color.orange); markerMapMax1Warning.get(newBrick.uid) .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " warning max"); markerMapMax1Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT); markerMapMax1Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT); plotMap.get(newBrick.uid).addRangeMarker(markerMapMax1Warning.get(newBrick.uid)); // create and add min, max and average markers // create maxima marker ValueMarker vmMax = new ValueMarker(0); vmMax.setPaint(Color.cyan); vmMax.setLabel("max"); vmMax.setLabelAnchor(RectangleAnchor.TOP_LEFT); vmMax.setLabelTextAnchor(TextAnchor.TOP_LEFT); // create minima marker ValueMarker vmMin = new ValueMarker(0); vmMin.setPaint(Color.cyan); vmMin.setLabel("min"); vmMin.setLabelAnchor(RectangleAnchor.TOP_LEFT); vmMin.setLabelTextAnchor(TextAnchor.TOP_LEFT); // create average marker ValueMarker vmAvg = new ValueMarker(0); vmAvg.setPaint(Color.blue); vmAvg.setLabel("average"); vmAvg.setLabelAnchor(RectangleAnchor.TOP_LEFT); vmAvg.setLabelTextAnchor(TextAnchor.TOP_LEFT); // add to maps markerMaxima.put(newBrick.uid, vmMax); markerMinima.put(newBrick.uid, vmMin); markerAverage.put(newBrick.uid, vmAvg); // add to plot plotMap.get(newBrick.uid).addRangeMarker(vmMax); plotMap.get(newBrick.uid).addRangeMarker(vmMin); plotMap.get(newBrick.uid).addRangeMarker(vmAvg); // create and add avrgCntrMarkers // create upper marker ValueMarker avrgCtrl1high = new ValueMarker(newBrick.getAvg1high()); avrgCtrl1high.setPaint(Color.orange); avrgCtrl1high.setLabel("avrg high"); avrgCtrl1high.setLabelAnchor(RectangleAnchor.TOP_LEFT); avrgCtrl1high.setLabelTextAnchor(TextAnchor.TOP_LEFT); // create lower marker ValueMarker avrgCtrl1low = new ValueMarker(newBrick.getAvg1low()); avrgCtrl1low.setPaint(Color.orange); avrgCtrl1low.setLabel("avrg low"); avrgCtrl1low.setLabelAnchor(RectangleAnchor.TOP_LEFT); avrgCtrl1low.setLabelTextAnchor(TextAnchor.TOP_LEFT); // add both markers avrg1High.put(newBrick.uid, avrgCtrl1high); avrg1Low.put(newBrick.uid, avrgCtrl1low); // add both to plot if (newBrick.controlAverage) { plotMap.get(newBrick.uid).addRangeMarker(avrgCtrl1high); plotMap.get(newBrick.uid).addRangeMarker(avrgCtrl1low); } // ----------------------------------------------------------------------------------------------------- // set title NumberAxis axisForTitleOnly = new NumberAxis( data.constants.brickIdMap.get(newBrick.deviceIdentifier) + " (" + newBrick.uid + ")"); axisForTitleOnly.setLabelFont(customFonts.get("titleFont")); axisForTitleOnly.setTickLabelsVisible(false); axisForTitleOnly.setTickMarksVisible(false); axisForTitleOnly.setMinorTickMarksVisible(false); axisForTitleOnly.setAxisLineVisible(false); plotMap.get(newBrick.uid).setDomainAxis(1, axisForTitleOnly); // add subplot to the main plot plot.add(plotMap.get(newBrick.uid)); }
From source file:org.gumtree.vis.awt.time.TimePlotPanel.java
@Override public void addTimeSeriesSet(ITimeSeriesSet timeSeriesSet) { int validDatasetCount = 0; for (int i = 0; i < getXYPlot().getDatasetCount(); i++) { XYDataset dataset = getXYPlot().getDataset(i); if (dataset != null && dataset instanceof ITimeSeriesSet) { validDatasetCount++;/*from www .jav a 2 s .co m*/ } } if (validDatasetCount == 1) { int numberOfSeries = getXYPlot().getDataset().getSeriesCount(); if (numberOfSeries <= 0) { getXYPlot().setDataset(0, timeSeriesSet); getXYPlot().getRangeAxis().setLabel(timeSeriesSet.getYTitle()); return; } } int index = getXYPlot().getDatasetCount(); getXYPlot().setDataset(index, timeSeriesSet); final NumberAxis rangeAxis2 = new NumberAxis(timeSeriesSet.getYTitle()); rangeAxis2.setAutoRangeIncludesZero(false); DefaultXYItemRenderer newRenderer = new DefaultXYItemRenderer(); newRenderer.setBaseShapesVisible(false); // newRenderer.setBaseShapesVisible(true); getXYPlot().setRenderer(index, newRenderer); getXYPlot().setRangeAxis(index, rangeAxis2); getXYPlot().mapDatasetToRangeAxis(index, index); if (index > 0) { rangeAxis2.setVisible(showMultiaxes); } }
From source file:ucar.unidata.idv.control.chart.VerticalProfileChart.java
/** * Add a series to the charts//w w w. j a v a 2s. c o 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:com.att.aro.diagnostics.GraphPanel.java
/** * Creates a sample dataset.//from ww w . j av a2 s . co m * * @return Series 1. */ private static XYPlot createThroughputPlot() { // 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); // 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:com.att.aro.diagnostics.GraphPanel.java
/** * Sets up the CPU plot/*from w w w. ja v a 2 s .co m*/ * * @return plot CPU plot */ private static XYPlot createCpuPlot() { // Set up renderer StandardXYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES); renderer.setAutoPopulateSeriesShape(false); renderer.setBaseShape(CPU_PLOT_POINT_SHAPE); renderer.setSeriesPaint(0, Color.black); // Normalize the throughput axis so that it represents max value NumberAxis axis = new NumberAxis(); axis.setVisible(false); axis.setAutoRange(false); axis.setRange(MIN_CPU_USAGE, MAX_CPU_USAGE); // Create plot XYPlot plot = new XYPlot(null, null, axis, renderer); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.getRangeAxis().setVisible(false); return plot; }