use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.
the class FrameController method calculateFontSizeScalingFactor.
private static double calculateFontSizeScalingFactor(int lookAndFeelDefaultMenuItemFontSize) {
final ResourceController resourceController = ResourceController.getResourceController();
final int userDefinedMenuItemFontSize = resourceController.getIntProperty(UITools.MENU_ITEM_FONT_SIZE_PROPERTY, UNKNOWN);
final double scalingFactor;
if (userDefinedMenuItemFontSize == UNKNOWN) {
scalingFactor = DEFAULT_SCALING_FACTOR;
} else {
scalingFactor = ((double) userDefinedMenuItemFontSize) / lookAndFeelDefaultMenuItemFontSize;
}
return scalingFactor;
}
use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.
the class FrameController method setLookAndFeel.
public static void setLookAndFeel(final String lookAndFeel, boolean supportHidpi) {
try {
if (lookAndFeel.equals("default")) {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} else {
LookAndFeelInfo[] lafInfos = UIManager.getInstalledLookAndFeels();
boolean setLnF = false;
for (LookAndFeelInfo lafInfo : lafInfos) {
if (lafInfo.getName().equalsIgnoreCase(lookAndFeel)) {
UIManager.setLookAndFeel(lafInfo.getClassName());
setLnF = true;
break;
}
}
if (!setLnF) {
final URLClassLoader userLibClassLoader = ClassLoaderFactory.getClassLoaderForUserLib();
try {
final Class<?> lookAndFeelClass = userLibClassLoader.loadClass(lookAndFeel);
UIManager.setLookAndFeel((LookAndFeel) lookAndFeelClass.newInstance());
final ClassLoader uiClassLoader = lookAndFeelClass.getClassLoader();
if (userLibClassLoader != uiClassLoader)
userLibClassLoader.close();
UIManager.getDefaults().put("ClassLoader", uiClassLoader);
} catch (ClassNotFoundException | ClassCastException | InstantiationException e) {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
Controller.getCurrentController().getResourceController().setProperty("lookandfeel", "default");
}
}
}
} catch (final Exception ex) {
LogUtils.warn("Error while setting Look&Feel" + lookAndFeel);
}
UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE);
final ResourceController resourceController = ResourceController.getResourceController();
if (!resourceController.getBooleanProperty("hugeFontsFixed", false)) {
if ("100".equals(resourceController.getProperties().get(UITools.MENU_ITEM_FONT_SIZE_PROPERTY))) {
resourceController.getProperties().remove(UITools.MENU_ITEM_FONT_SIZE_PROPERTY);
}
resourceController.setProperty("hugeFontsFixed", true);
}
int lookAndFeelDefaultMenuItemFontSize = getLookAndFeelDefaultMenuItemFontSize();
final long defaultMenuItemSize = Math.round(lookAndFeelDefaultMenuItemFontSize * DEFAULT_SCALING_FACTOR);
resourceController.setDefaultProperty(UITools.MENU_ITEM_FONT_SIZE_PROPERTY, Long.toString(defaultMenuItemSize));
if (supportHidpi) {
double scalingFactor = calculateFontSizeScalingFactor(lookAndFeelDefaultMenuItemFontSize);
scaleDefaultUIFonts(scalingFactor);
}
// Workaround for https://bugs.openjdk.java.net/browse/JDK-8134828
// Scrollbar thumb disappears with Nimbus L&F
// http://stackoverflow.com/questions/32857372/jscrollbar-dont-show-thumb-in-nimbus-lf
final Dimension minimumThumbSize = new Dimension(30, 30);
UIManager.getLookAndFeelDefaults().put("ScrollBar.minimumThumbSize", minimumThumbSize);
UIManager.put("ScrollBar.minimumThumbSize", minimumThumbSize);
// set FileChooserUI to MetalFileChooserUI if no JFileChooser can be created
try {
new JFileChooser();
} catch (Throwable t) {
try {
UIManager.getLookAndFeelDefaults().put("FileChooserUI", MetalFileChooserUI.class.getName());
} catch (Throwable t1) {
}
}
// Workaround for https://bugs.openjdk.java.net/browse/JDK-8179014
UIManager.put("FileChooser.useSystemExtensionHiding", false);
final Color color = UIManager.getColor("control");
if (color != null && color.getAlpha() < 255)
UIManager.getDefaults().put("control", Color.LIGHT_GRAY);
}
use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.
the class UIComponentVisibilityDispatcher method toggleVisibility.
public void toggleVisibility() {
final ResourceController resourceController = ResourceController.getResourceController();
final boolean wasVisible = resourceController.getBooleanProperty(getPropertyName());
setVisible(!wasVisible);
}
use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.
the class MModeController method createOptionPanelControls.
private void createOptionPanelControls() {
optionPanelBuilder = new OptionPanelBuilder();
final ResourceController resourceController = ResourceController.getResourceController();
URL preferences = resourceController.getResource("/xml/preferences.xml");
optionPanelBuilder.load(preferences);
getController().addAction(createShowPreferencesAction(optionPanelBuilder));
}
use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.
the class ReportGenerator method showBugReportDialog.
private String showBugReportDialog() {
final ResourceController resourceController = ResourceController.getResourceController();
String option = resourceController.getProperty(OPTION, BugReportDialogManager.ASK);
if (option.equals(BugReportDialogManager.ASK)) {
if (resourceController.getBooleanProperty("org.freeplane.plugin.bugreport.dialog.disabled"))
return BugReportDialogManager.DENIED;
String question = TextUtils.getText("org.freeplane.plugin.bugreport.question");
if (!question.startsWith("<html>")) {
question = HtmlUtils.plainToHTML(question);
}
final Object[] options = new Object[] { TextUtils.getText("org.freeplane.plugin.bugreport.always_agree"), TextUtils.getText("org.freeplane.plugin.bugreport.agree"), TextUtils.getText("org.freeplane.plugin.bugreport.deny"), TextUtils.getText("org.freeplane.plugin.bugreport.always_deny") };
final String title = TextUtils.getText("org.freeplane.plugin.bugreport.dialog.title");
final String reportName = TextUtils.getText("org.freeplane.plugin.bugreport.report");
final int choice = BugReportDialogManager.showBugReportDialog(title, question, JOptionPane.INFORMATION_MESSAGE, options, options[1], reportName, log);
switch(choice) {
case 0:
option = BugReportDialogManager.ALLOWED;
resourceController.setProperty(OPTION, option);
break;
case 1:
option = BugReportDialogManager.ALLOWED;
break;
case 2:
option = BugReportDialogManager.DENIED;
break;
case 3:
option = BugReportDialogManager.DENIED;
resourceController.setProperty(OPTION, option);
break;
default:
option = BugReportDialogManager.DENIED;
break;
}
}
return option;
}
Aggregations