Examples of CellCoord


Examples of org.gojul.fourinaline.model.GameModel.CellCoord

     * @return the coordinate of the cell which contains the chip if applicable,
     * null otherwise.
     */
    private synchronized CellCoord getChipIfOnlyOneInserted(final GameModel model)
    {
      CellCoord result = null;
      int nbCellsOccupied = 0;
     
      for (int i = 0; i < model.getRowCount() && nbCellsOccupied <= 1; i++)
      {
        for (int j = 0; j < model.getColCount() && nbCellsOccupied <= 1; j++)
        {
          if (model.getCell(i, j) != null)
          {
            if (nbCellsOccupied == 0)
            {
              result = new CellCoord(i, j);
            }
            else
            {
              result = null;
            }
View Full Code Here

Examples of org.gojul.fourinaline.model.GameModel.CellCoord

     * @return the coordinates of the last inserted chip, in case <code>model</code>
     * is the current game model plus one inserted chip.
     */
    private synchronized CellCoord getLastInsertedChip(final GameModel model)
    {
      CellCoord result = null;
     
      // In case the dimensions of model are not the same as the dimensions
      // of gameModel, returns null.
      if (model.getRowCount() != gameModel.getRowCount()
          || model.getColCount() != gameModel.getColCount())
        return result;
     
      // There must be only one different cell between model and gameModel
      // and this must be a newly played cell.
      for (int i = 0; i < model.getRowCount(); i++)
      {
        for (int j = 0; j < model.getColCount(); j++)
        {
          if (model.getCell(i, j) != null && !model.getCell(i, j).equals(gameModel.getCell(i, j)))
          {
            if (result == null)
              result = new CellCoord(i, j);
            else
            {
              // Here the new model is not a successor of the old one, so
              // we do not return any information.
              return null;
View Full Code Here

Examples of org.gojul.fourinaline.model.GameModel.CellCoord

      // which would lead to some very bad issues.
     
      if (model == null)
        throw new NullPointerException();
     
      CellCoord lastBeforeRefresh = lastInsertedCell;
     
      // We do not set up the last inserted cell coordinates
      // now as we do not want to have a circled element before
      // it is dropped.
      lastInsertedCell = null;
     
      CellCoord last = getLastInsertedChip(model);
     
      for (int i = 0, len1 = playerMarks.length; i < len1; i++)
      {
        for (int j = 0, len2 = playerMarks[i].length; j < len2; j++)
        {
          playerMarks[i][j] = model.getCell(i, j);
        }
      }
     
      int cellWidth = getCellWidth();
      int cellHeight = getCellHeight();
     
      // Play a small animation in order to drop chips.
      // if there's a drop to display.
      if (last != null)
      {
        displayAnimation(model, last);
       
        // We delete the circle of the last inserted cell when possible.
        if (lastBeforeRefresh != null)
        {
          paintImmediately(new Rectangle(lastBeforeRefresh.getColIndex() * cellWidth,
              lastBeforeRefresh.getRowIndex() * cellHeight,
              cellWidth, cellHeight));
        }
      }
     
      // Now that the animation is successful, we can copy
      // the parameters so that it is taken into account by
      // the paint() method.
      lastInsertedCell = last;
      gameModel = model;
     
      // OpenJDK speed improvement : we only paint the last inserted chip when
      // this is possible...
      if (last != null && gameModel != null && gameModel.getGameStatus().equals(GameStatus.CONTINUE_STATUS))
      {       
        paintImmediately(new Rectangle(last.getColIndex() * cellWidth, last.getRowIndex() * cellHeight,
            cellWidth, cellHeight));
      }
      else
      {
        repaint();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.