Java 类javafx.scene.chart.XYChart.Data 实例源码

项目:marathonv5    文件:ChartActions.java   
public static void addDataItemStrNum(final XYChart<String, Number> chart) {
    if (chart.getData() == null) {
        chart.setData(FXCollections.<XYChart.Series<String, Number>>observableArrayList());
    }
    if (chart.getData().isEmpty()) {
        chart.getData().add(new XYChart.Series<String, Number>());
    }

    int sIndex = (int) (Math.random() * chart.getData().size());
    XYChart.Series<String, Number> series = chart.getData().get(sIndex);

    Set<String> existingYears = new HashSet<String>();
    for (Data<String, Number> data : series.getData()) {
        existingYears.add(data.getXValue());
    }

    int randomYear = 1900 + (int) (Math.round(12 * Math.random()) * 10);
    while (existingYears.contains(Integer.toString(randomYear))) {
        randomYear++;
    }
    series.getData().add(new XYChart.Data<String, Number>(Integer.toString(randomYear), 10 + (Math.random() * 3800)));
}
项目:marathonv5    文件:ChartActions.java   
public static void addDataItemNumStr(final XYChart<Number, String> chart) {
    if (chart.getData() == null) {
        chart.setData(FXCollections.<XYChart.Series<Number, String>>observableArrayList());
    }
    if (chart.getData().isEmpty()) {
        chart.getData().add(new XYChart.Series<Number, String>());
    }

    int sIndex = (int) (Math.random() * chart.getData().size());
    XYChart.Series<Number, String> series = chart.getData().get(sIndex);

    Set<String> existingYears = new HashSet<String>();
    for (Data<Number, String> data : series.getData()) {
        existingYears.add(data.getYValue());
    }

    int randomYear = 1900 + (int) (Math.round(12 * Math.random()) * 10);
    while (existingYears.contains(Integer.toString(randomYear))) {
        randomYear++;
    }
    series.getData().add(new XYChart.Data<Number, String>(10 + (Math.random() * 3800), Integer.toString(randomYear)));
}
项目:marathonv5    文件:ChartActions.java   
public static void addDataItemStrNum(final XYChart<String, Number> chart) {
    if (chart.getData() == null) {
        chart.setData(FXCollections.<XYChart.Series<String, Number>>observableArrayList());
    }
    if (chart.getData().isEmpty()) {
        chart.getData().add(new XYChart.Series<String, Number>());
    }

    int sIndex = (int) (Math.random() * chart.getData().size());
    XYChart.Series<String, Number> series = chart.getData().get(sIndex);

    Set<String> existingYears = new HashSet<String>();
    for (Data<String, Number> data : series.getData()) {
        existingYears.add(data.getXValue());
    }

    int randomYear = 1900 + (int) (Math.round(12 * Math.random()) * 10);
    while (existingYears.contains(Integer.toString(randomYear))) {
        randomYear++;
    }
    series.getData().add(new XYChart.Data<String, Number>(Integer.toString(randomYear), 10 + (Math.random() * 3800)));
}
项目:marathonv5    文件:ChartActions.java   
public static void addDataItemNumStr(final XYChart<Number, String> chart) {
    if (chart.getData() == null) {
        chart.setData(FXCollections.<XYChart.Series<Number, String>>observableArrayList());
    }
    if (chart.getData().isEmpty()) {
        chart.getData().add(new XYChart.Series<Number, String>());
    }

    int sIndex = (int) (Math.random() * chart.getData().size());
    XYChart.Series<Number, String> series = chart.getData().get(sIndex);

    Set<String> existingYears = new HashSet<String>();
    for (Data<Number, String> data : series.getData()) {
        existingYears.add(data.getYValue());
    }

    int randomYear = 1900 + (int) (Math.round(12 * Math.random()) * 10);
    while (existingYears.contains(Integer.toString(randomYear))) {
        randomYear++;
    }
    series.getData().add(new XYChart.Data<Number, String>(10 + (Math.random() * 3800), Integer.toString(randomYear)));
}
项目:java-ml-projects    文件:Clustering.java   
private void swapClusteredChartSeriesColors() {
    List<Series<Number, Number>> clusteredSeries = new ArrayList<>();
    // we have to copy the original data to swap the series
    clusteredChart.getData().forEach(serie -> {
        Series<Number, Number> series = new Series<>();
        series.setName(serie.getName());
        serie.getData().stream().map(d -> new Data<Number, Number>(d.getXValue(), d.getYValue()))
                .forEach(series.getData()::add);
        clusteredSeries.add(series);
    });
    int i = swapColorsCombinations[swapIndex][0];
    int j = swapColorsCombinations[swapIndex][1];
    Collections.swap(clusteredSeries, i, j);
    clusteredChart.getData().clear();
    clusteredChart.getData().addAll(clusteredSeries);
    swapIndex = swapIndex == NUMBER_OF_CLASSES - 1 ? 0 : swapIndex + 1;
}
项目:FlashLib    文件:AreaChartControl.java   
@Override
public void newData(byte[] data) {
    if(data[0] == FlashboardXYChart.VALUE_UPDATE){
        synchronized (dataCollection) {
            double x = FlashUtil.toDouble(data, 1);
            double y = FlashUtil.toDouble(data, 9);

            dataCollection.add(new Data<Number, Number>(x, y));
        }
    }
    if(data[0] == FlashboardXYChart.CONFIG_UPDATE){
        synchronized (configMutex) {
            minX = FlashUtil.toDouble(data, 1);
            maxX = FlashUtil.toDouble(data, 9);
            minY = FlashUtil.toDouble(data, 17);
            maxY = FlashUtil.toDouble(data, 25);
            configUpdate = true;
        }
    }
}
项目:FlashLib    文件:BarChartControl.java   
@Override
protected void update() {
    synchronized (configMutex) {
        if(configUpdate){
            configUpdate = false;

            axisY.setUpperBound(maxY);
            axisY.setLowerBound(minY);
        }
    }

    Enumeration<BarChartSeriesControl> controlEnum = controls.elements();
    while(controlEnum.hasMoreElements()){
        BarChartSeriesControl control = controlEnum.nextElement();

        if(control.hasData()){
            double dataY = Mathf.roundDecimal(control.getData());
            Data<String, Number> data = new Data<String, Number>(control.getName(), dataY);

            //chart.setTitle(getName()+": "+dataY);
            chartSeries.getData().add(data);
            ((StackPane)data.getNode()).getChildren().add(new Label(String.valueOf(dataY)));
        }
    }
}
项目:FlashLib    文件:LineChartControl.java   
@Override
public void newData(byte[] data) {
    if(data[0] == FlashboardXYChart.VALUE_UPDATE){
        synchronized (dataCollection) {
            double x = FlashUtil.toDouble(data, 1);
            double y = FlashUtil.toDouble(data, 9);

            dataCollection.add(new Data<Number, Number>(x, y));
        }
    }
    if(data[0] == FlashboardXYChart.CONFIG_UPDATE){
        synchronized (configMutex) {
            minX = FlashUtil.toDouble(data, 1);
            maxX = FlashUtil.toDouble(data, 9);
            minY = FlashUtil.toDouble(data, 17);
            maxY = FlashUtil.toDouble(data, 25);
            configUpdate = true;
        }
    }
}
项目:Java-oscilloscope-project    文件:ZoomManager.java   
static <X, Y> ObservableList<XYChart.Data<X, Y>> deepCopySeriesData(
        final Collection<? extends XYChart.Data<X, Y>> data) {
    final ObservableList<XYChart.Data<X, Y>> result = FXCollections.observableArrayList();
    for (final Data<X, Y> i : data) {
        result.add(new Data<>(i.getXValue(), i.getYValue()));
    }
    return result;
}
项目:javafx-chart-zooming    文件:ZoomManager.java   
static <X, Y> ObservableList<XYChart.Data<X, Y>> deepCopySeriesData(
        final Collection<? extends XYChart.Data<X, Y>> data) {
    final ObservableList<XYChart.Data<X, Y>> result = FXCollections.observableArrayList();
    for (final Data<X, Y> i : data) {
        result.add(new Data<>(i.getXValue(), i.getYValue()));
    }
    return result;
}
项目:Gargoyle    文件:BaseGoogleTrendAdapter.java   
@Override
public Data<String, Number> getValue(int columnIndex, String columnName, int row) {
    Map<String, List<Map<String, String>>> map = this.rows.get().get(row);
    List<Map<String, String>> list = map.get("c");
    Map<String, String> dateInfo = list.get(0);

    Map<String, String> query = list.get(columnIndex + 1);
    if (query == null)
        return null;

    String colName = dateInfo.get("f");
    String value = query.get("f");
    if (colName == null || value == null)
        return null;
    Integer valueOf = Integer.valueOf(value, 10);
    return new Data<>(colName, valueOf);
}
项目:Gargoyle    文件:SliderLineChartComposite.java   
@FXML
public void initialize() {
    items.addListener(this);
    //      chart.getData().add(chartSeries);

    slider.setMin(0D);
    slider.setMax(displaySize.get());
    this.displaySize.bind(slider.maxProperty());

    slider.valueProperty().addListener((oba, oldval, newval) -> {

        int start = newval.intValue();
        int end = (int) (start + displaySize.get());
        if (end > items.size())
            end = items.size();
        ObservableList<Data<String, Number>> subList = items.stream().skip(start).limit(5).map(v -> converter.apply(v))
                .collect(FxCollectors.toObservableList());
        Series<String, Number> chartSeries = new Series<>("", subList);
        chart.getData().remove(0);
        chart.getData().add(chartSeries);

    });
}
项目:Gargoyle    文件:SVNViewer.java   
private void setDataNode(SVNLogEntry entry, Data<String, String> data) {

        Group group = new Group();
        group.setManaged(false);
        Text value = new Text(entry.getRevision() + "");
        value.setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT);
        value.translateYProperty().set(-15);
        Circle circle = new Circle(4, Color.WHITE);
        circle.setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT);
        circle.setStroke(Color.web("#f3622d"));
        StackPane stackPane = new StackPane(value, circle);
        stackPane.setPrefSize(30, 60);
        group.getChildren().add(stackPane);
        data.setNode(group);

    }
项目:Gargoyle    文件:PMDViolationFilebyLineChartComposite.java   
@Override
    public void seriesLegendLabelCustomAction(Data t, Node u) {

//      u.setOnMouseEntered(ev -> {
//          u.setCursor(Cursor.HAND);
//      });
//
//      u.setOnMouseExited(ev -> {
//          u.setCursor(Cursor.DEFAULT);
//      });
//
//      u.setOnMouseClicked(ev -> {
//
//          ListView<RuleViolation> lvViolation = this.checkedListComposite.getLvViolation();
//          ObservableList<RuleViolation> items = lvViolation.getItems();
//          ObservableList<RuleViolation> violationList = this.checkedListComposite.getViolationList();
//          List<RuleViolation> collect = violationList.stream().filter(ruleViolationFilter())
//                  .filter(v -> ValueUtil.equals(t.getName(), ValueUtil.getSimpleFileName(v.getFilename()))).collect(Collectors.toList());
//          items.setAll(collect);
//
//      });

    }
项目:Lernkartei    文件:Diagramm.java   
public static ObservableList<XYChart.Series<String, Number>> getChartData()
{
    Debugger.out("Diagramm getChartData says : Hello ! ");
        if (Data != null || Data.get(0).equals(null))
        {
            resetData();
        } else
        {
            Logger.out("ObservableList Data in Diagramm is already empty");
        }

        getKarteien();
        getPunkte();

        for (int i = 0; i < Stacks.size(); i++)
        {
            Series<String, Number> thisSerie = new Series<String, Number>();
            thisSerie.setName(Stacks.get(i));
            Number forChart = (Number) Punkte.get(i);
            thisSerie.getData().add(new Data<String, Number>(Stacks.get(i), forChart));
            Data.add(thisSerie);
        }
    return Data;
}
项目:Map-Projections    文件:MapPlotter.java   
private static void plotProjections(ScatterChart<Number, Number> chart,
        AnchorPane overlay, List<Label> labels, List<Data<Number,Number>> data,
        Projection[] projections, String name, double[][][] points) {
    final Series<Number, Number> series = new Series<Number, Number>();
    series.setName(name);

    for (Projection projection: projections) {
        System.out.print(projection+": ");
        final double[] params = projection.getDefaultParameters();
        final double distortion[] = projection.avgDistortion(points, params);
        final Data<Number, Number> datum = new Data<Number, Number>(
                distortion[0]/DECIBEL, distortion[1]/DECIBEL);
        series.getData().add(datum);
        final Label lbl = new Label(projection.getName());
        overlay.getChildren().add(lbl);
        labels.add(lbl);
        data.add(datum);
        System.out.println(distortion[0]+", "+distortion[1]);
    }

    chart.getData().add(series);
}
项目:Map-Projections    文件:MapPlotter.java   
private void drawLabelsAndSave(ScatterChart<Number,Number> chart,
        List<Label> labels, List<Data<Number,Number>> data) {
    for (int i = 0; i < labels.size(); i ++) {
        AnchorPane.setLeftAnchor(labels.get(i),
                chart.getXAxis().localToParent(chart.getXAxis().getDisplayPosition(data.get(i).getXValue()), 0).getX() + chart.getPadding().getLeft() + 3);
        AnchorPane.setTopAnchor(labels.get(i),
                chart.getYAxis().localToParent(0, chart.getYAxis().getDisplayPosition(data.get(i).getYValue())).getY() + chart.getPadding().getTop() - labels.get(i).getHeight()
                );
    }
    Platform.runLater(() -> {
            try {
                ImageIO.write(
                        SwingFXUtils.fromFXImage(stack.snapshot(null, null), null),
                        "png", new File("output/graph - plotter.png"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
}
项目:SurePulseDataProcessor    文件:TrimDataController.java   
public void updateExpectedPulse(){

    chart.getData().remove(expectedPulseSeries);
    if(showExpectedIncidentPulseCheckBox.isSelected() && getActivatedData() instanceof IncidentPulse && strikerBar.isValid() && barSetup != null){
        IncidentPulse pulse = (IncidentPulse)getActivatedData();
        expectedPulseSeries = new XYChart.Series<Number, Number>();
        expectedPulseSeries.setName("Expected Incident Pulse");
        ArrayList<Data<Number, Number>> expectedPulseDataPoints = new ArrayList<Data<Number, Number>>();
        int begin = getChartBeginIndex();
        int end = getChartEndIndex();
        int totalDataPoints = end - begin;
        double[] xData = getActivatedData().Data.timeData;
        xData = Arrays.stream(xData).map(x -> x * timeUnits.getMultiplier()).toArray();
        for (int i = begin; i <= end; i++) {
            int sign = isCompressionSample ? -1 : 1;
            if (i >= getActivatedData().getBegin() && i <= getActivatedData().getEnd()) {
                expectedPulseDataPoints
                        .add(new Data<Number, Number>(xData[i], sign * barSetup.IncidentBar.getExpectedPulse(strikerBar,pulse.strainGauge)) );
            }
            i += totalDataPoints / dataPointsToShow;
        }
        expectedPulseSeries.getData().addAll(expectedPulseDataPoints);
        chart.getData().add(expectedPulseSeries);
    }
}
项目:SurePulseDataProcessor    文件:TrimDataController.java   
private void setReflectedBeginFromIncidentAndBarSetup(){
    int incidentCount = 0;
    IncidentPulse incidentPulse = null;
    for(DataSubset sub : DataFiles.getAllDatasets()){
        if(sub instanceof IncidentPulse){
            incidentCount++;
            incidentPulse = (IncidentPulse)sub;
        }
    }
    if(incidentCount != 1){
        Dialogs.showAlert("There must be 1 incident pulse.", stage);
        return;
    }
    ReflectedPulse reflectedPulse = (ReflectedPulse)getActivatedData();


    double beginIncidentTime = incidentPulse.Data.timeData[incidentPulse.getBegin()];
    double IncidWaveSpeed = barSetup.IncidentBar.getWaveSpeed();
    double timeToTravel = incidentPulse.strainGauge.distanceToSample / IncidWaveSpeed + 
            reflectedPulse.strainGauge.distanceToSample / IncidWaveSpeed; //distances to sample are the same. Same SG
    reflectedPulse.setBeginFromTimeValue(beginIncidentTime + timeToTravel);
    updateChart();
}
项目:HdrHistogramVisualizer    文件:HistogramAccumulator.java   
@Override
List<Data<Number, Number>> getPercentileData(int percentileOutputTicksPerHalf,
                                             DoubleUnaryOperator xConversion,
                                             DoubleUnaryOperator yConversion) {

    DoublePercentileIterator percentileIterator = new DoublePercentileIterator(
            accumulatedHistogram,
            percentileOutputTicksPerHalf);

    List<Data<Number, Number>> percentileData = new ArrayList<>(512);

    while (percentileIterator.hasNext()) {
        DoubleHistogramIterationValue value = percentileIterator.next();

        final double x = xConversion.applyAsDouble(value.getPercentileLevelIteratedTo());
        final double y = yConversion.applyAsDouble(value.getValueIteratedTo());

        if (Double.isInfinite(x))
            break;

        percentileData.add(new Data<>(x, y));
    }

    return percentileData;
}
项目:HdrHistogramVisualizer    文件:HistogramAccumulator.java   
@Override
List<Data<Number, Number>> getPercentileData(int percentileOutputTicksPerHalf,
                                             DoubleUnaryOperator xConversion,
                                             DoubleUnaryOperator yConversion) {
    PercentileIterator percentileIterator = new PercentileIterator(
            accumulatedHistogram,
            percentileOutputTicksPerHalf);

    List<Data<Number, Number>> percentileData = new ArrayList<>(512);

    while (percentileIterator.hasNext()) {
        HistogramIterationValue value = percentileIterator.next();

        final double x = xConversion.applyAsDouble(value.getPercentileLevelIteratedTo());
        final double y = yConversion.applyAsDouble(value.getValueIteratedTo());

        if (Double.isInfinite(x))
            break;

        percentileData.add(new Data<>(x, y));
    }

    return percentileData;
}
项目:RaspberryPiBeaconParser    文件:PlotBatteryRSSI.java   
public static void main(String[] args) throws Exception {
   String destinationName = "rawHeartbeatEvents_60";
   // Local connection
   Properties props = new Properties();
   props.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jms.jndi.JmsInitialContextFactory");
   props.setProperty("connectionfactory.myFactoryLookup", "amqp://192.168.1.107:5672");
   Context context = new InitialContext(props);
   ConnectionFactory factory = (ConnectionFactory) context.lookup("myFactoryLookup");
   Connection connection = factory.createConnection("guest", "guest");
   connection.start();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   System.out.printf("Connected to broker\n");
   Queue destination = session.createQueue(destinationName);
   List<Data<Long, Integer>> data = browseData(session, destination);
   RSSIChart.run(args, data);
   session.close();
   connection.close();
}
项目:RaspberryPiBeaconParser    文件:PlotBatteryRSSI.java   
private static List<Data<Long, Integer>> browseData(Session session, Queue destination) throws JMSException {
   List<Data<Long, Integer>> data = new ArrayList<>();
   QueueBrowser browser = session.createBrowser(destination);
   Enumeration<Message> msgs = browser.getEnumeration();
   Long minTime = Long.MAX_VALUE;
   Long maxTime = Long.MIN_VALUE;
   while (msgs.hasMoreElements()) {
      Message msg = msgs.nextElement();
      Integer rssi = msg.getIntProperty("rssi");
      Long time = msg.getLongProperty("time");
      minTime = Math.min(minTime, time);
      maxTime = Math.max(maxTime, time);
      data.add(new Data<>(time, rssi));
   }
   browser.close();
   long duration = maxTime - minTime;
   long hours = duration / (3600*1000);
   double days = hours / 24.0;
   System.out.printf("minTime=%s, maxTime=%s, hours=%d, days=%.2f\n", minTime, maxTime, hours, days);
   return data;
}
项目:kotlinfx-ensemble    文件:ChartActions.java   
public static void addDataItemStrNum(final XYChart<String, Number> chart) {
    if (chart.getData() == null) {
        chart.setData(FXCollections.<XYChart.Series<String, Number>>observableArrayList());
    }
    if (chart.getData().isEmpty()) {
        chart.getData().add(new XYChart.Series<String, Number>());
    }

    int sIndex = (int) (Math.random() * chart.getData().size());
    XYChart.Series<String, Number> series = chart.getData().get(sIndex);

    Set<String> existingYears = new HashSet<String>();
    for (Data<String, Number> data : series.getData()) {
        existingYears.add(data.getXValue());
    }

    int randomYear = 1900 + (int) (Math.round(12 * Math.random()) * 10);
    while (existingYears.contains(Integer.toString(randomYear))) {
        randomYear++;
    }
    series.getData().add(new XYChart.Data<String, Number>(Integer.toString(randomYear), 10 + (Math.random() * 3800)));
}
项目:kotlinfx-ensemble    文件:ChartActions.java   
public static void addDataItemNumStr(final XYChart<Number, String> chart) {
    if (chart.getData() == null) {
        chart.setData(FXCollections.<XYChart.Series<Number, String>>observableArrayList());
    }
    if (chart.getData().isEmpty()) {
        chart.getData().add(new XYChart.Series<Number, String>());
    }

    int sIndex = (int) (Math.random() * chart.getData().size());
    XYChart.Series<Number, String> series = chart.getData().get(sIndex);

    Set<String> existingYears = new HashSet<String>();
    for (Data<Number, String> data : series.getData()) {
        existingYears.add(data.getYValue());
    }

    int randomYear = 1900 + (int) (Math.round(12 * Math.random()) * 10);
    while (existingYears.contains(Integer.toString(randomYear))) {
        randomYear++;
    }
    series.getData().add(new XYChart.Data<Number, String>(10 + (Math.random() * 3800), Integer.toString(randomYear)));
}
项目:lizard-enclosure    文件:SensorReadingsVisualizer.java   
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);
}
项目:JacpFX-misc    文件:ContactChartViewComponent.java   
@Override
public Node postHandle(final Node node,
        final Message<Event, Object> message) throws Exception {
    if (message.getMessageBody() instanceof BarChartAction) {
        if (BarChartAction.RESET.equals(message.getMessageBody())) {
            this.clearChartPane();
        }
    }
    if (message.getMessageBody() instanceof Contact) {
        final Contact contact = (Contact) message.getMessageBody();
        this.refreshChartPane(contact);
        final List<Data<String, Number>> data = contact.getDto()
                .getSeriesOneData();
        this.addData(this.series1, data);
        this.addData(this.series2, contact.getDto().getSeriesTwoData());
        this.addData(this.series3, contact.getDto().getSeriesThreeData());
        this.addData(this.series4, contact.getDto().getSeriesFourData());

    } 
    return this.root;
}
项目:lizard-enclosure    文件:SensorReadingsVisualizer.java   
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);
}
项目:Lernkartei_2017    文件:Diagramm.java   
public static ObservableList<XYChart.Series<String, Number>> getChartData()
{
    Debugger.out("Diagramm getChartData says : Hello ! ");
        if (Data != null || Data.get(0).equals(null))
        {
            resetData();
        } else
        {
            Logger.out("ObservableList Data in Diagramm is already empty");
        }

        getKarteien();
        getPunkte();

        for (int i = 0; i < Stacks.size(); i++)
        {
            Series<String, Number> thisSerie = new Series<String, Number>();
            thisSerie.setName(Stacks.get(i));
            Number forChart = (Number) Punkte.get(i);
            thisSerie.getData().add(new Data<String, Number>(Stacks.get(i), forChart));
            Data.add(thisSerie);
        }
    return Data;
}
项目:Lernkartei_2017    文件:Diagramm.java   
public static Boolean resetData()
{
    Data.clear();
    Stacks.clear();
    Punkte.clear();
    return true;
}
项目:mokka7    文件:ChartDataItem.java   
public void create(long time) {

        if (list.size() >= maxHistory.get()) {
            list.remove(0, list.size() - maxHistory.get());
        }
        value.set(readValue());
        list.add(new Data<Number, Number>(time, value.get()));
    }
项目:Java-oscilloscope-project    文件:ZoomManager.java   
static <X, Y> ObservableList<X> extractXValues(final ObservableList<Data<X, Y>> data) {
    final ObservableList<X> result = FXCollections.observableArrayList();
    for (final Data<X, Y> d : data) {
        result.add(d.getXValue());
    }
    return result;
}
项目:Java-oscilloscope-project    文件:ZoomManager.java   
static <X, Y> ObservableList<Y> extractYValues(final ObservableList<Data<X, Y>> data) {
    final ObservableList<Y> result = FXCollections.observableArrayList();
    for (final Data<X, Y> d : data) {
        result.add(d.getYValue());
    }
    return result;
}
项目:Java-oscilloscope-project    文件:ZoomManager.java   
private void doZoom(final boolean x, final Number n1, final Number n2) {
    final double min = Math.min(n1.doubleValue(), n2.doubleValue());
    final double max = Math.max(n1.doubleValue(), n2.doubleValue());
    if (max - min > 1) {
        zoomed = true;
        final Iterator<XYChart.Series<X, Y>> it = chart.getData().iterator();
        while (it.hasNext()) {
            final XYChart.Series<X, Y> s = it.next();
            final Iterator<XYChart.Data<X, Y>> it2 = s.getData().iterator();
            while (it2.hasNext()) {
                final XYChart.Data<X, Y> d = it2.next();
                final Object value;
                if (x) {
                    value = d.getXValue();
                } else {
                    value = d.getYValue();
                }
                if (value instanceof Number) {
                    final Number n = (Number) value;
                    final double dd = n.doubleValue();
                    if (dd < min || dd > max) {
                        it2.remove();
                    } else {
                    }
                }
                if (s.getData().isEmpty()) {
                    it.remove();
                }
            }
        }
    } else {
        // System.out.println("Skip tiny zoom");
    }

}
项目:Java-oscilloscope-project    文件:ZoomManager.java   
private void doZoom(final boolean x, String s1, String s2) {
    if (s1 == null && s2 == null) {
        return;
    }
    if (s1 == null) {
        s1 = s2;
    }
    if (s2 == null) {
        s2 = s1;
    }

    final Iterator<XYChart.Series<X, Y>> it = chart.getData().iterator();
    while (it.hasNext()) {
        final XYChart.Series<X, Y> s = it.next();
        final List<?> values;
        if (x) {
            values = extractXValues(s.getData());
        } else {
            values = extractYValues(s.getData());
        }
        final int index1 = values.indexOf(s1);
        final int index2 = values.indexOf(s2);
        final int lower = Math.min(index1, index2);
        final int upper = Math.max(index1, index2);
        final Iterator<Data<X, Y>> it2 = s.getData().iterator();
        while (it2.hasNext()) {
            final Data<X, Y> d = it2.next();
            final Object value;
            if (x) {
                value = d.getXValue();
            } else {
                value = d.getYValue();
            }
            final int index = values.indexOf(value);
            if (index != -1 && (index < lower || index > upper)) {
                it2.remove();
            }
        }
    }
}
项目:can4eve    文件:JFXCanValueHistoryPlot.java   
/**
 * update the given chart Series
 * @param series - the series to update
 * @param canProperty - the canvalue to take the data from
 */
@SuppressWarnings("rawtypes")
public void updateSeries(XYChart.Series<Number, Number> series, CANProperty canProperty) {
  CircularFifoQueue<?> history = canProperty.getCanValue().getHistory();
  if (debug)
    LOGGER.log(Level.INFO,
      "plotting for " + history.size() + " history values of " + canProperty.getCanValue().canInfo.getTitle());
  Date first=null;
  ObservableList<Data<Number, Number>> dataList = series.getData();
  // FIXME - full redraw?
  dataList.clear();
  for (Object historyValueObject : history) {
    ValueItem<?>historyValue = (ValueItem<?>) historyValueObject;

    Date timeStamp=historyValue.getTimeStamp();
    if (first==null)
      first=timeStamp;
    Double value;
    if (historyValue.getValue() instanceof Integer) {
      // http://stackoverflow.com/questions/31860761/maven-compile-error-with-using-java-generics
      int intValue=(Integer) historyValue.getValue();
      value = new Double(intValue*1.0);
    } else {
      value = (Double) historyValue.getValue();
    }
    long minute = getMinute(timeStamp,first);
    Data<Number, Number> chartData = new XYChart.Data<Number,Number>(minute,value);
    dataList.add(chartData);
  }
}
项目:can4eve    文件:JFXCanCellStatePlot.java   
/**
 * update the series
 * 
 * @param series
 * @param cellValues
 */
private void updateSeries(Series<String, Number> series,
    CANProperty<DoubleValue, Double> cellValues) {
  DoubleValue cellDoubleValues = cellValues.getCanValue();
  if (cellDoubleValues.getMax()==null || cellDoubleValues.getMin()==null) {
    return;
  }

  List<CANValueItem<Double>> valueItems = cellDoubleValues.getValueItems();
  ObservableList<Data<String, Number>> seriesData = series.getData();
  if (debug) {
    CANInfo canInfo = cellValues.getCANInfo();
    LOGGER.log(Level.INFO, "plotting for " + canInfo.getMaxIndex()
        + " values of " + canInfo.getTitle());
  }
  int i = 0;
  yAxis.setAutoRanging(false);
  yAxis.setLowerBound(cellDoubleValues.getMin()-rangeExtra);
  yAxis.setUpperBound(cellDoubleValues.getMax()+rangeExtra);
  yAxis.setTickUnit(this.tickUnit);
  for (CANValueItem<Double> valueItem : valueItems) {
    if (valueItem.isAvailable()) {
      Double value = valueItem.getValue();
      if (seriesData.size() > i) {
        Data<String, Number> seriesEntry = seriesData.get(i);
        seriesEntry.setYValue(value);
      } else {
        String cellnum = "" + (i+1);
        seriesData.add(
            new XYChart.Data<String, Number>(cellnum, value));
      } // if seriesEntry exists
    } // if available
    i++;
  } // for

}
项目:javafx-chart-zooming    文件:ZoomManager.java   
static <X, Y> ObservableList<X> extractXValues(final ObservableList<Data<X, Y>> data) {
    final ObservableList<X> result = FXCollections.observableArrayList();
    for (final Data<X, Y> d : data) {
        result.add(d.getXValue());
    }
    return result;
}
项目:javafx-chart-zooming    文件:ZoomManager.java   
static <X, Y> ObservableList<Y> extractYValues(final ObservableList<Data<X, Y>> data) {
    final ObservableList<Y> result = FXCollections.observableArrayList();
    for (final Data<X, Y> d : data) {
        result.add(d.getYValue());
    }
    return result;
}
项目:javafx-chart-zooming    文件:ZoomManager.java   
private void doZoom(final boolean x, final Number n1, final Number n2) {
    final double min = Math.min(n1.doubleValue(), n2.doubleValue());
    final double max = Math.max(n1.doubleValue(), n2.doubleValue());
    if (max - min > 1) {
        zoomed = true;
        final Iterator<XYChart.Series<X, Y>> it = chart.getData().iterator();
        while (it.hasNext()) {
            final XYChart.Series<X, Y> s = it.next();
            final Iterator<XYChart.Data<X, Y>> it2 = s.getData().iterator();
            while (it2.hasNext()) {
                final XYChart.Data<X, Y> d = it2.next();
                final Object value;
                if (x) {
                    value = d.getXValue();
                } else {
                    value = d.getYValue();
                }
                if (value instanceof Number) {
                    final Number n = (Number) value;
                    final double dd = n.doubleValue();
                    if (dd < min || dd > max) {
                        it2.remove();
                    } else {
                    }
                }
                if (s.getData().isEmpty()) {
                    it.remove();
                }
            }
        }
    } else {
        // System.out.println("Skip tiny zoom");
    }

}