当前位置: 首页>>代码示例>>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;未经允许,请勿转载。