protected AreaChart<Number, Number> createChart() { NumberAxis xAxis = new NumberAxis(); NumberAxis yAxis = new NumberAxis(); AreaChart<Number,Number> ac = new AreaChart<Number,Number>(xAxis,yAxis); // setup chart ac.setTitle("Area Chart Example"); xAxis.setLabel("X Axis"); yAxis.setLabel("Y Axis"); // add starting data for (int s=0;s<3;s++) { XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>(); series.setName("Data Series "+s); double x = 0; while (x<95) { series.getData().add(new XYChart.Data<Number,Number>(x, Math.random()*99)); x += 5 + (15*Math.random()); } series.getData().add(new XYChart.Data<Number,Number>(99d, Math.random()*99)); ac.getData().add(series); } return ac; }
protected AreaChart<Number,Number> createChart() { final NumberAxis xAxis = new NumberAxis(0,128,8); final NumberAxis yAxis = new NumberAxis(0,50,10); final AreaChart<Number,Number> ac = new AreaChart<Number,Number>(xAxis,yAxis); // setup chart ac.setId("audioAreaDemo"); ac.setLegendVisible(false); ac.setTitle("Live Audio Spectrum Data"); ac.setAnimated(false); xAxis.setLabel("Frequency Bands"); yAxis.setLabel("Magnitudes"); yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis,null,"dB")); // add starting data XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>(); series.setName("Audio Spectrum"); //noinspection unchecked series1Data = new XYChart.Data[(int)xAxis.getUpperBound()]; for (int i=0; i<series1Data.length; i++) { series1Data[i] = new XYChart.Data<Number,Number>(i,50); series.getData().add(series1Data[i]); } ac.getData().add(series); return ac; }
private void createChart() { xAxis = new NumberAxis(); xAxis.setForceZeroInRange(false); xAxis.setAutoRanging(true); NumberAxis yAxis = new NumberAxis(); yAxis.setForceZeroInRange(false); yAxis.setAutoRanging(true); yAxis.setLabel(Res.get("shared.amountWithCur", Res.getBaseCurrencyCode())); yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis, "", "")); seriesBuy = new XYChart.Series<>(); seriesSell = new XYChart.Series<>(); areaChart = new AreaChart<>(xAxis, yAxis); areaChart.setLegendVisible(false); areaChart.setAnimated(false); areaChart.setId("charts"); areaChart.setMinHeight(300); areaChart.setPrefHeight(300); areaChart.setPadding(new Insets(0, 30, 0, 0)); areaChart.getData().addAll(seriesBuy, seriesSell); }
private void addDataToSeriesOriginal() { // add 20 numbers to the plot+ for(int i = 0; i < 20; i++) { if( internalTemperatureMessageQueue.isEmpty() ) { break; } AreaChart.Data data = new AreaChart.Data(xSeriesData++, internalTemperatureMessageQueue.remove()); internalTemperatureSeries.getData().add(data); } // remove points to keep us at no more than MAX_DATA_POINTS if(internalTemperatureSeries.getData().size() > MAX_DATA_POINTS) { internalTemperatureSeries.getData().remove(0, internalTemperatureSeries.getData().size() - MAX_DATA_POINTS); } // update xAxis.setLowerBound(xSeriesData-MAX_DATA_POINTS); xAxis.setUpperBound(xSeriesData-1); }
/**Add date item to chart *@param AreaChart<Number,Number> *@param String the sensor id **/ public static void addDataItem(AreaChart<Number,Number> ac, String sensor) { ObservableList<XYChart.Series<Number, Number>> data = ac.getData(); if (!data.isEmpty()) { for(int i=0;i<data.size();i++) { XYChart.Series<Number, Number> s = data.get(i); if(s.getName().equals(sensor)) { if(s!=null) //not implemented yet break; } } } }
public AreaChartSample() { NumberAxis xAxis = new NumberAxis("X Values", 1.0d, 9.0d, 2.0d); xAxis.setTickLength(12.0f); NumberAxis yAxis = new NumberAxis("Y Values", 0.0d, 10.0d, 2.0d); ObservableList<AreaChart.Series> areaChartData = FXCollections.observableArrayList( new AreaChart.Series("Series 1",FXCollections.observableArrayList( new AreaChart.Data(0,4), new AreaChart.Data(2,5), new AreaChart.Data(4,4), new AreaChart.Data(6,2), new AreaChart.Data(8,6), new AreaChart.Data(10,8) )), new AreaChart.Series("Series 2", FXCollections.observableArrayList( new AreaChart.Data(0,8), new AreaChart.Data(2,2), new AreaChart.Data(4,9), new AreaChart.Data(6,7), new AreaChart.Data(8,5), new AreaChart.Data(10,7) )), new AreaChart.Series("Series 3", FXCollections.observableArrayList( new AreaChart.Data(0,2), new AreaChart.Data(2,5), new AreaChart.Data(4,8), new AreaChart.Data(6,6), new AreaChart.Data(8,9), new AreaChart.Data(10,7) )) ); AreaChart chart = new AreaChart(xAxis, yAxis, areaChartData); getChildren().add(chart); }
public AreaChartControl(String name) { super(name, FlashboardSendableType.AREACHART); axisX = new NumberAxis(); axisX.setForceZeroInRange(false); axisX.setAutoRanging(false); axisX.setUpperBound(maxX); axisX.setLowerBound(minX); axisY = new NumberAxis(); axisY.setForceZeroInRange(false); axisY.setAutoRanging(false); axisY.setUpperBound(maxY); axisY.setLowerBound(minY); chart = new AreaChart<Number, Number>(axisX, axisY); chart.setLegendVisible(false); chart.setAnimated(false); chartSeries = new AreaChart.Series<Number, Number>(); chart.setTitle(name); chart.getData().add(chartSeries); root = new VBox(); root.setAlignment(Pos.CENTER); root.setMaxSize(WIDTH, HEIGHT); root.getChildren().add(chart); }
protected Chart createObject(Axis x_axis, Axis y_axis, double width, double height) { Series s1 = new Series( FXCollections.observableArrayList( new XYChart.Data(1,4), new XYChart.Data(2,5), new XYChart.Data(3,6) )); s1.setName("Set 1"); Series s2 = new Series( FXCollections.observableArrayList( new XYChart.Data(4,4), new XYChart.Data(5,3), new XYChart.Data(6,2) )); s2.setName("Set 2"); Series s3 = new Series( FXCollections.observableArrayList( new XYChart.Data(7,4), new XYChart.Data(8,6), new XYChart.Data(9,8) )); s3.setName("Set 3"); ObservableList data = FXCollections.observableArrayList(s1, s2, s3); AreaChart chart = new AreaChart(x_axis, y_axis, data); chart.setMaxSize(width, height); chart.setPrefSize(width, height); chart.setTitle("AreaChart"); chart.setStyle("-fx-border-color: darkgray;"); return chart; }
@Override protected Chart getNewChartInstance() { NumberAxis axis1 = new NumberAxis(0, 100, 10); NumberAxis axis2 = new NumberAxis(0, 100, 10); AreaChart chart = new AreaChart(axis1, axis2); return chart; }
@Test(timeout = 60000) public void createSymbolsPropertyTest() { assertTrue(new AreaChart(new NumberAxis(), new NumberAxis()).getCreateSymbols()); assertTrue(new StackedAreaChart(new NumberAxis(), new NumberAxis()).getCreateSymbols()); populateChart(); checkTextFieldText(AreaTestsProperties.createSymbols, "true"); checkDotsCount(30); setPropertyByToggleClick(SettingType.BIDIRECTIONAL, AreaTestsProperties.createSymbols, false); checkTextFieldText(AreaTestsProperties.createSymbols, "false"); checkDotsCount(0); setPropertyByToggleClick(SettingType.SETTER, AreaTestsProperties.createSymbols, true); checkTextFieldText(AreaTestsProperties.createSymbols, "true"); checkDotsCount(30); setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, AreaTestsProperties.createSymbols, false); checkTextFieldText(AreaTestsProperties.createSymbols, "false"); checkDotsCount(0); removeFromIndex(2, 1, 0); checkDotsCount(0); setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, AreaTestsProperties.createSymbols, true); addSeries("Series C", 0, 100, 30); checkDotsCount(30); removeFromIndex(0); checkDotsCount(0); setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, AreaTestsProperties.createSymbols, false); checkDotsCount(0); addSeries("Series C", 0, 100, 30); checkDotsCount(0); }
private GPXTrackviewer() { myMapView = new MapView(); myMapView.setZoom(0); myGPXWaypointLayer = new GPXWaypointLayer(); myMapView.addLayer(myGPXWaypointLayer); myMapView.setVisible(false); myMapView.setCursor(Cursor.CROSSHAIR); final NumberAxis xAxis = new NumberAxis(); final NumberAxis yAxis = new NumberAxis(); myAreaChart = new AreaChart(xAxis, yAxis); myAreaChart.setLegendVisible(false); myAreaChart.setVisible(false); myAreaChart.setCursor(Cursor.CROSSHAIR); }
@Override protected XYChart<ZonedDateTime, Double> buildChart(ZonedDateTimeAxis xAxis, ValueAxis<Double> yAxis, BooleanProperty showSymbolsProperty) { AreaChart<ZonedDateTime, Double> newChart = new AreaChart<>(xAxis, yAxis); newChart.setCreateSymbols(false); newChart.createSymbolsProperty().bindBidirectional(showSymbolsProperty); return newChart; }
/** * creates the Node that contans the elevation data. * * @return */ private Node createElevationViewNode() { // in front of the label is the chart NumberAxis xAxis = new NumberAxis(); xAxis.setForceZeroInRange(false); xAxis.setAnimated(false); NumberAxis yAxis = new NumberAxis(); yAxis.setForceZeroInRange(false); yAxis.setAnimated(false); elevationChart = new AreaChart<>(xAxis, yAxis); elevationChart.setCreateSymbols(false); // if the chart is set to animated, we get error message son the console when adding data elevationChart.setAnimated(false); return elevationChart; }
@Test public void testGetAreaChartAdjuster() { Adjuster adjuster = Adjuster.getAdjuster(AreaChart.class); assertThat(adjuster, is(instanceOf(RegionAdjuster.class))); assertThat(adjuster.getNodeClass(), is(sameInstance(Region.class))); }
private void addDataToSeries() { for (int i = 0; i < 50; i++) { if (stockDataQueue.isEmpty()) break; stockPriceSeries.getData().add(new AreaChart.Data(xSeriesDataStock++, stockDataQueue.remove())); if (predictionDataQueue.isEmpty() || emaDataQueue.isEmpty()) break; predictionSeries.getData().add(new AreaChart.Data(xSeriesDataPrediction, predictionDataQueue.remove())); emaPriceSeries.getData().add(new AreaChart.Data(xSeriesDataPrediction, emaDataQueue.remove())); xSeriesDataPrediction++; // series3.getData().add(new AreaChart.Data(xSeriesData++, dataQ3.remove())); } // remove points to keep us at no more than MAX_DATA_POINTS if (stockPriceSeries.getData().size() > MAX_DATA_POINTS) { stockPriceSeries.getData().remove(0, stockPriceSeries.getData().size() - MAX_DATA_POINTS); } if (predictionSeries.getData().size() > MAX_DATA_POINTS) { predictionSeries.getData().remove(0, predictionSeries.getData().size() - MAX_DATA_POINTS); } if (emaPriceSeries.getData().size() > MAX_DATA_POINTS) { emaPriceSeries.getData().remove(0, emaPriceSeries.getData().size() - MAX_DATA_POINTS); } xAxis.setLowerBound(xSeriesDataPrediction - MAX_DATA_POINTS); xAxis.setUpperBound(xSeriesDataStock - 1); }
@Override public void start(Stage primaryStage) { primaryStage.setTitle("java-buddy.blogspot.com"); Group root = new Group(); final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Month"); yAxis.setLabel("Value"); final AreaChart<String,Number> areaChart = new AreaChart<String,Number>(xAxis,yAxis); areaChart.setTitle("AreaChart"); XYChart.Series series = new XYChart.Series(); series.setName("XYChart.Series"); series.getData().add(new XYChart.Data("January", 100)); series.getData().add(new XYChart.Data("February", 200)); series.getData().add(new XYChart.Data("March", 50)); series.getData().add(new XYChart.Data("April", 75)); series.getData().add(new XYChart.Data("May", 110)); series.getData().add(new XYChart.Data("June", 300)); series.getData().add(new XYChart.Data("July", 111)); series.getData().add(new XYChart.Data("August", 30)); series.getData().add(new XYChart.Data("September", 75)); series.getData().add(new XYChart.Data("October", 55)); series.getData().add(new XYChart.Data("November", 225)); series.getData().add(new XYChart.Data("December", 99)); areaChart.getData().add(series); root.getChildren().add(areaChart); primaryStage.setScene(new Scene(root, 500, 400)); primaryStage.show(); }
@Override protected XYChart<Number, Number> createXYChart() { final NumberAxis xAxis = new NumberAxis(); final NumberAxis yAxis = new NumberAxis(); final XYChart<Number, Number> chart = new AreaChart<Number, Number>(xAxis, yAxis); chart.getStyleClass().add("chart-extension"); return chart; }
/**Clears the chart area *@param AreaChart<Number,Number> to be cleared *@return void **/ public static void clearAreaChart(AreaChart<Number,Number> ac) { if (!ac.getData().isEmpty()) { ac.getData().clear(); } }
/**Removes the specified series from the specified chart area *@param AreaChart<Number,Number> from which the series will be removed *@param String sensor *@return void **/ public static void removeAreaChartSeries(AreaChart<Number,Number> ac,String sensor) { if (!ac.getData().isEmpty()) { ObservableList data= ac.getData(); for(int i=0;i<data.size();i++) { if(ac.getData().get(i).getName().equals(LN.getString(sensor))) ac.getData().remove(i); } } }
@Override public void start(Stage stage) { if (stage == null) { return; } stage.setTitle("Area Chart Sample"); final NumberAxis xAxis = new NumberAxis(1, 31, 1); final NumberAxis yAxis = new NumberAxis(); final AreaChart<Number,Number> ac = new AreaChart<>(xAxis,yAxis); ac.setTitle("Temperature Monitoring (in Degrees C)"); XYChart.Series seriesApril= new XYChart.Series(); seriesApril.setName("April"); seriesApril.getData().add(new XYChart.Data(1, 4)); seriesApril.getData().add(new XYChart.Data(3, 10)); seriesApril.getData().add(new XYChart.Data(6, 15)); seriesApril.getData().add(new XYChart.Data(9, 8)); seriesApril.getData().add(new XYChart.Data(12, 5)); seriesApril.getData().add(new XYChart.Data(15, 18)); seriesApril.getData().add(new XYChart.Data(18, 15)); seriesApril.getData().add(new XYChart.Data(21, 13)); seriesApril.getData().add(new XYChart.Data(24, 19)); seriesApril.getData().add(new XYChart.Data(27, 21)); seriesApril.getData().add(new XYChart.Data(30, 21)); XYChart.Series seriesMay = new XYChart.Series(); seriesMay.setName("May"); seriesMay.getData().add(new XYChart.Data(1, 20)); seriesMay.getData().add(new XYChart.Data(3, 15)); seriesMay.getData().add(new XYChart.Data(6, 13)); seriesMay.getData().add(new XYChart.Data(9, 12)); seriesMay.getData().add(new XYChart.Data(12, 14)); seriesMay.getData().add(new XYChart.Data(15, 18)); seriesMay.getData().add(new XYChart.Data(18, 25)); seriesMay.getData().add(new XYChart.Data(21, 25)); seriesMay.getData().add(new XYChart.Data(24, 23)); seriesMay.getData().add(new XYChart.Data(27, 26)); seriesMay.getData().add(new XYChart.Data(31, 26)); Scene scene = new Scene(ac,800,600); ac.getData().addAll(seriesApril, seriesMay); stage.setScene(scene); stage.show(); }
@Override public void draw() { NumberAxis xAxis = new NumberAxis(); NumberAxis yAxis = new NumberAxis(); xAxis.setMinorTickVisible(false); xAxis.setTickMarkVisible(false); xAxis.setTickLabelsVisible(false); xAxis.setAutoRanging(false); yAxis.setMinorTickVisible(false); yAxis.setTickMarkVisible(false); yAxis.setLabel("MB"); XYChart.Series<Number, Long> capacitySeries = new XYChart.Series<>(); XYChart.Series<Number, Long> usageSeries = new XYChart.Series<>(); AreaChart<Number, Long> chart = new AreaChart(xAxis, yAxis, FXCollections.observableArrayList(capacitySeries, usageSeries)); chart.setAnimated(false); chart.setLegendVisible(false); chart.lookup(".series0").setStyle("-fx-fill: red; -fx-stroke: red;"); // capacity chart.lookup(".series1").setStyle("-fx-fill: blue; -fx-stroke: blue;"); // usage Stage stage = super.createStage(chart, "Metaspace usage"); for(LogData log : super.logdata){ long capacity; long usage; if(!super.shouldProcess(log) || (log.getTags().size() != 2) || !log.getTags().contains("metaspace")){ continue; } long gcid = super.getGcId(); Matcher matcher = METASPACE_USAGE_PATTERN.matcher(super.getLogBody()); if(!matcher.matches()){ continue; } usage = Long.parseLong(matcher.group(1)) / 1024; // in MB capacity = Long.parseLong(matcher.group(2)) / 1024; // in MB LogTimeValue logTimeValue = LogTimeValue.getLogTimeValue(log, super.chartWizardController.getTimeRange()); XYChart.Data<Number, Long> capacityData = new XYChart.Data<>(logTimeValue.getValue(), capacity); XYChart.Data<Number, Long> usageData = new XYChart.Data<>(logTimeValue.getValue(), usage); capacitySeries.getData().add(capacityData); usageSeries.getData().add(usageData); Node capacityDataNode = capacityData.getNode(); Node usageDataNode = usageData.getNode(); capacityDataNode.lookup(".chart-area-symbol").setStyle(BASE_SYMBOL_STYLE + "-fx-background-color: white, red;"); usageDataNode.lookup(".chart-area-symbol").setStyle(BASE_SYMBOL_STYLE + "-fx-background-color: white, blue;"); capacityDataNode.addEventHandler(MouseEvent.MOUSE_ENTERED_TARGET, e -> capacityDataNode.setOpacity(1.0d)); capacityDataNode.addEventHandler(MouseEvent.MOUSE_EXITED_TARGET, e -> capacityDataNode.setOpacity(0.0d)); usageDataNode.addEventHandler(MouseEvent.MOUSE_ENTERED_TARGET, e -> usageDataNode.setOpacity(1.0d)); usageDataNode.addEventHandler(MouseEvent.MOUSE_EXITED_TARGET, e -> usageDataNode.setOpacity(0.0d)); capacityDataNode.addEventHandler(MouseEvent.MOUSE_ENTERED_TARGET, e -> setTooltipValue(logTimeValue.toString(), capacity, usage, gcid)); usageDataNode.addEventHandler(MouseEvent.MOUSE_ENTERED_TARGET, e -> setTooltipValue(logTimeValue.toString(), capacity, usage, gcid)); capacityDataNode.addEventHandler(MouseEvent.MOUSE_CLICKED, e -> super.showLogWindow(super.gcEventList.get(gcid), "GC ID: " + gcid)); usageDataNode.addEventHandler(MouseEvent.MOUSE_CLICKED, e -> super.showLogWindow(super.gcEventList.get(gcid), "GC ID: " + gcid)); Tooltip.install(capacityData.getNode(), tooltip); Tooltip.install(usageData.getNode(), tooltip); } if(capacitySeries.getData().size() == 0){ (new Alert(Alert.AlertType.ERROR, "No GC data", ButtonType.OK)).showAndWait(); return; } xAxis.setLowerBound(capacitySeries.getData().get(0).getXValue().doubleValue()); xAxis.setUpperBound(capacitySeries.getData().get(capacitySeries.getData().size() - 1).getXValue().doubleValue()); stage.show(); }
public AreaChart getNewChart() { AreaChart chart = new AreaChart(axis1, axis2); chart.setTitle("AreaChart"); chart.setStyle("-fx-border-color: darkgray;"); return chart; }
void setHistogram(final PathTableData<?> model, final String columnName) { if (model != null && model.getMeasurementNames().contains(columnName)) { double[] values = model.getDoubleValues(columnName); int nBins = params.getIntParameterValue("nBins"); if (nBins < 2) nBins = 2; else if (nBins > 1000) nBins = 1000; // We can have values in the 'wrong' order to facilitate comparison... Arrays.sort(values); // Check if we've actually changed anything - if not, then abort if (nBins == currentBins && currentValues != null && Arrays.equals(currentValues, values)) return; Histogram histogram = new Histogram(values, nBins); histogram.setNormalizeCounts(params.getBooleanParameterValue("normalizeCounts")); panelHistogram.getHistogramData().setAll(HistogramPanelFX.createHistogramData(histogram, false, (Integer)null)); AreaChart<Number, Number> chart = panelHistogram.getChart(); chart.setVerticalGridLinesVisible(true); chart.setHorizontalGridLinesVisible(true); chart.setLegendVisible(false); chart.setCreateSymbols(false); // Can't stop them being orange... chart.getXAxis().setLabel("Values"); chart.getYAxis().setLabel("Counts"); chart.getYAxis().setTickLabelsVisible(true); chart.getYAxis().setTickMarkVisible(true); chart.getXAxis().setTickLabelsVisible(true); chart.getXAxis().setTickMarkVisible(true); chart.setAnimated(params.getBooleanParameterValue("animate")); updateTable(histogram); currentColumn = columnName; currentBins = nBins; currentValues = values; this.model = model; } else panelHistogram.getHistogramData().clear(); }
public AreaChart<Number, Number> getChart() { return chart; }
private XYChart<Number, Number> createChart() { final XYChart.Series<Number, Number> series = new XYChart.Series<>(); final double divisionWidth = (this.story.getRange().getLength() * 1.0) / (numDivisions * 1.0); for (int i = 0; i < numDivisions; ++i) { final TextRange range = new TextRange((int) Math.round(i * divisionWidth), (int) Math.round((i + 1) * divisionWidth)); final double count = getNumOverlaps(range, this.ranges); series.getData().add(new Data<Number, Number>(range.getStartIndex(), count)); } final StringConverter<Number> tickLabelFormatter = new StringConverter<Number>() { @Override public String toString(final Number n) { return String.valueOf((int) Math.round(n.doubleValue())); } @Override public Number fromString(final String string) { return Double.valueOf(string); } }; final NumberAxis xAxis = new NumberAxis(0, this.story.getRange().getLength() - divisionWidth, divisionWidth); xAxis.setLabel("Text Position"); xAxis.setTickLabelsVisible(true); xAxis.setTickLabelFormatter(tickLabelFormatter); final NumberAxis yAxis = new NumberAxis(); yAxis.setTickUnit(1); yAxis.setLabel("# Found"); yAxis.setTickLabelsVisible(true); yAxis.setTickLabelFormatter(tickLabelFormatter); final AreaChart<Number, Number> chart = new AreaChart<>(xAxis, yAxis); chart.setAnimated(false); chart.getData().add(series); chart.setLegendVisible(false); chart.setPrefWidth(600); chart.setPrefHeight(400); chart.setTitle("Heat Map"); return chart; }
private void initialize(Stage primaryStage) { logger = Logger.getLogger(getClass().getName()); xAxis = new NumberAxis(0,MAX_DATA_POINTS,MAX_DATA_POINTS/10); xAxis.setForceZeroInRange(false); xAxis.setAutoRanging(false); NumberAxis yAxis = new NumberAxis(); yAxis.setAutoRanging(true); // Chart final AreaChart<Number, Number> sc = new AreaChart<Number, Number>(xAxis, yAxis) { @Override protected void dataItemAdded(Series<Number, Number> series, int itemIndex, Data<Number, Number> item) { ; // This method is overriden with empty statement, to remove symbols on each data point. } }; sc.setAnimated(false); sc.setId("liveAreaChart"); sc.setTitle("Lizard Enclosure Sensor Readings"); // internal temperature Series internalTemperatureSeries = new AreaChart.Series<Number, Number>(); internalTemperatureSeries.setName("Internal Temperature"); sc.getData().add(internalTemperatureSeries); externalTemperatureSeries = new AreaChart.Series<Number, Number>(); externalTemperatureSeries.setName("External Temperature"); sc.getData().add(externalTemperatureSeries); internalHumiditySeries = new AreaChart.Series<Number, Number>(); internalHumiditySeries.setName("Internal Humidity"); sc.getData().add(internalHumiditySeries); primaryStage.setScene(new Scene(sc)); primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent t) { Platform.exit(); System.exit(0); } }); }
/** * Handles the events responsible of changing the chart view * @param boolean initiateSliders instructing the system to initiate the sliders **/ public static void handleChartChangeEvent(boolean initiateSliders ) { try { removeAllAreaChartSeries(Globals.areaChart); int seriesLength=Globals.graphObj.getHeaders().size(); String time=Globals.graphObj.getHeaders().get(0); for(int s=1;s<seriesLength;s++) { String sensorName=Globals.graphObj.getHeaders().get(s); if((Boolean)Globals.graphObj.getCheckboxesStatus().get(sensorName)) { String sensorUnit=Globals.graphObj.getUnits().get(s); String seriesNameLong=builSeriesName(sensorName, sensorUnit); int timeIndex=Globals.graphObj.getHeaderIndexForID(time); int sensorIndex=Globals.graphObj.getHeaderIndexForID(sensorName); ArrayList<HashMap> seriesData=Globals.graphObj.getSeries(); AreaChart.Series<Number,Number> series = new AreaChart.Series<Number,Number>(); series.setName(LN.getString(seriesNameLong)); for(int i=0;i<seriesData.size();i++) { double yVal =(Double)seriesData.get(i).get(sensorIndex); double xVal =(Double)seriesData.get(i).get(timeIndex); if(initiateSliders) { series.getData().add(new AreaChart.Data<Number,Number>(xVal, yVal)); updateSlidersLimits((int)xVal,(int)yVal); } else if(xVal>=Globals.xFirst&&xVal<=Globals.xLast&&yVal>=Globals.yFirst&&yVal<=Globals.yLast) series.getData().add(new AreaChart.Data<Number,Number>(xVal, yVal)); } addAreaChartSeries(Globals.areaChart,series); } } } catch(Exception e) {} }
public static void removeAllAreaChartSeries(AreaChart<Number,Number> ac) { ac.getData().clear(); }
/**Adds new data series to the specified area chart, on the specified index *@param AreaChart<Number,Number> from which the series will be removed *@paramAreaChart.Series<Number,Number> the data series *@return void **/ public static void addAreaChartSeries(AreaChart<Number,Number> ac,AreaChart.Series<Number,Number> series) { ac.getData().add(series); }