use of org.cytoscape.ding.DArrowShape in project cytoscape-impl by cytoscape.
the class VisualPropertyIconFactory method createIcon.
public static <V> Icon createIcon(V value, int w, int h) {
if (value == null)
return null;
Icon icon = null;
if (value instanceof Color) {
icon = new ColorIcon((Color) value, w, h, value.toString());
} else if (value instanceof NodeShape) {
final DNodeShape dShape;
if (NodeShapeVisualProperty.isDefaultShape((NodeShape) value))
dShape = DNodeShape.getDShape((NodeShape) value);
else
dShape = (DNodeShape) value;
icon = new NodeIcon(dShape.getShape(), w, h, dShape.getDisplayName());
} else if (value instanceof LineType) {
icon = new StrokeIcon(DLineType.getDLineType((LineType) value).getStroke(2f), w, h, value.toString());
} else if (value instanceof CyCustomGraphics) {
final String name = ((CyCustomGraphics) value).getDisplayName();
if (name != null)
icon = new CustomGraphicsIcon(((CyCustomGraphics) value), w, h, name);
} else if (value instanceof ObjectPosition) {
icon = new ObjectPositionIcon((ObjectPosition) value, w, h, "Label");
} else if (value instanceof Font) {
icon = new FontFaceIcon((Font) value, w, h, "");
} else if (value instanceof ArrowShape) {
final ArrowShape arrowShape = (ArrowShape) value;
final DArrowShape dShape;
if (ArrowShapeVisualProperty.isDefaultShape(arrowShape))
dShape = DArrowShape.getArrowShape(arrowShape);
else
dShape = DArrowShape.NONE;
if (dShape.getShape() == null)
// No arrow
icon = new TextIcon(value, w, h, "");
else
icon = new ArrowIcon(dShape.getShape(), w, h, dShape.getDisplayName());
} else if (value instanceof Bend) {
icon = new EdgeBendIcon((Bend) value, w, h, value.toString());
} else {
// If not found, use return value of toString() as icon.
icon = new TextIcon(value, w, h, value.toString());
}
return icon;
}
Aggregations