Introduced some preferences
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Mon, 16 Sep 2019 12:46:02 +0000 (14:46 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Mon, 16 Sep 2019 12:47:47 +0000 (14:47 +0200)
plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java
plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/submodels/SubmodelComponent.java
plugins/net.mograsim.preferences/src/net/mograsim/preferences/DefaultPreferences.java

index 15346c6..c4a8c2d 100644 (file)
@@ -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);
        }
 
index 9388e2f..745597d 100644 (file)
@@ -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<Runnable> 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.
index 2f5c7c2..b261003 100644 (file)
@@ -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);
                }