Пример #1
0
  /*
   * (non-Javadoc)
   *
   * @see dao.MapDAO#addMap(components.RoomMap)
   */
  @Override
  public void addMap(RoomMap newMap) {
    // TODO find the index that doesn't exist and assign it to the map before storing it
    int newMapId = 0;
    int listSize = allMaps.size();
    int highestId = 0;
    for (int i = 0; i < listSize; i++) {
      if (allMaps.get(i).getId() > highestId) {
        highestId = allMaps.get(i).getId();
      }
    }
    newMapId = highestId + 1;
    newMap.setId(newMapId);
    allMaps.add(newMap);

    // send the single map to the server
    uploadMapToServer(newMap);
  }
Пример #2
0
  /*
   * (non-Javadoc)
   *
   * @see dao.MapDAO#getAllMaps()
   */
  @Override
  public List<RoomMap> getAllMaps() {

    if (allMaps != null) {
      return allMaps;
    } else {
      allMaps = new ArrayList<RoomMap>();
    }

    // sample maps initialization values
    RoomMap map = null;
    BufferedImage image = null;
    double roomWidth = 0.0;
    double roomHeight = 0.0;
    String title = "";
    ArrayList<Receiver> receivers = null;

    // add sample map, id 0
    String path1 = "images/room_4m_6m.png";
    image = (BufferedImage) Utilities.loadImage(path1);
    title = "Test Room";
    roomWidth = 4.0;
    roomHeight = 6.0;
    receivers = new ArrayList<Receiver>();
    receivers.add(new Receiver(0, 0.0, 0.0, 45.0, true));
    receivers.add(new Receiver(1, 4.0, 0.0, 135.0, true));
    receivers.add(new Receiver(2, 4.0, 6.0, 225.0, true));
    receivers.add(new Receiver(3, 0.0, 6.0, 315.0, true));
    map = new RoomMap(image, title, receivers);
    map.setId(0);
    map.setWidthInMeters(roomWidth);
    map.setHeightInMeters(roomHeight);
    map.setLowerLeftMarkerOffsetXInPixels(0);
    map.setLowerLeftMarkerOffsetYInPixels(460);
    map.setUpperRightMarkerOffsetXInPixels(309);
    map.setUpperRightMarkerOffsetYInPixels(0);
    map.setRatioWidth(75.5);
    map.setRatioHeight(75.5);
    map.setPath(path1);
    allMaps.add(map);

    // add sample map, id 1
    String path2 = "images/test_room_fifth_floor.png";
    image = (BufferedImage) Utilities.loadImage(path2);
    title = "Room 501";
    roomWidth = 6.0;
    roomHeight = 6.0;
    receivers = new ArrayList<Receiver>();
    receivers.add(new Receiver(0, 0.0, 6.0, 315.0, true));
    receivers.add(new Receiver(1, 2.0, 6.0, 270.0, true));
    receivers.add(new Receiver(2, 6.0, 6.0, 225.0, true));
    receivers.add(new Receiver(3, 0.0, 2.45, 0.0, true));
    receivers.add(new Receiver(4, 6.0, 2.45, 180.0, true));
    receivers.add(new Receiver(6, 6.0, 0.0, 135.0, true));
    receivers.add(new Receiver(9, 3.60, 2.0, 270.0, true));
    map = new RoomMap(image, title, receivers);
    map.setId(1);
    map.setWidthInMeters(roomWidth);
    map.setHeightInMeters(roomHeight);
    map.setLowerLeftMarkerOffsetXInPixels(0);
    map.setLowerLeftMarkerOffsetYInPixels(538);
    map.setUpperRightMarkerOffsetXInPixels(538);
    map.setUpperRightMarkerOffsetYInPixels(0);
    map.setRatioWidth(89.67);
    map.setRatioHeight(89.67);
    map.setPath(path2);
    allMaps.add(map);

    // add sample map, id 2
    String path3 = "images/room_4m_6m.png";
    image = (BufferedImage) Utilities.loadImage(path3);
    title = "Room 481";
    roomWidth = 5.0;
    roomHeight = 8.30;
    receivers = new ArrayList<Receiver>();
    receivers.add(new Receiver(6, 0.7, 0.0, 90.0, true));
    receivers.add(new Receiver(1, 5.0, 0.65, 135.0, true));
    receivers.add(new Receiver(2, 5.0, 4.5, 180.0, true));
    receivers.add(new Receiver(3, 0.0, 2.0, 0.0, true));
    receivers.add(new Receiver(4, 0.0, 7.8, 315.0, true));
    receivers.add(new Receiver(0, 2.5, 8.3, 270.0, true));
    receivers.add(new Receiver(9, 4.80, 8.3, 225.0, true));
    map = new RoomMap(image, title, receivers);
    map.setId(2);
    map.setWidthInMeters(roomWidth);
    map.setHeightInMeters(roomHeight);
    map.setLowerLeftMarkerOffsetXInPixels(0);
    map.setLowerLeftMarkerOffsetYInPixels(460);
    map.setUpperRightMarkerOffsetXInPixels(309);
    map.setUpperRightMarkerOffsetYInPixels(0);
    map.setRatioWidth(61.80);
    map.setRatioHeight(55.42);
    map.setPath(path3);
    allMaps.add(map);

    return allMaps;
  }