當前位置: 首頁>>代碼示例>>Java>>正文


Java Direction.EAST屬性代碼示例

本文整理匯總了Java中com.cburch.logisim.data.Direction.EAST屬性的典型用法代碼示例。如果您正苦於以下問題:Java Direction.EAST屬性的具體用法?Java Direction.EAST怎麽用?Java Direction.EAST使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.cburch.logisim.data.Direction的用法示例。


在下文中一共展示了Direction.EAST屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateports

private void updateports(Instance instance) {
	Direction dir = instance.getAttributeValue(StdAttr.FACING);
	BitWidth bw = instance.getAttributeValue(ATTR_WIDTH);
	Port[] ports = new Port[2];
	if (dir == Direction.EAST || dir == Direction.WEST) {
		ports[0] = new Port(0, 0, Port.OUTPUT, bw);
		ports[1] = new Port(0, 10, Port.OUTPUT, bw);
	} else {
		ports[0] = new Port(0, 0, Port.OUTPUT, bw);
		ports[1] = new Port(-10, 0, Port.OUTPUT, bw);
	}
	ports[0].setToolTip(Strings.getter("X"));
	ports[1].setToolTip(Strings.getter("Y"));

	instance.setPorts(ports);

}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:17,代碼來源:Joystick.java

示例2: contains

@Override
public boolean contains(Location loc, boolean assumeFilled) {
	if (super.isInCircle(loc, RADIUS)) {
		return true;
	} else {
		Location center = getLocation();
		Location end = center.translate(facing, RADIUS + INDICATOR_LENGTH);
		if (facing == Direction.EAST || facing == Direction.WEST) {
			return Math.abs(loc.getY() - center.getY()) < 2
					&& (loc.getX() < center.getX()) != (loc.getX() < end.getX());
		} else {
			return Math.abs(loc.getX() - center.getX()) < 2
					&& (loc.getY() < center.getY()) != (loc.getY() < end.getY());
		}
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:16,代碼來源:AppearanceAnchor.java

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

示例4: getOffsetBounds

@Override
public Bounds getOffsetBounds(AttributeSet attrs) {
	Direction facing = attrs.getValue(StdAttr.FACING);
	if (facing == Direction.EAST) {
		return Bounds.create(-42, -6, 42, 12);
	} else if (facing == Direction.WEST) {
		return Bounds.create(0, -6, 42, 12);
	} else if (facing == Direction.NORTH) {
		return Bounds.create(-6, 0, 12, 42);
	} else {
		return Bounds.create(-6, -42, 12, 42);
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:13,代碼來源:PullResistor.java

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

示例6: 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 == Io.LABEL_CENTER) {
		x = bds.getX() + (bds.getWidth() - DEPTH) / 2;
		y = bds.getY() + (bds.getHeight() - DEPTH) / 2;
	} else 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,代碼行數:37,代碼來源:Button.java

示例7: contains

@Override
public boolean contains(Location loc) {
	if (super.contains(loc)) {
		Location myLoc = getLocation();
		Direction facing = getAttributeSet().getValue(StdAttr.FACING);
		if (facing == Direction.EAST || facing == Direction.WEST) {
			return Math.abs(loc.getX() - myLoc.getX()) > 5 || loc.manhattanDistanceTo(myLoc) <= 5;
		} else {
			return Math.abs(loc.getY() - myLoc.getY()) > 5 || loc.manhattanDistanceTo(myLoc) <= 5;
		}
	} else {
		return false;
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:14,代碼來源:Splitter.java

示例8: paintIcon

@Override
public void paintIcon(InstancePainter painter) {
	int w = painter.getAttributeValue(StdAttr.WIDTH).getWidth();
	int pinx = 17;
	int piny = 8;
	Direction dir = painter.getAttributeValue(StdAttr.FACING);
	if (dir == Direction.EAST) {
	} // keep defaults
	else if (dir == Direction.WEST) {
		pinx = 0;
	} else if (dir == Direction.NORTH) {
		pinx = 8;
		piny = 2;
	} else if (dir == Direction.SOUTH) {
		pinx = 8;
		piny = 15;
	}

	Graphics g = painter.getGraphics();
	g.setColor(BACKGROUND_COLOR);
	g.fillRoundRect(2, 3, 16, 14, 3, 3);
	g.setColor(Color.BLACK);
	if (w == 1) {
		int v = painter.getAttributeValue(ATTR_VALUE).intValue();
		Value val = v == 1 ? Value.TRUE : Value.FALSE;
		g.setColor(val.getColor());
		GraphicsUtil.drawCenteredText(g, "" + v, 11, 8);
	} else {
		g.setFont(g.getFont().deriveFont(9.0f));
		GraphicsUtil.drawCenteredText(g, "x" + w, 11, 8);
	}
	g.fillOval(pinx, piny, 3, 3);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:33,代碼來源:Constant.java

示例9: getFacing

public Direction getFacing() {
	AppearanceAnchor anchor = findAnchor();
	if (anchor == null) {
		return Direction.EAST;
	} else {
		return anchor.getFacing();
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:8,代碼來源:CircuitAppearance.java

示例10: contains

static boolean contains(Location loc, Bounds bds, Direction facing) {
	if (bds.contains(loc, 1)) {
		int x = loc.getX();
		int y = loc.getY();
		int x0 = bds.getX();
		int x1 = x0 + bds.getWidth();
		int y0 = bds.getY();
		int y1 = y0 + bds.getHeight();
		if (facing == Direction.NORTH || facing == Direction.SOUTH) {
			if (x < x0 + 5 || x > x1 - 5) {
				if (facing == Direction.SOUTH) {
					return y < y0 + 5;
				} else {
					return y > y1 - 5;
				}
			} else {
				return true;
			}
		} else {
			if (y < y0 + 5 || y > y1 - 5) {
				if (facing == Direction.EAST) {
					return x < x0 + 5;
				} else {
					return x > x1 - 5;
				}
			} else {
				return true;
			}
		}
	} else {
		return false;
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:33,代碼來源:Plexers.java

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

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

示例13: getOffsetBounds

@Override
public Bounds getOffsetBounds(AttributeSet attrs) {
	Direction dir = attrs.getValue(StdAttr.FACING);
	if (dir == Direction.EAST || dir == Direction.WEST)
		return Bounds.create(-30, -10, 30, 30).rotate(Direction.EAST, dir, 0, 5);
	else if (dir == Direction.SOUTH)
		return Bounds.create(-20, -30, 30, 30);
	else
		return Bounds.create(-20, 0, 30, 30);

}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:11,代碼來源:Joystick.java

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

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


注:本文中的com.cburch.logisim.data.Direction.EAST屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。