コード例 #1
0
  /**
   * Set the scroll position.
   *
   * @param x coordinate of upper left corner.
   * @param y coordinate of upper left corner.
   */
  public void setScrollPosition(int x, int y) {
    final DjVuImage image = getImage();
    if ((image != null) && ((x != scrollPosition.x) || (y != scrollPosition.y))) {
      final Dimension imageSize = image.getSize();
      final Dimension viewportSize = getViewportSize();
      x = Math.max(0, Math.min(imageSize.width - viewportSize.width, x));
      y = Math.max(0, Math.min(imageSize.height - viewportSize.height, y));

      if ((x != scrollPosition.x) || (y != scrollPosition.y)) {
        scrollPosition.setLocation(x, y);
        updateScrollbars();
        repaint(50L);
      }
    }
  }
コード例 #2
0
ファイル: ShopGame.java プロジェクト: Wissamkahi/Shop-Game
 /*Creates the equipment in all states to initiate the game */
 private void fillStates(int sAvail, int sRent, int sShop) {
   int[] statesSizes = {sAvail, sRent, sShop};
   int s = 1;
   for (int stateSize : statesSizes) {
     for (int t = 1; t <= TYPES; t++) {
       for (int i = 1; i <= stateSize; i++) {
         Equipment e = new Equipment();
         e.state = s;
         e.type = t;
         int sMax =
             Math.max(
                 s - 2, 0); /*formula to make sure identifiers resume counting and stay unique */
         int sMin =
             Math.min(
                 s - 1, 1); /*formula to make sure identifiers resume counting and stay unique */
         e.ident = i + (sMin) * sAvail + (sMax) * sRent;
         e.c = equipColor(e.type);
         switch (s) {
           case 1:
             availEquipment.add(e);
             break;
           case 2:
             rentEquipment.add(e);
             break;
           case 3:
             shopEquipment.add(e);
             break;
         }
       }
     }
     s++;
   }
   computeInitialTimes();
   assignShapes();
 }
コード例 #3
0
ファイル: ListFrame.java プロジェクト: rohanagarwal/sticigui
 public void setList(String[][] text) {
   for (int i = 0; i < Math.min(nLists, text.length); i++) {
     list[i].clear();
     for (int j = 0; j < text[i].length; j++) {
       list[i].addItem(text[i][j]);
     }
   }
 }
コード例 #4
0
ファイル: Graph2D.java プロジェクト: corywalker/simuconomy
  /**
   * Get the Minimum Y value of all attached DataSets.
   *
   * @return The minimum value
   */
  public double getYmin() {
    DataSet d;
    double min = 0.0;

    if (dataset == null | dataset.isEmpty()) return min;
    for (int i = 0; i < dataset.size(); i++) {
      d = ((DataSet) dataset.elementAt(i));
      if (i == 0) min = d.getYmin();
      else min = Math.min(min, d.getYmin());
    }

    return min;
  }
コード例 #5
0
  void animate() {
    dim = getSize();
    size = (int) (Math.min(dim.height, dim.width) / 2.2);
    timer.tell_time();
    if (timer.time_diff == 0) return; // not enought time has passed, dont animate-crach fix
    dragged_speed = dragged_vec.sub(last_dragged_vec).div(timer.time_diff);
    last_dragged_vec = dragged_vec;
    if (dragged_ball != -1) {
      balls.get2(dragged_ball).pos = dragged_vec.add(find_offset).trim(-1, 1);
      balls.get2(dragged_ball).speed = dragged_speed;
    }

    balls = new WorldAnimate().calc_new_frame(balls, springs, RADIUS, timer);
  }
コード例 #6
0
ファイル: ListFrame.java プロジェクト: rohanagarwal/sticigui
 public ListFrame(String title, int[] row, int[] col, Applet ma, boolean multiple, Font ft) {
   super();
   myApplet = ma;
   this.setTitle(title);
   this.nLists = Math.min(row.length, col.length);
   setLayout(new BorderLayout());
   panel = new Panel();
   panel.setLayout(new BorderLayout());
   list = new List[nLists];
   for (int i = 0; i < nLists; i++) {
     list[i] = new List(row[i], multiple);
     list[i].setFont(ft);
   }
   add("North", list[0]);
   panel.add("Center", list[1]);
   add("Center", panel);
   this.setResizable(true);
   this.resize(minimumSize);
   selectedIndices = new int[nLists][];
 }
コード例 #7
0
ファイル: ListFrame.java プロジェクト: rohanagarwal/sticigui
 public void setFont(Font[] f) {
   for (int i = 0; i < Math.min(nLists, f.length); i++) {
     list[i].setFont(f[i]);
   }
 }
コード例 #8
0
ファイル: ListFrame.java プロジェクト: rohanagarwal/sticigui
 public void setMultipleSelections(boolean[] b) {
   for (int i = 0; i < Math.min(b.length, list.length); i++) {
     list[i].setMultipleSelections(b[i]);
   }
 }
コード例 #9
0
 double trim(double x, double min_value, double max_value) {
   return Math.min(Math.max(x, min_value), max_value);
 }
コード例 #10
0
 void tell_time() {
   double time = system_time() - epoch_time;
   time_diff = Math.min(time - cur_time, .05);
   cur_time = time;
 }