当前位置: 首页>>代码示例>>Java>>正文


Java StdAttr.WIDTH属性代码示例

本文整理汇总了Java中com.cburch.logisim.instance.StdAttr.WIDTH属性的典型用法代码示例。如果您正苦于以下问题:Java StdAttr.WIDTH属性的具体用法?Java StdAttr.WIDTH怎么用?Java StdAttr.WIDTH使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.cburch.logisim.instance.StdAttr的用法示例。


在下文中一共展示了StdAttr.WIDTH属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Random

public Random() {
	super("Random", Strings.getter("randomComponent"));
	setAttributes(
			new Attribute[] { StdAttr.WIDTH, ATTR_SEED, StdAttr.EDGE_TRIGGER, StdAttr.LABEL, StdAttr.LABEL_FONT,
					StdAttr.ATTR_LABEL_COLOR },
			new Object[] { BitWidth.create(8), Integer.valueOf(0), StdAttr.TRIG_RISING, "",
					StdAttr.DEFAULT_LABEL_FONT, Color.BLACK });
	setKeyConfigurator(new BitWidthConfigurator(StdAttr.WIDTH));

	setOffsetBounds(Bounds.create(-30, -20, 30, 40));
	setIconName("random.gif");
	setInstanceLogger(Logger.class);

	Port[] ps = new Port[4];
	ps[OUT] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
	ps[CK] = new Port(-30, -10, Port.INPUT, 1);
	ps[NXT] = new Port(-30, 10, Port.INPUT, 1);
	ps[RST] = new Port(-20, 20, Port.INPUT, 1);
	ps[OUT].setToolTip(Strings.getter("randomQTip"));
	ps[CK].setToolTip(Strings.getter("randomClockTip"));
	ps[NXT].setToolTip(Strings.getter("randomNextTip"));
	ps[RST].setToolTip(Strings.getter("randomResetTip"));
	setPorts(ps);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:24,代码来源:Random.java

示例2: setValue

@Override
public <V> void setValue(Attribute<V> attr, V value) {
	if (attr == StdAttr.WIDTH) {
		width = (BitWidth) value;
	} else if (attr == Pin.ATTR_TRISTATE) {
		threeState = ((Boolean) value).booleanValue();
	} else if (attr == Pin.ATTR_TYPE) {
		type = ((Boolean) value).booleanValue() ? EndData.OUTPUT_ONLY : EndData.INPUT_ONLY;
	} else if (attr == Pin.ATTR_PULL) {
		pull = value;
	} else if (attr == StdAttr.ATTR_LABEL_COLOR) {
		LabelColor = (Color) value;
	} else {
		super.setValue(attr, value);
		return;
	}
	fireAttributeValueChanged(attr, value);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:18,代码来源:PinAttributes.java

示例3: Multiplier

public Multiplier() {
	super("Multiplier", Strings.getter("multiplierComponent"));
	setAttributes(new Attribute[] { StdAttr.WIDTH }, new Object[] { BitWidth.create(8) });
	setKeyConfigurator(new BitWidthConfigurator(StdAttr.WIDTH));
	setOffsetBounds(Bounds.create(-40, -20, 40, 40));
	setIconName("multiplier.gif");

	Port[] ps = new Port[5];
	ps[IN0] = new Port(-40, -10, Port.INPUT, StdAttr.WIDTH);
	ps[IN1] = new Port(-40, 10, Port.INPUT, StdAttr.WIDTH);
	ps[OUT] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
	ps[C_IN] = new Port(-20, -20, Port.INPUT, StdAttr.WIDTH);
	ps[C_OUT] = new Port(-20, 20, Port.OUTPUT, StdAttr.WIDTH);
	ps[IN0].setToolTip(Strings.getter("multiplierInputTip"));
	ps[IN1].setToolTip(Strings.getter("multiplierInputTip"));
	ps[OUT].setToolTip(Strings.getter("multiplierOutputTip"));
	ps[C_IN].setToolTip(Strings.getter("multiplierCarryInTip"));
	ps[C_OUT].setToolTip(Strings.getter("multiplierCarryOutTip"));
	setPorts(ps);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:20,代码来源:Multiplier.java

示例4: setValue

@Override
public <V> void setValue(Attribute<V> attr, V value) {
	if (attr == StdAttr.FACING) {
		facing = (Direction) value;
		configureLabel();
	} else if (attr == StdAttr.WIDTH) {
		width = (BitWidth) value;
	} else if (attr == StdAttr.LABEL) {
		label = (String) value;
	} else if (attr == StdAttr.LABEL_FONT) {
		labelFont = (Font) value;
	} else {
		throw new IllegalArgumentException("unknown attribute");
	}
	offsetBounds = null;
	fireAttributeValueChanged(attr, value);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:17,代码来源:TunnelAttributes.java

示例5: Divider

public Divider() {
	super("Divider", Strings.getter("dividerComponent"));
	setAttributes(new Attribute[] { StdAttr.WIDTH }, new Object[] { BitWidth.create(8) });
	setKeyConfigurator(new BitWidthConfigurator(StdAttr.WIDTH));
	setOffsetBounds(Bounds.create(-40, -20, 40, 40));
	setIconName("divider.gif");

	Port[] ps = new Port[5];
	ps[IN0] = new Port(-40, -10, Port.INPUT, StdAttr.WIDTH);
	ps[IN1] = new Port(-40, 10, Port.INPUT, StdAttr.WIDTH);
	ps[OUT] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
	ps[UPPER] = new Port(-20, -20, Port.INPUT, StdAttr.WIDTH);
	ps[REM] = new Port(-20, 20, Port.OUTPUT, StdAttr.WIDTH);
	ps[IN0].setToolTip(Strings.getter("dividerDividendLowerTip"));
	ps[IN1].setToolTip(Strings.getter("dividerDivisorTip"));
	ps[OUT].setToolTip(Strings.getter("dividerOutputTip"));
	ps[UPPER].setToolTip(Strings.getter("dividerDividendUpperTip"));
	ps[REM].setToolTip(Strings.getter("dividerRemainderTip"));
	setPorts(ps);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:20,代码来源:Divider.java

示例6: Adder

public Adder() {
	super("Adder", Strings.getter("adderComponent"));
	setAttributes(new Attribute[] { StdAttr.WIDTH }, new Object[] { BitWidth.create(8) });
	setKeyConfigurator(new BitWidthConfigurator(StdAttr.WIDTH));
	setOffsetBounds(Bounds.create(-40, -20, 40, 40));
	setIconName("adder.gif");

	Port[] ps = new Port[5];
	ps[IN0] = new Port(-40, -10, Port.INPUT, StdAttr.WIDTH);
	ps[IN1] = new Port(-40, 10, Port.INPUT, StdAttr.WIDTH);
	ps[OUT] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
	ps[C_IN] = new Port(-20, -20, Port.INPUT, 1);
	ps[C_OUT] = new Port(-20, 20, Port.INPUT, 1);
	ps[IN0].setToolTip(Strings.getter("adderInputTip"));
	ps[IN1].setToolTip(Strings.getter("adderInputTip"));
	ps[OUT].setToolTip(Strings.getter("adderOutputTip"));
	ps[C_IN].setToolTip(Strings.getter("adderCarryInTip"));
	ps[C_OUT].setToolTip(Strings.getter("adderCarryOutTip"));
	setPorts(ps);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:20,代码来源:Adder.java

示例7: configurePorts

private void configurePorts(Instance instance) {
	Object size = instance.getAttributeValue(ATTR_SIZE);
	Direction facing = instance.getAttributeValue(StdAttr.FACING);
	int dx = size == SIZE_NARROW ? -20 : -30;

	Port[] ports = new Port[2];
	ports[0] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
	Location out = Location.create(0, 0).translate(facing, dx);
	ports[1] = new Port(out.getX(), out.getY(), Port.INPUT, StdAttr.WIDTH);
	instance.setPorts(ports);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:11,代码来源:NotGate.java

示例8: getValue

@Override
public <V> V getValue(Attribute<V> attr) {
	if (attr == StdAttr.FACING)
		return (V) facing;
	if (attr == StdAttr.WIDTH)
		return (V) width;
	if (attr == StdAttr.LABEL)
		return (V) label;
	if (attr == StdAttr.LABEL_FONT)
		return (V) labelFont;
	if (attr == ATTR_SIZE)
		return (V) size;
	if (attr == ATTR_INPUTS)
		return (V) Integer.valueOf(inputs);
	if (attr == ATTR_OUTPUT)
		return (V) out;
	if (attr == ATTR_XOR)
		return (V) xorBehave;
	if (attr == StdAttr.ATTR_LABEL_COLOR)
		return (V) labelColor;
	if (attr instanceof NegateAttribute) {
		int index = ((NegateAttribute) attr).index;
		int bit = (negated >> index) & 1;
		return (V) Boolean.valueOf(bit == 1);
	}

	return null;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:28,代码来源:GateAttributes.java

示例9: configurePorts

private void configurePorts(Instance instance) {
	Direction facing = instance.getAttributeValue(StdAttr.FACING);

	Port[] ports = new Port[2];
	ports[0] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
	Location out = Location.create(0, 0).translate(facing, -20);
	ports[1] = new Port(out.getX(), out.getY(), Port.INPUT, StdAttr.WIDTH);
	instance.setPorts(ports);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:9,代码来源:Buffer.java

示例10: instanceAttributeChanged

@Override
protected void instanceAttributeChanged(Instance instance, Attribute<?> attr) {
	if (attr == StdAttr.FACING || attr == Wiring.ATTR_GATE) {
		instance.recomputeBounds();
		updatePorts(instance);
	} else if (attr == StdAttr.WIDTH) {
		instance.fireInvalidated();
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:9,代码来源:TransmissionGate.java

示例11: updatePorts

private void updatePorts(Instance instance) {
	int dx = 0;
	int dy = 0;
	Direction facing = instance.getAttributeValue(StdAttr.FACING);
	if (facing == Direction.NORTH) {
		dy = 1;
	} else if (facing == Direction.EAST) {
		dx = -1;
	} else if (facing == Direction.SOUTH) {
		dy = -1;
	} else if (facing == Direction.WEST) {
		dx = 1;
	}

	Object powerLoc = instance.getAttributeValue(Wiring.ATTR_GATE);
	boolean flip = (facing == Direction.SOUTH || facing == Direction.WEST) == (powerLoc == Wiring.GATE_TOP_LEFT);

	Port[] ports = new Port[4];
	ports[OUTPUT] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
	ports[INPUT] = new Port(40 * dx, 40 * dy, Port.INPUT, StdAttr.WIDTH);
	if (flip) {
		ports[GATE1] = new Port(20 * (dx - dy), 20 * (dx + dy), Port.INPUT, 1);
		ports[GATE0] = new Port(20 * (dx + dy), 20 * (-dx + dy), Port.INPUT, 1);
	} else {
		ports[GATE0] = new Port(20 * (dx - dy), 20 * (dx + dy), Port.INPUT, 1);
		ports[GATE1] = new Port(20 * (dx + dy), 20 * (-dx + dy), Port.INPUT, 1);
	}
	instance.setPorts(ports);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:29,代码来源:TransmissionGate.java

示例12: getValue

@Override
public <V> V getValue(Attribute<V> attr) {
	if (attr == StdAttr.WIDTH)
		return (V) width;
	if (attr == Pin.ATTR_TRISTATE)
		return (V) Boolean.valueOf(threeState);
	if (attr == Pin.ATTR_TYPE)
		return (V) Boolean.valueOf(type == EndData.OUTPUT_ONLY);
	if (attr == Pin.ATTR_PULL)
		return (V) pull;
	if (attr == StdAttr.ATTR_LABEL_COLOR) {
		return (V) LabelColor;
	}
	return super.getValue(attr);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:15,代码来源:PinAttributes.java

示例13: configurePorts

private void configurePorts(Instance instance) {
	PinAttributes attrs = (PinAttributes) instance.getAttributeSet();
	String endType = attrs.isOutput() ? Port.INPUT : Port.OUTPUT;
	Port port = new Port(0, 0, endType, StdAttr.WIDTH);
	if (attrs.isOutput()) {
		port.setToolTip(Strings.getter("pinOutputToolTip"));
	} else {
		port.setToolTip(Strings.getter("pinInputToolTip"));
	}
	instance.setPorts(new Port[] { port });
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:11,代码来源:Pin.java

示例14: instanceAttributeChanged

@Override
protected void instanceAttributeChanged(Instance instance, Attribute<?> attr) {
	if (attr == ATTR_TYPE) {
		configurePorts(instance);
	} else if (attr == StdAttr.WIDTH || attr == StdAttr.FACING || attr == Pin.ATTR_LABEL_LOC) {
		instance.recomputeBounds();
		PinAttributes attrs = (PinAttributes) instance.getAttributeSet();
		Probe.configureLabel(instance, attrs.labelloc, attrs.facing);
	} else if (attr == Pin.ATTR_TRISTATE || attr == Pin.ATTR_PULL) {
		instance.fireInvalidated();
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:12,代码来源:Pin.java

示例15: instanceAttributeChanged

@Override
protected void instanceAttributeChanged(Instance instance, Attribute<?> attr) {
	if (attr == StdAttr.FACING || attr == Wiring.ATTR_GATE) {
		instance.recomputeBounds();
		updatePorts(instance);
	} else if (attr == StdAttr.WIDTH) {
		updatePorts(instance);
	} else if (attr == ATTR_TYPE) {
		instance.fireInvalidated();
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:11,代码来源:Transistor.java


注:本文中的com.cburch.logisim.instance.StdAttr.WIDTH属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。