use of kutch.biff.marvin.configuration.ConfigurationReader in project Board-Instrumentation-Framework by intel.
the class AboutBox method SetupExtraInfoPane.
private static int SetupExtraInfoPane(GridPane grid, int iStartRow, int column) {
ConfigurationReader CONFIG = ConfigurationReader.GetConfigReader();
// ConfigurationReader CONFIG = GetConfigReader();
Label lblScaling;
Label lblAppDimensions;
Label lblVersionJVM;
Label lblTabCount;
Rectangle2D visualBounds = CONFIG.getConfiguration().getPrimaryScreen().getVisualBounds();
int appWidth = (int) visualBounds.getWidth();
int appHeight = (int) visualBounds.getHeight();
String rtv = System.getProperty("java.runtime.version");
if (null == rtv) {
// bogus one - should NEVER happen
rtv = "1.1.0_11-b32";
}
lblTabCount = new Label("Number of Tabs: " + Integer.toString(CONFIG.getTabs().size()));
String scalingString = "Scaling: ";
if (CONFIG.getConfiguration().isAutoScale()) {
scalingString += "[AutoScale] ";
}
scalingString += String.format("%.2f", CONFIG.getConfiguration().getScaleFactor());
lblScaling = new Label(scalingString);
CONFIG.getConfiguration().getScaleProperty().addListener(new // when the scale changes
ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) {
String scalingString = "Scaling: ";
if (CONFIG.getConfiguration().isAutoScale()) {
scalingString += "[AutoScale] ";
}
scalingString += String.format("%.2f", CONFIG.getConfiguration().getScaleFactor());
lblScaling.setText(scalingString);
}
});
lblAppDimensions = new Label("Screen Size: " + Integer.toString(appWidth) + "x" + Integer.toString(appHeight));
lblVersionJVM = new Label("JVM Version - " + rtv);
grid.add(lblTabCount, column, iStartRow++);
grid.add(lblScaling, column, iStartRow++);
grid.add(lblAppDimensions, column, iStartRow++);
grid.add(lblVersionJVM, column, iStartRow++);
return iStartRow;
}
use of kutch.biff.marvin.configuration.ConfigurationReader in project Board-Instrumentation-Framework by intel.
the class MenuButtonWidget method onChange.
@Override
protected void onChange(ObservableValue<?> o, Object oldVal, Object newVal) {
String entriesList = newVal.toString();
if (entriesList.length() < 1 || __LastValue.equals(entriesList)) {
return;
}
__LastValue = entriesList;
_Button.getItems().clear();
String[] newEntries = newVal.toString().split(",");
ConfigurationReader rdr = ConfigurationReader.GetConfigReader();
for (String entry : newEntries) {
FrameworkNode menuNode = new FrameworkNode(__CommonTaskNode);
menuNode.AddAttibute("Text", entry);
MenuItem objItem = null;
try {
objItem = rdr.ReadMenuItem(menuNode, _Button.getItems().size());
setupChangeTitleListener(objItem);
} catch (Exception ex) {
LOGGER.severe(ex.toString());
}
if (null != objItem) {
try {
_Button.getItems().add(objItem);
} catch (Exception ex) {
LOGGER.severe(ex.toString());
}
}
}
ApplyCSS();
}
use of kutch.biff.marvin.configuration.ConfigurationReader in project Board-Instrumentation-Framework by intel.
the class MenuButtonWidget method HandleWidgetSpecificSettings.
@Override
public boolean HandleWidgetSpecificSettings(FrameworkNode widgetNode) {
if (super.HandleWidgetSpecificSettings(widgetNode)) {
return true;
}
if (widgetNode.getNodeName().equalsIgnoreCase("MenuItem")) {
ConfigurationReader rdr = ConfigurationReader.GetConfigReader();
MenuItem objItem = rdr.ReadMenuItem(widgetNode, _Button.getItems().size());
if (null != objItem) {
_Button.getItems().add(objItem);
setupChangeTitleListener(objItem);
return true;
}
}
return false;
}
use of kutch.biff.marvin.configuration.ConfigurationReader in project Board-Instrumentation-Framework by intel.
the class AboutBox method Setup.
private static Pane Setup(Stage stage) {
// TaskManager TASKMAN = TaskManager.getTaskManager();
ConfigurationReader CONFIG = ConfigurationReader.GetConfigReader();
GridPane grid = new GridPane();
URL resource = AboutBox.class.getResource("About.png");
Image img = new Image(resource.toString());
ImageView aboutImg = new ImageView(img);
Button OKBtn = new Button("OK");
Label By = new Label("by");
Label Author = new Label("Patrick Kutch");
Label With = new Label("with Brian Johnson");
Label With2 = new Label("and Michael Shearer");
Label Where = new Label("https://github.com/PatrickKutch");
Label DataCount = new Label("Datapoints: " + Integer.toString(DataManager.getDataManager().NumberOfRegisteredDatapoints()));
Author.setAlignment(Pos.CENTER);
GridPane.setHalignment(Author, HPos.CENTER);
GridPane.setHalignment(By, HPos.CENTER);
GridPane.setHalignment(With, HPos.CENTER);
GridPane.setHalignment(With2, HPos.CENTER);
GridPane.setHalignment(Where, HPos.CENTER);
Label VerLabel = new Label(Version.getVersion());
Label Widgets = new Label("Number of Widgets - " + Integer.toString(BaseWidget.getWidgetCount()));
Label Tasks = new Label("Number of Tasks - " + Integer.toString(BaseTask.getTaskCount()));
long freeMem = Runtime.getRuntime().freeMemory();
long totalMem = Runtime.getRuntime().maxMemory();
long usedMem = totalMem - freeMem;
usedMem /= 1024.0;
String MBMemStr = NumberFormat.getNumberInstance(Locale.US).format(usedMem / 1024);
Label MemUsage = new Label("Mem usage (MB) - " + MBMemStr);
int newBottom = 1;
grid.setAlignment(Pos.CENTER);
grid.add(aboutImg, 1, newBottom++);
grid.add(By, 1, newBottom++);
grid.add(Author, 1, newBottom++);
grid.add(With, 1, newBottom++);
grid.add(With2, 1, newBottom++);
grid.add(Where, 1, newBottom++);
grid.add(new Label(" "), 1, newBottom++);
if (CONFIG.getConfiguration().GetApplicationID().length() > 0) {
Label ID = new Label("ID : " + CONFIG.getConfiguration().GetApplicationID());
grid.add(ID, 1, newBottom++);
}
grid.add(VerLabel, 1, newBottom++);
grid.add(Widgets, 1, newBottom++);
grid.add(Tasks, 1, newBottom++);
grid.add(DataCount, 1, newBottom++);
grid.add(MemUsage, 1, newBottom++);
GridPane.setHalignment(OKBtn, HPos.CENTER);
// grid.add(new Label(" "), 1, newBottom++);
newBottom = AboutBox.SetupExtraInfoPane(grid, newBottom++, 1);
Slider objSlider = new Slider(.25, 3, CONFIG.getConfiguration().getScaleFactor());
objSlider.valueProperty().bindBidirectional(CONFIG.getConfiguration().getScaleProperty());
grid.add(objSlider, 1, newBottom++);
objSlider.setVisible(false);
aboutImg.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
if (event.isShiftDown()) {
objSlider.setVisible(true);
}
}
});
grid.add(OKBtn, 1, newBottom);
grid.setStyle("-fx-padding: 5; -fx-background-color: cornsilk; -fx-border-width:5; -fx-border-color: linear-gradient(to bottom, chocolate, derive(chocolate, 50%));");
OKBtn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
stage.close();
}
});
// place on correct screen.
int xPos = (int) (CONFIG.getConfiguration().getPrimaryScreen().getVisualBounds().getMinX());
int yPos = (int) (CONFIG.getConfiguration().getPrimaryScreen().getVisualBounds().getMinY());
stage.setX(xPos);
stage.setY(yPos);
// and center it.
stage.centerOnScreen();
return grid;
}
use of kutch.biff.marvin.configuration.ConfigurationReader in project Board-Instrumentation-Framework by intel.
the class Marvin method testAppSize.
/*
* private void LoadApplication(Stage stage) { stage.setIconified(true); _Config
* = new ConfigurationReader(); if (null == _Config) { return; }
*
* Configuration config = _Config.ReadStartupInfo(ConfigFilename); if (null ==
* config) { return; } _objTabPane = new TabPane();
* _objTabPane.setSide(config.getSide());
*
* GridPane sceneGrid = new GridPane();
*
* GridPane.setHalignment(_Config.getConfiguration().getMenuBar(), HPos.LEFT);
* GridPane.setValignment(_Config.getConfiguration().getMenuBar(), VPos.TOP);
*
* sceneGrid.add(_Config.getConfiguration().getMenuBar(), 0, 0);
* sceneGrid.add(_objTabPane, 0, 1);
*
* Scene scene = null; Rectangle2D visualBounds =
* _Config.getConfiguration().getPrimaryScreen().getVisualBounds(); int appWidth
* = (int) visualBounds.getWidth(); int appHeight = (int)
* visualBounds.getHeight();
*
* if (config.getWidth() > 0) { appWidth = config.getWidth(); } else {
* config.setWidth(appWidth); } if (config.getHeight() > 0) { appHeight =
* config.getHeight(); } else { config.setHeight(appHeight); }
*
* scene = new Scene(sceneGrid); SetAppStyle(scene.getStylesheets());
* stage.setScene(scene); stage.setIconified(true);
*
* stage.setX(_Config.getConfiguration().getPrimaryScreen().getVisualBounds().
* getMinX());
* stage.setY(_Config.getConfiguration().getPrimaryScreen().getVisualBounds().
* getMinY());
*
* stage.setMaximized(true);
*
* stage.addEventHandler(WindowEvent.WINDOW_SHOWN, new
* EventHandler<WindowEvent>() {
*
* @Override public void handle(WindowEvent window) { FinishLoad(stage); } });
*
* while (false && !_SizeCheckWindowShowing) { try { Thread.sleep(100); } catch
* (InterruptedException ex) {
* Logger.getLogger(Marvin.class.getName()).log(Level.SEVERE, null, ex); } }
*
* FinishLoad(stage);
*
* }
*/
// / pop up quick simple tab,menu and style it, then grab the size of the window
// / so we know the canvas dimenstions
private boolean testAppSize(Stage stage) {
final GridPane stagePane = new GridPane();
final GridPane canvasPane = new GridPane();
canvasPane.setAlignment(Pos.TOP_LEFT);
_Config = new ConfigurationReader();
if (null == _Config) {
return false;
}
final Configuration basicConfig = _Config.ReadStartupInfo(ConfigFilename);
if (null == basicConfig) {
return false;
}
stage.setX(basicConfig.getPrimaryScreen().getVisualBounds().getMinX());
stage.setY(basicConfig.getPrimaryScreen().getVisualBounds().getMinY());
TabPane tabPane = new TabPane();
Tab objTab = new Tab();
final Side tabSide = basicConfig.getSide();
if (tabSide == Side.TOP || tabSide == Side.BOTTOM) {
tabPane.setSide(Side.TOP);
} else {
tabPane.setSide(Side.LEFT);
}
objTab.setText("");
tabPane.getTabs().add(objTab);
stagePane.add(tabPane, 0, 1);
MenuBar objMenuBar = new MenuBar();
if (basicConfig.getShowMenuBar()) {
Menu objMenu = new Menu("About");
MenuItem objItem = new MenuItem("Dummy");
objMenu.getItems().add(objItem);
objMenuBar.getMenus().add(objMenu);
stagePane.add(objMenuBar, 0, 0);
}
if (basicConfig.getEnableScrollBars()) {
ScrollPane testScrollPane = new ScrollPane();
testScrollPane.setPannable(true);
testScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
testScrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
testScrollPane.setContent(canvasPane);
objTab.setContent(testScrollPane);
} else {
objTab.setContent(canvasPane);
}
stage.setTitle(basicConfig.getAppTitle());
Scene scene = new Scene(stagePane);
stage.setScene(scene);
SetAppStyle(scene.getStylesheets());
if (_Config.getConfiguration().getKioskMode()) {
stage.initStyle(StageStyle.UNDECORATED);
}
URL resource = AboutBox.class.getResource("About.png");
Image iconImg = new Image(resource.toString());
stage.getIcons().add(iconImg);
stage.addEventHandler(WindowEvent.WINDOW_SHOWN, new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent window) {
scene.heightProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneHeight, Number newSceneHeight) {
scene.heightProperty().removeListener(this);
Point2D canvasInScene = canvasPane.localToScene(0.0, 0.0);
int cvHeight;
int cvWidth;
if (tabSide == Side.TOP || tabSide == Side.BOTTOM) {
cvHeight = (int) (scene.getHeight() - canvasInScene.getY());
cvWidth = (int) scene.getWidth();
} else {
cvHeight = (int) (scene.getHeight() - canvasInScene.getY());
cvWidth = (int) (scene.getWidth() - canvasInScene.getX());
}
basicConfig.setCanvasWidth(cvWidth);
basicConfig.setCanvasHeight(cvHeight);
stage.setIconified(true);
Platform.runLater(new Runnable() {
@Override
public void run() {
FinishLoad(stage);
}
});
}
});
}
});
stage.show();
if (basicConfig.getWidth() > 0) {
stage.setWidth(basicConfig.getWidth());
stage.setHeight(basicConfig.getHeight());
} else {
stage.setMaximized(true);
}
return true;
}
Aggregations