use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.
the class IEEEXOrShape method drawIEEE.
@Override
protected void drawIEEE(Graphic graphic) {
graphic.drawLine(new Vector(0, 0), new Vector(5 + SIZE2, 0), Style.WIRE);
graphic.drawLine(new Vector(0, SIZE * 2), new Vector(5 + SIZE2, SIZE * 2), Style.WIRE);
graphic.drawPolygon(POLYGON, Style.NORMAL);
graphic.drawPolygon(POLYGON2, Style.NORMAL);
}
use of de.neemann.digital.draw.graphics.Vector 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.Vector in project Digital by hneemann.
the class ProbeShape method drawTo.
@Override
public void drawTo(Graphic graphic, Style highLight) {
int dy = -1;
Orientation orientation = Orientation.LEFTCENTER;
if (isLabel) {
graphic.drawText(new Vector(2, -4), new Vector(3, -4), label, Orientation.LEFTBOTTOM, Style.NORMAL);
dy = 4;
orientation = Orientation.LEFTTOP;
}
String v = "?";
if (inValueCopy != null)
v = format.formatToView(inValueCopy);
graphic.drawText(new Vector(2, dy), new Vector(3, dy), v, orientation, Style.NORMAL);
}
use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.
the class ModifyMoveSelected method rotateElements.
/**
* Rotates the given elements
*
* @param elements the elements to rotate
* @param center the center position
*/
public static void rotateElements(ArrayList<Movable> elements, Vector center) {
Transform transform = new TransformRotate(center, 1) {
@Override
public Vector transform(Vector v) {
return super.transform(v.sub(center));
}
@Override
public VectorFloat transform(VectorFloat v) {
return super.transform(v.sub(center));
}
};
for (Movable m : elements) {
if (m instanceof VisualElement) {
VisualElement ve = (VisualElement) m;
ve.rotate();
ve.setPos(transform.transform(ve.getPos()));
} else if (m instanceof Wire) {
Wire w = (Wire) m;
w.p1 = transform.transform(w.p1);
w.p2 = transform.transform(w.p2);
} else {
Vector p = m.getPos();
Vector t = transform.transform(p);
m.move(t.sub(p));
}
}
}
use of de.neemann.digital.draw.graphics.Vector 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);
}
}
Aggregations