Statistics
| Revision:

root / org.gvsig.legend.vectorfilterexpression.app.mainplugin / trunk / org.gvsig.legend.vectorfilterexpression.app.mainplugin / src / main / java / org / gvsig / symbology / gui / layerproperties / ExpressionSymbolPanelView.java @ 3373

History | View | Annotate | Download (5.54 KB)

1
package org.gvsig.symbology.gui.layerproperties;
2

    
3
import com.jeta.forms.components.separator.TitledSeparator;
4
import com.jeta.open.i18n.I18NUtils;
5
import com.jgoodies.forms.layout.CellConstraints;
6
import com.jgoodies.forms.layout.FormLayout;
7
import java.awt.BorderLayout;
8
import java.awt.ComponentOrientation;
9
import java.awt.Container;
10
import java.awt.Dimension;
11
import javax.swing.Box;
12
import javax.swing.ImageIcon;
13
import javax.swing.JButton;
14
import javax.swing.JFrame;
15
import javax.swing.JPanel;
16
import javax.swing.JScrollPane;
17
import javax.swing.JTextArea;
18

    
19

    
20
public class ExpressionSymbolPanelView extends JPanel
21
{
22
   TitledSeparator lblExpression = new TitledSeparator();
23
   TitledSeparator lblSymbolAndDescriptor = new TitledSeparator();
24
   JPanel pnlExpression = new JPanel();
25
   JButton btnSymbolPreview = new JButton();
26
   JTextArea txtSymbolDescription = new JTextArea();
27

    
28
   /**
29
    * Default constructor
30
    */
31
   public ExpressionSymbolPanelView()
32
   {
33
      initializePanel();
34
   }
35

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

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

    
58
      for( int index = 0; index < cols.length; index++ )
59
      {
60
         if ( cols[index] == 1 && filled_cell_11 )
61
         {
62
            continue;
63
         }
64
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
65
      }
66

    
67
      for( int index = 0; index < rows.length; index++ )
68
      {
69
         if ( rows[index] == 1 && filled_cell_11 )
70
         {
71
            continue;
72
         }
73
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
74
      }
75

    
76
   }
77

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

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

    
115
   public JPanel createPanel()
116
   {
117
      JPanel jpanel1 = new JPanel();
118
      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:50PX:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:NONE,CENTER:2DLU:NONE");
119
      CellConstraints cc = new CellConstraints();
120
      jpanel1.setLayout(formlayout1);
121

    
122
      lblExpression.setName("lblExpression");
123
      lblExpression.setText("_Expression");
124
      jpanel1.add(lblExpression,cc.xy(2,2));
125

    
126
      lblSymbolAndDescriptor.setName("lblSymbolAndDescriptor");
127
      lblSymbolAndDescriptor.setText("_Symbol_and_description");
128
      jpanel1.add(lblSymbolAndDescriptor,cc.xy(2,6));
129

    
130
      pnlExpression.setName("pnlExpression");
131
      jpanel1.add(pnlExpression,cc.xy(2,4));
132

    
133
      jpanel1.add(createPanel1(),cc.xy(2,8));
134
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8,9 });
135
      return jpanel1;
136
   }
137

    
138
   public JPanel createPanel1()
139
   {
140
      JPanel jpanel1 = new JPanel();
141
      FormLayout formlayout1 = new FormLayout("FILL:35PX:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0)","FILL:35PX:NONE");
142
      CellConstraints cc = new CellConstraints();
143
      jpanel1.setLayout(formlayout1);
144

    
145
      btnSymbolPreview.setName("btnSymbolPreview");
146
      jpanel1.add(btnSymbolPreview,new CellConstraints(1,1,1,1,CellConstraints.FILL,CellConstraints.FILL));
147

    
148
      txtSymbolDescription.setName("txtSymbolDescription");
149
      JScrollPane jscrollpane1 = new JScrollPane();
150
      jscrollpane1.setViewportView(txtSymbolDescription);
151
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
152
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
153
      jpanel1.add(jscrollpane1,cc.xy(3,1));
154

    
155
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
156
      return jpanel1;
157
   }
158

    
159
   /**
160
    * Initializer
161
    */
162
   protected void initializePanel()
163
   {
164
      setLayout(new BorderLayout());
165
      add(createPanel(), BorderLayout.CENTER);
166
   }
167

    
168

    
169
}