Exemple #1
0
 public String getOrientation(Cell cell) {
   if (cell.getType().equals(Cell.CELL_EMPTY) || cell.getType().equals(Cell.CELL_WALL)) {
     return "";
   }
   if (cell.getType().equals(Cell.CELL_LASER_END)) {
     if (cell.getLaserV() == Cell.N) {
       return String.valueOf(Cell.S);
     }
     if (cell.getLaserV() == Cell.S) {
       return String.valueOf(Cell.N);
     }
     if (cell.getLaserH() == Cell.E) {
       return String.valueOf(Cell.W);
     }
     if (cell.getLaserH() == Cell.W) {
       return String.valueOf(Cell.E);
     }
   }
   return String.valueOf(cell.getAngle());
 }
Exemple #2
0
  public void dropObject(DragDropEvent ddEvent) {
    Map<String, String> params =
        FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
    String ligne = getParam("ligne");
    String colonne = getParam("colonne");
    String left = params.get("class");
    String[] sClass = left.split(" ");
    int colTmp = -1;
    int ligneTmp = 0;
    int item = -1;
    String idTmp = "";
    for (String s : sClass) {
      if (StringUtils.startsWith(s, "colonne_")) {
        String c = s.replace("colonne_", "");
        colTmp = Integer.valueOf(c);
      }
      if (StringUtils.startsWith(s, "ligne_")) {
        String c = s.replace("ligne_", "");
        ligneTmp = Integer.valueOf(c);
      }
      if (StringUtils.startsWith(s, "id_")) {
        idTmp = s.replace("id_", "");
      }

      if (StringUtils.startsWith(s, "position_")) {
        String c = s.replace("position_", "");
        item = Integer.valueOf(c);
      }
    }
    int x = Integer.valueOf(ligne);
    int y = Integer.valueOf(colonne);
    String id;
    if (StringUtils.isEmpty(idTmp)) {
      id = params.get("dragId");
      id = id.replaceAll("FormContent:", "");
    } else {
      id = idTmp;
      if (item != -1) pioche.remove(item);
    }
    if (colTmp == -1) {
      Cell newCell = list.get(x).get(y);
      newCell.setType(id);
      newCell.setAngle(0);
    } else {
      Cell c = list.get(ligneTmp).get(colTmp);
      Cell newCell = list.get(x).get(y);
      newCell.setType(c.getType());
      newCell.setAngle(c.getAngle());
      c.setType(Cell.CELL_EMPTY);
      c.setAngle(-1);
    }
  }