コード例 #1
0
  public void testMappedEObjectMetrics() throws IOException {
    UMLData umlData = new UMLData(2000);
    Resource leftUML = umlData.getLeftUML();

    final Metric<EObject> metric = new EObjectFullMetric();
    FastMap<EObject> fastMap =
        new FastMap<EObject>(3) {
          @Override
          protected double distance(EObject target1, EObject target2) {
            return metric.distance(target1, target2);
          }
        };

    TreeIterator<EObject> it = leftUML.getAllContents();
    while (it.hasNext()) {
      EObject object = it.next();
      fastMap.add(object);
    }
    ;

    Space<EObject> space = new TreeBackedSpace<EObject>();
    fastMap.map(true, space);

    List<double[]> coordinates = new ArrayList<double[]>();

    int count = 0;
    for (EObject object : space) {
      if (++count % 100 == 0) coordinates.add(space.getCoordinates(object));
    }

    checkNormalized(coordinates, EuclideanMetric.INSTANCE);
    checkSymmetric(coordinates, EuclideanMetric.INSTANCE);
  }
コード例 #2
0
ファイル: GameBoard.java プロジェクト: Theheck1/BoardGame
  /**
   * Loads spaces from a text file
   *
   * @param filepath Filepath of text file
   */
  public void loadGame(String filepath) {
    if (loaded) return;
    InputStream stream = this.getClass().getResourceAsStream("/space1.txt");

    Scanner in = null;
    try {
      in = new Scanner(stream);
      while (in.hasNextLine()) {
        String name = in.nextLine();
        String scoreModifier = in.nextLine();
        String goAgain = in.nextLine();
        String RGB = in.nextLine();
        String[] colors = RGB.split(",");
        Color color =
            new Color(
                Integer.parseInt(colors[0]),
                Integer.parseInt(colors[1]),
                Integer.parseInt(colors[2]));
        // System.out.println(color.toString());
        Space space =
            new Space(name, Integer.parseInt(scoreModifier), Boolean.parseBoolean(goAgain));
        space.setColor(color);
        addSpace(space);
      }

    } catch (Exception e) {
      System.out.println("Unable to read file.");

    } finally {
      in.close();
    }
  }
コード例 #3
0
  public void setUpGroups() {

    this.groups = game.getGroups();
    Color[] groupToColor = new Color[groups.length];
    for (int i = 0; i < groupToColor.length; i++) {
      groupToColor[i] = possibleColors[i % possibleColors.length];
    }

    for (int i = 0; i < groupToColor.length; i++) {
      Group[] conflictingGroups;
      conflictingGroups = conflicting(i, groupToColor);

      int noOfTimes = 0;

      while (conflictingGroups.length != 0) {
        int offset;
        if (noOfTimes > 5) offset = 3;
        else offset = 2;

        groupToColor[conflictingGroups[0].groupIDX] =
            possibleColors[(conflictingGroups[0].groupIDX + offset) % possibleColors.length];
        conflictingGroups = conflicting(i, groupToColor);
        noOfTimes++;
      }
    }

    for (int i = 0; i < groups.length; i++) {
      Space[] groupSpaces = groups[i].getSpaces();
      for (int j = 0; j < groupSpaces.length; j++) {
        Space current = groupSpaces[j];
        GUILogi5Space currentSpace = (GUILogi5Space) (spaces[current.getX()][current.getY()]);
        currentSpace.setColor(groupToColor[i]);
      }
    }
  }
コード例 #4
0
ファイル: TowerDefense.java プロジェクト: Rishabh2/apcs
  public static void main(String[] args) {
    World world = new World("defense");
    ArrayList<Enemy> enemies = new ArrayList<Enemy>();
    ArrayList<Tower> towers = new ArrayList<Tower>();
    ArrayList<Bullet> bullets = new ArrayList<Bullet>();
    while (true) {

      world.draw();

      for (Bullet bullet : bullets) {
        bullet.move(); // TODO
        bullet.draw(); // TODO
      }

      for (int i = 0; i < enemies.size(); i++) {
        Enemy enemy = enemies.get(i);
        enemy.move();
        enemy.draw();

        for (int j = 0; j < bullets.size(); j++) {
          Bullet bullet = bullets.get(j);
          if (bullet.isHitting(enemy)) {
            enemies.remove(i);
            bullets.remove(j);
            i--;
            break;
          }
        }
      }
      if (Window.mouse.clicked()) {
        int x = Window.mouse.getX() / world.getScale();
        int y = Window.mouse.getY() / world.getScale();

        Space space = world.getSpace(x, y);
        String color = "orange";
        int reload = 50;
        int range = world.getScale() * 5;

        if (space.getType() == world.GRASS && space.hasTower() == false) {
          Tower tower = new Tower(space, world, color, reload, range, null);
          tower.setComparator(new CloseComparator(tower));
          towers.add(tower);
        }
      }

      for (Tower tower : towers) {
        tower.draw(world.getScale() / 2); // TODO
        Bullet bullet = tower.fire(enemies);
        if (bullet != null) {
          bullets.add(bullet);
        }
      }

      Window.frame();

      if (Window.random(-40, 40) == 0) {
        enemies.add(new Enemy(10, 3, world));
      }
    }
  }
コード例 #5
0
 private void _buildExits() {
   for (String spaceName : _ini.keys("exits")) {
     String portalName = _ini.get("exits", spaceName);
     Space space = _spaces.get(spaceName);
     Portal portal = _portals.get(portalName);
     space.setPortal(portal);
   }
 }
コード例 #6
0
ファイル: MainWindow.java プロジェクト: fl4v/OpenComm-Group
 /** Look for a SHIFT key Press to begin drawing lasso, and selecting for private space */
 public void keyPressed() {
   if (key == CODED) { // Coded keys are ALT, CTRL, SHIFT, UP, DOWN etc....
     if (keyCode == SHIFT && !mainSpace.isCreatingPrivateSpace()) {
       mainSpace.beginPrivateSpaceSelection();
       mainSpace.selected = null;
       System.out.println("Selecting For Private Space....");
     }
   }
 }
コード例 #7
0
ファイル: User.java プロジェクト: praxiscomputing/Jtrac
 /**
  * when the passed space is null this has a special significance it will return roles that are
  * 'global'
  */
 public List<String> getRoleKeys(Space space) {
   List<String> roleKeys = new ArrayList<String>();
   for (UserSpaceRole usr : userSpaceRoles) {
     Space s = usr.getSpace();
     if (s == space || (s != null && s.equals(space))) {
       roleKeys.add(usr.getRoleKey());
     }
   }
   return roleKeys;
 }
コード例 #8
0
ファイル: NavMesh.java プロジェクト: davoodinator/StarMade
 /*     */ public Space findSpace(float x, float y) /*     */ {
   /*  70 */ for (int i = 0; i < this.spaces.size(); i++) {
     /*  71 */ Space space = getSpace(i);
     /*  72 */ if (space.contains(x, y)) {
       /*  73 */ return space;
       /*     */ }
     /*     */ }
   /*     */
   /*  77 */ return null;
   /*     */ }
コード例 #9
0
ファイル: GameBoard.java プロジェクト: Theheck1/BoardGame
 @Override
 public void run() {
   Color originalColor = spaceToBlink.getColor();
   Color blinkColor = (spaceToBlink.getScoreModifier() < 0) ? Color.RED : Color.GREEN;
   Graphics2D g2d = (Graphics2D) this.getGraphics();
   for (int i = 0; i < 5; i++) {
     g2d.setColor(blinkColor);
     g2d.fillRect(
         spaceToBlink.getPoint().x, spaceToBlink.getPoint().y, getSpaceWidth(), getSpaceHeight());
     for (GamePiece pce : gamePieces) pce.repaint();
     try {
       Thread.sleep(100);
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
     g2d.setColor(originalColor);
     g2d.fillRect(
         spaceToBlink.getPoint().x, spaceToBlink.getPoint().y, getSpaceWidth(), getSpaceHeight());
     for (GamePiece pce : gamePieces) pce.repaint();
   }
   Font font = new Font("Serif", Font.PLAIN, 20);
   g2d.setFont(font);
   g2d.setColor(Color.WHITE);
   g2d.drawString(
       spaceToBlink.getName(),
       spaceToBlink.getPoint().x,
       spaceToBlink.getPoint().y + (getSpaceHeight() / 2));
 }
コード例 #10
0
ファイル: TransientSpace.java プロジェクト: eMerchantPay/jPOS
 public static final LocalSpace getSpace(String spaceName) {
   String key = "jpos:space/" + spaceName;
   Object obj = getSpace().rdp(key);
   Space sp = getSpace();
   if (obj == null) {
     synchronized (TransientSpace.class) {
       obj = sp.rdp(key);
       if (obj == null) {
         obj = new TransientSpace();
         sp.out(key, obj);
       }
     }
   }
   return (LocalSpace) obj;
 }
コード例 #11
0
ファイル: Blueprint.java プロジェクト: joantune/fenix
 private void checkNewBluePrintDates(Space space) {
   Blueprint mostRecentBlueprint = space.getMostRecentBlueprint();
   if (mostRecentBlueprint != null
       && mostRecentBlueprint.getValidFrom().isEqual(new YearMonthDay())) {
     throw new DomainException("error.blueprint.validFrom.date.already.exists");
   }
 }
コード例 #12
0
ファイル: MainWindow.java プロジェクト: fl4v/OpenComm-Group
 /** Look for a SHIFT key release to ask for confirmation for creating private space */
 public void keyReleased() {
   if (key == CODED) { // Coded keys are ALT, CTRL, SHIFT, UP, DOWN etc....
     if (keyCode == SHIFT) {
       mainSpace.createNewConfirmBox();
     }
   }
 }
コード例 #13
0
ファイル: SpaceTest.java プロジェクト: ulrichgenick/hdc
 @Test
 public void delete() throws ModelException {
   DBCollection spaces = Database.getCollection("spaces");
   assertEquals(0, spaces.count());
   Space space = new Space();
   space._id = new ObjectId();
   space.name = "Test space";
   space.owner = new ObjectId();
   space.visualization = new ObjectId();
   space.order = 1;
   space.records = new HashSet<ObjectId>();
   Space.add(space);
   assertEquals(1, spaces.count());
   Space.delete(space.owner, space._id);
   assertEquals(0, spaces.count());
 }
コード例 #14
0
ファイル: User.java プロジェクト: praxiscomputing/Jtrac
 public boolean isGuestForSpace(Space space) {
   if (id == 0) {
     return true;
   }
   for (UserSpaceRole usr : getUserSpaceRolesBySpaceId(space.getId())) {
     if (usr.isGuest()) {
       return true;
     }
   }
   return false;
 }
コード例 #15
0
ファイル: MainWindow.java プロジェクト: fl4v/OpenComm-Group
  public void draw() {
    // background(255);
    mainSpace.draw(this);

    /*if (!((PrivateSpace)pspace1).isOpen() && !((PrivateSpace)pspace2).isOpen()) {
    	background(50);
    }
    else {
    	background(0);
    }*/
  }
コード例 #16
0
ファイル: NavMesh.java プロジェクト: davoodinator/StarMade
 /*     */ public NavPath findPath(float sx, float sy, float tx, float ty, boolean optimize)
       /*     */ {
   /*  91 */ Space source = findSpace(sx, sy);
   /*  92 */ Space target = findSpace(tx, ty);
   /*     */
   /*  94 */ if ((source == null) || (target == null)) {
     /*  95 */ return null;
     /*     */ }
   /*     */
   /*  98 */ for (int i = 0; i < this.spaces.size(); i++) {
     /*  99 */ ((Space) this.spaces.get(i)).clearCost();
     /*     */ }
   /* 101 */ target.fill(source, tx, ty, 0.0F);
   /* 102 */ if (target.getCost() == 3.4028235E+38F) {
     /* 103 */ return null;
     /*     */ }
   /* 105 */ if (source.getCost() == 3.4028235E+38F) {
     /* 106 */ return null;
     /*     */ }
   /*     */
   /* 109 */ NavPath path = new NavPath();
   /* 110 */ path.push(new Link(sx, sy, null));
   /* 111 */ if (source.pickLowestCost(target, path)) {
     /* 112 */ path.push(new Link(tx, ty, null));
     /* 113 */ if (optimize) {
       /* 114 */ optimize(path);
       /*     */ }
     /* 116 */ return path;
     /*     */ }
   /*     */
   /* 119 */ return null;
   /*     */ }
コード例 #17
0
ファイル: Blueprint.java プロジェクト: joantune/fenix
 private void refreshBlueprintsDates(Space space) {
   SortedSet<Blueprint> blueprints = new TreeSet<Blueprint>(space.getBlueprints());
   if (!blueprints.isEmpty() && blueprints.last() != this) {
     for (Iterator<Blueprint> iter = blueprints.iterator(); iter.hasNext(); ) {
       Blueprint blueprint = iter.next();
       if (blueprint == this) {
         Blueprint nextBlueprint = iter.next();
         nextBlueprint.updateValidFromDate(blueprint.getValidFrom());
         break;
       }
     }
   }
 }
コード例 #18
0
ファイル: ResourceObserver.java プロジェクト: f1ori-demo/yacy
  /** checks the resources and pauses crawls if necessary */
  public void resourceObserverJob() {
    MemoryControl.setDHTMbyte(getMinFreeMemory());

    normalizedDiskFree = getNormalizedDiskFree();
    normalizedMemoryFree = getNormalizedMemoryFree();

    if (normalizedDiskFree.compareTo(Space.HIGH) < 0
        || normalizedMemoryFree.compareTo(Space.HIGH) < 0) {

      if (normalizedDiskFree.compareTo(Space.HIGH) < 0) { // pause crawls
        if (!sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL)) {
          log.logInfo("pausing local crawls");
          sb.pauseCrawlJob(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);
        }
        if (!sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL)) {
          log.logInfo("pausing remote triggered crawls");
          sb.pauseCrawlJob(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);
        }
      }

      if ((normalizedDiskFree == Space.LOW || normalizedMemoryFree.compareTo(Space.HIGH) < 0)
          && sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW, false)) {
        log.logInfo("disabling index receive");
        sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, false);
        sb.peers.mySeed().setFlagAcceptRemoteIndex(false);
        sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_AUTODISABLED, true);
      }
    } else {
      if (sb.getConfigBool(
          SwitchboardConstants.INDEX_RECEIVE_AUTODISABLED, false)) { // we were wrong!
        log.logInfo("enabling index receive");
        sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true);
        sb.peers.mySeed().setFlagAcceptRemoteIndex(true);
        sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_AUTODISABLED, false);
      }
      log.logInfo("resources ok");
    }
  }
コード例 #19
0
 <T extends Composite> T parse(String stringText, Class<T> compositeClass)
     throws ParsingException, IllegalAccessException, InstantiationException {
   T type;
   try {
     type = compositeClass.newInstance();
     Class componentClass = componentMap.get(compositeClass);
     Matcher matcher = patterns.get(componentClass).matcher(stringText);
     while (matcher.find()) {
       if (componentClass == SentenceToken.class) {
         if (matcher.group().matches(patterns.get(Word.class).toString())) {
           type.add(new Word(matcher.group()));
         }
         if (matcher.group().matches(patterns.get(Numbers.class).toString())) {
           Numbers number = new Numbers();
           number.add(new Integer(matcher.group()));
           type.add(number);
         }
         if (matcher.group().matches(patterns.get(Punctuation.class).toString())) {
           Punctuation punctuation = new Punctuation();
           punctuation.add(matcher.group().charAt(0));
           type.add(punctuation);
         }
         if (matcher.group().matches(patterns.get(Space.class).toString())) {
           Space space = new Space();
           space.add(matcher.group().charAt(0));
           type.add(space);
         }
       } else {
         Component c = parse(matcher.group(), componentClass);
         type.add(c);
       }
     }
     return type;
   } catch (InstantiationException | IllegalAccessException ignored) {
     logger.error("Could not parse the elements of text ");
     throw new ParsingException("Could not parse the elements of text ");
   }
 }
コード例 #20
0
ファイル: SpaceTest.java プロジェクト: ulrichgenick/hdc
 @Test
 public void notExists() throws ModelException {
   DBCollection spaces = Database.getCollection("spaces");
   assertEquals(0, spaces.count());
   Space space = new Space();
   space._id = new ObjectId();
   space.name = "Test space";
   space.owner = new ObjectId();
   space.visualization = new ObjectId();
   space.order = 1;
   space.records = new HashSet<ObjectId>();
   Space.add(space);
   assertEquals(1, spaces.count());
   assertFalse(
       Space.exists(
           new ChainedMap<String, ObjectId>()
               .put("_id", new ObjectId())
               .put("owner", space.owner)
               .get()));
 }
コード例 #21
0
ファイル: Setup.java プロジェクト: robby35us/KnightmareChess
  /*
   * Sets the black pieces on the board
   */
  private static void placeBlackPieces(PlayerSet blackSet, Board board) {
    Space currentSpace = board.getSpace(Rank.Eight, File.A);
    Iterator<Piece> it = blackSet.iterator();

    // set the "first" row(Rank 8) of black pieces from left to right
    currentSpace.changePiece(it.next());
    for (int i = 0; i < 7; i++) {
      currentSpace = currentSpace.getSpaceRight();
      currentSpace.changePiece(it.next());
    }
    currentSpace = currentSpace.getSpaceBackward();

    // set the "second" row(Rank 7) of black pieces from right to left
    for (int i = 0; i < 8; i++) {
      currentSpace.changePiece(it.next());
      currentSpace = currentSpace.getSpaceLeft();
    }
  }
コード例 #22
0
ファイル: Setup.java プロジェクト: robby35us/KnightmareChess
  /*
   * Sets the white Pieces on the board
   */
  private static void placeWhitePieces(PlayerSet whiteSet, Board board) {
    Space currentSpace = board.getSpace(Rank.One, File.A);
    Iterator<Piece> it = whiteSet.iterator();

    // set the "first" row (Rank 1) of white pieces left to right
    currentSpace.changePiece(it.next());
    for (int i = 0; i < 7; i++) {
      currentSpace = currentSpace.getSpaceRight();
      currentSpace.changePiece(it.next());
    }
    currentSpace = currentSpace.getSpaceForward();

    // set the "second" row ("Rank 2) of white pieces from right to left
    for (int i = 0; i < 8; i++) {
      currentSpace.changePiece(it.next());
      currentSpace = currentSpace.getSpaceLeft();
    }
  }
コード例 #23
0
  /** Parse the email as confluence notification. If the email doesn't match, return null. */
  public static PageNotification parse(MimeMessage msg) throws MessagingException, IOException {
    Space sp = Space.find(msg);
    if (sp == null) return null;

    String pageTitle = msg.getSubject().substring(sp.subjectPrefix.length());

    List<String> contents = Arrays.asList(msg.getContent().toString().split("\n"));
    if (contents.size() < 10) return null; // too short to be real

    /*
                The portion of the email body we are looking for is this:

    <div class="email">
        <h2><a href="https://wiki.jenkins-ci.org/display/JENKINS/Obat+Penggugur+Kandungan+Ampuh+085727827778">Obat Penggugur Kandungan Ampuh 085727827778</a></h2>
        <h4>Page  <b>added</b> by             <a href="https://wiki.jenkins-ci.org/display/~obatfarmasi">gilang kurniawan</a>

             */
    for (int i = 0; i < contents.size(); i++) {
      if (contents.get(i).trim().equals("<div class=\"email\">")) {
        if (i + 2 >= contents.size()) return null; // expecting two more lines to follow

        String line2 = contents.get(i + 2);
        Matcher m = ACTION_PATTERN.matcher(line2);
        if (!m.find()) return null; // expecting to find action
        String action = m.group(1);

        m = USERID_PATTERN.matcher(line2);
        if (!m.find()) return null; // expecting to find user ID
        String userId = m.group(1);

        return new PageNotification(action, pageTitle, userId, sp.id);
      }
    }

    return null;
  }
コード例 #24
0
 private Group[] conflicting(int ish, Color[] groupToColor) {
   ArrayList<Group> touchers = new ArrayList<Group>();
   Group g = groups[ish];
   Space[] gSpaces = g.getSpaces();
   for (int i = 0; i < gSpaces.length; i++) {
     Space current = gSpaces[i];
     for (int k = -1; k < 2; k++) {
       int curSX = current.getX();
       int curSY = current.getY();
       curSX += k;
       curSY += k;
       if (curSX < 0) {
         curSX = 0;
       }
       if (curSX > spaces.length - 1) {
         curSX = spaces.length - 1;
       }
       if (curSY < 0) {
         curSY = 0;
       }
       if (curSY > spaces.length - 1) {
         curSY = spaces.length - 1;
       }
       Space[] comparison = new Space[2];
       comparison[0] = game.getSpaceAt(curSX, current.getY());
       comparison[1] = game.getSpaceAt(current.getX(), curSY);
       int mod = groupToColor.length;
       for (int j = 0; j < comparison.length; j++) {
         if ((comparison[j].getGroup().groupIDX != g.groupIDX)
             && groupToColor[comparison[j].getGroup().groupIDX % mod]
                 == groupToColor[current.getGroup().groupIDX % mod]
             && !touchers.contains(comparison[j].getGroup())) {
           touchers.add(comparison[j].getGroup());
         }
       }
     }
   }
   return touchers.toArray(new Group[touchers.size()]);
 }
コード例 #25
0
ファイル: Wiki.java プロジェクト: xwiki-contrib/retired
 public Document getDocument(String spaceName, String docName) {
   Space space = getSpace(spaceName);
   return space != null ? space.getDocument(docName) : null;
 }
コード例 #26
0
ファイル: User.java プロジェクト: praxiscomputing/Jtrac
 public Map<Integer, String> getPermittedTransitions(Space space, int status) {
   return space.getMetadata().getPermittedTransitions(getRoleKeys(space), status);
 }
コード例 #27
0
ファイル: User.java プロジェクト: praxiscomputing/Jtrac
 public List<Field> getEditableFieldList(Space space, int status) {
   return space.getMetadata().getEditableFields(getRoleKeys(space), status);
 }
コード例 #28
0
 /** Check if the number of neighbors is > 3 or < 2 and die if so. Die = remove from the space. */
 public void step() {
   int numNeighbors = space.getNumNeighbors(x, y);
   if (numNeighbors > 3 || numNeighbors < 2) {
     space.remove(this);
   }
 }
コード例 #29
0
ファイル: GameBoard.java プロジェクト: Theheck1/BoardGame
 public Point getSpaceLocation(Space space) {
   for (Space s : spaceList) {
     if (s.equals(space)) return s.getPoint();
   }
   return new Point(0, 0);
 }
コード例 #30
0
public class Boundary {
  private float SPACE_BOUNDARY_X = Global.to_pixels(Space.instance().half_size_x);
  private float SPACE_BOUNDARY_Y = Global.to_pixels(Space.instance().half_size_y);
  private float BOUNDARY_SIZE = Global.to_pixels(5f);
  //  Boundary, made up of four meshes.
  // p1  ___________________ p2
  // p4 |_________1_________|p3
  //   | |p11		     p5| |
  //   |4|			   |2|
  // p8 |_|p12__________p7|_|p6
  // p10|_________3_________|p9

  private Mesh[] meshes = new Mesh[4];

  public Boundary() {
    Vector2 point_1 =
        new Vector2(-SPACE_BOUNDARY_X - BOUNDARY_SIZE, SPACE_BOUNDARY_Y + BOUNDARY_SIZE);

    Vector2 point_2 =
        new Vector2(SPACE_BOUNDARY_X + BOUNDARY_SIZE, SPACE_BOUNDARY_Y + BOUNDARY_SIZE);

    Vector2 point_3 = new Vector2(SPACE_BOUNDARY_X + BOUNDARY_SIZE, SPACE_BOUNDARY_Y);

    Vector2 point_4 = new Vector2(-SPACE_BOUNDARY_X - BOUNDARY_SIZE, SPACE_BOUNDARY_Y);

    Vector2 point_5 = new Vector2(SPACE_BOUNDARY_X, SPACE_BOUNDARY_Y);

    Vector2 point_6 = new Vector2(SPACE_BOUNDARY_X + BOUNDARY_SIZE, -SPACE_BOUNDARY_Y);

    Vector2 point_7 = new Vector2(SPACE_BOUNDARY_X, -SPACE_BOUNDARY_Y);

    Vector2 point_8 = new Vector2(-SPACE_BOUNDARY_X - BOUNDARY_SIZE, -SPACE_BOUNDARY_Y);

    Vector2 point_9 =
        new Vector2(SPACE_BOUNDARY_X + BOUNDARY_SIZE, -SPACE_BOUNDARY_Y - BOUNDARY_SIZE);

    Vector2 point_10 =
        new Vector2(-SPACE_BOUNDARY_X - BOUNDARY_SIZE, -SPACE_BOUNDARY_Y - BOUNDARY_SIZE);

    Vector2 point_11 = new Vector2(-SPACE_BOUNDARY_X, SPACE_BOUNDARY_Y);

    Vector2 point_12 = new Vector2(-SPACE_BOUNDARY_X, -SPACE_BOUNDARY_Y);

    float border_colour = Color.toFloatBits(255, 0, 0, 255);

    meshes[0] =
        MeshFactory.square(
            point_1,
            border_colour,
            point_2,
            border_colour,
            point_3,
            border_colour,
            point_4,
            border_colour);

    meshes[1] =
        MeshFactory.square(
            point_5,
            border_colour,
            point_3,
            border_colour,
            point_6,
            border_colour,
            point_7,
            border_colour);

    meshes[2] =
        MeshFactory.square(
            point_8,
            border_colour,
            point_6,
            border_colour,
            point_9,
            border_colour,
            point_10,
            border_colour);

    meshes[3] =
        MeshFactory.square(
            point_4,
            border_colour,
            point_11,
            border_colour,
            point_12,
            border_colour,
            point_8,
            border_colour);
  }

  public void render() {
    for (Mesh mesh : meshes) {
      mesh.render(GL10.GL_TRIANGLE_STRIP, 0, 4);
    }
  }

  public boolean update(Ship ship) {
    boolean handled = true;

    // Force a direction on the ship if they have gone beyond the bounds of space.
    if (Global.to_pixels(ship.get_body().getPosition().x) < -SPACE_BOUNDARY_X) {
      ship.force_turn(Global.Dir.Right);
    } else if (Global.to_pixels(ship.get_body().getPosition().x) > SPACE_BOUNDARY_X) {
      ship.force_turn(Global.Dir.Left);
    } else if (Global.to_pixels(ship.get_body().getPosition().y) > SPACE_BOUNDARY_Y) {
      ship.force_turn(Global.Dir.Down);
    } else if (Global.to_pixels(ship.get_body().getPosition().y) < -SPACE_BOUNDARY_Y) {
      ship.force_turn(Global.Dir.Up);
    } else {
      handled = false;
    }

    Console.write_line("Boundary Controls it", handled);

    return handled;
  }

  public boolean contains(SpaceBody body) {
    return ((Math.abs(Global.to_pixels(body.get_body().getPosition().x)) <= SPACE_BOUNDARY_X)
        && (Math.abs(Global.to_pixels(body.get_body().getPosition().y)) <= SPACE_BOUNDARY_Y));
  }
}