Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.impl / src / main / java / org / gvsig / export / swing / impl / panels / ExportProgressPanelView.java @ 44408

History | View | Annotate | Download (5.22 KB)

1 44386 omartinez
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.export.swing.impl.panels;
7
import com.jgoodies.forms.layout.CellConstraints;
8
import com.jgoodies.forms.layout.FormLayout;
9
import java.awt.BorderLayout;
10
import java.awt.ComponentOrientation;
11
import java.awt.Container;
12
import java.awt.Dimension;
13
import java.awt.event.WindowAdapter;
14
import java.awt.event.WindowEvent;
15
import javax.swing.Box;
16
import javax.swing.ImageIcon;
17
import javax.swing.JButton;
18
import javax.swing.JFrame;
19
import javax.swing.JPanel;
20
import javax.swing.border.EmptyBorder;
21
22
23
public class ExportProgressPanelView extends JPanel
24
{
25
   JPanel jpnMain = new JPanel();
26
   JButton btnBookmark = new JButton();
27
28
   /**
29
    * Default constructor
30
    */
31
   public ExportProgressPanelView()
32
   {
33
      initializePanel();
34
   }
35
36
   /**
37
    * Main method for panel
38
    */
39
   public static void main(String[] args)
40
   {
41
      JFrame frame = new JFrame();
42
      frame.setSize(600, 400);
43
      frame.setLocation(100, 100);
44
      frame.getContentPane().add(new ExportProgressPanelView());
45
      frame.setVisible(true);
46
47
      frame.addWindowListener( new WindowAdapter()
48
      {
49
         public void windowClosing( WindowEvent evt )
50
         {
51
            System.exit(0);
52
         }
53
      });
54
   }
55
56
   /**
57
    * Adds fill components to empty cells in the first row and first column of the grid.
58
    * This ensures that the grid spacing will be the same as shown in the designer.
59
    * @param cols an array of column indices in the first row where fill components should be added.
60
    * @param rows an array of row indices in the first column where fill components should be added.
61
    */
62
   void addFillComponents( Container panel, int[] cols, int[] rows )
63
   {
64
      Dimension filler = new Dimension(10,10);
65
66
      boolean filled_cell_11 = false;
67
      CellConstraints cc = new CellConstraints();
68
      if ( cols.length > 0 && rows.length > 0 )
69
      {
70
         if ( cols[0] == 1 && rows[0] == 1 )
71
         {
72
            /** add a rigid area  */
73
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
74
            filled_cell_11 = true;
75
         }
76
      }
77
78
      for( int index = 0; index < cols.length; index++ )
79
      {
80
         if ( cols[index] == 1 && filled_cell_11 )
81
         {
82
            continue;
83
         }
84
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
85
      }
86
87
      for( int index = 0; index < rows.length; index++ )
88
      {
89
         if ( rows[index] == 1 && filled_cell_11 )
90
         {
91
            continue;
92
         }
93
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
94
      }
95
96
   }
97
98
   /**
99
    * Helper method to load an image file from the CLASSPATH
100
    * @param imageName the package and name of the file to load relative to the CLASSPATH
101
    * @return an ImageIcon instance with the specified image file
102
    * @throws IllegalArgumentException if the image resource cannot be loaded.
103
    */
104
   public ImageIcon loadImage( String imageName )
105
   {
106
      try
107
      {
108
         ClassLoader classloader = getClass().getClassLoader();
109
         java.net.URL url = classloader.getResource( imageName );
110
         if ( url != null )
111
         {
112
            ImageIcon icon = new ImageIcon( url );
113
            return icon;
114
         }
115
      }
116
      catch( Exception e )
117
      {
118
         e.printStackTrace();
119
      }
120
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
121
   }
122
123
   /**
124
    * Method for recalculating the component orientation for
125
    * right-to-left Locales.
126
    * @param orientation the component orientation to be applied
127
    */
128
   public void applyComponentOrientation( ComponentOrientation orientation )
129
   {
130
      // Not yet implemented...
131
      // I18NUtils.applyComponentOrientation(this, orientation);
132
      super.applyComponentOrientation(orientation);
133
   }
134
135
   public JPanel createPanel()
136
   {
137
      JPanel jpanel1 = new JPanel();
138
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:347PX:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:14PX:NONE,FILL:165PX:GROW(1.0),CENTER:DEFAULT:NONE");
139
      CellConstraints cc = new CellConstraints();
140
      jpanel1.setLayout(formlayout1);
141
142
      jpnMain.setName("jpnMain");
143
      jpanel1.add(jpnMain,cc.xy(2,3));
144
145
      jpanel1.add(createPanel1(),new CellConstraints(2,1,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT));
146
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4 });
147
      return jpanel1;
148
   }
149
150
   public JPanel createPanel1()
151
   {
152
      JPanel jpanel1 = new JPanel();
153
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:7PX:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
154
      CellConstraints cc = new CellConstraints();
155
      jpanel1.setLayout(formlayout1);
156
157
      btnBookmark.setName("btnBookmark");
158
      EmptyBorder emptyborder1 = new EmptyBorder(0,0,0,0);
159
      btnBookmark.setBorder(emptyborder1);
160
      jpanel1.add(btnBookmark,cc.xy(3,1));
161
162
      addFillComponents(jpanel1,new int[]{ 1,2 },new int[]{ 1 });
163
      return jpanel1;
164
   }
165
166
   /**
167
    * Initializer
168
    */
169
   protected void initializePanel()
170
   {
171
      setLayout(new BorderLayout());
172
      add(createPanel(), BorderLayout.CENTER);
173
   }
174
175
176
}