Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.Direction


        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(-100, 20, w);
        }

        if (facing == Direction.SOUTH) {
View Full Code Here


        }
    }

    @Override
    public void paintInstance(InstancePainter painter) {
        Direction face = painter.getAttributeValue(StdAttr.FACING);

        Graphics g = painter.getGraphics();

        // draw control wire
        GraphicsUtil.switchToWidth(g, 3);
View Full Code Here

        }
        painter.drawLabel();
    }

    private void paintShape(InstancePainter painter) {
        Direction facing = painter.getAttributeValue(StdAttr.FACING);
        Location loc = painter.getLocation();
        int x = loc.getX();
        int y = loc.getY();
        double rotate = 0.0;
        Graphics g = painter.getGraphics();
        g.translate(x, y);
        if (facing != Direction.EAST && g instanceof Graphics2D) {
            rotate = -facing.toRadians();
            ((Graphics2D) g).rotate(rotate);
        }

        if (isInverter) {
            PainterShaped.paintNot(painter);
View Full Code Here

            NotGate.configureLabel(instance, false, instance.getPortLocation(2));
        }
    }

    private void configurePorts(Instance instance) {
        Direction facing = instance.getAttributeValue(StdAttr.FACING);
        Bounds bds = getOffsetBounds(instance.getAttributeSet());
        int d = Math.max(bds.getWidth(), bds.getHeight()) - 20;
        Location loc0 = Location.create(0, 0);
        Location loc1 = loc0.translate(facing.reverse(), 20 + d);
        Location loc2;
        if (instance.getAttributeValue(ATTR_CONTROL) == LEFT_HANDED) {
            loc2 = loc0.translate(facing.reverse(), 10 + d, 10);
        } else {
            loc2 = loc0.translate(facing.reverse(), 10 + d, -10);
        }

        Port[] ports = new Port[3];
        ports[0] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
        ports[1] = new Port(loc1.getX(), loc1.getY(), Port.INPUT, StdAttr.WIDTH);
View Full Code Here

            HashSet<Location> connLocs, ArrayList<SearchNode> connNodes,
            AvoidanceMap selAvoid) {
        Location cur = conn.getLocation();
        Location dest = cur.translate(dx, dy);
        if (selAvoid.get(cur) == null) {
            Direction preferred = conn.getDirection();
            if (preferred == null) {
                if (Math.abs(dx) > Math.abs(dy)) {
                    preferred = dx > 0 ? Direction.EAST : Direction.WEST;
                } else {
                    preferred = dy > 0 ? Direction.SOUTH : Direction.NORTH;
                }
            }

            connLocs.add(cur);
            connNodes.add(new SearchNode(conn, cur, preferred, dest));
        }

        for (Wire w : conn.getWirePath()) {
            for (Location loc : w) {
                if (selAvoid.get(loc) == null || loc.equals(dest)) {
                    boolean added = connLocs.add(loc);
                    if (added) {
                        Direction dir = null;
                        if (w.endsAt(loc)) {
                            if (w.isVertical()) {
                                int y0 = loc.getY();
                                int y1 = w.getOtherEnd(loc).getY();
                                dir = y0 < y1 ? Direction.NORTH : Direction.SOUTH;
View Full Code Here

            boolean added = visited.add(n);
            if (!added) {
                continue;
            }
            Location loc = n.getLocation();
            Direction dir = n.getDirection();
            int neighbors = 3;
            Object allowed = avoid.get(loc);
            if (allowed != null && n.isStart() && pathLocs.contains(loc)) {
                allowed = null;
            }
            if (allowed == ALLOW_NEITHER) {
                neighbors = 0;
            } else if (allowed == ALLOW_VERTICAL) {
                if (dir == null) {
                    dir = Direction.NORTH;
                    neighbors = 2;
                } else if (dir == Direction.NORTH || dir == Direction.SOUTH) {
                    neighbors = 1;
                } else {
                    neighbors = 0;
                }
            } else if (allowed == ALLOW_HORIZONTAL) {
                if (dir == null) {
                    dir = Direction.EAST;
                    neighbors = 2;
                } else if (dir == Direction.EAST || dir == Direction.WEST) {
                    neighbors = 1;
                } else {
                    neighbors = 0;
                }
            } else {
                if (dir == null) {
                    dir = Direction.NORTH;
                    neighbors = 4;
                } else {
                    neighbors = 3;
                }
            }
            for (int i = 0; i < neighbors; i++) {
                Direction oDir;
                switch (i) {
                case 0:
                    oDir = dir;
                    break;
                case 1:
View Full Code Here

    }

    private int getHeuristic() {
        Location cur = loc;
        Location dst = dest;
        Direction curDir = dir;
        int dx = dst.getX() - cur.getX();
        int dy = dst.getY() - cur.getY();
        int ret = -1;
        if (extendsWire) {
            ret = -1;
View Full Code Here

        return ret;
    }

    public SearchNode next(Direction moveDir, boolean crossing) {
        int newDist = dist;
        Direction connDir = conn.getDirection();
        Location nextLoc = loc.translate(moveDir, 10);
        boolean exWire = extendsWire && moveDir == connDir;
        if (exWire) {
            newDist += 9;
        } else {
View Full Code Here

            Instance pin, Map<Instance, AppearancePort> others) {
        // Determine which locations are being used in canvas, and look for
        // which instances facing the same way in layout
        Set<Location> usedLocs = new HashSet<Location>();
        List<Instance> sameWay = new ArrayList<Instance>();
        Direction facing = pin.getAttributeValue(StdAttr.FACING);
        for (Map.Entry<Instance, AppearancePort> entry : others.entrySet()) {
            Instance pin2 = entry.getKey();
            Location loc = entry.getValue().getLocation();
            usedLocs.add(loc);
            if (pin2.getAttributeValue(StdAttr.FACING) == facing) {
View Full Code Here

        state.setPort(0, Value.createKnown(width, value), 1);
    }

    @Override
    public Bounds getOffsetBounds(AttributeSet attrs) {
        Direction facing = attrs.getValue(StdAttr.FACING);
        BitWidth width = attrs.getValue(StdAttr.WIDTH);
        int chars = (width.getWidth() + 3) / 4;

        Bounds ret = null;
        if (facing == Direction.EAST) {
View Full Code Here

TOP

Related Classes of com.cburch.logisim.data.Direction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.