01: package xui.samples.carousel.components;
02:
03: import com.xoetrope.swing.XPolygonalTextArea;
04: import net.xoetrope.xui.*;
05: import net.xoetrope.swing.*;
06:
07: /**
08: * Provide some interaction with the flowed text components
09: * <p>Copyright: Xoetrope Ltd. (c) 2001-2006</p>
10: * <p>License: see license.txt</p>
11: * <p>$Revision: 1.6 $</p>
12: */
13: public class Flows extends XPage {
14: private XPolygonalTextArea flow;
15:
16: public Flows() {
17: }
18:
19: /**
20: * The page has been created and all components instantiated
21: */
22: public void pageCreated() {
23: flow = ((XPolygonalTextArea) findComponent("flowedTextArea"));
24: }
25:
26: /**
27: * Toggle the visiblility of the images
28: */
29: public void showImages() {
30: ((XImage) findComponent("imageA")).setVisible(true);
31: ((XImage) findComponent("imageB")).setVisible(true);
32:
33: // Force the flowed component to reinitialize/recalculate the flow area
34: flow.init();
35: }
36:
37: /**
38: * Toggle the visiblility of the images
39: */
40: public void hideImages() {
41: ((XImage) findComponent("imageA")).setVisible(false);
42: ((XImage) findComponent("imageB")).setVisible(false);
43: // Force the flowed component to reinitialize/recalculate the flow area
44: flow.init();
45: }
46:
47: /**
48: * Chaneg how the flow area clips the sibling components
49: */
50: public void clipImages() {
51: flow.setClip(!flow.getClip());
52: }
53:
54: /**
55: * Change the z-order of the flow area so it can overlay the images and other
56: * components
57: */
58: public void overlayImages() {
59: XPanel overlayPanel = ((XPanel) findComponent("overlayPanel"));
60: if (flow.getParent() == overlayPanel)
61: ((XPanel) findComponent("textPanel")).add(flow);
62: else
63: overlayPanel.add(flow);
64:
65: flow.init();
66: }
67:
68: /**
69: * Change the number of columns in the flow area
70: */
71: public void showColumns() {
72: int cols = flow.getNumColumns();
73: if (cols < 2)
74: flow.setNumColumns(2);
75: else
76: flow.setNumColumns(1);
77: flow.init();
78: }
79: }
|