/** * Returns the plot area in the reference's coordinate space. */ public Rectangle2D getPlotArea() { Axis<?> xAxis = chart.getXAxis(); Axis<?> yAxis = chart.getYAxis(); double xStart = getXShift( xAxis, referenceNode ); double yStart = getYShift( yAxis, referenceNode ); //If the direct method to get the width (which is based on its Node dimensions) is not found to //be appropriate, an alternative method is commented. // double width = xAxis.getDisplayPosition( xAxis.toRealValue( xAxis.getUpperBound() ) ); double width = xAxis.getWidth(); // double height = yAxis.getDisplayPosition( yAxis.toRealValue( yAxis.getLowerBound() ) ); double height = yAxis.getHeight(); return new Rectangle2D( xStart, yStart, width, height ); }
/** * Construct a new CandleStickChart with the given axis. * * @param xAxis The x axis to use * @param yAxis The y axis to use */ public CandleStickChart(Axis<Number> xAxis, Axis<Number> yAxis) { super(xAxis, yAxis); setAnimated(false); xAxis.setAnimated(false); yAxis.setAnimated(false); }
/** * This is called when the range has been invalidated and we need to update it. If the axis are auto * ranging then we compile a list of all data that the given axis has to plot and call invalidateRange() on the * axis passing it that data. */ @Override protected void updateAxisRange() { // For candle stick chart we need to override this method as we need to let the axis know that they need to be able // to cover the whole area occupied by the high to low range not just its center data value final Axis<Number> xa = getXAxis(); final Axis<Number> ya = getYAxis(); List<Number> xData = null; List<Number> yData = null; if (xa.isAutoRanging()) { xData = new ArrayList<Number>(); } if (ya.isAutoRanging()) { yData = new ArrayList<Number>(); } if (xData != null || yData != null) { for (Series<Number, Number> series : getData()) { for (Data<Number, Number> data : series.getData()) { if (xData != null) { xData.add(data.getXValue()); } if (yData != null) { CandleStickExtraValues extras = (CandleStickExtraValues) data.getExtraValue(); if (extras != null) { yData.add(extras.getHigh()); yData.add(extras.getLow()); } else { yData.add(data.getYValue()); } } } } if (xData != null) { xa.invalidateRange(xData); } if (yData != null) { ya.invalidateRange(yData); } } }
/** * Instantiates a new Timing diagram view. * * @param xaxis the x axis * @param yaxis the y axis */ public TimingDiagramView(NumberAxis xaxis, Axis<A> yaxis) { super(xaxis, yaxis); this.xaxis = xaxis; this.yaxis = yaxis; setPrefHeight(80); getPlotChildren().addAll(cycleSelectionPane, durationLinesPane, dataPane); ViewUtils.setupView(this); ObservableList<Series<Number, A>> seriesObservableList = FXCollections.observableArrayList(); setData(seriesObservableList); seriesObservableList.addListener((InvalidationListener) change -> { Platform.runLater(TimingDiagramView.this::requestRelayout); }); }
/** * Generates an integer timing diagram. * * @param concreteSpec the concrete specification which should be used to extract the needed * information * @param specIoVar the variable for which a diagram should be generated * @param globalXAxis global x axis used for all diagrams * @param selection selection that should be updated when hovering with mouse * @param activated only update selection if true * @return A {@link Pair} which holds a {@link TimingDiagramController} and a {@link NumberAxis} */ public static Pair<TimingDiagramController, Axis> createIntegerTimingDiagram( ConcreteSpecification concreteSpec, ValidIoVariable specIoVar, NumberAxis globalXAxis, Selection selection, BooleanProperty activated) { NumberAxis yaxis = new NumberAxis(0, 10, 1); yaxis.setPrefWidth(30); yaxis.setSide(Side.LEFT); yaxis.setTickLabelFormatter(new IntegerTickLabelConverter()); yaxis.setMinorTickVisible(false); TimingDiagramController timingDiagramController = new TimingDiagramController(globalXAxis, yaxis, concreteSpec, specIoVar, selection, activated); return new ImmutablePair<>(timingDiagramController, yaxis); }
/** * Generates a boolean timing diagram. * * @param concreteSpec the concrete specification which should be used to extract the needed * information * @param specIoVar the variable for which a diagram should be generated * @param globalXAxis global x axis used for all diagrams * @param selection selection that should be updated when hovering with mouse * @param activated only update selection if true * @return A {@link Pair} which holds a {@link TimingDiagramController} and a {@link CategoryAxis} */ public static Pair<TimingDiagramController, Axis> createBoolTimingDiagram( ConcreteSpecification concreteSpec, ValidIoVariable specIoVar, NumberAxis globalXAxis, Selection selection, BooleanProperty activated) { ObservableList<String> categories = FXCollections.observableArrayList(); categories.addAll("FALSE", "TRUE"); CategoryAxis boolCategoryAxis = new CategoryAxis(categories); boolCategoryAxis.setPrefWidth(30); boolCategoryAxis.setSide(Side.LEFT); boolCategoryAxis.setAutoRanging(true); TimingDiagramController timingDiagramController = new TimingDiagramController(globalXAxis, boolCategoryAxis, concreteSpec, specIoVar, selection, activated); return new ImmutablePair<>(timingDiagramController, boolCategoryAxis); }
/** * Generates an enum timing diagram. * * @param concreteSpec the concrete specification which should be used to extract the needed * information * @param specIoVar the variable for which a diagram should be generated * @param typeEnum type of the enum this diagram is generated for * @param globalXAxis global x axis used for all diagrams * @param selection selection that should be updated when hovering with mouse * @param activated only update selection if true * @return A {@link Pair} which holds a {@link TimingDiagramController} and a {@link CategoryAxis} */ public static Pair<TimingDiagramController, Axis> createEnumTimingDiagram( ConcreteSpecification concreteSpec, ValidIoVariable specIoVar, TypeEnum typeEnum, NumberAxis globalXAxis, Selection selection, BooleanProperty activated) { ObservableList<String> categories = FXCollections.observableArrayList(); typeEnum.getValues().stream().map(ValueEnum::getEnumValue).forEach(categories::add); CategoryAxis categoryAxis = new CategoryAxis(categories); categoryAxis.setSide(Side.LEFT); categoryAxis.setPrefWidth(30); categoryAxis.setAutoRanging(true); TimingDiagramController timingDiagramController = new TimingDiagramController(globalXAxis, categoryAxis, concreteSpec, specIoVar, selection, activated); return new ImmutablePair<>(timingDiagramController, categoryAxis); }
/** * Generates a {@link TimingDiagramController} for a given {@link ValidIoVariable}. The method * adds multiple views to the {@link TimingDiagramCollectionView view} of this controller: * <ul> * <li>A {@link TimingDiagramView} wrapped in a * {@link edu.kit.iti.formal.stvs.view.spec.timingdiagram.renderer.VerticalResizeContainerView} * will be added to {@link TimingDiagramCollectionView#diagramContainer}</li> * <li>A {@link Label} (title of the {@link ValidIoVariable}) will be added to * {@link TimingDiagramCollectionView#labelContainer}</li> * <li>A {@link Axis} will be added to the {@link TimingDiagramCollectionView#yaxisContainer}</li> * </ul> * * @param concreteSpec the concrete specification which should be used to extract the needed * information * @param validIoVariable the variable for which a diagram should be generated */ private void createTimingDiagram(ConcreteSpecification concreteSpec, ValidIoVariable validIoVariable) { Pair<TimingDiagramController, Axis> diagramAxisPair = validIoVariable.getValidType().match( () -> TimingDiagramController.createIntegerTimingDiagram(concreteSpec, validIoVariable, view.getXaxis(), selection, activated), () -> TimingDiagramController.createBoolTimingDiagram(concreteSpec, validIoVariable, view.getXaxis(), selection, activated), (e) -> TimingDiagramController.createEnumTimingDiagram(concreteSpec, validIoVariable, e, view.getXaxis(), selection, activated)); TimingDiagramView timingDiagramView = diagramAxisPair.getLeft().getView(); if (concreteSpec.isCounterExample()) { timingDiagramView.getStyleClass().add("counterexample"); } Axis externalYAxis = diagramAxisPair.getRight(); VerticalResizeContainerController verticalResizeContainerController = new VerticalResizeContainerController(timingDiagramView); this.view.getDiagramContainer().getChildren().add(verticalResizeContainerController.getView()); this.view.getyAxisContainer().getChildren().add(externalYAxis); timingDiagramView.getyAxis().layoutBoundsProperty() .addListener(change -> updateAxisExternalPosition(timingDiagramView, externalYAxis)); verticalResizeContainerController.getView().layoutYProperty() .addListener(change -> updateAxisExternalPosition(timingDiagramView, externalYAxis)); AnchorPane.setRightAnchor(externalYAxis, 0.0); Label label = new Label(validIoVariable.getName()); label.getStyleClass().add(validIoVariable.getCategory().name().toLowerCase()); this.view.getLabelContainer().getChildren().add(label); // Ensures that labels are always centered vertically relative to their diagram label.layoutYProperty().bind(externalYAxis.layoutYProperty() .add(externalYAxis.heightProperty().divide(2)).subtract(label.heightProperty().divide(2))); }
public void setXAxis(final Axis AXIS) { if (null == xAxis) { _xAxis = AXIS; fireTileEvent(RESIZE_EVENT); } else { xAxis.set(AXIS); } }
public ObjectProperty<Axis> xAxisProperty() { if (null == xAxis) { xAxis = new ObjectPropertyBase<Axis>(_xAxis) { @Override protected void invalidated() { fireTileEvent(RESIZE_EVENT); } @Override public Object getBean() { return Tile.this; } @Override public String getName() { return "xAxis"; } }; _xAxis = null; } return xAxis; }
public void setYAxis(final Axis AXIS) { if (null == yAxis) { _yAxis = AXIS; fireTileEvent(RESIZE_EVENT); } else { yAxis.set(AXIS); } }
public ObjectProperty<Axis> yAxisProperty() { if (null == yAxis) { yAxis = new ObjectPropertyBase<Axis>(_yAxis) { @Override protected void invalidated() { fireTileEvent(RESIZE_EVENT); } @Override public Object getBean() { return Tile.this; } @Override public String getName() { return "yAxis"; } }; _yAxis = null; } return yAxis; }
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; }
public static Chart createObject(Axis x_axis, Axis y_axis, double width, double height) { Series s1 = new Series( FXCollections.observableArrayList( new XYChart.Data("First", 4), new XYChart.Data("Second", 5), new XYChart.Data("Fourth", 6) )); s1.setName("Set 1"); Series s2 = new Series( FXCollections.observableArrayList( new XYChart.Data("First", 4), new XYChart.Data("Second", 3), new XYChart.Data("Fourth", 2) )); s2.setName("Set 2"); Series s3 = new Series( FXCollections.observableArrayList( new XYChart.Data("First", 4), new XYChart.Data("Second", 6), new XYChart.Data("Fourth", 8) )); s3.setName("Set 3"); ObservableList data = FXCollections.observableArrayList(s1, s2, s3); StackedBarChart chart = new StackedBarChart(x_axis, y_axis, data); chart.setMaxSize(width, height); chart.setPrefSize(width, height); chart.setTitle("StackedBarChart"); chart.setStyle("-fx-border-color: darkgray;"); return chart; }
protected Object 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(4, 5), new XYChart.Data(9, 6) )); s1.setName("Set 1"); Series s2 = new Series( FXCollections.observableArrayList( new XYChart.Data(0, 4), new XYChart.Data(3, 3), new XYChart.Data(8, 2) )); s2.setName("Set 2"); Series s3 = new Series( FXCollections.observableArrayList( new XYChart.Data(2, 4), new XYChart.Data(5, 6), new XYChart.Data(9, 8) )); s3.setName("Set 3"); ObservableList data = FXCollections.observableArrayList(s1, s2, s3); LineChart chart = new LineChart(x_axis, y_axis, data); chart.setMaxSize(width, height); chart.setPrefSize(width, height); chart.setTitle("LineChart"); chart.setStyle("-fx-border-color: darkgray;"); return chart; }
@Override protected Node createWrap(Axis x_axis, Axis y_axis, double width, double height) { Series s1 = new Series( FXCollections.observableArrayList( new XYChart.Data("First", "First"), new XYChart.Data("Second", "Second"), new XYChart.Data("Fourth", "Third") )); s1.setName("Set 1"); Series s2 = new Series( FXCollections.observableArrayList( new XYChart.Data("First", "Third"), new XYChart.Data("Second", "First"), new XYChart.Data("Fourth", "Second") )); s2.setName("Set 2"); Series s3 = new Series( FXCollections.observableArrayList( new XYChart.Data("First", "Second"), new XYChart.Data("Second", "Third"), new XYChart.Data("Third", "First") )); s3.setName("Set 3"); ObservableList data = FXCollections.observableArrayList(s1, s2, s3); Chart chart = new ScatterChart(x_axis, y_axis, data); chart.setMaxSize(width, height); chart.setPrefSize(width, height); chart.setTitle("ScatterChart"); chart.setStyle("-fx-border-color: darkgray;"); return chart; }
public static Chart createObject(Axis x_axis, Axis y_axis, double width, double height) { Series s1 = new Series( FXCollections.observableArrayList( new XYChart.Data("First", 4), new XYChart.Data("Second", 5), new XYChart.Data("Fourth", 6) )); s1.setName("Set 1"); Series s2 = new Series( FXCollections.observableArrayList( new XYChart.Data("First", 4), new XYChart.Data("Second", 3), new XYChart.Data("Fourth", 2) )); s2.setName("Set 2"); Series s3 = new Series( FXCollections.observableArrayList( new XYChart.Data("First", 4), new XYChart.Data("Second", 6), new XYChart.Data("Fourth", 8) )); s3.setName("Set 3"); ObservableList data = FXCollections.observableArrayList(s1, s2, s3); BarChart chart = new BarChart(x_axis, y_axis, data); chart.setMaxSize(width, height); chart.setPrefSize(width, height); chart.setTitle("BarChart"); chart.setStyle("-fx-border-color: darkgray;"); return chart; }
protected Chart createObject(Axis x_axis, Axis y_axis, double width, double height) { Series s1 = new Series( FXCollections.observableArrayList( new XYChart.Data(3, 4, 0.5), new XYChart.Data(1, 5, 0.2), new XYChart.Data(4, 6, 2) )); s1.setName("Set 1"); Series s2 = new Series( FXCollections.observableArrayList( new XYChart.Data(1, 4, 0.3), new XYChart.Data(2, 3, 0.2), new XYChart.Data(4, 2, 0.4) )); s2.setName("Set 2"); Series s3 = new Series( FXCollections.observableArrayList( new XYChart.Data(5, 4, 0.2), new XYChart.Data(1, 6, 1.2), new XYChart.Data(3, 8, 1.1) )); s3.setName("Set 3"); ObservableList data = FXCollections.observableArrayList(s1, s2, s3); BubbleChart chart = new BubbleChart(x_axis, y_axis, data); chart.setMaxSize(width, height); chart.setPrefSize(width, height); chart.setTitle("BubbleChart"); chart.setStyle("-fx-border-color: darkgray;"); return chart; }
public static Object createObject(Axis x_axis, Axis y_axis, double width, double height) { Series s1 = new Series( FXCollections.observableArrayList( new XYChart.Data(3, 4), new XYChart.Data(1, 5), new XYChart.Data(4, 6) )); s1.setName("Set 1"); Series s2 = new Series( FXCollections.observableArrayList( new XYChart.Data(1, 4), new XYChart.Data(2, 3), new XYChart.Data(4, 2) )); s2.setName("Set 2"); Series s3 = new Series( FXCollections.observableArrayList( new XYChart.Data(5, 4), new XYChart.Data(1, 6), new XYChart.Data(3, 8) )); s3.setName("Set 3"); ObservableList data = FXCollections.observableArrayList(s1, s2, s3); ScatterChart chart = new ScatterChart(x_axis, y_axis, data); chart.setMaxSize(width, height); chart.setPrefSize(width, height); chart.setTitle("ScatterChart"); chart.setStyle("-fx-border-color: darkgray;"); return chart; }
@SuppressWarnings("unchecked") public LineChartBox( Axis<X> xAxis, Axis<Y> yAxis) { super(xAxis, yAxis); myPlots = new ArrayList<InternalPlot<X, Y>>(); this.setAnimated(true); myData = FXCollections.observableArrayList(); this.setData(myData); }
public LineChartBox( Axis<X> xAxis, Axis<Y> yAxis,ObservableList<Series<X,Y>> data) { super(xAxis, yAxis, data); myPlots = new ArrayList<InternalPlot<X, Y>>(); this.setAnimated(true); myData = FXCollections.observableArrayList(); this.setData(myData); }
@SuppressWarnings("unchecked") public LineChartBox( Axis<X> xAxis, Axis<Y> yAxis) { super(xAxis, yAxis); myPlots = new ArrayList<InternalPlot<X, Y>>(); this.setAnimated(true); this.setCreateSymbols(false); myData = FXCollections.observableArrayList(); this.setData(myData); start = true; }
public LineChartBox( Axis<X> xAxis, Axis<Y> yAxis,ObservableList<Series<X,Y>> data) { super(xAxis, yAxis, data); myPlots = new ArrayList<InternalPlot<X, Y>>(); this.setAnimated(true); myData = FXCollections.observableArrayList(); this.setData(myData); start = true; }
public static XYChart<Number, Number> copyChart(final XYChart<Number, Number> chart) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { @SuppressWarnings("unchecked") XYChart<Number, Number> chart2 = (XYChart<Number, Number>)chart.getClass().getConstructor(Axis.class, Axis.class).newInstance(new NumberAxis(), new NumberAxis()); // Set the axis appropriately setAxisProperties(chart.getXAxis(), chart2.getXAxis()); setAxisProperties(chart.getYAxis(), chart2.getYAxis()); // Add all the data for (Series<Number, Number> series : chart.getData()) { Series<Number, Number> series2 = new Series<>(); series2.setName(series.getName()); for (Data<Number, Number> data : series.getData()) { series2.getData().add(new Data<Number, Number>(data.getXValue(), data.getYValue(), data.getExtraValue())); } chart2.getData().add(series2); // // Set visibility of nodes, as required // int counter = 0; // for (Data<Number, Number> data : series.getData()) { // if (data.getNode() != null && series2.getData().get(counter).getNode() != null) { // series2.getData().get(counter).getNode().setVisible(data.getNode().isVisible()); // } // } } // Set other main properties chart2.setTitle(chart.getTitle()); chart2.setStyle(chart.getStyle()); return chart2; }
private static void setAxisProperties(final Axis<Number> axisOrig, final Axis<Number> axisNew) { if (axisOrig instanceof NumberAxis && axisNew instanceof NumberAxis) { NumberAxis nAxisOrig = (NumberAxis)axisOrig; NumberAxis nAxisNew = (NumberAxis)axisNew; nAxisNew.setLowerBound(nAxisOrig.getLowerBound()); nAxisNew.setUpperBound(nAxisOrig.getUpperBound()); nAxisNew.setTickUnit(nAxisOrig.getTickUnit()); } axisNew.setAutoRanging(axisOrig.isAutoRanging()); axisNew.setLabel(axisOrig.getLabel()); }
/** * Creates the correct x axis. * * @return the x axis. */ private Axis<?> createXAxis() { if (FXControlUtil.isTimestampColumn(dataBook, xColumnName)) { return new TimestampAxis(dateFormat); } else { return new NumberAxis(); } }
@Test public void testGetAxisAdjuster() { Adjuster adjuster = Adjuster.getAdjuster(Axis.class); assertThat(adjuster, is(instanceOf(RegionAdjuster.class))); assertThat(adjuster.getNodeClass(), is(sameInstance(Region.class))); }
@Override protected void updateAxisRange() { final Axis<Number> xa = getXAxis(); final Axis<Number> ya = getYAxis(); List<Number> xData = null; List<Number> yData = null; if (xa.isAutoRanging()) { xData = new ArrayList<>(); } if (ya.isAutoRanging()) yData = new ArrayList<>(); if (xData != null || yData != null) { for (XYChart.Series<Number, Number> series : getData()) { for (XYChart.Data<Number, Number> data : series.getData()) { if (xData != null) { xData.add(data.getXValue()); } if (yData != null) yData.add(data.getYValue()); } } if (xData != null) { xa.invalidateRange(xData); } if (yData != null) { ya.invalidateRange(yData); } } }
/** * This is called when the range has been invalidated and we need to update it. If the axis are auto * ranging then we compile a list of all data that the given axis has to plot and call invalidateRange() on the * axis passing it that data. */ @Override protected void updateAxisRange() { // For candle stick chart we need to override this method as we need to let the axis know that they need to be able // to cover the whole area occupied by the high to low range not just its center data value final Axis<Number> xa = getXAxis(); final Axis<Number> ya = getYAxis(); List<Number> xData = null; List<Number> yData = null; if (xa.isAutoRanging()) { xData = new ArrayList<>(); } if (ya.isAutoRanging()) { yData = new ArrayList<>(); } if (xData != null || yData != null) { for (XYChart.Series<Number, Number> series : getData()) { for (XYChart.Data<Number, Number> data : series.getData()) { if (xData != null) { xData.add(data.getXValue()); } if (yData != null) { if (data.getExtraValue() instanceof CandleData) { CandleData candleData = (CandleData) data.getExtraValue(); yData.add(candleData.high); yData.add(candleData.low); } else { yData.add(data.getYValue()); } } } } if (xData != null) { xa.invalidateRange(xData); } if (yData != null) { ya.invalidateRange(yData); } } }
private CandleStickChart(CategoryDateAxis xAxis, Axis<Number> yAxis) { super(xAxis, yAxis); _xAxis = xAxis; _yAxis = (NumberAxis) yAxis; setAnimated(false); xAxis.setAnimated(false); yAxis.setAnimated(false); _yAxis.setForceZeroInRange(false); _xAxis.setLabel("Day"); _yAxis.setLabel("Price"); getPlotChildren().addAll(_highMarker, _lowMarker); setTitle("Advance Trader Chart(2014)"); // create crossline this.crossLine = new CrossLine(this, getChildren()); final Node chartBackground = this.lookup(".chart-plot-background"); for (Node n : chartBackground.getParent().getChildrenUnmodifiable()) { if (n != chartBackground && n != _xAxis && n != _yAxis) { n.setMouseTransparent(true); } } this.setOnMouseMoved(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { crossLine.setLayoutXY(event.getX(), event.getY()); } }); }
/** * This is called when the range has been invalidated and we need to update * it. If the axis are auto ranging then we compile a list of all data that * the given axis has to plot and call invalidateRange() on the axis passing * it that data. */ @Override protected void updateAxisRange() { // For candle stick chart we need to override this method as we need to let the axis know that they need to be able // to cover the whole area occupied by the high to low range not just its center data value final Axis<String> xa = getXAxis(); final Axis<Number> ya = getYAxis(); List<String> xData = null; List<Number> yData = null; if (xa.isAutoRanging()) { xData = new ArrayList<String>(); } if (ya.isAutoRanging()) { yData = new ArrayList<Number>(); } if (xData != null || yData != null) { for (XYChart.Series<String, Number> series : getData()) { for (XYChart.Data<String, Number> data : series.getData()) { if (xData != null) { xData.add(data.getXValue()); } if (yData != null) { CandleStickExtraValues extras = (CandleStickExtraValues) data.getExtraValue(); if (extras != null) { yData.add(extras.getHigh()); yData.add(extras.getLow()); } else { yData.add(data.getYValue()); } } } } if (xData != null) { xa.invalidateRange(xData); } if (yData != null) { ya.invalidateRange(yData); } } }
public void layoutPlotChildren(CategoryDateAxis xAxis, Axis<Number> yAxis) { int length = _data.length; ((Path)_node).getElements().clear(); for (int i = 0; i < length; i++) { if (!Double.isNaN(_data[i])) { double x = xAxis.getDisplayPosition(_xAxisLabels.get(i)); double y = yAxis.getDisplayPosition(_data[i]); if (((Path)_node).getElements().isEmpty()) { ((Path)_node).getElements().add(new MoveTo(x, y)); } else { ((Path)_node).getElements().add(new LineTo(x, y)); } } } }
/** * This is called when the range has been invalidated and we need to update it. If the axis are auto * ranging then we compile a list of all data that the given axis has to plot and call invalidateRange() on the * axis passing it that data. */ @Override protected void updateAxisRange() { // For candle stick chart we need to override this method as we need to let the axis know that they need to be able // to cover the whole area occupied by the high to low range not just its center data value final Axis<String> xa = getXAxis(); final Axis<Number> ya = getYAxis(); List<String> xData = null; List<Number> yData = null; if (xa.isAutoRanging()) { xData = new ArrayList<String>(); } if (ya.isAutoRanging()) { yData = new ArrayList<Number>(); } if (xData != null || yData != null) { for (XYChart.Series<String, Number> series : getData()) { for (XYChart.Data<String, Number> data : series.getData()) { if (xData != null) { xData.add(data.getXValue()); } if (yData != null) { CandleStickExtraValues extras = (CandleStickExtraValues) data.getExtraValue(); if (extras != null) { yData.add(extras.getHigh()); yData.add(extras.getLow()); } else { yData.add(data.getYValue()); } } } } if (xData != null) { xa.invalidateRange(xData); } if (yData != null) { ya.invalidateRange(yData); } } }
public ImageChart(Axis<Number> xAxis, Axis<Number> yAxis, ImageRenderer renderer, Runnable onResize) { super(xAxis, yAxis); this.renderer = renderer; setData(FXCollections.<Series<Number,Number>>emptyObservableList()); this.imageView.setPreserveRatio(false); getPlotChildren().add(this.imageView); this.imageView.relocate(0, 0); this.onResize = onResize; }