mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-19 09:54:49 -04:00
Added simple Text which can be placed on the circuit.
This commit is contained in:
parent
d09e9ca9cd
commit
6b31d36e90
@ -159,7 +159,18 @@
|
||||
<string>Data</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="120" y="-60"/>
|
||||
<pos x="120" y="-40"/>
|
||||
<rotate>0</rotate>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Text</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>Synchroner Zähler aus JK-Flipflops</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="140" y="-80"/>
|
||||
<rotate>0</rotate>
|
||||
</visualElement>
|
||||
</visualElements>
|
||||
|
@ -133,7 +133,18 @@
|
||||
<string>Data</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="220" y="100"/>
|
||||
<pos x="220" y="120"/>
|
||||
<rotate>0</rotate>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Text</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>Asynchroner Zähler aus T-Flipflops</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="260" y="80"/>
|
||||
<rotate>0</rotate>
|
||||
</visualElement>
|
||||
</visualElements>
|
||||
|
@ -79,6 +79,7 @@ public class GraphicSVG implements Graphic, Closeable {
|
||||
|
||||
@Override
|
||||
public void drawLine(Vector p1, Vector p2, Style style) {
|
||||
if (style != Style.INVISIBLE)
|
||||
try {
|
||||
w.write("<line x1=\"" + p1.x + "\" y1=\"" + p1.y + "\" x2=\"" + p2.x + "\" y2=\"" + p2.y + "\" stroke=\"" + getColor(style) + "\" stroke-linecap=\"square\" stroke-width=\"" + getStrokeWidth(style) + "\"");
|
||||
// if (style.isDashed())
|
||||
@ -91,6 +92,7 @@ public class GraphicSVG implements Graphic, Closeable {
|
||||
|
||||
@Override
|
||||
public void drawPolygon(Polygon p, Style style) {
|
||||
if (style != Style.INVISIBLE)
|
||||
try {
|
||||
w.write("<path d=\"M " + str(p.get(0)));
|
||||
for (int i = 1; i < p.size(); i++)
|
||||
@ -117,6 +119,7 @@ public class GraphicSVG implements Graphic, Closeable {
|
||||
|
||||
@Override
|
||||
public void drawCircle(Vector p1, Vector p2, Style style) {
|
||||
if (style != Style.INVISIBLE)
|
||||
try {
|
||||
Vector c = p1.add(p2).div(2);
|
||||
double r = Math.abs(p2.sub(p1).x) / 2.0;
|
||||
|
@ -27,12 +27,15 @@ public class GraphicSwing implements Graphic {
|
||||
|
||||
@Override
|
||||
public void drawLine(Vector p1, Vector p2, Style style) {
|
||||
if (style != Style.INVISIBLE) {
|
||||
applyStyle(style);
|
||||
gr.drawLine(p1.x, p1.y, p2.x, p2.y);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPolygon(Polygon p, Style style) {
|
||||
if (style != Style.INVISIBLE) {
|
||||
applyStyle(style);
|
||||
Path2D path = new GeneralPath();
|
||||
boolean first = true;
|
||||
@ -50,6 +53,7 @@ public class GraphicSwing implements Graphic {
|
||||
gr.fill(path);
|
||||
gr.draw(path);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawCircle(Vector p1, Vector p2, Style style) {
|
||||
|
@ -19,6 +19,7 @@ public class Style {
|
||||
public static final Style DASH = new Style(1, false, Color.BLACK, new float[]{4, 4});
|
||||
public static final Style SHAPE_PIN = new Style(4, false, Color.GRAY, 18, null);
|
||||
public static final Style HIGHLIGHT = new Style(4, false, Color.CYAN);
|
||||
public static final Style INVISIBLE = new Style(0, false, Color.WHITE);
|
||||
|
||||
private final int thickness;
|
||||
private final boolean filled;
|
||||
|
@ -51,6 +51,7 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
|
||||
add(Out.SEVENHEXDESCRIPTION, menu);
|
||||
add(Terminal.DESCRIPTION, menu);
|
||||
add(DummyElement.DATADESCRIPTION, menu);
|
||||
add(DummyElement.TEXTDESCRIPTION, menu);
|
||||
|
||||
menu = Lang.get("lib_mux");
|
||||
add(Multiplexer.DESCRIPTION, menu);
|
||||
|
@ -1,24 +0,0 @@
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.draw.elements.Pin;
|
||||
|
||||
/**
|
||||
* @author hneemann
|
||||
*/
|
||||
public class OutputPinInfo {
|
||||
private final String name;
|
||||
private final Pin.Direction direction;
|
||||
|
||||
public OutputPinInfo(String name, boolean bidirectional) {
|
||||
this.name = name;
|
||||
this.direction = bidirectional ? Pin.Direction.both : Pin.Direction.output;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Pin.Direction getDirection() {
|
||||
return direction;
|
||||
}
|
||||
}
|
@ -60,6 +60,8 @@ public final class ShapeFactory {
|
||||
|
||||
map.put(Splitter.DESCRIPTION.getName(), SplitterShape::new);
|
||||
map.put(Driver.DESCRIPTION.getName(), DriverShape::new);
|
||||
|
||||
map.put(DummyElement.TEXTDESCRIPTION.getName(), TextShape::new);
|
||||
}
|
||||
|
||||
private PinDescription[] outputInfos(ElementTypeDescription description, ElementAttributes attributes) {
|
||||
|
52
src/main/java/de/neemann/digital/draw/shapes/TextShape.java
Normal file
52
src/main/java/de/neemann/digital/draw/shapes/TextShape.java
Normal file
@ -0,0 +1,52 @@
|
||||
package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
import de.neemann.digital.draw.elements.Pins;
|
||||
import de.neemann.digital.draw.graphics.*;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
/**
|
||||
* Simple text
|
||||
*
|
||||
* @author hneemann
|
||||
*/
|
||||
public class TextShape implements Shape {
|
||||
private final String label;
|
||||
|
||||
/**
|
||||
* Create a new instance
|
||||
*
|
||||
* @param attr attributes
|
||||
*/
|
||||
public TextShape(ElementAttributes attr) {
|
||||
String text = attr.getLabel();
|
||||
if (text.length() == 0)
|
||||
text = Lang.get("elem_Text");
|
||||
this.label = text;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pins getPins() {
|
||||
return new Pins();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interactor applyStateMonitor(IOState ioState, Observer guiObserver) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
int size = Style.NORMAL.getFontSize();
|
||||
graphic.drawPolygon(
|
||||
new Polygon(true)
|
||||
.add(0, 0)
|
||||
.add(size * 2, 0)
|
||||
.add(size * 2, size)
|
||||
.add(0, size), Style.INVISIBLE);
|
||||
graphic.drawText(new Vector(0, 0), new Vector(1, 0), label, Orientation.LEFTTOP, Style.NORMAL);
|
||||
}
|
||||
}
|
@ -22,6 +22,12 @@ public class DummyElement implements Element {
|
||||
public static final ElementTypeDescription DATADESCRIPTION = new ElementTypeDescription("Data", DummyElement.class)
|
||||
.addAttribute(AttributeKey.MicroStep);
|
||||
|
||||
/**
|
||||
* The TextElement description
|
||||
*/
|
||||
public static final ElementTypeDescription TEXTDESCRIPTION = new ElementTypeDescription("Text", DummyElement.class)
|
||||
.addAttribute(AttributeKey.Label);
|
||||
|
||||
/**
|
||||
* Creates a new dummy element
|
||||
*
|
||||
|
@ -96,6 +96,7 @@ elem_Reset_tt=Der Ausgang dieses Elements ist Null, solange sich das Model nach
|
||||
elem_Break_tt=Wenn der Eingang dieses Elementes zu Eins wird, wird der schnelle Simulationslauf beendet.\nDieses Element kann verwendet werden, um einen Assemblerbefehl BRK zu implementieren.\nEs kann dann ein Programm bis zum n\u00E4chsten BRK-Befehl ausgef\u00FChrt werden.
|
||||
elem_RAMDualPort_tt=Ein RAM Modul mit getrennten Anschl\u00FCssen f\u00FCr Lesen und Schreiben.\nEin gibt einen Eingang f\u00FCr das Beschreiben und einen Ausgang f\u00FCr das Auslesen der gespeicherten Daten.
|
||||
elem_RAMSinglePort_tt=Ein RAM Module mit einem bidirektionellem Anschluss f\u00FCr das Lesen und Schreiben von Daten.
|
||||
elem_Text=Text
|
||||
|
||||
rot_0=0\u00B0
|
||||
rot_90=90\u00B0
|
||||
|
@ -96,6 +96,7 @@ elem_Add=Add
|
||||
elem_Sub=Sub
|
||||
elem_Mul=Mul
|
||||
elem_Comparator=Comparator
|
||||
elem_Text=Text
|
||||
|
||||
rot_0=0\u00B0
|
||||
rot_90=90\u00B0
|
||||
|
Loading…
x
Reference in New Issue
Block a user