Пример #1
0
  Table(BeerCell controller) {
    this.controller = controller;

    // Work out where all of the stacks should go
    // 5% margins
    marginLeft = (int) (width * .05);
    marginRight = (int) (width * .05);
    marginTop = (int) (height * .05);
    marginBottom = (int) (height * .05);

    // Other Spacings
    hSpacingPlay = (int) (width * .03);
    hSpacingCell = (int) (width * .01);
    hSpacingHome = (int) (width * .01);
    vSpacing = (int) (height * .05);
    // cSpacing = (int) (width * .10);

    // The rest of the space can be used for stacks
    stackWidth = ((width - (marginLeft + marginRight + (hSpacingPlay * 7))) / 8);
    cardHeight = (int) (stackWidth * 1.33);

    //		// Create the stacks, calculating their base screen position as we go along.
    //		int playStackTopMargin = marginTop + cardHeight + vSpacing;
    //		for (int i=0; i < play.length; i++) {
    //			PlayStack theStack = new PlayStack((marginLeft + ((stackWidth + hSpacingPlay) * i)),
    // playStackTopMargin, stackWidth, (height - playStackTopMargin - marginBottom));
    //			theStack.setCardHeight(cardHeight);
    //			play[i] = theStack;
    //
    //		}
    //		for (int i=0; i < cell.length; i++) {
    //			cell[i] = new CellStack((marginLeft + ((stackWidth + hSpacingCell) * i)), marginTop,
    // stackWidth, cardHeight);
    //		}
    //		for (int i=0; i < home.length; i++) {
    //			Coordinate startingPoint = new Coordinate(width - (marginRight + ((stackWidth +
    // hSpacingHome) * home.length)), marginTop);
    //			home[i] = new HomeStack(startingPoint.getX() + ((stackWidth + hSpacingHome) * i),
    // startingPoint.getY(), stackWidth, cardHeight);
    //		}

    // Create the stacks, calculating their base screen position as we go along.
    int playStackTopMargin = marginTop + cardHeight + vSpacing;
    for (int i = 0; i < stacks.length; i++) {
      if (i < PLAYSTACKLENGTH) { // Play stacks
        PlayStack theStack =
            new PlayStack(
                (marginLeft + ((stackWidth + hSpacingPlay) * i)),
                playStackTopMargin,
                stackWidth,
                (height - playStackTopMargin - marginBottom));
        theStack.setCardHeight(cardHeight);
        stacks[i] = theStack;
      } else if ((i >= PLAYSTACKLENGTH) && (i < PLAYSTACKLENGTH + CELLSTACKLENGTH)) { // Cell stacks
        stacks[i] =
            new CellStack(
                (marginLeft + ((stackWidth + hSpacingCell) * (i - PLAYSTACKLENGTH))),
                marginTop,
                stackWidth,
                cardHeight);
      } else { // Home Stacks
        Coordinate startingPoint =
            new Coordinate(width - (marginRight + ((stackWidth + hSpacingHome) * 4)), marginTop);
        stacks[i] =
            new HomeStack(
                startingPoint.getX()
                    + ((stackWidth + hSpacingHome) * (i - PLAYSTACKLENGTH - CELLSTACKLENGTH)),
                startingPoint.getY(),
                stackWidth,
                cardHeight);
      }
    }

    populatePlayArea(new Deck(stackWidth, cardHeight));

    // Start the cursor off at play[0]
    cursor = new Cursor(stacks[cursorLocation]);
    cursor.setOffset(stackWidth / 2, cardHeight / 2);

    timerStrip =
        new TimerStrip(this, 0, this.getHeight() - marginBottom, this.getWidth(), this.getHeight());
  }