本文整理汇总了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);
}
示例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());
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
}
示例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);
}
示例9: getFacing
public Direction getFacing() {
AppearanceAnchor anchor = findAnchor();
if (anchor == null) {
return Direction.EAST;
} else {
return anchor.getFacing();
}
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}