Search in sources :

Example 31 with Bounds

use of com.cburch.logisim.data.Bounds in project logisim-evolution by reds-heig.

the class Probe method paintGhost.

// 
// graphics methods
// 
@Override
public void paintGhost(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    Bounds bds = painter.getOffsetBounds();
    g.drawOval(bds.getX() + 1, bds.getY() + 1, bds.getWidth() - 1, bds.getHeight() - 1);
}
Also used : Graphics(java.awt.Graphics) Bounds(com.cburch.logisim.data.Bounds)

Example 32 with Bounds

use of com.cburch.logisim.data.Bounds in project logisim-evolution by reds-heig.

the class Probe method getOffsetBounds.

// 
// static methods
// 
static Bounds getOffsetBounds(Direction dir, BitWidth width, RadixOption radix) {
    Bounds ret = null;
    int len = radix == null || radix == RadixOption.RADIX_2 ? width.getWidth() : radix.getMaxLength(width);
    if (dir == Direction.EAST) {
        switch(len) {
            case 0:
            case 1:
                ret = Bounds.create(-20, -10, 20, 20);
                break;
            case 2:
                ret = Bounds.create(-20, -10, 20, 20);
                break;
            case 3:
                ret = Bounds.create(-30, -10, 30, 20);
                break;
            case 4:
                ret = Bounds.create(-40, -10, 40, 20);
                break;
            case 5:
                ret = Bounds.create(-50, -10, 50, 20);
                break;
            case 6:
                ret = Bounds.create(-60, -10, 60, 20);
                break;
            case 7:
                ret = Bounds.create(-70, -10, 70, 20);
                break;
            case 8:
                ret = Bounds.create(-80, -10, 80, 20);
                break;
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
                ret = Bounds.create(-80, -20, 80, 40);
                break;
            case 17:
            case 18:
            case 19:
            case 20:
            case 21:
            case 22:
            case 23:
            case 24:
                ret = Bounds.create(-80, -30, 80, 60);
                break;
            case 25:
            case 26:
            case 27:
            case 28:
            case 29:
            case 30:
            case 31:
            case 32:
                ret = Bounds.create(-80, -40, 80, 80);
                break;
        }
    } else if (dir == Direction.WEST) {
        switch(len) {
            case 0:
            case 1:
                ret = Bounds.create(0, -10, 20, 20);
                break;
            case 2:
                ret = Bounds.create(0, -10, 20, 20);
                break;
            case 3:
                ret = Bounds.create(0, -10, 30, 20);
                break;
            case 4:
                ret = Bounds.create(0, -10, 40, 20);
                break;
            case 5:
                ret = Bounds.create(0, -10, 50, 20);
                break;
            case 6:
                ret = Bounds.create(0, -10, 60, 20);
                break;
            case 7:
                ret = Bounds.create(0, -10, 70, 20);
                break;
            case 8:
                ret = Bounds.create(0, -10, 80, 20);
                break;
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
                ret = Bounds.create(0, -20, 80, 40);
                break;
            case 17:
            case 18:
            case 19:
            case 20:
            case 21:
            case 22:
            case 23:
            case 24:
                ret = Bounds.create(0, -30, 80, 60);
                break;
            case 25:
            case 26:
            case 27:
            case 28:
            case 29:
            case 30:
            case 31:
            case 32:
                ret = Bounds.create(0, -40, 80, 80);
                break;
        }
    } else if (dir == Direction.SOUTH) {
        switch(len) {
            case 0:
            case 1:
                ret = Bounds.create(-10, -20, 20, 20);
                break;
            case 2:
                ret = Bounds.create(-10, -20, 20, 20);
                break;
            case 3:
                ret = Bounds.create(-15, -20, 30, 20);
                break;
            case 4:
                ret = Bounds.create(-20, -20, 40, 20);
                break;
            case 5:
                ret = Bounds.create(-25, -20, 50, 20);
                break;
            case 6:
                ret = Bounds.create(-30, -20, 60, 20);
                break;
            case 7:
                ret = Bounds.create(-35, -20, 70, 20);
                break;
            case 8:
                ret = Bounds.create(-40, -20, 80, 20);
                break;
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
                ret = Bounds.create(-40, -40, 80, 40);
                break;
            case 17:
            case 18:
            case 19:
            case 20:
            case 21:
            case 22:
            case 23:
            case 24:
                ret = Bounds.create(-40, -60, 80, 60);
                break;
            case 25:
            case 26:
            case 27:
            case 28:
            case 29:
            case 30:
            case 31:
            case 32:
                ret = Bounds.create(-40, -80, 80, 80);
                break;
        }
    } else if (dir == Direction.NORTH) {
        switch(len) {
            case 0:
            case 1:
                ret = Bounds.create(-10, 0, 20, 20);
                break;
            case 2:
                ret = Bounds.create(-10, 0, 20, 20);
                break;
            case 3:
                ret = Bounds.create(-15, 0, 30, 20);
                break;
            case 4:
                ret = Bounds.create(-20, 0, 40, 20);
                break;
            case 5:
                ret = Bounds.create(-25, 0, 50, 20);
                break;
            case 6:
                ret = Bounds.create(-30, 0, 60, 20);
                break;
            case 7:
                ret = Bounds.create(-35, 0, 70, 20);
                break;
            case 8:
                ret = Bounds.create(-40, 0, 80, 20);
                break;
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
                ret = Bounds.create(-40, 0, 80, 40);
                break;
            case 17:
            case 18:
            case 19:
            case 20:
            case 21:
            case 22:
            case 23:
            case 24:
                ret = Bounds.create(-40, 0, 80, 60);
                break;
            case 25:
            case 26:
            case 27:
            case 28:
            case 29:
            case 30:
            case 31:
            case 32:
                ret = Bounds.create(-40, 0, 80, 80);
                break;
        }
    }
    if (ret == null) {
        // should never happen
        ret = Bounds.create(0, -10, 20, 20);
    }
    return ret;
}
Also used : Bounds(com.cburch.logisim.data.Bounds)

Example 33 with Bounds

use of com.cburch.logisim.data.Bounds in project logisim-evolution by reds-heig.

the class Ram method paintInstance.

@Override
public void paintInstance(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    Bounds bds = painter.getBounds();
    int NrOfBits = painter.getAttributeValue(Mem.DATA_ATTR).getWidth();
    // int addrb = painter.getAttributeValue(Mem.ADDR_ATTR).getWidth();
    String Label = painter.getAttributeValue(StdAttr.LABEL);
    if (Label != null) {
        Font font = g.getFont();
        g.setFont(painter.getAttributeValue(StdAttr.LABEL_FONT));
        GraphicsUtil.drawCenteredText(g, Label, bds.getX() + bds.getWidth() / 2, bds.getY() - g.getFont().getSize());
        g.setFont(font);
    }
    int xpos = bds.getX();
    int ypos = bds.getY();
    DrawControlBlock(painter, xpos, ypos);
    for (int i = 0; i < NrOfBits; i++) {
        DrawDataBlock(painter, xpos, ypos, i, NrOfBits);
    }
    /* Draw contents */
    if (painter.getShowState()) {
        RamState state = (RamState) getState(painter);
        state.paint(painter.getGraphics(), bds.getX() + 20, bds.getY(), true, getControlHeight(painter.getAttributeSet()));
    }
}
Also used : Graphics(java.awt.Graphics) Bounds(com.cburch.logisim.data.Bounds) Font(java.awt.Font)

Example 34 with Bounds

use of com.cburch.logisim.data.Bounds in project logisim-evolution by reds-heig.

the class TclGeneric method paintInstance.

@Override
public void paintInstance(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    VhdlContent content = painter.getAttributeValue(CONTENT_ATTR);
    FontMetrics metric = g.getFontMetrics();
    Bounds bds = painter.getBounds();
    int x0 = bds.getX() + (bds.getWidth() / 2);
    int y0 = bds.getY() + metric.getHeight() + 12;
    GraphicsUtil.drawText(g, StringUtil.resizeString(content.getName(), metric, WIDTH), x0, y0, GraphicsUtil.H_CENTER, GraphicsUtil.V_BOTTOM);
    String glbLabel = painter.getAttributeValue(StdAttr.LABEL);
    if (glbLabel != null) {
        Font font = g.getFont();
        g.setFont(painter.getAttributeValue(StdAttr.LABEL_FONT));
        GraphicsUtil.drawCenteredText(g, glbLabel, bds.getX() + bds.getWidth() / 2, bds.getY() - g.getFont().getSize());
        g.setFont(font);
    }
    g.setColor(Color.GRAY);
    g.setFont(g.getFont().deriveFont((float) 10));
    metric = g.getFontMetrics();
    Port[] inputs = content.getInputs();
    Port[] outputs = content.getOutputs();
    for (int i = 0; i < inputs.length; i++) GraphicsUtil.drawText(g, StringUtil.resizeString(inputs[i].getToolTip(), metric, (WIDTH / 2) - X_PADDING), bds.getX() + 5, bds.getY() + HEIGHT - 2 + (i * PORT_GAP), GraphicsUtil.H_LEFT, GraphicsUtil.V_CENTER);
    for (int i = 0; i < outputs.length; i++) GraphicsUtil.drawText(g, StringUtil.resizeString(outputs[i].getToolTip(), metric, (WIDTH / 2) - X_PADDING), bds.getX() + WIDTH - 5, bds.getY() + HEIGHT - 2 + (i * PORT_GAP), GraphicsUtil.H_RIGHT, GraphicsUtil.V_CENTER);
    painter.drawBounds();
    painter.drawPorts();
}
Also used : Graphics(java.awt.Graphics) FontMetrics(java.awt.FontMetrics) Bounds(com.cburch.logisim.data.Bounds) Port(com.cburch.logisim.instance.Port) VhdlContent(com.cburch.logisim.std.hdl.VhdlContent) Font(java.awt.Font)

Example 35 with Bounds

use of com.cburch.logisim.data.Bounds in project logisim-evolution by reds-heig.

the class CounterPoker method paint.

@Override
public void paint(InstancePainter painter) {
    Bounds bds = painter.getBounds();
    BitWidth dataWidth = painter.getAttributeValue(StdAttr.WIDTH);
    int width = dataWidth == null ? 8 : dataWidth.getWidth();
    int len = (width + 3) / 4;
    int xcenter = Counter.SymbolWidth(width) - 25;
    Graphics g = painter.getGraphics();
    g.setColor(Color.RED);
    g.drawRect(bds.getX() + xcenter - len * 4, bds.getY() + 22, len * 8, 16);
    g.setColor(Color.BLACK);
}
Also used : BitWidth(com.cburch.logisim.data.BitWidth) Graphics(java.awt.Graphics) Bounds(com.cburch.logisim.data.Bounds)

Aggregations

Bounds (com.cburch.logisim.data.Bounds)133 Graphics (java.awt.Graphics)50 Direction (com.cburch.logisim.data.Direction)27 Location (com.cburch.logisim.data.Location)24 BitWidth (com.cburch.logisim.data.BitWidth)21 Component (com.cburch.logisim.comp.Component)11 Color (java.awt.Color)10 FontMetrics (java.awt.FontMetrics)10 Value (com.cburch.logisim.data.Value)7 Font (java.awt.Font)7 Circuit (com.cburch.logisim.circuit.Circuit)6 Port (com.cburch.logisim.instance.Port)6 Handle (com.cburch.draw.model.Handle)5 CanvasObject (com.cburch.draw.model.CanvasObject)4 Instance (com.cburch.logisim.instance.Instance)4 InstanceDataSingleton (com.cburch.logisim.instance.InstanceDataSingleton)4 ComponentFactory (com.cburch.logisim.comp.ComponentFactory)3 AttributeSet (com.cburch.logisim.data.AttributeSet)3 Project (com.cburch.logisim.proj.Project)3 Dimension (java.awt.Dimension)3