本文整理汇总了Java中com.cburch.logisim.analyze.model.TruthTable类的典型用法代码示例。如果您正苦于以下问题:Java TruthTable类的具体用法?Java TruthTable怎么用?Java TruthTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TruthTable类属于com.cburch.logisim.analyze.model包,在下文中一共展示了TruthTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRow
import com.cburch.logisim.analyze.model.TruthTable; //导入依赖的package包/类
@Override
public int getRow(MouseEvent event) {
TruthTable table = model.getTruthTable();
int inputs = table.getInputColumnCount();
if (inputs >= ROW_VARS.length)
return -1;
int left = computeMargin(getWidth(), tableWidth);
int top = computeMargin(getHeight(), tableHeight);
int x = event.getX() - left - headHeight - cellWidth;
int y = event.getY() - top - headHeight - cellHeight;
if (x < 0 || y < 0)
return -1;
int row = y / cellHeight;
int col = x / cellWidth;
int rows = 1 << ROW_VARS[inputs];
int cols = 1 << COL_VARS[inputs];
if (row >= rows || col >= cols)
return -1;
return getTableRow(row, col, rows, cols);
}
示例2: mousePressed
import com.cburch.logisim.analyze.model.TruthTable; //导入依赖的package包/类
@Override
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;
else if (oldValue == Entry.ONE)
newValue = Entry.DONT_CARE;
else
newValue = Entry.ZERO;
source.setEntryProvisional(cellY, cellX, newValue);
}
示例3: mouseReleased
import com.cburch.logisim.analyze.model.TruthTable; //导入依赖的package包/类
@Override
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;
}
示例4: structureChanged
import com.cburch.logisim.analyze.model.TruthTable; //导入依赖的package包/类
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;
}
if (markCol >= cols) {
markCol = cols - 1;
changed = true;
}
if (changed)
table.repaint();
}
示例5: getRow
import com.cburch.logisim.analyze.model.TruthTable; //导入依赖的package包/类
public int getRow(MouseEvent event) {
TruthTable table = model.getTruthTable();
int inputs = table.getInputColumnCount();
if (inputs >= ROW_VARS.length)
return -1;
int left = computeMargin(getWidth(), tableWidth);
int top = computeMargin(getHeight(), tableHeight);
int x = event.getX() - left - headHeight - 11;
int y = event.getY() - top - headHeight - 11;
if (x < 0 || y < 0)
return -1;
int row = y / cellHeight;
int col = x / cellWidth;
int rows = 1 << ROW_VARS[inputs];
int cols = 1 << COL_VARS[inputs];
if (row >= rows || col >= cols)
return -1;
return getTableRow(row, col, rows, cols);
}
示例6: mousePressed
import com.cburch.logisim.analyze.model.TruthTable; //导入依赖的package包/类
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;
else if (oldValue == Entry.ONE)
newValue = Entry.DONT_CARE;
else
newValue = Entry.ZERO;
source.setEntryProvisional(cellY, cellX, newValue);
}
示例7: mouseReleased
import com.cburch.logisim.analyze.model.TruthTable; //导入依赖的package包/类
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;
}
示例8: getRow
import com.cburch.logisim.analyze.model.TruthTable; //导入依赖的package包/类
public int getRow(MouseEvent event) {
TruthTable table = model.getTruthTable();
int inputs = table.getInputColumnCount();
if (inputs >= ROW_VARS.length) return -1;
int left = computeMargin(getWidth(), tableWidth);
int top = computeMargin(getHeight(), tableHeight);
int x = event.getX() - left - headHeight - cellWidth;
int y = event.getY() - top - headHeight - cellHeight;
if (x < 0 || y < 0) return -1;
int row = y / cellHeight;
int col = x / cellWidth;
int rows = 1 << ROW_VARS[inputs];
int cols = 1 << COL_VARS[inputs];
if (row >= rows || col >= cols) return -1;
return getTableRow(row, col, rows, cols);
}
示例9: mouseReleased
import com.cburch.logisim.analyze.model.TruthTable; //导入依赖的package包/类
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;
}
示例10: structureChanged
import com.cburch.logisim.analyze.model.TruthTable; //导入依赖的package包/类
@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;
}
if (markCol >= cols) {
markCol = cols - 1;
changed = true;
}
if (changed)
table.repaint();
}
示例11: getToolTipText
import com.cburch.logisim.analyze.model.TruthTable; //导入依赖的package包/类
@Override
public String getToolTipText(MouseEvent event) {
TruthTable table = model.getTruthTable();
int row = getRow(event);
int col = getOutputColumn(event);
Entry entry = table.getOutputEntry(row, col);
return entry.getErrorMessage();
}
示例12: TableTab
import com.cburch.logisim.analyze.model.TruthTable; //导入依赖的package包/类
public TableTab(TruthTable table) {
this.table = table;
table.addTruthTableListener(myListener);
setToolTipText(" ");
caret = new TableTabCaret(this);
clip = new TableTabClip(this);
}
示例13: selectAll
import com.cburch.logisim.analyze.model.TruthTable; //导入依赖的package包/类
void selectAll() {
table.requestFocus();
TruthTable model = table.getTruthTable();
setCursor(model.getRowCount(),
model.getInputColumnCount() + model.getOutputColumnCount(),
false);
setCursor(0, 0, true);
}
示例14: TableTab
import com.cburch.logisim.analyze.model.TruthTable; //导入依赖的package包/类
public TableTab(TruthTable table) {
this.table = table;
HeaderFont = AppPreferences.getScaledFont(getFont()).deriveFont(Font.BOLD);
EntryFont = AppPreferences.getScaledFont(getFont());
cellWidth = AppPreferences.getScaled(AppPreferences.IconSize+AppPreferences.IconBorder*2);
cellHeight = AppPreferences.getScaled(AppPreferences.IconSize);
ColSeperate = AppPreferences.getScaled(AppPreferences.IconSize>>1);
HeadSeperate = AppPreferences.getScaled(AppPreferences.IconSize>>2);
table.addTruthTableListener(myListener);
setToolTipText(" ");
caret = new TableTabCaret(this);
clip = new TableTabClip(this);
}
示例15: keyPressed
import com.cburch.logisim.analyze.model.TruthTable; //导入依赖的package包/类
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;
case KeyEvent.VK_DOWN: setCursor(cursorRow + 1, cursorCol, shift); break;
case KeyEvent.VK_RIGHT: setCursor(cursorRow, cursorCol + 1, shift); break;
case KeyEvent.VK_HOME:
if (cursorCol == 0) setCursor(0, 0, shift);
else setCursor(cursorRow, 0, shift);
break;
case KeyEvent.VK_END:
if (cursorCol == cols - 1) setCursor(rows - 1, cols - 1, shift);
else setCursor(cursorRow, cols - 1, shift);
break;
case KeyEvent.VK_PAGE_DOWN:
rows = table.getVisibleRect().height / table.getCellHeight();
if (rows > 2) rows--;
setCursor(cursorRow + rows, cursorCol, shift);
break;
case KeyEvent.VK_PAGE_UP:
rows = table.getVisibleRect().height / table.getCellHeight();
if (rows > 2) rows--;
setCursor(cursorRow - rows, cursorCol, shift);
break;
}
}