X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fmodel%2Fcomponents%2Fatomic%2FModelManualSwitch.java;h=789798254491d489a9cbed7ce3010fcf6e5253e0;hb=13e03ecec5e28dab69820e5ec4db5c1a2c5a3c73;hp=d4e04376f732a88fbe43b6c77677c4e1eb22105d;hpb=c356c613955c3ea57d2379fb76f9bd07f1e30170;p=Mograsim.git diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelManualSwitch.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelManualSwitch.java index d4e04376..78979825 100644 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelManualSwitch.java +++ b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelManualSwitch.java @@ -8,7 +8,6 @@ import org.eclipse.swt.graphics.Color; import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Font; -import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; import net.mograsim.logic.core.LogicObserver; import net.mograsim.logic.core.components.CoreManualSwitch; @@ -24,14 +23,16 @@ import net.mograsim.logic.model.modeladapter.componentadapters.ManualSwitchAdapt import net.mograsim.logic.model.serializing.IdentifyParams; import net.mograsim.logic.model.serializing.IndirectModelComponentCreator; import net.mograsim.logic.model.snippets.HighLevelStateHandler; +import net.mograsim.logic.model.util.TextRenderingHelper; import net.mograsim.preferences.Preferences; public class ModelManualSwitch extends ModelComponent { private static final double width = 20; - private static final double height = 15; + private static final double height = 10; private static final double fontHeight = 5; private static final double heightMiniButtons = 4; // 0 is disabled + private static final double textMargin = 0.5; public final int logicWidth; private final Pin outputPin; @@ -142,15 +143,14 @@ public class ModelManualSwitch extends ModelComponent if (foreground != null) gc.setForeground(foreground); gc.drawRectangle(getBounds()); - String label = BitVectorFormatter.formatAsString(manualSwitch == null ? null : getOutValues()); + String label = BitVectorFormatter.formatAsString(manualSwitch == null ? null : getOutValues(), false); Font oldFont = gc.getFont(); Font labelFont = new Font(oldFont.getName(), fontHeight, oldFont.getStyle()); gc.setFont(labelFont); - Point textExtent = gc.textExtent(label); Color textColor = Preferences.current().getColor("net.mograsim.logic.model.color.text"); if (textColor != null) gc.setForeground(textColor); - gc.drawText(label, getPosX() + (width - textExtent.x) / 2, getPosY() + (height - textExtent.y) / 2, true); + TextRenderingHelper.drawTextFitting(gc, label, getBounds(), textMargin, true); gc.setFont(oldFont); if (manualSwitch != null && logicWidth > 1 && heightMiniButtons > 0 && visibleRegion.y < getPosY() + heightMiniButtons)