Revision 42097
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.ui/src/main/resources/text.properties | ||
---|---|---|
140 | 140 |
known_values=Valores conocidos |
141 | 141 |
ladoVentana=Lado ventana |
142 | 142 |
languageRulesConfigurationLabel=Reglas de idioma |
143 |
largeIcon= Iconos grandes |
|
143 | 144 |
layer_abstract=Resumen de la capa |
144 | 145 |
layer_name=Nombre de la capa |
145 | 146 |
layer_title=T\u00edtulo de la capa |
... | ... | |
149 | 150 |
like_JTextField=Como JTextField |
150 | 151 |
limpiar=Limpiar |
151 | 152 |
line=L\u00ednea |
153 |
list=Lista |
|
152 | 154 |
log=Log |
153 | 155 |
maintain_position=Mantener posici\u00f3n |
154 | 156 |
max_features=M\u00e1x. features |
... | ... | |
195 | 197 |
options=Opciones |
196 | 198 |
origen=Origen |
197 | 199 |
outputType=Tipo de dato |
198 |
panel_adding_exception=Error agregando capa\:
|
|
200 |
panel_adding_exception=Error agregando capa\: |
|
199 | 201 |
panel_base_exception=Error cargando %(PANEL_LABEL)%(CAUSE_MESSAGE). |
200 | 202 |
panel_loading_exception=Error cargando capa\: |
201 | 203 |
panel_without_preferred_size_defined_exception=Panel de etiqueta %(PANEL_LABEL) sin tama\u00f1o inicial definido. |
... | ... | |
248 | 250 |
si=s\u00ed |
249 | 251 |
sideLong=Lado ventana |
250 | 252 |
siguiente=Siguiente |
253 |
smallIcon=Iconos peque\u00f1os |
|
251 | 254 |
srs=Srs |
252 | 255 |
subir=Subir |
253 | 256 |
teclas=Teclas |
254 | 257 |
test=Test |
255 |
test_TableFilterQueryJPanel_title=Test TableFilterQueryJPanel
|
|
258 |
test_TableFilterQueryJPanel_title=Test TableFilterQueryJPanel |
|
256 | 259 |
testJComboBoxConfigurableLookUpErrorMessage=Error de ejecuci\u00f3n en el componente JComboBoxConfigurableLookUp |
257 | 260 |
text_preview_text=Vista previa |
258 | 261 |
the_panel=el panel |
... | ... | |
269 | 272 |
validate_expression=Validar expresi\u00f3n |
270 | 273 |
validate_filter_expression_explanation=Validar o no la expresi\u00f3n de filtro. |
271 | 274 |
verdetalles=Ver detalles |
275 |
view=Vista |
|
272 | 276 |
vista=Vista |
273 | 277 |
warning=Aviso |
274 | 278 |
Warning=Aviso |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.ui/src/main/resources/text_en.properties | ||
---|---|---|
59 | 59 |
Information=Information |
60 | 60 |
known_values=Contents |
61 | 61 |
ladoVentana=Window side |
62 |
largeIcon= Large icons |
|
63 |
list=List |
|
62 | 64 |
msg_cancel_incrementable=Cancel the computation? |
63 | 65 |
no=No |
64 | 66 |
No=No |
... | ... | |
100 | 102 |
si=yes |
101 | 103 |
sideLong=Window side |
102 | 104 |
siguiente=Next |
105 |
smallIcon=Small icons |
|
103 | 106 |
subir=Up |
104 | 107 |
teclas=Keys |
105 | 108 |
text_preview_text=Preview |
... | ... | |
113 | 116 |
validate_filter_expression_explanation=Choose whether to validate filter expression |
114 | 117 |
Valores=Values |
115 | 118 |
verdetalles=Show details |
119 |
view=View |
|
116 | 120 |
Warning=Warning |
117 | 121 |
write_here_a_filter_expression=Enter an SQL WHERE style expression manually or use the buttons to compose one. |
118 | 122 |
yellow=Yellow |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.ui/src/main/java/org/gvsig/gui/beans/listview/painters/SmallIcon.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.gui.beans.listview.painters; |
25 | 25 |
|
26 |
import java.awt.Color; |
|
27 |
import java.awt.Dimension; |
|
28 |
import java.awt.Graphics2D; |
|
29 |
import java.awt.Rectangle; |
|
30 |
import java.awt.Shape; |
|
26 |
import java.awt.*; |
|
31 | 27 |
import java.util.ArrayList; |
32 | 28 |
|
33 | 29 |
import org.gvsig.gui.beans.listview.IListViewPainter; |
34 | 30 |
import org.gvsig.gui.beans.listview.ListViewItem; |
31 |
import org.gvsig.i18n.Messages; |
|
32 |
|
|
35 | 33 |
/** |
36 | 34 |
* Iconos de 82x28 |
37 | 35 |
* |
... | ... | |
39 | 37 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
40 | 38 |
*/ |
41 | 39 |
public class SmallIcon implements IListViewPainter { |
42 |
ArrayList items = null; |
|
43 |
int iconsWidth = 40; |
|
44 |
int minIconsWidth = 40; |
|
45 |
int iconsHeight = 28; |
|
46 |
Dimension lastDimension = new Dimension(0, 0); |
|
47 |
int cols = 0; |
|
48 | 40 |
|
49 |
public SmallIcon(ArrayList items) { |
|
50 |
this.items = items; |
|
51 |
} |
|
41 |
ArrayList items = null; |
|
52 | 42 |
|
53 |
/* |
|
54 |
* (non-Javadoc) |
|
55 |
* @see org.gvsig.gui.beans.graphic.listview.IListViewPainter#getName() |
|
56 |
*/ |
|
57 |
public String getName() { |
|
58 |
return "SmallIcon"; |
|
59 |
} |
|
43 |
int iconsWidth = 40; |
|
60 | 44 |
|
61 |
/* |
|
62 |
* (non-Javadoc) |
|
63 |
* @see org.gvsig.gui.beans.graphic.listview.IListViewPainter#getPreferredSize() |
|
64 |
*/ |
|
65 |
public Dimension getPreferredSize() { |
|
66 |
return lastDimension; |
|
67 |
} |
|
45 |
int minIconsWidth = 40; |
|
68 | 46 |
|
69 |
/* |
|
70 |
* (non-Javadoc) |
|
71 |
* @see org.gvsig.gui.beans.graphic.listview.IListViewPainter#paint(java.awt.Graphics2D, int, int) |
|
72 |
*/ |
|
73 |
public void paint(Graphics2D g, Rectangle visibleRect) { |
|
74 |
int aux = (int) Math.floor(visibleRect.getWidth() / (minIconsWidth + 2)); |
|
75 |
if (aux > items.size()) |
|
76 |
aux = items.size(); |
|
77 |
iconsWidth = (int) (Math.floor(visibleRect.getWidth() / aux) - 2); |
|
47 |
int iconsHeight = 28; |
|
78 | 48 |
|
79 |
int height2 = 0;
|
|
49 |
Dimension lastDimension = new Dimension(0, 0);
|
|
80 | 50 |
|
81 |
int posX = 0; |
|
82 |
int posY = 0; |
|
83 |
cols = 0; |
|
84 |
for (int i = 0; i < items.size(); i++) { |
|
85 |
// Evito que se pueda editar el nombre |
|
86 |
((ListViewItem) items.get(i)).setNameRectangle(null); |
|
51 |
int cols = 0; |
|
87 | 52 |
|
88 |
((ListViewItem) items.get(i)).setShowTooltip(true); |
|
89 |
if (posX != 0) { |
|
90 |
if (((posX + 1) * (iconsWidth + 2)) > visibleRect.getWidth()) { |
|
91 |
posX = 0; |
|
92 |
posY++; |
|
93 |
} |
|
94 |
} |
|
53 |
public SmallIcon(ArrayList items) { |
|
54 |
this.items = items; |
|
55 |
} |
|
95 | 56 |
|
96 |
((ListViewItem) items.get(i)).getItemRectangle().setBounds(posX * (iconsWidth + 2), (posY * (iconsHeight + 2)), iconsWidth + 2, iconsHeight + 2); |
|
97 |
if (((ListViewItem) items.get(i)).getItemRectangle().intersects(visibleRect)) { |
|
98 |
if (((ListViewItem) items.get(i)).isSelected()) { |
|
99 |
g.setColor(new Color(49, 106, 197)); |
|
100 |
g.fillRect(posX * (iconsWidth + 2), posY * (iconsHeight + 2), iconsWidth + 2, iconsHeight + 2); |
|
101 |
} |
|
57 |
/* |
|
58 |
* (non-Javadoc) |
|
59 |
* @see org.gvsig.gui.beans.graphic.listview.IListViewPainter#getName() |
|
60 |
*/ |
|
61 |
public String getName() { |
|
62 |
return Messages.getText("smallIcon"); |
|
63 |
} |
|
102 | 64 |
|
103 |
Shape clip = g.getClip(); |
|
104 |
g.translate(posX * (iconsWidth + 2) + 1, (posY * (iconsHeight + 2)) + 1); |
|
105 |
g.setClip(0, 0, iconsWidth, iconsHeight); |
|
65 |
/* |
|
66 |
* (non-Javadoc) |
|
67 |
* @see |
|
68 |
* org.gvsig.gui.beans.graphic.listview.IListViewPainter#getPreferredSize() |
|
69 |
*/ |
|
70 |
public Dimension getPreferredSize() { |
|
71 |
return lastDimension; |
|
72 |
} |
|
106 | 73 |
|
107 |
if (((ListViewItem) items.get(i)).getIcon() != null) |
|
108 |
((ListViewItem) items.get(i)).getIcon().paint(g, ((ListViewItem) items.get(i)).isSelected()); |
|
74 |
/* |
|
75 |
* (non-Javadoc) |
|
76 |
* @see |
|
77 |
* org.gvsig.gui.beans.graphic.listview.IListViewPainter#paint(java.awt.Graphics2D |
|
78 |
* , int, int) |
|
79 |
*/ |
|
80 |
public void paint(Graphics2D g, Rectangle visibleRect) { |
|
81 |
int aux = (int) Math.floor(visibleRect.getWidth() / (minIconsWidth + 2)); |
|
82 |
if (aux > items.size()) aux = items.size(); |
|
83 |
iconsWidth = (int) (Math.floor(visibleRect.getWidth() / aux) - 2); |
|
109 | 84 |
|
110 |
g.setClip(clip); |
|
111 |
g.translate(- (posX * (iconsWidth + 2) + 1), - ((posY * (iconsHeight + 2)) + 1)); |
|
112 |
} |
|
85 |
int height2 = 0; |
|
113 | 86 |
|
114 |
if (height2 < ((posY + 1) * (iconsHeight + 2))) |
|
115 |
height2 = (posY + 1) * (iconsHeight + 2); |
|
87 |
int posX = 0; |
|
88 |
int posY = 0; |
|
89 |
cols = 0; |
|
90 |
for (int i = 0; i < items.size(); i++) { |
|
91 |
// Evito que se pueda editar el nombre |
|
92 |
((ListViewItem) items.get(i)).setNameRectangle(null); |
|
116 | 93 |
|
117 |
if (cols < posX) |
|
118 |
cols = posX; |
|
94 |
((ListViewItem) items.get(i)).setShowTooltip(true); |
|
95 |
if (posX != 0) { |
|
96 |
if (((posX + 1) * (iconsWidth + 2)) > visibleRect.getWidth()) { |
|
97 |
posX = 0; |
|
98 |
posY++; |
|
99 |
} |
|
100 |
} |
|
119 | 101 |
|
120 |
posX++; |
|
121 |
} |
|
102 |
((ListViewItem) items.get(i)).getItemRectangle().setBounds( |
|
103 |
posX * (iconsWidth + 2), (posY * (iconsHeight + 2)), iconsWidth + 2, |
|
104 |
iconsHeight + 2); |
|
105 |
if (((ListViewItem) items.get(i)).getItemRectangle().intersects( |
|
106 |
visibleRect)) { |
|
107 |
if (((ListViewItem) items.get(i)).isSelected()) { |
|
108 |
g.setColor(new Color(49, 106, 197)); |
|
109 |
g.fillRect(posX * (iconsWidth + 2), posY * (iconsHeight + 2), |
|
110 |
iconsWidth + 2, iconsHeight + 2); |
|
111 |
} |
|
122 | 112 |
|
123 |
lastDimension = new Dimension(minIconsWidth + 2, height2); |
|
124 |
} |
|
113 |
Shape clip = g.getClip(); |
|
114 |
g.translate(posX * (iconsWidth + 2) + 1, (posY * (iconsHeight + 2)) + 1); |
|
115 |
g.setClip(0, 0, iconsWidth, iconsHeight); |
|
116 |
|
|
117 |
if (((ListViewItem) items.get(i)).getIcon() != null) |
|
118 |
((ListViewItem) items.get(i)).getIcon().paint(g, |
|
119 |
((ListViewItem) items.get(i)).isSelected()); |
|
120 |
|
|
121 |
g.setClip(clip); |
|
122 |
g.translate(-(posX * (iconsWidth + 2) + 1), |
|
123 |
-((posY * (iconsHeight + 2)) + 1)); |
|
124 |
} |
|
125 |
|
|
126 |
if (height2 < ((posY + 1) * (iconsHeight + 2))) |
|
127 |
height2 = (posY + 1) * (iconsHeight + 2); |
|
128 |
|
|
129 |
if (cols < posX) cols = posX; |
|
130 |
|
|
131 |
posX++; |
|
132 |
} |
|
133 |
|
|
134 |
lastDimension = new Dimension(minIconsWidth + 2, height2); |
|
135 |
} |
|
125 | 136 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.ui/src/main/java/org/gvsig/gui/beans/listview/painters/LargeIcon.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.gui.beans.listview.painters; |
25 | 25 |
|
26 |
import java.awt.Color; |
|
27 |
import java.awt.Dimension; |
|
28 |
import java.awt.Graphics2D; |
|
29 |
import java.awt.Rectangle; |
|
30 |
import java.awt.Shape; |
|
26 |
import java.awt.*; |
|
31 | 27 |
import java.util.ArrayList; |
32 | 28 |
|
33 | 29 |
import org.gvsig.gui.beans.listview.IListViewPainter; |
34 | 30 |
import org.gvsig.gui.beans.listview.ListViewItem; |
31 |
import org.gvsig.i18n.Messages; |
|
32 |
|
|
35 | 33 |
/** |
36 | 34 |
* Iconos de 82x28 |
37 | 35 |
* |
... | ... | |
39 | 37 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
40 | 38 |
*/ |
41 | 39 |
public class LargeIcon implements IListViewPainter { |
42 |
ArrayList items = null; |
|
43 |
int iconsWidth = 82; |
|
44 |
int minIconsWidth = 82; |
|
45 |
int iconsHeight = 28; |
|
46 |
Dimension lastDimension = new Dimension(0, 0); |
|
47 |
int cols = 0; |
|
48 | 40 |
|
49 |
public LargeIcon(ArrayList items) { |
|
50 |
this.items = items; |
|
51 |
} |
|
41 |
ArrayList items = null; |
|
52 | 42 |
|
53 |
/* |
|
54 |
* (non-Javadoc) |
|
55 |
* @see org.gvsig.gui.beans.graphic.listview.IListViewPainter#getName() |
|
56 |
*/ |
|
57 |
public String getName() { |
|
58 |
return "LargeIcon"; |
|
59 |
} |
|
43 |
int iconsWidth = 82; |
|
60 | 44 |
|
61 |
/* |
|
62 |
* (non-Javadoc) |
|
63 |
* @see org.gvsig.gui.beans.graphic.listview.IListViewPainter#getPreferredSize() |
|
64 |
*/ |
|
65 |
public Dimension getPreferredSize() { |
|
66 |
return lastDimension; |
|
67 |
} |
|
45 |
int minIconsWidth = 82; |
|
68 | 46 |
|
69 |
/* |
|
70 |
* (non-Javadoc) |
|
71 |
* @see org.gvsig.gui.beans.graphic.listview.IListViewPainter#paint(java.awt.Graphics2D, int, int) |
|
72 |
*/ |
|
73 |
public void paint(Graphics2D g, Rectangle visibleRect) { |
|
74 |
int aux = (int) Math.floor(visibleRect.getWidth() / (minIconsWidth + 2)); |
|
75 |
if (aux > items.size()) |
|
76 |
aux = items.size(); |
|
77 |
iconsWidth = (int) (Math.floor(visibleRect.getWidth() / aux) - 2); |
|
47 |
int iconsHeight = 28; |
|
78 | 48 |
|
79 |
int height2 = 0;
|
|
49 |
Dimension lastDimension = new Dimension(0, 0);
|
|
80 | 50 |
|
81 |
int posX = 0; |
|
82 |
int posY = 0; |
|
83 |
cols = 0; |
|
84 |
for (int i = 0; i < items.size(); i++) { |
|
85 |
// Evito que se pueda editar el nombre |
|
86 |
((ListViewItem) items.get(i)).setNameRectangle(null); |
|
51 |
int cols = 0; |
|
87 | 52 |
|
88 |
((ListViewItem) items.get(i)).setShowTooltip(true); |
|
89 |
if (posX != 0) { |
|
90 |
if (((posX + 1) * (iconsWidth + 2)) > visibleRect.getWidth()) { |
|
91 |
posX = 0; |
|
92 |
posY++; |
|
93 |
} |
|
94 |
} |
|
53 |
public LargeIcon(ArrayList items) { |
|
54 |
this.items = items; |
|
55 |
} |
|
95 | 56 |
|
96 |
((ListViewItem) items.get(i)).getItemRectangle().setBounds(posX * (iconsWidth + 2), (posY * (iconsHeight + 2)), iconsWidth + 2, iconsHeight + 2); |
|
97 |
if (((ListViewItem) items.get(i)).getItemRectangle().intersects(visibleRect)) { |
|
98 |
if (((ListViewItem) items.get(i)).isSelected()) { |
|
99 |
g.setColor(new Color(49, 106, 197)); |
|
100 |
g.fillRect(posX * (iconsWidth + 2), posY * (iconsHeight + 2), iconsWidth + 2, iconsHeight + 2); |
|
101 |
} |
|
57 |
/* |
|
58 |
* (non-Javadoc) |
|
59 |
* @see org.gvsig.gui.beans.graphic.listview.IListViewPainter#getName() |
|
60 |
*/ |
|
61 |
public String getName() { |
|
62 |
return Messages.getText("largeIcon"); |
|
63 |
} |
|
102 | 64 |
|
103 |
Shape clip = g.getClip(); |
|
104 |
g.translate(posX * (iconsWidth + 2) + 1, (posY * (iconsHeight + 2)) + 1); |
|
105 |
g.setClip(0, 0, iconsWidth, iconsHeight); |
|
65 |
/* |
|
66 |
* (non-Javadoc) |
|
67 |
* @see |
|
68 |
* org.gvsig.gui.beans.graphic.listview.IListViewPainter#getPreferredSize() |
|
69 |
*/ |
|
70 |
public Dimension getPreferredSize() { |
|
71 |
return lastDimension; |
|
72 |
} |
|
106 | 73 |
|
107 |
if (((ListViewItem) items.get(i)).getIcon() != null) |
|
108 |
((ListViewItem) items.get(i)).getIcon().paint(g, ((ListViewItem) items.get(i)).isSelected()); |
|
74 |
/* |
|
75 |
* (non-Javadoc) |
|
76 |
* @see |
|
77 |
* org.gvsig.gui.beans.graphic.listview.IListViewPainter#paint(java.awt.Graphics2D |
|
78 |
* , int, int) |
|
79 |
*/ |
|
80 |
public void paint(Graphics2D g, Rectangle visibleRect) { |
|
81 |
int aux = (int) Math.floor(visibleRect.getWidth() / (minIconsWidth + 2)); |
|
82 |
if (aux > items.size()) aux = items.size(); |
|
83 |
iconsWidth = (int) (Math.floor(visibleRect.getWidth() / aux) - 2); |
|
109 | 84 |
|
110 |
g.setClip(clip); |
|
111 |
g.translate(-(posX * (iconsWidth + 2) + 1), -((posY * (iconsHeight + 2)) + 1)); |
|
112 |
} |
|
85 |
int height2 = 0; |
|
113 | 86 |
|
114 |
if (height2 < ((posY + 1) * (iconsHeight + 2))) |
|
115 |
height2 = (posY + 1) * (iconsHeight + 2); |
|
87 |
int posX = 0; |
|
88 |
int posY = 0; |
|
89 |
cols = 0; |
|
90 |
for (int i = 0; i < items.size(); i++) { |
|
91 |
// Evito que se pueda editar el nombre |
|
92 |
((ListViewItem) items.get(i)).setNameRectangle(null); |
|
116 | 93 |
|
117 |
if (cols < posX) |
|
118 |
cols = posX; |
|
94 |
((ListViewItem) items.get(i)).setShowTooltip(true); |
|
95 |
if (posX != 0) { |
|
96 |
if (((posX + 1) * (iconsWidth + 2)) > visibleRect.getWidth()) { |
|
97 |
posX = 0; |
|
98 |
posY++; |
|
99 |
} |
|
100 |
} |
|
119 | 101 |
|
120 |
posX++; |
|
121 |
} |
|
102 |
((ListViewItem) items.get(i)).getItemRectangle().setBounds( |
|
103 |
posX * (iconsWidth + 2), (posY * (iconsHeight + 2)), iconsWidth + 2, |
|
104 |
iconsHeight + 2); |
|
105 |
if (((ListViewItem) items.get(i)).getItemRectangle().intersects( |
|
106 |
visibleRect)) { |
|
107 |
if (((ListViewItem) items.get(i)).isSelected()) { |
|
108 |
g.setColor(new Color(49, 106, 197)); |
|
109 |
g.fillRect(posX * (iconsWidth + 2), posY * (iconsHeight + 2), |
|
110 |
iconsWidth + 2, iconsHeight + 2); |
|
111 |
} |
|
122 | 112 |
|
123 |
lastDimension = new Dimension(minIconsWidth + 2, height2); |
|
124 |
} |
|
113 |
Shape clip = g.getClip(); |
|
114 |
g.translate(posX * (iconsWidth + 2) + 1, (posY * (iconsHeight + 2)) + 1); |
|
115 |
g.setClip(0, 0, iconsWidth, iconsHeight); |
|
116 |
|
|
117 |
if (((ListViewItem) items.get(i)).getIcon() != null) |
|
118 |
((ListViewItem) items.get(i)).getIcon().paint(g, |
|
119 |
((ListViewItem) items.get(i)).isSelected()); |
|
120 |
|
|
121 |
g.setClip(clip); |
|
122 |
g.translate(-(posX * (iconsWidth + 2) + 1), |
|
123 |
-((posY * (iconsHeight + 2)) + 1)); |
|
124 |
} |
|
125 |
|
|
126 |
if (height2 < ((posY + 1) * (iconsHeight + 2))) |
|
127 |
height2 = (posY + 1) * (iconsHeight + 2); |
|
128 |
|
|
129 |
if (cols < posX) cols = posX; |
|
130 |
|
|
131 |
posX++; |
|
132 |
} |
|
133 |
|
|
134 |
lastDimension = new Dimension(minIconsWidth + 2, height2); |
|
135 |
} |
|
125 | 136 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.ui/src/main/java/org/gvsig/gui/beans/listview/painters/PaintList.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.gui.beans.listview.painters; |
25 | 25 |
|
26 |
import java.awt.Color; |
|
27 |
import java.awt.Dimension; |
|
28 |
import java.awt.FontMetrics; |
|
29 |
import java.awt.GradientPaint; |
|
30 |
import java.awt.Graphics2D; |
|
31 |
import java.awt.Rectangle; |
|
32 |
import java.awt.Shape; |
|
26 |
import java.awt.*; |
|
33 | 27 |
import java.util.ArrayList; |
34 | 28 |
|
35 | 29 |
import org.gvsig.gui.beans.listview.IListViewPainter; |
36 | 30 |
import org.gvsig.gui.beans.listview.ListViewItem; |
31 |
import org.gvsig.i18n.Messages; |
|
32 |
|
|
37 | 33 |
/** |
38 | 34 |
* @version 28/06/2007 |
39 | 35 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
40 | 36 |
*/ |
41 | 37 |
public class PaintList implements IListViewPainter { |
42 |
ArrayList items = null; |
|
43 |
int iconsWidth = 35; |
|
44 |
int minIconsWidth = 35; |
|
45 |
Dimension lastDimension = new Dimension(0, 0); |
|
46 | 38 |
|
47 |
public PaintList(ArrayList items) { |
|
48 |
this.items = items; |
|
49 |
} |
|
39 |
ArrayList items = null; |
|
50 | 40 |
|
51 |
/* |
|
52 |
* (non-Javadoc) |
|
53 |
* @see org.gvsig.gui.beans.graphic.listview.IListViewPainter#getName() |
|
54 |
*/ |
|
55 |
public String getName() { |
|
56 |
return "List"; |
|
57 |
} |
|
41 |
int iconsWidth = 35; |
|
58 | 42 |
|
59 |
/* |
|
60 |
* (non-Javadoc) |
|
61 |
* @see org.gvsig.gui.beans.graphic.listview.IListViewPainter#getPreferredSize() |
|
62 |
*/ |
|
63 |
public Dimension getPreferredSize() { |
|
64 |
return lastDimension; |
|
65 |
} |
|
43 |
int minIconsWidth = 35; |
|
66 | 44 |
|
67 |
/* |
|
68 |
* (non-Javadoc) |
|
69 |
* @see org.gvsig.gui.beans.graphic.listview.IListViewPainter#paint(java.awt.Graphics2D, int, int) |
|
70 |
*/ |
|
71 |
public void paint(Graphics2D g, Rectangle visibleRect) { |
|
72 |
FontMetrics fm = g.getFontMetrics(); |
|
45 |
Dimension lastDimension = new Dimension(0, 0); |
|
73 | 46 |
|
74 |
int minAux = 0; |
|
75 |
for (int i = 0; i < items.size(); i++) { |
|
76 |
int auxWidth = g.getFontMetrics().stringWidth(((ListViewItem) items.get(i)).getName()) + 8; |
|
77 |
if (minAux < auxWidth) |
|
78 |
minAux = auxWidth; |
|
79 |
} |
|
80 |
minAux = visibleRect.width - minAux; |
|
81 |
if (minAux < minIconsWidth) |
|
82 |
minAux = minIconsWidth; |
|
83 |
iconsWidth = minAux; |
|
47 |
public PaintList(ArrayList items) { |
|
48 |
this.items = items; |
|
49 |
} |
|
84 | 50 |
|
85 |
int height2 = 0; |
|
86 |
int width2 = 0; |
|
87 |
for (int i = 0; i < items.size(); i++) { |
|
88 |
((ListViewItem) items.get(i)).setNameRectangle(null); |
|
51 |
/* |
|
52 |
* (non-Javadoc) |
|
53 |
* @see org.gvsig.gui.beans.graphic.listview.IListViewPainter#getName() |
|
54 |
*/ |
|
55 |
public String getName() { |
|
56 |
return Messages.getText("list"); |
|
57 |
} |
|
89 | 58 |
|
90 |
int auxWidth = g.getFontMetrics().stringWidth(((ListViewItem) items.get(i)).getName());
|
|
91 |
if ((minIconsWidth + 3 + auxWidth - visibleRect.x) > visibleRect.width) {
|
|
92 |
((ListViewItem) items.get(i)).setShowTooltip(true);
|
|
93 |
} else {
|
|
94 |
((ListViewItem) items.get(i)).setShowTooltip(false);
|
|
95 |
}
|
|
96 |
if (width2 < auxWidth)
|
|
97 |
width2 = auxWidth;
|
|
59 |
/*
|
|
60 |
* (non-Javadoc)
|
|
61 |
* @see
|
|
62 |
* org.gvsig.gui.beans.graphic.listview.IListViewPainter#getPreferredSize()
|
|
63 |
*/
|
|
64 |
public Dimension getPreferredSize() {
|
|
65 |
return lastDimension;
|
|
66 |
}
|
|
98 | 67 |
|
99 |
((ListViewItem) items.get(i)).getItemRectangle().setBounds(visibleRect.x, i * 17, visibleRect.width, 17); |
|
68 |
/* |
|
69 |
* (non-Javadoc) |
|
70 |
* @see |
|
71 |
* org.gvsig.gui.beans.graphic.listview.IListViewPainter#paint(java.awt.Graphics2D |
|
72 |
* , int, int) |
|
73 |
*/ |
|
74 |
public void paint(Graphics2D g, Rectangle visibleRect) { |
|
75 |
FontMetrics fm = g.getFontMetrics(); |
|
100 | 76 |
|
101 |
if (!((ListViewItem) items.get(i)).getItemRectangle().intersects(visibleRect)) |
|
102 |
continue; |
|
77 |
int minAux = 0; |
|
78 |
for (int i = 0; i < items.size(); i++) { |
|
79 |
int auxWidth = g.getFontMetrics().stringWidth( |
|
80 |
((ListViewItem) items.get(i)).getName()) + 8; |
|
81 |
if (minAux < auxWidth) minAux = auxWidth; |
|
82 |
} |
|
83 |
minAux = visibleRect.width - minAux; |
|
84 |
if (minAux < minIconsWidth) minAux = minIconsWidth; |
|
85 |
iconsWidth = minAux; |
|
103 | 86 |
|
104 |
int upper = fm.getLeading() + fm.getAscent() + ((17 - fm.getHeight()) / 2); |
|
87 |
int height2 = 0; |
|
88 |
int width2 = 0; |
|
89 |
for (int i = 0; i < items.size(); i++) { |
|
90 |
((ListViewItem) items.get(i)).setNameRectangle(null); |
|
105 | 91 |
|
106 |
if (((ListViewItem) items.get(i)).isSelected()) { |
|
107 |
Color color1 = new Color(89, 153, 229); |
|
108 |
Color color2 = new Color(31, 92, 207); |
|
109 |
g.setPaint(new GradientPaint(0, i * 17 + 1, color1, 0, i * 17 + 16, color2, false)); |
|
110 |
g.fillRect(visibleRect.x, i * 17 + 1, visibleRect.width, 16); |
|
111 |
g.setColor(new Color(61, 123, 218)); |
|
112 |
g.drawLine(visibleRect.x, i * 17, visibleRect.x + visibleRect.width, i * 17); |
|
113 |
g.setColor(Color.white); |
|
114 |
} else { |
|
115 |
g.setColor(Color.black); |
|
116 |
} |
|
117 |
g.drawString(((ListViewItem) items.get(i)).getName(), iconsWidth + 3, (i * 17) + upper); |
|
118 |
// Guardar el estado de donde se visualiza el nombre y cuanto ocupa |
|
119 |
((ListViewItem) items.get(i)).setNameRectangle(new Rectangle(iconsWidth + 2, i * 17 - 1, visibleRect.width - (iconsWidth + 2), 20)); |
|
92 |
int auxWidth = g.getFontMetrics().stringWidth( |
|
93 |
((ListViewItem) items.get(i)).getName()); |
|
94 |
if ((minIconsWidth + 3 + auxWidth - visibleRect.x) > visibleRect.width) { |
|
95 |
((ListViewItem) items.get(i)).setShowTooltip(true); |
|
96 |
} |
|
97 |
else { |
|
98 |
((ListViewItem) items.get(i)).setShowTooltip(false); |
|
99 |
} |
|
100 |
if (width2 < auxWidth) width2 = auxWidth; |
|
120 | 101 |
|
121 |
Shape clip = g.getClip(); |
|
122 |
g.translate(1, i * 17 + 1); |
|
123 |
g.setClip(0, 0, iconsWidth, 15); |
|
102 |
((ListViewItem) items.get(i)).getItemRectangle().setBounds(visibleRect.x, |
|
103 |
i * 17, visibleRect.width, 17); |
|
124 | 104 |
|
125 |
if (((ListViewItem) items.get(i)).getIcon() != null)
|
|
126 |
((ListViewItem) items.get(i)).getIcon().paint(g, ((ListViewItem) items.get(i)).isSelected());
|
|
105 |
if (!((ListViewItem) items.get(i)).getItemRectangle().intersects(
|
|
106 |
visibleRect)) continue;
|
|
127 | 107 |
|
128 |
g.setClip(clip); |
|
129 |
g.translate(-1, -(i * 17 + 1)); |
|
130 |
} |
|
131 |
height2 = items.size() * 17; |
|
108 |
int upper = fm.getLeading() + fm.getAscent() |
|
109 |
+ ((17 - fm.getHeight()) / 2); |
|
132 | 110 |
|
133 |
lastDimension = new Dimension(minIconsWidth + 3 + width2, height2); |
|
134 |
//lastDimension = new Dimension(0, height2); |
|
135 |
} |
|
111 |
if (((ListViewItem) items.get(i)).isSelected()) { |
|
112 |
Color color1 = new Color(89, 153, 229); |
|
113 |
Color color2 = new Color(31, 92, 207); |
|
114 |
g.setPaint(new GradientPaint(0, i * 17 + 1, color1, 0, i * 17 + 16, |
|
115 |
color2, false)); |
|
116 |
g.fillRect(visibleRect.x, i * 17 + 1, visibleRect.width, 16); |
|
117 |
g.setColor(new Color(61, 123, 218)); |
|
118 |
g.drawLine(visibleRect.x, i * 17, visibleRect.x + visibleRect.width, |
|
119 |
i * 17); |
|
120 |
g.setColor(Color.white); |
|
121 |
} |
|
122 |
else { |
|
123 |
g.setColor(Color.black); |
|
124 |
} |
|
125 |
g.drawString(((ListViewItem) items.get(i)).getName(), iconsWidth + 3, |
|
126 |
(i * 17) + upper); |
|
127 |
// Guardar el estado de donde se visualiza el nombre y cuanto ocupa |
|
128 |
((ListViewItem) items.get(i)) |
|
129 |
.setNameRectangle(new Rectangle(iconsWidth + 2, i * 17 - 1, |
|
130 |
visibleRect.width - (iconsWidth + 2), 20)); |
|
131 |
|
|
132 |
Shape clip = g.getClip(); |
|
133 |
g.translate(1, i * 17 + 1); |
|
134 |
g.setClip(0, 0, iconsWidth, 15); |
|
135 |
|
|
136 |
if (((ListViewItem) items.get(i)).getIcon() != null) |
|
137 |
((ListViewItem) items.get(i)).getIcon().paint(g, |
|
138 |
((ListViewItem) items.get(i)).isSelected()); |
|
139 |
|
|
140 |
g.setClip(clip); |
|
141 |
g.translate(-1, -(i * 17 + 1)); |
|
142 |
} |
|
143 |
height2 = items.size() * 17; |
|
144 |
|
|
145 |
lastDimension = new Dimension(minIconsWidth + 3 + width2, height2); |
|
146 |
// lastDimension = new Dimension(0, height2); |
|
147 |
} |
|
136 | 148 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.ui/src/main/java/org/gvsig/gui/beans/listview/ListViewComponent.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.gui.beans.listview; |
25 | 25 |
|
26 |
import java.awt.Color; |
|
27 |
import java.awt.Dimension; |
|
28 |
import java.awt.Graphics; |
|
29 |
import java.awt.Graphics2D; |
|
30 |
import java.awt.Image; |
|
31 |
import java.awt.Point; |
|
32 |
import java.awt.Rectangle; |
|
33 |
import java.awt.RenderingHints; |
|
26 |
import java.awt.*; |
|
34 | 27 |
import java.awt.color.ColorSpace; |
35 |
import java.awt.event.ActionEvent; |
|
36 |
import java.awt.event.ActionListener; |
|
37 |
import java.awt.event.FocusEvent; |
|
38 |
import java.awt.event.FocusListener; |
|
39 |
import java.awt.event.InputEvent; |
|
40 |
import java.awt.event.KeyEvent; |
|
41 |
import java.awt.event.KeyListener; |
|
42 |
import java.awt.event.MouseEvent; |
|
43 |
import java.awt.event.MouseListener; |
|
44 |
import java.awt.event.MouseMotionListener; |
|
28 |
import java.awt.event.*; |
|
45 | 29 |
import java.awt.image.BufferedImage; |
46 | 30 |
import java.awt.image.ColorConvertOp; |
47 |
import java.util.ArrayList; |
|
48 |
import java.util.Arrays; |
|
49 |
import java.util.EventObject; |
|
50 |
import java.util.Iterator; |
|
31 |
import java.util.*; |
|
51 | 32 |
|
52 |
import javax.swing.ButtonGroup; |
|
53 |
import javax.swing.JComponent; |
|
54 |
import javax.swing.JMenu; |
|
55 |
import javax.swing.JPopupMenu; |
|
56 |
import javax.swing.JRadioButtonMenuItem; |
|
57 |
import javax.swing.JScrollPane; |
|
58 |
import javax.swing.JTextField; |
|
59 |
import javax.swing.JViewport; |
|
33 |
import javax.swing.*; |
|
60 | 34 |
import javax.swing.event.AncestorEvent; |
61 | 35 |
import javax.swing.event.AncestorListener; |
62 | 36 |
|
63 |
import org.gvsig.gui.beans.listview.painters.LargeIcon;
|
|
64 |
import org.gvsig.gui.beans.listview.painters.PaintList;
|
|
65 |
import org.gvsig.gui.beans.listview.painters.SmallIcon; |
|
37 |
import org.gvsig.gui.beans.listview.painters.*;
|
|
38 |
import org.gvsig.i18n.Messages;
|
|
39 |
|
|
66 | 40 |
/** |
67 | 41 |
* Componente grafico para representar una lista de valores |
68 | 42 |
* |
69 | 43 |
* @version 28/06/2007 |
70 | 44 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
71 | 45 |
*/ |
72 |
public class ListViewComponent extends JComponent implements MouseListener, MouseMotionListener, ActionListener, KeyListener, FocusListener, AncestorListener { |
|
73 |
private static final long serialVersionUID = 6177600314634665863L; |
|
46 |
public class ListViewComponent extends JComponent implements MouseListener, |
|
47 |
MouseMotionListener, ActionListener, KeyListener, FocusListener, |
|
48 |
AncestorListener { |
|
74 | 49 |
|
75 |
/** |
|
76 |
* Lista de los tipos de vista existentes |
|
77 |
*/ |
|
78 |
private ArrayList<IListViewPainter> painters = new ArrayList<IListViewPainter>(); |
|
79 |
private ArrayList<JRadioButtonMenuItem> paintersMenu = new ArrayList<JRadioButtonMenuItem>(); |
|
50 |
private static final long serialVersionUID = 6177600314634665863L; |
|
80 | 51 |
|
81 |
/**
|
|
82 |
* Lista de items
|
|
83 |
*/
|
|
84 |
private ArrayList<ListViewItem> items = new ArrayList<ListViewItem>();
|
|
52 |
/**
|
|
53 |
* Lista de los tipos de vista existentes
|
|
54 |
*/
|
|
55 |
private ArrayList<IListViewPainter> painters = new ArrayList<IListViewPainter>();
|
|
85 | 56 |
|
86 |
/** |
|
87 |
* Selecciona el tipo de vista |
|
88 |
*/ |
|
89 |
private int view = 0; |
|
57 |
private ArrayList<JRadioButtonMenuItem> paintersMenu = new ArrayList<JRadioButtonMenuItem>(); |
|
90 | 58 |
|
91 |
/**
|
|
92 |
* Booleano para saber si se permite la multiselecci?n
|
|
93 |
*/
|
|
94 |
private boolean multiSelect = false;
|
|
59 |
/**
|
|
60 |
* Lista de items
|
|
61 |
*/
|
|
62 |
private ArrayList<ListViewItem> items = new ArrayList<ListViewItem>();
|
|
95 | 63 |
|
96 |
private Image image = null; |
|
97 |
private int width = 0; |
|
98 |
private int height = 0; |
|
99 |
private Graphics2D widgetGraphics = null; |
|
100 |
private JMenu jMenu = null; |
|
101 |
private ButtonGroup buttonGroup = null; |
|
102 |
private JPopupMenu jPopupMenu = null; |
|
64 |
/** |
|
65 |
* Selecciona el tipo de vista |
|
66 |
*/ |
|
67 |
private int view = 0; |
|
103 | 68 |
|
104 |
private JTextField jRenameEdit = null; |
|
69 |
/** |
|
70 |
* Booleano para saber si se permite la multiselecci?n |
|
71 |
*/ |
|
72 |
private boolean multiSelect = false; |
|
105 | 73 |
|
74 |
private Image image = null; |
|
106 | 75 |
|
107 |
private int itemEdited = -1; |
|
108 |
private int lastSelected = -1; |
|
109 |
private int cursorPos = -1; |
|
76 |
private int width = 0; |
|
110 | 77 |
|
78 |
private int height = 0; |
|
111 | 79 |
|
112 |
private boolean editable = false;
|
|
80 |
private Graphics2D widgetGraphics = null;
|
|
113 | 81 |
|
114 |
private ArrayList<ListViewListener> actionCommandListeners = new ArrayList<ListViewListener>();
|
|
82 |
private JMenu jMenu = null;
|
|
115 | 83 |
|
116 |
private ListViewItem lastSelectedItem = null;
|
|
84 |
private ButtonGroup buttonGroup = null;
|
|
117 | 85 |
|
118 |
/** |
|
119 |
* Construye un <code>ListViewComponent</code> |
|
120 |
* |
|
121 |
*/ |
|
122 |
public ListViewComponent() { |
|
123 |
setFocusable(true); |
|
86 |
private JPopupMenu jPopupMenu = null; |
|
124 | 87 |
|
125 |
initialize(); |
|
126 |
} |
|
88 |
private JTextField jRenameEdit = null; |
|
127 | 89 |
|
128 |
/** |
|
129 |
* Inicializa el <code>ListViewComponent</code> |
|
130 |
*/ |
|
131 |
private void initialize() { |
|
132 |
addListViewPainter(new PaintList(items)); |
|
133 |
addListViewPainter(new SmallIcon(items)); |
|
134 |
addListViewPainter(new LargeIcon(items)); |
|
90 |
private int itemEdited = -1; |
|
135 | 91 |
|
136 |
addAncestorListener(this);
|
|
92 |
private int lastSelected = -1;
|
|
137 | 93 |
|
138 |
addKeyListener(this); |
|
139 |
addMouseListener(this); |
|
140 |
addMouseMotionListener(this); |
|
141 |
} |
|
94 |
private int cursorPos = -1; |
|
142 | 95 |
|
143 |
/** |
|
144 |
* Obtiene que vista se esta usando en el componente |
|
145 |
* @return |
|
146 |
*/ |
|
147 |
public int getView() { |
|
148 |
return view; |
|
149 |
} |
|
96 |
private boolean editable = false; |
|
150 | 97 |
|
151 |
/** |
|
152 |
* Define que vista es la que se va a usar |
|
153 |
* @param view |
|
154 |
*/ |
|
155 |
public void setView(int view) { |
|
156 |
this.view = view; |
|
157 |
} |
|
98 |
private ArrayList<ListViewListener> actionCommandListeners = new ArrayList<ListViewListener>(); |
|
158 | 99 |
|
159 |
/** |
|
160 |
* Agrega una vista al componente |
|
161 |
* @param item |
|
162 |
*/ |
|
163 |
public void addListViewPainter(IListViewPainter item) { |
|
164 |
painters.add(item); |
|
100 |
private ListViewItem lastSelectedItem = null; |
|
165 | 101 |
|
166 |
JRadioButtonMenuItem jRadioButtonMenuItem = new JRadioButtonMenuItem(); |
|
167 |
getButtonGroup().add(jRadioButtonMenuItem); |
|
102 |
/** |
|
103 |
* Construye un <code>ListViewComponent</code> |
|
104 |
*/ |
|
105 |
public ListViewComponent() { |
|
106 |
setFocusable(true); |
|
168 | 107 |
|
169 |
jRadioButtonMenuItem.setText(item.getName()); |
|
170 |
if (paintersMenu.size() == 0) |
|
171 |
jRadioButtonMenuItem.setSelected(true); |
|
172 |
getJMenu().add(jRadioButtonMenuItem); |
|
108 |
initialize(); |
|
109 |
} |
|
173 | 110 |
|
174 |
jRadioButtonMenuItem.addActionListener(this); |
|
111 |
/** |
|
112 |
* Inicializa el <code>ListViewComponent</code> |
|
113 |
*/ |
|
114 |
private void initialize() { |
|
115 |
addListViewPainter(new PaintList(items)); |
|
116 |
addListViewPainter(new SmallIcon(items)); |
|
117 |
addListViewPainter(new LargeIcon(items)); |
|
175 | 118 |
|
176 |
paintersMenu.add(jRadioButtonMenuItem); |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* Sorts the specified array of objects into ascending order |
|
181 |
*/ |
|
182 |
public void sort() { |
|
183 |
Object[] list = items.toArray(); |
|
184 |
Arrays.sort(list); |
|
185 |
items.clear(); |
|
186 |
for (int i = 0; i < list.length; i++) |
|
187 |
items.add((ListViewItem)list[i]); |
|
188 |
} |
|
119 |
addAncestorListener(this); |
|
189 | 120 |
|
190 |
/** |
|
191 |
* Agrega un item al componente |
|
192 |
* @param item |
|
193 |
*/ |
|
194 |
public void addItem(ListViewItem item) { |
|
195 |
addItem(item, false); |
|
196 |
} |
|
121 |
addKeyListener(this); |
|
122 |
addMouseListener(this); |
|
123 |
addMouseMotionListener(this); |
|
124 |
} |
|
197 | 125 |
|
198 |
/** |
|
199 |
* Agrega un item al componente, si acceptRepeatNames es false no se aceptaran |
|
200 |
* nombres repetidos |
|
201 |
* @param item |
|
202 |
* @param acceptRepeatNames |
|
203 |
*/ |
|
204 |
public void addItem(ListViewItem item, boolean acceptRepeatNames) { |
|
205 |
items.add(item); |
|
206 |
if (!acceptRepeatNames) |
|
207 |
changeName(item.getName(), items.size() - 1); |
|
126 |
/** |
|
127 |
* Obtiene que vista se esta usando en el componente |
|
128 |
* |
|
129 |
* @return |
|
130 |
*/ |
|
131 |
public int getView() { |
|
132 |
return view; |
|
133 |
} |
|
208 | 134 |
|
209 |
viewItem(items.size() - 1); |
|
210 |
} |
|
135 |
/** |
|
136 |
* Define que vista es la que se va a usar |
|
137 |
* |
|
138 |
* @param view |
|
139 |
*/ |
|
140 |
public void setView(int view) { |
|
141 |
this.view = view; |
|
142 |
} |
|
211 | 143 |
|
212 |
/** |
|
213 |
* Agrega el item en la posicion especificada de la lista. |
|
214 |
* @param pos |
|
215 |
* @param item |
|
216 |
*/ |
|
217 |
public void addItem(int pos, ListViewItem item) { |
|
218 |
items.add(pos, item); |
|
219 |
changeName(item.getName(), pos); |
|
144 |
/** |
|
145 |
* Agrega una vista al componente |
|
146 |
* |
|
147 |
* @param item |
|
148 |
*/ |
|
149 |
public void addListViewPainter(IListViewPainter item) { |
|
150 |
painters.add(item); |
|
220 | 151 |
|
221 |
viewItem(pos);
|
|
222 |
}
|
|
152 |
JRadioButtonMenuItem jRadioButtonMenuItem = new JRadioButtonMenuItem();
|
|
153 |
getButtonGroup().add(jRadioButtonMenuItem);
|
|
223 | 154 |
|
224 |
/** |
|
225 |
* Agrega un item al componente |
|
226 |
* @param item |
|
227 |
*/ |
|
228 |
public void removeItem(int index) { |
|
229 |
items.remove(index); |
|
230 |
repaint(); |
|
231 |
} |
|
155 |
jRadioButtonMenuItem.setText(item.getName()); |
|
156 |
if (paintersMenu.size() == 0) jRadioButtonMenuItem.setSelected(true); |
|
157 |
getJMenu().add(jRadioButtonMenuItem); |
|
232 | 158 |
|
233 |
/** |
|
234 |
* Borra todos los items seleccionados |
|
235 |
*/ |
|
236 |
public void removeSelecteds() { |
|
237 |
for (int i = (items.size()-1); i>=0; i--) |
|
238 |
if (((ListViewItem) items.get(i)).isSelected()) |
|
239 |
items.remove(i); |
|
159 |
jRadioButtonMenuItem.addActionListener(this); |
|
240 | 160 |
|
241 |
repaint();
|
|
242 |
}
|
|
161 |
paintersMenu.add(jRadioButtonMenuItem);
|
|
162 |
}
|
|
243 | 163 |
|
244 |
/** |
|
245 |
* Devuelve un ArrayList con todos los items |
|
246 |
* @return |
|
247 |
*/ |
|
248 |
@SuppressWarnings("unchecked") |
|
249 |
public ArrayList getItems() { |
|
250 |
return items; |
|
251 |
} |
|
164 |
/** |
|
165 |
* Sorts the specified array of objects into ascending order |
|
166 |
*/ |
|
167 |
public void sort() { |
|
168 |
Object[] list = items.toArray(); |
|
169 |
Arrays.sort(list); |
|
170 |
items.clear(); |
|
171 |
for (int i = 0; i < list.length; i++) |
|
172 |
items.add((ListViewItem) list[i]); |
|
173 |
} |
|
252 | 174 |
|
253 |
private Graphics2D getWidgetGraphics() { |
|
254 |
getWidgetImage(); |
|
255 |
return widgetGraphics; |
|
256 |
} |
|
175 |
/** |
|
176 |
* Agrega un item al componente |
|
177 |
* |
|
178 |
* @param item |
|
179 |
*/ |
|
180 |
public void addItem(ListViewItem item) { |
|
181 |
addItem(item, false); |
|
182 |
} |
|
257 | 183 |
|
258 |
private Image getWidgetImage() { |
|
259 |
int width2 = getVisibleRect().width; |
|
260 |
int height2 = getVisibleRect().height; |
|
261 |
if (width2 <= 0) |
|
262 |
width2 = 1; |
|
263 |
if (height2 <= 0) |
|
264 |
height2=1; |
|
184 |
/** |
|
185 |
* Agrega un item al componente, si acceptRepeatNames es false no se aceptaran |
|
186 |
* nombres repetidos |
|
187 |
* |
|
188 |
* @param item |
|
189 |
* @param acceptRepeatNames |
|
190 |
*/ |
|
191 |
public void addItem(ListViewItem item, boolean acceptRepeatNames) { |
|
192 |
items.add(item); |
|
193 |
if (!acceptRepeatNames) changeName(item.getName(), items.size() - 1); |
|
265 | 194 |
|
266 |
if ((width != width2) || (height != height2)) { |
|
267 |
image = createImage(width2, height2); |
|
268 |
if (image == null) |
|
269 |
return null; |
|
270 |
widgetGraphics = (Graphics2D) image.getGraphics(); |
|
271 |
} |
|
195 |
viewItem(items.size() - 1); |
|
196 |
} |
|
272 | 197 |
|
273 |
width = width2; |
|
274 |
height = height2; |
|
275 |
return image; |
|
276 |
} |
|
198 |
/** |
|
199 |
* Agrega el item en la posicion especificada de la lista. |
|
200 |
* |
|
201 |
* @param pos |
|
202 |
* @param item |
|
203 |
*/ |
|
204 |
public void addItem(int pos, ListViewItem item) { |
|
205 |
items.add(pos, item); |
|
206 |
changeName(item.getName(), pos); |
|
277 | 207 |
|
278 |
/** |
|
279 |
* Redibujar el componente en el graphics temporal |
|
280 |
*/ |
|
281 |
private void redrawBuffer() { |
|
282 |
if (getWidgetGraphics() == null) |
|
283 |
return; |
|
208 |
viewItem(pos); |
|
209 |
} |
|
284 | 210 |
|
285 |
/** desactivaci?n del anti-aliasing */ |
|
286 |
getWidgetGraphics().setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); |
|
287 |
getWidgetGraphics().setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); |
|
211 |
/** |
|
212 |
* Agrega un item al componente |
|
213 |
* |
|
214 |
* @param item |
|
215 |
*/ |
|
216 |
public void removeItem(int index) { |
|
217 |
items.remove(index); |
|
218 |
repaint(); |
|
219 |
} |
|
288 | 220 |
|
289 |
/** demanda de rendimiento r?pido */ |
|
290 |
getWidgetGraphics().setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED); |
|
291 |
getWidgetGraphics().setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED); |
|
292 |
getWidgetGraphics().setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF); |
|
293 |
getWidgetGraphics().setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE); |
|
221 |
/** |
|
222 |
* Borra todos los items seleccionados |
|
223 |
*/ |
|
224 |
public void removeSelecteds() { |
|
225 |
for (int i = (items.size() - 1); i >= 0; i--) |
|
226 |
if (((ListViewItem) items.get(i)).isSelected()) items.remove(i); |
|
294 | 227 |
|
295 |
getWidgetGraphics().translate(-getVisibleRect().x, -getVisibleRect().y); |
|
296 |
getWidgetGraphics().setColor(Color.white); |
|
297 |
getWidgetGraphics().fillRect(getVisibleRect().x, getVisibleRect().y, getVisibleRect().width, getVisibleRect().height); |
|
228 |
repaint(); |
|
229 |
} |
|
298 | 230 |
|
299 |
((IListViewPainter) painters.get(view)).paint((Graphics2D) getWidgetGraphics(), getVisibleRect()); |
|
300 |
getWidgetGraphics().translate(getVisibleRect().x, getVisibleRect().y); |
|
301 |
} |
|
231 |
/** |
|
232 |
* Devuelve un ArrayList con todos los items |
|
233 |
* |
|
234 |
* @return |
|
235 |
*/ |
|
236 |
@SuppressWarnings("unchecked") |
|
237 |
public ArrayList getItems() { |
|
238 |
return items; |
|
239 |
} |
|
302 | 240 |
|
303 |
public void paint(Graphics g) { |
|
304 |
redrawBuffer(); |
|
241 |
private Graphics2D getWidgetGraphics() { |
|
242 |
getWidgetImage(); |
|
243 |
return widgetGraphics; |
|
244 |
} |
|
305 | 245 |
|
306 |
if (image != null) { |
|
307 |
if (isEnabled()) { |
|
308 |
g.drawImage(image, getVisibleRect().x, getVisibleRect().y, this); |
|
309 |
} else { |
|
310 |
// Dibujar en escala de grises y aclarado para cuando esta inactivo |
|
311 |
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); |
|
246 |
private Image getWidgetImage() { |
|
247 |
int width2 = getVisibleRect().width; |
|
248 |
int height2 = getVisibleRect().height; |
|
249 |
if (width2 <= 0) width2 = 1; |
|
250 |
if (height2 <= 0) height2 = 1; |
|
312 | 251 |
|
313 |
Graphics big = bi.createGraphics(); |
|
314 |
big.drawImage(image, 0, 0, this); |
|
252 |
if ((width != width2) || (height != height2)) { |
|
253 |
image = createImage(width2, height2); |
|
254 |
if (image == null) return null; |
|
255 |
widgetGraphics = (Graphics2D) image.getGraphics(); |
|
256 |
} |
|
315 | 257 |
|
316 |
ColorConvertOp colorConvert = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null); |
|
317 |
colorConvert.filter(bi, bi); |
|
258 |
width = width2; |
|
259 |
height = height2; |
|
260 |
return image; |
|
261 |
} |
|
318 | 262 |
|
319 |
big.setColor(new Color(255, 255, 255, 164)); |
|
320 |
big.fillRect(0, 0, width, height); |
|
263 |
/** |
|
264 |
* Redibujar el componente en el graphics temporal |
|
265 |
*/ |
|
266 |
private void redrawBuffer() { |
|
267 |
if (getWidgetGraphics() == null) return; |
|
321 | 268 |
|
322 |
g.drawImage(bi, getVisibleRect().x, getVisibleRect().y, this); |
|
323 |
} |
|
324 |
} |
|
269 |
/** desactivaci?n del anti-aliasing */ |
|
270 |
getWidgetGraphics().setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
|
271 |
RenderingHints.VALUE_ANTIALIAS_OFF); |
|
272 |
getWidgetGraphics().setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, |
|
273 |
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); |
|
325 | 274 |
|
275 |
/** demanda de rendimiento r?pido */ |
|
276 |
getWidgetGraphics().setRenderingHint(RenderingHints.KEY_RENDERING, |
|
277 |
RenderingHints.VALUE_RENDER_SPEED); |
|
278 |
getWidgetGraphics().setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, |
|
279 |
RenderingHints.VALUE_COLOR_RENDER_SPEED); |
|
280 |
getWidgetGraphics().setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, |
|
281 |
RenderingHints.VALUE_FRACTIONALMETRICS_OFF); |
|
282 |
getWidgetGraphics().setRenderingHint(RenderingHints.KEY_DITHERING, |
|
283 |
RenderingHints.VALUE_DITHER_DISABLE); |
|
326 | 284 |
|
327 |
Dimension size = getPreferredSize(); |
|
328 |
Dimension aux = ((IListViewPainter) painters.get(view)).getPreferredSize(); |
|
329 |
if (!size.equals(aux)) { |
|
330 |
setPreferredSize(aux); |
|
331 |
setSize(aux); |
|
332 |
} |
|
285 |
getWidgetGraphics().translate(-getVisibleRect().x, -getVisibleRect().y); |
|
286 |
getWidgetGraphics().setColor(Color.white); |
|
287 |
getWidgetGraphics().fillRect(getVisibleRect().x, getVisibleRect().y, |
|
288 |
getVisibleRect().width, getVisibleRect().height); |
|
333 | 289 |
|
334 |
if (getParent() instanceof JViewport) { |
|
335 |
JViewport jViewport = (JViewport) getParent(); |
|
336 |
if (jViewport.getParent() instanceof JScrollPane) { |
|
337 |
if (items.size() > 0) |
|
338 |
((JScrollPane) jViewport.getParent()).getVerticalScrollBar().setUnitIncrement(((ListViewItem) items.get(0)).getItemRectangle().height); |
|
339 |
} |
|
340 |
} |
|
341 |
} |
|
290 |
((IListViewPainter) painters.get(view)).paint( |
|
291 |
(Graphics2D) getWidgetGraphics(), getVisibleRect()); |
|
292 |
getWidgetGraphics().translate(getVisibleRect().x, getVisibleRect().y); |
|
293 |
} |
|
342 | 294 |
|
343 |
public boolean isMultiSelect() { |
|
344 |
return multiSelect; |
|
345 |
} |
|
295 |
public void paint(Graphics g) { |
|
296 |
redrawBuffer(); |
|
346 | 297 |
|
347 |
public void setMultiSelect(boolean multiSelect) { |
|
348 |
if (multiSelect == false) { |
|
349 |
for (int i = 0; i<items.size(); i++) |
|
350 |
((ListViewItem) items.get(i)).setSelected(false); |
|
351 |
if ((lastSelected != -1) && (lastSelected < items.size())) |
|
352 |
((ListViewItem) items.get(lastSelected)).setSelected(true); |
|
353 |
} |
|
298 |
if (image != null) { |
|
299 |
if (isEnabled()) { |
|
300 |
g.drawImage(image, getVisibleRect().x, getVisibleRect().y, this); |
|
301 |
} |
|
302 |
else { |
|
303 |
// Dibujar en escala de grises y aclarado para cuando esta inactivo |
|
304 |
BufferedImage bi = new BufferedImage(width, height, |
|
305 |
BufferedImage.TYPE_INT_RGB); |
|
354 | 306 |
|
355 |
this.multiSelect = multiSelect; |
|
356 |
repaint(); |
|
357 |
} |
|
307 |
Graphics big = bi.createGraphics(); |
|
308 |
big.drawImage(image, 0, 0, this); |
|
358 | 309 |
|
359 |
private int getItem(int x, int y) { |
|
360 |
Point point = new Point(x, y); |
|
361 |
Rectangle rectangle = null; |
|
362 |
for (int i = 0; i < items.size(); i++) { |
|
363 |
rectangle = ((ListViewItem) items.get(i)).getItemRectangle(); |
|
364 |
if ((rectangle != null) && (rectangle.getBounds().contains(point))) |
|
365 |
return i; |
|
366 |
} |
|
310 |
ColorConvertOp colorConvert = new ColorConvertOp( |
|
311 |
ColorSpace.getInstance(ColorSpace.CS_GRAY), null); |
|
312 |
colorConvert.filter(bi, bi); |
|
367 | 313 |
|
368 |
return -1;
|
|
369 |
}
|
|
314 |
big.setColor(new Color(255, 255, 255, 164));
|
|
315 |
big.fillRect(0, 0, width, height);
|
|
370 | 316 |
|
371 |
/* |
|
372 |
* (non-Javadoc) |
|
373 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) |
|
374 |
*/ |
|
375 |
public void mousePressed(MouseEvent e) { |
|
376 |
if (!isEnabled()) |
|
377 |
return; |
|
378 |
requestFocus(); |
|
317 |
g.drawImage(bi, getVisibleRect().x, getVisibleRect().y, this); |
|
318 |
} |
|
319 |
} |
|
379 | 320 |
|
380 |
try { |
|
381 |
if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != InputEvent.BUTTON1_MASK) |
|
382 |
return; |
|
321 |
Dimension size = getPreferredSize(); |
|
322 |
Dimension aux = ((IListViewPainter) painters.get(view)).getPreferredSize(); |
|
323 |
if (!size.equals(aux)) { |
|
324 |
setPreferredSize(aux); |
|
325 |
setSize(aux); |
|
326 |
} |
|
383 | 327 |
|
384 |
cursorPos = getItem(e.getX(), e.getY()); |
|
385 |
viewItem(cursorPos); |
|
386 |
if (cursorPos == -1) |
|
387 |
return; |
|
328 |
if (getParent() instanceof JViewport) { |
|
329 |
JViewport jViewport = (JViewport) getParent(); |
|
330 |
if (jViewport.getParent() instanceof JScrollPane) { |
|
331 |
if (items.size() > 0) |
|
332 |
((JScrollPane) jViewport.getParent()).getVerticalScrollBar() |
|
333 |
.setUnitIncrement( |
|
334 |
((ListViewItem) items.get(0)).getItemRectangle().height); |
|
335 |
} |
|
336 |
} |
|
337 |
} |
|
388 | 338 |
|
389 |
if (isMultiSelect()) { |
|
390 |
if ((e.getModifiers() & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK) { |
|
391 |
int pos1 = cursorPos; |
|
392 |
int pos2 = lastSelected; |
|
393 |
if (pos2 < pos1) { |
|
394 |
pos1 = lastSelected; |
|
395 |
pos2 = cursorPos; |
|
396 |
} |
|
339 |
public boolean isMultiSelect() { |
|
340 |
return multiSelect; |
|
341 |
} |
|
397 | 342 |
|
398 |
if ((e.getModifiers() & InputEvent.CTRL_MASK) != InputEvent.CTRL_MASK) |
|
399 |
for (int i = 0; i < items.size(); i++) |
|
400 |
((ListViewItem) items.get(i)).setSelected(false); |
|
343 |
public void setMultiSelect(boolean multiSelect) { |
|
344 |
if (multiSelect == false) { |
|
345 |
for (int i = 0; i < items.size(); i++) |
|
346 |
((ListViewItem) items.get(i)).setSelected(false); |
|
347 |
if ((lastSelected != -1) && (lastSelected < items.size())) |
|
348 |
((ListViewItem) items.get(lastSelected)).setSelected(true); |
|
349 |
} |
|
401 | 350 |
|
402 |
for (int i = pos1; i <= pos2; i++) |
|
403 |
((ListViewItem) items.get(i)).setSelected(true); |
|
404 |
return; |
|
405 |
} |
|
351 |
this.multiSelect = multiSelect; |
|
352 |
repaint(); |
|
353 |
} |
|
406 | 354 |
|
407 |
lastSelected = cursorPos; |
|
355 |
private int getItem(int x, int y) { |
|
356 |
Point point = new Point(x, y); |
|
357 |
Rectangle rectangle = null; |
|
358 |
for (int i = 0; i < items.size(); i++) { |
|
359 |
rectangle = ((ListViewItem) items.get(i)).getItemRectangle(); |
|
360 |
if ((rectangle != null) && (rectangle.getBounds().contains(point))) |
|
361 |
return i; |
|
362 |
} |
|
408 | 363 |
|
409 |
if ((e.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) { |
|
410 |
((ListViewItem) items.get(cursorPos)).setSelected(!((ListViewItem) items.get(cursorPos)).isSelected()); |
|
411 |
return; |
|
412 |
} |
|
364 |
return -1; |
|
365 |
} |
|
413 | 366 |
|
414 |
for (int i = 0; i < items.size(); i++) |
|
415 |
((ListViewItem) items.get(i)).setSelected(false); |
|
367 |
/* |
|
368 |
* (non-Javadoc) |
|
369 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) |
|
370 |
*/ |
|
371 |
public void mousePressed(MouseEvent e) { |
|
372 |
if (!isEnabled()) return; |
|
373 |
requestFocus(); |
|
416 | 374 |
|
417 |
((ListViewItem) items.get(cursorPos)).setSelected(true);
|
|
418 |
} else {
|
|
419 |
boolean selected = true;
|
|
375 |
try {
|
|
376 |
if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != InputEvent.BUTTON1_MASK)
|
|
377 |
return;
|
|
420 | 378 |
|
421 |
lastSelected = cursorPos; |
|
379 |
cursorPos = getItem(e.getX(), e.getY()); |
|
380 |
viewItem(cursorPos); |
|
381 |
if (cursorPos == -1) return; |
|
422 | 382 |
|
423 |
if ((e.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) |
|
424 |
selected = !((ListViewItem) items.get(cursorPos)).isSelected(); |
|
383 |
if (isMultiSelect()) { |
|
384 |
if ((e.getModifiers() & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK) { |
|
385 |
int pos1 = cursorPos; |
|
386 |
int pos2 = lastSelected; |
|
387 |
if (pos2 < pos1) { |
|
388 |
pos1 = lastSelected; |
|
389 |
pos2 = cursorPos; |
|
390 |
} |
|
425 | 391 |
|
426 |
for (int i = 0; i < items.size(); i++) |
|
427 |
((ListViewItem) items.get(i)).setSelected(false); |
|
392 |
if ((e.getModifiers() & InputEvent.CTRL_MASK) != InputEvent.CTRL_MASK) |
|
393 |
for (int i = 0; i < items.size(); i++) |
|
394 |
((ListViewItem) items.get(i)).setSelected(false); |
|
428 | 395 |
|
429 |
((ListViewItem) items.get(cursorPos)).setSelected(selected); |
|
430 |
} |
|
431 |
} finally { |
|
432 |
repaint(); |
|
433 |
} |
|
434 |
} |
|
396 |
for (int i = pos1; i <= pos2; i++) |
|
397 |
((ListViewItem) items.get(i)).setSelected(true); |
|
398 |
return; |
|
399 |
} |
|
435 | 400 |
|
436 |
/** |
|
437 |
* Establece que un item debe estar visible en la vista |
|
438 |
* @param pos |
|
439 |
*/ |
|
440 |
private void viewItem(int pos) { |
|
441 |
if ((pos == -1) || (items.size()==0)) |
|
442 |
return; |
|
443 |
redrawBuffer(); |
|
444 |
Dimension aux = ((IListViewPainter) painters.get(view)).getPreferredSize(); |
|
445 |
setPreferredSize(aux); |
|
446 |
setSize(aux); |
|
401 |
lastSelected = cursorPos; |
|
447 | 402 |
|
448 |
if (pos < 0) |
|
449 |
pos = 0; |
|
403 |
if ((e.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) { |
|
404 |
((ListViewItem) items.get(cursorPos)) |
|
405 |
.setSelected(!((ListViewItem) items.get(cursorPos)).isSelected()); |
|
406 |
return; |
|
407 |
} |
|
450 | 408 |
|
451 |
if (pos >= items.size())
|
|
452 |
pos = items.size() - 1;
|
|
409 |
for (int i = 0; i < items.size(); i++)
|
|
410 |
((ListViewItem) items.get(i)).setSelected(false);
|
|
453 | 411 |
|
454 |
if (getParent() instanceof JViewport) { |
|
455 |
JViewport jViewport = (JViewport) getParent(); |
|
412 |
((ListViewItem) items.get(cursorPos)).setSelected(true); |
|
413 |
} |
|
414 |
else { |
|
415 |
boolean selected = true; |
|
456 | 416 |
|
457 |
if (jViewport.getParent() instanceof JScrollPane) { |
|
458 |
ListViewItem lvi = ((ListViewItem) items.get(pos)); |
|
459 |
Rectangle rectangle = (Rectangle) lvi.getItemRectangle().clone(); |
|
460 |
if (rectangle == null) |
|
461 |
return; |
|
462 |
rectangle.setLocation((int) rectangle.getX() - getVisibleRect().x, (int) rectangle.getY() - getVisibleRect().y); |
|
463 |
jViewport.scrollRectToVisible(rectangle); |
|
464 |
((JScrollPane)jViewport.getParent()).getVerticalScrollBar().paintImmediately(((JScrollPane)jViewport.getParent()).getVerticalScrollBar().getVisibleRect()); |
|
465 |
} |
|
466 |
} |
|
467 |
} |
|
417 |
lastSelected = cursorPos; |
|
468 | 418 |
|
469 |
public void mouseDragged(MouseEvent e) { |
|
470 |
if (!isEnabled()) |
|
471 |
return; |
|
472 |
if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != InputEvent.BUTTON1_MASK) |
|
473 |
return; |
|
419 |
if ((e.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) |
|
420 |
selected = !((ListViewItem) items.get(cursorPos)).isSelected(); |
|
474 | 421 |
|
475 |
if (isMultiSelect()) { |
|
476 |
if ((e.getModifiers() & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK) |
|
477 |
return; |
|
478 |
if ((e.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) |
|
479 |
return; |
|
480 |
} |
|
422 |
for (int i = 0; i < items.size(); i++) |
|
423 |
((ListViewItem) items.get(i)).setSelected(false); |
|
481 | 424 |
|
482 |
int itemSelected = getItem(e.getX(), e.getY()); |
|
425 |
((ListViewItem) items.get(cursorPos)).setSelected(selected); |
|
426 |
} |
|
427 |
} |
|
428 |
finally { |
|
429 |
repaint(); |
|
430 |
} |
|
431 |
} |
|
483 | 432 |
|
484 |
if (itemSelected == -1) |
|
485 |
return; |
|
433 |
/** |
|
434 |
* Establece que un item debe estar visible en la vista |
|
435 |
* |
|
436 |
* @param pos |
|
437 |
*/ |
|
438 |
private void viewItem(int pos) { |
|
439 |
if ((pos == -1) || (items.size() == 0)) return; |
|
440 |
redrawBuffer(); |
|
441 |
Dimension aux = ((IListViewPainter) painters.get(view)).getPreferredSize(); |
|
442 |
setPreferredSize(aux); |
|
443 |
setSize(aux); |
|
486 | 444 |
|
487 |
lastSelected = itemSelected; |
|
488 |
cursorPos = itemSelected; |
|
445 |
if (pos < 0) pos = 0; |
|
489 | 446 |
|
490 |
for (int i = 0; i<items.size(); i++) |
|
491 |
((ListViewItem) items.get(i)).setSelected(false); |
|
447 |
if (pos >= items.size()) pos = items.size() - 1; |
|
492 | 448 |
|
493 |
((ListViewItem) items.get(itemSelected)).setSelected(true); |
|
449 |
if (getParent() instanceof JViewport) { |
|
450 |
JViewport jViewport = (JViewport) getParent(); |
|
494 | 451 |
|
495 |
repaint(); |
|
452 |
if (jViewport.getParent() instanceof JScrollPane) { |
|
453 |
ListViewItem lvi = ((ListViewItem) items.get(pos)); |
|
454 |
Rectangle rectangle = (Rectangle) lvi.getItemRectangle().clone(); |
|
455 |
if (rectangle == null) return; |
|
456 |
rectangle.setLocation((int) rectangle.getX() - getVisibleRect().x, |
|
457 |
(int) rectangle.getY() - getVisibleRect().y); |
|
458 |
jViewport.scrollRectToVisible(rectangle); |
|
459 |
((JScrollPane) jViewport.getParent()).getVerticalScrollBar() |
|
460 |
.paintImmediately( |
Also available in: Unified diff