Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.geodb.app / org.gvsig.geodb.app.mainplugin / src / main / java / org / gvsig / geodb / preferences / layersVisibility / LayersVisibilityReminderView.java @ 45160

History | View | Annotate | Download (4.41 KB)

1
package org.gvsig.geodb.preferences.layersVisibility;
2

    
3
import com.jgoodies.forms.layout.CellConstraints;
4
import com.jgoodies.forms.layout.FormLayout;
5
import java.awt.BorderLayout;
6
import java.awt.ComponentOrientation;
7
import java.awt.Container;
8
import java.awt.Dimension;
9
import javax.swing.Box;
10
import javax.swing.ImageIcon;
11
import javax.swing.JLabel;
12
import javax.swing.JList;
13
import javax.swing.JPanel;
14
import javax.swing.JScrollPane;
15
import org.gvsig.andami.preferences.AbstractPreferencePage;
16

    
17

    
18
public abstract class LayersVisibilityReminderView extends AbstractPreferencePage
19
{
20
   JList lstRemembers = new JList();
21
   JLabel lblTitle = new JLabel();
22

    
23
   /**
24
    * Default constructor
25
    */
26
   public LayersVisibilityReminderView()
27
   {
28
      initializePanel();
29
   }
30

    
31
   /**
32
    * Adds fill components to empty cells in the first row and first column of the grid.
33
    * This ensures that the grid spacing will be the same as shown in the designer.
34
    * @param cols an array of column indices in the first row where fill components should be added.
35
    * @param rows an array of row indices in the first column where fill components should be added.
36
    */
37
   void addFillComponents( Container panel, int[] cols, int[] rows )
38
   {
39
      Dimension filler = new Dimension(10,10);
40

    
41
      boolean filled_cell_11 = false;
42
      CellConstraints cc = new CellConstraints();
43
      if ( cols.length > 0 && rows.length > 0 )
44
      {
45
         if ( cols[0] == 1 && rows[0] == 1 )
46
         {
47
            /** add a rigid area  */
48
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
49
            filled_cell_11 = true;
50
         }
51
      }
52

    
53
      for( int index = 0; index < cols.length; index++ )
54
      {
55
         if ( cols[index] == 1 && filled_cell_11 )
56
         {
57
            continue;
58
         }
59
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
60
      }
61

    
62
      for( int index = 0; index < rows.length; index++ )
63
      {
64
         if ( rows[index] == 1 && filled_cell_11 )
65
         {
66
            continue;
67
         }
68
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
69
      }
70

    
71
   }
72

    
73
   /**
74
    * Helper method to load an image file from the CLASSPATH
75
    * @param imageName the package and name of the file to load relative to the CLASSPATH
76
    * @return an ImageIcon instance with the specified image file
77
    * @throws IllegalArgumentException if the image resource cannot be loaded.
78
    */
79
   public ImageIcon loadImage( String imageName )
80
   {
81
      try
82
      {
83
         ClassLoader classloader = getClass().getClassLoader();
84
         java.net.URL url = classloader.getResource( imageName );
85
         if ( url != null )
86
         {
87
            ImageIcon icon = new ImageIcon( url );
88
            return icon;
89
         }
90
      }
91
      catch( Exception e )
92
      {
93
         e.printStackTrace();
94
      }
95
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
96
   }
97

    
98
   /**
99
    * Method for recalculating the component orientation for 
100
    * right-to-left Locales.
101
    * @param orientation the component orientation to be applied
102
    */
103
   public void applyComponentOrientation( ComponentOrientation orientation )
104
   {
105
      // Not yet implemented...
106
      // I18NUtils.applyComponentOrientation(this, orientation);
107
      super.applyComponentOrientation(orientation);
108
   }
109

    
110
   public JPanel createPanel()
111
   {
112
      JPanel jpanel1 = new JPanel();
113
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE");
114
      CellConstraints cc = new CellConstraints();
115
      jpanel1.setLayout(formlayout1);
116

    
117
      lstRemembers.setName("lstRemembers");
118
      JScrollPane jscrollpane1 = new JScrollPane();
119
      jscrollpane1.setViewportView(lstRemembers);
120
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
121
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
122
      jpanel1.add(jscrollpane1,cc.xy(2,4));
123

    
124
      lblTitle.setName("lblTitle");
125
      lblTitle.setText("_Visibility_scales_remembered_for_the_following_layers");
126
      jpanel1.add(lblTitle,cc.xy(2,2));
127

    
128
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5 });
129
      return jpanel1;
130
   }
131

    
132
   /**
133
    * Initializer
134
    */
135
   protected void initializePanel()
136
   {
137
      setLayout(new BorderLayout());
138
      add(createPanel(), BorderLayout.CENTER);
139
   }
140

    
141

    
142
}