本文整理汇总了Java中javafx.application.Preloader类的典型用法代码示例。如果您正苦于以下问题:Java Preloader类的具体用法?Java Preloader怎么用?Java Preloader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Preloader类属于javafx.application包,在下文中一共展示了Preloader类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import javafx.application.Preloader; //导入依赖的package包/类
@Override
public void init() throws Exception {
int progress = 0;
applicationDataManager = new ApplicationDataManager();
locale = ApplicationProperty.LOCALE.get(ApplicationDataManager.getApplicationProperties());
if (!containsUnamedLaunchParameter(ProgramArgument.NoSplash)) {
for (; progress < 100; progress++) {
Thread.sleep(40);
notifyPreloaderLog(new Preloader.ProgressNotification(progress / 100.0));
}
}
}
示例2: init
import javafx.application.Preloader; //导入依赖的package包/类
@Override
public void init() throws Exception {
appInstance = this;
VERSION = getVersion();
// Lets install/update the overlays if newer version
AppSetup.install(VERSION);
log = LogManager.getLogger(TokenTool.class);
log.info("3D Hardware Available? " + Platform.isSupported(ConditionalFeature.SCENE3D));
// Now lets cache any overlays we find and update preLoader with progress
overlayCount = (int) Files.walk(AppConstants.OVERLAY_DIR.toPath()).filter(Files::isRegularFile).count();
overlayTreeItems = cacheOverlays(AppConstants.OVERLAY_DIR, null, THUMB_SIZE);
// All Done!
notifyPreloader(new Preloader.ProgressNotification(1.0));
}
示例3: notifyPreloaderLog
import javafx.application.Preloader; //导入依赖的package包/类
private void notifyPreloaderLog(Preloader.PreloaderNotification notification) {
if (containsUnamedLaunchParameter(ProgramArgument.LogInitProgress)) {
if (notification instanceof Preloader.ProgressNotification) {
System.out.println("Preloader Log Progress: " + ((Preloader.ProgressNotification) notification).getProgress());
} else if (notification instanceof Preloader.StateChangeNotification) {
System.out.println("Preloader Stage Change: " + ((Preloader.StateChangeNotification) notification).getType());
} else if (notification instanceof Preloader.ErrorNotification) {
System.out.println("Preloader Error: " + notification);
}
}
notifyPreloader(notification);
}
示例4: handleApplicationNotification
import javafx.application.Preloader; //导入依赖的package包/类
@Override
public void handleApplicationNotification(Preloader.PreloaderNotification pn) {
if (pn instanceof Preloader.StateChangeNotification) {
stage.hide();
}
}
示例5: start
import javafx.application.Preloader; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
notifyPreloader(new Preloader.StateChangeNotification(Preloader.StateChangeNotification.Type.BEFORE_START));
stage.setTitle("Post Firefighters App");
Scene scene = firefightersRootPane.initScene();
stage.setScene(scene);
URL resource = FirefighterPostApp.class.getClassLoader().getResource("ui.css");
scene.getStylesheets().add(resource.toExternalForm());
stage.setResizable(true);
stage.centerOnScreen();
stage.show();
LOG.info("Application Started");
}
示例6: init
import javafx.application.Preloader; //导入依赖的package包/类
@Override
public void init() throws IOException {
parsedArgs = commandLineHelper.parse(getParameters().getRaw());
if (parsedArgs.hasOption(UICommandLineHelper.HEADLESS_OPTION)) {
// If --headless was specified on the command line,
// run in headless mode (only use the core module)
logger.info("Launching GRIP in headless mode");
injector = Guice.createInjector(Modules.override(new GripCoreModule(), new GripFileModule(),
new GripSourcesHardwareModule()).with(new GripNetworkModule()));
injector.injectMembers(this);
headless = true;
} else {
// Otherwise, run with both the core and UI modules, and show the JavaFX stage
logger.info("Launching GRIP in UI mode");
injector = Guice.createInjector(Modules.override(new GripCoreModule(), new GripFileModule(),
new GripSourcesHardwareModule()).with(new GripNetworkModule(), new GripUiModule()));
injector.injectMembers(this);
notifyPreloader(new Preloader.ProgressNotification(0.15));
System.setProperty("prism.lcdtext", "false");
Font.loadFont(this.getClass().getResource("roboto/Roboto-Regular.ttf").openStream(), -1);
Font.loadFont(this.getClass().getResource("roboto/Roboto-Bold.ttf").openStream(), -1);
Font.loadFont(this.getClass().getResource("roboto/Roboto-Italic.ttf").openStream(), -1);
Font.loadFont(this.getClass().getResource("roboto/Roboto-BoldItalic.ttf").openStream(), -1);
notifyPreloader(new Preloader.ProgressNotification(0.3));
}
notifyPreloader(new Preloader.ProgressNotification(0.45));
server.addHandler(pipelineSwitcher);
notifyPreloader(new Preloader.ProgressNotification(0.6));
pipelineRunner.startAsync();
notifyPreloader(new Preloader.ProgressNotification(0.75));
}
示例7: cacheOverlays
import javafx.application.Preloader; //导入依赖的package包/类
/**
*
* @author Jamz
* @throws IOException
* @since 2.0
*
* This method loads and processes all the overlays found in user.home/overlays and it can take a minute to load as it creates thumbnail versions for the comboBox so we call this during the
* init and display progress in the preLoader (splash screen).
*
*/
private TreeItem<Path> cacheOverlays(File dir, TreeItem<Path> parent, int THUMB_SIZE) throws IOException {
TreeItem<Path> root = new TreeItem<>(dir.toPath());
root.setExpanded(false);
log.debug("caching " + dir.getAbsolutePath());
File[] files = dir.listFiles();
for (File file : files) {
if (file.isDirectory()) {
cacheOverlays(file, root, THUMB_SIZE);
} else {
Path filePath = file.toPath();
TreeItem<Path> imageNode = new TreeItem<>(filePath, ImageUtil.getOverlayThumb(new ImageView(), filePath));
root.getChildren().add(imageNode);
notifyPreloader(new Preloader.ProgressNotification((double) loadCount++ / overlayCount));
}
}
if (parent != null) {
// When we show the overlay image, the TreeItem value is "" so we need to
// sort those to the bottom for a cleaner look and keep sub dir's at the top.
// If a node has no children then it's an overlay, otherwise it's a directory...
root.getChildren().sort(new Comparator<TreeItem<Path>>() {
@Override
public int compare(TreeItem<Path> o1, TreeItem<Path> o2) {
if (o1.getChildren().size() == 0 && o2.getChildren().size() == 0)
return 0;
else if (o1.getChildren().size() == 0)
return Integer.MAX_VALUE;
else if (o2.getChildren().size() == 0)
return Integer.MIN_VALUE;
else
return o1.getValue().compareTo(o2.getValue());
}
});
parent.getChildren().add(root);
}
return root;
}
示例8: start
import javafx.application.Preloader; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
notifyPreloader(new Preloader.StateChangeNotification(Preloader.StateChangeNotification.Type.BEFORE_START));
stage.setTitle(windowTitle);
stage.setScene(new Scene(projectsView.getView()));
stage.setResizable(true);
stage.centerOnScreen();
stage.show();
}
示例9: start
import javafx.application.Preloader; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
notifyPreloader(new Preloader.StateChangeNotification(Preloader.StateChangeNotification.Type.BEFORE_START));
stage.setTitle(windowTitle);
stage.setScene(new Scene(mainLayout));
stage.setResizable(true);
stage.centerOnScreen();
stage.show();
}
示例10: start
import javafx.application.Preloader; //导入依赖的package包/类
@Override
public void start(Stage stage) throws IOException {
// Load UI elements if we're not in headless mode
if (!headless) {
root = FXMLLoader.load(Main.class.getResource("MainWindow.fxml"), null, null,
injector::getInstance);
root.setStyle("-fx-font-size: " + DPIUtility.FONT_SIZE + "px");
notifyPreloader(new Preloader.ProgressNotification(0.9));
project.addIsSaveDirtyConsumer(newValue -> {
if (newValue) {
Platform.runLater(() -> stage.setTitle(MAIN_TITLE + " | Edited"));
} else {
Platform.runLater(() -> stage.setTitle(MAIN_TITLE));
}
});
stage.setTitle(MAIN_TITLE);
stage.getIcons().add(new Image("/edu/wpi/grip/ui/icons/grip.png"));
stage.setScene(new Scene(root));
notifyPreloader(new Preloader.ProgressNotification(1.0));
notifyPreloader(new Preloader.StateChangeNotification(
Preloader.StateChangeNotification.Type.BEFORE_START));
stage.show();
}
operations.addOperations();
cvOperations.addOperations();
commandLineHelper.loadFile(parsedArgs, project);
commandLineHelper.setServerPort(parsedArgs, settingsProvider, eventBus);
// This will throw an exception if the port specified by the save file or command line
// argument is already taken. Since we have to have the server running to handle remotely
// loading pipelines and uploading images, as well as potential HTTP publishing operations,
// this will cause the program to exit.
try {
server.start();
} catch (GripServerException e) {
logger.log(Level.SEVERE, "The HTTP server could not be started", e);
Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "", ButtonType.YES, ButtonType.NO);
alert.setTitle("The HTTP server could not be started");
alert.setHeaderText("The HTTP server could not be started");
alert.setContentText(
"This is normally caused by the network port being used by another process.\n\n"
+ "HTTP sources and operations will not work until GRIP is restarted. "
+ "Continue without HTTP functionality anyway?"
);
alert.showAndWait().filter(ButtonType.NO::equals).ifPresent(bt -> SafeShutdown.exit(1));
}
}
示例11: main
import javafx.application.Preloader; //导入依赖的package包/类
public static void main(String[] args) {
Preloader.launch(args);
}