KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > rero > dialogs > ImageDialog


1 package rero.dialogs;
2
3 import java.awt.*;
4 import java.awt.event.*;
5
6 import javax.swing.*;
7 import javax.swing.table.*;
8 import javax.swing.event.*;
9
10 import java.util.*;
11 import rero.config.*;
12
13 import rero.dck.items.*;
14 import rero.dck.*;
15
16 public class ImageDialog extends DMain implements DParent, ActionListener
17 {
18    protected String JavaDoc current = "desktop";
19    protected TabbedInput tabs;
20    protected ImagePreview preview;
21    protected NormalInput label;
22
23    protected void setupLabel()
24    {
25       label.setText("<html><b><u>" + current.substring(0, 1).toUpperCase() + current.substring(1, current.length()) + "</u></b>: background properties</html>");
26    }
27
28    public void actionPerformed(ActionEvent ev)
29    {
30       tabs.save();
31       current = ev.getActionCommand();
32
33       setupLabel();
34
35       tabs.refresh();
36       preview.refresh();
37       preview.repaint();
38    }
39
40    public String JavaDoc getTitle()
41    {
42       return "Backgrounds";
43    }
44
45    public void notifyParent(String JavaDoc variable)
46    {
47       ClientState.getClientState().fireChange(current);
48       preview.repaint();
49
50       if (variable.equals(current + ".bgtype"))
51          tabs.refresh();
52    }
53
54    public String JavaDoc getVariable(String JavaDoc variable)
55    {
56       return current + "." + variable;
57    }
58
59    public String JavaDoc getDescription()
60    {
61       return "Client Background Images";
62    }
63
64    public void setupDialog()
65    {
66       addBlankSpace();
67       preview = (ImagePreview)addOther(new ImagePreview(35, 115));
68
69       label = (NormalInput)addLabelNormal("Editing Statusbar Options", 5);
70       setupLabel();
71
72       tabs = addTabbedInput();
73       tabs.addTab(new BackgroundSetup());
74       tabs.addTab(new EditColor());
75       tabs.addTab(new TransformImage());
76       tabs.addTab(new EditTint());
77
78       tabs.setParent(this);
79       preview.addActionListener(this);
80    }
81    
82    protected class EditTint extends DTab
83    {
84       public String JavaDoc getTitle()
85       {
86          return "Tint";
87       }
88
89       public boolean isEnabled()
90       {
91          int type = ClientState.getClientState().getInteger(current + ".bgtype", 0);
92          return type == 2 || type == 3;
93       }
94  
95       public String JavaDoc getDescription()
96       {
97          return "Adjust transparency settings";
98       }
99
100       public void setupDialog()
101       {
102          addFloatInput("tint", 0f, "Alpha Tint: ");
103       }
104    }
105
106    protected class EditColor extends DTab
107    {
108       public String JavaDoc getTitle()
109       {
110          return "Setup";
111       }
112
113       public boolean isEnabled()
114       {
115          return ClientState.getClientState().getInteger(current + ".bgtype", 0) != 0;
116       }
117
118       public String JavaDoc getDescription()
119       {
120          return "Select color and image for background";
121       }
122
123       public void setupDialog()
124       {
125          addOther(new ImageInput("image", "", "Background Image: ", 'I'));
126          addColorInput("color", Color.black, "Select Background Color", 'c');
127       }
128    }
129
130    protected class TransformImage extends DTab
131    {
132       public String JavaDoc getTitle()
133       {
134          return "Transform";
135       }
136
137       public boolean isEnabled()
138       {
139          return ClientState.getClientState().getInteger(current + ".bgtype", 0) == 3;
140       }
141
142       public String JavaDoc getDescription()
143       {
144          return "Options for selected background image";
145       }
146
147       public void setupDialog()
148       {
149          addSelectInput("bgstyle", 0, new String JavaDoc[] { "Tile", "Center", "Fill", "Stretch" }, "Transform Image: ", 'T', 25);
150          addCheckboxInput("relative", false, "Align image with desktop", 'A');
151       }
152    }
153
154    protected class BackgroundSetup extends DTab
155    {
156       private DefaultComboBoxModel desktop = new DefaultComboBoxModel(new String JavaDoc[] { "Default", "Solid Color", " ", "Image" });
157       private DefaultComboBoxModel statusbar = new DefaultComboBoxModel(new String JavaDoc[] { "Default", "Solid Color", "Transparent", "Image" });
158       private DefaultComboBoxModel window = new DefaultComboBoxModel(new String JavaDoc[] { " ", "Solid Color", " ", "Image" });
159
160       private SelectInput selector;
161
162       public void refresh()
163       {
164          if (current.equals("statusbar"))
165             selector.setModel(statusbar);
166
167          if (current.equals("desktop"))
168             selector.setModel(desktop);
169
170          if (current.equals("window"))
171             selector.setModel(window);
172
173          super.refresh();
174       }
175
176       public String JavaDoc getTitle()
177       {
178          return "Type";
179       }
180
181       public String JavaDoc getDescription()
182       {
183          return "Choose background options for the component";
184       }
185
186       public void setupDialog()
187       {
188          selector = (SelectInput)addSelectInput("bgtype", 0, new String JavaDoc[] { "Default", "Solid Color", "Transparent", "Image" }, "Type of background: ", 'T', 0);
189       }
190    }
191 }
192
193
194
195
Popular Tags