Statistics
| Revision:

gvsig-3d / org.gvsig.animation3d / trunk / org.gvsig.animation3d / org.gvsig.animation3d.swing / org.gvsig.animation3d.swing.impl / src / main / java / org / gvsig / animation3d / swing / impl / DefaultAnimation3DPanelView.java @ 672

History | View | Annotate | Download (8.41 KB)

1
package org.gvsig.animation3d.swing.impl;
2

    
3
import java.awt.BorderLayout;
4
import java.awt.ComponentOrientation;
5
import java.awt.Container;
6
import java.awt.Dimension;
7

    
8
import javax.swing.Box;
9
import javax.swing.ButtonGroup;
10
import javax.swing.ImageIcon;
11
import javax.swing.JButton;
12
import javax.swing.JComboBox;
13
import javax.swing.JLabel;
14
import javax.swing.JPanel;
15
import javax.swing.JRadioButton;
16
import javax.swing.JScrollPane;
17
import javax.swing.JTable;
18

    
19
import com.jeta.forms.components.line.HorizontalLineComponent;
20
import com.jgoodies.forms.layout.CellConstraints;
21
import com.jgoodies.forms.layout.FormLayout;
22

    
23

    
24
public class DefaultAnimation3DPanelView extends JPanel
25
{
26
   JLabel viewText = new JLabel();
27
   HorizontalLineComponent horizontallinecomponent1 = new HorizontalLineComponent();
28
   JButton close = new JButton();
29
   JTable animations = new JTable();
30
   JButton addAnimation = new JButton();
31
   JTable frames = new JTable();
32
   JButton addFrame = new JButton();
33
   JButton removeFrame = new JButton();
34
   JButton upFrame = new JButton();
35
   JButton downFrame = new JButton();
36
   JButton zoomToFrame = new JButton();
37
   JButton playAnimation = new JButton();
38
   JComboBox viewsCombo = new JComboBox();
39
   JButton removeAnimation = new JButton();
40
   JRadioButton sphericalOption = new JRadioButton();
41
   ButtonGroup buttongroup1 = new ButtonGroup();
42
   JRadioButton flatOption = new JRadioButton();
43

    
44
   /**
45
    * Default constructor
46
    */
47
   public DefaultAnimation3DPanelView()
48
   {
49
      initializePanel();
50
   }
51

    
52
   /**
53
    * Adds fill components to empty cells in the first row and first column of the grid.
54
    * This ensures that the grid spacing will be the same as shown in the designer.
55
    * @param cols an array of column indices in the first row where fill components should be added.
56
    * @param rows an array of row indices in the first column where fill components should be added.
57
    */
58
   void addFillComponents( Container panel, int[] cols, int[] rows )
59
   {
60
      Dimension filler = new Dimension(10,10);
61

    
62
      boolean filled_cell_11 = false;
63
      CellConstraints cc = new CellConstraints();
64
      if ( cols.length > 0 && rows.length > 0 )
65
      {
66
         if ( cols[0] == 1 && rows[0] == 1 )
67
         {
68
            /** add a rigid area  */
69
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
70
            filled_cell_11 = true;
71
         }
72
      }
73

    
74
      for( int index = 0; index < cols.length; index++ )
75
      {
76
         if ( cols[index] == 1 && filled_cell_11 )
77
         {
78
            continue;
79
         }
80
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
81
      }
82

    
83
      for( int index = 0; index < rows.length; index++ )
84
      {
85
         if ( rows[index] == 1 && filled_cell_11 )
86
         {
87
            continue;
88
         }
89
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
90
      }
91

    
92
   }
93

    
94
   /**
95
    * Helper method to load an image file from the CLASSPATH
96
    * @param imageName the package and name of the file to load relative to the CLASSPATH
97
    * @return an ImageIcon instance with the specified image file
98
    * @throws IllegalArgumentException if the image resource cannot be loaded.
99
    */
100
   public ImageIcon loadImage( String imageName )
101
   {
102
      try
103
      {
104
         ClassLoader classloader = getClass().getClassLoader();
105
         java.net.URL url = classloader.getResource( imageName );
106
         if ( url != null )
107
         {
108
            ImageIcon icon = new ImageIcon( url );
109
            return icon;
110
         }
111
      }
112
      catch( Exception e )
113
      {
114
         e.printStackTrace();
115
      }
116
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
117
   }
118

    
119
   /**
120
    * Method for recalculating the component orientation for 
121
    * right-to-left Locales.
122
    * @param orientation the component orientation to be applied
123
    */
124
   public void applyComponentOrientation( ComponentOrientation orientation )
125
   {
126
      // Not yet implemented...
127
      // I18NUtils.applyComponentOrientation(this, orientation);
128
      super.applyComponentOrientation(orientation);
129
   }
130

    
131
   public JPanel createPanel()
132
   {
133
      JPanel jpanel1 = new JPanel();
134
      FormLayout formlayout1 = new FormLayout("FILL:8DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:8DLU:NONE,FILL:DEFAULT:NONE,FILL:8DLU:NONE","CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,FILL:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,FILL:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE");
135
      CellConstraints cc = new CellConstraints();
136
      jpanel1.setLayout(formlayout1);
137

    
138
      viewText.setName("viewText");
139
      viewText.setText("View");
140
      jpanel1.add(viewText,cc.xy(2,2));
141

    
142
      jpanel1.add(horizontallinecomponent1,cc.xywh(2,11,8,1));
143

    
144
      close.setActionCommand("close");
145
      close.setName("close");
146
      close.setText("close");
147
      jpanel1.add(close,cc.xy(9,24));
148

    
149
      animations.setName("animations");
150
      JScrollPane jscrollpane1 = new JScrollPane();
151
      jscrollpane1.setViewportView(animations);
152
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
153
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
154
      jpanel1.add(jscrollpane1,cc.xywh(2,4,6,4));
155

    
156
      addAnimation.setActionCommand("add");
157
      addAnimation.setEnabled(false);
158
      addAnimation.setName("addAnimation");
159
      addAnimation.setText("add");
160
      jpanel1.add(addAnimation,cc.xy(9,4));
161

    
162
      frames.setName("frames");
163
      JScrollPane jscrollpane2 = new JScrollPane();
164
      jscrollpane2.setViewportView(frames);
165
      jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
166
      jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
167
      jpanel1.add(jscrollpane2,cc.xywh(2,13,6,10));
168

    
169
      addFrame.setActionCommand("add");
170
      addFrame.setEnabled(false);
171
      addFrame.setName("addFrame");
172
      addFrame.setText("add");
173
      jpanel1.add(addFrame,cc.xy(9,13));
174

    
175
      removeFrame.setActionCommand("JButton");
176
      removeFrame.setEnabled(false);
177
      removeFrame.setName("removeFrame");
178
      removeFrame.setText("remove");
179
      jpanel1.add(removeFrame,cc.xy(9,15));
180

    
181
      upFrame.setActionCommand("JButton");
182
      upFrame.setEnabled(false);
183
      upFrame.setName("upFrame");
184
      upFrame.setText("up");
185
      jpanel1.add(upFrame,cc.xy(9,17));
186

    
187
      downFrame.setActionCommand("JButton");
188
      downFrame.setEnabled(false);
189
      downFrame.setName("downFrame");
190
      downFrame.setText("down");
191
      jpanel1.add(downFrame,cc.xy(9,19));
192

    
193
      zoomToFrame.setActionCommand("JButton");
194
      zoomToFrame.setEnabled(false);
195
      zoomToFrame.setName("zoomToFrame");
196
      zoomToFrame.setText("zoom_to_frame");
197
      jpanel1.add(zoomToFrame,cc.xy(9,21));
198

    
199
      playAnimation.setActionCommand("play");
200
      playAnimation.setEnabled(false);
201
      playAnimation.setName("playAnimation");
202
      playAnimation.setText("play");
203
      jpanel1.add(playAnimation,cc.xy(9,9));
204

    
205
      viewsCombo.setName("viewsCombo");
206
      jpanel1.add(viewsCombo,cc.xywh(4,2,6,1));
207

    
208
      removeAnimation.setActionCommand("remove");
209
      removeAnimation.setEnabled(false);
210
      removeAnimation.setName("removeAnimation");
211
      removeAnimation.setText("remove");
212
      jpanel1.add(removeAnimation,cc.xy(9,6));
213

    
214
      sphericalOption.setActionCommand("spherical");
215
      sphericalOption.setEnabled(false);
216
      sphericalOption.setName("sphericalOption");
217
      sphericalOption.setText("spherical_view_3d");
218
      buttongroup1.add(sphericalOption);
219
      jpanel1.add(sphericalOption,cc.xywh(2,9,3,1));
220

    
221
      flatOption.setActionCommand("flat");
222
      flatOption.setEnabled(false);
223
      flatOption.setName("flatOption");
224
      flatOption.setText("flat_view_3d");
225
      buttongroup1.add(flatOption);
226
      jpanel1.add(flatOption,cc.xy(6,9));
227

    
228
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8,9,10 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25 });
229
      return jpanel1;
230
   }
231

    
232
   /**
233
    * Initializer
234
    */
235
   protected void initializePanel()
236
   {
237
      setLayout(new BorderLayout());
238
      add(createPanel(), BorderLayout.CENTER);
239
   }
240

    
241

    
242
}