Slight improvements in documentation.
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / components / SimpleRectangularGUIGate.java
index 7beafe1..0dd4c40 100644 (file)
@@ -4,14 +4,16 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
+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.ui.model.ModelVisitor;
 import net.mograsim.logic.ui.model.ViewModelModifiable;
 import net.mograsim.logic.ui.model.wires.MovablePin;
 import net.mograsim.logic.ui.model.wires.Pin;
+import net.mograsim.preferences.Preferences;
 
 public class SimpleRectangularGUIGate extends GUIComponent
 {
@@ -64,16 +66,22 @@ public class SimpleRectangularGUIGate extends GUIComponent
        @Override
        public void render(GeneralGC gc, Rectangle visibleRegion)
        {
+               Color foreground = Preferences.current().getColor("net.mograsim.logic.ui.color.foreground");
+               if (foreground != null)
+                       gc.setForeground(foreground);
                double height = (getPins().size() - 1) * pinDistance;
                gc.drawRectangle(getPosX(), getPosY(), rectWidth, height);
+               if (isInverted)
+                       gc.drawOval(getPosX() + rectWidth, getPosY() + (height - invertedCircleDiam) / 2, invertedCircleDiam, invertedCircleDiam);
                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.ui.color.text");
+               if (textColor != null)
+                       gc.setForeground(textColor);
                gc.drawText(label, getPosX() + (rectWidth - textExtent.x) / 2, getPosY() + (height - textExtent.y) / 2, true);
                gc.setFont(oldFont);
-               if (isInverted)
-                       gc.drawOval(getPosX() + rectWidth, getPosY() + (height - invertedCircleDiam) / 2, invertedCircleDiam, invertedCircleDiam);
        }
 
        @Override
@@ -83,10 +91,4 @@ public class SimpleRectangularGUIGate extends GUIComponent
                m.put(kLogicWidth, logicWidth);
                return m;
        }
-
-       @Override
-       public void accept(ModelVisitor mv)
-       {
-               mv.visit(this);
-       }
 }
\ No newline at end of file