Search in sources :

Example 51 with ObservableValue

use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.

the class DynamicImageWidget method Create.

/**
 * @param pane
 * @param dataMgr
 * @return
 */
@Override
public boolean Create(GridPane pane, DataManager dataMgr) {
    SetParent(pane);
    if (setupImages()) {
        ConfigureAlignment();
        for (String key : this._ImageFilenames.keySet()) {
            ImageView obj = _ImageViewMap.get(key);
            basePane.add(obj, 0, 0);
        }
        pane.add(basePane, getColumn(), getRow(), getColumnSpan(), getRowSpan());
        SetupPeekaboo(dataMgr);
        if (_AutoAdvance) {
            if (null == getMinionID() || null == getNamespace()) {
                String ID = Integer.toBinaryString(DynamicImageWidget._AutoAdvanceImageNumber);
                DynamicImageWidget._AutoAdvanceImageNumber++;
                if (null == getMinionID()) {
                    setMinionID(ID);
                }
                if (null == getNamespace()) {
                    setNamespace(ID);
                }
            }
            MarvinTask mt = new MarvinTask();
            mt.AddDataset(getMinionID(), getNamespace(), "Next");
            TASKMAN.AddPostponedTask(mt, _AutoAdvanceInterval);
        }
        if (!_MontorMap.isEmpty()) {
            MarvinTask mt = new MarvinTask();
            mt.AddDataset(getMinionID(), getNamespace(), "Monitor");
            TASKMAN.AddPostponedTask(mt, _MonitorInterval);
        }
        DynamicImageWidget objDynaImg = this;
        dataMgr.AddListener(getMinionID(), getNamespace(), new ChangeListener() {

            @Override
            public void changed(ObservableValue o, Object oldVal, Object newVal) {
                boolean ChangeOcurred = false;
                if (IsPaused()) {
                    return;
                }
                String strVal = newVal.toString().replaceAll("(\\r|\\n)", "");
                String key;
                if (// go to next image in the list
                strVal.equalsIgnoreCase("Next")) {
                    key = _ListID.GetNext();
                } else if (// go to previous image in the list
                strVal.equalsIgnoreCase("Previous")) {
                    key = _ListID.GetPrevious();
                } else if (strVal.equalsIgnoreCase("Monitor")) {
                    ChangeOcurred = MonitorForFilechange();
                    if (ChangeOcurred) {
                        key = _CurrentKey;
                    }
                    key = _CurrentKey;
                    MarvinTask mt = new MarvinTask();
                    mt.AddDataset(getMinionID(), getNamespace(), "Monitor");
                    TASKMAN.AddPostponedTask(mt, _MonitorInterval);
                } else {
                    // expecting an ID
                    key = strVal;
                    // just to keep next/prev alignment
                    _ListID.get(key);
                }
                key = key.toLowerCase();
                if (_ImageFilenames.containsKey(key)) {
                    if (// no reason to re-load if it is already loaded
                    !key.equalsIgnoreCase(_CurrentKey) || ChangeOcurred) {
                        DynamicTransition objTransition = null;
                        ImageView startView = null;
                        ImageView nextView = null;
                        if (_TransitionMap.containsKey(_CurrentKey)) {
                            DynamicTransition objCurrentTransition = _TransitionMap.get(_CurrentKey);
                            if (objCurrentTransition.stillPlaying()) {
                                objCurrentTransition.stopTransition();
                            }
                        }
                        if (_TransitionMap.containsKey(key)) {
                            objTransition = _TransitionMap.get(key);
                            startView = _ImageViewMap.get(_CurrentKey);
                        } else {
                            _ImageViewMap.get(_CurrentKey).setVisible(false);
                        }
                        _CurrentKey = key;
                        if (null != objTransition && null != startView) {
                            nextView = _ImageViewMap.get(_CurrentKey);
                            objTransition.Transition(objDynaImg, startView, nextView);
                        } else {
                            _ImageViewMap.get(_CurrentKey).setVisible(true);
                        }
                    }
                } else {
                    LOGGER.warning("Received unknown ID: [" + strVal + "] for dynamic Image#" + getName() + ": [" + getNamespace() + ":" + getMinionID() + "]");
                    return;
                }
                if (_AutoAdvance) {
                    if (!_AutoLoopWithAdvance && _ListID.IsLast(key)) {
                        _AutoAdvance = false;
                        return;
                    }
                    MarvinTask mt = new MarvinTask();
                    mt.AddDataset(getMinionID(), getNamespace(), "Next");
                    TASKMAN.AddPostponedTask(mt, _AutoAdvanceInterval);
                }
            }
        });
        SetupTaskAction();
        return ApplyCSS();
    }
    return false;
}
Also used : DynamicTransition(kutch.biff.marvin.widget.dynamicgrid.DynamicTransition) ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener) ImageView(javafx.scene.image.ImageView) MarvinTask(kutch.biff.marvin.task.MarvinTask)

Example 52 with ObservableValue

use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.

the class LineChartWidget method Create.

@Override
@SuppressWarnings("unchecked")
public boolean Create(GridPane pane, DataManager dataMgr) {
    SetParent(pane);
    if (getSeries().isEmpty()) {
        if (getyAxisMaxCount() > 0) {
            for (int iLoop = 0; iLoop < getyAxisMaxCount(); iLoop++) {
                SeriesDataSet objDS = new SeriesDataSet(Integer.toString(iLoop), "", "");
                getSeries().add(objDS);
            }
        } else {
            LOGGER.severe("Chart created with no series defined and no count defined for yAxis");
            return false;
        }
    }
    _CreateChart();
    ConfigureDimentions();
    ConfigureAlignment();
    SetupPeekaboo(dataMgr);
    pane.add(getChart(), getColumn(), getRow(), getColumnSpan(), getRowSpan());
    // hmm, only get called if different, that could be a problem for a chart
    dataMgr.AddListener(getMinionID(), getNamespace(), new ChangeListener() {

        @Override
        @SuppressWarnings("unchecked")
        public void changed(ObservableValue o, Object oldVal, Object newVal) {
            if (IsPaused()) {
                return;
            }
            String[] strList = newVal.toString().split(",");
            int iIndex = 0;
            for (String strValue : strList) {
                double newValue;
                try {
                    newValue = Double.parseDouble(strValue);
                } catch (NumberFormatException ex) {
                    LOGGER.severe("Invalid data for Line Chart received: " + strValue);
                    return;
                }
                if (iIndex < getSeries().size()) {
                    SeriesDataSet ds = getSeries().get(iIndex++);
                    ShiftSeries(ds.getSeries(), getxAxisMaxCount());
                    ds.getSeries().getData().add(new XYChart.Data<>(ds.getSeries().getData().size(), newValue));
                } else {
                    LOGGER.severe("Received More datapoints for Line Chart than was defined in application definition file. Received " + Integer.toString(strList.length) + " expecting " + Integer.toString(getSeries().size()));
                    return;
                }
            }
        }
    });
    SetupTaskAction();
    return ApplyCSS();
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener) SeriesDataSet(kutch.biff.marvin.utility.SeriesDataSet)

Example 53 with ObservableValue

use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.

the class LineChartWidget_MS method _CreateMSChart.

/**
 * @param pane
 * @param dataMgr
 * @return
 */
@SuppressWarnings("unchecked")
protected boolean _CreateMSChart(GridPane pane, DataManager dataMgr) {
    _CreateChart();
    ConfigureDimentions();
    ConfigureAlignment();
    SetupPeekaboo(dataMgr);
    ConfigureSynchronizationForMultiSource();
    pane.add(getChart(), getColumn(), getRow(), getColumnSpan(), getRowSpan());
    if (0 == _SeriesOrder.size()) {
        for (SeriesDataSet ds : getSeries()) {
            dataMgr.AddListener(ds.getID(), ds.getNamespace(), new ChangeListener() {

                @Override
                public void changed(ObservableValue o, Object oldVal, Object newVal) {
                    if (IsPaused()) {
                        return;
                    }
                    String strVal = newVal.toString();
                    double newValue = 0;
                    try {
                        newValue = Double.parseDouble(strVal);
                    } catch (Exception ex) {
                        LOGGER.severe("Invalid data for Chart received: " + strVal);
                        return;
                    }
                    OnDataArrived(ds, strVal);
                }
            });
        }
    } else {
        SetupSeriesSets(dataMgr);
    }
    SetupTaskAction();
    return ApplyCSS();
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener) SeriesDataSet(kutch.biff.marvin.utility.SeriesDataSet)

Example 54 with ObservableValue

use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.

the class WebWidget method Create.

@Override
public boolean Create(GridPane pane, DataManager dataMgr) {
    SetParent(pane);
    ConfigureDimentions();
    if (_ReverseContent) {
        _Browser.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
    }
    ConfigureAlignment();
    SetupPeekaboo(dataMgr);
    SetContent(_CurrentContent);
    pane.add(_Browser, getColumn(), getRow(), getColumnSpan(), getRowSpan());
    dataMgr.AddListener(getMinionID(), getNamespace(), new ChangeListener() {

        @Override
        public void changed(ObservableValue o, Object oldVal, Object newVal) {
            if (IsPaused()) {
                return;
            }
            _HackedFile = null;
            SetContent(newVal.toString());
        }
    });
    // check status of loading
    _Browser.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {

        @Override
        public void changed(ObservableValue ov, State oldState, State newState) {
            if (newState == State.FAILED) {
                // browser requires absolute path, so let's try to provide that, in case a relative one was provided
                if ("file:".equalsIgnoreCase(_CurrentContent.substring(0, 5))) {
                    if (_HackedFile == null) {
                        Path currentRelativePath = Paths.get("");
                        String workDir = currentRelativePath.toAbsolutePath().toString() + java.io.File.separator;
                        _HackedFile = _CurrentContent;
                        _CurrentContent = "file:" + workDir + _CurrentContent.substring(5);
                        SetContent(_CurrentContent);
                        return;
                    }
                    _CurrentContent = _HackedFile;
                }
                LOGGER.info("Error loading web widget content: " + _CurrentContent);
            }
        }
    });
    SetupTaskAction();
    return ApplyCSS();
}
Also used : Path(java.nio.file.Path) State(javafx.concurrent.Worker.State) ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener)

Example 55 with ObservableValue

use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.

the class BarGaugeWidget method Create.

@Override
public boolean Create(GridPane pane, DataManager dataMgr) {
    SetParent(pane);
    if (false == SetupGauge()) {
        return false;
    }
    _Gauge.setValue(_InitialValue);
    ConfigureAlignment();
    SetupPeekaboo(dataMgr);
    ConfigureDimentions();
    pane.add(_Gauge, getColumn(), getRow(), getColumnSpan(), getRowSpan());
    dataMgr.AddListener(getMinionID(), getNamespace(), new ChangeListener() {

        @Override
        public void changed(ObservableValue o, Object oldVal, Object newVal) {
            if (IsPaused()) {
                return;
            }
            double newDialValue = 0;
            String strVal = newVal.toString();
            try {
                newDialValue = Double.parseDouble(strVal);
            } catch (NumberFormatException ex) {
                LOGGER.info("Ignoring invalid data for BarGauge received: " + strVal);
                return;
            }
            _Gauge.setValue(newDialValue);
        }
    });
    return true;
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener)

Aggregations

ObservableValue (javafx.beans.value.ObservableValue)85 ChangeListener (javafx.beans.value.ChangeListener)53 FXML (javafx.fxml.FXML)13 Scene (javafx.scene.Scene)13 ImageView (javafx.scene.image.ImageView)13 KeyEvent (javafx.scene.input.KeyEvent)11 ArrayList (java.util.ArrayList)10 Label (javafx.scene.control.Label)10 TableColumn (javafx.scene.control.TableColumn)10 TableView (javafx.scene.control.TableView)10 ActionEvent (javafx.event.ActionEvent)9 MouseEvent (javafx.scene.input.MouseEvent)9 TextField (javafx.scene.control.TextField)8 Color (javafx.scene.paint.Color)8 ObservableList (javafx.collections.ObservableList)7 MenuItem (javafx.scene.control.MenuItem)7 CellDataFeatures (javafx.scene.control.TableColumn.CellDataFeatures)7 List (java.util.List)6 Set (java.util.Set)6 Platform (javafx.application.Platform)6