1 /** 2 * The chess framework library. 3 * More information is available at http://www.jinchess.com/. 4 * Copyright (C) 2002 Alexander Maryanovsky. 5 * All rights reserved. 6 * 7 * The chess framework library is free software; you can redistribute 8 * it and/or modify it under the terms of the GNU Lesser General Public License 9 * as published by the Free Software Foundation; either version 2 of the 10 * License, or (at your option) any later version. 11 * 12 * The chess framework library is distributed in the hope that it will 13 * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 15 * General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License 18 * along with the chess framework library; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 */ 21 22 package free.chess; 23 24 import java.awt.Color; 25 26 27 /** 28 * A skeleton implementation of <code>ColoredBoardPainter</code>. 29 */ 30 31 public abstract class AbstractColoredBoardPainter implements ColoredBoardPainter{ 32 33 34 35 /** 36 * The color of the light squares. 37 */ 38 39 private Color lightColor; 40 41 42 43 /** 44 * The color of the dark squares. 45 */ 46 47 private Color darkColor; 48 49 50 51 /** 52 * Creates a new <code>AbstractColoredBoardPainter</code> with the specified 53 * colors for light and dark squares. 54 */ 55 AbstractColoredBoardPainter(Color lightColor, Color darkColor)56 public AbstractColoredBoardPainter(Color lightColor, Color darkColor){ 57 if (lightColor == null) 58 throw new IllegalArgumentException("Null light color"); 59 if (darkColor == null) 60 throw new IllegalArgumentException("Null dark color"); 61 62 this.lightColor = lightColor; 63 this.darkColor = darkColor; 64 } 65 66 67 68 /** 69 * Creates a new <code>AbstractColoredBoardPainter</code> with default colors 70 * for light and dark squares. 71 */ 72 AbstractColoredBoardPainter()73 public AbstractColoredBoardPainter(){ 74 this(Color.white.darker(), Color.black.brighter()); 75 } 76 77 78 79 /** 80 * Returns the color with which light squares are drawn. 81 */ 82 getLightColor()83 public Color getLightColor(){ 84 return lightColor; 85 } 86 87 88 89 /** 90 * Sets the color with which light squares are drawn; 91 */ 92 setLightColor(Color lightColor)93 public void setLightColor(Color lightColor){ 94 if (lightColor == null) 95 throw new IllegalArgumentException("Null color"); 96 97 this.lightColor = lightColor; 98 } 99 100 101 102 /** 103 * Returns the color with which dark squares are drawn. 104 */ 105 getDarkColor()106 public Color getDarkColor(){ 107 return darkColor; 108 } 109 110 111 112 /** 113 * Sets the color with which dark squares are drawn; 114 */ 115 setDarkColor(Color darkColor)116 public void setDarkColor(Color darkColor){ 117 if (darkColor == null) 118 throw new IllegalArgumentException("Null color"); 119 120 this.darkColor = darkColor; 121 } 122 123 124 125 }