Package com.cburch.logisim.data

Examples of com.cburch.logisim.data.Direction


      updatePorts(instance);
    }
  }

  private void updatePorts(Instance instance) {
    Direction facing = instance.getAttributeValue(StdAttr.FACING);
    BitWidth data = instance.getAttributeValue(StdAttr.WIDTH);
    BitWidth group = instance.getAttributeValue(GROUP_ATTR);
    int groups = (data.getWidth() + group.getWidth() - 1) / group.getWidth() - 1;
    int selectBits = 1;
    if (groups > 0) {
View Full Code Here


    painter.drawLabel();
  }

  private void paintBase(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    Direction facing = painter.getAttributeValue(StdAttr.FACING);
    Location loc = painter.getLocation();
    int x = loc.getX();
    int y = loc.getY();
    g.translate(x, y);
    double rotate = 0.0;
    if (facing != null && facing != Direction.EAST && g instanceof Graphics2D) {
      rotate = -facing.toRadians();
      ((Graphics2D) g).rotate(rotate);
    }
   
    Object shape = painter.getGateShape();
    if (shape == AppPreferences.SHAPE_RECTANGULAR) {
View Full Code Here

  }

  @Override
  public void paintInstance(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    Direction facing = painter.getAttributeValue(StdAttr.FACING);

    Plexers.drawTrapezoid(g, painter.getBounds(), facing, 9);
    Bounds bds = painter.getBounds();
    g.setColor(Color.BLACK);
    GraphicsUtil.drawCenteredText(g, "Sel",
View Full Code Here

    });
  }

  @Override
  public Bounds getOffsetBounds(AttributeSet attrs) {
    Direction facing = attrs.getValue(StdAttr.FACING);
    if (facing == Direction.SOUTH) return Bounds.create(-9, -20, 18, 20);
    if (facing == Direction.NORTH) return Bounds.create(-9, 0, 18, 20);
    if (facing == Direction.WEST) return Bounds.create(0, -9, 20, 18);
    return Bounds.create(-20, -9, 20, 18);
  }
View Full Code Here

      NotGate.configureLabel(instance, false, null);
    }
  }
 
  private void configurePorts(Instance instance) {
    Direction facing = instance.getAttributeValue(StdAttr.FACING);

    Port[] ports = new Port[2];
    ports[0] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
    Location out = Location.create(0, 0).translate(facing, -20);
    ports[1] = new Port(out.getX(), out.getY(), Port.INPUT, StdAttr.WIDTH);
View Full Code Here

    painter.drawPorts();
    painter.drawLabel();
  }

  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];
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

 
  static void drawLegacy(ComponentDrawContext context, SplitterAttributes attrs,
      Location origin) {
    Graphics g = context.getGraphics();
    CircuitState state = context.getCircuitState();
    Direction facing = attrs.facing;
    int fanout = attrs.fanout;
    SplitterParameters parms = attrs.getParameters();
   
    g.setColor(Color.BLACK);
    int x0 = origin.getX();
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

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.