From 269b34bc8e58453170ad4bb34266eb2d78d5627a Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Mon, 16 Sep 2019 14:46:02 +0200 Subject: [PATCH] Introduced some preferences --- .../mograsim/logic/model/LogicUICanvas.java | 4 +--- .../submodels/SubmodelComponent.java | 24 ++++++++----------- .../preferences/DefaultPreferences.java | 6 +++++ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java index 15346c63..c4a8c2d4 100644 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java +++ b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java @@ -38,8 +38,6 @@ import net.mograsim.preferences.Preferences; */ public class LogicUICanvas extends ZoomableCanvas { - private static final boolean OPEN_DEBUG_SETHIGHLEVELSTATE_SHELL = false; - private final LogicModel model; public LogicUICanvas(Composite parent, int style, LogicModel model) @@ -60,7 +58,7 @@ public class LogicUICanvas extends ZoomableCanvas addListener(SWT.MouseDown, this::mouseDown); - if (OPEN_DEBUG_SETHIGHLEVELSTATE_SHELL) + if (Preferences.current().getBoolean("net.mograsim.logic.model.debug.openhlsshell")) openDebugSetHighLevelStateShell(model); } diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/submodels/SubmodelComponent.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/submodels/SubmodelComponent.java index 9388e2fb..745597d4 100644 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/submodels/SubmodelComponent.java +++ b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/submodels/SubmodelComponent.java @@ -68,26 +68,14 @@ public abstract class SubmodelComponent extends ModelComponent * A pseudo-component containing all submodel interface pins on the submodel side. */ private final SubmodelInterface submodelInterface; - /** * The factor by which the submodel is scaled when rendering. */ private double submodelScale; - /** - * If this {@link SubmodelComponent} fills at least this amount of the visible region vertically or horizontally, the submodel starts to - * be visible. - */ - private double maxVisibleRegionFillRatioForAlpha0; - /** - * If this {@link SubmodelComponent} fills at least this amount of the visible region vertically or horizontally, the submodel is fully - * visible. - */ - private double minVisibleRegionFillRatioForAlpha1; /** * The renderer used for rendering the submodel. */ private final LogicUIRenderer renderer; - /** * The {@link Renderer} used to render the symbol of this SubmodelCoponent. */ @@ -118,8 +106,6 @@ public abstract class SubmodelComponent extends ModelComponent this.submodelInterface = new SubmodelInterface(submodelModifiable); this.submodelScale = 1; - this.maxVisibleRegionFillRatioForAlpha0 = 0.8; - this.minVisibleRegionFillRatioForAlpha1 = 0.9; this.renderer = new LogicUIRenderer(submodelModifiable); Consumer redrawHandlerChangedListener = submodelModifiable::setRedrawHandler; @@ -377,6 +363,16 @@ public abstract class SubmodelComponent extends ModelComponent GeneralGC tgc = new TranslatedGC(gc, getPosX(), getPosY(), submodelScale, true); conf.reset(tgc); double visibleRegionFillRatio = Math.max(getWidth() / visibleRegion.width, getHeight() / visibleRegion.height); + /** + * If this {@link SubmodelComponent} fills at least this amount of the visible region vertically or horizontally, the submodel + * starts to be visible. + */ + double maxVisibleRegionFillRatioForAlpha0 = Preferences.current().getDouble("net.mograsim.logic.model.submodel.zoomalpha0"); + /** + * If this {@link SubmodelComponent} fills at least this amount of the visible region vertically or horizontally, the submodel is + * fully visible. + */ + double minVisibleRegionFillRatioForAlpha1 = Preferences.current().getDouble("net.mograsim.logic.model.submodel.zoomalpha1"); double alphaFactor = map(visibleRegionFillRatio, maxVisibleRegionFillRatioForAlpha0, minVisibleRegionFillRatioForAlpha1, 0, 1); alphaFactor = Math.max(0, Math.min(1, alphaFactor)); // we need to take the old alpha into account to support nested submodules better. diff --git a/plugins/net.mograsim.preferences/src/net/mograsim/preferences/DefaultPreferences.java b/plugins/net.mograsim.preferences/src/net/mograsim/preferences/DefaultPreferences.java index 2f5c7c2a..b261003d 100644 --- a/plugins/net.mograsim.preferences/src/net/mograsim/preferences/DefaultPreferences.java +++ b/plugins/net.mograsim.preferences/src/net/mograsim/preferences/DefaultPreferences.java @@ -11,6 +11,8 @@ public class DefaultPreferences extends Preferences { case "net.mograsim.logic.model.improvetext": return true; + case "net.mograsim.logic.model.debug.openhlsshell": + return false; default: throw new IllegalArgumentException("Unknown boolean preference name: " + name); } @@ -37,6 +39,10 @@ public class DefaultPreferences extends Preferences return 0.5; case "net.mograsim.logic.model.linewidth.wire.multibit": return 0.85; + case "net.mograsim.logic.model.submodel.zoomalpha0": + return 0.8; + case "net.mograsim.logic.model.submodel.zoomalpha1": + return 0.9; default: throw new IllegalArgumentException("Unknown double preference name: " + name); } -- 2.17.1