package net.mograsim.logic.ui;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import net.haspamelodica.swt.helper.zoomablecanvas.ZoomableCanvas;
import net.mograsim.logic.ui.model.ViewModel;
import net.mograsim.logic.ui.model.components.GUIComponent;
+import net.mograsim.preferences.Preferences;
/**
* Simulation visualizer canvas.
this.model = model;
LogicUIRenderer renderer = new LogicUIRenderer(model);
- addZoomedRenderer(gc -> renderer.render(gc, new Rectangle(-offX / zoom, -offY / zoom, gW / zoom, gH / zoom)));
+ addZoomedRenderer(gc ->
+ {
+ Color background = Preferences.current().getColor("net.mograsim.logic.ui.color.background");
+ if (background != null)
+ setBackground(background);// this.setBackground, not gc.setBackground to have the background fill the canvas
+ renderer.render(gc, new Rectangle(-offX / zoom, -offY / zoom, gW / zoom, gH / zoom));
+ });
model.addRedrawListener(this::redrawThreadsafe);
addListener(SWT.MouseDown, this::mouseDown);
package net.mograsim.logic.ui.model.components;
+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.mograsim.logic.ui.model.wires.Pin;
import net.mograsim.logic.ui.modeladapter.ViewLogicModelAdapter;
import net.mograsim.logic.ui.modeladapter.componentadapters.BitDisplayAdapter;
+import net.mograsim.preferences.Preferences;
public class GUIBitDisplay 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);
gc.drawRectangle(getBounds());
String label = bitDisplay == null ? BitVectorFormatter.formatAsString(null)
: BitVectorFormatter.formatAsString(bitDisplay.getDisplayedValue());
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() + (width - textExtent.x) / 2, getPosY() + (height - textExtent.y) / 2, true);
gc.setFont(oldFont);
}
package net.mograsim.logic.ui.model.components;
+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.mograsim.logic.ui.model.wires.Pin;
import net.mograsim.logic.ui.modeladapter.ViewLogicModelAdapter;
import net.mograsim.logic.ui.modeladapter.componentadapters.ManualSwitchAdapter;
+import net.mograsim.preferences.Preferences;
public class GUIManualSwitch extends GUIComponent
{
public void render(GeneralGC gc, Rectangle visibleRegion)
{
// TODO maybe draw switch state too?
+ Color foreground = Preferences.current().getColor("net.mograsim.logic.ui.color.foreground");
+ if (foreground != null)
+ gc.setForeground(foreground);
gc.drawRectangle(getBounds());
String label = BitVectorFormatter.formatValueAsString(end);
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() + (width - textExtent.x) / 2, getPosY() + (height - textExtent.y) / 2, true);
gc.setFont(oldFont);
}
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.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
{
@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
import java.util.Map;
import java.util.TreeMap;
+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.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 SimpleRectangularSubmodelComponent extends SubmodelComponent
{
Font oldFont = gc.getFont();
gc.setFont(new Font(oldFont.getName(), labelFontHeight, oldFont.getStyle()));
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() + (getWidth() - textExtent.x) / 2, getPosY() + (getHeight() - textExtent.y) / 2, true);
gc.setFont(new Font(oldFont.getName(), pinNameFontHeight, oldFont.getStyle()));
for (int i = 0; i < inputPinNames.size(); i++)
@Override
protected void renderOutline(GeneralGC gc, Rectangle visibleRegion)
{
+ Color foreground = Preferences.current().getColor("net.mograsim.logic.ui.color.foreground");
+ if (foreground != null)
+ gc.setForeground(foreground);
gc.drawRectangle(getBounds());
}
extension.name.1 = XML Problem
decorator.label = Resource Decorator
themeElementCategory.label = Mograsim
-colorDefinition.label = Simulation Background
+colorDefinition.label = Simulation Hintergrundfarbe
colorDefinition.description = The Background of the Simulation Visualisation
-colorDefinition.label.0 = Simulation Text Farbe
+colorDefinition.label.0 = Simulation Vordergrundfarbe
colorDefinition.label.1 = Assembler Kommentarfarbe
colorDefinition.label.2 = Assembler Beschriftungsfarbe
colorDefinition.label.3 = Assembler Operationsfarbe
colorDefinition.label.4 = Assembler Zahlenfarbe
-fontDefinition.label = Assembler Operation Textstil
\ No newline at end of file
+colorDefinition.label.5 = Simulation Farbe 1
+colorDefinition.label.6 = Simulation Farbe U
+colorDefinition.label.7 = Simulation Farbe X
+colorDefinition.label.8 = Simulation Farbe Z
+colorDefinition.label.9 = Simulation Farbe 0
+colorDefinition.label.10 = Simulation Textfarbe
+fontDefinition.label = Assembler Operation Textstil
+view.name.0 = Simulation View
+themeElementCategory.label.0 = Simulation
\ No newline at end of file
net.mograsim.preferences;bundle-version="0.1.0"
Bundle-RequiredExecutionEnvironment: JavaSE-11
Automatic-Module-Name: net.mograsim.plugin.core
-Bundle-Vendor: Mograsim Team
+Bundle-Vendor: %Bundle-Vendor.0
themeElementCategory.label = Mograsim
colorDefinition.label = Simulation Background
colorDefinition.description = The Background of the Simulation Visualisation
-colorDefinition.label.0 = Simulation Text Color
+colorDefinition.label.0 = Simulation Foreground Color
colorDefinition.label.1 = Assembler Comment Color
colorDefinition.label.2 = Assembler Label Color
colorDefinition.label.3 = Assembler Operation Color
colorDefinition.label.4 = Assembler Number Color
-fontDefinition.label = Assembler Operation Style
\ No newline at end of file
+colorDefinition.label.5 = Simulation Color 1
+colorDefinition.label.6 = Simulation Color U
+colorDefinition.label.7 = Simulation Color X
+colorDefinition.label.8 = Simulation Color Z
+colorDefinition.label.9 = Simulation Color 0
+colorDefinition.label.10 = Simulation text color
+fontDefinition.label = Assembler Operation Style
+view.name.0 = Simulation View
+themeElementCategory.label.0 = Simulation
+Bundle-Vendor.0 = Mograsim Team
\ No newline at end of file
icon="icons/mograsim/blue-orange/icon_blue-orange_16.png"
id="net.mograsim.plugin.core.view1"
inject="true"
- name="Simulation View"
+ name="%view.name.0"
restorable="true">
</view>
</extension>
<themeElementCategory
class="net.mograsim.plugin.SimulationPreview"
id="net.mograsim.logic.ui"
- label="Simulation"
+ label="%themeElementCategory.label.0"
parentId="net.mograsim.plugin.mograsim">
</themeElementCategory>
<colorDefinition
categoryId="net.mograsim.logic.ui"
- id="net.mograsim.plugin.sim_backgound"
+ id="net.mograsim.logic.ui.color.background"
isEditable="true"
label="%colorDefinition.label"
value="COLOR_WHITE">
</colorDefinition>
<colorDefinition
categoryId="net.mograsim.logic.ui"
- id="net.mograsim.plugin.sim_text_color"
+ id="net.mograsim.logic.ui.color.foreground"
isEditable="true"
label="%colorDefinition.label.0"
value="COLOR_BLACK">
</colorDefinition>
+ <colorDefinition
+ categoryId="net.mograsim.logic.ui"
+ id="net.mograsim.logic.ui.color.text"
+ label="%colorDefinition.label.10"
+ value="COLOR_BLACK">
+ </colorDefinition>
<colorDefinition
categoryId="net.mograsim.logic.ui"
id="net.mograsim.logic.ui.color.bit.one"
isEditable="true"
- label="Simulation Farbe 1"
+ label="%colorDefinition.label.5"
value="COLOR_GREEN">
</colorDefinition>
<colorDefinition
categoryId="net.mograsim.logic.ui"
id="net.mograsim.logic.ui.color.bit.u"
isEditable="true"
- label="Simulation Farbe U"
+ label="%colorDefinition.label.6"
value="COLOR_CYAN">
</colorDefinition>
<colorDefinition
categoryId="net.mograsim.logic.ui"
id="net.mograsim.logic.ui.color.bit.x"
isEditable="true"
- label="Simulation Farbe X"
+ label="%colorDefinition.label.7"
value="COLOR_RED">
</colorDefinition>
<colorDefinition
categoryId="net.mograsim.logic.ui"
id="net.mograsim.logic.ui.color.bit.z"
isEditable="true"
- label="Simulation Farbe Z"
+ label="%colorDefinition.label.8"
value="COLOR_YELLOW">
</colorDefinition>
<colorDefinition
categoryId="net.mograsim.logic.ui"
id="net.mograsim.logic.ui.color.bit.zero"
isEditable="true"
- label="Simulation Farbe 0"
+ label="%colorDefinition.label.9"
value="COLOR_GRAY">
</colorDefinition>
<colorDefinition
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.statushandlers.StatusManager;
-import org.eclipse.ui.themes.ITheme;
import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput;
import net.mograsim.logic.core.timeline.Timeline;
userInput.buttonZoom = 2;
userInput.enableUserInput();
- ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
- update(currentTheme);
- currentTheme.getColorRegistry().addListener(e -> update(currentTheme));
-
// initialize executer
exec = new LogicExecuter(timeline);
exec.startLiveExecution();
}
- private void update(ITheme currentTheme)
- {
- ui.setBackground(currentTheme.getColorRegistry().get("net.mograsim.plugin.sim_backgound"));
- ui.setForeground(currentTheme.getColorRegistry().get("net.mograsim.plugin.sim_text_color"));
- }
-
@Override
public void setFocus()
{
return new ColorDefinition(BuiltInColor.COLOR_YELLOW);
case "net.mograsim.logic.ui.color.bit.zero":
return new ColorDefinition(BuiltInColor.COLOR_GRAY);
+ case "net.mograsim.logic.ui.color.background":
+ return new ColorDefinition(BuiltInColor.COLOR_WHITE);
+ case "net.mograsim.logic.ui.color.foreground":
+ return new ColorDefinition(BuiltInColor.COLOR_BLACK);
+ case "net.mograsim.logic.ui.color.text":
+ return new ColorDefinition(BuiltInColor.COLOR_BLACK);
default:
// TODO proper logging here...
System.err.println("Unknown color name: " + name);
- return new ColorDefinition(BuiltInColor.COLOR_BLACK);
+ return null;
}
}
}
\ No newline at end of file