use of de.neemann.digital.draw.graphics.Style in project Digital by hneemann.
the class TextShape method drawTo.
@Override
public void drawTo(Graphic graphic, Style highLight) {
StringBuilder sb = new StringBuilder();
Style style = Style.NORMAL.deriveFontStyle(fontSize, true);
Vector pos = new Vector(0, 0);
final int dy = (style.getFontSize() * 20) / 16;
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
if (c == '\n') {
if (sb.length() > 0) {
graphic.drawText(pos, pos.add(1, 0), sb.toString(), Orientation.LEFTTOP, style);
sb.setLength(0);
}
pos = pos.add(0, dy);
} else
sb.append(c);
}
if (sb.length() > 0)
graphic.drawText(pos, pos.add(1, 0), sb.toString(), Orientation.LEFTTOP, style);
}
use of de.neemann.digital.draw.graphics.Style in project Digital by hneemann.
the class SixteenShape method drawTo.
@Override
public void drawTo(Graphic graphic, Style highLight) {
graphic.drawPolygon(SevenShape.FRAME, Style.NORMAL);
int bits = -1;
if (inValue != null)
bits = (int) inValue.getValue();
int mask = 1;
for (Polygon p : POLYGONS) {
Style s = onStyle;
if ((bits & mask) == 0)
s = offStyle;
graphic.drawPolygon(p, s);
mask <<= 1;
}
Style s = onStyle;
if (dpValue != null && !dpValue.getBool())
s = offStyle;
graphic.drawCircle(DOT, DOT.add(8, 8), s);
}
use of de.neemann.digital.draw.graphics.Style in project Digital by hneemann.
the class DataPlotter method drawTo.
@Override
public void drawTo(Graphic g, Style highLight) {
ValueTable data;
if (modelSync == NoSync.INST) {
data = dataOriginal;
} else {
data = modelSync.access(new Runnable() {
private ValueTable data;
@Override
public void run() {
data = new ValueTable(dataOriginal);
}
}).data;
}
int x = getTextBorder();
int yOffs = SIZE / 2;
int y = BORDER;
int signals = data.getColumns();
for (int i = 0; i < signals; i++) {
String text = data.getColumnName(i);
g.drawText(new Vector(x - 2, y + yOffs), new Vector(x + 1, y + yOffs), text, Orientation.RIGHTCENTER, Style.NORMAL);
g.drawLine(new Vector(x, y - SEP2), new Vector(x + (int) (size * data.getRows()), y - SEP2), Style.DASH);
y += SIZE + SEP;
}
g.drawLine(new Vector(x, y - SEP2), new Vector(x + (int) (size * data.getRows()), y - SEP2), Style.DASH);
int[] lastRy = new int[signals];
boolean first = true;
double pos = 0;
for (Value[] s : data) {
int xx = (int) (pos + x);
g.drawLine(new Vector(xx, BORDER - SEP2), new Vector(xx, (SIZE + SEP) * signals + BORDER - SEP2), Style.DASH);
y = BORDER;
for (int i = 0; i < signals; i++) {
Style style;
switch(s[i].getState()) {
case FAIL:
style = Style.FAILED;
break;
case PASS:
style = Style.PASS;
break;
default:
style = Style.NORMAL;
}
long width = data.getMax(i);
if (width == 0)
width = 1;
int ry;
ry = (int) (SIZE - (SIZE * s[i].getValue()) / width);
g.drawLine(new Vector(xx, y + ry), new Vector((int) (xx + size), y + ry), style);
if (!first && ry != lastRy[i])
g.drawLine(new Vector(xx, y + lastRy[i]), new Vector(xx, y + ry), style);
lastRy[i] = ry;
y += SIZE + SEP;
}
first = false;
pos += size;
}
g.drawLine(new Vector((int) (pos + x), BORDER - SEP2), new Vector((int) (pos + x), (SIZE + SEP) * signals + BORDER - SEP2), Style.DASH);
}
use of de.neemann.digital.draw.graphics.Style in project Digital by hneemann.
the class OutputShape method drawTo.
@Override
public void drawTo(Graphic graphic, Style highLight) {
if (graphic.isFlagSet(Graphic.LATEX)) {
Vector center = new Vector(LATEX_RAD.x, 0);
graphic.drawCircle(center.sub(LATEX_RAD), center.add(LATEX_RAD), Style.NORMAL);
Vector textPos = new Vector(SIZE2 + LATEX_RAD.x, 0);
graphic.drawText(textPos, textPos.add(1, 0), label, Orientation.LEFTCENTER, Style.INOUT);
} else {
Style style = Style.NORMAL;
if (value != null) {
style = Style.getWireStyle(value);
if (value.getBits() > 1) {
Vector textPos = new Vector(1 + SIZE, -4 - SIZE);
graphic.drawText(textPos, textPos.add(1, 0), format.formatToView(value), Orientation.CENTERBOTTOM, Style.NORMAL);
}
}
Vector center = new Vector(1 + SIZE, 0);
graphic.drawCircle(center.sub(RAD), center.add(RAD), style);
graphic.drawCircle(center.sub(RADL), center.add(RADL), Style.NORMAL);
Vector textPos = new Vector(SIZE * 3, 0);
graphic.drawText(textPos, textPos.add(1, 0), label, Orientation.LEFTCENTER, Style.INOUT);
}
}
use of de.neemann.digital.draw.graphics.Style in project Digital by hneemann.
the class DiodeShape 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);
}