當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。