use of net.rptools.tokentool.model.Window_Preferences in project tokentool by RPTools.
the class TokenTool_Controller method setWindoFrom_Preferences.
// For user preferences...
public void setWindoFrom_Preferences(String preferencesJson) {
if (preferencesJson != null) {
Window_Preferences window_Preferences = new Gson().fromJson(preferencesJson, new TypeToken<Window_Preferences>() {
}.getType());
window_Preferences.setWindow(TokenTool.getInstance().getStage());
}
}
use of net.rptools.tokentool.model.Window_Preferences in project tokentool by RPTools.
the class RegionSelector_Controller method captureButton_onAction.
@FXML
void captureButton_onAction(ActionEvent event) {
Stage stage = (Stage) captureButton.getScene().getWindow();
Scene scene = stage.getScene();
int x = (int) stage.getX();
int y = (int) stage.getY();
int sceneWidth = (int) scene.getWidth();
int sceneHeight = (int) scene.getHeight();
stage.hide();
log.debug("Rect: " + new Rectangle(x, y, sceneWidth, sceneHeight));
// Test to see if this works better on Linux. Linux would still capture this stage in the
// image...
Platform.runLater(() -> {
try {
// Robot robot = new
// Robot(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice());
BufferedImage bi = new Robot().createScreenCapture(new Rectangle(x, y, sceneWidth, sceneHeight));
tokenTool_Controller.updateImage(SwingFXUtils.toFXImage(bi, null));
AppPreferences.setPreference(AppPreferences.WINDOW_REGION_SELECTOR_PREFERENCES, new Window_Preferences(stage).toJson());
stage.close();
} catch (AWTException e) {
log.error("Error capturing screen shot!", e);
}
});
}
use of net.rptools.tokentool.model.Window_Preferences in project tokentool by RPTools.
the class AppPreferences method savePreferences.
public static void savePreferences(TokenTool_Controller tokentool_Controller) {
log.info("Saving preferences to " + prefs.toString());
// Save Overlay details
prefs.putBoolean(OVERLAY_ASPECT, tokentool_Controller.getOverlayAspect());
prefs.putInt(OVERLAY_WIDTH, tokentool_Controller.getOverlayWidth());
prefs.putInt(OVERLAY_HEIGHT, tokentool_Controller.getOverlayHeight());
prefs.putBoolean(OVERLAY_USE_BASE, tokentool_Controller.getOverlayUseAsBase());
prefs.putBoolean(OVERLAY_CLIP_PORTRAIT, tokentool_Controller.getClipPortraitCheckbox());
// Save naming details
prefs.putBoolean(USE_FILE_NUMBERING, tokentool_Controller.getUseFileNumberingCheckbox());
prefs.put(FILE_NAME_TEXT_FIELD, tokentool_Controller.getFileNameTextField());
prefs.put(FILE_NAME_SUFFIX_TEXT_FIELD, tokentool_Controller.getFileNameSuffixTextField());
prefs.put(PORTRAIT_NAME_TEXT_FIELD, tokentool_Controller.getPortraitNameTextField());
prefs.putBoolean(USE_TOKEN_NAME, tokentool_Controller.getUseTokenNameCheckbox());
prefs.put(PORTRAIT_NAME_SUFFIX_TEXT_FIELD, tokentool_Controller.getPortraitNameSuffixTextField());
prefs.putBoolean(SAVE_PORTRAIT_ON_DRAG, tokentool_Controller.getSavePortraitOnDragCheckbox());
prefs.putBoolean(USE_BACKGROUND_ON_DRAG, tokentool_Controller.getUseBackgroundOnDragCheckbox());
// Save recent overlays used
log.debug("...saving recent overlay count");
Map<Path, TreeItem<Path>> recentOverlays = tokentool_Controller.getRecentOverlayTreeItems();
prefs.putInt(RECENT_OVERLAY_COUNT, recentOverlays.size());
log.debug("...saving recent overlays");
int i = 1;
for (Path path : recentOverlays.keySet()) prefs.put(RECENT_OVERLAY + i++, path.toString());
// Save location of save
log.debug("...saving last file save location");
try {
if (FileSaveUtil.getLastFile() != null)
if (FileSaveUtil.getLastFile().getParentFile().exists())
prefs.put(LAST_TOKEN_SAVE_LOCATION, FileSaveUtil.getLastFile().getCanonicalPath());
} catch (NullPointerException e) {
log.warn("No last save location to save...");
} catch (IOException e) {
log.error("Error saving last file preference.", e);
}
// Save last portrait used
try {
File lastPortrait = new File(AppConstants.CACHE_DIR, "last_portrait.png");
ImageIO.write(SwingFXUtils.fromFXImage(tokentool_Controller.getPortraitImage(), null), "png", lastPortrait);
prefs.put(PORTRAIT_IMAGEVIEW_PREFERENCES, tokentool_Controller.getPortrait_Preferences(lastPortrait.getCanonicalPath()));
} catch (NullPointerException e) {
log.warn("No portrait to save...");
} catch (IOException e) {
log.error("Error saving last portrait preference.", e);
}
// Save last background used
try {
Image backgroundImage = tokentool_Controller.getBackgroundImage();
if (backgroundImage != null) {
File lastBackground = new File(AppConstants.CACHE_DIR, "last_background.png");
ImageIO.write(SwingFXUtils.fromFXImage(tokentool_Controller.getBackgroundImage(), null), "png", lastBackground);
prefs.put(BACKGROUND_IMAGEVIEW_PREFERENCES, tokentool_Controller.getBackground_Preferences(lastBackground.getCanonicalPath()));
} else {
prefs.put(BACKGROUND_IMAGEVIEW_PREFERENCES, tokentool_Controller.getBackground_Preferences(null));
}
} catch (IOException e) {
log.error("Error saving last background preference.", e);
}
// Save window size/position
prefs.put(WINDOW_MAIN_PREFERENCES, new Window_Preferences(TokenTool.getInstance().getStage()).toJson());
}
Aggregations