本文整理匯總了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();
}