當前位置: 首頁>>代碼示例>>Java>>正文


Java TruthTable類代碼示例

本文整理匯總了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);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:21,代碼來源:KarnaughMapPanel.java

示例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);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:20,代碼來源:TruthTableMouseListener.java

示例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;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:20,代碼來源:TruthTableMouseListener.java

示例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();
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:27,代碼來源:TableTabCaret.java

示例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);
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:20,代碼來源:KarnaughMapPanel.java

示例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);
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:19,代碼來源:TruthTableMouseListener.java

示例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;
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:19,代碼來源:TruthTableMouseListener.java

示例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); 
}
 
開發者ID:franciscaconcha,項目名稱:ProyectoLogisim,代碼行數:17,代碼來源:KarnaughMapPanel.java

示例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;
}
 
開發者ID:franciscaconcha,項目名稱:ProyectoLogisim,代碼行數:18,代碼來源:TruthTableMouseListener.java

示例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();
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:28,代碼來源:TableTabCaret.java

示例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();
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:9,代碼來源:KarnaughMapPanel.java

示例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);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:8,代碼來源:TableTab.java

示例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);
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:9,代碼來源:TableTabCaret.java

示例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);
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:14,代碼來源:TableTab.java

示例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;
	}
}
 
開發者ID:franciscaconcha,項目名稱:ProyectoLogisim,代碼行數:34,代碼來源:TableTabCaret.java


注:本文中的com.cburch.logisim.analyze.model.TruthTable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。