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;
}
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();
}
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();
}
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();
}
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;
}
Aggregations