示例#1
0
文件: CardGrid.java 项目: poixen/mage
 @Override
 public int compare(MageCard o1, MageCard o2) {
   int val = o1.getOriginal().getColor().compareTo(o2.getOriginal().getColor());
   if (val == 0) {
     return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
   } else {
     return val;
   }
 }
示例#2
0
文件: CardGrid.java 项目: poixen/mage
 @Override
 public int compare(MageCard o1, MageCard o2) {
   int val =
       Integer.valueOf(o1.getOriginal().getConvertedManaCost())
           .compareTo(Integer.valueOf(o2.getOriginal().getConvertedManaCost()));
   if (val == 0) {
     return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
   } else {
     return val;
   }
 }
示例#3
0
文件: CardGrid.java 项目: poixen/mage
 @Override
 public int compare(MageCard o1, MageCard o2) {
   int val =
       CardUtil.getColorIdentitySortValue(
               o1.getOriginal().getManaCost(),
               o1.getOriginal().getColor(),
               o1.getOriginal().getRules())
           - CardUtil.getColorIdentitySortValue(
               o2.getOriginal().getManaCost(),
               o2.getOriginal().getColor(),
               o2.getOriginal().getRules());
   if (val == 0) {
     return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
   } else {
     return val;
   }
 }
示例#4
0
文件: CardGrid.java 项目: poixen/mage
 @Override
 public int compare(MageCard o1, MageCard o2) {
   return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
 }
示例#5
0
文件: CardGrid.java 项目: poixen/mage
 @Override
 public void drawCards(SortSetting sortSetting) {
   int maxWidth = this.getParent().getWidth();
   int cardVerticalOffset = GUISizeHelper.editorCardOffsetSize;
   int numColumns = maxWidth / cardDimension.width;
   int curColumn = 0;
   int curRow = 0;
   if (cards.size() > 0) {
     Rectangle rectangle = new Rectangle(cardDimension.width, cardDimension.height);
     List<MageCard> sortedCards = new ArrayList<>(cards.values());
     switch (sortSetting.getSortBy()) {
       case NAME:
         Collections.sort(sortedCards, new CardNameComparator());
         break;
       case RARITY:
         Collections.sort(sortedCards, new CardRarityComparator());
         break;
       case COLOR:
         Collections.sort(sortedCards, new CardColorComparator());
         break;
       case COLOR_IDENTITY:
         Collections.sort(sortedCards, new CardColorDetailedIdentity());
         break;
       case CASTING_COST:
         Collections.sort(sortedCards, new CardCostComparator());
         break;
     }
     MageCard lastCard = null;
     for (MageCard cardImg : sortedCards) {
       if (sortSetting.isPilesToggle()) {
         if (lastCard == null) {
           lastCard = cardImg;
         }
         switch (sortSetting.getSortBy()) {
           case NAME:
             if (!cardImg.getOriginal().getName().equals(lastCard.getOriginal().getName())) {
               curColumn++;
               curRow = 0;
             }
             break;
           case RARITY:
             if (!cardImg.getOriginal().getRarity().equals(lastCard.getOriginal().getRarity())) {
               curColumn++;
               curRow = 0;
             }
             break;
           case COLOR:
             if (cardImg.getOriginal().getColor().compareTo(lastCard.getOriginal().getColor())
                 != 0) {
               curColumn++;
               curRow = 0;
             }
             break;
           case COLOR_IDENTITY:
             if (CardUtil.getColorIdentitySortValue(
                     cardImg.getOriginal().getManaCost(),
                     cardImg.getOriginal().getColor(),
                     cardImg.getOriginal().getRules())
                 != CardUtil.getColorIdentitySortValue(
                     lastCard.getOriginal().getManaCost(),
                     lastCard.getOriginal().getColor(),
                     lastCard.getOriginal().getRules())) {
               curColumn++;
               curRow = 0;
             }
             break;
           case CASTING_COST:
             if (cardImg.getOriginal().getConvertedManaCost()
                 != lastCard.getOriginal().getConvertedManaCost()) {
               curColumn++;
               curRow = 0;
             }
             break;
         }
         rectangle.setLocation(curColumn * cardDimension.width, curRow * cardVerticalOffset);
         cardImg.setBounds(rectangle);
         cardImg.setCardBounds(
             rectangle.x, rectangle.y, cardDimension.width, cardDimension.height);
         moveToFront(cardImg);
         curRow++;
         lastCard = cardImg;
       } else {
         rectangle.setLocation(curColumn * cardDimension.width, curRow * cardVerticalOffset);
         cardImg.setBounds(rectangle);
         cardImg.setCardBounds(
             rectangle.x, rectangle.y, cardDimension.width, cardDimension.height);
         moveToFront(cardImg);
         curColumn++;
         if (curColumn == numColumns) {
           curColumn = 0;
           curRow++;
         }
       }
     }
   }
   resizeArea();
   revalidate();
   repaint();
 }