use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.
the class FragmentSameInValue method addToCircuit.
@Override
public void addToCircuit(Vector pos, Circuit circuit) {
List<Vector> in = Vector.add(fragment.getInputs(), pos);
Vector last = null;
for (Vector v : in) {
Vector p = v.add(-SIZE, 0);
circuit.add(new Wire(v, p));
if (last != null)
circuit.add(new Wire(last, p));
last = p;
}
fragment.addToCircuit(pos, circuit);
}
use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.
the class FragmentVisualElement method doLayout.
@Override
public Box doLayout() {
GraphicMinMax mm = new GraphicMinMax();
for (Vector p : inputs) mm.check(p);
for (Vector p : outputs) mm.check(p);
Vector delta = mm.getMax().sub(mm.getMin());
if (visualElement.equalsDescription(FlipflopJK.DESCRIPTION) || visualElement.equalsDescription(FlipflopD.DESCRIPTION))
// Space for label
return new Box(delta.x, delta.y + SIZE);
else
return new Box(delta.x, delta.y);
}
use of de.neemann.digital.draw.graphics.Vector in project Digital by hneemann.
the class InsertAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (node.isUnique()) {
VisualElement visualElement = new VisualElement(node.getName()).setPos(new Vector(10, 10)).setShapeFactory(shapeFactory);
if (getIcon() == null) {
try {
node.getDescription();
setIcon(node.getIcon(shapeFactory));
} catch (IOException ex) {
SwingUtilities.invokeLater(new ErrorMessage(Lang.get("msg_errorImportingModel_N0", node.getName())).addCause(ex));
}
}
if (visualElement.getShape() instanceof MissingShape)
return;
circuitComponent.setPartToInsert(visualElement);
insertHistory.add(this);
}
}
use of de.neemann.digital.draw.graphics.Vector 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.Vector in project Digital by hneemann.
the class IEEENotShape method drawTo.
@Override
public void drawTo(Graphic graphic, Style highLight) {
graphic.drawPolygon(new Polygon(true).add(1, -SIZE2 - 2).add(SIZE - 1, 0).add(1, SIZE2 + 2), Style.NORMAL);
graphic.drawCircle(new Vector(SIZE + 1, -SIZE2 + 1), new Vector(SIZE * 2 - 1, SIZE2 - 1), Style.NORMAL);
}
Aggregations