1 /****************************************************************************** 2 * RatingGraphConfig.java - Configure the ratings graph 3 * $Id$ 4 * 5 * BuckoFIBS - Backgammon by BuckoSoft 6 * Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp. 7 * 8 * $Log$ 9 * Revision 1.3 2010/03/03 13:12:22 inim 10 * Replaced (c) sign in comment mangled by CVS default encoding back to UTF-8 11 * 12 * Revision 1.2 2010/03/03 12:19:49 inim 13 * Moved source to UTF8 encoding from CP1252 encoding. To this end all source files' (c) message was updated to "Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.". This replaces the (c) sign to UTF8, and adds the new year 2010. 14 * 15 * Revision 1.1 2010/02/04 05:57:53 inim 16 * Mavenized project folder layout 17 * 18 * Revision 1.2 2010/01/29 23:10:09 dick 19 * Need to be able to clone(). 20 * 21 * Revision 1.1 2010/01/26 19:11:21 dick 22 * Configure the ratings graph. 23 * 24 */ 25 26 /* 27 * This program is free software: you can redistribute it and/or modify 28 * it under the terms of the GNU General Public License as published by 29 * the Free Software Foundation, either version 3 of the License, or 30 * (at your option) any later version. 31 * 32 * This program is distributed in the hope that it will be useful, 33 * but WITHOUT ANY WARRANTY; without even the implied warranty of 34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 35 * GNU General Public License for more details. 36 * 37 * You should have received a copy of the GNU General Public License 38 * along with this program. If not, see <http://www.gnu.org/licenses/>. 39 * 40 * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>. 41 * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp. 42 * 43 */ 44 package com.buckosoft.fibs.domain.config; 45 46 import java.util.Date; 47 48 /** Configure the ratings graph. 49 * @author Dick Balaska 50 * @since Jan 26, 2010 51 * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/domain/config/RatingGraphConfig.java">cvs RatingGraphConfig.java</a> 52 */ 53 public class RatingGraphConfig implements Cloneable { 54 55 /** Define what type of data to display in the Rating Graph. 56 * @author Dick Balaska 57 * @since Jan 26, 2010 58 * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/domain/config/RatingGraphConfig.java">cvs RatingGraphConfig.java</a> 59 */ 60 public enum Type { 61 /** Display all of the matches we have played. */ 62 displayAllMatches, 63 /** Display the last (constant) number of matches that we've played. */ 64 displayLastXMatches, 65 /** Display all matches from a (constant) date. */ 66 displayFromDate 67 } 68 69 private Type type = Type.displayLastXMatches; 70 private int matchCount = 100; 71 private Date firstMatchDate = new Date(0); 72 73 /** make a copy of this RatingGraphConfig 74 * @return The new copy of this RatingGraphConfig 75 */ 76 public RatingGraphConfig clone() { 77 RatingGraphConfig rgc = new RatingGraphConfig(); 78 rgc.setTypeAsInt(this.getTypeAsInt()); 79 rgc.setMatchCount(this.getMatchCount()); 80 rgc.firstMatchDate = new Date(this.firstMatchDate.getTime()); 81 return(rgc); 82 } 83 84 /** Fetch the {@link com.buckosoft.fibs.domain.config.RatingGraphConfig.Type} of graph to display 85 * @return the type 86 */ 87 public Type getType() { 88 return type; 89 } 90 91 /** Set the type of graph that the user wants to display. 92 * @param type the type to set 93 */ 94 public void setType(Type type) { 95 this.type = type; 96 } 97 98 /** Set the type of graph as an int. Useful for database access. 99 * @param type The (most likely) stored type 100 */ 101 public void setTypeAsInt(int type) { 102 if (type == Type.displayAllMatches.ordinal()) 103 this.type = Type.displayAllMatches; 104 else if (type == Type.displayLastXMatches.ordinal()) 105 this.type = Type.displayLastXMatches; 106 else if (type == Type.displayFromDate.ordinal()) 107 this.type = Type.displayFromDate; 108 } 109 110 /** Fetch the type of graph as an int. Useful for database access. 111 * @return What type of graph the user wants displayed. 112 */ 113 public int getTypeAsInt() { 114 return(this.type.ordinal()); 115 } 116 117 /** Get the number of matches that the user wants to display. 118 * Useful only for Type.displayLastXMatches 119 * @return the matchCount 120 */ 121 public int getMatchCount() { 122 return matchCount; 123 } 124 125 /** Set the number of matches that the user wants to display. 126 * @param matchCount the matchCount to set 127 */ 128 public void setMatchCount(int matchCount) { 129 this.matchCount = matchCount; 130 } 131 132 /** Get the date of the first match to display. 133 * @return the firstMatchDate 134 */ 135 public Date getFirstMatchDate() { 136 return firstMatchDate; 137 } 138 139 /** Set the date of the first match to display. 140 * @param firstMatchDate the firstMatchDate to set 141 */ 142 public void setFirstMatchDate(Date firstMatchDate) { 143 this.firstMatchDate = firstMatchDate; 144 } 145 146 147 }