Search in sources :

Example 6 with Vector

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);
}
Also used : Wire(de.neemann.digital.draw.elements.Wire) Vector(de.neemann.digital.draw.graphics.Vector)

Example 7 with Vector

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);
}
Also used : GraphicMinMax(de.neemann.digital.draw.graphics.GraphicMinMax) Vector(de.neemann.digital.draw.graphics.Vector)

Example 8 with Vector

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);
    }
}
Also used : VisualElement(de.neemann.digital.draw.elements.VisualElement) IOException(java.io.IOException) ErrorMessage(de.neemann.gui.ErrorMessage) Vector(de.neemann.digital.draw.graphics.Vector) MissingShape(de.neemann.digital.draw.shapes.MissingShape)

Example 9 with Vector

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);
}
Also used : Style(de.neemann.digital.draw.graphics.Style) Vector(de.neemann.digital.draw.graphics.Vector)

Example 10 with Vector

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);
}
Also used : Polygon(de.neemann.digital.draw.graphics.Polygon) Vector(de.neemann.digital.draw.graphics.Vector)

Aggregations

Vector (de.neemann.digital.draw.graphics.Vector)63 Wire (de.neemann.digital.draw.elements.Wire)13 Polygon (de.neemann.digital.draw.graphics.Polygon)12 VisualElement (de.neemann.digital.draw.elements.VisualElement)9 Style (de.neemann.digital.draw.graphics.Style)8 Circuit (de.neemann.digital.draw.elements.Circuit)6 Pin (de.neemann.digital.draw.elements.Pin)3 Pins (de.neemann.digital.draw.elements.Pins)3 ArrayList (java.util.ArrayList)3 Rotation (de.neemann.digital.core.element.Rotation)2 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)2 ElementNotFoundException (de.neemann.digital.draw.library.ElementNotFoundException)2 ShapeFactory (de.neemann.digital.draw.shapes.ShapeFactory)2 IOException (java.io.IOException)2 NodeException (de.neemann.digital.core.NodeException)1 ObservableValue (de.neemann.digital.core.ObservableValue)1 Movable (de.neemann.digital.draw.elements.Movable)1 GraphicMinMax (de.neemann.digital.draw.graphics.GraphicMinMax)1 Orientation (de.neemann.digital.draw.graphics.Orientation)1 Transform (de.neemann.digital.draw.graphics.Transform)1