View Javadoc
1 /* 2 * Created on Sep 29, 2003 3 * Copyright (c) 2003. All rights reserved. 4 */ 5 package portaview.model; 6 7 import java.awt.Color; 8 import java.util.Hashtable; 9 10 /*** 11 * Settings for the slideshow. This contains most of the state in the PortaView. This 12 * object is transfered over to remote PortaView in order to change their settings. 13 * 14 * @author <a href="mailto:wwlee1@uiuc.edu">William Lee</a> 15 * @version $Id: SlideSettings.java,v 1.6 2003/12/10 06:18:57 wlee Exp $ 16 */ 17 public class SlideSettings 18 { 19 public static final String SLIDE = "slide"; // slide name 20 public static final String INDEX = "index"; // index in side 21 public static final String TOTAL = "total"; // total number of slides 22 public static final String SPEED = "speed"; 23 public static final String TRANSPARENCY = "transparency"; 24 public static final String PLAY_STATE = "state"; 25 // speed 0 = stop, >0 = second for the next slide. 26 public static final String BORDER_RED = "borderRed"; // border red 27 public static final String BORDER_GREEN = "borderGreen"; // border green 28 public static final String BORDER_BLUE = "borderBlue"; // border blue 29 public static final String BORDER = "border"; // border thickness 30 public static final int PLAY = 0; // constant for play state 31 public static final int PAUSE = 1; // constant for pause state 32 33 private String slide = ""; 34 private int index = 0; 35 private int total = 0; 36 private int speed = 15; 37 private Color borderColor = Color.BLACK; 38 private int border = 0; 39 private int playState = PAUSE; 40 private int transparency = 10; 41 42 public SlideSettings() 43 { 44 } 45 46 /*** 47 * Returns true if the given slide settings is exactly the same. This can be used 48 * for checking whether the remote PortaView needs to be updated. 49 * @param ss slide settings to test. 50 * @return true if ss equals the current object. 51 */ 52 public boolean equals(SlideSettings ss) 53 { 54 if (!ss.getSlide().equals(slide)) 55 return false; 56 if (ss.getIndex() != index) 57 return false; 58 if (ss.getTotal() != total) 59 return false; 60 if (ss.getSpeed() != speed) 61 return false; 62 if (!ss.getBorderColor().equals(borderColor)) 63 return false; 64 if (ss.getBorder() != border) 65 return false; 66 if (ss.getPlayState() != playState) 67 return false; 68 return true; 69 } 70 71 public boolean equals(Object ss) 72 { 73 return equals((SlideSettings) ss); 74 } 75 76 /*** 77 * Serializes to string for pretty print out. 78 */ 79 public String toString() 80 { 81 StringBuffer sb = new StringBuffer(); 82 sb.append(slide); 83 sb.append(":"); 84 sb.append(index); 85 sb.append("/"); 86 sb.append(total); 87 sb.append(":"); 88 sb.append("speed="); 89 sb.append(speed); 90 sb.append(":"); 91 sb.append("color="); 92 if (borderColor != null) 93 { 94 sb.append(":"); 95 sb.append(borderColor.toString()); 96 } 97 sb.append(":"); 98 sb.append("border="); 99 sb.append(border); 100 sb.append(":"); 101 sb.append("trans="); 102 sb.append(transparency); 103 sb.append(":"); 104 sb.append("playState="); 105 if (playState == PLAY) 106 sb.append("play"); 107 else 108 sb.append("pause"); 109 return sb.toString(); 110 } 111 /*** 112 * Given a Hashtable that represents this object (got form XML-RPC mostly), convert 113 * and set this object. 114 */ 115 public SlideSettings(Hashtable def) 116 { 117 this.slide = (String) def.get(SLIDE); 118 Integer val = ((Integer) def.get(INDEX)); 119 if (val != null) 120 this.index = val.intValue(); 121 val = ((Integer) def.get(TOTAL)); 122 if (val != null) 123 this.total = val.intValue(); 124 val = ((Integer) def.get(SPEED)); 125 if (val != null) 126 this.speed = val.intValue(); 127 128 Integer r, g, b; 129 r = ((Integer) def.get(BORDER_RED)); 130 g = ((Integer) def.get(BORDER_GREEN)); 131 b = ((Integer) def.get(BORDER_BLUE)); 132 if (r != null && g != null && b != null) 133 { 134 this.borderColor = 135 new Color(r.intValue(), g.intValue(), b.intValue()); 136 } 137 138 val = ((Integer) def.get(BORDER)); 139 if (val != null) 140 this.border = val.intValue(); 141 val = ((Integer) def.get(PLAY_STATE)); 142 if (val != null) 143 this.playState = val.intValue(); 144 val = ((Integer) def.get(TRANSPARENCY)); 145 if (val != null) 146 this.transparency = val.intValue(); 147 } 148 149 /*** 150 * @return a Hashtable for XML-RPC calls. 151 */ 152 public Object toHashtable() 153 { 154 Hashtable rtn = new Hashtable(); 155 rtn.put(SLIDE, slide); 156 rtn.put(INDEX, new Integer(index)); 157 rtn.put(TOTAL, new Integer(total)); 158 rtn.put(SPEED, new Integer(speed)); 159 rtn.put(BORDER_RED, new Integer(borderColor.getRed())); 160 rtn.put(BORDER_GREEN, new Integer(borderColor.getGreen())); 161 rtn.put(BORDER_BLUE, new Integer(borderColor.getBlue())); 162 rtn.put(BORDER, new Integer(border)); 163 rtn.put(PLAY_STATE, new Integer(playState)); 164 rtn.put(TRANSPARENCY, new Integer(transparency)); 165 return rtn; 166 } 167 168 /*** 169 * @return the border width. 170 */ 171 public int getBorder() 172 { 173 return border; 174 } 175 176 /*** 177 * Sets border width. 178 * @param border the border width. 179 */ 180 public void setBorder(int border) 181 { 182 this.border = border; 183 } 184 185 /*** 186 * @return the border color 187 */ 188 public Color getBorderColor() 189 { 190 return borderColor; 191 } 192 193 /*** 194 * Sets border color 195 * @param borderColor color to set. 196 */ 197 public void setBorderColor(Color borderColor) 198 { 199 this.borderColor = borderColor; 200 } 201 202 /*** 203 * @return the index of the picture shown in the current slide. 204 */ 205 public int getIndex() 206 { 207 return index; 208 } 209 210 /*** 211 * Sets the picture index. 212 * @param index index of the picture. 213 */ 214 public void setIndex(int index) 215 { 216 this.index = index; 217 } 218 219 /*** 220 * @return the slide's name. 221 */ 222 public String getSlide() 223 { 224 return slide; 225 } 226 227 /*** 228 * Sets the slide's name. 229 * @param slide slide's name. 230 */ 231 public void setSlide(String slide) 232 { 233 this.slide = slide; 234 } 235 236 /*** 237 * @return the total number of slides it is showing. 238 */ 239 public int getTotal() 240 { 241 return total; 242 } 243 244 /*** 245 * Sets the total number of slides. 246 * @param total total number of slides. 247 */ 248 public void setTotal(int total) 249 { 250 this.total = total; 251 } 252 253 /*** 254 * @return the play speed. 255 */ 256 public int getSpeed() 257 { 258 return speed; 259 } 260 261 /*** 262 * Sets the play speed. 263 * @param speed play speed. 264 */ 265 public void setSpeed(int speed) 266 { 267 this.speed = speed; 268 } 269 270 /*** 271 * @return the play state. This can be PLAY or PAUSE. 272 */ 273 public int getPlayState() 274 { 275 return playState; 276 } 277 278 /*** 279 * Sets the play state. 280 * @param i play state, this can be PLAY or PAUSE. 281 */ 282 public void setPlayState(int i) 283 { 284 playState = i; 285 } 286 287 /*** 288 * @return the alpha transparency. This number goes from 0 to 10. 289 */ 290 public int getTransparency() 291 { 292 return transparency; 293 } 294 295 /*** 296 * Sets the alpha transparency 297 * @param i alpha transparency. This number goes from 0 to 10. 298 */ 299 public void setTransparency(int i) 300 { 301 transparency = i; 302 } 303 304 }

This page was automatically generated by Maven