use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.
the class SteelLedBarGraphWidget method Create.
@Override
public boolean Create(GridPane pane, DataManager dataMgr) {
SetParent(pane);
if (false == SetupBarGraph()) {
return false;
}
_Pane.getChildren().add(_BarGraph);
ConfigureAlignment();
SetupPeekaboo(dataMgr);
pane.add(_BarGraph, getColumn(), getRow(), getColumnSpan(), getRowSpan());
// pane.add(_Pane, getColumn(), getRow(),getRowSpan(),getColumnSpan());
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.severe("Invalid data for LED received: " + strVal);
return;
}
if (newDialValue == 0) {
_BarGraph.setValue(newDialValue);
return;
}
if (newDialValue != 100.0) {
while (newDialValue >= 100) {
newDialValue /= 10.0;
}
}
newDialValue /= 100.0001;
_BarGraph.setValue(newDialValue);
}
});
SetupTaskAction();
return ApplyCSS();
}
use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.
the class TextWidget method Create.
@Override
public boolean Create(GridPane pane, DataManager dataMgr) {
SetParent(pane);
if (null != _TextString) {
_TextControl.setText(_TextString);
}
ConfigureDimentions();
_TextControl.setScaleShape(getScaleToFitBounderies());
// By adding it to a group, the underlying java framework will properly
// clip and resize bounderies if rotated
_Group = new Group(_TextControl);
ConfigureAlignment();
SetupPeekaboo(dataMgr);
pane.add(_Group, getColumn(), getRow(), getColumnSpan(), getRowSpan());
dataMgr.AddListener(getMinionID(), getNamespace(), new ChangeListener() {
@Override
public void changed(ObservableValue o, Object oldVal, Object newVal) {
if (IsPaused()) {
return;
}
_TextString = newVal.toString();
if (true == _NumericFormat) {
try {
if (// good bet it's a float
_TextString.contains(".")) {
_TextString = NumberFormat.getNumberInstance().format(Float.parseFloat(_TextString));
} else {
_TextString = NumberFormat.getNumberInstance().format(Long.parseLong(_TextString));
}
} catch (Exception Ex) {
// System.out.println(Ex.toString());
}
} else if (true == _MoneraryFormat) {
if (// good bet it's a float
_TextString.contains(".")) {
_TextString = NumberFormat.getCurrencyInstance().format(Float.parseFloat(_TextString));
} else {
_TextString = NumberFormat.getCurrencyInstance().format(Long.parseLong(_TextString));
}
} else if (true == _PercentFormat) {
if (// good bet it's a float
_TextString.contains(".")) {
_TextString = NumberFormat.getPercentInstance().format(Float.parseFloat(_TextString));
} else {
_TextString = NumberFormat.getPercentInstance().format(Long.parseLong(_TextString));
}
}
_TextString += _Suffix;
if (// seems a single character won't display - bug in Java
_TextString.length() < 2) {
_TextString += " ";
}
_TextControl.setText(_TextString);
}
});
SetupTaskAction();
return ApplyCSS();
}
use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.
the class PieChartWidget method Create.
@Override
public boolean Create(GridPane pane, DataManager dataMgr) {
SetParent(pane);
SetupPieChart();
ConfigureDimentions();
ConfigureAlignment();
SetupPeekaboo(dataMgr);
pane.add(_Chart, getColumn(), getRow(), getColumnSpan(), getRowSpan());
dataMgr.AddListener(getMinionID(), getNamespace(), new ChangeListener() {
@Override
public void changed(ObservableValue o, Object oldVal, Object newVal) {
if (IsPaused()) {
return;
}
// expecting comma separated data
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 < _Slices.size()) {
_Chart.getData().get(iIndex).setPieValue(newValue);
} else {
LOGGER.severe("Received More datapoints for Pie Chart than was defined in application definition file");
return;
}
iIndex++;
}
}
});
SetupTaskAction();
return ApplyCSS();
}
use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.
the class ProgressBarWidget method Create.
@Override
public boolean Create(GridPane pane, DataManager dataMgr) {
SetParent(pane);
ConfigureDimentions();
ConfigureAlignment();
SetupPeekaboo(dataMgr);
pane.add(_ProgressBar, getColumn(), getRow(), getColumnSpan(), getRowSpan());
dataMgr.AddListener(getMinionID(), getNamespace(), new ChangeListener() {
@Override
public void changed(ObservableValue o, Object oldVal, Object newVal) {
if (IsPaused()) {
return;
}
double newValue = 0;
String strVal = newVal.toString();
try {
newValue = Double.parseDouble(strVal);
} catch (Exception ex) {
LOGGER.severe("Invalid data for Progress Bar received: " + strVal);
return;
}
if (newValue != 100.0) {
while (newValue >= 10) {
newValue /= 10.0;
}
}
_ProgressBar.setProgress(newValue / 10);
}
});
SetupTaskAction();
return ApplyCSS();
}
use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.
the class DynamicGridWidget method Create.
@Override
public boolean Create(GridPane parentPane, DataManager dataMgr) {
setTaskID(null);
// don't want a task setup for this actual dyanmic grid, but if one is
setMouseHasBeenSetup(true);
// specified, all the contined grids will have that task
if (super.Create(parentPane, dataMgr)) {
// _ParentPane is used in
_TransitionPane = getGridPane();
for (Widget objWidget : _Widgets) {
if (GridWidget.class.isInstance(objWidget)) {
// make all the grids invisible
objWidget.getStylableObject().setVisible(false);
}
}
if (_GridMap.isEmpty()) {
LOGGER.warning("Dynamic Grid has no Grids. Ignoring.");
return true;
}
if (null != _CurrentKey) {
if (!_GridMap.containsKey(_CurrentKey)) {
LOGGER.severe("Initial ID for Dynamic Grid: " + _CurrentKey + " is invalid.");
return false;
}
GridWidget objGrid = _GridMap.get(_ListID.get(_CurrentKey));
setAlignment(objGrid.getAlignment());
getGridPane().setAlignment(getPosition());
objGrid.getStylableObject().setVisible(true);
}
if (_AutoAdvance) {
if (null == getMinionID() || null == getNamespace()) {
String ID = Integer.toBinaryString(DynamicGridWidget._AutoAdvanceGridNumber);
DynamicGridWidget._AutoAdvanceGridNumber++;
if (null == getMinionID()) {
setMinionID(ID);
}
if (null == getNamespace()) {
setNamespace(ID);
}
}
MarvinTask mt = new MarvinTask();
mt.AddDataset(getMinionID(), getNamespace(), "Next");
TASKMAN.AddPostponedTask(mt, _AutoAdvanceInterval);
}
dataMgr.AddListener(getMinionID(), getNamespace(), new ChangeListener() {
@Override
public void changed(ObservableValue o, Object oldVal, Object newVal) {
if (IsPaused()) {
return;
}
String strVal = newVal.toString().replaceAll("(\\r|\\n)", "");
String key;
if (// go to next image in the list
strVal.equalsIgnoreCase("Next")) {
int count = _ListID.size();
key = _ListID.GetNext();
while (_DoNotIncludeInAutoMap.containsKey(key) && count >= 0) {
count--;
key = _ListID.GetNext();
}
if (count < 0) {
LOGGER.warning("Asked to perform Next, however all items in DyanmicGrid are marked as to exclude from automatic actions.");
return;
}
} else if (// go to previous image in the list
strVal.equalsIgnoreCase("Previous")) {
int count = _ListID.size();
key = _ListID.GetPrevious();
while (_DoNotIncludeInAutoMap.containsKey(key) && count >= 0) {
count--;
key = _ListID.GetPrevious();
}
if (count < 0) {
LOGGER.warning("Asked to perform previous, however all items in DyanmicGrid are marked as to exclude from automatic actions.");
return;
}
} else {
// expecting an ID
key = strVal;
// just to keep next/prev alignment
_ListID.get(key);
}
ActivateGrid(key);
}
});
return true;
}
return false;
}
Aggregations