Author: kono
Date: 2011-10-10 16:35:04 -0700 (Mon, 10 Oct 2011)
New Revision: 27118
Modified:
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/AbstractVisualPropertyValue.java
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/NodeShapeVisualProperty.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/NodeIcon.java
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/ObjectPositionIcon.java
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/valueeditor/DiscreteValueEditor.java
Log:
fixes #417 Value editor displays human-readable name of the value if such
string is available. Also, fixed broken icon renderer problem.
Modified:
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/AbstractVisualPropertyValue.java
===================================================================
---
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/AbstractVisualPropertyValue.java
2011-10-10 21:42:27 UTC (rev 27117)
+++
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/AbstractVisualPropertyValue.java
2011-10-10 23:35:04 UTC (rev 27118)
@@ -19,5 +19,10 @@
public String getSerializableString() {
return this.serializableString;
}
+
+ @Override
+ public String toString() {
+ return displayName;
+ }
}
Modified:
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/NodeShapeVisualProperty.java
===================================================================
---
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/NodeShapeVisualProperty.java
2011-10-10 21:42:27 UTC (rev 27117)
+++
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/NodeShapeVisualProperty.java
2011-10-10 23:35:04 UTC (rev 27118)
@@ -12,22 +12,14 @@
AbstractVisualProperty<NodeShape> {
// Presets
- public static final NodeShape RECTANGLE = new NodeShapeImpl("Rectangle",
- "RECTANGLE");
- public static final NodeShape ROUND_RECTANGLE = new NodeShapeImpl(
- "Round Rectangle", "ROUND_RECTANGLE");
- public static final NodeShape TRIANGLE = new NodeShapeImpl("Triangle",
- "TRIANGLE");
- public static final NodeShape PARALLELOGRAM = new NodeShapeImpl(
- "Parallelogram", "PARALLELOGRAM");
- public static final NodeShape DIAMOND = new NodeShapeImpl("Diamond",
- "DIAMOND");
- public static final NodeShape ELLIPSE = new NodeShapeImpl("Ellipse",
- "ELLIPSE");
- public static final NodeShape HEXAGON = new NodeShapeImpl("Hexagon",
- "HEXAGON");
- public static final NodeShape OCTAGON = new NodeShapeImpl("Octagon",
- "OCTAGON");
+ public static final NodeShape RECTANGLE = new
NodeShapeImpl("Rectangle", "RECTANGLE");
+ public static final NodeShape ROUND_RECTANGLE = new
NodeShapeImpl("Round Rectangle", "ROUND_RECTANGLE");
+ public static final NodeShape TRIANGLE = new NodeShapeImpl("Triangle",
"TRIANGLE");
+ public static final NodeShape PARALLELOGRAM = new
NodeShapeImpl("Parallelogram", "PARALLELOGRAM");
+ public static final NodeShape DIAMOND = new NodeShapeImpl("Diamond",
"DIAMOND");
+ public static final NodeShape ELLIPSE = new NodeShapeImpl("Ellipse",
"ELLIPSE");
+ public static final NodeShape HEXAGON = new NodeShapeImpl("Hexagon",
"HEXAGON");
+ public static final NodeShape OCTAGON = new NodeShapeImpl("Octagon",
"OCTAGON");
private static final DiscreteRange<NodeShape> NODE_SHAPE_RANGE;
@@ -96,7 +88,11 @@
// TODO Auto-generated method stub
return null;
}
-
+
+ @Override
+ public String toString() {
+ return super.toString();
+ }
}
}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/NodeIcon.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/NodeIcon.java
2011-10-10 21:42:27 UTC (rev 27117)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/NodeIcon.java
2011-10-10 23:35:04 UTC (rev 27118)
@@ -82,20 +82,6 @@
final AffineTransform af = new AffineTransform();
- final Rectangle2D bound = value.getBounds2D();
- final double minx = bound.getMinX();
- final double miny = bound.getMinY();
-
- if (minx < 0) {
- af.setToTranslation(Math.abs(minx), 0);
- newShape = af.createTransformedShape(value);
- }
-
- if (miny < 0) {
- af.setToTranslation(0, Math.abs(miny));
- newShape = af.createTransformedShape(value);
- }
-
af.setToScale(xRatio, yRatio);
newShape = af.createTransformedShape(value);
}
@@ -111,18 +97,14 @@
@Override public void paintIcon(Component c, Graphics g, int x, int y)
{
g2d = (Graphics2D) g;
- final AffineTransform af = new AffineTransform();
-
// AA on
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
-
- af.setToTranslation(leftPad, (c.getHeight() -
newShape.getBounds2D().getHeight()) / 2);
- newShape = af.createTransformedShape(newShape);
-
+ g2d.translate(leftPad, (c.getHeight() -
newShape.getBounds2D().getHeight()) / 2);
g2d.setColor(color);
g2d.setStroke(new BasicStroke(2.0f));
g2d.draw(newShape);
+ g2d.translate(-leftPad, -((c.getHeight() -
newShape.getBounds2D().getHeight()) / 2));
}
Modified:
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/ObjectPositionIcon.java
===================================================================
---
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/ObjectPositionIcon.java
2011-10-10 21:42:27 UTC (rev 27117)
+++
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/ObjectPositionIcon.java
2011-10-10 23:35:04 UTC (rev 27118)
@@ -39,7 +39,6 @@
lp.applyPosition();
lp.paint(g2d);
-
// Transform to fit to the component
g2d.translate(-(x+leftPad), -y);
}
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/valueeditor/DiscreteValueEditor.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/valueeditor/DiscreteValueEditor.java
2011-10-10 21:42:27 UTC (rev 27117)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/valueeditor/DiscreteValueEditor.java
2011-10-10 23:35:04 UTC (rev 27118)
@@ -59,6 +59,7 @@
import org.cytoscape.view.model.DiscreteRange;
import org.cytoscape.view.model.VisualProperty;
import org.cytoscape.view.presentation.RenderingEngine;
+import org.cytoscape.view.presentation.property.VisualPropertyValue;
import org.cytoscape.view.vizmap.gui.editor.ValueEditor;
import org.jdesktop.swingx.border.DropShadowBorder;
@@ -77,7 +78,6 @@
private final static long serialVersionUID = 1202339876950593L;
// Default icon size.
- private static final int ICON_SIZE = 32;
private static final int ICON_SIZE_LARGE = 64;
// Value data type for this chooser.
@@ -90,30 +90,28 @@
private final CyApplicationManager appManager;
private Map<T, Icon> iconMap;
-//
-// private List<T> orderedKeyList;
-// private T defaultValue;
+
private boolean canceled = false;
- public DiscreteValueEditor(final CyApplicationManager appManager, final
Class<T> type, final DiscreteRange<T> dRange, final VisualProperty<T> vp) {
+ public DiscreteValueEditor(final CyApplicationManager appManager, final
Class<T> type,
+ final DiscreteRange<T> dRange, final VisualProperty<T>
vp) {
super();
- if(dRange == null)
+ if (dRange == null)
throw new NullPointerException("Range object is null.");
-
- this.range = dRange;
+
+ this.range = dRange;
this.type = type;
this.appManager = appManager;
this.vp = vp;
-
+
this.iconMap = new HashMap<T, Icon>();
-
+
this.setModal(true);
this.setTitle("Select a value");
initComponents();
setListItems();
-
}
/**
@@ -238,14 +236,6 @@
return null;
return (T) iconList.getSelectedValue();
-
-// final int selectedIndex = iconList.getSelectedIndex();
-//
-// if ((0 <= selectedIndex) && (selectedIndex <
orderedKeyList.size()))
-// return orderedKeyList.get(selectedIndex);
-// else
-//
-// return defaultValue;
}
@@ -271,10 +261,11 @@
}
// TODO: optimize icon layout
- public class IconCellRenderer extends JLabel implements
ListCellRenderer {
+ private final class IconCellRenderer extends JLabel implements
ListCellRenderer {
+
private final static long serialVersionUID = 1202339876940871L;
- private final Font SELECTED_FONT = new Font("SansSerif",
Font.ITALIC,
- 18);
+
+ private final Font SELECTED_FONT = new Font("SansSerif",
Font.ITALIC, 18);
private final Font NORMAL_FONT = new Font("SansSerif",
Font.BOLD, 14);
private final Color SELECTED_COLOR = new Color(30, 30, 80, 25);
private final Color SELECTED_FONT_COLOR = new Color(0, 150,
255, 120);
@@ -288,30 +279,27 @@
// Get icon for the target value
final Icon icon = iconMap.get(value);
-
-
- //icon.setLeftPadding(15);
setIcon(icon);
setFont(isSelected ? SELECTED_FONT : NORMAL_FONT);
this.setVerticalTextPosition(SwingConstants.CENTER);
this.setVerticalAlignment(SwingConstants.CENTER);
- this.setIconTextGap(45);
+ this.setIconTextGap(55);
setBackground(isSelected ? SELECTED_COLOR :
list.getBackground());
- setForeground(isSelected ? SELECTED_FONT_COLOR : list
- .getForeground());
+ setForeground(isSelected ? SELECTED_FONT_COLOR :
list.getForeground());
- this.setHorizontalTextPosition(LEFT);
- this.setHorizontalAlignment(LEFT);
-
- if(icon != null) {
-
- setPreferredSize(new
Dimension(icon.getIconWidth(), icon.getIconHeight() + 20));
- } else {
- setText(value.toString());
- setPreferredSize(new Dimension(100, 60));
- }
+
+ if(icon != null)
+ setPreferredSize(new
Dimension(icon.getIconWidth() + 230, icon.getIconHeight() + 24));
+ else
+ setPreferredSize(new Dimension(230, 60));
+
+ if(value instanceof VisualPropertyValue)
+ setText(((VisualPropertyValue)
value).getDisplayName());
+ else
+ setText("("+ value.toString() +")");
+
this.setBorder(new DropShadowBorder());
return this;
--
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.