Java Code Examples for javafx.scene.chart.Axis#invalidateRange()

The following examples show how to use javafx.scene.chart.Axis#invalidateRange() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdvCandleStickChartSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 2
Source File: AdvCandleStickChartSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 3
Source File: VolumeChart.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@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);
        }
    }
}
 
Example 4
Source File: CandleStickChart.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 5
Source File: TimelineChart.java    From constellation with Apache License 2.0 4 votes vote down vote up
/**
 * 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() {
    //THIS IS ONE EPIC DIRTY FIX FOR A WEIRD BUG IN JAVAFX!!
    // turning axis.autoranging to false causes immense lag. but this method
    // needs it to be false... so we set it to false
    // then run this method once and set it to true then never run this method again. It seems to work.
    if (!firstaxisUpdate) {
        firstaxisUpdate = true;
        final Axis<Number> xa = getXAxis();
        final Axis<Number> ya = getYAxis();
        List<Number> xData = null;
        List<Number> yData = null;

        shiftYAxis = this.getHeight() - yAxis.getHeight();

        if (xa.isAutoRanging()) {
            xData = new ArrayList<>();
        }
        if (ya.isAutoRanging()) {
            yData = new ArrayList<>();
        }
        if (xData != null || yData != null) {
            ObservableList<XYChart.Series<Number, Number>> list = getData();
            if (list != null) {
                for (Series<Number, Number> series : list) {
                    for (Data<Number, Number> data : series.getData()) {
                        if (xData != null) {
                            xData.add(data.getXValue());
                        }
                        if (yData != null && data.getExtraValue() instanceof Interaction) {
                            final Interaction intr = (Interaction) data.getExtraValue();
                            if (intr != null) {
                                yData.add(intr.getTopVertex().getDisplayPos());
                                yData.add(intr.getBottomVertex().getDisplayPos());
                            } else {
                                yData.add(data.getYValue());
                            }
                        }
                    }
                }
            }
            if (xData != null) {
                xa.invalidateRange(xData);
            }
            if (yData != null) {
                ya.invalidateRange(yData);
            }
        }
        this.xAxis.setAutoRanging(true);
        this.yAxis.setAutoRanging(true);
    }
}