Package com.cburch.logisim.analyze.model

Examples of com.cburch.logisim.analyze.model.TruthTable


    int c0 = caret.getCursorCol();
    int c1 = caret.getMarkCol();
    int r0 = caret.getCursorRow();
    int r1 = caret.getMarkRow();
    if (r0 < 0 || r1 < 0 || c0 < 0 || c1 < 0) return;
    TruthTable model = table.getTruthTable();
    int rows = model.getRowCount();
    int inputs = model.getInputColumnCount();
    int outputs = model.getOutputColumnCount();
    if (c0 == c1 && r0 == r1) {
      if (r0 + entries.length > rows
          || c0 + entries[0].length > inputs + outputs) {
        JOptionPane.showMessageDialog(table.getRootPane(),
            Strings.get("clipPasteEndError"),
            Strings.get("clipPasteErrorTitle"),
            JOptionPane.ERROR_MESSAGE);
        return;
      }
    } else {
      if (r0 > r1) { int t = r0; r0 = r1; r1 = t; }
      if (c0 > c1) { int t = c0; c0 = c1; c1 = t; }
     
      if (r1 - r0 + 1 != entries.length
          || c1 - c0 + 1 != entries[0].length) {
        JOptionPane.showMessageDialog(table.getRootPane(),
            Strings.get("clipPasteSizeError"),
            Strings.get("clipPasteErrorTitle"),
            JOptionPane.ERROR_MESSAGE);
        return;
      }
    }
    for (int r = 0; r < entries.length; r++) {
      for (int c = 0; c < entries[0].length; c++) {
        if (c0 + c >= inputs) {
          model.setOutputEntry(r0 + r, c0 + c - inputs,
              entries[r][c]);
        }
      }
    }
  }
View Full Code Here


  private Entry oldValue;
  private Entry newValue;
 
  public void mousePressed(MouseEvent event) {
    TruthTablePanel source = (TruthTablePanel) event.getSource();
    TruthTable model = source.getTruthTable();
    int cols = model.getInputColumnCount() + model.getOutputColumnCount();
    int rows = model.getRowCount();
    cellX = source.getOutputColumn(event);
    cellY = source.getRow(event);
    if (cellX < 0 || cellY < 0 || cellX >= cols || cellY >= rows) return;
    oldValue = source.getTruthTable().getOutputEntry(cellY, cellX);
    if (oldValue == Entry.ZERO)     newValue = Entry.ONE;
View Full Code Here

    else                           newValue = Entry.ZERO;
    source.setEntryProvisional(cellY, cellX, newValue);
  }
  public void mouseReleased(MouseEvent event) {
    TruthTablePanel source = (TruthTablePanel) event.getSource();
    TruthTable model = source.getTruthTable();
    int cols = model.getInputColumnCount() + model.getOutputColumnCount();
    int rows = model.getRowCount();
    if (cellX < 0 || cellY < 0 || cellX >= cols || cellY >= rows) return;

    int x = source.getOutputColumn(event);
    int y = source.getRow(event);
    TruthTable table = source.getTruthTable();
    if (x == cellX && y == cellY) {
      table.setOutputEntry(y, x, newValue);
    }
    source.setEntryProvisional(cellY, cellX, null);
    cellX = -1;
    cellY = -1;
  }
View Full Code Here

        int c1 = caret.getMarkCol();
        int r1 = caret.getMarkRow();
        if (c1 < c0) { int t = c0; c0 = c1; c1 = t; }
        if (r1 < r0) { int t = r0; r0 = r1; r1 = t; }

        TruthTable t = table.getTruthTable();
        int inputs = t.getInputColumnCount();
        String[] header = new String[c1 - c0 + 1];
        for (int c = c0; c <= c1; c++) {
            if (c < inputs) {
                header[c - c0] = t.getInputHeader(c);
            } else {
                header[c - c0] = t.getOutputHeader(c - inputs);
            }
        }
        String[][] contents = new String[r1 - r0 + 1][c1 - c0 + 1];
        for (int r = r0; r <= r1; r++) {
            for (int c = c0; c <= c1; c++) {
                if (c < inputs) {
                    contents[r - r0][c - c0] = t.getInputEntry(r, c).getDescription();
                } else {
                    contents[r - r0][c - c0] = t.getOutputEntry(r, c - inputs).getDescription();
                }
            }
        }

        Clipboard clip = table.getToolkit().getSystemClipboard();
View Full Code Here

        int c0 = caret.getCursorCol();
        int c1 = caret.getMarkCol();
        int r0 = caret.getCursorRow();
        int r1 = caret.getMarkRow();
        if (r0 < 0 || r1 < 0 || c0 < 0 || c1 < 0) return;
        TruthTable model = table.getTruthTable();
        int rows = model.getRowCount();
        int inputs = model.getInputColumnCount();
        int outputs = model.getOutputColumnCount();
        if (c0 == c1 && r0 == r1) {
            if (r0 + entries.length > rows
                    || c0 + entries[0].length > inputs + outputs) {
                JOptionPane.showMessageDialog(table.getRootPane(),
                        getFromLocale("clipPasteEndError"),
                        getFromLocale("clipPasteErrorTitle"),
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
        } else {
            if (r0 > r1) { int t = r0; r0 = r1; r1 = t; }
            if (c0 > c1) { int t = c0; c0 = c1; c1 = t; }

            if (r1 - r0 + 1 != entries.length
                    || c1 - c0 + 1 != entries[0].length) {
                JOptionPane.showMessageDialog(table.getRootPane(),
                        getFromLocale("clipPasteSizeError"),
                        getFromLocale("clipPasteErrorTitle"),
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
        }
        for (int r = 0; r < entries.length; r++) {
            for (int c = 0; c < entries[0].length; c++) {
                if (c0 + c >= inputs) {
                    model.setOutputEntry(r0 + r, c0 + c - inputs,
                            entries[r][c]);
                }
            }
        }
    }
View Full Code Here

    int getMarkRow() { return markRow; }
    int getMarkCol() { return markCol; }

    void selectAll() {
        table.requestFocus();
        TruthTable model = table.getTruthTable();
        setCursor(model.getRowCount(), model.getInputColumnCount() + model.getOutputColumnCount(), false);
        setCursor(0, 0, true);
    }
View Full Code Here

        setCursor(model.getRowCount(), model.getInputColumnCount() + model.getOutputColumnCount(), false);
        setCursor(0, 0, true);
    }

    private void setCursor(int row, int col, boolean keepMark) {
        TruthTable model = table.getTruthTable();
        int rows = model.getRowCount();
        int cols = model.getInputColumnCount() + model.getOutputColumnCount();
        if (row < 0) row = 0;
        if (col < 0) col = 0;
        if (row >= rows) row = rows - 1;
        if (col >= cols) col = cols - 1;
View Full Code Here

            char c = e.getKeyChar();
            Entry newEntry = null;
            switch (c) {
            case ' ':
                if (cursorRow >= 0) {
                    TruthTable model = table.getTruthTable();
                    int inputs = model.getInputColumnCount();
                    if (cursorCol >= inputs) {
                        Entry cur = model.getOutputEntry(cursorRow, cursorCol - inputs);
                        if (cur == Entry.ZERO) cur = Entry.ONE;
                        else if (cur == Entry.ONE) {
                            cur = Entry.DONT_CARE;
                        }

                        else {
                            cur = Entry.ZERO;
                        }

                        model.setOutputEntry(cursorRow, cursorCol - inputs, cur);
                    }
                }
                break;
            case '0':
                newEntry = Entry.ZERO;
                break;
            case '1':
                newEntry = Entry.ONE;
                break;
            case 'x':
                newEntry = Entry.DONT_CARE;
                break;
            case '\n':
                setCursor(cursorRow + 1, table.getTruthTable().getInputColumnCount(),
                        (mask & InputEvent.SHIFT_MASK) != 0);
                break;
            case '\u0008': case '\u007f':
                setCursor(cursorRow, cursorCol - 1, (mask & InputEvent.SHIFT_MASK) != 0);
                break;
            default:
            }
            if (newEntry != null) {
                TruthTable model = table.getTruthTable();
                int inputs = model.getInputColumnCount();
                int outputs = model.getOutputColumnCount();
                if (cursorCol >= inputs) {
                    model.setOutputEntry(cursorRow, cursorCol - inputs, newEntry);
                    if (cursorCol >= inputs + outputs - 1) {
                        setCursor(cursorRow + 1, inputs, false);
                    } else {
                        setCursor(cursorRow, cursorCol + 1, false);
                    }
View Full Code Here

        }

        @Override
        public void keyPressed(KeyEvent e) {
            if (cursorRow < 0) return;
            TruthTable model = table.getTruthTable();
            int rows = model.getRowCount();
            int inputs = model.getInputColumnCount();
            int outputs = model.getOutputColumnCount();
            int cols = inputs + outputs;
            boolean shift = (e.getModifiers() & InputEvent.SHIFT_MASK) != 0;
            switch (e.getKeyCode()) {
            case KeyEvent.VK_UP:    setCursor(cursorRow - 1, cursorCol, shift); break;
            case KeyEvent.VK_LEFT:  setCursor(cursorRow, cursorCol - 1, shift); break;
View Full Code Here

        @Override
        public void cellsChanged(TruthTableEvent event) { }

        @Override
        public void structureChanged(TruthTableEvent event) {
            TruthTable model = event.getSource();
            int inputs = model.getInputColumnCount();
            int outputs = model.getOutputColumnCount();
            int rows = model.getRowCount();
            int cols = inputs + outputs;
            boolean changed = false;
            if (cursorRow >= rows) { cursorRow = rows - 1; changed = true; }
            if (cursorCol >= cols) { cursorCol = cols - 1; changed = true; }
            if (markRow >= rows) { markRow = rows - 1; changed = true; }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.analyze.model.TruthTable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.