Search in sources :

Example 86 with Location

use of com.cburch.logisim.data.Location in project logisim-evolution by reds-heig.

the class InstanceComponent method recomputeBounds.

void recomputeBounds() {
    Location p = loc;
    bounds = factory.getOffsetBounds(attrs).translate(p.getX(), p.getY());
}
Also used : Location(com.cburch.logisim.data.Location)

Example 87 with Location

use of com.cburch.logisim.data.Location in project logisim-evolution by reds-heig.

the class InstancePainter method isPortConnected.

public boolean isPortConnected(int index) {
    Circuit circ = context.getCircuit();
    Location loc = comp.getEnd(index).getLocation();
    return circ.isConnected(loc, comp);
}
Also used : Circuit(com.cburch.logisim.circuit.Circuit) Location(com.cburch.logisim.data.Location)

Example 88 with Location

use of com.cburch.logisim.data.Location in project logisim-evolution by reds-heig.

the class LineTool method mouseReleased.

@Override
public void mouseReleased(Canvas canvas, MouseEvent e) {
    if (active) {
        updateMouse(canvas, e.getX(), e.getY(), e.getModifiersEx());
        Location start = mouseStart;
        Location end = mouseEnd;
        CanvasObject add = null;
        if (!start.equals(end)) {
            active = false;
            CanvasModel model = canvas.getModel();
            Location[] ends = { start, end };
            List<Location> locs = UnmodifiableList.create(ends);
            add = attrs.applyTo(new Poly(false, locs));
            add.setValue(DrawAttr.PAINT_TYPE, DrawAttr.PAINT_STROKE);
            canvas.doAction(new ModelAddAction(model, add));
            repaintArea(canvas);
        }
        canvas.toolGestureComplete(this, add);
    }
}
Also used : CanvasObject(com.cburch.draw.model.CanvasObject) ModelAddAction(com.cburch.draw.actions.ModelAddAction) CanvasModel(com.cburch.draw.model.CanvasModel) Poly(com.cburch.draw.shapes.Poly) Location(com.cburch.logisim.data.Location)

Example 89 with Location

use of com.cburch.logisim.data.Location in project logisim-evolution by reds-heig.

the class LineTool method mousePressed.

@Override
public void mousePressed(Canvas canvas, MouseEvent e) {
    int x = e.getX();
    int y = e.getY();
    int mods = e.getModifiersEx();
    if ((mods & InputEvent.CTRL_DOWN_MASK) != 0) {
        x = canvas.snapX(x);
        y = canvas.snapY(y);
    }
    Location loc = Location.create(x, y);
    mouseStart = loc;
    mouseEnd = loc;
    lastMouseX = loc.getX();
    lastMouseY = loc.getY();
    active = canvas.getModel() != null;
    repaintArea(canvas);
}
Also used : Location(com.cburch.logisim.data.Location)

Example 90 with Location

use of com.cburch.logisim.data.Location in project logisim-evolution by reds-heig.

the class LineTool method draw.

@Override
public void draw(Canvas canvas, Graphics g) {
    if (active) {
        Location start = mouseStart;
        Location end = mouseEnd;
        g.setColor(Color.GRAY);
        g.drawLine(start.getX(), start.getY(), end.getX(), end.getY());
    }
}
Also used : Location(com.cburch.logisim.data.Location)

Aggregations

Location (com.cburch.logisim.data.Location)169 Direction (com.cburch.logisim.data.Direction)39 Graphics (java.awt.Graphics)35 Component (com.cburch.logisim.comp.Component)26 Bounds (com.cburch.logisim.data.Bounds)24 ArrayList (java.util.ArrayList)23 CanvasObject (com.cburch.draw.model.CanvasObject)17 BitWidth (com.cburch.logisim.data.BitWidth)16 Wire (com.cburch.logisim.circuit.Wire)13 HashMap (java.util.HashMap)10 Handle (com.cburch.draw.model.Handle)9 AttributeSet (com.cburch.logisim.data.AttributeSet)9 Value (com.cburch.logisim.data.Value)9 Instance (com.cburch.logisim.instance.Instance)9 Port (com.cburch.logisim.instance.Port)9 Color (java.awt.Color)9 Graphics2D (java.awt.Graphics2D)9 HashSet (java.util.HashSet)9 Circuit (com.cburch.logisim.circuit.Circuit)8 EndData (com.cburch.logisim.comp.EndData)7