Пример #1
0
  /*
   * getWall() - Environment check. Checks both the currently active windows
   * and the sides of the screen. Returns the border if on one. Controls the
   * current Wall attribute of each mascot.
   */
  public Border getWall(boolean ignoreSeparator) {
    // Don't let the mascot hold onto window walls when within 64px of
    // the top of the screen.
    if (mascot.getAnchor().getY() <= getWorkArea().getTop() + 64) {
      Point p = mascot.getAnchor();
      if (mascot.onBorder()) {
        p.setLocation(p.getX() + 1, p.getY());
        mascot.setAnchor(p);
      }
      return NotOnBorder.INSTANCE;
    }
    if (mascot.isLookRight()) {
      if (getIE().onLeft(mascot.getAnchor())) {
        Wall w = getIE().getLeft(mascot.getAnchor());
        if (!checkLayering(w.getArea())) {
          mascot.setCurW(null);
          return NotOnVisibleBorder.INSTANCE;
        }
        mascot.setCurW(w);
        return w;
      }

      if (getWorkArea().getRightBorder().isOn(mascot.getAnchor())) {
        // if ( !ignoreSeparator || isScreenLeftRight() ) {
        if (isScreenLeftRight(ignoreSeparator)) {
          mascot.setCurW(null);
          return getWorkArea().getRightBorder();
        }
      }

    } else {
      if (getIE().onRight(mascot.getAnchor())) {
        Wall w = getIE().getRight(mascot.getAnchor());
        if (!checkLayering(w.getArea())) {
          mascot.setCurW(null);
          return NotOnVisibleBorder.INSTANCE;
        }
        mascot.setCurW(w);
        return w;
      }

      if (getWorkArea().getLeftBorder().isOn(mascot.getAnchor())) {
        // if ( !ignoreSeparator ||isScreenLeftRight() ) {
        if (isScreenLeftRight(ignoreSeparator)) {
          mascot.setCurW(null);
          return getWorkArea().getLeftBorder();
        }
      }
    }
    mascot.setCurW(null);
    return NotOnBorder.INSTANCE;
  }
Пример #2
0
  /**
   * マスコットを含むスクリーンを取得する
   *
   * @return
   */
  public Area getWorkArea() {
    if (numScreens == 1) {
      if (currentWorkArea == null) {
        currentWorkArea = impl.getWorkArea();
      }
      return currentWorkArea;
    }

    // if ( currentWorkArea!=null ) {
    // NOTE Windows マルチモニタ対応 Windowsのワークエリアはメインのスクリーンより小さい。
    // 現在のスクリーンがワークエリアを含んでおり、かつマスコットがワークエリアに含まれているならばワークエリアを優先する。
    // if ( currentWorkArea!=impl.getWorkArea() &&
    // currentWorkArea.toRectangle().contains(impl.getWorkArea().toRectangle()) ) {
    // if (impl.getWorkArea().contains(mascot.getAnchor().x, mascot.getAnchor().y)) {
    // currentWorkArea = impl.getWorkArea();
    // return currentWorkArea;
    // }
    // }

    // NOTE マルチモニタ対応 マスコットが複数のモニタに同時に含まれる場合があるが、
    // その場合は現在のモニタを優先する
    // if ( currentWorkArea.contains(mascot.getAnchor().x, mascot.getAnchor().y) ) {
    // return currentWorkArea;
    // }
    // }

    // まずワークエリアに含まれているか調べる
    // if (impl.getWorkArea().contains(mascot.getAnchor().x, mascot.getAnchor().y)) {
    // currentWorkArea = impl.getWorkArea();
    // return currentWorkArea;
    // }

    // 各モニタに含まれているか調べる
    if (currentWorkArea != null) {
      if (currentWorkArea.getTopBorder().isOn(mascot.getAnchor())) {
        return currentWorkArea;
      }
    }
    int cnt = 0;
    Area a = new Area();
    for (Area area : impl.getScreens()) {
      if (area.contains(mascot.getAnchor().x, mascot.getAnchor().y)) {
        cnt++;
        a = area;
      }
    }
    if (cnt == 1) {
      currentWorkArea = a;
      return currentWorkArea;
    } else if (cnt == 2) {
      Iterator<Area> iter = impl.getScreens().iterator();
      Area temp = iter.next();
      if (!mascot.isLookRight()) {
        currentWorkArea = temp;
        return currentWorkArea;
      } else {
        currentWorkArea = iter.next();
        return currentWorkArea;
      }
    }

    if (impl.getScreens().iterator().hasNext()) {
      currentWorkArea = impl.getScreens().iterator().next();
      return currentWorkArea;
    }

    currentWorkArea = impl.getWorkArea();
    return currentWorkArea;
  }