Search in sources :

Example 41 with Vector

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

Example 42 with Vector

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

Example 43 with Vector

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

Example 44 with Vector

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

Example 45 with Vector

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