Author: kono
Date: 2010-07-22 14:20:55 -0700 (Thu, 22 Jul 2010)
New Revision: 20993
Modified:
cytoscape/trunk/src/cytoscape/visual/CalculatorCatalog.java
cytoscape/trunk/src/cytoscape/visual/ui/VizMapperMainPanel.java
cytoscape/trunk/src/cytoscape/visual/ui/editors/discrete/CyComboBoxPropertyEditor.java
Log:
Combo box editor values were not rendered properly. Fixed by changing label
text for the cell renderer.
Modified: cytoscape/trunk/src/cytoscape/visual/CalculatorCatalog.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/CalculatorCatalog.java 2010-07-22
20:32:10 UTC (rev 20992)
+++ cytoscape/trunk/src/cytoscape/visual/CalculatorCatalog.java 2010-07-22
21:20:55 UTC (rev 20993)
@@ -66,9 +66,9 @@
public class CalculatorCatalog {
private static final String label = "label";
private Map<VisualPropertyType, Map<String, Calculator>> calculators;
- private Map<VisualPropertyType, List> listeners;
+ private Map<VisualPropertyType, List<?>> listeners;
private Map<String, VisualStyle> visualStyles;
- private Map<String, Class> mappers;
+ private Map<String, Class<?>> mappers;
/**
* Only one <code>ChangeEvent</code> is needed per catalog instance
since
@@ -101,12 +101,12 @@
*/
public void clear() {
calculators = new EnumMap<VisualPropertyType, Map<String,
Calculator>>(VisualPropertyType.class);
- listeners = new EnumMap<VisualPropertyType,
List>(VisualPropertyType.class);
+ listeners = new EnumMap<VisualPropertyType,
List<?>>(VisualPropertyType.class);
visualStyles = new HashMap<String, VisualStyle>();
// mapping database
- mappers = new HashMap<String, Class>();
+ mappers = new HashMap<String, Class<?>>();
}
@@ -260,7 +260,7 @@
/**
* Returns the HashMap of mappers
*/
- public Set getMappingNames() {
+ public Set<String> getMappingNames() {
return mappers.keySet();
}
Modified: cytoscape/trunk/src/cytoscape/visual/ui/VizMapperMainPanel.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/ui/VizMapperMainPanel.java
2010-07-22 20:32:10 UTC (rev 20992)
+++ cytoscape/trunk/src/cytoscape/visual/ui/VizMapperMainPanel.java
2010-07-22 21:20:55 UTC (rev 20993)
@@ -674,6 +674,8 @@
*/
private CyComboBoxPropertyEditor nodeAttrEditor = new
CyComboBoxPropertyEditor();
private CyComboBoxPropertyEditor edgeAttrEditor = new
CyComboBoxPropertyEditor();
+
+ //
private CyComboBoxPropertyEditor nodeNumericalAttrEditor = new
CyComboBoxPropertyEditor();
private CyComboBoxPropertyEditor edgeNumericalAttrEditor = new
CyComboBoxPropertyEditor();
@@ -954,7 +956,7 @@
table.setSelectionForeground(Color.blue);
- final Set mappingTypes =
Cytoscape.getVisualMappingManager().getCalculatorCatalog()
+ final Set<String> mappingTypes =
Cytoscape.getVisualMappingManager().getCalculatorCatalog()
.getMappingNames();
mappingTypeEditor.setAvailableValues(mappingTypes.toArray());
Modified:
cytoscape/trunk/src/cytoscape/visual/ui/editors/discrete/CyComboBoxPropertyEditor.java
===================================================================
---
cytoscape/trunk/src/cytoscape/visual/ui/editors/discrete/CyComboBoxPropertyEditor.java
2010-07-22 20:32:10 UTC (rev 20992)
+++
cytoscape/trunk/src/cytoscape/visual/ui/editors/discrete/CyComboBoxPropertyEditor.java
2010-07-22 21:20:55 UTC (rev 20993)
@@ -47,6 +47,7 @@
private static final Color NOT_SELECTED = new Color(51, 51, 255, 150);
private static final Color SELECTED = Color.red;
private static final Font SELECTED_FONT = new Font("SansSerif",
Font.BOLD, 12);
+
private Object oldValue;
private Icon[] icons;
@@ -136,13 +137,15 @@
*
* @param values DOCUMENT ME!
*/
- public void setAvailableValues(Object[] values) {
- ((JComboBox) editor).setModel(new DefaultComboBoxModel(values));
- if(((JComboBox) editor).getItemCount() != 0){
- ((JComboBox) editor).setSelectedIndex(0);
- }
+ public void setAvailableValues(final Object[] values) {
+ final JComboBox cbox = ((JComboBox) editor);
+
+ cbox.setModel(new DefaultComboBoxModel(values));
+ if(cbox.getItemCount() != 0)
+ cbox.setSelectedIndex(0);
}
+
/**
* DOCUMENT ME!
*
@@ -152,39 +155,38 @@
this.icons = icons;
}
- public class Renderer extends DefaultListCellRenderer {
+ class Renderer extends DefaultListCellRenderer {
+
+ private static final long serialVersionUID =
1142732116479667701L;
+
public Component getListCellRendererComponent(JList list,
Object value, int index,
boolean
isSelected, boolean cellHasFocus) {
+
Component component =
super.getListCellRendererComponent(list,
(value instanceof Value)
? ((Value) value).visualValue
: value, index, isSelected,
cellHasFocus);
-
+
if ((icons != null) && (index >= 0) && component
instanceof JLabel)
((JLabel) component).setIcon(icons[index]);
-
- if ((index >= 0) && component instanceof JLabel) {
- }
-
+
+ component.setForeground(NOT_SELECTED);
+ component.setBackground(BACKGROUND);
+
if (value == null) {
+ // Cell is empty. Warn user by showing message.
component = new JLabel("Select Value!");
+ ((JLabel) component).setFont(SELECTED_FONT);
component.setForeground(SELECTED);
- ((JLabel) component).setFont(new
Font("SansSerif", Font.BOLD, 12));
- } else if(((JComboBox) editor).getItemCount() != 0) {
- component = new JLabel(((JComboBox)
editor).getItemAt(0).toString());
- component.setForeground(SELECTED);
- ((JLabel) component).setFont(new
Font("SansSerif", Font.BOLD, 12));
- }
+ } else if(((JComboBox) editor).getItemCount() != 0 &&
value != null)
+ component = new JLabel(value.toString());
if (isSelected) {
component.setForeground(SELECTED);
((JLabel) component).setFont(SELECTED_FONT);
- } else
- component.setForeground(NOT_SELECTED);
+ }
- component.setBackground(BACKGROUND);
-
return component;
}
}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.