mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-14 15:26:52 -04:00
increased graphics resolution by factor 2
This commit is contained in:
parent
59472aeb92
commit
000d1bc6fb
@ -35,6 +35,7 @@ public class Circuit {
|
||||
ATTR_LIST.add(AttributeKey.Width);
|
||||
}
|
||||
|
||||
private int version = 1;
|
||||
private ElementAttributes attributes;
|
||||
private final ArrayList<VisualElement> visualElements;
|
||||
private ArrayList<Wire> wires;
|
||||
@ -63,6 +64,18 @@ public class Circuit {
|
||||
Circuit circuit = (Circuit) xStream.fromXML(in);
|
||||
for (VisualElement ve : circuit.getElements())
|
||||
ve.setShapeFactory(shapeFactory);
|
||||
|
||||
if (circuit.version == 0) {
|
||||
// convert to version 1
|
||||
for (Wire w : circuit.getWires()) {
|
||||
w.p1 = w.p1.mul(2);
|
||||
w.p2 = w.p2.mul(2);
|
||||
}
|
||||
for (VisualElement e : circuit.getElements())
|
||||
e.setPos(e.getPos().mul(2));
|
||||
circuit.version = 1;
|
||||
}
|
||||
|
||||
return circuit;
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import java.awt.image.BufferedImage;
|
||||
* @author hneemann
|
||||
*/
|
||||
public class VisualElement implements Drawable, Moveable, AttributeListener {
|
||||
private static final int PIN = 1;
|
||||
private static final int PIN = 2;
|
||||
private final String elementName;
|
||||
private final ElementAttributes elementAttributes;
|
||||
private transient GraphicMinMax minMax;
|
||||
@ -142,10 +142,10 @@ public class VisualElement implements Drawable, Moveable, AttributeListener {
|
||||
public ImageIcon createIcon(int maxHeight) {
|
||||
GraphicMinMax mm = getMinMax();
|
||||
|
||||
if (mm.getMax().y - mm.getMin().y > maxHeight)
|
||||
if (mm.getMax().y - mm.getMin().y > maxHeight * 2)
|
||||
return null;
|
||||
|
||||
BufferedImage bi = new BufferedImage(mm.getMax().x - mm.getMin().x + 4, mm.getMax().y - mm.getMin().y + 4, BufferedImage.TYPE_INT_ARGB);
|
||||
BufferedImage bi = new BufferedImage((mm.getMax().x - mm.getMin().x + 4) / 2 + 1, (mm.getMax().y - mm.getMin().y + 4) / 2 + 1, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D gr = bi.createGraphics();
|
||||
gr.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
gr.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
@ -154,6 +154,7 @@ public class VisualElement implements Drawable, Moveable, AttributeListener {
|
||||
|
||||
gr.setColor(new Color(255, 255, 255, 0));
|
||||
gr.fillRect(0, 0, bi.getWidth(), bi.getHeight());
|
||||
gr.scale(0.5, 0.5);
|
||||
gr.translate(2 - mm.getMin().x, 2 - mm.getMin().y);
|
||||
GraphicSwing grs = new GraphicSwing(gr);
|
||||
drawTo(grs, false);
|
||||
|
@ -10,7 +10,7 @@ import de.neemann.digital.draw.shapes.Drawable;
|
||||
* @author hneemann
|
||||
*/
|
||||
public class Wire implements Drawable, Moveable {
|
||||
private static final int MIN_LABEL_LEN = 50;
|
||||
private static final int MIN_LABEL_LEN = 100;
|
||||
public Vector p1;
|
||||
public Vector p2;
|
||||
private transient ObservableValue value;
|
||||
|
@ -7,7 +7,7 @@ import java.util.Date;
|
||||
* @author hneemann
|
||||
*/
|
||||
public class GraphicSVG implements Graphic, Closeable {
|
||||
private static final int DEF_SCALE = 30;
|
||||
private static final int DEF_SCALE = 15;
|
||||
private final BufferedWriter w;
|
||||
|
||||
public GraphicSVG(File file, Vector min, Vector max) throws IOException {
|
||||
|
@ -54,7 +54,7 @@ public class GraphicSVGLaTeX extends GraphicSVG {
|
||||
|
||||
@Override
|
||||
public void drawCircle(Vector p1, Vector p2, Style style) {
|
||||
if ((style != Style.WIRE && style != Style.WIRE_OUT) || Math.abs(p1.x - p2.x) > 2)
|
||||
if ((style != Style.WIRE && style != Style.WIRE_OUT) || Math.abs(p1.x - p2.x) > 4)
|
||||
super.drawCircle(p1, p2, style);
|
||||
}
|
||||
|
||||
|
@ -8,16 +8,16 @@ import java.awt.*;
|
||||
* @author hneemann
|
||||
*/
|
||||
public class Style {
|
||||
public static final Style NORMAL = new Style(2, false, Color.BLACK);
|
||||
public static final Style WIRE = new Style(2, true, Color.BLUE.darker());
|
||||
public static final Style WIRE_LOW = new Style(2, true, new Color(0, 112, 0));
|
||||
public static final Style WIRE_HIGH = new Style(2, true, new Color(102, 255, 102));
|
||||
public static final Style WIRE_HIGHZ = new Style(2, true, Color.GRAY);
|
||||
public static final Style WIRE_OUT = new Style(2, true, Color.RED.darker());
|
||||
public static final Style FILLED = new Style(2, true, Color.BLACK);
|
||||
public static final Style DASH = new Style(0, false, Color.BLACK, new float[]{2, 2});
|
||||
public static final Style SHAPE_PIN = new Style(2, false, Color.GRAY, 9, null);
|
||||
public static final Style HIGHLIGHT = new Style(2, false, Color.CYAN);
|
||||
public static final Style NORMAL = new Style(4, false, Color.BLACK);
|
||||
public static final Style WIRE = new Style(4, true, Color.BLUE.darker());
|
||||
public static final Style WIRE_LOW = new Style(4, true, new Color(0, 112, 0));
|
||||
public static final Style WIRE_HIGH = new Style(4, true, new Color(102, 255, 102));
|
||||
public static final Style WIRE_HIGHZ = new Style(4, true, Color.GRAY);
|
||||
public static final Style WIRE_OUT = new Style(4, true, Color.RED.darker());
|
||||
public static final Style FILLED = new Style(4, true, Color.BLACK);
|
||||
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);
|
||||
|
||||
private final int thickness;
|
||||
private final boolean filled;
|
||||
@ -28,11 +28,11 @@ public class Style {
|
||||
private final Font font;
|
||||
|
||||
public Style(int thickness, boolean filled, Color color, float[] dash) {
|
||||
this(thickness, filled, color, 12, dash);
|
||||
this(thickness, filled, color, 24, dash);
|
||||
}
|
||||
|
||||
public Style(int thickness, boolean filled, Color color) {
|
||||
this(thickness, filled, color, 12, null);
|
||||
this(thickness, filled, color, 24, null);
|
||||
}
|
||||
|
||||
private Style(int thickness, boolean filled, Color color, int fontsize, float[] dash) {
|
||||
|
@ -13,8 +13,8 @@ import de.neemann.digital.draw.graphics.Vector;
|
||||
* @author hneemann
|
||||
*/
|
||||
public class BreakShape implements Shape {
|
||||
private static final int SIZE = 8;
|
||||
private static final int SIZEQ = 3;
|
||||
public static final int SIZE = GenericShape.SIZE * 3 / 4;
|
||||
private static final int SIZEQ = SIZE / 2;
|
||||
private static final Vector RAD = new Vector(SIZE, SIZE);
|
||||
private static final Vector D1 = new Vector(SIZEQ, -SIZEQ);
|
||||
private static final Vector D2 = new Vector(SIZEQ, SIZEQ);
|
||||
|
@ -49,8 +49,8 @@ public class DriverShape implements Shape {
|
||||
, Style.NORMAL
|
||||
);
|
||||
if (bottom)
|
||||
graphic.drawLine(new Vector(0, SIZE), new Vector(0, 4), Style.NORMAL);
|
||||
graphic.drawLine(new Vector(0, SIZE), new Vector(0, 7), Style.NORMAL);
|
||||
else
|
||||
graphic.drawLine(new Vector(0, -SIZE), new Vector(0, -4), Style.NORMAL);
|
||||
graphic.drawLine(new Vector(0, -SIZE), new Vector(0, -7), Style.NORMAL);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import de.neemann.digital.draw.graphics.*;
|
||||
* @author hneemann
|
||||
*/
|
||||
public class GenericShape implements Shape {
|
||||
public static final int SIZE2 = 5;
|
||||
public static final int SIZE2 = 10;
|
||||
public static final int SIZE = SIZE2 * 2;
|
||||
|
||||
private final String name;
|
||||
@ -99,8 +99,8 @@ public class GenericShape implements Shape {
|
||||
|
||||
graphic.drawPolygon(new Polygon(true)
|
||||
.add(1, -SIZE2)
|
||||
.add(SIZE * width - (invert ? 0 : 1), -SIZE2)
|
||||
.add(SIZE * width - (invert ? 0 : 1), height)
|
||||
.add(SIZE * width - 1, -SIZE2)
|
||||
.add(SIZE * width - 1, height)
|
||||
.add(1, height), Style.NORMAL);
|
||||
|
||||
if (invert) {
|
||||
|
@ -18,7 +18,7 @@ import static de.neemann.digital.draw.shapes.OutputShape.SIZE;
|
||||
* @author hneemann
|
||||
*/
|
||||
public class LEDShape implements Shape {
|
||||
public static final Vector RAD = new Vector(SIZE - 1, SIZE - 1);
|
||||
public static final Vector RAD = new Vector(SIZE - 2, SIZE - 2);
|
||||
public static final Vector RADL = new Vector(SIZE, SIZE);
|
||||
private final String label;
|
||||
private Style onStyle;
|
||||
|
@ -14,8 +14,8 @@ import de.neemann.digital.draw.graphics.Vector;
|
||||
* @author hneemann
|
||||
*/
|
||||
public class OutputShape implements Shape {
|
||||
public static final int SIZE = 8;
|
||||
public static final Vector RAD = new Vector(SIZE - 3, SIZE - 3);
|
||||
public static final int SIZE = GenericShape.SIZE * 3 / 4;
|
||||
public static final Vector RAD = new Vector(SIZE - 6, SIZE - 6);
|
||||
public static final Vector RADL = new Vector(SIZE, SIZE);
|
||||
private final String label;
|
||||
private IOState ioState;
|
||||
|
@ -15,8 +15,8 @@ import static de.neemann.digital.draw.shapes.GenericShape.SIZE2;
|
||||
*/
|
||||
public abstract class SevenShape implements Shape {
|
||||
protected static final int HEIGHT = 7;
|
||||
private static final Vector ofs = new Vector(2, 8);
|
||||
private static final int LEN = 26;
|
||||
private static final Vector ofs = new Vector(1, 12);
|
||||
private static final int LEN = 56;
|
||||
|
||||
|
||||
private final String label;
|
||||
@ -25,28 +25,30 @@ public abstract class SevenShape implements Shape {
|
||||
|
||||
public SevenShape(String label, Color color) {
|
||||
this.label = label;
|
||||
onStyle = new Style(4, true, color);
|
||||
offStyle = new Style(4, true, new Color(230, 230, 230));
|
||||
onStyle = new Style(8, true, color);
|
||||
offStyle = new Style(8, true, new Color(230, 230, 230));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTo(Graphic graphic, boolean highLight) {
|
||||
graphic.drawPolygon(new Polygon(true)
|
||||
.add(-SIZE2, 0)
|
||||
.add(SIZE * 3 + SIZE2, 0)
|
||||
.add(SIZE * 3 + SIZE2, HEIGHT * SIZE)
|
||||
.add(-SIZE2, HEIGHT * SIZE), Style.NORMAL);
|
||||
.add(-SIZE2, 1)
|
||||
.add(SIZE * 3 + SIZE2, 1)
|
||||
.add(SIZE * 3 + SIZE2, HEIGHT * SIZE - 1)
|
||||
.add(-SIZE2, HEIGHT * SIZE - 1), Style.NORMAL);
|
||||
|
||||
int th = onStyle.getThickness();
|
||||
int th = onStyle.getThickness() + 1;
|
||||
int slant = 2;
|
||||
int dot = 4;
|
||||
int o = 4;
|
||||
graphic.drawLine(new Vector(th + slant, 0).add(ofs), new Vector(LEN - th + slant, 0).add(ofs), getStyle(0));
|
||||
graphic.drawLine(new Vector(LEN + slant, th).add(ofs), new Vector(LEN, LEN - th).add(ofs), getStyle(1));
|
||||
graphic.drawLine(new Vector(LEN, LEN + th).add(ofs), new Vector(LEN - slant, 2 * LEN - th).add(ofs), getStyle(2));
|
||||
graphic.drawLine(new Vector(LEN + slant, th - o).add(ofs), new Vector(LEN, LEN - th + o).add(ofs), getStyle(1));
|
||||
graphic.drawLine(new Vector(LEN, LEN + th - o).add(ofs), new Vector(LEN - slant, 2 * LEN - th + o).add(ofs), getStyle(2));
|
||||
graphic.drawLine(new Vector(th - slant, 2 * LEN).add(ofs), new Vector(LEN - th - slant, 2 * LEN).add(ofs), getStyle(3));
|
||||
graphic.drawLine(new Vector(0, LEN + th).add(ofs), new Vector(-slant, 2 * LEN - th).add(ofs), getStyle(4));
|
||||
graphic.drawLine(new Vector(slant, th).add(ofs), new Vector(0, LEN - th).add(ofs), getStyle(5));
|
||||
graphic.drawLine(new Vector(0, LEN + th - o).add(ofs), new Vector(-slant, 2 * LEN - th + o).add(ofs), getStyle(4));
|
||||
graphic.drawLine(new Vector(slant, th - o).add(ofs), new Vector(0, LEN - th + o).add(ofs), getStyle(5));
|
||||
graphic.drawLine(new Vector(th, LEN).add(ofs), new Vector(LEN - th, LEN).add(ofs), getStyle(6));
|
||||
graphic.drawCircle(new Vector(LEN, LEN * 2 - slant).add(ofs), new Vector(LEN + slant * 2, LEN * 2 + slant).add(ofs), getStyle(7));
|
||||
graphic.drawCircle(new Vector(LEN + dot - 1, LEN * 2 - slant - 1).add(ofs), new Vector(LEN + slant * 2 + dot + 1, LEN * 2 + slant + 1).add(ofs), getStyle(7));
|
||||
}
|
||||
|
||||
protected abstract Style getStyle(int i);
|
||||
|
Loading…
x
Reference in New Issue
Block a user