Revision 35526

View differences:

tags/v2_0_0_Build_2028/libUIComponent/src/org/gvsig/app/gui/panels/ColorPanel.java
1

  
2
/*
3
 * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
4
 * for visualizing and manipulating spatial features with geometry and attributes.
5
 *
6
 * Copyright (C) 2003 Vivid Solutions
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
 *
22
 * For more information, contact:
23
 *
24
 * Vivid Solutions
25
 * Suite #1A
26
 * 2328 Government Street
27
 * Victoria BC  V8T 5G5
28
 * Canada
29
 *
30
 * (250)385-6040
31
 * www.vividsolutions.com
32
 */
33

  
34
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
35
 *
36
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
37
 *
38
 * This program is free software; you can redistribute it and/or
39
 * modify it under the terms of the GNU General Public License
40
 * as published by the Free Software Foundation; either version 2
41
 * of the License, or (at your option) any later version.
42
 *
43
 * This program is distributed in the hope that it will be useful,
44
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
45
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
46
 * GNU General Public License for more details.
47
 *
48
 * You should have received a copy of the GNU General Public License
49
 * along with this program; if not, write to the Free Software
50
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
51
 *
52
 * For more information, contact:
53
 *
54
 *  Generalitat Valenciana
55
 *   Conselleria d'Infraestructures i Transport
56
 *   Av. Blasco Ib??ez, 50
57
 *   46010 VALENCIA
58
 *   SPAIN
59
 *
60
 *      +34 963862235
61
 *   gvsig@gva.es
62
 *      www.gvsig.gva.es
63
 *
64
 *    or
65
 *
66
 *   IVER T.I. S.A
67
 *   Salamanca 50
68
 *   46005 Valencia
69
 *   Spain
70
 *
71
 *   +34 963163400
72
 *   dac@iver.es
73
 */
74
package org.gvsig.app.gui.panels;
75

  
76
import java.awt.BasicStroke;
77
import java.awt.Color;
78
import java.awt.Graphics;
79
import java.awt.Graphics2D;
80

  
81
import javax.swing.JPanel;
82

  
83

  
84
/**
85
 * Displays a colour.
86
 */
87
public class ColorPanel extends JPanel {
88
    private Color fillColor = Color.red;
89
    private Color lineColor = Color.green;
90
    private int margin = 0;
91

  
92
    public ColorPanel() {
93
        setBackground(Color.white);
94
    }
95

  
96
    protected void paintComponent(Graphics g) {
97
        super.paintComponent(g);
98

  
99
        //Before I simply set the ColorPanel's background colour. But I found this
100
        //caused weird paint effects e.g. a second copy of the panel appearing
101
        //at the top left corner of the rendered image. [Jon Aquino].
102
        //<<TODO:DESIGN>> Use the GraphicsState class [Jon Aquino]
103
        Color originalColor = g.getColor();
104
        g.setColor(getBackground());
105
        ((Graphics2D)g).setStroke(fillStroke);
106
        g.fillRect(0, 0, getWidth() - 1, getHeight() - 1);
107
        g.setColor(fillColor);
108
        g.fillRect(margin, margin, getWidth() - 1 - margin - margin,
109
            getHeight() - 1 - margin - margin);
110

  
111
        if (lineColor != null) {
112
            g.setColor(lineColor);
113
            ((Graphics2D)g).setStroke(lineStroke);
114

  
115
            //-1 to ensure the rectangle doesn't extend past the panel [Jon Aquino]
116
            g.drawRect(margin, margin, getWidth() - 1 - margin - margin,
117
                getHeight() - 1 - margin - margin);
118
        }
119

  
120
        //<<TODO:DESIGN>> Put the next line in a finally block [Jon Aquino]
121
        g.setColor(originalColor);
122
    }
123

  
124
    /** Workaround for bug 4238829 in the Java bug database */
125
    public void setBounds(int x, int y, int w, int h) {
126
        super.setBounds(x, y, w, h);
127
        validate();
128
    }
129

  
130
    public void setFillColor(Color fillColor) {
131
        this.fillColor = fillColor;
132
    }
133

  
134
    /**
135
     * @param lineColor the new line colour, or null to not draw the line
136
     */
137
    public void setLineColor(Color lineColor) {
138
        this.lineColor = lineColor;
139
    }
140

  
141
    public void setMargin(int margin) {
142
        this.margin = margin;
143
    }
144
    public Color getFillColor() {
145
        return fillColor;
146
    }
147

  
148
    public Color getLineColor() {
149
        return lineColor;
150
    }
151
    
152
    private BasicStroke fillStroke = new BasicStroke(1);
153
    private int lineWidth = 1;
154
    private BasicStroke lineStroke = new BasicStroke(lineWidth);
155
    
156
    public void setLineWidth(int lineWidth) {
157
        lineStroke = new BasicStroke(lineWidth);
158
        this.lineWidth = lineWidth;
159
    }
160
    
161
    public int getLineWidth() {
162
        return lineWidth;
163
    }
164

  
165
}
0 166

  
tags/v2_0_0_Build_2028/libUIComponent/src/org/gvsig/app/gui/panels/ColorChooserPanel.java
1

  
2
/*
3
 * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
4
 * for visualizing and manipulating spatial features with geometry and attributes.
5
 *
6
 * Copyright (C) 2003 Vivid Solutions
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
 *
22
 * For more information, contact:
23
 *
24
 * Vivid Solutions
25
 * Suite #1A
26
 * 2328 Government Street
27
 * Victoria BC  V8T 5G5
28
 * Canada
29
 *
30
 * (250)385-6040
31
 * www.vividsolutions.com
32
 */
33

  
34
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
35
 *
36
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
37
 *
38
 * This program is free software; you can redistribute it and/or
39
 * modify it under the terms of the GNU General Public License
40
 * as published by the Free Software Foundation; either version 2
41
 * of the License, or (at your option) any later version.
42
 *
43
 * This program is distributed in the hope that it will be useful,
44
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
45
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
46
 * GNU General Public License for more details.
47
 *
48
 * You should have received a copy of the GNU General Public License
49
 * along with this program; if not, write to the Free Software
50
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
51
 *
52
 * For more information, contact:
53
 *
54
 *  Generalitat Valenciana
55
 *   Conselleria d'Infraestructures i Transport
56
 *   Av. Blasco Ib??ez, 50
57
 *   46010 VALENCIA
58
 *   SPAIN
59
 *
60
 *      +34 963862235
61
 *   gvsig@gva.es
62
 *      www.gvsig.gva.es
63
 *
64
 *    or
65
 *
66
 *   IVER T.I. S.A
67
 *   Salamanca 50
68
 *   46005 Valencia
69
 *   Spain
70
 *
71
 *   +34 963163400
72
 *   dac@iver.es
73
 */
74
package org.gvsig.app.gui.panels;
75

  
76
import java.awt.Color;
77
import java.awt.Dimension;
78
import java.awt.GridBagConstraints;
79
import java.awt.GridBagLayout;
80
import java.awt.GridLayout;
81
import java.awt.event.ActionEvent;
82
import java.awt.event.ActionListener;
83
import java.util.ArrayList;
84
import java.util.Iterator;
85

  
86
import javax.swing.BorderFactory;
87
import javax.swing.JButton;
88
import javax.swing.JCheckBox;
89
import javax.swing.JColorChooser;
90
import javax.swing.JFrame;
91
import javax.swing.JLabel;
92
import javax.swing.JPanel;
93
import javax.swing.JSlider;
94
import javax.swing.SwingUtilities;
95
import javax.swing.event.ChangeEvent;
96
import javax.swing.event.ChangeListener;
97

  
98
import org.gvsig.i18n.Messages;
99

  
100

  
101

  
102
/**
103
 * A custom Colour Scheme Browser - custom choices based on JColorChooser.
104
 */
105

  
106
public class ColorChooserPanel extends JPanel {
107
	private GridBagLayout gridBagLayout1 = new GridBagLayout();
108
	private JButton changeButton = new JButton();
109

  
110

  
111
    //{DEFECT-PREVENTION} In accessors, it's better to use "workbench = newWorkbench"
112
    //rather than "this.workbench = workbench", because otherwise if you misspell the
113
    //argument, Java won't complain! We should do this everywhere. [Jon Aquino]
114
    private JPanel outerColorPanel = new JPanel();
115
    private ColorPanel colorPanel = new ColorPanel();
116
    private Color color = Color.black;
117
//    private int alpha;
118
    private Dimension dim = new Dimension(100, 22);
119
    private Dimension dim2 = new Dimension(dim.width, dim.height*2+5);
120
    private ArrayList<ActionListener> actionListeners = new ArrayList<ActionListener>();
121
    private boolean withTransp;
122
    private boolean withTranspPerc;
123
	private boolean withNoFill;
124
    private JCheckBox chkUseColor;
125
	private JSlider sldTransparency;
126
	private JLabel lblTransparency;
127
	private boolean muteSldTransparency = false;
128
	private double perc = 0.392156863 ;/*100/255*/
129
	private ChangeListener sldAction = new ChangeListener() {
130
		public void stateChanged(ChangeEvent e) {
131
			if (!muteSldTransparency) {
132
				int alphaValue = sldTransparency.getValue();
133
				setAlpha(alphaValue);
134

  
135
				if(withTranspPerc) {
136
					int percValue = (int) (alphaValue * perc);
137
					lblTransparency.setText( String.valueOf(percValue) + "%");
138
				}
139
				fireActionPerformed();
140
			}
141
		}
142

  
143
	};
144

  
145

  
146
    public ColorChooserPanel() {
147
        this(false);
148
    }
149

  
150
    /**
151
	 * Constructor method
152
	 *
153
	 * @param withTransparencySlider boolean that specifies if the user
154
	 * wants a slider with the color chooser panel to control the transparency
155
	 * of the selected color.Also, it will appear a text which specifies the transparency percentage.
156
	 * @param withNoFill boolean that specifies if the color chooser panel
157
	 * allows a null value for the color selected (true case). If this values
158
	 * is false, when the color selected is null then black color is assigned
159
	 * automatically.
160
	 */
161
    public ColorChooserPanel(boolean withTransparencySlider) {
162
    	this(withTransparencySlider,false);
163

  
164
    }
165

  
166
	/**
167
	 * Constructor method
168
	 *
169
	 * @param withTransparencySlider boolean that specifies if the user
170
	 * wants a slider with the color chooser panel to control the transparency
171
	 * of the selected color.
172
	 * @param withNoFill boolean that specifies if the color chooser panel
173
	 * allows a null value for the color selected (true case). If this values
174
	 * is false, when the color selected is null then black color is assigned
175
	 * automatically.
176
	 */
177
	public ColorChooserPanel(boolean withTransparencySlider, boolean withNoFill) {
178

  
179
		this.withTransp=withTransparencySlider;
180
		this.withTranspPerc=withTransparencySlider;
181
		this.withNoFill=withNoFill;
182

  
183
		try {
184
			if (withTransp) {
185
				sldTransparency = new JSlider(0, 255);
186
				sldTransparency.addChangeListener(sldAction);
187
				int width = withNoFill ? dim2.width - 40 : dim2.width;
188
				sldTransparency.setPreferredSize(new Dimension(width-5, dim2.height/2));
189
				sldTransparency.setToolTipText(Messages.getText("transparencia"));
190

  
191
				if(withTranspPerc) {
192
					lblTransparency = new JLabel();
193
					int percValue = (int) (sldTransparency.getValue() * perc);
194
					lblTransparency.setText(String.valueOf(percValue) +"%");
195
					lblTransparency.setPreferredSize(new Dimension(40,20));
196
				}
197

  
198
				sldTransparency.setValue(255);
199

  
200
			}
201
			jbInit();
202
			colorPanel.setLineColor(null);
203
			changeButton.setToolTipText(Messages.getText("browse"));
204

  
205
		} catch (Exception e) {
206
			e.printStackTrace();
207
		}
208
	}
209

  
210
	private void jbInit() throws Exception {
211
		JPanel pane = new JPanel(new GridBagLayout());
212
		GridBagConstraints c = new GridBagConstraints();
213

  
214
		changeButton.setText("...");
215
		changeButton.addActionListener(new java.awt.event.ActionListener() {
216
			public void actionPerformed(ActionEvent e) {
217
				changeButton_actionPerformed(e);
218
			}
219
		});
220
		outerColorPanel.setBorder(BorderFactory.createLoweredBevelBorder());
221
		outerColorPanel.setPreferredSize(new Dimension(dim.width/2, dim.height));
222
		outerColorPanel.setBackground(Color.white);
223

  
224

  
225
		c.fill = GridBagConstraints.HORIZONTAL;
226
		c.gridx = 1;
227
		c.gridy = 0;
228
		c.gridwidth = 2;
229
		pane.add(outerColorPanel,c);
230

  
231
		c.fill = GridBagConstraints.HORIZONTAL;
232
		c.gridx = 3;
233
		c.gridy = 0;
234
		c.gridwidth = 1;
235
		pane.add(changeButton,c);
236
		outerColorPanel.add(colorPanel);
237

  
238
		if(withNoFill) {
239
			chkUseColor = new JCheckBox();
240
			chkUseColor.setSelected(true);
241
			c.fill = GridBagConstraints.HORIZONTAL;
242
			c.gridwidth = 1;
243
			c.gridx = 0;
244
			c.gridy = 1;
245

  
246

  
247
			chkUseColor.addActionListener(new java.awt.event.ActionListener() {
248
				public void actionPerformed(ActionEvent e) {
249
					useColor_actionPerformed(e);
250
				}
251
			});
252
			pane.add(chkUseColor,c);
253
		}
254

  
255

  
256
		if (withTransp) {
257

  
258
			c.fill = GridBagConstraints.HORIZONTAL;
259
			c.gridwidth = 3;
260
			c.gridx = 1;
261
			c.gridy = 1;
262
			pane.add(sldTransparency,c);
263

  
264

  
265
			if(withTranspPerc) {
266
				c.fill = GridBagConstraints.HORIZONTAL;
267
				c.gridwidth = 3;
268
				c.gridx = 4;
269
				c.gridy = 1;
270
				pane.add(lblTransparency,c);
271
			}
272

  
273
		}
274

  
275
		add(pane);
276
	}
277

  
278
    private void changeButton_actionPerformed(ActionEvent e) {
279
    	Color newColor = JColorChooser.showDialog(SwingUtilities.windowForComponent(this), Messages.getText("choose_color"), color);
280

  
281
        if (newColor == null) {
282
            return;
283
        }
284

  
285
        setColor(newColor);
286
        fireActionPerformed();
287
    }
288

  
289
    /**
290
	 * Returns true if the check box of the color chooser panel is selected.
291
	 * False otherwise.
292
	 * @return boolean true if the check box is selected. Otherwise, false.
293
	 */
294
	public boolean getUseColorisSelected() {
295
		if(withNoFill)
296
			return chkUseColor.isSelected();
297
		return false;
298
	}
299
	/**
300
	 * Sets the check box of the color chooser panel
301

  
302
	 * @param b boolean true if the user wants to select it.Otherwise, false.
303
	 */
304
	public void setUseColorIsSelected(boolean b) {
305
		if(withNoFill)
306
			chkUseColor.setSelected(b);
307
	}
308
	/**
309
	 * Controls the events when the check box of the color chooser panel
310
	 * is modified
311
	 *
312
	 * @param e Action Event
313
	 */
314
	private void useColor_actionPerformed(ActionEvent e) {
315
		if(chkUseColor.isSelected())
316
			setColor(color);
317
		else setColor(null);
318
		fireActionPerformed();
319
	}
320

  
321
     public void addActionListener(ActionListener l) {
322
        actionListeners.add(l);
323
    }
324

  
325
    public void removeActionListener(ActionListener l) {
326
        actionListeners.remove(l);
327
    }
328

  
329
    protected void fireActionPerformed() {
330
        for (Iterator<ActionListener> i = actionListeners.iterator(); i.hasNext();) {
331
            i.next().actionPerformed(new ActionEvent(this, 0, null));
332
        }
333
    }
334
	/**
335
	 * Sets the color of the chooser panel.
336
	 *
337
	 * @param color Color to be selected.
338
	 */
339
	public void setColor(Color color) {
340

  
341
		if( color != null) {
342
			this.color = color;
343
			setAlpha(color.getAlpha());
344
			updateColorPanel();
345
		}
346

  
347
	}
348

  
349
	/**
350
	 * Sets the alpha value of the color selected in the color chooser
351
	 * panel.
352
	 *
353
	 * @param alpha Alpha value of the color.
354
	 */
355
	public void setAlpha(int alpha) {
356
		muteSldTransparency = true;
357

  
358
		if (color != null)
359
			color=alphaColor(color,alpha);
360

  
361
		if (withTransp) {
362
			sldTransparency.setValue(alpha);
363
			sldTransparency.validate();
364
			int percValue = (int) (alpha * perc);
365
			lblTransparency.setText( String.valueOf(percValue)+ "%");
366
		}
367

  
368
		updateColorPanel();
369
		muteSldTransparency = false;
370
//		fireActionPerformed();
371
	}
372

  
373
	public int getAlpha() {
374
		if (withTransp) {
375
			return sldTransparency.getValue();
376
		} else {
377
			return color.getAlpha();
378
		}
379

  
380
	}
381

  
382
    private void updateColorPanel() {
383
        colorPanel.setFillColor(color);
384
        colorPanel.repaint();
385
    }
386

  
387

  
388
	/**
389
	 * Obtains the selected color in the color chooser panel.
390
	 *
391
	 * @return color the selected color
392
	 */
393
	public Color getColor() {
394
		return color;
395
	}
396

  
397
	public void disabledWithTransparency() {
398
		changeButton.setEnabled(false);
399
		if(withNoFill)
400
			chkUseColor.setEnabled(false);
401

  
402
	}
403

  
404
	@Override
405
	public void setEnabled(boolean newEnabled) {
406

  
407
		changeButton.setEnabled(newEnabled);
408
		if(withTransp) {
409
			sldTransparency.setEnabled(newEnabled);
410
		}
411
		if(withTranspPerc) {
412
			lblTransparency.setEnabled(newEnabled);
413
		}
414
		if(withNoFill) {
415
			chkUseColor.setEnabled(newEnabled);
416
		}
417

  
418
	}
419

  
420
	public static void main(String[] args) {
421
		JFrame f = new JFrame();
422

  
423
		final ColorChooserPanel ce2 = new ColorChooserPanel(true,true);
424

  
425
		JPanel content = new JPanel(new GridLayout(2, 1));
426

  
427
		content.add(ce2);
428

  
429

  
430
		f.setContentPane(content);
431
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
432
		f.pack();
433
		f.setVisible(true);
434

  
435
	}
436

  
437
    private Color alphaColor(Color color, int alpha) {
438
        return new Color(color.getRed(), color.getGreen(), color.getBlue(),
439
            alpha);
440
    }
441

  
442
}
0 443

  
tags/v2_0_0_Build_2028/libUIComponent/src/org/gvsig/gui/javax/swing/jLabelCellRenderer/JLabelCellRenderer.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.gui.javax.swing.jLabelCellRenderer;
42

  
43
import java.awt.Color;
44
import java.awt.Component;
45
import java.io.Serializable;
46

  
47
import javax.swing.DefaultListCellRenderer;
48
import javax.swing.JLabel;
49
import javax.swing.JList;
50
import javax.swing.ListCellRenderer;
51

  
52
/**
53
 * This class allows render a JLabel in a Cell of other graphic component (as a JList)
54
 * 
55
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
56
 */
57
public class JLabelCellRenderer extends DefaultListCellRenderer implements ListCellRenderer, Serializable {
58
	private static final long serialVersionUID = -3820198983465837422L;
59

  
60
	/* (non-Javadoc)
61
	 * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
62
	 */
63
	public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
64
        /* The DefaultListCellRenderer class will take care of
65
         * the JLabels text property, it's foreground and background
66
         * colors, and so on.
67
         */
68
        super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
69
		
70
		// Set the text property, background and foreground color
71
        if (value instanceof JLabel) {
72
        	setText(((JLabel)value).getText());
73
    		setBackground(((JLabel)value).getBackground());
74
    		
75
    		if (isSelected)
76
    			setForeground(Color.red);
77
    		else
78
    			setForeground(((JLabel)value).getForeground());
79
        }
80

  
81
		return this;
82
	}
83
}
0 84

  
tags/v2_0_0_Build_2028/libUIComponent/src/org/gvsig/gui/javax/swing/jLabelCellRenderer/JLabelCellRendererWithTextAsToolTipText.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.gui.javax.swing.jLabelCellRenderer;
42

  
43
import java.awt.Color;
44
import java.awt.Component;
45
import java.io.Serializable;
46

  
47
import javax.swing.JLabel;
48
import javax.swing.JList;
49
import javax.swing.ListCellRenderer;
50
/**
51
 * This class allows render a JLabel in a Cell of other graphic component (as a JList) and
52
 * if mouse is on this cell, a tool tip text with the text value will be shown
53
 * 
54
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
55
 */
56
public class JLabelCellRendererWithTextAsToolTipText extends JLabelCellRenderer implements ListCellRenderer, Serializable {
57
	private static final long serialVersionUID = 4799667459274027212L;
58

  
59
	/* (non-Javadoc)
60
	 * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
61
	 */
62
	public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
63
        /* The DefaultListCellRenderer class will take care of
64
         * the JLabels text property, it's foreground and background
65
         * colors, and so on.
66
         */
67
        super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
68
		
69
		// Set the text property, background and foreground color
70
        if (value instanceof JLabel) {
71
        	setText(((JLabel)value).getText());
72
    		setBackground(((JLabel)value).getBackground());
73
    		
74
    		if (isSelected)
75
    			setForeground(Color.red);
76
    		else
77
    			setForeground(((JLabel)value).getForeground());
78
        }
79
        
80
		return this;
81
	}
82
	
83
	/*
84
	 *  (non-Javadoc)
85
	 * @see javax.swing.JLabel#setText(java.lang.String)
86
	 */
87
	public void setText(String text) {
88
		super.setText(text);
89
		
90
		// Set as tool tip text for this cell, it's text value
91
		if (text != null)
92
			super.setToolTipText(text);
93
	}
94
}
0 95

  
tags/v2_0_0_Build_2028/libUIComponent/src/org/gvsig/gui/IColorTablesFactory.java
1
package org.gvsig.gui;
2

  
3
public interface IColorTablesFactory {
4
	public IColorTables createColorTables();
5
}
0 6

  
tags/v2_0_0_Build_2028/libUIComponent/src/org/gvsig/gui/awt/event/specificCaretPosition/ISpecificCaretPosition.java
1
package org.gvsig.gui.awt.event.specificCaretPosition;
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42

  
43
/**
44
 * Interface with the prototype of methods to have a component with an specific
45
 *   caret position
46
 * 
47
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
48
 */
49
public interface ISpecificCaretPosition {
50
	public static final int LEFT_POSITIONS = 1;
51
	public static final int RIGHT_POSITIONS = 2;
52
	public static final int LIKE_JTEXTCOMPONENT = 3;
53
	
54
	/**
55
	 * Gets the position of text that will be seen
56
	 *
57
	 * @return The position of text that will be seen (LEFT_POSITIONS, RIGHT_POSITIONS or LIKE_JTEXTCOMPONENT)
58
	 */
59
	public int getCaretPositionMode();
60

  
61
	/**
62
	 * Sets the position of text that will be seen
63
	 * 
64
	 * @param caretPositionMode The position of text that will be seen (LEFT_POSITIONS, RIGHT_POSITIONS or LIKE_JTEXTCOMPONENT)
65
	 */
66
	public void setCaretPositionMode(int caretPositionMode);
67
}
0 68

  
tags/v2_0_0_Build_2028/libUIComponent/src/org/gvsig/gui/awt/event/specificCaretPosition/SpecificCaretPositionListeners.java
1
package org.gvsig.gui.awt.event.specificCaretPosition;
2

  
3
import java.awt.event.FocusAdapter;
4
import java.awt.event.FocusEvent;
5

  
6
import javax.swing.event.CaretEvent;
7
import javax.swing.event.CaretListener;
8
import javax.swing.event.DocumentEvent;
9
import javax.swing.event.DocumentListener;
10
import javax.swing.text.JTextComponent;
11

  
12
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
13
 *
14
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
15
 *
16
 * This program is free software; you can redistribute it and/or
17
 * modify it under the terms of the GNU General Public License
18
 * as published by the Free Software Foundation; either version 2
19
 * of the License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU General Public License
27
 * along with this program; if not, write to the Free Software
28
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
29
 *
30
 * For more information, contact:
31
 *
32
 *  Generalitat Valenciana
33
 *   Conselleria d'Infraestructures i Transport
34
 *   Av. Blasco Ib??ez, 50
35
 *   46010 VALENCIA
36
 *   SPAIN
37
 *
38
 *      +34 963862235
39
 *   gvsig@gva.es
40
 *      www.gvsig.gva.es
41
 *
42
 *    or
43
 *
44
 *   IVER T.I. S.A
45
 *   Salamanca 50
46
 *   46005 Valencia
47
 *   Spain
48
 *
49
 *   +34 963163400
50
 *   dac@iver.es
51
 */
52

  
53
/**
54
 * This class has a method which adds the necessary listeners for convert a JTextComponent to another which can be configurated
55
 *   its 'text visible positions when isn't edited' behaviour: left positions, right positions or like JTextComponent (doesn't change text visible positions)
56
 * 
57
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
58
 */
59
public class SpecificCaretPositionListeners {
60
	/**
61
	 * Adds three listeners to a JTextComponent component:
62
	 *  - A FocusListener -> if this component loses its focus -> set caret position to 0
63
	 *  - A DocumentListener -> if this component doesn't have the focus and its caret position has changed -> set caret position to 0
64
	 *  - A CaretListener -> sometimes DocumentListener doesn't take effect, but this listener does
65
	 * @param component
66
	 */
67
	public static void setListeners(final JTextComponent component) {
68
		// The Focus Listener
69
		component.addFocusListener(new FocusAdapter() {
70
			/*
71
			 *  (non-Javadoc)
72
			 * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
73
			 */
74
			public void focusLost(FocusEvent e) {
75
				switch (((ISpecificCaretPosition)component).getCaretPositionMode()) {
76
					case ISpecificCaretPosition.LEFT_POSITIONS:
77
						(component).setCaretPosition(0);
78
						break;
79
					case ISpecificCaretPosition.RIGHT_POSITIONS:
80
						(component).setCaretPosition(component.getDocument().getLength());
81
						break;
82
					case ISpecificCaretPosition.LIKE_JTEXTCOMPONENT: // Do nothing
83
						break;
84
				}
85
			}
86
		});
87
		
88
		// The Document Listener
89
		component.getDocument().addDocumentListener(new DocumentListener() {
90
			/*
91
			 *  (non-Javadoc)
92
			 * @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)
93
			 */
94
			public void changedUpdate(DocumentEvent e) {				
95
				if (!component.isFocusOwner()) {
96
					switch (((ISpecificCaretPosition)component).getCaretPositionMode()) {
97
						case ISpecificCaretPosition.LEFT_POSITIONS:
98
							(component).setCaretPosition(0);
99
							break;
100
						case ISpecificCaretPosition.RIGHT_POSITIONS:
101
							(component).setCaretPosition(component.getDocument().getLength());
102
							break;
103
						case ISpecificCaretPosition.LIKE_JTEXTCOMPONENT: // Do nothing
104
							break;
105
					}
106
				}
107
			}
108

  
109
			/*
110
			 *  (non-Javadoc)
111
			 * @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)
112
			 */
113
			public void insertUpdate(DocumentEvent e) {
114
				if (!component.isFocusOwner()) {
115
					switch (((ISpecificCaretPosition)component).getCaretPositionMode()) {
116
						case ISpecificCaretPosition.LEFT_POSITIONS:
117
							(component).setCaretPosition(0);
118
							break;
119
						case ISpecificCaretPosition.RIGHT_POSITIONS:
120
							(component).setCaretPosition(component.getDocument().getLength());
121
							break;
122
						case ISpecificCaretPosition.LIKE_JTEXTCOMPONENT: // Do nothing
123
							break;
124
					}
125
				}
126
			}
127

  
128
			/*
129
			 *  (non-Javadoc)
130
			 * @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)
131
			 */
132
			public void removeUpdate(DocumentEvent e) {
133
				if (!component.isFocusOwner()) {
134
					switch (((ISpecificCaretPosition)component).getCaretPositionMode()) {
135
						case ISpecificCaretPosition.LEFT_POSITIONS:
136
							(component).setCaretPosition(0);
137
							break;
138
						case ISpecificCaretPosition.RIGHT_POSITIONS:
139
							(component).setCaretPosition(component.getDocument().getLength());
140
							break;
141
						case ISpecificCaretPosition.LIKE_JTEXTCOMPONENT: // Do nothing
142
							break;
143
					}
144
				}
145
			}			
146
		});
147

  
148
		// The Caret Listener
149
		component.addCaretListener(new CaretListener() {
150
			/*
151
			 *  (non-Javadoc)
152
			 * @see javax.swing.event.CaretListener#caretUpdate(javax.swing.event.CaretEvent)
153
			 */
154
			public void caretUpdate(CaretEvent e) {				
155
				if (!component.isFocusOwner()) {
156
					switch (((ISpecificCaretPosition)component).getCaretPositionMode()) {
157
						case ISpecificCaretPosition.LEFT_POSITIONS:
158
							if ((component).getCaretPosition() != 0)
159
								(component).setCaretPosition(0);
160
							break;
161
						case ISpecificCaretPosition.RIGHT_POSITIONS:
162
							if ((component).getCaretPosition() != component.getDocument().getLength())
163
							(component).setCaretPosition(component.getDocument().getLength());
164
							break;
165
						case ISpecificCaretPosition.LIKE_JTEXTCOMPONENT: // Do nothing
166
							break;
167
					}
168
				}
169
			}
170
		});
171
	}
172
}
0 173

  
tags/v2_0_0_Build_2028/libUIComponent/src/org/gvsig/gui/util/StatusComponent.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.gui.util;
20

  
21
import java.util.ArrayList;
22

  
23
import javax.swing.JComponent;
24
/**
25
 * Clase para poder cambiar el estado de un componente y sus componentes hijos.
26
 *
27
 * Tiene dos formas de uso:
28
 *
29
 * 1.- Desactivar un componente y todos sus hijos sin necesidad de guardar su
30
 *     estado. Para este caso solo es necesario usar el m?todo est?tico
31
 *     setDisabled(componente). El hecho de que no exista un activar es que para
32
 *     desactivar esta claro que queremos desactivar un componente y sus hijos,
33
 *     pero a la hora de activar no todos los hijos deben estar activos, para
34
 *     estos casos es necesario ver la segunda opci?n.
35
 *
36
 * 2.- Desactivar un componente guardando todos sus estados y volver a recuperar
37
 *     sus estados como estaba inicialmente. Ejemplo:
38
 *
39
 *     // Creamos el StatusComponent asoci?ndolo al componente en cuesti?n
40
 *     StatusComponent statusComponent = new StatusComponent(miControl);
41
 *
42
 *     // Desactivamos el componente y sus hijos guardando todos los estados.
43
 *     statusComponent.setEnabled(false);
44
 *
45
 *     ......
46
 *     // Activamos el componente recuperando su estado inicial
47
 *     statusComponent.setEnabled(true);
48
 *
49
 * @version 07/09/2007
50
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
51
 */
52
public class StatusComponent {
53
	private ArrayList<StatusComponentStruct> statusList = new ArrayList<StatusComponentStruct>();
54
	private boolean    enabled   = true;
55
	private JComponent component = null;
56

  
57
	/**
58
	 * Estructura de datos para poder tener el estado de un componente
59
	 * @version 07/09/2007
60
	 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
61
	 */
62
	public class StatusComponentStruct {
63
		private JComponent object;
64
		private boolean enabled;
65

  
66
		public boolean isEnabled() {
67
			return enabled;
68
		}
69

  
70
		public void setEnabled(boolean enabled) {
71
			this.enabled = enabled;
72
		}
73

  
74
		public JComponent getObject() {
75
			return object;
76
		}
77

  
78
		public void setObject(JComponent object) {
79
			this.object = object;
80
		}
81
	}
82

  
83
	/**
84
	 * Construye un StatusComponent. Es necesario pasarle el componente que
85
	 * queremos tratar.
86
	 * @param component
87
	 */
88
	public StatusComponent(JComponent component) {
89
		this.component = component;
90
	}
91

  
92
	/**
93
	 * Recupera el estado de un componente y todos sus hijos, vaciando la pila de
94
	 * estados. Eso quiere decir que no se podra volver a recuperar su estado sin
95
	 * haberlo guardado previamente.
96
	 * @param component
97
	 */
98
	private void restoreStatus(JComponent component) {
99
		boolean auxEnabled = false;
100
		boolean finded = false;
101
		// Buscar estado de dicho componente
102
		for (int i = 0; i < statusList.size(); i++) {
103
			StatusComponentStruct auxStatus = (StatusComponentStruct) statusList.get(i);
104
			if (auxStatus.getObject() == component) {
105
				auxEnabled = auxStatus.isEnabled();
106
				statusList.remove(i);
107
				finded = true;
108
				break;
109
			}
110
		}
111

  
112
		// Asignar su estado
113
		if (finded)
114
			component.setEnabled(auxEnabled);
115

  
116
		for (int i = 0; i < component.getComponentCount(); i++)
117
			if (component.getComponent(i) instanceof JComponent)
118
				restoreStatus((JComponent) component.getComponent(i));
119
	}
120

  
121
	/**
122
	 * Desactivar el componente y todos sus hijos sin guardar los estados. Hay que
123
	 * tener cuidado con no confundirlo con setEnabled(false). Este metodo nunca
124
	 * guardara el estado, asi que no se podra recuperar despues dicho estado.
125
	 * @param component
126
	 */
127
	static public void setDisabled(JComponent component) {
128
		component.setEnabled(false);
129
		for (int i = 0; i < component.getComponentCount(); i++)
130
			if (component.getComponent(i) instanceof JComponent)
131
				setDisabled((JComponent) component.getComponent(i));
132
	}
133

  
134
	/**
135
	 * Guarda el estado de un componente. Este proceso es recursivo. El estado
136
	 * se guarda en un array y este array no es vaciado inicialmente. La idea es
137
	 * guardar en un disabled y recuperar en un enabled y asegurarse que no puede
138
	 * ocurrir un disabled o un enabled dos veces.
139
	 * @param component
140
	 */
141
	private void saveComponentsStatus(JComponent component) {
142
		// Guardar estado
143
		StatusComponentStruct auxStatus = new StatusComponentStruct();
144
		auxStatus.setEnabled(component.isEnabled());
145
		auxStatus.setObject(component);
146
		statusList.add(auxStatus);
147

  
148
		for (int i = 0; i < component.getComponentCount(); i++)
149
			if (component.getComponent(i) instanceof JComponent)
150
				saveComponentsStatus((JComponent) component.getComponent(i));
151
	}
152

  
153
	/**
154
	 * Activa o desactiva un componente y todos sus componentes hijos. No se puede
155
	 * activar o desactivar dos veces seguidas. Siendo ignoradas las peticiones
156
	 * repetitivas.
157
	 * @param enabled
158
	 */
159
	public void setEnabled(boolean enabled) {
160
		// Si el estado ha cambiado, hacemos algo
161
		if (this.enabled != enabled) {
162
			if (enabled) {
163
				restoreStatus(component);
164
			} else {
165
				saveComponentsStatus(component);
166
				setDisabled(component);
167
			}
168
			this.enabled = enabled;
169
		}
170
	}
171

  
172
	/**
173
	 * @return the enabled
174
	 */
175
	public boolean isEnabled() {
176
		return enabled;
177
	}
178
}
0 179

  
tags/v2_0_0_Build_2028/libUIComponent/src/org/gvsig/gui/IColorTables.java
1
package org.gvsig.gui;
2

  
3
import java.awt.Color;
4
import java.awt.Graphics2D;
5
import java.awt.Rectangle;
6
import java.util.Iterator;
7

  
8

  
9
public interface IColorTables {
10

  
11
	public abstract void load(String palettesPath, boolean interpolateValues);
12

  
13
	public abstract IColorTablePaint get(int i);
14

  
15
	public abstract int size();
16

  
17
	public abstract Iterator iterator();
18

  
19
	public interface IColorTablePaint {
20

  
21
		/**
22
		 * Defines if the values are interpolated between them or not.
23
		 *
24
		 * @param value
25
		 */
26
		public abstract void setInterpolated(boolean value);
27

  
28
		public abstract Color[] getColors();
29

  
30
		/**
31
		 * Method to paint the color table
32
		 *
33
		 * @param g
34
		 * @param isSelected
35
		 */
36
		public abstract void paint(Graphics2D g, boolean isSelected,
37
				Rectangle bounds);
38

  
39
		public abstract String getTableName();
40

  
41
	}
42
}
43

  
0 44

  
tags/v2_0_0_Build_2028/libUIComponent/src/org/gvsig/gui/beans/openfile/OpenFileContainer.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.gui.beans.openfile;
20

  
21
import java.awt.GridBagConstraints;
22
import java.awt.GridBagLayout;
23
import java.io.File;
24

  
25
import javax.swing.JButton;
26
import javax.swing.JPanel;
27
import javax.swing.JTextField;
28

  
29
import org.gvsig.gui.beans.Messages;
30
import org.gvsig.gui.beans.openfile.listeners.OpenFileListener;
31
/**
32
 *
33
 * @version 13/07/2007
34
 */
35
public class OpenFileContainer extends JPanel {
36
	private static final long serialVersionUID = 5823371652872582451L;
37
	private int 					wComp = 500, hComp = 55;
38
	private int						wButton = 165;
39
	private int						wText = (int)Math.floor(0.63 * wComp);
40
	private int						hButton = 22;
41

  
42
	private JButton jButton = null;
43
	private JTextField tOpen = null;
44
	private OpenFileListener listener = null;
45

  
46
	private boolean isButtonVisible = true;
47

  
48
	public OpenFileContainer() {
49
		super();
50
		listener = new OpenFileListener(this);
51
		initialize();
52
		listener.setButton(this.getJButton());
53
	}
54

  
55
	/**
56
	 * Constructor
57
	 * @param WIDTH
58
	 * Window width
59
	 * @param HEIGHT
60
	 * Window height
61
	 * @param isButtonVisible
62
	 * If the open button is visible
63
	 */
64
	public OpenFileContainer(int WIDTH,int HEIGHT,boolean isButtonVisible){
65
		super();
66
		this.isButtonVisible = isButtonVisible;
67
		this.wComp = WIDTH;
68
		this.hComp = HEIGHT;
69
		listener = new OpenFileListener(this);
70
		initialize();
71
		listener.setButton(this.getJButton());
72
	}
73

  
74
	/**
75
	 * This method initializes this
76
	 *
77
	 */
78
	private void initialize() {
79
				GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
80
				gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
81
				gridBagConstraints1.gridx = 1;
82
				gridBagConstraints1.gridy = 0;
83
				gridBagConstraints1.weightx = 10.0;
84
				gridBagConstraints1.insets = new java.awt.Insets(0,2,0,0);
85
				GridBagConstraints gridBagConstraints = new GridBagConstraints();
86
				gridBagConstraints.insets = new java.awt.Insets(0,0,0,2);
87
				gridBagConstraints.gridy = 0;
88
				gridBagConstraints.gridx = 0;
89
				gridBagConstraints.weightx = 1.0;
90
				this.setLayout(new GridBagLayout());
91
				this.setSize(new java.awt.Dimension(500,50));
92
				this.setBorder(javax.swing.BorderFactory.createTitledBorder(null, Messages.getText("open_file"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
93
				this.add(getJButton(), gridBagConstraints);
94
				this.add(getTOpen(), gridBagConstraints1);
95

  
96
	}
97

  
98
	/**
99
	 * This method initializes jButton
100
	 *
101
	 * @return javax.swing.JButton
102
	 */
103
	private JButton getJButton() {
104
		if (jButton == null) {
105
			jButton = new JButton();
106
			jButton.setPreferredSize(new java.awt.Dimension(wButton,hButton));
107
			jButton.addActionListener(listener);
108
			jButton.setSize(wButton, hButton);
109
			jButton.setText(Messages.getText("abrir..."));
110
			jButton.setVisible(isButtonVisible);
111
			getTOpen().setEnabled(isButtonVisible);
112
		}
113
		return jButton;
114
	}
115

  
116
	/**
117
	 * This method initializes jTextField
118
	 *
119
	 * @return javax.swing.JTextField
120
	 */
121
	public JTextField getTOpen() {
122
		if (tOpen == null) {
123
			tOpen = new JTextField();
124
			if (isButtonVisible){
125
				tOpen.setPreferredSize(new java.awt.Dimension(wText,hButton));
126
			}else{
127
				tOpen.setPreferredSize(new java.awt.Dimension((int)Math.floor(wComp * 0.95),hButton));
128
			}
129
		}
130
		return tOpen;
131
	}
132

  
133
	/**
134
	 * Pone el texto que le pasamos como texto del borde del panel.
135
	 * @param text
136
	 */
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff