use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.
the class CircuitComponent method getToolTipText.
@Override
public String getToolTipText(MouseEvent event) {
Vector pos = getPosVector(event);
VisualElement ve = circuit.getElementAt(pos);
if (ve != null) {
Pin p = circuit.getPinAt(raster(pos), ve);
if (p != null)
return createPinToolTip(p);
try {
ElementTypeDescription etd = library.getElementType(ve.getElementName());
String tt = etd.getDescription(ve.getElementAttributes());
final String pin = ve.getElementAttributes().get(Keys.PINNUMBER);
if (pin.length() > 0)
tt += " (" + Lang.get("msg_pin_N", pin) + ")";
return checkToolTip(tt);
} catch (ElementNotFoundException e) {
return null;
}
}
Wire w = circuit.getWireAt(pos, SIZE2);
if (w != null) {
ObservableValue v = w.getValue();
if (v != null)
return v.getValueString();
}
return null;
}
use of de.neemann.digital.draw.graphics.Vector 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.Vector in project Digital by hneemann.
the class WireContainsTest method testDiagonal.
public void testDiagonal() {
Wire w = new Wire(new Vector(0, 0), new Vector(10, 10));
assertFalse(w.contains(new Vector(0, 10), 5));
assertFalse(w.contains(new Vector(10, 0), 5));
assertFalse(w.contains(new Vector(16, 16), 5));
assertFalse(w.contains(new Vector(-6, -6), 5));
assertTrue(w.contains(new Vector(5, 5), 5));
assertTrue(w.contains(new Vector(6, 4), 5));
assertTrue(w.contains(new Vector(7, 3), 5));
assertTrue(w.contains(new Vector(8, 2), 5));
assertFalse(w.contains(new Vector(9, 1), 5));
assertTrue(w.contains(new Vector(4, 6), 5));
assertTrue(w.contains(new Vector(3, 7), 5));
assertTrue(w.contains(new Vector(2, 8), 5));
assertFalse(w.contains(new Vector(1, 9), 5));
assertTrue(w.contains(new Vector(6, 4), 3));
assertTrue(w.contains(new Vector(7, 3), 3));
assertFalse(w.contains(new Vector(8, 2), 3));
assertTrue(w.contains(new Vector(4, 6), 3));
assertTrue(w.contains(new Vector(3, 7), 3));
assertFalse(w.contains(new Vector(2, 8), 3));
}
use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.
the class WireMergerTest method testVertical.
public void testVertical() {
WireMerger.OrientationHandler handler = new WireMerger.OrientationHandlerVertical();
assertEquals(1, handler.getS(new Vector(3, 1)));
assertEquals(3, handler.getWireClass(new Vector(3, 1)));
Wire wire = handler.toWire(new WireMerger.SimpleWire(1, 3, 7));
assertEquals(new Vector(1, 3), wire.p1);
assertEquals(new Vector(1, 7), wire.p2);
}
use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.
the class NetListTest method testTunnel2.
public void testTunnel2() throws Exception {
Circuit c = new Circuit();
c.add(new Wire(new Vector(1, 1), new Vector(2, 1)));
addTunnel(c, new Vector(2, 1), "A");
c.add(new Wire(new Vector(3, 1), new Vector(4, 1)));
addTunnel(c, new Vector(3, 1), "A");
c.add(new Wire(new Vector(1, 4), new Vector(2, 4)));
addTunnel(c, new Vector(2, 4), "B");
c.add(new Wire(new Vector(3, 4), new Vector(4, 4)));
addTunnel(c, new Vector(3, 4), "B");
NetList ns = new NetList(c);
assertEquals(2, ns.size());
}
Aggregations