mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-26 14:31:02 -04:00
introduced a separate color (red) to indicate errors
This commit is contained in:
parent
bcc980d321
commit
243e58fd88
@ -170,17 +170,18 @@ public class Circuit {
|
||||
* @param graphic the graphic instance used
|
||||
*/
|
||||
public void drawTo(Graphic graphic) {
|
||||
drawTo(graphic, EMPTY_SET, NoSync.INST);
|
||||
drawTo(graphic, EMPTY_SET, null, NoSync.INST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws tis circuit using the given graphic instance
|
||||
* Draws this circuit using the given graphic instance
|
||||
*
|
||||
* @param graphic the graphic instance used
|
||||
* @param highLighted a list of Drawables to highlight
|
||||
* @param highlight style used to draw the highlighted elements
|
||||
* @param modelSync sync interface to access the model. Is locked while drawing circuit
|
||||
*/
|
||||
public void drawTo(Graphic graphic, Collection<Drawable> highLighted, Sync modelSync) {
|
||||
public void drawTo(Graphic graphic, Collection<Drawable> highLighted, Style highlight, Sync modelSync) {
|
||||
if (!dotsPresent) {
|
||||
new DotCreator(wires).applyDots();
|
||||
dotsPresent = true;
|
||||
@ -189,11 +190,11 @@ public class Circuit {
|
||||
modelSync.access(() -> {
|
||||
graphic.openGroup();
|
||||
for (Wire w : wires)
|
||||
w.drawTo(graphic, highLighted.contains(w));
|
||||
w.drawTo(graphic, highLighted.contains(w) ? highlight : null);
|
||||
graphic.closeGroup();
|
||||
for (VisualElement p : visualElements) {
|
||||
graphic.openGroup();
|
||||
p.drawTo(graphic, highLighted.contains(p));
|
||||
p.drawTo(graphic, highLighted.contains(p) ? highlight : null);
|
||||
graphic.closeGroup();
|
||||
}
|
||||
});
|
||||
@ -640,9 +641,9 @@ public class Circuit {
|
||||
* @param circuit the circuit to take the listeners from
|
||||
*/
|
||||
public void getListenersFrom(Circuit circuit) {
|
||||
if (circuit.listeners!=null) {
|
||||
if (listeners==null)
|
||||
listeners=new ArrayList<>();
|
||||
if (circuit.listeners != null) {
|
||||
if (listeners == null)
|
||||
listeners = new ArrayList<>();
|
||||
listeners.addAll(circuit.listeners);
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class VisualElement implements Drawable, Movable, AttributeListener {
|
||||
this.elementName = proto.elementName;
|
||||
this.elementAttributes = new ElementAttributes(proto.elementAttributes);
|
||||
setPos(new Vector(proto.pos));
|
||||
this.shapeFactory=proto.shapeFactory;
|
||||
this.shapeFactory = proto.shapeFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,19 +165,19 @@ public class VisualElement implements Drawable, Movable, AttributeListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
drawShape(graphic, highLight);
|
||||
|
||||
// draw circle around element
|
||||
if (highLight) {
|
||||
if (highLight != null) {
|
||||
GraphicMinMax mm = getMinMax(false);
|
||||
Vector delta = mm.getMax().sub(mm.getMin()).add(SIZE, SIZE).div(2);
|
||||
Vector pos = mm.getMax().add(mm.getMin()).div(2);
|
||||
graphic.drawCircle(pos.sub(delta), pos.add(delta), Style.HIGHLIGHT);
|
||||
graphic.drawCircle(pos.sub(delta), pos.add(delta), highLight);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawShape(Graphic graphic, boolean highLight) {
|
||||
private void drawShape(Graphic graphic, Style highLight) {
|
||||
Graphic gr = new GraphicTransform(graphic, createTransform());
|
||||
Shape shape = getShape();
|
||||
shape.drawTo(gr, highLight);
|
||||
@ -205,14 +205,14 @@ public class VisualElement implements Drawable, Movable, AttributeListener {
|
||||
if (includeText) {
|
||||
if (minMaxText == null) {
|
||||
GraphicMinMax mm = new GraphicMinMax(true);
|
||||
drawShape(mm, false);
|
||||
drawShape(mm, null);
|
||||
minMaxText = mm;
|
||||
}
|
||||
return minMaxText;
|
||||
} else {
|
||||
if (minMax == null) {
|
||||
GraphicMinMax mm = new GraphicMinMax(false);
|
||||
drawShape(mm, false);
|
||||
drawShape(mm, null);
|
||||
minMax = mm;
|
||||
}
|
||||
return minMax;
|
||||
@ -246,7 +246,7 @@ public class VisualElement implements Drawable, Movable, AttributeListener {
|
||||
*/
|
||||
public BufferedImage getBufferedImage(double scale, int maxHeight) {
|
||||
GraphicMinMax mm = new GraphicMinMax();
|
||||
drawShape(mm, false);
|
||||
drawShape(mm, null);
|
||||
|
||||
if (mm.getMax().y - mm.getMin().y > maxHeight / scale)
|
||||
scale = (double) (maxHeight - 1) / (mm.getMax().y - mm.getMin().y + 4);
|
||||
@ -266,7 +266,7 @@ public class VisualElement implements Drawable, Movable, AttributeListener {
|
||||
gr.scale(scale, scale);
|
||||
gr.translate(2 - mm.getMin().x, 2 - mm.getMin().y);
|
||||
GraphicSwing grs = new GraphicSwing(gr);
|
||||
drawTo(grs, false);
|
||||
drawTo(grs, null);
|
||||
return bi;
|
||||
}
|
||||
|
||||
|
@ -55,9 +55,9 @@ public class Wire implements Drawable, Movable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
Style style = Style.HIGHLIGHT;
|
||||
if (!highLight)
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
Style style = highLight;
|
||||
if (style == null)
|
||||
style = Style.getWireStyle(value);
|
||||
|
||||
graphic.drawLine(p1, p2, style);
|
||||
|
@ -84,6 +84,11 @@ public class Style {
|
||||
*/
|
||||
public static final Style HIGHLIGHT = new Style(WIRETHICK, false, Color.CYAN);
|
||||
|
||||
/**
|
||||
* error color used for the circles to mark an element
|
||||
*/
|
||||
public static final Style ERROR = new Style(WIRETHICK, false, Color.RED.darker());
|
||||
|
||||
private final int thickness;
|
||||
private final boolean filled;
|
||||
private final Color color;
|
||||
@ -180,4 +185,5 @@ public class Style {
|
||||
if (value.getValueIgnoreBurn() == 1) return WIRE_HIGH;
|
||||
else return WIRE_LOW;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class BreakShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
Vector center = new Vector(2 + SIZE, 0);
|
||||
graphic.drawCircle(center.sub(RAD), center.add(RAD), Style.NORMAL);
|
||||
graphic.drawLine(center.sub(D1), center.add(D1), Style.NORMAL);
|
||||
|
@ -83,7 +83,7 @@ public class ButtonShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean heighLight) {
|
||||
public void drawTo(Graphic graphic, Style heighLight) {
|
||||
boolean down = false;
|
||||
if (ioState != null) down = ioState.getOutput(0).getBool();
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class ClockShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean heighLight) {
|
||||
public void drawTo(Graphic graphic, Style heighLight) {
|
||||
graphic.drawPolygon(new Polygon(true)
|
||||
.add(-SIZE * 2 - 1, -SIZE)
|
||||
.add(-1, -SIZE)
|
||||
|
@ -45,7 +45,7 @@ public class ConstShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean heighLight) {
|
||||
public void drawTo(Graphic graphic, Style heighLight) {
|
||||
Vector textPos = new Vector(-3, 0);
|
||||
graphic.drawText(textPos, textPos.add(1, 0), value, Orientation.RIGHTCENTER, Style.NORMAL);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class DILShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
int dp = SPACING * SIZE;
|
||||
int pin = dp / 4;
|
||||
int x = width * SIZE;
|
||||
|
@ -10,6 +10,7 @@ import de.neemann.digital.core.element.PinDescriptions;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
import de.neemann.digital.draw.elements.Pins;
|
||||
import de.neemann.digital.draw.graphics.Graphic;
|
||||
import de.neemann.digital.draw.graphics.Style;
|
||||
import de.neemann.digital.draw.model.ModelCreator;
|
||||
import de.neemann.digital.draw.model.ModelEntry;
|
||||
import de.neemann.digital.gui.components.CircuitComponent;
|
||||
@ -61,11 +62,11 @@ public class DataShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean heighLight) {
|
||||
public void drawTo(Graphic graphic, Style heighLight) {
|
||||
if (dataSet == null) {
|
||||
dataSet = new DataSet();
|
||||
}
|
||||
dataSet.drawTo(graphic, false);
|
||||
dataSet.drawTo(graphic, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,7 +41,7 @@ public class DelayShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean heighLight) {
|
||||
public void drawTo(Graphic graphic, Style heighLight) {
|
||||
graphic.drawPolygon(
|
||||
new Polygon(true)
|
||||
.add(1, -SIZE2)
|
||||
|
@ -65,7 +65,7 @@ public class DemuxerShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
graphic.drawPolygon(new Polygon(true)
|
||||
.add(1, 5)
|
||||
.add(SIZE * 2 - 1, -4)
|
||||
|
@ -50,7 +50,7 @@ public class DiodeBackwardShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
Style style = blown ? Style.DASH : Style.NORMAL;
|
||||
|
||||
graphic.drawPolygon(
|
||||
|
@ -50,7 +50,7 @@ public class DiodeForewardShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
Style style = blown ? Style.DASH : Style.NORMAL;
|
||||
|
||||
graphic.drawPolygon(
|
||||
|
@ -48,7 +48,7 @@ public class DiodeShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
Style style = blown ? Style.DASH : Style.NORMAL;
|
||||
|
||||
graphic.drawPolygon(
|
||||
|
@ -1,6 +1,7 @@
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.draw.graphics.Graphic;
|
||||
import de.neemann.digital.draw.graphics.Style;
|
||||
|
||||
/**
|
||||
* Interface implemented by the elements which can draw itself to a {@link Graphic} instance.
|
||||
@ -10,9 +11,8 @@ import de.neemann.digital.draw.graphics.Graphic;
|
||||
public interface Drawable {
|
||||
/**
|
||||
* Draws an element depending on its state.
|
||||
*
|
||||
* @param graphic interface to draw to
|
||||
* @param graphic interface to draw to
|
||||
* @param highLight true if a highlighted drawing is required
|
||||
*/
|
||||
void drawTo(Graphic graphic, boolean highLight);
|
||||
void drawTo(Graphic graphic, Style highLight);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class DriverShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
graphic.drawPolygon(
|
||||
new Polygon(true)
|
||||
.add(-SIZE + 1, -SIZE2 - 2)
|
||||
|
@ -51,7 +51,7 @@ public abstract class FETShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
final int g = SIZE2 / 2;
|
||||
graphic.drawPolygon(new Polygon(false)
|
||||
.add(SIZE, 0)
|
||||
|
@ -37,7 +37,7 @@ public class FETShapeN extends FETShape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
super.drawTo(graphic, highLight);
|
||||
|
||||
// the arrow
|
||||
|
@ -38,7 +38,7 @@ public class FETShapeP extends FETShape {
|
||||
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
super.drawTo(graphic, highLight);
|
||||
|
||||
// the arrow
|
||||
|
@ -45,7 +45,7 @@ public class FGFETShapeN extends FETShape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
super.drawTo(graphic, highLight);
|
||||
|
||||
if (programmed)
|
||||
|
@ -44,7 +44,7 @@ public class FGFETShapeP extends FETShape {
|
||||
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
super.drawTo(graphic, highLight);
|
||||
|
||||
if (programmed)
|
||||
|
@ -171,7 +171,7 @@ public class GenericShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
int max = Math.max(inputs.size(), outputs.size());
|
||||
int height = (max - 1) * SIZE + SIZE2;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class GroundShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean heighLight) {
|
||||
public void drawTo(Graphic graphic, Style heighLight) {
|
||||
graphic.drawLine(new Vector(-SIZE2, 0), new Vector(SIZE2, 0), Style.THICK);
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class InputShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean heighLight) {
|
||||
public void drawTo(Graphic graphic, Style heighLight) {
|
||||
Style style = Style.NORMAL;
|
||||
if (ioState != null) {
|
||||
ObservableValue value = ioState.getOutput(0);
|
||||
|
@ -54,7 +54,7 @@ public class LEDShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean heighLight) {
|
||||
public void drawTo(Graphic graphic, Style heighLight) {
|
||||
boolean fill = true;
|
||||
if (ioState != null) {
|
||||
fill = false;
|
||||
|
@ -12,8 +12,6 @@ import de.neemann.digital.draw.graphics.Graphic;
|
||||
import de.neemann.digital.draw.graphics.Style;
|
||||
import de.neemann.digital.draw.graphics.Vector;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import static de.neemann.digital.draw.shapes.GenericShape.SIZE;
|
||||
|
||||
/**
|
||||
@ -56,7 +54,7 @@ public class LightBulbShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
if (a != null && b != null) {
|
||||
boolean on = !a.isHighZ() && !b.isHighZ() && (a.getBool() != b.getBool());
|
||||
if (on)
|
||||
|
@ -42,7 +42,7 @@ public class MissingShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
Style style = Style.NORMAL_TEXT;
|
||||
graphic.drawText(new Vector(4, 4), new Vector(5, 4), message, Orientation.LEFTTOP, style);
|
||||
if (cause != null && cause.length() > 0)
|
||||
|
@ -60,7 +60,7 @@ public class MuxerShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean heighLight) {
|
||||
public void drawTo(Graphic graphic, Style heighLight) {
|
||||
graphic.drawPolygon(new Polygon(true)
|
||||
.add(1, -4)
|
||||
.add(SIZE * 2 - 1, 5)
|
||||
|
@ -63,7 +63,7 @@ public class OutputShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
Style style = Style.NORMAL;
|
||||
if (ioState != null) {
|
||||
ObservableValue value = ioState.getInput(0);
|
||||
|
@ -58,7 +58,7 @@ public class ProbeShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
graphic.drawText(new Vector(2, -1), new Vector(3, -1), label, Orientation.LEFTBOTTOM, Style.NORMAL);
|
||||
if (bits > 1) {
|
||||
String v = format.format(inValue);
|
||||
|
@ -53,7 +53,7 @@ public class PullDownShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
graphic.drawPolygon(
|
||||
new Polygon(true)
|
||||
.add(-WIDTH2, 1)
|
||||
|
@ -47,7 +47,7 @@ public class PullUpShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
graphic.drawPolygon(
|
||||
new Polygon(true)
|
||||
.add(-WIDTH2, -1)
|
||||
|
@ -56,7 +56,7 @@ public class RelayShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
int yOffs = 0;
|
||||
|
||||
boolean closed = invers;
|
||||
|
@ -44,7 +44,7 @@ public class ResetShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
graphic.drawPolygon(new Polygon(true).add(-SIZE * 2 - 2, -SIZE).add(-2, -SIZE).add(-2, SIZE).add(-SIZE * 2 - 2, SIZE), Style.NORMAL);
|
||||
|
||||
Vector textPos = new Vector(-SIZE * 2 + 2, -SIZE + 2);
|
||||
|
@ -106,7 +106,7 @@ public class RotEncoderShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean heighLight) {
|
||||
public void drawTo(Graphic graphic, Style heighLight) {
|
||||
graphic.drawPolygon(new Polygon(true)
|
||||
.add(0, -SIZE)
|
||||
.add(0, SIZE * 2)
|
||||
|
@ -74,7 +74,7 @@ public class SevenSegShape extends SevenShape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
super.drawTo(graphic, highLight);
|
||||
if (commonCatode)
|
||||
graphic.drawLine(
|
||||
|
@ -67,7 +67,7 @@ public abstract class SevenShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
graphic.drawPolygon(new Polygon(true)
|
||||
.add(-SIZE2, 1)
|
||||
.add(SIZE * 3 + SIZE2, 1)
|
||||
|
@ -55,7 +55,7 @@ public class SplitterShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean heighLight) {
|
||||
public void drawTo(Graphic graphic, Style heighLight) {
|
||||
for (int i = 0; i < inputs.size(); i++) {
|
||||
Vector pos = new Vector(-2, i * SIZE - 3);
|
||||
graphic.drawText(pos, pos.add(2, 0), inputs.get(i).getName(), Orientation.RIGHTBOTTOM, Style.SHAPE_PIN);
|
||||
|
@ -65,7 +65,7 @@ public class SwitchShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
int yOffs = 0;
|
||||
if (closed) {
|
||||
graphic.drawLine(new Vector(0, 0), new Vector(SIZE * 2, 0), Style.NORMAL);
|
||||
|
@ -45,7 +45,7 @@ public class TestCaseShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
Polygon pol = new Polygon(true)
|
||||
.add(SIZE2, SIZE2)
|
||||
.add(SIZE2 + SIZE * 4, SIZE2)
|
||||
|
@ -45,7 +45,7 @@ public class TextShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
graphic.drawText(new Vector(0, 0), new Vector(1, 0), label, Orientation.LEFTTOP, Style.NORMAL_TEXT);
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class TransGateShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
graphic.drawPolygon(TOP, Style.NORMAL);
|
||||
graphic.drawPolygon(BOTTOM, Style.NORMAL);
|
||||
graphic.drawLine(new Vector(SIZE, -SIZE), new Vector(SIZE, -SIZE2), Style.NORMAL);
|
||||
|
@ -48,7 +48,7 @@ public class TunnelShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic gr, boolean highLight) {
|
||||
public void drawTo(Graphic gr, Style highLight) {
|
||||
gr.drawPolygon(new Polygon(true)
|
||||
.add(0, 0)
|
||||
.add(WIDTH, HEIGHT)
|
||||
|
@ -45,7 +45,7 @@ public class VDDShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean heighLight) {
|
||||
public void drawTo(Graphic graphic, Style heighLight) {
|
||||
graphic.drawPolygon(
|
||||
new Polygon(false)
|
||||
.add(-SIZE2, DOWNSHIFT)
|
||||
|
@ -54,7 +54,7 @@ public abstract class IEEEGenericShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
int offs = (inputs.size() / 2 - 1) * SIZE;
|
||||
drawIEEE(new GraphicTransform(graphic, v -> v.add(0, offs)));
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class IEEENotShape implements Shape {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
public void drawTo(Graphic graphic, Style highLight) {
|
||||
graphic.drawPolygon(
|
||||
new Polygon(true)
|
||||
.add(1, -SIZE2 - 2)
|
||||
|
@ -917,6 +917,11 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
if (createAndStartModel(false, ModelEvent.MICROSTEP, null))
|
||||
circuitComponent.setManualChangeObserver(new MicroStepObserver(model));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void leave() {
|
||||
circuitComponent.removeHighLighted();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1009,6 +1014,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
BurnException e = (BurnException) cause;
|
||||
circuitComponent.addHighLightedWires(e.getValues());
|
||||
}
|
||||
circuitComponent.setHighLightStyle(Style.ERROR);
|
||||
circuitComponent.repaintNeeded();
|
||||
new ErrorMessage(message).addCause(cause).show(Main.this);
|
||||
stoppedState.enter();
|
||||
|
@ -107,6 +107,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
private ArrayList<Modification> modifications;
|
||||
private Circuit initialCircuit;
|
||||
private int undoPosition;
|
||||
private Style highLightStyle = Style.HIGHLIGHT;
|
||||
|
||||
|
||||
/**
|
||||
@ -558,8 +559,19 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
*/
|
||||
public void removeHighLighted() {
|
||||
highLighted.clear();
|
||||
highLightStyle = Style.HIGHLIGHT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the style used to highlight components
|
||||
*
|
||||
* @param highLightStyle the style to highlight components
|
||||
*/
|
||||
public void setHighLightStyle(Style highLightStyle) {
|
||||
this.highLightStyle = highLightStyle;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the given element to insert to the circuit
|
||||
*
|
||||
@ -624,7 +636,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
GraphicSwing gr = new GraphicSwing(gr2, (int) (2 / transform.getScaleX()));
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
circuit.drawTo(gr, highLighted, modelSync);
|
||||
circuit.drawTo(gr, highLighted, highLightStyle, modelSync);
|
||||
time = System.currentTimeMillis() - time;
|
||||
|
||||
if (time > 500) antiAlias = false;
|
||||
@ -1137,7 +1149,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
@Override
|
||||
public void drawTo(Graphic gr) {
|
||||
if (delta != null)
|
||||
element.drawTo(gr, true);
|
||||
element.drawTo(gr, Style.HIGHLIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1203,7 +1215,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic gr) {
|
||||
visualElement.drawTo(gr, true);
|
||||
visualElement.drawTo(gr, Style.HIGHLIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1293,7 +1305,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
@Override
|
||||
public void drawTo(Graphic gr) {
|
||||
// ensure that highlighted wire is visible by drawing it on top of other drawings.
|
||||
wire.drawTo(gr, true);
|
||||
wire.drawTo(gr, Style.HIGHLIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1350,7 +1362,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic gr) {
|
||||
wire.drawTo(gr, true);
|
||||
wire.drawTo(gr, Style.HIGHLIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1376,7 +1388,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
}
|
||||
|
||||
private void activate(Vector startPos) {
|
||||
startPos=raster(startPos);
|
||||
startPos = raster(startPos);
|
||||
activate(startPos, startPos);
|
||||
selectionMade = false;
|
||||
}
|
||||
@ -1387,7 +1399,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
wire1 = new Wire(startPos, endPos);
|
||||
wire2 = new Wire(startPos, endPos);
|
||||
selectionMade = true;
|
||||
lastPosition=endPos;
|
||||
lastPosition = endPos;
|
||||
setWires();
|
||||
}
|
||||
|
||||
@ -1447,8 +1459,8 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic gr) {
|
||||
wire1.drawTo(gr, true);
|
||||
wire2.drawTo(gr, true);
|
||||
wire1.drawTo(gr, Style.HIGHLIGHT);
|
||||
wire2.drawTo(gr, Style.HIGHLIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1684,7 +1696,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
if (elements != null)
|
||||
for (Movable m : elements)
|
||||
if (m instanceof Drawable)
|
||||
((Drawable) m).drawTo(gr, true);
|
||||
((Drawable) m).drawTo(gr, Style.HIGHLIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -140,7 +140,7 @@ public class DataSet implements Iterable<DataSample>, Drawable {
|
||||
|
||||
|
||||
@Override
|
||||
synchronized public void drawTo(Graphic g, boolean highLight) {
|
||||
synchronized public void drawTo(Graphic g, Style highLight) {
|
||||
int x = getTextBorder();
|
||||
|
||||
int yOffs = SIZE / 2;
|
||||
|
@ -29,7 +29,7 @@ public class DataSetComponent extends JComponent {
|
||||
g.setColor(Color.WHITE);
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
|
||||
dataSet.drawTo(new GraphicSwing(g2), false);
|
||||
dataSet.drawTo(new GraphicSwing(g2), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -117,10 +117,10 @@ public class DocuTest extends TestCase {
|
||||
|
||||
private void writeSVG(File imageFile, VisualElement ve) throws IOException {
|
||||
GraphicMinMax minMax = new GraphicMinMax(true);
|
||||
ve.drawTo(minMax, false);
|
||||
ve.drawTo(minMax, null);
|
||||
try (FileOutputStream out = new FileOutputStream(imageFile)) {
|
||||
try (GraphicSVG svg = new GraphicSVG(out, minMax.getMin(), minMax.getMax(), null, 20)) {
|
||||
ve.drawTo(svg, false);
|
||||
ve.drawTo(svg, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user