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


Java Direction.WEST属性代码示例

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


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

示例1: configureOptions

private void configureOptions() {
	// compute the set of options for BitOutAttributes
	options = new BitOutOption[fanout + 1];
	boolean isVertical = facing == Direction.EAST || facing == Direction.WEST;
	for (int i = -1; i < fanout; i++) {
		options[i + 1] = new BitOutOption(i, isVertical, i == fanout - 1);
	}

	// go ahead and set the options for the existing attributes
	int offs = INIT_ATTRIBUTES.size();
	int curNum = attrs.size() - offs;
	for (int i = 0; i < curNum; i++) {
		BitOutAttribute attr = (BitOutAttribute) attrs.get(offs + i);
		attr.options = options;
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:16,代码来源:SplitterAttributes.java

示例2: toString

@Override
public String toString() {
	if (value < 0) {
		return Strings.get("splitterBitNone");
	} else {
		String ret = "" + value;
		Direction noteDir;
		if (value == 0) {
			noteDir = isVertical ? Direction.NORTH : Direction.EAST;
		} else if (isLast) {
			noteDir = isVertical ? Direction.SOUTH : Direction.WEST;
		} else {
			noteDir = null;
		}
		if (noteDir != null) {
			ret += " (" + noteDir.toVerticalDisplayString() + ")";
		}
		return ret;
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:20,代码来源:SplitterAttributes.java

示例3: configureLabel

private void configureLabel(Instance instance) {
	Bounds bds = instance.getBounds();
	Direction loc = instance.getAttributeValue(CircuitAttributes.LABEL_LOCATION_ATTR);

	int x = bds.getX() + bds.getWidth() / 2;
	int y = bds.getY() + bds.getHeight() / 2;
	int ha = GraphicsUtil.H_CENTER;
	int va = GraphicsUtil.V_CENTER;
	if (loc == Direction.EAST) {
		x = bds.getX() + bds.getWidth() + 2;
		ha = GraphicsUtil.H_LEFT;
	} else if (loc == Direction.WEST) {
		x = bds.getX() - 2;
		ha = GraphicsUtil.H_RIGHT;
	} else if (loc == Direction.SOUTH) {
		y = bds.getY() + bds.getHeight() + 2;
		va = GraphicsUtil.V_TOP;
	} else {
		y = bds.getY() - 2;
		va = GraphicsUtil.V_BASELINE;
	}
	instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, StdAttr.ATTR_LABEL_COLOR, x, y, ha, va);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:23,代码来源:SubcircuitFactory.java

示例4: computeTextField

private void computeTextField(Instance instance) {
	Direction facing = instance.getAttributeValue(StdAttr.FACING);
	Object labelLoc = instance.getAttributeValue(Io.ATTR_LABEL_LOC);

	Bounds bds = instance.getBounds();
	int x = bds.getX() + bds.getWidth() / 2;
	int y = bds.getY() + bds.getHeight() / 2;
	int halign = GraphicsUtil.H_CENTER;
	int valign = GraphicsUtil.V_CENTER;
	if (labelLoc == Direction.NORTH) {
		y = bds.getY() - 2;
		valign = GraphicsUtil.V_BOTTOM;
	} else if (labelLoc == Direction.SOUTH) {
		y = bds.getY() + bds.getHeight() + 2;
		valign = GraphicsUtil.V_TOP;
	} else if (labelLoc == Direction.EAST) {
		x = bds.getX() + bds.getWidth() + 2;
		halign = GraphicsUtil.H_LEFT;
	} else if (labelLoc == Direction.WEST) {
		x = bds.getX() - 2;
		halign = GraphicsUtil.H_RIGHT;
	}
	if (labelLoc == facing) {
		if (labelLoc == Direction.NORTH || labelLoc == Direction.SOUTH) {
			x += 12;
			halign = GraphicsUtil.H_LEFT;
		} else {
			y -= 12;
			valign = GraphicsUtil.V_BOTTOM;
		}
	}

	instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, StdAttr.ATTR_LABEL_COLOR, x, y, halign, valign);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:34,代码来源:RGBLed.java

示例5: 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

示例6: getOffsetBounds

@Override
public Bounds getOffsetBounds(AttributeSet attrs) {
	int w = 20;
	if (isInverter && !NotGate.SIZE_NARROW.equals(attrs.getValue(NotGate.ATTR_SIZE))) {
		w = 30;
	}
	Direction facing = attrs.getValue(StdAttr.FACING);
	if (facing == Direction.NORTH)
		return Bounds.create(-10, 0, 20, w);
	if (facing == Direction.SOUTH)
		return Bounds.create(-10, -w, 20, w);
	if (facing == Direction.WEST)
		return Bounds.create(0, -10, w, 20);
	return Bounds.create(-w, -10, w, 20);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:15,代码来源:ControlledBuffer.java

示例7: computeTextField

private void computeTextField(Instance instance) {
	Direction facing = instance.getAttributeValue(StdAttr.FACING);
	Object labelLoc = instance.getAttributeValue(Io.ATTR_LABEL_LOC);

	Bounds bds = instance.getBounds();
	int x = bds.getX() + bds.getWidth() / 2;
	int y = bds.getY() + bds.getHeight() / 2;
	int halign = GraphicsUtil.H_CENTER;
	int valign = GraphicsUtil.V_CENTER;
	if (labelLoc == Direction.NORTH) {
		y = bds.getY() - 2;
		valign = GraphicsUtil.V_BOTTOM;
	} else if (labelLoc == Direction.SOUTH) {
		y = bds.getY() + bds.getHeight() + 2;
		valign = GraphicsUtil.V_TOP;
	} else if (labelLoc == Direction.EAST) {
		x = bds.getX() + bds.getWidth() + 2;
		halign = GraphicsUtil.H_LEFT;
	} else if (labelLoc == Direction.WEST) {
		x = bds.getX() - 2;
		halign = GraphicsUtil.H_RIGHT;
	}
	if (labelLoc == facing) {
		if (labelLoc == Direction.NORTH || labelLoc == Direction.SOUTH) {
			x += 2;
			halign = GraphicsUtil.H_LEFT;
		} else {
			y -= 2;
			valign = GraphicsUtil.V_BOTTOM;
		}
	}

	instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, StdAttr.ATTR_LABEL_COLOR, x, y, halign, valign);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:34,代码来源:Led.java

示例8: getOffsetBounds

@Override
public Bounds getOffsetBounds(AttributeSet attrs) {
	Direction facing = attrs.getValue(StdAttr.FACING);
	Object gateLoc = attrs.getValue(Wiring.ATTR_GATE);
	int delta = gateLoc == Wiring.GATE_TOP_LEFT ? -20 : 0;
	if (facing == Direction.NORTH) {
		return Bounds.create(delta, 0, 20, 40);
	} else if (facing == Direction.SOUTH) {
		return Bounds.create(delta, -40, 20, 40);
	} else if (facing == Direction.WEST) {
		return Bounds.create(0, delta, 40, 20);
	} else { // facing == Direction.EAST
		return Bounds.create(-40, delta, 40, 20);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:15,代码来源:Transistor.java

示例9: updatePorts

private void updatePorts(Instance instance) {
	Direction facing = instance.getAttributeValue(StdAttr.FACING);
	int dx = 0;
	int dy = 0;
	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[3];
	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[GATE] = new Port(20 * (dx + dy), 20 * (-dx + dy), Port.INPUT, 1);
	} else {
		ports[GATE] = new Port(20 * (dx - dy), 20 * (dx + dy), Port.INPUT, 1);
	}
	instance.setPorts(ports);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:27,代码来源:Transistor.java

示例10: updateports

private void updateports(Instance instance) {
	Direction dir = instance.getAttributeValue(StdAttr.FACING);

	int switches = instance.getAttributeValue(ATTR_NSWITCHES).intValue();
	Port[] ports = new Port[switches];

	if (dir == Direction.EAST || dir == Direction.WEST) {
		for (int i = 0; i < ports.length; i++)
			ports[i] = new Port(0, 20 * i + 10, Port.OUTPUT, 1);
	} else {
		for (int i = 0; i < ports.length; i++)
			ports[i] = new Port(20 * i + 10, 0, Port.OUTPUT, 1);
	}
	instance.setPorts(ports);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:15,代码来源:DipSwitch.java

示例11: paintInstance

@Override
public void paintInstance(InstancePainter painter) {
	Graphics g = painter.getGraphics();
	Direction facing = painter.getAttributeValue(StdAttr.FACING);

	painter.drawRoundBounds(Color.WHITE);
	Bounds bds = painter.getBounds();
	g.setColor(Color.GRAY);
	int x0;
	int y0;
	int halign;
	if (facing == Direction.WEST) {
		x0 = bds.getX() + bds.getWidth() - 3;
		y0 = bds.getY() + 15;
		halign = GraphicsUtil.H_RIGHT;
	} else if (facing == Direction.NORTH) {
		x0 = bds.getX() + 10;
		y0 = bds.getY() + bds.getHeight() - 2;
		halign = GraphicsUtil.H_CENTER;
	} else if (facing == Direction.SOUTH) {
		x0 = bds.getX() + 10;
		y0 = bds.getY() + 12;
		halign = GraphicsUtil.H_CENTER;
	} else {
		x0 = bds.getX() + 3;
		y0 = bds.getY() + 15;
		halign = GraphicsUtil.H_LEFT;
	}
	GraphicsUtil.drawText(g, "0", x0, y0, halign, GraphicsUtil.V_BASELINE);
	g.setColor(Color.BLACK);
	GraphicsUtil.drawCenteredText(g, "Pri", bds.getX() + bds.getWidth() / 2, bds.getY() + bds.getHeight() / 2);
	painter.drawPorts();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:33,代码来源:PriorityEncoder.java

示例12: keyEventReceived

@Override
public KeyConfigurationResult keyEventReceived(KeyConfigurationEvent event) {
	if (event.getType() == KeyConfigurationEvent.KEY_PRESSED) {
		KeyEvent e = event.getKeyEvent();
		if (e.getModifiersEx() == modsEx) {
			Direction value = null;
			switch (e.getKeyCode()) {
			case KeyEvent.VK_UP:
				value = Direction.NORTH;
				break;
			case KeyEvent.VK_DOWN:
				value = Direction.SOUTH;
				break;
			case KeyEvent.VK_LEFT:
				value = Direction.WEST;
				break;
			case KeyEvent.VK_RIGHT:
				value = Direction.EAST;
				break;
			}
			if (value != null) {
				event.consume();
				return new KeyConfigurationResult(event, attr, value);
			}
		}
	}
	return null;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:28,代码来源:DirectionConfigurator.java

示例13: getOffsetBounds

@Override
public Bounds getOffsetBounds(AttributeSet attrs) {
	Direction facing = attrs.getValue(StdAttr.FACING);
	if (facing == Direction.SOUTH)
		return Bounds.create(-9, -20, 18, 20);
	if (facing == Direction.NORTH)
		return Bounds.create(-9, 0, 18, 20);
	if (facing == Direction.WEST)
		return Bounds.create(0, -9, 20, 18);
	return Bounds.create(-20, -9, 20, 18);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:11,代码来源:Buffer.java

示例14: computeTextField

private void computeTextField(Instance instance) {
	Bounds bds = instance.getBounds();
	Direction dir = instance.getAttributeValue(StdAttr.FACING);
	if (dir == Direction.EAST || dir == Direction.WEST)
		instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, StdAttr.ATTR_LABEL_COLOR,
				bds.getX() + bds.getWidth() + 3, bds.getY() + bds.getHeight() / 2, GraphicsUtil.H_LEFT,
				GraphicsUtil.V_CENTER);
	else
		instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, StdAttr.ATTR_LABEL_COLOR,
				bds.getX() + bds.getWidth() / 2, bds.getY() - 3, GraphicsUtil.H_CENTER, GraphicsUtil.V_BASELINE);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:11,代码来源:AbstractTtlGate.java

示例15: getOffsetBounds

@Override
public Bounds getOffsetBounds(AttributeSet attrs) {
	Direction facing = attrs.getValue(StdAttr.FACING);
	int y = attrs.getValue(ATTR_NSWITCHES).intValue() * 20;
	if (facing == Direction.EAST)
		return Bounds.create(-30, 0, 30, y);
	else if (facing == Direction.WEST)
		return Bounds.create(0, 0, 30, y);
	else if (facing == Direction.NORTH)
		return Bounds.create(0, 0, y, 30);
	else
		return Bounds.create(0, -30, y, 30);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:13,代码来源:DipSwitch.java


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