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


Java InstanceDataSingleton類代碼示例

本文整理匯總了Java中com.cburch.logisim.instance.InstanceDataSingleton的典型用法代碼示例。如果您正苦於以下問題:Java InstanceDataSingleton類的具體用法?Java InstanceDataSingleton怎麽用?Java InstanceDataSingleton使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


InstanceDataSingleton類屬於com.cburch.logisim.instance包,在下文中一共展示了InstanceDataSingleton類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: paintInstance

import com.cburch.logisim.instance.InstanceDataSingleton; //導入依賴的package包/類
@Override
public void paintInstance(InstancePainter painter) {
	InstanceDataSingleton data = (InstanceDataSingleton) painter.getData();
	Value val = data == null ? Value.FALSE : (Value) data.getValue();
	Bounds bds = painter.getBounds().expand(-1);

	Graphics g = painter.getGraphics();
	if (painter.getShowState()) {
		Color onColor = painter.getAttributeValue(Io.ATTR_ON_COLOR);
		Color offColor = painter.getAttributeValue(Io.ATTR_OFF_COLOR);
		Boolean activ = painter.getAttributeValue(Io.ATTR_ACTIVE);
		Object desired = activ.booleanValue() ? Value.TRUE : Value.FALSE;
		g.setColor(val == desired ? onColor : offColor);
		g.fillOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
	}
	g.setColor(Color.BLACK);
	GraphicsUtil.switchToWidth(g, 2);
	g.drawOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
	GraphicsUtil.switchToWidth(g, 1);
	painter.drawLabel();
	painter.drawPorts();
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:23,代碼來源:Led.java

示例2: propagate

import com.cburch.logisim.instance.InstanceDataSingleton; //導入依賴的package包/類
@Override
public void propagate(InstanceState state) {
	int summary = 0;
	for (int i = 0; i < 8; i++) {
		Value val = state.getPort(i);
		if (val == Value.TRUE)
			summary |= 1 << i;
	}
	Object value = Integer.valueOf(summary);
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	if (data == null) {
		state.setData(new InstanceDataSingleton(value));
	} else {
		data.setValue(value);
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:17,代碼來源:SevenSegment.java

示例3: paintInstance

import com.cburch.logisim.instance.InstanceDataSingleton; //導入依賴的package包/類
@Override
public void paintInstance(InstancePainter painter) {
	InstanceDataSingleton data = (InstanceDataSingleton) painter.getData();
	int summ = (data == null ? 0 : ((Integer) data.getValue()).intValue());
	Bounds bds = painter.getBounds().expand(-1);

	Graphics g = painter.getGraphics();
	if (painter.getShowState()) {
		Boolean activ = painter.getAttributeValue(Io.ATTR_ACTIVE);
		int mask = activ.booleanValue() ? 0 : 7;
		summ ^= mask;
		int red = ((summ >> RED) & 1) * 0xFF;
		int green = ((summ >> GREEN) & 1) * 0xFF;
		int blue = ((summ >> BLUE) & 1) * 0xFF;
		Color LedColor = new Color(red, green, blue);
		g.setColor(LedColor);
		g.fillOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
	}
	g.setColor(Color.BLACK);
	GraphicsUtil.switchToWidth(g, 2);
	g.drawOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
	GraphicsUtil.switchToWidth(g, 1);
	painter.drawLabel();
	painter.drawPorts();
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:26,代碼來源:RGBLed.java

示例4: propagate

import com.cburch.logisim.instance.InstanceDataSingleton; //導入依賴的package包/類
@Override
public void propagate(InstanceState state) {
	int summary = 0;
	for (int i = 0; i < 3; i++) {
		Value val = state.getPortValue(i);
		if (val == Value.TRUE)
			summary |= 1 << i;
	}
	Object value = Integer.valueOf(summary);
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	if (data == null) {
		state.setData(new InstanceDataSingleton(value));
	} else {
		data.setValue(value);
	}
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:17,代碼來源:RGBLed.java

示例5: propagate

import com.cburch.logisim.instance.InstanceDataSingleton; //導入依賴的package包/類
@Override
public void propagate(InstanceState state) {
	int summary = 0;
	for (int i = 0; i < 8; i++) {
		Value val = state.getPortValue(i);
		if (val == Value.TRUE)
			summary |= 1 << i;
	}
	Object value = Integer.valueOf(summary);
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	if (data == null) {
		state.setData(new InstanceDataSingleton(value));
	} else {
		data.setValue(value);
	}
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:17,代碼來源:SevenSegment.java

示例6: paintInstance

import com.cburch.logisim.instance.InstanceDataSingleton; //導入依賴的package包/類
@Override
public void paintInstance(InstancePainter painter) {
	InstanceDataSingleton data = (InstanceDataSingleton) painter.getData();
	Value val = data == null ? Value.FALSE : (Value) data.getValue();
	Bounds bds = painter.getBounds().expand(-1);

	Graphics g = painter.getGraphics();
	if (painter.getShowState()) {
		Color onColor = painter.getAttributeValue(Io.ATTR_ON_COLOR);
		Color offColor = painter.getAttributeValue(Io.ATTR_OFF_COLOR);
		Boolean activ = painter.getAttributeValue(Io.ATTR_ACTIVE);
		Object desired = activ.booleanValue() ? Value.TRUE : Value.FALSE;
		g.setColor(val == desired ? onColor : offColor);
		g.fillOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
	}
	g.setColor(Color.BLACK);
	GraphicsUtil.switchToWidth(g, 2);
	g.drawOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
	GraphicsUtil.switchToWidth(g, 1);
	g.setColor(painter.getAttributeValue(Io.ATTR_LABEL_COLOR));
	painter.drawLabel();
	painter.drawPorts();
}
 
開發者ID:franciscaconcha,項目名稱:ProyectoLogisim,代碼行數:24,代碼來源:Led.java

示例7: mouseReleased

import com.cburch.logisim.instance.InstanceDataSingleton; //導入依賴的package包/類
@Override
public void mouseReleased(InstanceState state, MouseEvent e) {
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	if (data != null && (Boolean) data.getValue())
		setActive(state, false);
	else
		setActive(state, true);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:9,代碼來源:Switch.java

示例8: setActive

import com.cburch.logisim.instance.InstanceDataSingleton; //導入依賴的package包/類
private void setActive(InstanceState state, boolean active) {
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	if (data == null) {
		state.setData(new InstanceDataSingleton(active));
	} else {
		data.setValue(active);
	}
	state.getInstance().fireInvalidated();
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:10,代碼來源:Switch.java

示例9: propagate

import com.cburch.logisim.instance.InstanceDataSingleton; //導入依賴的package包/類
@Override
public void propagate(InstanceState state) {
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	Value val = (data == null || !(Boolean) data.getValue())
			? Value.createUnknown(state.getAttributeValue(StdAttr.WIDTH))
			: state.getPort(0);
	state.setPort(1, val, 1);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:9,代碼來源:Switch.java

示例10: getLogValue

import com.cburch.logisim.instance.InstanceDataSingleton; //導入依賴的package包/類
@Override
public Value getLogValue(InstanceState state, Object option) {
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	if (data == null)
		return Value.FALSE;
	return data.getValue() == Value.TRUE ? Value.TRUE : Value.FALSE;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:8,代碼來源:Led.java

示例11: propagate

import com.cburch.logisim.instance.InstanceDataSingleton; //導入依賴的package包/類
@Override
public void propagate(InstanceState state) {
	Value val = state.getPort(0);
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	if (data == null) {
		state.setData(new InstanceDataSingleton(val));
	} else {
		data.setValue(val);
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:11,代碼來源:Led.java

示例12: setValue

import com.cburch.logisim.instance.InstanceDataSingleton; //導入依賴的package包/類
private void setValue(InstanceState state, Value val) {
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	if (data == null) {
		state.setData(new InstanceDataSingleton(val));
	} else {
		data.setValue(val);
	}
	state.getInstance().fireInvalidated();
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:10,代碼來源:Button.java

示例13: getLogValue

import com.cburch.logisim.instance.InstanceDataSingleton; //導入依賴的package包/類
@Override
public Value getLogValue(InstanceState state, Object option) {
	InstanceDataSingleton data = (InstanceDataSingleton) state
			.getData();
	if (data == null)
		return Value.FALSE;
	return data.getValue() == Value.TRUE ? Value.TRUE : Value.FALSE;
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:9,代碼來源:RGBLed.java

示例14: propagate

import com.cburch.logisim.instance.InstanceDataSingleton; //導入依賴的package包/類
@Override
public void propagate(InstanceState state) {
	Value val = state.getPortValue(0);
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	if (data == null) {
		state.setData(new InstanceDataSingleton(val));
	} else {
		data.setValue(val);
	}
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:11,代碼來源:Led.java

示例15: setValue

import com.cburch.logisim.instance.InstanceDataSingleton; //導入依賴的package包/類
private void setValue(InstanceState state, Value val) {
	InstanceDataSingleton data = (InstanceDataSingleton) state
			.getData();
	if (data == null) {
		state.setData(new InstanceDataSingleton(val));
	} else {
		data.setValue(val);
	}
	state.getInstance().fireInvalidated();
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:11,代碼來源:Button.java


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