use of de.neemann.digital.draw.graphics.Style in project Digital by hneemann.
the class MissingShape method drawTo.
@Override
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);
Throwable c = cause;
int y = 4;
while (c != null) {
String message = c.getMessage();
if (message != null && message.length() > 0) {
if (message.length() > 100)
message = message.substring(0, 100) + "...";
y += style.getFontSize();
graphic.drawText(new Vector(4, y), new Vector(5, y), message, Orientation.LEFTTOP, style);
}
c = c.getCause();
}
}
use of de.neemann.digital.draw.graphics.Style in project Digital by hneemann.
the class Wire method drawTo.
@Override
public void drawTo(Graphic graphic, Style highLight) {
Style style = highLight;
if (style == null)
style = Style.getWireStyle(value);
graphic.drawLine(p1, p2, style);
if (value != null)
bits = value.getBits();
final boolean showBits = Settings.getInstance().get(Keys.SETTINGS_SHOW_WIRE_BITS);
final int wireLen = Math.abs(p1.x - p2.x);
if (value != null && p1.y == p2.y && wireLen > MIN_LABEL_WIRE_LEN && value.getBits() > 1) {
de.neemann.digital.draw.graphics.Orientation ori;
Vector pos = getRoundPos();
if (showBits) {
pos = pos.add(0, 3);
ori = de.neemann.digital.draw.graphics.Orientation.RIGHTTOP;
} else {
pos = pos.add(0, -3);
ori = de.neemann.digital.draw.graphics.Orientation.CENTERBOTTOM;
}
graphic.drawText(pos, pos.add(1, 0), value.toString(), ori, Style.WIRE_VALUE);
}
int minCrossLen = isConnectedToSplitter ? MIN_CROSS_WIRE_LEN_SPLITTER : MIN_CROSS_WIRE_LEN;
if (bits > 1 && p1.y == p2.y && wireLen >= minCrossLen && showBits) {
Vector pos = getRoundPos();
graphic.drawLine(pos.add(CROSS_LEN, CROSS_LEN), pos.add(-CROSS_LEN, -CROSS_LEN), Style.WIRE_BITS);
Vector numPos = pos.add(0, -3);
graphic.drawText(numPos, numPos.add(1, 0), Integer.toString(bits), de.neemann.digital.draw.graphics.Orientation.LEFTBOTTOM, Style.WIRE_BITS);
}
if (p1Dot || p2Dot) {
Vector r = new Vector(style.getThickness(), style.getThickness());
if (p1Dot)
graphic.drawCircle(p1.sub(r), p1.add(r), style);
if (p2Dot)
graphic.drawCircle(p2.sub(r), p2.add(r), style);
}
}
use of de.neemann.digital.draw.graphics.Style in project Digital by hneemann.
the class DiodeBackwardShape method drawTo.
@Override
public void drawTo(Graphic graphic, Style highLight) {
Style style = blown ? Style.DASH : Style.NORMAL;
graphic.drawPolygon(new Polygon(true).add(-SIZE2, -SIZE + 1).add(SIZE2, -SIZE + 1).add(0, -1), style);
graphic.drawLine(new Vector(-SIZE2, -1), new Vector(SIZE2, -1), style);
}
use of de.neemann.digital.draw.graphics.Style in project Digital by hneemann.
the class DiodeForewardShape method drawTo.
@Override
public void drawTo(Graphic graphic, Style highLight) {
Style style = blown ? Style.DASH : Style.NORMAL;
graphic.drawPolygon(new Polygon(true).add(-SIZE2, 1).add(SIZE2, 1).add(0, SIZE - 1), style);
graphic.drawLine(new Vector(-SIZE2, SIZE - 1), new Vector(SIZE2, SIZE - 1), style);
}