001 /*
002 * This file is part of the Echo Point Project. This project is a
003 * collection of Components that have extended the Echo Web Application
004 * Framework Version 3.
005 *
006 * Version: MPL 1.1
007 *
008 * The contents of this file are subject to the Mozilla Public License Version
009 * 1.1 (the "License"); you may not use this file except in compliance with
010 * the License. You may obtain a copy of the License at
011 * http://www.mozilla.org/MPL/
012 *
013 * Software distributed under the License is distributed on an "AS IS" basis,
014 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015 * for the specific language governing rights and limitations under the
016 * License.
017 */
018 package echopoint;
019
020 import nextapp.echo.app.Component;
021 import nextapp.echo.app.Font;
022 import nextapp.echo.app.Color;
023 import nextapp.echo.app.Insets;
024 import nextapp.echo.app.Extent;
025 import nextapp.echo.app.Alignment;
026
027 /**
028 * A component that displays a floating information window when hovering over
029 * a <i>driver</i> text. The driver text and optionally text surrounding the
030 * driver text are displayed in this component, while the floating information
031 * window is displayed or hidden as the user hovers over or moves out of the
032 * driver text.
033 *
034 * <p>The following shows sample use of this component.</p>
035 * <pre>
036 * import echopoint.InfoWindow;
037 *
038 * ...
039 * final InfoWindow infoWindow = new InfoWindow();
040 * infoWindow.setTitle( "Note!" );
041 * infoWindow.setContent( "My floating ino window" );
042 * infoWindow.setText( "Hover over me" );
043 * ...
044 * container.add( infoWindow ); // container is any appropriate container component.
045 * </pre>
046 *
047 * @author Rakesh 2008-10-24
048 * @version $Id: InfoWindow.java 74 2008-10-26 00:14:00Z sptrakesh $
049 */
050 public class InfoWindow extends Component
051 {
052 private static final long serialVersionUID = 1l;
053
054 /**
055 * Optional prefix text before the text that drives the display of the
056 * info window. The content should be plain text without any markup.
057 * This property may be styled.
058 */
059 public static final String PROPERTY_PREFIX = "prefix";
060
061 /**
062 * Optional postfix text after the text that drives the display of the
063 * info window. The content should be plain text without any markup.
064 * This property may be styled.
065 */
066 public static final String PROPERTY_POSTFIX = "postfix";
067
068 /**
069 * The text that drives the display of the info window. Hovering over
070 * the text will display the info window. This property may be styled.
071 */
072 public static final String PROPERTY_TEXT = "text";
073
074 /** The font to use for the driver text. This is best styled. */
075 public static final String PROPERTY_TEXT_FONT = "textFont";
076
077 /** The foreground for the driver text. This is best styled. */
078 public static final String PROPERTY_TEXT_FOREGROUND = "textForeground";
079
080 /** The background for the driver text. This is best styled. */
081 public static final String PROPERTY_TEXT_BACKGROUND = "textBackground";
082
083 /** The insets for the driver text. This is best styled. */
084 public static final String PROPERTY_TEXT_INSETS = "textInsets";
085
086 /** The font to use for the pre/postfix text. This is best styled. */
087 public static final String PROPERTY_OTHER_TEXT_FONT = "otherTextFont";
088
089 /** The foreground for the pre/postfix text. This is best styled. */
090 public static final String PROPERTY_OTHER_TEXT_FOREGROUND = "otherTextForeground";
091
092 /** The background for the pre/postfix text. This is best styled. */
093 public static final String PROPERTY_OTHER_TEXT_BACKGROUND = "otherTextBackground";
094
095 /** The insets for the pre/postfix text. This is best styled. */
096 public static final String PROPERTY_OTHER_TEXT_INSETS = "otherTextInsets";
097
098 /**
099 * The title to display for the info window. Specify this only if
100 * you want a default title bar component. The text may contain HTML
101 * markup.
102 */
103 public static final String PROPERTY_TITLE = "title";
104
105 /** The alignment to use for the title. This is best styled. */
106 public static final String PROPERTY_TITLE_ALIGNMENT = "titleAlignment";
107
108 /** The font to use for the title. This is best styled. */
109 public static final String PROPERTY_TITLE_FONT = "titleFont";
110
111 /** The foreground for the title. This is best styled. */
112 public static final String PROPERTY_TITLE_FOREGROUND = "titleForeground";
113
114 /** The background for the title. This is best styled. */
115 public static final String PROPERTY_TITLE_BACKGROUND = "titleBackground";
116
117 /** The insets for the title. This is best styled. */
118 public static final String PROPERTY_TITLE_INSETS = "titleInsets";
119
120 /**
121 * The content to display in the info window. Specify this only
122 * if you want a default content area. The text may contain HTML
123 * markup.
124 */
125 public static final String PROPERTY_CONTENT = "content";
126
127 /** The alignment for the content text in the info window. */
128 public static final String PROPERTY_ALIGNMENT = "alignment";
129
130 /** The insets to apply for the content within the info window. */
131 public static final String PROPERTY_INSETS = "insets";
132
133 /** The width of the info window. This property is best styled. */
134 public static final String PROPERTY_WIDTH = "width";
135
136 /**
137 * Return the value of the {@link #PROPERTY_CONTENT} property.
138 *
139 * @return The content to be displayed in the info window.
140 */
141 public String getContent()
142 {
143 return (String) get( PROPERTY_CONTENT );
144 }
145
146 /**
147 * Set the value of the {@link #PROPERTY_CONTENT} property.
148 *
149 * @param content The value to set for the property.
150 */
151 public void setContent( final String content )
152 {
153 set( PROPERTY_CONTENT, content );
154 }
155
156 /**
157 * Return the value of the {@link #PROPERTY_TITLE} property.
158 *
159 * @return The title that drives display of the info window.
160 */
161 public String getTitle()
162 {
163 return (String) get( PROPERTY_TITLE );
164 }
165
166 /**
167 * Set the value of the {@link #PROPERTY_TITLE} property.
168 *
169 * @param title The value to set for the property.
170 */
171 public void setTitle( final String title )
172 {
173 set( PROPERTY_TITLE, title );
174 }
175
176 /**
177 * Return the value of the {@link #PROPERTY_TITLE_ALIGNMENT} property.
178 *
179 * @return The alignment to use for the title text.
180 */
181 public Alignment getTitleAlignment()
182 {
183 return (Alignment) get( PROPERTY_TITLE_ALIGNMENT );
184 }
185
186 /**
187 * Set the value of the {@link #PROPERTY_TITLE_ALIGNMENT} property.
188 *
189 * @param titleAlignment The value to set for the property.
190 */
191 public void setTitleAlignment( final Alignment titleAlignment )
192 {
193 set( PROPERTY_TITLE_ALIGNMENT, titleAlignment );
194 }
195
196 /**
197 * Return the value of the {@link #PROPERTY_TITLE_FONT} property.
198 *
199 * @return The font to use for the title.
200 */
201 public Font getTitleFont()
202 {
203 return (Font) get( PROPERTY_TITLE_FONT );
204 }
205
206 /**
207 * Set the value of the {@link #PROPERTY_TITLE_FONT} property.
208 *
209 * @param titleFont The value to set for the property.
210 */
211 public void setTitleFont( final Font titleFont )
212 {
213 set( PROPERTY_TITLE_FONT, titleFont );
214 }
215
216 /**
217 * Return the value of the {@link #PROPERTY_TITLE_FOREGROUND} property.
218 *
219 * @return The font to use for the title.
220 */
221 public Color getTitleForeground()
222 {
223 return (Color) get( PROPERTY_TITLE_FOREGROUND );
224 }
225
226 /**
227 * Set the value of the {@link #PROPERTY_TITLE_FOREGROUND} property.
228 *
229 * @param titleForeground The value to set for the property.
230 */
231 public void setTitleForeground( final Color titleForeground )
232 {
233 set( PROPERTY_TITLE_FOREGROUND, titleForeground );
234 }
235
236 /**
237 * Return the value of the {@link #PROPERTY_TITLE_BACKGROUND} property.
238 *
239 * @return The font to use for the title.
240 */
241 public Color getTitleBackground()
242 {
243 return (Color) get( PROPERTY_TITLE_BACKGROUND );
244 }
245
246 /**
247 * Set the value of the {@link #PROPERTY_TITLE_BACKGROUND} property.
248 *
249 * @param titleBackground The value to set for the property.
250 */
251 public void setTitleBackground( final Color titleBackground )
252 {
253 set( PROPERTY_TITLE_BACKGROUND, titleBackground );
254 }
255
256 /**
257 * Return the value of the {@link #PROPERTY_TITLE_INSETS} property.
258 *
259 * @return The insets to use for the title.
260 */
261 public Insets getTitleInsets()
262 {
263 return (Insets) get( PROPERTY_TITLE_INSETS );
264 }
265
266 /**
267 * Set the value of the {@link #PROPERTY_TITLE_INSETS} property.
268 *
269 * @param titleInsets The value to set for the property.
270 */
271 public void setTitleInsets( final Insets titleInsets )
272 {
273 set( PROPERTY_TITLE_INSETS, titleInsets );
274 }
275
276 /**
277 * Return the value of the {@link #PROPERTY_PREFIX} property.
278 *
279 * @return The optional prefix text to display before the driver text.
280 */
281 public String getPrefix()
282 {
283 return (String) get( PROPERTY_PREFIX );
284 }
285
286 /**
287 * Set the value of the {@link #PROPERTY_PREFIX} property.
288 *
289 * @param prefix The value to set for the property.
290 */
291 public void setPrefix( final String prefix )
292 {
293 set( PROPERTY_PREFIX, prefix );
294 }
295
296 /**
297 * Return the value of the {@link #PROPERTY_POSTFIX} property.
298 *
299 * @return The postfix text to display after the driver text.
300 */
301 public String getPostfix()
302 {
303 return (String) get( PROPERTY_POSTFIX );
304 }
305
306 /**
307 * Set the value of the {@link #PROPERTY_POSTFIX} property.
308 *
309 * @param postfix The value to set for the property.
310 */
311 public void setPostfix( final String postfix )
312 {
313 set( PROPERTY_POSTFIX, postfix );
314 }
315
316 /**
317 * Return the value of the {@link #PROPERTY_TEXT} property.
318 *
319 * @return The text that drives display of the info window.
320 */
321 public String getText()
322 {
323 return (String) get( PROPERTY_TEXT );
324 }
325
326 /**
327 * Set the value of the {@link #PROPERTY_TEXT} property.
328 *
329 * @param text The value to set for the property.
330 */
331 public void setText( final String text )
332 {
333 set( PROPERTY_TEXT, text );
334 }
335
336 /**
337 * Return the value of the {@link #PROPERTY_TEXT_FONT} property.
338 *
339 * @return The font to use for the driver text.
340 */
341 public Font getTextFont()
342 {
343 return (Font) get( PROPERTY_TEXT_FONT );
344 }
345
346 /**
347 * Set the value of the {@link #PROPERTY_TEXT_FONT} property.
348 *
349 * @param textFont The value to set for the property.
350 */
351 public void setTextFont( final Font textFont )
352 {
353 set( PROPERTY_TEXT_FONT, textFont );
354 }
355
356 /**
357 * Return the value of the {@link #PROPERTY_TEXT_FOREGROUND} property.
358 *
359 * @return The font to use for the driver text.
360 */
361 public Color getTextForeground()
362 {
363 return (Color) get( PROPERTY_TEXT_FOREGROUND );
364 }
365
366 /**
367 * Set the value of the {@link #PROPERTY_TEXT_FOREGROUND} property.
368 *
369 * @param textForeground The value to set for the property.
370 */
371 public void setTextForeground( final Color textForeground )
372 {
373 set( PROPERTY_TEXT_FOREGROUND, textForeground );
374 }
375
376 /**
377 * Return the value of the {@link #PROPERTY_TEXT_BACKGROUND} property.
378 *
379 * @return The font to use for the driver text.
380 */
381 public Color getTextBackground()
382 {
383 return (Color) get( PROPERTY_TEXT_BACKGROUND );
384 }
385
386 /**
387 * Set the value of the {@link #PROPERTY_TEXT_BACKGROUND} property.
388 *
389 * @param textBackground The value to set for the property.
390 */
391 public void setTextBackground( final Color textBackground )
392 {
393 set( PROPERTY_TEXT_BACKGROUND, textBackground );
394 }
395
396 /**
397 * Return the value of the {@link #PROPERTY_TEXT_INSETS} property.
398 *
399 * @return The insets to use for the driver text.
400 */
401 public Insets getTextInsets()
402 {
403 return (Insets) get( PROPERTY_TEXT_INSETS );
404 }
405
406 /**
407 * Set the value of the {@link #PROPERTY_TEXT_INSETS} property.
408 *
409 * @param textInsets The value to set for the property.
410 */
411 public void setTextInsets( final Insets textInsets )
412 {
413 set( PROPERTY_TEXT_INSETS, textInsets );
414 }
415
416 /**
417 * Return the value of the {@link #PROPERTY_OTHER_TEXT_FONT} property.
418 *
419 * @return The font to use for the pre/postfix text.
420 */
421 public Font getOtherTextFont()
422 {
423 return (Font) get( PROPERTY_OTHER_TEXT_FONT );
424 }
425
426 /**
427 * Set the value of the {@link #PROPERTY_OTHER_TEXT_FONT} property.
428 *
429 * @param textFont The value to set for the property.
430 */
431 public void setOtherTextFont( final Font textFont )
432 {
433 set( PROPERTY_OTHER_TEXT_FONT, textFont );
434 }
435
436 /**
437 * Return the value of the {@link #PROPERTY_OTHER_TEXT_FOREGROUND} property.
438 *
439 * @return The font to use for the pre/postfix text.
440 */
441 public Color getOtherTextForeground()
442 {
443 return (Color) get( PROPERTY_OTHER_TEXT_FOREGROUND );
444 }
445
446 /**
447 * Set the value of the {@link #PROPERTY_OTHER_TEXT_FOREGROUND} property.
448 *
449 * @param textForeground The value to set for the property.
450 */
451 public void setOtherTextForeground( final Color textForeground )
452 {
453 set( PROPERTY_OTHER_TEXT_FOREGROUND, textForeground );
454 }
455
456 /**
457 * Return the value of the {@link #PROPERTY_OTHER_TEXT_BACKGROUND} property.
458 *
459 * @return The font to use for the pre/postfix text.
460 */
461 public Color getOtherTextBackground()
462 {
463 return (Color) get( PROPERTY_OTHER_TEXT_BACKGROUND );
464 }
465
466 /**
467 * Set the value of the {@link #PROPERTY_OTHER_TEXT_BACKGROUND} property.
468 *
469 * @param textBackground The value to set for the property.
470 */
471 public void setOtherTextBackground( final Color textBackground )
472 {
473 set( PROPERTY_OTHER_TEXT_BACKGROUND, textBackground );
474 }
475
476 /**
477 * Return the value of the {@link #PROPERTY_OTHER_TEXT_INSETS} property.
478 *
479 * @return The insets to use for the pre/postfix text.
480 */
481 public Insets getOtherTextInsets()
482 {
483 return (Insets) get( PROPERTY_OTHER_TEXT_INSETS );
484 }
485
486 /**
487 * Set the value of the {@link #PROPERTY_OTHER_TEXT_INSETS} property.
488 *
489 * @param textInsets The value to set for the property.
490 */
491 public void setOtherTextInsets( final Insets textInsets )
492 {
493 set( PROPERTY_OTHER_TEXT_INSETS, textInsets );
494 }
495
496 /**
497 * Return the value of the {@link #PROPERTY_ALIGNMENT} property.
498 *
499 * @return The alignment to use for the content text.
500 */
501 public Alignment getAlignment()
502 {
503 return (Alignment) get( PROPERTY_ALIGNMENT );
504 }
505
506 /**
507 * Set the value of the {@link #PROPERTY_ALIGNMENT} property.
508 *
509 * @param alignment The value to set for the property.
510 */
511 public void setAlignment( final Alignment alignment )
512 {
513 set( PROPERTY_ALIGNMENT, alignment );
514 }
515
516 /**
517 * Return the value of the {@link #PROPERTY_INSETS} property.
518 *
519 * @return The insets to use for the pre/postfix text.
520 */
521 public Insets getInsets()
522 {
523 return (Insets) get( PROPERTY_INSETS );
524 }
525
526 /**
527 * Set the value of the {@link #PROPERTY_INSETS} property.
528 *
529 * @param insets The value to set for the property.
530 */
531 public void setInsets( final Insets insets )
532 {
533 set( PROPERTY_INSETS, insets );
534 }
535
536 /**
537 * Return the value of the {@link #PROPERTY_WIDTH} property.
538 *
539 * @return The width of the info window component.
540 */
541 public Extent getWidth()
542 {
543 return (Extent) get( PROPERTY_WIDTH );
544 }
545
546 /**
547 * Set the value of the {@link #PROPERTY_WIDTH} property.
548 *
549 * @param width The value to set for the property.
550 */
551 public void setWidth( final Extent width )
552 {
553 set( PROPERTY_WIDTH, width );
554 }
555 }