Revision 2634
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.300/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/test/java/org/gvsig/tools/AppTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.tools; |
|
25 |
|
|
26 |
import junit.framework.Test; |
|
27 |
import junit.framework.TestCase; |
|
28 |
import junit.framework.TestSuite; |
|
29 |
|
|
30 |
/** |
|
31 |
* Unit test for simple App. |
|
32 |
*/ |
|
33 |
public class AppTest extends TestCase { |
|
34 |
|
|
35 |
/** |
|
36 |
* @return the suite of tests being tested |
|
37 |
*/ |
|
38 |
public static Test suite() { |
|
39 |
return new TestSuite(AppTest.class); |
|
40 |
} |
|
41 |
|
|
42 |
/** |
|
43 |
* Create the test case |
|
44 |
* |
|
45 |
* @param testName |
|
46 |
* name of the test case |
|
47 |
*/ |
|
48 |
public AppTest(String testName) { |
|
49 |
super(testName); |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* Rigourous Test :-) |
|
54 |
*/ |
|
55 |
public void testApp() { |
|
56 |
assertTrue(true); |
|
57 |
} |
|
58 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.300/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/dialogreminder/DefaultDialogReminderManager.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.tools.swing.impl.dialogreminder; |
|
3 |
|
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.Collections; |
|
6 |
import java.util.HashMap; |
|
7 |
import java.util.Iterator; |
|
8 |
import java.util.List; |
|
9 |
import java.util.Map; |
|
10 |
import org.gvsig.tools.swing.api.reminder.DialogReminder; |
|
11 |
import org.gvsig.tools.swing.api.reminder.DialogReminderManager; |
|
12 |
|
|
13 |
|
|
14 |
public class DefaultDialogReminderManager implements DialogReminderManager { |
|
15 |
|
|
16 |
private Map<String,DialogReminder> remembers; |
|
17 |
|
|
18 |
public DefaultDialogReminderManager() { |
|
19 |
this.remembers = new HashMap<>(); |
|
20 |
} |
|
21 |
|
|
22 |
@Override |
|
23 |
public boolean exists(String id) { |
|
24 |
return this.remembers.containsKey(id); |
|
25 |
} |
|
26 |
|
|
27 |
@Override |
|
28 |
public DialogReminder get(String id) { |
|
29 |
return this.remembers.get(id); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public DialogReminder add(String id) { |
|
34 |
DialogReminder r = this.get(id); |
|
35 |
if( r == null ) { |
|
36 |
r = new DefaultDialogReminder(id); |
|
37 |
this.remembers.put(id, r); |
|
38 |
} |
|
39 |
return r; |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public DialogReminder add(String id, int value) { |
|
44 |
DialogReminder r = this.add(id); |
|
45 |
r.setValue(value); |
|
46 |
return r; |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public Iterator<DialogReminder> iterator() { |
|
51 |
return this.remembers.values().iterator(); |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public List<DialogReminder> reminders() { |
|
56 |
return Collections.unmodifiableList(new ArrayList<>(this.remembers.values())); |
|
57 |
} |
|
58 |
|
|
59 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.300/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/dialogreminder/DefaultDialogReminder.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.tools.swing.impl.dialogreminder; |
|
3 |
|
|
4 |
import org.gvsig.tools.swing.api.reminder.DialogReminder; |
|
5 |
|
|
6 |
|
|
7 |
public class DefaultDialogReminder implements DialogReminder { |
|
8 |
private final String id; |
|
9 |
private Object value; |
|
10 |
|
|
11 |
public DefaultDialogReminder(String id) { |
|
12 |
this.id = id; |
|
13 |
this.value = null; |
|
14 |
} |
|
15 |
@Override |
|
16 |
public String getId() { |
|
17 |
return id; |
|
18 |
} |
|
19 |
|
|
20 |
@Override |
|
21 |
public Object getValue() { |
|
22 |
return this.value; |
|
23 |
} |
|
24 |
|
|
25 |
@Override |
|
26 |
public void reset() { |
|
27 |
this.value = null; |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
public boolean hasValue() { |
|
32 |
return this.value!=null; |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
public void setValue(Object value) { |
|
37 |
this.value = value; |
|
38 |
} |
|
39 |
|
|
40 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.300/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/DropDownLabelIcon.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.tools.swing.impl; |
|
3 |
|
|
4 |
import java.awt.Color; |
|
5 |
import javax.swing.ImageIcon; |
|
6 |
import javax.swing.JComponent; |
|
7 |
import javax.swing.JLabel; |
|
8 |
|
|
9 |
/** |
|
10 |
* |
|
11 |
* @author omartinez |
|
12 |
*/ |
|
13 |
|
|
14 |
public class DropDownLabelIcon extends DropDownLabel { |
|
15 |
|
|
16 |
public DropDownLabelIcon(JComponent component, Color warningBackgroundColor) { |
|
17 |
super(component, warningBackgroundColor); |
|
18 |
} |
|
19 |
|
|
20 |
@Override |
|
21 |
protected void setText(String s, Color backgroundColor) { |
|
22 |
JComponent comp = this.asJComponent(); |
|
23 |
if (comp instanceof JLabel) { |
|
24 |
ImageIcon icon = this.getIcons().get(this.getSelectedIndex()); |
|
25 |
((JLabel) comp).setIcon(icon); |
|
26 |
} |
|
27 |
comp.setBackground(backgroundColor); |
|
28 |
} |
|
29 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.300/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/TreeComboCellRenderer.java | ||
---|---|---|
1 |
package org.gvsig.tools.swing.impl; |
|
2 |
|
|
3 |
import java.awt.Component; |
|
4 |
import javax.swing.ComboBoxModel; |
|
5 |
import javax.swing.Icon; |
|
6 |
import javax.swing.JLabel; |
|
7 |
import javax.swing.JList; |
|
8 |
import javax.swing.ListCellRenderer; |
|
9 |
import javax.swing.UIManager; |
|
10 |
import javax.swing.border.Border; |
|
11 |
import javax.swing.border.EmptyBorder; |
|
12 |
import javax.swing.tree.DefaultMutableTreeNode; |
|
13 |
import org.gvsig.tools.swing.api.IconGetter; |
|
14 |
import org.gvsig.tools.swing.impl.TreeComboUtils.TreeModelToComboBoxModelAdapter; |
|
15 |
|
|
16 |
public class TreeComboCellRenderer extends JLabel implements ListCellRenderer { |
|
17 |
|
|
18 |
private static final long serialVersionUID = 3732251042879578480L; |
|
19 |
private static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0); |
|
20 |
private static final int OFFSET = 16; |
|
21 |
|
|
22 |
private final Icon leafIcon = (Icon) UIManager.get("Tree.leafIcon"); |
|
23 |
private final Icon nodeIcon = (Icon) UIManager.get("Tree.openIcon"); |
|
24 |
private final TreeModelToComboBoxModelAdapter model; |
|
25 |
private final IconGetter icons; |
|
26 |
|
|
27 |
public TreeComboCellRenderer(ComboBoxModel model) { |
|
28 |
this.setOpaque(true); |
|
29 |
this.model = (TreeModelToComboBoxModelAdapter) model; |
|
30 |
if( this.model instanceof IconGetter ) { |
|
31 |
this.icons = (IconGetter) this.model; |
|
32 |
} else { |
|
33 |
this.icons = null; |
|
34 |
} |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public final void setOpaque(boolean isOpaque) { |
|
39 |
super.setOpaque(isOpaque); |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public Component getListCellRendererComponent( |
|
44 |
JList listbox, |
|
45 |
Object value, |
|
46 |
int index, |
|
47 |
boolean isSelected, |
|
48 |
boolean cellHasFocus) { |
|
49 |
DefaultMutableTreeNode entry = model.getNode(value); |
|
50 |
if (entry != null) { |
|
51 |
Border border; |
|
52 |
setText(getCellText(entry)); |
|
53 |
if( this.icons==null ) { |
|
54 |
setIcon(getCellIcon(entry)); |
|
55 |
} else { |
|
56 |
setIcon(this.icons.getIcon(value)); |
|
57 |
} |
|
58 |
if (index != -1) { |
|
59 |
border = new EmptyBorder(0, OFFSET * entry.getLevel(), 0, 0); |
|
60 |
} else { |
|
61 |
border = emptyBorder; |
|
62 |
} |
|
63 |
|
|
64 |
if (UIManager.getLookAndFeel().getName().equals("CDE/Motif")) { |
|
65 |
if (index == -1) { |
|
66 |
this.setOpaque(false); |
|
67 |
} else { |
|
68 |
this.setOpaque(true); |
|
69 |
} |
|
70 |
} else { |
|
71 |
this.setOpaque(true); |
|
72 |
} |
|
73 |
|
|
74 |
this.setBorder(border); |
|
75 |
if (isSelected) { |
|
76 |
this.setBackground(UIManager.getColor("ComboBox.selectionBackground")); |
|
77 |
this.setForeground(UIManager.getColor("ComboBox.selectionForeground")); |
|
78 |
} else { |
|
79 |
this.setBackground(UIManager.getColor("ComboBox.background")); |
|
80 |
this.setForeground(UIManager.getColor("ComboBox.foreground")); |
|
81 |
} |
|
82 |
} else { |
|
83 |
setText(""); |
|
84 |
} |
|
85 |
return this; |
|
86 |
} |
|
87 |
|
|
88 |
public Icon getCellIcon(DefaultMutableTreeNode node) { |
|
89 |
return node.getAllowsChildren() ? nodeIcon : leafIcon; |
|
90 |
} |
|
91 |
|
|
92 |
public String getCellText(DefaultMutableTreeNode node) { |
|
93 |
return node.getUserObject().toString(); |
|
94 |
} |
|
95 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.300/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/FilteredTableModelImpl.java | ||
---|---|---|
1 |
package org.gvsig.tools.swing.impl; |
|
2 |
|
|
3 |
import org.gvsig.tools.swing.api.FilteredTableModel; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Objects; |
|
7 |
import javax.swing.SwingUtilities; |
|
8 |
import javax.swing.event.TableModelEvent; |
|
9 |
import javax.swing.table.AbstractTableModel; |
|
10 |
import javax.swing.table.TableModel; |
|
11 |
import org.apache.commons.io.FilenameUtils; |
|
12 |
import org.apache.commons.lang3.ObjectUtils; |
|
13 |
import org.apache.commons.lang3.StringUtils; |
|
14 |
import org.gvsig.tools.swing.api.FilteredModel; |
|
15 |
import org.gvsig.tools.util.CompareUtils; |
|
16 |
|
|
17 |
/** |
|
18 |
* |
|
19 |
* @author jjdelcerro |
|
20 |
*/ |
|
21 |
class FilteredTableModelImpl extends AbstractTableModel implements FilteredTableModel { |
|
22 |
|
|
23 |
private final TableModel baseModel ; |
|
24 |
private final int filterColumn; |
|
25 |
|
|
26 |
private String filter; |
|
27 |
private List<Integer> filteredElements; |
|
28 |
private FilteredModel.FilterFunction filterfn; |
|
29 |
private boolean caseSensitive; |
|
30 |
|
|
31 |
public FilteredTableModelImpl(TableModel tableModel, int theFilterColumn) { |
|
32 |
this.baseModel = tableModel; |
|
33 |
this.filterColumn = theFilterColumn; |
|
34 |
this.filteredElements = null; |
|
35 |
this.setFilter(null); |
|
36 |
this.baseModel.addTableModelListener((TableModelEvent e) -> { |
|
37 |
fireContentsChanged(); |
|
38 |
}); |
|
39 |
this.filterfn = (Object model, Object row, String filter1) -> { |
|
40 |
int i = (Integer) row; |
|
41 |
Object value = baseModel.getValueAt(i, filterColumn); |
|
42 |
return CompareUtils.match(value,filter1); |
|
43 |
}; |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public void setFilterFunction(FilterFunction filter) { |
|
48 |
this.filterfn = filter; |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public String getColumnName(int column) { |
|
53 |
return this.baseModel.getColumnName(column); |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public Class<?> getColumnClass(int columnIndex) { |
|
58 |
return this.baseModel.getColumnClass(columnIndex); |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
public final void setFilter(String filter) { |
|
63 |
if (StringUtils.isBlank(filter)) { |
|
64 |
this.filter = null; |
|
65 |
this.filteredElements = new ArrayList<>(this.baseModel.getRowCount()); |
|
66 |
for (int i = 0; i < this.baseModel.getRowCount(); i++) { |
|
67 |
filteredElements.add(i); |
|
68 |
|
|
69 |
} |
|
70 |
} else { |
|
71 |
if( StringUtils.containsAny(filter, "*?") ) { |
|
72 |
this.filter = filter; |
|
73 |
} else { |
|
74 |
this.filter = filter + "*"; |
|
75 |
} |
|
76 |
this.filteredElements = new ArrayList<>(); |
|
77 |
for (int i = 0; i < this.baseModel.getRowCount(); i++) { |
|
78 |
if( this.filterfn.test(this.baseModel, i, this.filter) ) { |
|
79 |
this.filteredElements.add(i); |
|
80 |
} |
|
81 |
} |
|
82 |
} |
|
83 |
fireContentsChanged(); |
|
84 |
} |
|
85 |
|
|
86 |
private void fireContentsChanged() { |
|
87 |
if( !SwingUtilities.isEventDispatchThread() ) { |
|
88 |
SwingUtilities.invokeLater(this::fireContentsChanged); |
|
89 |
return; |
|
90 |
} |
|
91 |
this.fireTableDataChanged(); |
|
92 |
} |
|
93 |
|
|
94 |
@Override |
|
95 |
public String getFilter() { |
|
96 |
return this.filter; |
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
100 |
public void sort(final boolean ascending) { |
|
101 |
this.sortBackground(ascending); |
|
102 |
} |
|
103 |
|
|
104 |
private void sortBackground(final boolean ascending) { |
|
105 |
Thread th = new Thread(() -> { |
|
106 |
sortForeground(ascending); |
|
107 |
}, "FilteredTableModelSorter"); |
|
108 |
th.start(); |
|
109 |
} |
|
110 |
|
|
111 |
private void sortForeground(final boolean ascending) { |
|
112 |
filteredElements.sort((Integer row1, Integer row2) -> { |
|
113 |
try { |
|
114 |
int r; |
|
115 |
Comparable o1 = (Comparable) baseModel.getValueAt(row1, filterColumn); |
|
116 |
Comparable o2 = (Comparable) baseModel.getValueAt(row2, filterColumn); |
|
117 |
if( isCaseSensitive() ) { |
|
118 |
r = CompareUtils.compare(o1, o2); |
|
119 |
} else { |
|
120 |
r = ObjectUtils.compare(o1, o2); |
|
121 |
} |
|
122 |
if (ascending) { |
|
123 |
return r; |
|
124 |
} |
|
125 |
return r * -1; |
|
126 |
} catch(Exception ex) { |
|
127 |
return 0; |
|
128 |
} |
|
129 |
}); |
|
130 |
fireContentsChanged(); |
|
131 |
} |
|
132 |
|
|
133 |
@Override |
|
134 |
public int getRowCount() { |
|
135 |
return this.filteredElements.size(); |
|
136 |
} |
|
137 |
|
|
138 |
@Override |
|
139 |
public int getColumnCount() { |
|
140 |
return this.baseModel.getColumnCount(); |
|
141 |
} |
|
142 |
|
|
143 |
@Override |
|
144 |
public Object getValueAt(int rowIndex, int columnIndex) { |
|
145 |
int row = this.filteredElements.get(rowIndex); |
|
146 |
return this.baseModel.getValueAt(row, columnIndex); |
|
147 |
} |
|
148 |
|
|
149 |
@Override |
|
150 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
|
151 |
int row = this.filteredElements.get(rowIndex); |
|
152 |
this.baseModel.setValueAt(aValue, row, columnIndex); |
|
153 |
} |
|
154 |
|
|
155 |
@Override |
|
156 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
|
157 |
int row = this.filteredElements.get(rowIndex); |
|
158 |
return this.baseModel.isCellEditable(row, columnIndex); |
|
159 |
} |
|
160 |
|
|
161 |
@Override |
|
162 |
public void setCaseSensitive(boolean sensitive) { |
|
163 |
this.caseSensitive = sensitive; |
|
164 |
} |
|
165 |
|
|
166 |
@Override |
|
167 |
public boolean isCaseSensitive() { |
|
168 |
return this.caseSensitive; |
|
169 |
} |
|
170 |
|
|
171 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.300/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/DefaultColorChooserController.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.tools.swing.impl; |
|
3 |
|
|
4 |
import java.awt.Color; |
|
5 |
import java.awt.Font; |
|
6 |
import java.awt.event.ActionEvent; |
|
7 |
import java.awt.event.ActionListener; |
|
8 |
|
|
9 |
import javax.swing.JButton; |
|
10 |
import javax.swing.JColorChooser; |
|
11 |
import javax.swing.JSlider; |
|
12 |
import javax.swing.SwingUtilities; |
|
13 |
import javax.swing.event.ChangeEvent; |
|
14 |
import javax.swing.event.ChangeListener; |
|
15 |
import javax.swing.text.JTextComponent; |
|
16 |
|
|
17 |
import org.gvsig.tools.ToolsLocator; |
|
18 |
import org.gvsig.tools.i18n.I18nManager; |
|
19 |
import org.gvsig.tools.swing.api.ColorChooserController; |
|
20 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
21 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
22 |
|
|
23 |
public class DefaultColorChooserController implements ColorChooserController { |
|
24 |
|
|
25 |
private final JTextComponent txtLabel; |
|
26 |
private final JButton btnShowDialog; |
|
27 |
private final JSlider sldAlpha; |
|
28 |
private Color color; |
|
29 |
private boolean allowNull; |
|
30 |
private ChangeListener changeListener; |
|
31 |
|
|
32 |
public DefaultColorChooserController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull) { |
|
33 |
this.txtLabel = txtLabel; |
|
34 |
this.btnShowDialog = btnShowDialog; |
|
35 |
this.sldAlpha = sldAlpha; |
|
36 |
|
|
37 |
// Remove the listeners to prevent strange behavior when you call this |
|
38 |
// class repeatedly with the same button and slider. |
|
39 |
for(ActionListener l : btnShowDialog.getActionListeners()) { |
|
40 |
btnShowDialog.removeActionListener(l); |
|
41 |
} |
|
42 |
for( ChangeListener l : sldAlpha.getChangeListeners()) { |
|
43 |
sldAlpha.removeChangeListener(l); |
|
44 |
} |
|
45 |
this.btnShowDialog.addActionListener((ActionEvent e) -> { |
|
46 |
doShowDialog(); |
|
47 |
}); |
|
48 |
if( this.sldAlpha != null ) { |
|
49 |
this.sldAlpha.setMinimum(0); |
|
50 |
this.sldAlpha.setMaximum(255); |
|
51 |
this.sldAlpha.addChangeListener((ChangeEvent e) -> { |
|
52 |
doAlphaChanged(); |
|
53 |
}); |
|
54 |
} |
|
55 |
Font font = this.txtLabel.getFont(); |
|
56 |
try { |
|
57 |
font = new Font(Font.MONOSPACED, Font.PLAIN, font.getSize()); |
|
58 |
this.txtLabel.setFont(font); |
|
59 |
} catch(Exception ex) { |
|
60 |
// If dont set a monospaced font ignore it. |
|
61 |
font = null; |
|
62 |
} |
|
63 |
this.allowNull = allowNull; |
|
64 |
if( !this.allowNull ) { |
|
65 |
this.color = Color.BLACK; |
|
66 |
} |
|
67 |
} |
|
68 |
|
|
69 |
public DefaultColorChooserController(JTextComponent txtLabel, JButton btnShowDialog) { |
|
70 |
this(txtLabel, btnShowDialog, null, false); |
|
71 |
} |
|
72 |
|
|
73 |
public DefaultColorChooserController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha) { |
|
74 |
this(txtLabel, btnShowDialog, sldAlpha, false); |
|
75 |
} |
|
76 |
|
|
77 |
private void doAlphaChanged() { |
|
78 |
if( this.color == null ) { |
|
79 |
set(Color.BLACK); |
|
80 |
} |
|
81 |
int alpha = 255; |
|
82 |
if( this.sldAlpha == null ) { |
|
83 |
set(new Color( |
|
84 |
color.getRed(), |
|
85 |
color.getGreen(), |
|
86 |
color.getBlue() |
|
87 |
)); |
|
88 |
} else { |
|
89 |
alpha = this.sldAlpha.getValue(); |
|
90 |
set(new Color( |
|
91 |
color.getRed(), |
|
92 |
color.getGreen(), |
|
93 |
color.getBlue(), |
|
94 |
alpha |
|
95 |
)); |
|
96 |
} |
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
100 |
public void addChangeListener(ChangeListener changeListener) { |
|
101 |
this.changeListener = changeListener; |
|
102 |
} |
|
103 |
|
|
104 |
protected void fireChanged() { |
|
105 |
if( this.changeListener != null ) { |
|
106 |
this.changeListener.stateChanged(null); |
|
107 |
} |
|
108 |
} |
|
109 |
|
|
110 |
protected void doShowDialog() { |
|
111 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
112 |
Color c = JColorChooser.showDialog( |
|
113 |
SwingUtilities.windowForComponent(this.btnShowDialog), |
|
114 |
i18n.getTranslation("choose_color"), |
|
115 |
this.get() |
|
116 |
); |
|
117 |
if( c == null ) { |
|
118 |
return; |
|
119 |
} |
|
120 |
set(c); |
|
121 |
} |
|
122 |
|
|
123 |
@Override |
|
124 |
public void set(Color color) { |
|
125 |
if( color == null ) { |
|
126 |
if( allowNull ) { |
|
127 |
this.color = null; |
|
128 |
return; |
|
129 |
} |
|
130 |
color = Color.BLACK; |
|
131 |
} |
|
132 |
ToolsSwingManager manager = ToolsSwingLocator.getToolsSwingManager(); |
|
133 |
this.color = color; |
|
134 |
String text = String.format("%02x %02x%02x%02x",color.getAlpha(),color.getRed(),color.getGreen(),color.getBlue()); |
|
135 |
this.txtLabel.setBackground(manager.opaqueColor(this.color)); |
|
136 |
this.txtLabel.setText(text); |
|
137 |
if( this.sldAlpha != null ) { |
|
138 |
this.sldAlpha.setValue(this.color.getAlpha()); |
|
139 |
} |
|
140 |
this.txtLabel.invalidate(); |
|
141 |
} |
|
142 |
|
|
143 |
@Override |
|
144 |
public Color get() { |
|
145 |
return this.color; |
|
146 |
} |
|
147 |
|
|
148 |
@Override |
|
149 |
public void setEnabled(boolean enabled) { |
|
150 |
this.txtLabel.setEditable(enabled); |
|
151 |
this.btnShowDialog.setEnabled(enabled); |
|
152 |
if( this.sldAlpha!=null ) { |
|
153 |
this.sldAlpha.setEnabled(enabled); |
|
154 |
} |
|
155 |
} |
|
156 |
|
|
157 |
@Override |
|
158 |
public boolean isEnabled() { |
|
159 |
return this.btnShowDialog.isEnabled(); |
|
160 |
} |
|
161 |
|
|
162 |
|
|
163 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.300/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/coerce/CoerceToColor.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.tools.swing.impl.coerce; |
|
25 |
|
|
26 |
import java.awt.Color; |
|
27 |
import java.util.HashMap; |
|
28 |
import java.util.Map; |
|
29 |
import org.apache.commons.lang3.StringUtils; |
|
30 |
import org.apache.commons.lang3.math.NumberUtils; |
|
31 |
import org.gvsig.tools.ToolsLocator; |
|
32 |
import org.gvsig.tools.dataTypes.AbstractCoercion; |
|
33 |
import org.gvsig.tools.dataTypes.CoercionContext; |
|
34 |
import org.gvsig.tools.dataTypes.CoercionException; |
|
35 |
import org.gvsig.tools.dataTypes.DataTypesManager; |
|
36 |
import org.gvsig.tools.swing.api.DataTypes; |
|
37 |
|
|
38 |
public class CoerceToColor extends AbstractCoercion { |
|
39 |
|
|
40 |
private static Map<String, Color> colorTable = null; |
|
41 |
|
|
42 |
@Override |
|
43 |
@SuppressWarnings("UseSpecificCatch") |
|
44 |
public Object coerce(Object value, CoercionContext context) throws CoercionException { |
|
45 |
if (value == null || value instanceof Color) { |
|
46 |
return value; |
|
47 |
} |
|
48 |
try { |
|
49 |
if (value instanceof Number) { |
|
50 |
int rgb = ((Number) value).intValue(); |
|
51 |
Color color = new Color(rgb); // Alpha?? |
|
52 |
return color; |
|
53 |
} |
|
54 |
String s = value.toString().trim(); |
|
55 |
if (s.startsWith("rgb(")) { |
|
56 |
s = s.replace(")", ""); |
|
57 |
String[] x = StringUtils.split(s, ","); |
|
58 |
if (x.length < 3 || x.length > 4) { |
|
59 |
throw new CoercionException("Can't convert '" + value.toString() + "' to color."); |
|
60 |
} |
|
61 |
try { |
|
62 |
Color color; |
|
63 |
int r = NumberUtils.createInteger(x[0]); |
|
64 |
int g = NumberUtils.createInteger(x[1]); |
|
65 |
int b = NumberUtils.createInteger(x[2]); |
|
66 |
if (x.length == 3) { |
|
67 |
color = new Color(r, g, b); |
|
68 |
} else { |
|
69 |
int a = NumberUtils.createInteger(x[3]); |
|
70 |
color = new Color(r, g, b, a); |
|
71 |
} |
|
72 |
return color; |
|
73 |
} catch (NumberFormatException ex) { |
|
74 |
throw new CoercionException("Can't convert '" + value.toString() + "' to color."); |
|
75 |
} |
|
76 |
|
|
77 |
} |
|
78 |
if (s.startsWith("#")) { |
|
79 |
s = "0x" + s.substring(1); |
|
80 |
} |
|
81 |
try { |
|
82 |
int rgb = NumberUtils.createInteger(s); |
|
83 |
Color color = new Color(rgb); |
|
84 |
return color; |
|
85 |
} catch (NumberFormatException ex) { |
|
86 |
// Pass, do nothing |
|
87 |
} |
|
88 |
Color color = this.getColor(s); |
|
89 |
if (color == null) { |
|
90 |
throw new CoercionException("Can't convert '" + value.toString() + "' to color."); |
|
91 |
} |
|
92 |
return color; |
|
93 |
} catch (Exception e) { |
|
94 |
throw new CoercionException(e); |
|
95 |
} |
|
96 |
|
|
97 |
} |
|
98 |
|
|
99 |
private Color getColor(String name) { |
|
100 |
if (colorTable == null) { |
|
101 |
// |
|
102 |
// HTML Color Names |
|
103 |
// from https://www.w3schools.com/colors/colors_names.asp |
|
104 |
// |
|
105 |
colorTable = new HashMap<>(); |
|
106 |
colorTable.put("aliceblue", new Color(0xF0, 0xF8, 0xFF)); |
|
107 |
colorTable.put("antiquewhite", new Color(0xFA, 0xEB, 0xD7)); |
|
108 |
colorTable.put("aqua", new Color(0x00, 0xFF, 0xFF)); |
|
109 |
colorTable.put("aquamarine", new Color(0x7F, 0xFF, 0xD4)); |
|
110 |
colorTable.put("azure", new Color(0xF0, 0xFF, 0xFF)); |
|
111 |
colorTable.put("beige", new Color(0xF5, 0xF5, 0xDC)); |
|
112 |
colorTable.put("bisque", new Color(0xFF, 0xE4, 0xC4)); |
|
113 |
colorTable.put("black", new Color(0x00, 0x00, 0x00)); |
|
114 |
colorTable.put("blanchedalmond", new Color(0xFF, 0xEB, 0xCD)); |
|
115 |
colorTable.put("blue", new Color(0x00, 0x00, 0xFF)); |
|
116 |
colorTable.put("blueviolet", new Color(0x8A, 0x2B, 0xE2)); |
|
117 |
colorTable.put("brown", new Color(0xA5, 0x2A, 0x2A)); |
|
118 |
colorTable.put("burlywood", new Color(0xDE, 0xB8, 0x87)); |
|
119 |
colorTable.put("cadetblue", new Color(0x5F, 0x9E, 0xA0)); |
|
120 |
colorTable.put("chartreuse", new Color(0x7F, 0xFF, 0x00)); |
|
121 |
colorTable.put("chocolate", new Color(0xD2, 0x69, 0x1E)); |
|
122 |
colorTable.put("coral", new Color(0xFF, 0x7F, 0x50)); |
|
123 |
colorTable.put("cornflowerblue", new Color(0x64, 0x95, 0xED)); |
|
124 |
colorTable.put("cornsilk", new Color(0xFF, 0xF8, 0xDC)); |
|
125 |
colorTable.put("crimson", new Color(0xDC, 0x14, 0x3C)); |
|
126 |
colorTable.put("cyan", new Color(0x00, 0xFF, 0xFF)); |
|
127 |
colorTable.put("darkblue", new Color(0x00, 0x00, 0x8B)); |
|
128 |
colorTable.put("darkcyan", new Color(0x00, 0x8B, 0x8B)); |
|
129 |
colorTable.put("darkgoldenrod", new Color(0xB8, 0x86, 0x0B)); |
|
130 |
colorTable.put("darkgray", new Color(0xA9, 0xA9, 0xA9)); |
|
131 |
colorTable.put("darkgrey", new Color(0xA9, 0xA9, 0xA9)); |
|
132 |
colorTable.put("darkgreen", new Color(0x00, 0x64, 0x00)); |
|
133 |
colorTable.put("darkkhaki", new Color(0xBD, 0xB7, 0x6B)); |
|
134 |
colorTable.put("darkmagenta", new Color(0x8B, 0x00, 0x8B)); |
|
135 |
colorTable.put("darkolivegreen", new Color(0x55, 0x6B, 0x2F)); |
|
136 |
colorTable.put("darkorange", new Color(0xFF, 0x8C, 0x00)); |
|
137 |
colorTable.put("darkorchid", new Color(0x99, 0x32, 0xCC)); |
|
138 |
colorTable.put("darkred", new Color(0x8B, 0x00, 0x00)); |
|
139 |
colorTable.put("darksalmon", new Color(0xE9, 0x96, 0x7A)); |
|
140 |
colorTable.put("darkseagreen", new Color(0x8F, 0xBC, 0x8F)); |
|
141 |
colorTable.put("darkslateblue", new Color(0x48, 0x3D, 0x8B)); |
|
142 |
colorTable.put("darkslategray", new Color(0x2F, 0x4F, 0x4F)); |
|
143 |
colorTable.put("darkslategrey", new Color(0x2F, 0x4F, 0x4F)); |
|
144 |
colorTable.put("darkturquoise", new Color(0x00, 0xCE, 0xD1)); |
|
145 |
colorTable.put("darkviolet", new Color(0x94, 0x00, 0xD3)); |
|
146 |
colorTable.put("deeppink", new Color(0xFF, 0x14, 0x93)); |
|
147 |
colorTable.put("deepskyblue", new Color(0x00, 0xBF, 0xFF)); |
|
148 |
colorTable.put("dimgray", new Color(0x69, 0x69, 0x69)); |
|
149 |
colorTable.put("dimgrey", new Color(0x69, 0x69, 0x69)); |
|
150 |
colorTable.put("dodgerblue", new Color(0x1E, 0x90, 0xFF)); |
|
151 |
colorTable.put("firebrick", new Color(0xB2, 0x22, 0x22)); |
|
152 |
colorTable.put("floralwhite", new Color(0xFF, 0xFA, 0xF0)); |
|
153 |
colorTable.put("forestgreen", new Color(0x22, 0x8B, 0x22)); |
|
154 |
colorTable.put("fuchsia", new Color(0xFF, 0x00, 0xFF)); |
|
155 |
colorTable.put("gainsboro", new Color(0xDC, 0xDC, 0xDC)); |
|
156 |
colorTable.put("ghostwhite", new Color(0xF8, 0xF8, 0xFF)); |
|
157 |
colorTable.put("gold", new Color(0xFF, 0xD7, 0x00)); |
|
158 |
colorTable.put("goldenrod", new Color(0xDA, 0xA5, 0x20)); |
|
159 |
colorTable.put("gray", new Color(0x80, 0x80, 0x80)); |
|
160 |
colorTable.put("grey", new Color(0x80, 0x80, 0x80)); |
|
161 |
colorTable.put("green", new Color(0x00, 0x80, 0x00)); |
|
162 |
colorTable.put("greenyellow", new Color(0xAD, 0xFF, 0x2F)); |
|
163 |
colorTable.put("honeydew", new Color(0xF0, 0xFF, 0xF0)); |
|
164 |
colorTable.put("hotpink", new Color(0xFF, 0x69, 0xB4)); |
|
165 |
colorTable.put("indianred", new Color(0xCD, 0x5C, 0x5C)); |
|
166 |
colorTable.put("indigo", new Color(0x4B, 0x00, 0x82)); |
|
167 |
colorTable.put("ivory", new Color(0xFF, 0xFF, 0xF0)); |
|
168 |
colorTable.put("khaki", new Color(0xF0, 0xE6, 0x8C)); |
|
169 |
colorTable.put("lavender", new Color(0xE6, 0xE6, 0xFA)); |
|
170 |
colorTable.put("lavenderblush", new Color(0xFF, 0xF0, 0xF5)); |
|
171 |
colorTable.put("lawngreen", new Color(0x7C, 0xFC, 0x00)); |
|
172 |
colorTable.put("lemonchiffon", new Color(0xFF, 0xFA, 0xCD)); |
|
173 |
colorTable.put("lightblue", new Color(0xAD, 0xD8, 0xE6)); |
|
174 |
colorTable.put("lightcoral", new Color(0xF0, 0x80, 0x80)); |
|
175 |
colorTable.put("lightcyan", new Color(0xE0, 0xFF, 0xFF)); |
|
176 |
colorTable.put("lightgoldenrodyellow", new Color(0xFA, 0xFA, 0xD2)); |
|
177 |
colorTable.put("lightgray", new Color(0xD3, 0xD3, 0xD3)); |
|
178 |
colorTable.put("lightgrey", new Color(0xD3, 0xD3, 0xD3)); |
|
179 |
colorTable.put("lightgreen", new Color(0x90, 0xEE, 0x90)); |
|
180 |
colorTable.put("lightpink", new Color(0xFF, 0xB6, 0xC1)); |
|
181 |
colorTable.put("lightsalmon", new Color(0xFF, 0xA0, 0x7A)); |
|
182 |
colorTable.put("lightseagreen", new Color(0x20, 0xB2, 0xAA)); |
|
183 |
colorTable.put("lightskyblue", new Color(0x87, 0xCE, 0xFA)); |
|
184 |
colorTable.put("lightslategray", new Color(0x77, 0x88, 0x99)); |
|
185 |
colorTable.put("lightslategrey", new Color(0x77, 0x88, 0x99)); |
|
186 |
colorTable.put("lightsteelblue", new Color(0xB0, 0xC4, 0xDE)); |
|
187 |
colorTable.put("lightyellow", new Color(0xFF, 0xFF, 0xE0)); |
|
188 |
colorTable.put("lime", new Color(0x00, 0xFF, 0x00)); |
|
189 |
colorTable.put("limegreen", new Color(0x32, 0xCD, 0x32)); |
|
190 |
colorTable.put("linen", new Color(0xFA, 0xF0, 0xE6)); |
|
191 |
colorTable.put("magenta", new Color(0xFF, 0x00, 0xFF)); |
|
192 |
colorTable.put("maroon", new Color(0x80, 0x00, 0x00)); |
|
193 |
colorTable.put("mediumaquamarine", new Color(0x66, 0xCD, 0xAA)); |
|
194 |
colorTable.put("mediumblue", new Color(0x00, 0x00, 0xCD)); |
|
195 |
colorTable.put("mediumorchid", new Color(0xBA, 0x55, 0xD3)); |
|
196 |
colorTable.put("mediumpurple", new Color(0x93, 0x70, 0xDB)); |
|
197 |
colorTable.put("mediumseagreen", new Color(0x3C, 0xB3, 0x71)); |
|
198 |
colorTable.put("mediumslateblue", new Color(0x7B, 0x68, 0xEE)); |
|
199 |
colorTable.put("mediumspringgreen", new Color(0x00, 0xFA, 0x9A)); |
|
200 |
colorTable.put("mediumturquoise", new Color(0x48, 0xD1, 0xCC)); |
|
201 |
colorTable.put("mediumvioletred", new Color(0xC7, 0x15, 0x85)); |
|
202 |
colorTable.put("midnightblue", new Color(0x19, 0x19, 0x70)); |
|
203 |
colorTable.put("mintcream", new Color(0xF5, 0xFF, 0xFA)); |
|
204 |
colorTable.put("mistyrose", new Color(0xFF, 0xE4, 0xE1)); |
|
205 |
colorTable.put("moccasin", new Color(0xFF, 0xE4, 0xB5)); |
|
206 |
colorTable.put("navajowhite", new Color(0xFF, 0xDE, 0xAD)); |
|
207 |
colorTable.put("navy", new Color(0x00, 0x00, 0x80)); |
|
208 |
colorTable.put("oldlace", new Color(0xFD, 0xF5, 0xE6)); |
|
209 |
colorTable.put("olive", new Color(0x80, 0x80, 0x00)); |
|
210 |
colorTable.put("olivedrab", new Color(0x6B, 0x8E, 0x23)); |
|
211 |
colorTable.put("orange", new Color(0xFF, 0xA5, 0x00)); |
|
212 |
colorTable.put("orangered", new Color(0xFF, 0x45, 0x00)); |
|
213 |
colorTable.put("orchid", new Color(0xDA, 0x70, 0xD6)); |
|
214 |
colorTable.put("palegoldenrod", new Color(0xEE, 0xE8, 0xAA)); |
|
215 |
colorTable.put("palegreen", new Color(0x98, 0xFB, 0x98)); |
|
216 |
colorTable.put("paleturquoise", new Color(0xAF, 0xEE, 0xEE)); |
|
217 |
colorTable.put("palevioletred", new Color(0xDB, 0x70, 0x93)); |
|
218 |
colorTable.put("papayawhip", new Color(0xFF, 0xEF, 0xD5)); |
|
219 |
colorTable.put("peachpuff", new Color(0xFF, 0xDA, 0xB9)); |
|
220 |
colorTable.put("peru", new Color(0xCD, 0x85, 0x3F)); |
|
221 |
colorTable.put("pink", new Color(0xFF, 0xC0, 0xCB)); |
|
222 |
colorTable.put("plum", new Color(0xDD, 0xA0, 0xDD)); |
|
223 |
colorTable.put("powderblue", new Color(0xB0, 0xE0, 0xE6)); |
|
224 |
colorTable.put("purple", new Color(0x80, 0x00, 0x80)); |
|
225 |
colorTable.put("rebeccapurple", new Color(0x66, 0x33, 0x99)); |
|
226 |
colorTable.put("red", new Color(0xFF, 0x00, 0x00)); |
|
227 |
colorTable.put("rosybrown", new Color(0xBC, 0x8F, 0x8F)); |
|
228 |
colorTable.put("royalblue", new Color(0x41, 0x69, 0xE1)); |
|
229 |
colorTable.put("saddlebrown", new Color(0x8B, 0x45, 0x13)); |
|
230 |
colorTable.put("salmon", new Color(0xFA, 0x80, 0x72)); |
|
231 |
colorTable.put("sandybrown", new Color(0xF4, 0xA4, 0x60)); |
|
232 |
colorTable.put("seagreen", new Color(0x2E, 0x8B, 0x57)); |
|
233 |
colorTable.put("seashell", new Color(0xFF, 0xF5, 0xEE)); |
|
234 |
colorTable.put("sienna", new Color(0xA0, 0x52, 0x2D)); |
|
235 |
colorTable.put("silver", new Color(0xC0, 0xC0, 0xC0)); |
|
236 |
colorTable.put("skyblue", new Color(0x87, 0xCE, 0xEB)); |
|
237 |
colorTable.put("slateblue", new Color(0x6A, 0x5A, 0xCD)); |
|
238 |
colorTable.put("Slategray", new Color(0x70, 0x80, 0x90)); |
|
239 |
colorTable.put("slategrey", new Color(0x70, 0x80, 0x90)); |
|
240 |
colorTable.put("snow", new Color(0xFF, 0xFA, 0xFA)); |
|
241 |
colorTable.put("springgreen", new Color(0x00, 0xFF, 0x7F)); |
|
242 |
colorTable.put("steelblue", new Color(0x46, 0x82, 0xB4)); |
|
243 |
colorTable.put("tan", new Color(0xD2, 0xB4, 0x8C)); |
|
244 |
colorTable.put("teal", new Color(0x00, 0x80, 0x80)); |
|
245 |
colorTable.put("thistle", new Color(0xD8, 0xBF, 0xD8)); |
|
246 |
colorTable.put("tomato", new Color(0xFF, 0x63, 0x47)); |
|
247 |
colorTable.put("turquoise", new Color(0x40, 0xE0, 0xD0)); |
|
248 |
colorTable.put("violet", new Color(0xEE, 0x82, 0xEE)); |
|
249 |
colorTable.put("wheat", new Color(0xF5, 0xDE, 0xB3)); |
|
250 |
colorTable.put("white", new Color(0xFF, 0xFF, 0xFF)); |
|
251 |
colorTable.put("whitesmoke", new Color(0xF5, 0xF5, 0xF5)); |
|
252 |
colorTable.put("yellow", new Color(0xFF, 0xFF, 0x00)); |
|
253 |
colorTable.put("yellowgreen", new Color(0x9A, 0xCD, 0x32)); |
|
254 |
} |
|
255 |
return colorTable.get(name.toLowerCase()); |
|
256 |
} |
|
257 |
|
|
258 |
public static class CoerceColorToString extends AbstractCoercion { |
|
259 |
|
|
260 |
@Override |
|
261 |
public Object coerce(Object value, CoercionContext context) throws CoercionException { |
|
262 |
if (value == null || value instanceof String) { |
|
263 |
return value; |
|
264 |
} |
|
265 |
if (value instanceof Color) { |
|
266 |
int rgb = ((Color) value).getRGB(); |
|
267 |
int r = ((Color) value).getRed(); |
|
268 |
int g = ((Color) value).getGreen(); |
|
269 |
int b = ((Color) value).getBlue(); |
|
270 |
int a = ((Color) value).getAlpha(); |
|
271 |
for (Map.Entry<String, Color> entry : colorTable.entrySet()) { |
|
272 |
String name = entry.getKey(); |
|
273 |
Color color = entry.getValue(); |
|
274 |
if (rgb == color.getRGB() && color.getAlpha() == a) { |
|
275 |
return name; |
|
276 |
} |
|
277 |
} |
|
278 |
return String.format("rgb(0x%02x,0x%02x,0x%02x,0x%02x)", r, g, b, a); |
|
279 |
} |
|
280 |
throw new CoercionException("Can't convert '" + value.getClass().getName() + "' to string"); |
|
281 |
} |
|
282 |
|
|
283 |
} |
|
284 |
|
|
285 |
public static void selfRegister() { |
|
286 |
DataTypesManager dataTypesManager = ToolsLocator.getDataTypesManager(); |
|
287 |
dataTypesManager.addtype(DataTypes.COLOR, null, "Color", Color.class, new CoerceToColor()); |
|
288 |
dataTypesManager.addCoercion(DataTypes.STRING, new CoerceColorToString()); |
|
289 |
} |
|
290 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.300/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/task/DefaultJTaskStatusView.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.tools.swing.impl.task; |
|
25 |
|
|
26 |
import java.awt.Component; |
|
27 |
import java.awt.Dimension; |
|
28 |
import java.awt.GridBagConstraints; |
|
29 |
import java.awt.GridBagLayout; |
|
30 |
import javax.swing.JButton; |
|
31 |
import javax.swing.JLabel; |
|
32 |
import javax.swing.JPanel; |
|
33 |
import javax.swing.JProgressBar; |
|
34 |
import org.gvsig.tools.swing.api.task.JTaskStatus; |
|
35 |
|
|
36 |
/** |
|
37 |
* Default implementation of the view component of {@link JTaskStatus}. |
|
38 |
* |
|
39 |
* @author gvSIG Team |
|
40 |
* @version $Id$ |
|
41 |
*/ |
|
42 |
public class DefaultJTaskStatusView { |
|
43 |
|
|
44 |
protected JLabel titlelabel = null; |
|
45 |
protected JLabel messagelabel = null; |
|
46 |
protected JProgressBar progressBar = null; |
|
47 |
protected JButton cancelRequestButton = null; |
|
48 |
protected JButton removeTaskButton; |
|
49 |
|
|
50 |
|
|
51 |
public DefaultJTaskStatusView(JPanel panel) { |
|
52 |
this.initComponents(panel); |
|
53 |
} |
|
54 |
|
|
55 |
private void initComponents(JPanel panel) { |
|
56 |
this.titlelabel = new JLabel(); |
|
57 |
|
|
58 |
this.progressBar = new JProgressBar(1, 100); |
|
59 |
this.progressBar.setPreferredSize(new Dimension(200, 10)); |
|
60 |
this.progressBar.setBorderPainted(true); |
|
61 |
|
|
62 |
this.cancelRequestButton = new JButton(); |
|
63 |
this.cancelRequestButton.setPreferredSize(new Dimension(16, 16)); |
|
64 |
this.cancelRequestButton.setBorderPainted(false); |
|
65 |
|
|
66 |
this.removeTaskButton = new JButton(); |
|
67 |
this.removeTaskButton.setPreferredSize(new Dimension(16, 16)); |
|
68 |
this.removeTaskButton.setBorderPainted(false); |
|
69 |
|
|
70 |
this.messagelabel = new JLabel(); |
|
71 |
|
|
72 |
panel.setLayout(new GridBagLayout()); |
|
73 |
|
|
74 |
this.add(panel, this.titlelabel, 0, 0, GridBagConstraints.HORIZONTAL, 0.98, 0); |
|
75 |
this.add(panel, this.progressBar, 0, 1, GridBagConstraints.HORIZONTAL, 0.98, 0); |
|
76 |
this.add(panel, this.messagelabel, 0, 2, GridBagConstraints.HORIZONTAL, 0.98, 0); |
|
77 |
this.add(panel, this.cancelRequestButton, 1, 1, GridBagConstraints.NONE, 0.01, 0); |
|
78 |
this.add(panel, this.removeTaskButton, 2, 1, GridBagConstraints.NONE, 0.01, 0); |
|
79 |
} |
|
80 |
|
|
81 |
private void add(JPanel panel, Component comp, int gridx, int gridy, int fill, double weightx, double weighty) { |
|
82 |
GridBagConstraints c = new GridBagConstraints(); |
|
83 |
c.fill = fill; |
|
84 |
c.gridx = gridx; |
|
85 |
c.gridy = gridy; |
|
86 |
c.weightx = weightx; |
|
87 |
c.weighty = weighty; |
|
88 |
panel.add(comp, c); |
|
89 |
} |
|
90 |
|
|
91 |
} |
|
0 | 92 |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.300/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/task/DefaultJTasksStatusList.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2021 gvSIG Association. |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.tools.swing.impl.task; |
|
25 |
|
|
26 |
import java.awt.BorderLayout; |
|
27 |
import java.awt.Component; |
|
28 |
import java.awt.Dimension; |
|
29 |
import java.util.ArrayList; |
|
30 |
import java.util.EventObject; |
|
31 |
import java.util.List; |
|
32 |
import java.util.Objects; |
|
33 |
|
|
34 |
import javax.swing.JLabel; |
|
35 |
import javax.swing.JScrollPane; |
|
36 |
import javax.swing.JTable; |
|
37 |
import javax.swing.SwingUtilities; |
|
38 |
import javax.swing.event.CellEditorListener; |
|
39 |
import javax.swing.table.AbstractTableModel; |
|
40 |
import javax.swing.table.DefaultTableColumnModel; |
|
41 |
import javax.swing.table.TableCellEditor; |
|
42 |
import javax.swing.table.TableCellRenderer; |
|
43 |
import javax.swing.table.TableColumn; |
|
44 |
import javax.swing.table.TableModel; |
|
45 |
|
|
46 |
import org.gvsig.tools.observer.Observable; |
|
47 |
import org.gvsig.tools.observer.Observer; |
|
48 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
49 |
import org.gvsig.tools.swing.api.task.JTaskStatus; |
|
50 |
import org.gvsig.tools.swing.api.task.JTasksStatusList; |
|
51 |
import org.gvsig.tools.swing.api.task.TaskStatusSwingManager; |
|
52 |
import org.gvsig.tools.task.TaskStatus; |
|
53 |
import org.gvsig.tools.task.TaskStatusManager; |
|
54 |
import org.slf4j.Logger; |
|
55 |
import org.slf4j.LoggerFactory; |
|
56 |
|
|
57 |
/** |
|
58 |
* Default implementation of the {@link JTasksStatusList}. |
|
59 |
* |
|
60 |
* @author gvSIG Team |
|
61 |
*/ |
|
62 |
public class DefaultJTasksStatusList extends JTasksStatusList implements |
|
63 |
Observer { |
|
64 |
|
|
65 |
public static final Logger LOGGER = LoggerFactory.getLogger(DefaultJTasksStatusList.class); |
|
66 |
|
|
67 |
private static final long serialVersionUID = 7740032506050392725L; |
|
68 |
|
|
69 |
private final TaskStatusManager manager; |
|
70 |
private JTable table; |
|
71 |
|
|
72 |
@SuppressWarnings("LeakingThisInConstructor") |
|
73 |
public DefaultJTasksStatusList(TaskStatusManager manager) { |
|
74 |
this.manager = manager; |
|
75 |
this.makeUI(); |
|
76 |
this.manager.addObserver(this); |
|
77 |
} |
|
78 |
|
|
79 |
@Override |
|
80 |
public TaskStatusManager getManager() { |
|
81 |
return this.manager; |
|
82 |
} |
|
83 |
|
|
84 |
|
|
85 |
private void makeUI() { |
|
86 |
this.setLayout(new BorderLayout()); |
|
87 |
TaskStatusSwingManager swingManager = ToolsSwingLocator.getTaskStatusSwingManager(); |
|
88 |
this.table = new JTable(); |
|
89 |
DefaultTableColumnModel columnModel = new DefaultTableColumnModel(); |
|
90 |
TableColumn tableColumn = new TableColumn( |
|
91 |
0, |
|
92 |
300, |
|
93 |
new TableCellRenderer() { |
|
94 |
JTaskStatus component = swingManager.createJTaskStatus(); |
|
95 |
JLabel empty = new JLabel("???"); |
|
96 |
@Override |
|
97 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
|
98 |
if( value instanceof TaskStatus ) { |
|
99 |
this.component.bind((TaskStatus) value); |
|
100 |
return this.component; |
|
101 |
} |
|
102 |
this.empty.setText("??? "+Objects.toString(value)); |
|
103 |
return this.empty; |
|
104 |
} |
|
105 |
}, |
|
106 |
new TableCellEditor() { |
|
107 |
JTaskStatus component = swingManager.createJTaskStatus(); |
|
108 |
JLabel empty = new JLabel("???"); |
|
109 |
@Override |
|
110 |
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
111 |
if( value instanceof TaskStatus ) { |
|
112 |
this.component.bind((TaskStatus) value); |
|
113 |
return this.component; |
|
114 |
} |
|
115 |
this.empty.setText("??? "+Objects.toString(value)); |
|
116 |
return this.empty; |
|
117 |
} |
|
118 |
|
|
119 |
@Override |
|
120 |
public Object getCellEditorValue() { |
|
121 |
return this.component.getTaskStatus(); |
|
122 |
} |
|
123 |
|
|
124 |
@Override |
|
125 |
public boolean isCellEditable(EventObject anEvent) { |
|
126 |
return true; |
|
127 |
} |
|
128 |
|
|
129 |
@Override |
|
130 |
public boolean shouldSelectCell(EventObject anEvent) { |
|
131 |
return false; |
|
132 |
} |
|
133 |
|
|
134 |
@Override |
|
135 |
public boolean stopCellEditing() { |
|
136 |
return true; |
|
137 |
} |
|
138 |
|
|
139 |
@Override |
|
140 |
public void cancelCellEditing() { |
|
141 |
} |
|
142 |
|
|
143 |
@Override |
|
144 |
public void addCellEditorListener(CellEditorListener l) { |
|
145 |
} |
|
146 |
|
|
147 |
@Override |
|
148 |
public void removeCellEditorListener(CellEditorListener l) { |
|
149 |
} |
|
150 |
} |
|
151 |
); |
|
152 |
JTaskStatus taskStatusHeight = swingManager.createJTaskStatus(); |
|
153 |
taskStatusHeight.setTitle("WWWMMMGGGgggqqqjjjttt"); |
|
154 |
taskStatusHeight.message("WWWMMMGGGgggqqqjjjttt"); |
|
155 |
columnModel.addColumn(tableColumn); |
|
156 |
this.table.setColumnModel(columnModel); |
|
157 |
this.table.setRowHeight(taskStatusHeight.getPreferredSize().height); |
|
158 |
this.table.setAutoCreateColumnsFromModel(false); |
|
159 |
this.table.setTableHeader(null); |
|
160 |
this.table.setModel(this.createModel()); |
|
161 |
JScrollPane scroller = new JScrollPane(table); |
|
162 |
|
|
163 |
scroller.setAlignmentY(Component.TOP_ALIGNMENT); |
|
164 |
scroller.setPreferredSize(new Dimension(300, 150)); |
|
165 |
this.add(scroller, BorderLayout.CENTER); |
|
166 |
} |
|
167 |
|
|
168 |
private TableModel createModel() { |
|
169 |
List<TaskStatus> tasks = new ArrayList<>(this.manager.getAll().values()); |
|
170 |
return new AbstractTableModel() { |
|
171 |
@Override |
|
172 |
public int getRowCount() { |
|
173 |
return tasks.size(); |
|
174 |
} |
|
175 |
|
|
176 |
@Override |
|
177 |
public int getColumnCount() { |
|
178 |
return 1; |
|
179 |
} |
|
180 |
|
|
181 |
@Override |
|
182 |
public String getColumnName(int columnIndex) { |
|
183 |
return null; |
|
184 |
} |
|
185 |
|
|
186 |
@Override |
|
187 |
public Class<?> getColumnClass(int columnIndex) { |
|
188 |
return TaskStatus.class; |
|
189 |
} |
|
190 |
|
|
191 |
@Override |
|
192 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
|
193 |
return true; |
|
194 |
} |
|
195 |
|
|
196 |
@Override |
|
197 |
public Object getValueAt(int rowIndex, int columnIndex) { |
|
198 |
return tasks.get(rowIndex); |
|
199 |
} |
|
200 |
|
|
201 |
@Override |
|
202 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
|
203 |
} |
|
204 |
}; |
|
205 |
} |
|
206 |
|
|
207 |
@Override |
|
208 |
public void update(final Observable observable, final Object notification) { |
|
209 |
if (!(observable instanceof TaskStatusManager)) { |
|
210 |
return; |
|
211 |
} |
|
212 |
if( !SwingUtilities.isEventDispatchThread() ) { |
|
213 |
SwingUtilities.invokeLater(() -> { update(observable, notification); }); |
|
214 |
return; |
|
215 |
} |
|
216 |
if (this.table.isEditing()) { |
|
217 |
this.table.editingCanceled(null); |
|
218 |
} |
|
219 |
this.table.setModel(this.createModel()); |
|
220 |
} |
|
221 |
} |
|
0 | 222 |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.300/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/task/DefaultJTaskStatus.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.tools.swing.impl.task; |
|
25 |
|
|
26 |
import javax.swing.JComponent; |
|
27 |
import org.gvsig.tools.swing.api.task.JTaskStatus; |
|
28 |
import org.gvsig.tools.task.TaskStatus; |
|
29 |
|
|
30 |
/** |
|
31 |
* Default implementation of the {@link JTaskStatus}. |
|
32 |
* |
|
33 |
* @author gvSIG Team |
|
34 |
* @version $Id$ |
|
35 |
*/ |
|
36 |
public class DefaultJTaskStatus extends JTaskStatus { |
|
37 |
|
|
38 |
private DefaultJTaskStatusView view; |
|
39 |
private DefaultJTaskStatusController controller; |
|
40 |
|
|
41 |
public DefaultJTaskStatus(TaskStatus taskStatus) { |
|
42 |
this.view = new DefaultJTaskStatusView(this); |
|
43 |
this.controller = new DefaultJTaskStatusController( |
|
44 |
taskStatus, |
|
45 |
this.view.titlelabel, |
|
46 |
this.view.messagelabel, |
|
47 |
this.view.progressBar, |
|
48 |
this.view.cancelRequestButton, |
|
49 |
this.view.removeTaskButton |
|
50 |
); |
|
51 |
} |
|
52 |
|
|
53 |
public DefaultJTaskStatus() { |
|
54 |
this(null); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public void bind(TaskStatus taskStatus) { |
|
59 |
this.controller.bind(taskStatus); |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public boolean getShowCancelButton() { |
|
64 |
return this.controller.getShowCancelButton(); |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public void setShowCancelButton(boolean showCancelButton) { |
|
69 |
this.controller.setShowCancelButton(showCancelButton); |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public boolean getShowRemoveTaskButton() { |
|
74 |
return this.controller.getShowRemoveTaskButton(); |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public void setShowRemoveTaskButton(boolean showRemoveTaskButton) { |
|
79 |
this.controller.setShowRemoveTaskButton(showRemoveTaskButton); |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public void setTittle(String tittle) { |
|
84 |
this.controller.setTitle(tittle); |
|
85 |
} |
|
86 |
|
|
87 |
@Override |
|
88 |
public void setTitle(String title) { |
|
89 |
this.controller.setTitle(title); |
|
90 |
} |
|
91 |
|
|
92 |
@Override |
|
93 |
public TaskStatus getTaskStatus() { |
|
94 |
return this.controller.getTaskStatus(); |
|
95 |
} |
|
96 |
|
|
97 |
@Override |
|
98 |
public void message(String message) { |
|
99 |
this.controller.message(message); |
|
100 |
} |
|
101 |
|
|
102 |
@Override |
|
103 |
public void setCurValue(long value) { |
|
104 |
this.controller.setCurValue(value); |
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
108 |
public JComponent asJComponent() { |
|
109 |
return this; |
|
110 |
} |
|
111 |
|
|
112 |
|
|
113 |
} |
|
0 | 114 |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.300/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/task/DefaultJTasksStatus.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.tools.swing.impl.task; |
|
25 |
|
|
26 |
import java.awt.Dimension; |
|
27 |
import java.awt.GridBagConstraints; |
|
28 |
import java.awt.GridBagLayout; |
|
29 |
import java.awt.LayoutManager; |
|
30 |
import java.awt.event.ActionEvent; |
|
31 |
import java.awt.event.ActionListener; |
|
32 |
import java.net.URL; |
|
33 |
|
|
34 |
import javax.swing.ImageIcon; |
|
35 |
import javax.swing.JButton; |
|
36 |
import javax.swing.JComponent; |
|
37 |
import javax.swing.JLabel; |
|
38 |
import javax.swing.JProgressBar; |
|
39 |
import javax.swing.SwingUtilities; |
|
40 |
import org.apache.commons.lang3.StringUtils; |
|
41 |
|
|
42 |
import org.gvsig.tools.ToolsLocator; |
|
43 |
import org.gvsig.tools.observer.Observable; |
|
44 |
import org.gvsig.tools.observer.Observer; |
|
45 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
46 |
import org.gvsig.tools.swing.api.task.JTasksStatus; |
|
47 |
import org.gvsig.tools.swing.api.task.JTasksStatusList; |
|
48 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
49 |
import org.gvsig.tools.task.TaskStatus; |
|
50 |
import org.gvsig.tools.task.TaskStatusManager; |
|
51 |
|
|
52 |
/** |
|
53 |
* Default implementation of the {@link JTasksStatus}. |
|
54 |
* |
|
55 |
* @author gvSIG Team |
|
56 |
* @version $Id$ |
|
57 |
*/ |
|
58 |
public class DefaultJTasksStatus extends JTasksStatus implements Observer { |
|
59 |
|
|
60 |
private static final long serialVersionUID = 245436792193991920L; |
|
61 |
|
|
62 |
private TaskStatusManager manager = null; |
|
63 |
private JLabel label = null; |
|
64 |
private JProgressBar progressBar = null; |
|
65 |
private JButton showAllTaskStatusButton = null; |
|
66 |
private int maxLabelSize = 25; |
|
67 |
|
|
68 |
public DefaultJTasksStatus() { |
|
69 |
this(ToolsLocator.getTaskStatusManager()); |
|
70 |
} |
|
71 |
|
|
72 |
public DefaultJTasksStatus(TaskStatusManager manager) { |
|
73 |
this.bind(manager); |
|
74 |
this.createComponents(); |
|
75 |
} |
|
76 |
|
|
77 |
public void setMaxLabelSize(int maxLabelSize) { |
|
78 |
this.maxLabelSize = maxLabelSize; |
|
79 |
} |
|
80 |
|
|
81 |
public int getMaxLabelSize() { |
|
82 |
return this.maxLabelSize; |
|
83 |
} |
|
84 |
|
|
85 |
public JComponent asJComponent() { |
|
86 |
return this; |
|
87 |
} |
|
88 |
|
|
89 |
public void bind(TaskStatusManager manager) { |
|
90 |
if( this.manager!=null ) { |
|
91 |
this.manager.deleteObserver(this); |
|
92 |
} |
|
93 |
this.manager = manager; |
Also available in: Unified diff