本文整理匯總了Java中com.cburch.logisim.data.Direction.SOUTH屬性的典型用法代碼示例。如果您正苦於以下問題:Java Direction.SOUTH屬性的具體用法?Java Direction.SOUTH怎麽用?Java Direction.SOUTH使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.cburch.logisim.data.Direction
的用法示例。
在下文中一共展示了Direction.SOUTH屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: paintInternalBase
private void paintInternalBase(InstancePainter painter) {
Direction dir = painter.getAttributeValue(StdAttr.FACING);
Bounds bds = painter.getBounds();
int x = bds.getX();
int y = bds.getY();
int width = bds.getWidth();
int height = bds.getHeight();
if (dir == Direction.SOUTH || dir == Direction.NORTH) {
x += (width - height) / 2;
y += (height - width) / 2;
width = bds.getHeight();
height = bds.getWidth();
}
if (this.ngatestodraw == 0)
paintInternal(painter, x, y, height, false);
else {
paintBase(painter, false, false);
for (int i = 0; i < this.ngatestodraw; i++) {
paintInternal(painter,
x + (i < this.ngatestodraw / 2 ? i : i - this.ngatestodraw / 2)
* ((width - 20) / (this.ngatestodraw / 2)) + (i < this.ngatestodraw / 2 ? 0 : 20),
y, height, !(i < this.ngatestodraw / 2));
}
}
}
示例2: getOffsetBounds
@Override
public Bounds getOffsetBounds(AttributeSet attrs) {
Direction dir = attrs.getValue(StdAttr.FACING);
BitWidth select = attrs.getValue(Plexers.ATTR_SELECT);
int inputs = 1 << select.getWidth();
int offs = -5 * inputs;
int len = 10 * inputs + 10;
if (dir == Direction.NORTH) {
return Bounds.create(offs, 0, len, 40);
} else if (dir == Direction.SOUTH) {
return Bounds.create(offs, -40, len, 40);
} else if (dir == Direction.WEST) {
return Bounds.create(0, offs, 40, len);
} else { // dir == Direction.EAST
return Bounds.create(-40, offs, 40, len);
}
}
示例3: drawPin
public void drawPin(Component comp, int i, String label, Direction dir) {
Color curColor = g.getColor();
if (i < 0 || i >= comp.getEnds().size())
return;
EndData e = comp.getEnd(i);
Location pt = e.getLocation();
int x = pt.getX();
int y = pt.getY();
if (getShowState()) {
CircuitState state = getCircuitState();
g.setColor(state.getValue(pt).getColor());
} else {
g.setColor(Color.BLACK);
}
g.fillOval(x - PIN_OFFS, y - PIN_OFFS, PIN_RAD, PIN_RAD);
g.setColor(curColor);
if (dir == Direction.EAST) {
GraphicsUtil.drawText(g, label, x + 3, y, GraphicsUtil.H_LEFT, GraphicsUtil.V_CENTER);
} else if (dir == Direction.WEST) {
GraphicsUtil.drawText(g, label, x - 3, y, GraphicsUtil.H_RIGHT, GraphicsUtil.V_CENTER);
} else if (dir == Direction.SOUTH) {
GraphicsUtil.drawText(g, label, x, y - 3, GraphicsUtil.H_CENTER, GraphicsUtil.V_BASELINE);
} else if (dir == Direction.NORTH) {
GraphicsUtil.drawText(g, label, x, y + 3, GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
}
}
示例4: contains
@Override
public boolean contains(Location loc, AttributeSet attrsBase) {
GateAttributes attrs = (GateAttributes) attrsBase;
if (super.contains(loc, attrs)) {
if (attrs.negated == 0) {
return true;
} else {
Direction facing = attrs.facing;
Bounds bds = getOffsetBounds(attrsBase);
int delt;
if (facing == Direction.NORTH) {
delt = loc.getY() - (bds.getY() + bds.getHeight());
} else if (facing == Direction.SOUTH) {
delt = loc.getY() - bds.getY();
} else if (facing == Direction.WEST) {
delt = loc.getX() - (bds.getX() + bds.getHeight());
} else {
delt = loc.getX() - bds.getX();
}
if (Math.abs(delt) > 5) {
return true;
} else {
int inputs = attrs.inputs;
for (int i = 1; i <= inputs; i++) {
Location offs = getInputOffset(attrs, i);
if (loc.manhattanDistanceTo(offs) <= 5)
return true;
}
return false;
}
}
} else {
return false;
}
}
示例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);
}
示例6: 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);
}
示例7: 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;
}
示例8: 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);
}
示例9: 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);
}
示例10: 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);
}
示例11: 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);
}
示例12: 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;
}
}
示例13: configureLabel
static void configureLabel(Instance instance, Direction labelLoc, Direction facing) {
Bounds bds = instance.getBounds();
int x;
int y;
int halign;
int valign;
if (labelLoc == Direction.NORTH) {
halign = TextField.H_CENTER;
valign = TextField.V_BOTTOM;
x = bds.getX() + bds.getWidth() / 2;
y = bds.getY() - 2;
if (facing == labelLoc) {
halign = TextField.H_LEFT;
x += 2;
}
} else if (labelLoc == Direction.SOUTH) {
halign = TextField.H_CENTER;
valign = TextField.V_TOP;
x = bds.getX() + bds.getWidth() / 2;
y = bds.getY() + bds.getHeight() + 2;
if (facing == labelLoc) {
halign = TextField.H_LEFT;
x += 2;
}
} else if (labelLoc == Direction.EAST) {
halign = TextField.H_LEFT;
valign = TextField.V_CENTER;
x = bds.getX() + bds.getWidth() + 2;
y = bds.getY() + bds.getHeight() / 2;
if (facing == labelLoc) {
valign = TextField.V_BOTTOM;
y -= 2;
}
} else { // WEST
halign = TextField.H_RIGHT;
valign = TextField.V_CENTER;
x = bds.getX() - 2;
y = bds.getY() + bds.getHeight() / 2;
if (facing == labelLoc) {
valign = TextField.V_BOTTOM;
y -= 2;
}
}
instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, StdAttr.ATTR_LABEL_COLOR, x, y, halign, valign);
}
示例14: drawInstance
private void drawInstance(InstancePainter painter, boolean isGhost) {
Object type = painter.getAttributeValue(ATTR_TYPE);
Object powerLoc = painter.getAttributeValue(Wiring.ATTR_GATE);
Direction from = painter.getAttributeValue(StdAttr.FACING);
Direction facing = painter.getAttributeValue(StdAttr.FACING);
boolean flip = (facing == Direction.SOUTH || facing == Direction.WEST) == (powerLoc == Wiring.GATE_TOP_LEFT);
int degrees = Direction.EAST.toDegrees() - from.toDegrees();
double radians = Math.toRadians((degrees + 360) % 360);
int m = flip ? 1 : -1;
Graphics2D g = (Graphics2D) painter.getGraphics();
Location loc = painter.getLocation();
g.translate(loc.getX(), loc.getY());
g.rotate(radians);
Color gate;
Color input;
Color output;
Color platform;
if (!isGhost && painter.getShowState()) {
gate = painter.getPort(GATE).getColor();
input = painter.getPort(INPUT).getColor();
output = painter.getPort(OUTPUT).getColor();
Value out = computeOutput(painter);
platform = out.isUnknown() ? Value.UNKNOWN.getColor() : out.getColor();
} else {
Color base = g.getColor();
gate = base;
input = base;
output = base;
platform = base;
}
// input and output lines
GraphicsUtil.switchToWidth(g, Wire.WIDTH);
g.setColor(output);
g.drawLine(0, 0, -11, 0);
g.drawLine(-11, m * 7, -11, 0);
g.setColor(input);
g.drawLine(-40, 0, -29, 0);
g.drawLine(-29, m * 7, -29, 0);
// gate line
g.setColor(gate);
if (type == TYPE_P) {
g.drawLine(-20, m * 20, -20, m * 15);
GraphicsUtil.switchToWidth(g, 1);
g.drawOval(-22, m * 12 - 2, 4, 4);
} else {
g.drawLine(-20, m * 20, -20, m * 11);
GraphicsUtil.switchToWidth(g, 1);
}
// draw platforms
g.drawLine(-10, m * 10, -30, m * 10); // gate platform
g.setColor(platform);
g.drawLine(-9, m * 8, -31, m * 8); // input/output platform
// arrow (same color as platform)
g.drawLine(-21, m * 6, -18, m * 3);
g.drawLine(-21, 0, -18, m * 3);
g.rotate(-radians);
g.translate(-loc.getX(), -loc.getY());
}
示例15: updatePorts
private void updatePorts(Instance instance) {
Direction facing = instance.getAttributeValue(StdAttr.FACING);
Object selectLoc = instance.getAttributeValue(Plexers.ATTR_SELECT_LOC);
BitWidth data = instance.getAttributeValue(StdAttr.WIDTH);
BitWidth select = instance.getAttributeValue(Plexers.ATTR_SELECT);
boolean enable = instance.getAttributeValue(Plexers.ATTR_ENABLE).booleanValue();
int outputs = 1 << select.getWidth();
Port[] ps = new Port[outputs + (enable ? 3 : 2)];
Location sel;
int selMult = selectLoc == Plexers.SELECT_BOTTOM_LEFT ? 1 : -1;
if (outputs == 2) {
Location end0;
Location end1;
if (facing == Direction.WEST) {
end0 = Location.create(-30, -10);
end1 = Location.create(-30, 10);
sel = Location.create(-20, selMult * 20);
} else if (facing == Direction.NORTH) {
end0 = Location.create(-10, -30);
end1 = Location.create(10, -30);
sel = Location.create(selMult * -20, -20);
} else if (facing == Direction.SOUTH) {
end0 = Location.create(-10, 30);
end1 = Location.create(10, 30);
sel = Location.create(selMult * -20, 20);
} else {
end0 = Location.create(30, -10);
end1 = Location.create(30, 10);
sel = Location.create(20, selMult * 20);
}
ps[0] = new Port(end0.getX(), end0.getY(), Port.OUTPUT, data.getWidth());
ps[1] = new Port(end1.getX(), end1.getY(), Port.OUTPUT, data.getWidth());
} else {
int dx = -(outputs / 2) * 10;
int ddx = 10;
int dy = dx;
int ddy = 10;
if (facing == Direction.WEST) {
dx = -40;
ddx = 0;
sel = Location.create(-20, selMult * (dy + 10 * outputs));
} else if (facing == Direction.NORTH) {
dy = -40;
ddy = 0;
sel = Location.create(selMult * dx, -20);
} else if (facing == Direction.SOUTH) {
dy = 40;
ddy = 0;
sel = Location.create(selMult * dx, 20);
} else {
dx = 40;
ddx = 0;
sel = Location.create(20, selMult * (dy + 10 * outputs));
}
for (int i = 0; i < outputs; i++) {
ps[i] = new Port(dx, dy, Port.OUTPUT, data.getWidth());
dx += ddx;
dy += ddy;
}
}
Location en = sel.translate(facing, -10);
ps[outputs] = new Port(sel.getX(), sel.getY(), Port.INPUT, select.getWidth());
if (enable) {
ps[outputs + 1] = new Port(en.getX(), en.getY(), Port.INPUT, BitWidth.ONE);
}
ps[ps.length - 1] = new Port(0, 0, Port.INPUT, data.getWidth());
for (int i = 0; i < outputs; i++) {
ps[i].setToolTip(Strings.getter("demultiplexerOutTip", "" + i));
}
ps[outputs].setToolTip(Strings.getter("demultiplexerSelectTip"));
if (enable) {
ps[outputs + 1].setToolTip(Strings.getter("demultiplexerEnableTip"));
}
ps[ps.length - 1].setToolTip(Strings.getter("demultiplexerInTip"));
instance.setPorts(ps);
}