use of com.cburch.logisim.data.Direction in project logisim-evolution by reds-heig.
the class Multiplexer method paintGhost.
@Override
public void paintGhost(InstancePainter painter) {
Direction facing = painter.getAttributeValue(StdAttr.FACING);
BitWidth select = painter.getAttributeValue(Plexers.ATTR_SELECT);
Bounds bds = painter.getBounds();
if (select.getWidth() == 1) {
if (facing == Direction.EAST || facing == Direction.WEST) {
Plexers.drawTrapezoid(painter.getGraphics(), Bounds.create(bds.getX(), bds.getY() + 5, bds.getWidth(), bds.getHeight() - 10), facing, 10);
} else {
Plexers.drawTrapezoid(painter.getGraphics(), Bounds.create(bds.getX() + 5, bds.getY(), bds.getWidth() - 10, bds.getHeight()), facing, 10);
}
} else {
Plexers.drawTrapezoid(painter.getGraphics(), bds, facing, 20);
}
}
use of com.cburch.logisim.data.Direction in project logisim-evolution by reds-heig.
the class PriorityEncoder method paintInstance.
@Override
public void paintInstance(InstancePainter painter) {
Graphics g = painter.getGraphics();
Direction facing = painter.getAttributeValue(StdAttr.FACING);
painter.drawBounds();
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();
}
use of com.cburch.logisim.data.Direction in project logisim-evolution by reds-heig.
the class CircuitAttributes method setValue.
@Override
public <E> void setValue(Attribute<E> attr, E value) {
if (attr == StdAttr.FACING) {
Direction val = (Direction) value;
if (facing.equals(val))
return;
facing = val;
fireAttributeValueChanged(StdAttr.FACING, val, null);
if (subcircInstance != null)
subcircInstance.recomputeBounds();
} else if (attr == StdAttr.LABEL) {
String val = (String) value;
String oldval = label;
if (label.equals(val))
return;
label = val;
fireAttributeValueChanged(StdAttr.LABEL, val, oldval);
} else if (attr == StdAttr.LABEL_FONT) {
Font val = (Font) value;
if (labelFont.equals(val))
return;
labelFont = val;
fireAttributeValueChanged(StdAttr.LABEL_FONT, val, null);
} else if (attr == StdAttr.LABEL_VISIBILITY) {
Boolean val = (Boolean) value;
if (LabelVisable == value)
return;
LabelVisable = val;
fireAttributeValueChanged(StdAttr.LABEL_VISIBILITY, val, null);
} else if (attr == LABEL_LOCATION_ATTR) {
Direction val = (Direction) value;
if (labelLocation.equals(val))
return;
labelLocation = val;
fireAttributeValueChanged(LABEL_LOCATION_ATTR, val, null);
} else {
source.getStaticAttributes().setValue(attr, value);
if (attr == NAME_ATTR) {
source.fireEvent(CircuitEvent.ACTION_SET_NAME, value);
}
}
}
use of com.cburch.logisim.data.Direction in project logisim-evolution by reds-heig.
the class AbstractGate method paintBase.
private void paintBase(InstancePainter painter) {
GateAttributes attrs = (GateAttributes) painter.getAttributeSet();
Direction facing = attrs.facing;
int inputs = attrs.inputs;
int negated = attrs.negated;
Object shape = painter.getGateShape();
Location loc = painter.getLocation();
Bounds bds = painter.getOffsetBounds();
int width = bds.getWidth();
int height = bds.getHeight();
if (facing == Direction.NORTH || facing == Direction.SOUTH) {
int t = width;
width = height;
height = t;
}
if (negated != 0) {
width -= 10;
}
Graphics g = painter.getGraphics();
Color baseColor = g.getColor();
if (shape == AppPreferences.SHAPE_SHAPED && paintInputLines) {
PainterShaped.paintInputLines(painter, this);
} else if (negated != 0) {
for (int i = 0; i < inputs; i++) {
int negatedBit = (negated >> i) & 1;
if (negatedBit == 1) {
Location in = getInputOffset(attrs, i);
Location cen = in.translate(facing, 5);
painter.drawDongle(loc.getX() + cen.getX(), loc.getY() + cen.getY());
}
}
}
g.setColor(baseColor);
g.translate(loc.getX(), loc.getY());
double rotate = 0.0;
if (facing != Direction.EAST && g instanceof Graphics2D) {
rotate = -facing.toRadians();
Graphics2D g2 = (Graphics2D) g;
g2.rotate(rotate);
}
if (shape == AppPreferences.SHAPE_RECTANGULAR) {
paintRectangular(painter, width, height);
} else if (shape == AppPreferences.SHAPE_DIN40700) {
paintDinShape(painter, width, height, inputs);
} else {
// SHAPE_SHAPED
if (negateOutput) {
g.translate(-10, 0);
paintShape(painter, width - 10, height);
painter.drawDongle(5, 0);
g.translate(10, 0);
} else {
paintShape(painter, width, height);
}
}
if (rotate != 0.0) {
((Graphics2D) g).rotate(-rotate);
}
g.translate(-loc.getX(), -loc.getY());
painter.drawLabel();
}
use of com.cburch.logisim.data.Direction in project logisim-evolution by reds-heig.
the class Buffer method paintBase.
private void paintBase(InstancePainter painter) {
Direction facing = painter.getAttributeValue(StdAttr.FACING);
Location loc = painter.getLocation();
int x = loc.getX();
int y = loc.getY();
Graphics g = painter.getGraphics();
g.translate(x, y);
double rotate = 0.0;
if (facing != Direction.EAST && g instanceof Graphics2D) {
rotate = -facing.toRadians();
((Graphics2D) g).rotate(rotate);
}
GraphicsUtil.switchToWidth(g, 2);
int[] xp = new int[4];
int[] yp = new int[4];
xp[0] = 0;
yp[0] = 0;
xp[1] = -19;
yp[1] = -7;
xp[2] = -19;
yp[2] = 7;
xp[3] = 0;
yp[3] = 0;
g.drawPolyline(xp, yp, 4);
if (rotate != 0.0) {
((Graphics2D) g).rotate(-rotate);
}
g.translate(-x, -y);
}
Aggregations