本文整理汇总了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();
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
}
示例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();
}
示例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;
}
示例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);
}
}
示例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();
}