View Javadoc
1   /******************************************************************************
2    * Chain.java - a chain bean, define a chain of attributes to make one set of contacts
3    * 
4    * PicMan - The BuckoSoft Picture Manager in Java
5    * Copyright(c) 2005 - Dick Balaska
6    * 
7    */
8   package com.buckosoft.PicMan.domain;
9   
10  import java.io.Serializable;
11  import java.util.Iterator;
12  import java.util.LinkedList;
13  import java.util.List;
14  
15  /** Define the attributes required to make one set of contacts
16   * @author Dick Balaska
17   * @since 2005/07/30
18   * @see <a href="http://cvs.buckosoft.com/Projects/PicMan/PicMan/src/main/java/com/buckosoft/PicMan/domain/Chain.java">Chain.java</a>
19   */
20  public class Chain implements Serializable, DataStrings {
21  	private static final long serialVersionUID = 1L;
22  	
23  	private	int		cid = -1;
24  	private	String	name;
25  	private	String	shortName = "";
26  	private	String	contactPrefix = "";
27  	private	String	description = "";
28  	private	boolean	active = false;
29  	private	String	engine = "";
30  	private	String	contactDirectory = "";
31  	private	int		contactCount = 4;
32  	private	int		contactWidth = 640;
33  	private	int		contactHeight = 480;
34  	private	int		picSelector = PICSELECTOR_SORT;
35  	private	int		ratingMin = 1;
36  	private	int		ratingMax = 9;
37  	private	boolean	showUnusedSets = true;
38  	
39  	private	LinkedList<SetSize>	setSizes = new LinkedList<SetSize>();
40  	
41  	public	void	setName(String name) { this.name = name; }
42  	public	String	getName() { return(name); }
43  	
44  	public	void	setDescription(String desc) { this.description = desc; }
45  	public	String	getDescription() { return(description); }
46  
47  	
48  	/**
49  	 * @return Returns the cid.
50  	 */
51  	public int getCid() {
52  		return cid;
53  	}
54  	/**
55  	 * @param cid The cid to set.
56  	 */
57  	public void setCid(int cid) {
58  		this.cid = cid;
59  	}
60  
61  	/**
62  	 * @return Returns the shortName.
63  	 */
64  	public String getShortName() {
65  		return shortName;
66  	}
67  	/**
68  	 * @param shortName The shortName to set.
69  	 */
70  	public void setShortName(String shortName) {
71  		this.shortName = shortName;
72  	}
73  
74  	/**
75  	 * @return Returns whether this chain is active.
76  	 */
77  	public boolean isActive() {
78  		return active;
79  	}
80  	/**
81  	 * @param active Set whether this chain is active.
82  	 */
83  	public void setActive(boolean active) {
84  		this.active = active;
85  	}
86  
87  	public String getContactPrefix() { return(contactPrefix); }
88  	public void setContactPrefix(String contactPrefix) { this.contactPrefix = contactPrefix; }
89  	
90  	
91  	public int getContactCount() {
92  		return contactCount;
93  	}
94  	public void setContactCount(int contactCount) {
95  		this.contactCount = contactCount;
96  	}
97  	public String getContactDirectory() {
98  		return contactDirectory;
99  	}
100 	public void setContactDirectory(String contactDirectory) {
101 		this.contactDirectory = contactDirectory;
102 	}
103 	public int getContactHeight() {
104 		return contactHeight;
105 	}
106 	public void setContactHeight(int contactHeight) {
107 		this.contactHeight = contactHeight;
108 	}
109 	public int getContactWidth() {
110 		return contactWidth;
111 	}
112 	public void setContactWidth(int contactWidth) {
113 		this.contactWidth = contactWidth;
114 	}
115 	public String getEngine() {
116 		return engine;
117 	}
118 	public void setEngine(String engine) {
119 		this.engine = engine;
120 	}
121 	public LinkedList<SetSize> getSetSizes() { 
122 		return setSizes;
123 	}
124 
125 	public	void	addSetSize(SetSize ss) {
126 		setSizes.add(ss);
127 	}
128 	public	void	setSetSizes(LinkedList<SetSize> setSizes) {
129 		this.setSizes = setSizes;
130 	}
131 	
132 	/** Get a list of the Set names used in this chain
133 	 * @return a list of Strings
134 	 */
135 	public	List<String>	getSetNames() {
136 		LinkedList<String> theList = new LinkedList<String>();
137 		Iterator<SetSize> iter = this.setSizes.iterator();
138 		while (iter.hasNext()) {
139 			SetSize ss = (SetSize)iter.next();
140 			boolean match = false;
141 			Iterator<String> iterThe = theList.iterator();
142 			while (iterThe.hasNext()) {
143 				String s = (String)iterThe.next();
144 				if (s.equals(ss.getSetName())) {
145 					match = true;
146 					break;
147 				}
148 			}
149 			if (match == false) {
150 				theList.add(ss.getSetName());
151 			}
152 		}
153 		return(theList);
154 	}
155 	
156 	/** Determine whether this set/size is in this chain
157 	 * @return true if this set/size is in the chain
158 	 */
159 	public	boolean	hasSetSize(String setName, int size) {
160 		Iterator<SetSize> iter = this.setSizes.iterator();
161 		while (iter.hasNext()) {
162 			SetSize ss = (SetSize)iter.next();
163 			if (ss.getSetName().equals(setName) && ss.getSize() == size)
164 				return(true);
165 		}
166 		return(false);
167 	}
168 
169 	/**
170 	 * @return Returns the picSelector.
171 	 */
172 	public int getPicSelector() {
173 		return picSelector;
174 	}
175 
176 	/**
177 	 * @param picSelector The picSelector to set.
178 	 */
179 	public void setPicSelector(int picSelector) {
180 		this.picSelector = picSelector;
181 	}
182 
183 	/** Get the maximum rating of a pic that can be used in this chain.
184 	 * @return Returns the ratingMax.
185 	 */
186 	public int getRatingMax() {
187 		return ratingMax;
188 	}
189 
190 	/** Set the maximum rating of a pic that can be used in this chain.
191 	 * @param ratingMax The ratingMax to set.
192 	 */
193 	public void setRatingMax(int ratingMax) {
194 		this.ratingMax = ratingMax;
195 	}
196 
197 	/** Get the minimum rating of a pic that can be used in this chain.
198 	 * @return Returns the ratingsMin.
199 	 */
200 	public int getRatingMin() {
201 		return ratingMin;
202 	}
203 
204 	/** Set the minimum rating of a pic that can be used in this chain.
205 	 * @param ratingMin The ratingsMin to set.
206 	 */
207 	public void setRatingMin(int ratingMin) {
208 		this.ratingMin = ratingMin;
209 	}
210 
211 	/** Do we show or hide the unused sets during Chain editing?
212 	 * @return the showUnusedSets
213 	 */
214 	public boolean isShowUnusedSets() {
215 		return showUnusedSets;
216 	}
217 	/** Set do we show or hide the unused sets during Chain editing?
218 	 * @param showUnusedSets the showUnusedSets to set
219 	 */
220 	public void setShowUnusedSets(boolean showUnusedSets) {
221 		this.showUnusedSets = showUnusedSets;
222 	}
223 	
224 
225 }