svn-gvsig-desktop / tags / v2_0_0_Build_2058 / extensions / org.gvsig.symbology.app / org.gvsig.symbology.app.importsymbols / src / main / java / org / gvsig / symbology / app / importsymbols / ImportPictureMarkerSymbolsPanelLayout.java @ 39269
History | View | Annotate | Download (7.72 KB)
1 | 38782 | jjdelcerro | package org.gvsig.symbology.app.importsymbols; |
---|---|---|---|
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.ImageIcon; |
||
10 | import javax.swing.JButton; |
||
11 | import javax.swing.JComboBox; |
||
12 | import javax.swing.JLabel; |
||
13 | import javax.swing.JList; |
||
14 | import javax.swing.JPanel; |
||
15 | import javax.swing.JScrollPane; |
||
16 | import javax.swing.JSpinner; |
||
17 | import javax.swing.JTextField; |
||
18 | |||
19 | import com.jgoodies.forms.layout.CellConstraints; |
||
20 | import com.jgoodies.forms.layout.FormLayout; |
||
21 | |||
22 | |||
23 | public class ImportPictureMarkerSymbolsPanelLayout extends JPanel |
||
24 | { |
||
25 | /**
|
||
26 | *
|
||
27 | */
|
||
28 | private static final long serialVersionUID = -5315759500182797864L; |
||
29 | JLabel labelTitle = new JLabel(); |
||
30 | JLabel labelImagesToImport = new JLabel(); |
||
31 | JLabel labelFolderName = new JLabel(); |
||
32 | JTextField ctrltFolderName = new JTextField(); |
||
33 | JList ctrlExistingFolders = new JList(); |
||
34 | JLabel labelSize = new JLabel(); |
||
35 | JSpinner ctrlDefaultSize = new JSpinner(); |
||
36 | JButton ctrlCancel = new JButton(); |
||
37 | JButton ctrlImport = new JButton(); |
||
38 | JLabel labelOverwriteOptions = new JLabel(); |
||
39 | JComboBox ctrlOverwriteOptions = new JComboBox(); |
||
40 | JList ctrlImagesToImport = new JList(); |
||
41 | JButton ctrlBrowseImagesToImport = new JButton(); |
||
42 | |||
43 | /**
|
||
44 | * Default constructor
|
||
45 | */
|
||
46 | public ImportPictureMarkerSymbolsPanelLayout()
|
||
47 | { |
||
48 | initializePanel(); |
||
49 | } |
||
50 | |||
51 | /**
|
||
52 | * Adds fill components to empty cells in the first row and first column of the grid.
|
||
53 | * This ensures that the grid spacing will be the same as shown in the designer.
|
||
54 | * @param cols an array of column indices in the first row where fill components should be added.
|
||
55 | * @param rows an array of row indices in the first column where fill components should be added.
|
||
56 | */
|
||
57 | void addFillComponents( Container panel, int[] cols, int[] rows ) |
||
58 | { |
||
59 | Dimension filler = new Dimension(10,10); |
||
60 | |||
61 | boolean filled_cell_11 = false; |
||
62 | CellConstraints cc = new CellConstraints();
|
||
63 | if ( cols.length > 0 && rows.length > 0 ) |
||
64 | { |
||
65 | if ( cols[0] == 1 && rows[0] == 1 ) |
||
66 | { |
||
67 | /** add a rigid area */
|
||
68 | panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
||
69 | filled_cell_11 = true;
|
||
70 | } |
||
71 | } |
||
72 | |||
73 | for( int index = 0; index < cols.length; index++ ) |
||
74 | { |
||
75 | if ( cols[index] == 1 && filled_cell_11 ) |
||
76 | { |
||
77 | continue;
|
||
78 | } |
||
79 | panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
||
80 | } |
||
81 | |||
82 | for( int index = 0; index < rows.length; index++ ) |
||
83 | { |
||
84 | if ( rows[index] == 1 && filled_cell_11 ) |
||
85 | { |
||
86 | continue;
|
||
87 | } |
||
88 | panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
||
89 | } |
||
90 | |||
91 | } |
||
92 | |||
93 | /**
|
||
94 | * Helper method to load an image file from the CLASSPATH
|
||
95 | * @param imageName the package and name of the file to load relative to the CLASSPATH
|
||
96 | * @return an ImageIcon instance with the specified image file
|
||
97 | * @throws IllegalArgumentException if the image resource cannot be loaded.
|
||
98 | */
|
||
99 | public ImageIcon loadImage( String imageName ) |
||
100 | { |
||
101 | try
|
||
102 | { |
||
103 | ClassLoader classloader = getClass().getClassLoader();
|
||
104 | java.net.URL url = classloader.getResource( imageName ); |
||
105 | if ( url != null ) |
||
106 | { |
||
107 | ImageIcon icon = new ImageIcon( url ); |
||
108 | return icon;
|
||
109 | } |
||
110 | } |
||
111 | catch( Exception e ) |
||
112 | { |
||
113 | e.printStackTrace(); |
||
114 | } |
||
115 | throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
||
116 | } |
||
117 | |||
118 | /**
|
||
119 | * Method for recalculating the component orientation for
|
||
120 | * right-to-left Locales.
|
||
121 | * @param orientation the component orientation to be applied
|
||
122 | */
|
||
123 | public void applyComponentOrientation( ComponentOrientation orientation ) |
||
124 | { |
||
125 | // Not yet implemented...
|
||
126 | // I18NUtils.applyComponentOrientation(this, orientation);
|
||
127 | super.applyComponentOrientation(orientation);
|
||
128 | } |
||
129 | |||
130 | public JPanel createPanel() |
||
131 | { |
||
132 | JPanel jpanel1 = new JPanel(); |
||
133 | 38806 | jjdelcerro | FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,FILL:PREF:GROW(1.0),CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
134 | 38782 | jjdelcerro | CellConstraints cc = new CellConstraints();
|
135 | jpanel1.setLayout(formlayout1); |
||
136 | |||
137 | labelTitle.setName("labelTitle");
|
||
138 | 38806 | jjdelcerro | labelTitle.setText("_Import_images_as_picture_marker_symbols");
|
139 | 38782 | jjdelcerro | jpanel1.add(labelTitle,cc.xywh(2,2,6,1)); |
140 | |||
141 | labelImagesToImport.setName("labelImagesToImport");
|
||
142 | labelImagesToImport.setText("_Images_to_import");
|
||
143 | jpanel1.add(labelImagesToImport,cc.xywh(2,4,6,1)); |
||
144 | |||
145 | labelFolderName.setName("labelFolderName");
|
||
146 | 38806 | jjdelcerro | labelFolderName.setText("_Folder_name_for_creatimg_the_symbols");
|
147 | 38782 | jjdelcerro | jpanel1.add(labelFolderName,cc.xywh(2,7,6,1)); |
148 | |||
149 | ctrltFolderName.setName("ctrltFolderName");
|
||
150 | jpanel1.add(ctrltFolderName,cc.xywh(3,8,5,1)); |
||
151 | |||
152 | ctrlExistingFolders.setName("ctrlExistingFolders");
|
||
153 | JScrollPane jscrollpane1 = new JScrollPane(); |
||
154 | jscrollpane1.setViewportView(ctrlExistingFolders); |
||
155 | jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||
156 | jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||
157 | 38806 | jjdelcerro | jpanel1.add(jscrollpane1,new CellConstraints(3,9,5,1,CellConstraints.FILL,CellConstraints.TOP)); |
158 | 38782 | jjdelcerro | |
159 | labelSize.setName("labelSize");
|
||
160 | labelSize.setText("_Default_size_to_use_in_symbols");
|
||
161 | jpanel1.add(labelSize,cc.xywh(2,11,6,1)); |
||
162 | |||
163 | ctrlDefaultSize.setName("ctrlDefaultSize");
|
||
164 | jpanel1.add(ctrlDefaultSize,cc.xywh(3,12,5,1)); |
||
165 | |||
166 | ctrlCancel.setActionCommand("_Cancel");
|
||
167 | ctrlCancel.setName("ctrlCancel");
|
||
168 | ctrlCancel.setText("_Cancel");
|
||
169 | jpanel1.add(ctrlCancel,cc.xy(5,17)); |
||
170 | |||
171 | ctrlImport.setActionCommand("_import");
|
||
172 | ctrlImport.setName("ctrlImport");
|
||
173 | ctrlImport.setText("_import");
|
||
174 | jpanel1.add(ctrlImport,cc.xy(7,17)); |
||
175 | |||
176 | labelOverwriteOptions.setName("labelOverwriteOptions");
|
||
177 | labelOverwriteOptions.setText("_Overwrite_options");
|
||
178 | jpanel1.add(labelOverwriteOptions,cc.xywh(2,14,6,1)); |
||
179 | |||
180 | ctrlOverwriteOptions.setName("ctrlOverwriteOptions");
|
||
181 | ctrlOverwriteOptions.addItem("_Ask_to_user");
|
||
182 | ctrlOverwriteOptions.addItem("_Dont_overwrite");
|
||
183 | ctrlOverwriteOptions.addItem("_Overwrite_always");
|
||
184 | jpanel1.add(ctrlOverwriteOptions,cc.xywh(3,15,5,1)); |
||
185 | |||
186 | ctrlImagesToImport.setName("ctrlImagesToImport");
|
||
187 | JScrollPane jscrollpane2 = new JScrollPane(); |
||
188 | jscrollpane2.setViewportView(ctrlImagesToImport); |
||
189 | jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||
190 | jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||
191 | 38806 | jjdelcerro | jpanel1.add(jscrollpane2,new CellConstraints(3,5,5,1,CellConstraints.DEFAULT,CellConstraints.TOP)); |
192 | 38782 | jjdelcerro | |
193 | ctrlBrowseImagesToImport.setActionCommand("_Browse");
|
||
194 | ctrlBrowseImagesToImport.setName("ctrlBrowseImagesToImport");
|
||
195 | ctrlBrowseImagesToImport.setText("_Select_images");
|
||
196 | 38806 | jjdelcerro | jpanel1.add(ctrlBrowseImagesToImport,new CellConstraints(3,6,5,1,CellConstraints.RIGHT,CellConstraints.DEFAULT)); |
197 | 38782 | jjdelcerro | |
198 | addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 }); |
||
199 | return jpanel1;
|
||
200 | } |
||
201 | |||
202 | /**
|
||
203 | * Initializer
|
||
204 | */
|
||
205 | protected void initializePanel() |
||
206 | { |
||
207 | setLayout(new BorderLayout()); |
||
208 | add(createPanel(), BorderLayout.CENTER);
|
||
209 | } |
||
210 | |||
211 | |||
212 | } |