mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-16 08:25:09 -04:00
better visual difference between running and editing mode
This commit is contained in:
parent
52b72f9140
commit
99945937aa
@ -7,7 +7,7 @@ import java.awt.*;
|
|||||||
*/
|
*/
|
||||||
public class Style {
|
public class Style {
|
||||||
public static final Style NORMAL = new Style(2, false, Color.BLACK);
|
public static final Style NORMAL = new Style(2, false, Color.BLACK);
|
||||||
public static final Style WIRE = new Style(3, true, new Color(0, 112, 0));
|
public static final Style WIRE_LOW = new Style(3, true, new Color(0, 112, 0));
|
||||||
public static final Style WIRE_HIGH = new Style(3, true, new Color(102, 255, 102));
|
public static final Style WIRE_HIGH = new Style(3, true, new Color(102, 255, 102));
|
||||||
public static final Style FILLED = new Style(2, true, Color.BLACK);
|
public static final Style FILLED = new Style(2, true, Color.BLACK);
|
||||||
public static final Style THIN = new Style(1, false, Color.BLACK);
|
public static final Style THIN = new Style(1, false, Color.BLACK);
|
||||||
|
@ -12,7 +12,7 @@ import java.util.Iterator;
|
|||||||
* @author hneemann
|
* @author hneemann
|
||||||
*/
|
*/
|
||||||
public class Circuit implements Drawable {
|
public class Circuit implements Drawable {
|
||||||
private static final Vector RAD = new Vector(3, 3);
|
private static final Vector RAD = new Vector(2, 2);
|
||||||
private final ArrayList<VisualPart> visualParts;
|
private final ArrayList<VisualPart> visualParts;
|
||||||
private transient ArrayList<Vector> dots;
|
private transient ArrayList<Vector> dots;
|
||||||
private ArrayList<Wire> wires;
|
private ArrayList<Wire> wires;
|
||||||
@ -26,7 +26,7 @@ public class Circuit implements Drawable {
|
|||||||
@Override
|
@Override
|
||||||
public void drawTo(Graphic graphic, State state) {
|
public void drawTo(Graphic graphic, State state) {
|
||||||
for (Vector d : getDots())
|
for (Vector d : getDots())
|
||||||
graphic.drawCircle(d.sub(RAD), d.add(RAD), Style.WIRE);
|
graphic.drawCircle(d.sub(RAD), d.add(RAD), Style.FILLED);
|
||||||
for (Wire w : wires)
|
for (Wire w : wires)
|
||||||
w.drawTo(graphic, state);
|
w.drawTo(graphic, state);
|
||||||
for (VisualPart p : visualParts)
|
for (VisualPart p : visualParts)
|
||||||
|
@ -21,9 +21,12 @@ public class Wire implements Drawable, Moveable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawTo(Graphic graphic, State state) {
|
public void drawTo(Graphic graphic, State state) {
|
||||||
Style style = Style.WIRE;
|
Style style = Style.NORMAL;
|
||||||
if (value != null && value.getValue() != 0) {
|
if (value != null) {
|
||||||
style = Style.WIRE_HIGH;
|
if (value.getValue() != 0)
|
||||||
|
style = Style.WIRE_HIGH;
|
||||||
|
else
|
||||||
|
style = Style.WIRE_LOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
graphic.drawLine(p1, p2, style);
|
graphic.drawLine(p1, p2, style);
|
||||||
|
@ -61,9 +61,13 @@ public class InputShape implements Shape {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawTo(Graphic graphic, State state) {
|
public void drawTo(Graphic graphic, State state) {
|
||||||
Style style = Style.WIRE;
|
Style style = Style.NORMAL;
|
||||||
if (state != null && state.getOutput(0).getValue() != 0)
|
if (state != null) {
|
||||||
style = Style.WIRE_HIGH;
|
if (state.getOutput(0).getValue() != 0)
|
||||||
|
style = Style.WIRE_HIGH;
|
||||||
|
else
|
||||||
|
style = Style.WIRE_LOW;
|
||||||
|
}
|
||||||
|
|
||||||
Vector center = new Vector(-2 - SIZE, 0);
|
Vector center = new Vector(-2 - SIZE, 0);
|
||||||
graphic.drawCircle(center.sub(RAD), center.add(RAD), style);
|
graphic.drawCircle(center.sub(RAD), center.add(RAD), style);
|
||||||
|
@ -46,9 +46,13 @@ public class OutputShape implements Shape {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawTo(Graphic graphic, State state) {
|
public void drawTo(Graphic graphic, State state) {
|
||||||
Style style = Style.WIRE;
|
Style style = Style.NORMAL;
|
||||||
if (state != null && state.getInput(0).getValue() != 0)
|
if (state != null) {
|
||||||
style = Style.WIRE_HIGH;
|
if (state.getInput(0).getValue() != 0)
|
||||||
|
style = Style.WIRE_HIGH;
|
||||||
|
else
|
||||||
|
style = Style.WIRE_LOW;
|
||||||
|
}
|
||||||
|
|
||||||
Vector center = new Vector(2 + SIZE, 0);
|
Vector center = new Vector(2 + SIZE, 0);
|
||||||
graphic.drawCircle(center.sub(RAD), center.add(RAD), style);
|
graphic.drawCircle(center.sub(RAD), center.add(RAD), style);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user