mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-18 09:24:42 -04:00
added some documentation
This commit is contained in:
parent
abcb49b2c7
commit
4c75bfd745
@ -158,9 +158,7 @@ public class VisualElement implements Drawable, Moveable, AttributeListener {
|
||||
// draw circle around element
|
||||
if (highLight) {
|
||||
GraphicMinMax mm = getMinMax();
|
||||
Vector delta = mm.getMax().sub(mm.getMin());
|
||||
int rad = (int) Math.sqrt(delta.x * delta.x + delta.y * delta.y) / 2;
|
||||
delta = new Vector(rad, rad);
|
||||
Vector delta = mm.getMax().sub(mm.getMin()).mul(3).div(5);
|
||||
Vector pos = mm.getMax().add(mm.getMin()).div(2);
|
||||
graphic.drawCircle(pos.sub(delta), pos.add(delta), Style.HIGHLIGHT);
|
||||
}
|
||||
|
@ -79,7 +79,6 @@ 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())
|
||||
@ -92,7 +91,6 @@ 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++)
|
||||
@ -119,7 +117,6 @@ 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,15 +27,12 @@ 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;
|
||||
@ -53,7 +50,6 @@ public class GraphicSwing implements Graphic {
|
||||
gr.fill(path);
|
||||
gr.draw(path);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawCircle(Vector p1, Vector p2, Style style) {
|
||||
|
@ -1,17 +1,46 @@
|
||||
package de.neemann.digital.draw.graphics;
|
||||
|
||||
/**
|
||||
* The text orientation
|
||||
*
|
||||
* @author hneemann
|
||||
*/
|
||||
public enum Orientation {
|
||||
/**
|
||||
* the anchor point is at the left side of the text at the bottom line
|
||||
*/
|
||||
LEFTBOTTOM(0, 0),
|
||||
/**
|
||||
* the anchor point is at the center of the text at the bottom line
|
||||
*/
|
||||
CENTERBOTTOM(1, 0),
|
||||
/**
|
||||
* the anchor point is at the right side of the text at the bottom line
|
||||
*/
|
||||
RIGHTBOTTOM(2, 0),
|
||||
/**
|
||||
* the anchor point is at the right side of the text in middle height
|
||||
*/
|
||||
RIGHTCENTER(2, 1),
|
||||
/**
|
||||
* the anchor point is at the right side of the text at the top of the text
|
||||
*/
|
||||
RIGHTTOP(2, 2),
|
||||
/**
|
||||
* the anchor point is at the center of the text at the top of the text
|
||||
*/
|
||||
CENTERTOP(1, 2),
|
||||
/**
|
||||
* the anchor point is at the left side of the text at the top of the text
|
||||
*/
|
||||
LEFTTOP(0, 2),
|
||||
/**
|
||||
* the anchor point is at the left side of the text in middle height
|
||||
*/
|
||||
LEFTCENTER(0, 1),
|
||||
/**
|
||||
* the anchor point is in the center of the text
|
||||
*/
|
||||
CENTERCENTER(1, 1);
|
||||
|
||||
|
||||
|
@ -8,18 +8,50 @@ import java.awt.*;
|
||||
* @author hneemann
|
||||
*/
|
||||
public class Style {
|
||||
/**
|
||||
* used for all lines to draw the shapes itself
|
||||
*/
|
||||
public static final Style NORMAL = new Style(4, false, Color.BLACK);
|
||||
/**
|
||||
* thin line used for the graphic in the clock or delay shape
|
||||
*/
|
||||
public static final Style THIN = new Style(2, false, Color.BLACK);
|
||||
/**
|
||||
* Used for wires in editing mode
|
||||
*/
|
||||
public static final Style WIRE = new Style(4, true, Color.BLUE.darker());
|
||||
/**
|
||||
* Used for low wires in running mode
|
||||
*/
|
||||
public static final Style WIRE_LOW = new Style(4, true, new Color(0, 112, 0));
|
||||
/**
|
||||
* Used for high wires in running mode
|
||||
*/
|
||||
public static final Style WIRE_HIGH = new Style(4, true, new Color(102, 255, 102));
|
||||
/**
|
||||
* Used for wires in high Z state
|
||||
*/
|
||||
public static final Style WIRE_HIGHZ = new Style(4, true, Color.GRAY);
|
||||
/**
|
||||
* used to draw the output dots
|
||||
*/
|
||||
public static final Style WIRE_OUT = new Style(4, true, Color.RED.darker());
|
||||
/**
|
||||
* filld style used to fill the splitter or the dark LEDs
|
||||
*/
|
||||
public static final Style FILLED = new Style(4, true, Color.BLACK);
|
||||
/**
|
||||
* Used to draw the grid in the graph
|
||||
*/
|
||||
public static final Style DASH = new Style(1, false, Color.BLACK, new float[]{4, 4});
|
||||
/**
|
||||
* Used todraw the pin description text
|
||||
*/
|
||||
public static final Style SHAPE_PIN = new Style(4, false, Color.GRAY, 18, null);
|
||||
/**
|
||||
* highlight color used for the circles to mark an element
|
||||
*/
|
||||
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;
|
||||
|
@ -5,7 +5,10 @@ import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.PinDescription;
|
||||
import de.neemann.digital.draw.elements.IOState;
|
||||
import de.neemann.digital.draw.elements.Pins;
|
||||
import de.neemann.digital.draw.graphics.*;
|
||||
import de.neemann.digital.draw.graphics.Graphic;
|
||||
import de.neemann.digital.draw.graphics.Orientation;
|
||||
import de.neemann.digital.draw.graphics.Style;
|
||||
import de.neemann.digital.draw.graphics.Vector;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
/**
|
||||
@ -41,13 +44,6 @@ public class TextShape implements Shape {
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user