Search in sources :

Example 16 with Polygon

use of de.neemann.digital.draw.graphics.Polygon in project Digital by hneemann.

the class DiodeForewardShape method drawTo.

@Override
public void drawTo(Graphic graphic, Style highLight) {
    Style style = blown ? Style.DASH : Style.NORMAL;
    graphic.drawPolygon(new Polygon(true).add(-SIZE2, 1).add(SIZE2, 1).add(0, SIZE - 1), style);
    graphic.drawLine(new Vector(-SIZE2, SIZE - 1), new Vector(SIZE2, SIZE - 1), style);
}
Also used : Style(de.neemann.digital.draw.graphics.Style) Polygon(de.neemann.digital.draw.graphics.Polygon) Vector(de.neemann.digital.draw.graphics.Vector)

Example 17 with Polygon

use of de.neemann.digital.draw.graphics.Polygon in project Digital by hneemann.

the class FETShapeN method drawTo.

@Override
public void drawTo(Graphic graphic, Style highLight) {
    super.drawTo(graphic, highLight);
    // the arrow
    graphic.drawLine(new Vector(SIZE2 + 5, SIZE), new Vector(SIZE, SIZE), Style.THIN);
    graphic.drawPolygon(new Polygon(true).add(SIZE2 + 2, SIZE).add(SIZE - SIZE2 / 3, SIZE - SIZE2 / 4).add(SIZE - SIZE2 / 3, SIZE + SIZE2 / 4), Style.THIN_FILLED);
}
Also used : Polygon(de.neemann.digital.draw.graphics.Polygon) Vector(de.neemann.digital.draw.graphics.Vector)

Example 18 with Polygon

use of de.neemann.digital.draw.graphics.Polygon in project Digital by hneemann.

the class GenericShape method drawTo.

@Override
public void drawTo(Graphic graphic, Style highLight) {
    int max = Math.max(inputs.size(), outputs.size());
    int height = (max - 1) * SIZE + SIZE2;
    if (symmetric && inputs.size() > 0 && ((inputs.size() & 1) == 0))
        height += SIZE;
    Polygon polygon = new Polygon(true).add(1, -SIZE2).add(SIZE * width - 1, -SIZE2).add(SIZE * width - 1, height).add(1, height);
    if (color != Color.WHITE && !graphic.isFlagSet(Graphic.LATEX))
        graphic.drawPolygon(polygon, Style.NORMAL.deriveFillStyle(color));
    graphic.drawPolygon(polygon, Style.NORMAL);
    if (invert) {
        int offs = symmetric ? inputs.size() / 2 * SIZE : 0;
        for (int i = 0; i < outputs.size(); i++) graphic.drawCircle(new Vector(SIZE * width + 1, i * SIZE - SIZE2 + 1 + offs), new Vector(SIZE * (width + 1) - 1, i * SIZE + SIZE2 - 1 + offs), Style.NORMAL);
    }
    if (label != null) {
        Vector pos = new Vector(SIZE2 * width, -SIZE2 - 8);
        graphic.drawText(pos, pos.add(1, 0), label, Orientation.CENTERBOTTOM, Style.NORMAL);
    }
    if (showPinLabels) {
        for (Pin p : getPins()) {
            int dx = 4;
            if (isInverted(p.getName(), inverterConfig))
                dx += SIZE;
            if (p.getDirection() == Pin.Direction.input) {
                if (p.isClock()) {
                    final int triangle = SIZE2 / 2 + 2;
                    graphic.drawPolygon(new Polygon(false).add(p.getPos().add(dx - 3, triangle)).add(p.getPos().add(dx + triangle - 3, 0)).add(p.getPos().add(dx - 3, -triangle)), Style.THIN);
                    dx += triangle;
                }
                graphic.drawText(p.getPos().add(dx, 0), p.getPos().add(dx + 1, 0), p.getName(), Orientation.LEFTCENTER, Style.SHAPE_PIN);
            } else
                graphic.drawText(p.getPos().add(-4, 0), p.getPos().add(5, 0), p.getName(), Orientation.RIGHTCENTER, Style.SHAPE_PIN);
        }
    }
    if (name.length() > 0) {
        if (name.length() <= 3 && !showPinLabels) {
            Vector pos = new Vector(SIZE2 * width, -SIZE2 + 4);
            graphic.drawText(pos, pos.add(1, 0), name, Orientation.CENTERTOP, Style.NORMAL);
        } else {
            Vector pos = new Vector(SIZE2 * width, height + 4);
            graphic.drawText(pos, pos.add(1, 0), name, Orientation.CENTERTOP, Style.SHAPE_PIN);
        }
    }
    drawInputInvert(graphic, inverterConfig, getPins());
}
Also used : Pin(de.neemann.digital.draw.elements.Pin) Polygon(de.neemann.digital.draw.graphics.Polygon)

Example 19 with Polygon

use of de.neemann.digital.draw.graphics.Polygon in project Digital by hneemann.

the class InputShape method drawTo.

@Override
public void drawTo(Graphic graphic, Style heighLight) {
    if (graphic.isFlagSet(Graphic.LATEX)) {
        Vector center = new Vector(-LATEX_RAD.x, 0);
        graphic.drawCircle(center.sub(LATEX_RAD), center.add(LATEX_RAD), Style.NORMAL);
        Vector textPos = new Vector(-SIZE2 - LATEX_RAD.x, 0);
        graphic.drawText(textPos, textPos.add(1, 0), label, Orientation.RIGHTCENTER, Style.INOUT);
    } else {
        Style style = Style.NORMAL;
        final Polygon box = new Polygon(true).add(-SIZE * 2 - 1, -SIZE).add(-1, -SIZE).add(-1, SIZE).add(-SIZE * 2 - 1, SIZE);
        if (value != null) {
            style = Style.getWireStyle(value);
            if (value.getBits() > 1) {
                Vector textPos = new Vector(-1 - SIZE, -4 - SIZE);
                graphic.drawText(textPos, textPos.add(1, 0), format.formatToView(value), Orientation.CENTERBOTTOM, Style.NORMAL);
            } else {
                if (inValue != null && !inValue.isEqual(value))
                    graphic.drawPolygon(box, Style.getWireStyle(inValue));
            }
        }
        graphic.drawPolygon(box, Style.NORMAL);
        Vector center = new Vector(-1 - SIZE, 0);
        graphic.drawCircle(center.sub(RAD), center.add(RAD), style);
        Vector textPos = new Vector(-SIZE * 3, 0);
        graphic.drawText(textPos, textPos.add(1, 0), label, Orientation.RIGHTCENTER, Style.INOUT);
    }
}
Also used : Polygon(de.neemann.digital.draw.graphics.Polygon)

Aggregations

Polygon (de.neemann.digital.draw.graphics.Polygon)19 Vector (de.neemann.digital.draw.graphics.Vector)12 Style (de.neemann.digital.draw.graphics.Style)4 Pin (de.neemann.digital.draw.elements.Pin)1