本文整理汇总了Java中com.cburch.logisim.util.GraphicsUtil.H_CENTER属性的典型用法代码示例。如果您正苦于以下问题:Java GraphicsUtil.H_CENTER属性的具体用法?Java GraphicsUtil.H_CENTER怎么用?Java GraphicsUtil.H_CENTER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.cburch.logisim.util.GraphicsUtil
的用法示例。
在下文中一共展示了GraphicsUtil.H_CENTER属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeTextField
private void computeTextField(Instance instance) {
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();
y = bds.getY() - 2;
valign = GraphicsUtil.V_BOTTOM;
}
instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, StdAttr.ATTR_LABEL_COLOR, x, y, halign, valign);
}
示例2: 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);
}
示例3: 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();
}
示例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);
}
示例5: 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);
}
示例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 == 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: paintInstance
@Override
public void paintInstance(InstancePainter painter) {
Graphics g = painter.getGraphics();
Bounds bds = painter.getBounds();
Direction facing = painter.getAttributeValue(StdAttr.FACING);
BitWidth select = painter.getAttributeValue(Plexers.ATTR_SELECT);
boolean enable = painter.getAttributeValue(Plexers.ATTR_ENABLE).booleanValue();
int inputs = 1 << select.getWidth();
// draw stubs for select/enable inputs that aren't on instance boundary
GraphicsUtil.switchToWidth(g, 3);
boolean vertical = facing != Direction.NORTH && facing != Direction.SOUTH;
Object selectLoc = painter.getAttributeValue(Plexers.ATTR_SELECT_LOC);
int selMult = selectLoc == Plexers.SELECT_BOTTOM_LEFT ? 1 : -1;
int dx = vertical ? 0 : -selMult;
int dy = vertical ? selMult : 0;
if (inputs == 2) { // draw select wire
Location pt = painter.getInstance().getPortLocation(inputs);
if (painter.getShowState()) {
g.setColor(painter.getPort(inputs).getColor());
}
g.drawLine(pt.getX() - 2 * dx, pt.getY() - 2 * dy, pt.getX(), pt.getY());
}
if (enable) {
Location en = painter.getInstance().getPortLocation(inputs + 1);
if (painter.getShowState()) {
g.setColor(painter.getPort(inputs + 1).getColor());
}
int len = inputs == 2 ? 6 : 4;
g.drawLine(en.getX() - len * dx, en.getY() - len * dy, en.getX(), en.getY());
}
GraphicsUtil.switchToWidth(g, 1);
// draw a circle indicating where the select input is located
Multiplexer.drawSelectCircle(g, bds, painter.getInstance().getPortLocation(inputs));
// draw a 0 indicating where the numbering starts for inputs
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;
}
g.setColor(Color.GRAY);
GraphicsUtil.drawText(g, "0", x0, y0, halign, GraphicsUtil.V_BASELINE);
// draw the trapezoid, "MUX" string, the individual ports
g.setColor(Color.BLACK);
Plexers.drawTrapezoid(g, bds, facing, select.getWidth() == 1 ? 10 : 20);
GraphicsUtil.drawCenteredText(g, "MUX", bds.getX() + bds.getWidth() / 2, bds.getY() + bds.getHeight() / 2);
painter.drawPorts();
}
示例8: paintInstance
@Override
public void paintInstance(InstancePainter painter) {
Graphics g = painter.getGraphics();
Bounds bds = painter.getBounds();
Direction facing = painter.getAttributeValue(StdAttr.FACING);
Object selectLoc = painter.getAttributeValue(Plexers.ATTR_SELECT_LOC);
BitWidth select = painter.getAttributeValue(Plexers.ATTR_SELECT);
boolean enable = painter.getAttributeValue(Plexers.ATTR_ENABLE).booleanValue();
int selMult = selectLoc == Plexers.SELECT_TOP_RIGHT ? -1 : 1;
int outputs = 1 << select.getWidth();
// draw stubs for select and enable ports
GraphicsUtil.switchToWidth(g, 3);
boolean vertical = facing == Direction.NORTH || facing == Direction.SOUTH;
int dx = vertical ? selMult : 0;
int dy = vertical ? 0 : -selMult;
if (outputs == 2) { // draw select wire
if (painter.getShowState()) {
g.setColor(painter.getPort(outputs).getColor());
}
Location pt = painter.getInstance().getPortLocation(outputs);
g.drawLine(pt.getX(), pt.getY(), pt.getX() + 2 * dx, pt.getY() + 2 * dy);
}
if (enable) {
Location en = painter.getInstance().getPortLocation(outputs + 1);
int len = outputs == 2 ? 6 : 4;
if (painter.getShowState()) {
g.setColor(painter.getPort(outputs + 1).getColor());
}
g.drawLine(en.getX(), en.getY(), en.getX() + len * dx, en.getY() + len * dy);
}
GraphicsUtil.switchToWidth(g, 1);
// draw a circle indicating where the select input is located
Multiplexer.drawSelectCircle(g, bds, painter.getInstance().getPortLocation(outputs));
// draw "0"
int x0;
int y0;
int halign;
if (facing == Direction.WEST) {
x0 = 3;
y0 = 15;
halign = GraphicsUtil.H_LEFT;
} else if (facing == Direction.NORTH) {
x0 = 10;
y0 = 15;
halign = GraphicsUtil.H_CENTER;
} else if (facing == Direction.SOUTH) {
x0 = 10;
y0 = bds.getHeight() - 3;
halign = GraphicsUtil.H_CENTER;
} else {
x0 = bds.getWidth() - 3;
y0 = 15;
halign = GraphicsUtil.H_RIGHT;
}
g.setColor(Color.GRAY);
GraphicsUtil.drawText(g, "0", bds.getX() + x0, bds.getY() + y0, halign, GraphicsUtil.V_BASELINE);
// draw trapezoid, "Decd", and ports
g.setColor(Color.BLACK);
Plexers.drawTrapezoid(g, bds, facing.reverse(), outputs == 2 ? 10 : 20);
GraphicsUtil.drawCenteredText(g, "Decd", bds.getX() + bds.getWidth() / 2, bds.getY() + bds.getHeight() / 2);
painter.drawPorts();
}
示例9: paintInstance
@Override
public void paintInstance(InstancePainter painter) {
Graphics g = painter.getGraphics();
Bounds bds = painter.getBounds();
Direction facing = painter.getAttributeValue(StdAttr.FACING);
BitWidth select = painter.getAttributeValue(Plexers.ATTR_SELECT);
boolean enable = painter.getAttributeValue(Plexers.ATTR_ENABLE).booleanValue();
int outputs = 1 << select.getWidth();
// draw select and enable inputs
GraphicsUtil.switchToWidth(g, 3);
boolean vertical = facing == Direction.NORTH || facing == Direction.SOUTH;
Object selectLoc = painter.getAttributeValue(Plexers.ATTR_SELECT_LOC);
int selMult = selectLoc == Plexers.SELECT_BOTTOM_LEFT ? 1 : -1;
int dx = vertical ? selMult : 0;
int dy = vertical ? 0 : -selMult;
if (outputs == 2) { // draw select wire
Location sel = painter.getInstance().getPortLocation(outputs);
if (painter.getShowState()) {
g.setColor(painter.getPort(outputs).getColor());
}
g.drawLine(sel.getX(), sel.getY(), sel.getX() + 2 * dx, sel.getY() + 2 * dy);
}
if (enable) {
Location en = painter.getInstance().getPortLocation(outputs + 1);
if (painter.getShowState()) {
g.setColor(painter.getPort(outputs + 1).getColor());
}
int len = outputs == 2 ? 6 : 4;
g.drawLine(en.getX(), en.getY(), en.getX() + len * dx, en.getY() + len * dy);
}
GraphicsUtil.switchToWidth(g, 1);
// draw a circle indicating where the select input is located
Multiplexer.drawSelectCircle(g, bds, painter.getInstance().getPortLocation(outputs));
// draw "0" next to first input
int x0;
int y0;
int halign;
if (facing == Direction.WEST) {
x0 = 3;
y0 = 15;
halign = GraphicsUtil.H_LEFT;
} else if (facing == Direction.NORTH) {
x0 = 10;
y0 = 15;
halign = GraphicsUtil.H_CENTER;
} else if (facing == Direction.SOUTH) {
x0 = 10;
y0 = bds.getHeight() - 3;
halign = GraphicsUtil.H_CENTER;
} else {
x0 = bds.getWidth() - 3;
y0 = 15;
halign = GraphicsUtil.H_RIGHT;
}
g.setColor(Color.GRAY);
GraphicsUtil.drawText(g, "0", bds.getX() + x0, bds.getY() + y0, halign, GraphicsUtil.V_BASELINE);
// draw trapezoid, "DMX" label, and ports
g.setColor(Color.BLACK);
Plexers.drawTrapezoid(g, bds, facing.reverse(), select.getWidth() == 1 ? 10 : 20);
GraphicsUtil.drawCenteredText(g, "DMX", bds.getX() + bds.getWidth() / 2, bds.getY() + bds.getHeight() / 2);
painter.drawPorts();
}