X-Git-Url: https://git.hedgecode.org/?a=blobdiff_plain;f=chesshog-format%2Fsrc%2Fmain%2Fjava%2Forg%2Fhedgecode%2Fchess%2Fimg%2Fpiece%2FPieceSet.java;fp=chesshog-format%2Fsrc%2Fmain%2Fjava%2Forg%2Fhedgecode%2Fchess%2Fimg%2Fpiece%2FPieceSet.java;h=0000000000000000000000000000000000000000;hb=e185f00e2252021d946f23f4871ae9721f7e65fa;hp=342ba1aec49a2bec39b94eb947482989d97325fa;hpb=612dc701d600159c094ab201c6de6136ae38dba9;p=chesshog.git diff --git a/chesshog-format/src/main/java/org/hedgecode/chess/img/piece/PieceSet.java b/chesshog-format/src/main/java/org/hedgecode/chess/img/piece/PieceSet.java deleted file mode 100644 index 342ba1a..0000000 --- a/chesshog-format/src/main/java/org/hedgecode/chess/img/piece/PieceSet.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2018-2019. Developed by Hedgecode. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.hedgecode.chess.img.piece; - -import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.hedgecode.chess.position.Color; -import org.hedgecode.chess.position.ColorPiece; -import org.hedgecode.chess.position.Piece; - -/** - * - * - * @author Dmitry Samoshin aka gotty - */ -public class PieceSet { - - private Map pieceSetMap = new HashMap<>(); - - private static String[] allPieceNames; - - PieceSet() { - } - - public void add(String name, BufferedImage image) { - if (name != null && name.length() == 2) { - name = name.toLowerCase(); - ColorPiece colorPiece = ColorPiece.getColorPiece( - Color.byLetter(name.charAt(0)), - Piece.byLetter(name.charAt(1)) - ); - if (colorPiece != null){ - add(colorPiece, image); - } - } - } - - public void add(ColorPiece colorPiece, BufferedImage image) { - if (pieceSetMap.containsKey(colorPiece)) { - pieceSetMap.replace(colorPiece, image); - } else { - pieceSetMap.put(colorPiece, image); - } - } - - public BufferedImage get(ColorPiece colorPiece) { - return pieceSetMap.get(colorPiece); - } - - public boolean isFull() { - for (ColorPiece colorPiece : ColorPiece.values()) { - if (!pieceSetMap.containsKey(colorPiece) - || (pieceSetMap.get(colorPiece) == null)) { - return false; - } - } - return true; - } - - public static String[] getAllPieceNames() { - if (allPieceNames == null) { - List listNames = new ArrayList<>(); - for (Color color : Color.values()) { - for (Piece piece : Piece.values()) { - listNames.add( - String.valueOf( - new char[] {color.letter(), piece.letter()} - ) - ); - } - } - allPieceNames = listNames.toArray(new String[listNames.size()]); - } - return allPieceNames; - } - - public static PieceSet create() { - return new PieceSet(); - } - -}