use of org.cytoscape.ding.impl.visualproperty.ObjectPositionVisualProperty in project cytoscape-impl by cytoscape.
the class DNodeView method applyVisualProperty.
@Override
@SuppressWarnings("unchecked")
protected <T, V extends T> void applyVisualProperty(final VisualProperty<? extends T> vpOriginal, V value) {
VisualProperty<?> vp = vpOriginal;
// Check to make sure our view hasn't gotten disconnected somewhere along the line
if (graphView.getNodeView(this.getModel()) == null)
return;
// Null means set value to VP's default.
if (value == null)
value = (V) vp.getDefault();
if (vp == DVisualLexicon.NODE_SHAPE) {
setShape(((NodeShape) value));
} else if (vp == DVisualLexicon.NODE_SELECTED_PAINT) {
setSelectedPaint((Paint) value);
} else if (vp == BasicVisualLexicon.NODE_SELECTED) {
setSelected((Boolean) value);
} else if (vp == BasicVisualLexicon.NODE_VISIBLE) {
if (((Boolean) value).booleanValue()) {
graphView.showGraphObject(this);
isVisible = true;
} else {
graphView.hideGraphObject(this);
isVisible = false;
}
} else if (vp == BasicVisualLexicon.NODE_FILL_COLOR) {
setUnselectedPaint((Paint) value);
} else if (vp == DVisualLexicon.NODE_BORDER_PAINT) {
setBorderPaint((Color) value);
} else if (vp == DVisualLexicon.NODE_BORDER_TRANSPARENCY) {
final Integer opacity = ((Number) value).intValue();
setBorderTransparency(opacity);
} else if (vp == DVisualLexicon.NODE_BORDER_WIDTH) {
setBorderWidth(new Float(((Number) value).floatValue()));
} else if (vp == DVisualLexicon.NODE_BORDER_LINE_TYPE) {
final DLineType dLineType = DLineType.getDLineType((LineType) value);
final float currentBorderWidth = graphView.m_nodeDetails.getBorderWidth(model);
setBorder(dLineType.getStroke(currentBorderWidth));
} else if (vp == DVisualLexicon.NODE_TRANSPARENCY) {
setTransparency(((Number) value).intValue());
} else if (vp == BasicVisualLexicon.NODE_WIDTH) {
setWidth(((Number) value).doubleValue());
} else if (vp == BasicVisualLexicon.NODE_HEIGHT) {
setHeight(((Number) value).doubleValue());
} else if (vp == BasicVisualLexicon.NODE_LABEL) {
setText(value.toString());
} else if (vp == BasicVisualLexicon.NODE_LABEL_WIDTH) {
setLabelWidth(((Number) value).doubleValue());
} else if (vp == BasicVisualLexicon.NODE_X_LOCATION) {
setXPosition(((Number) value).doubleValue());
} else if (vp == BasicVisualLexicon.NODE_Y_LOCATION) {
setYPosition(((Number) value).doubleValue());
} else if (vp == BasicVisualLexicon.NODE_Z_LOCATION) {
setZPosition(((Number) value).doubleValue());
} else if (vp == DVisualLexicon.NODE_TOOLTIP) {
setToolTip(value.toString());
} else if (vp == BasicVisualLexicon.NODE_LABEL_COLOR) {
setTextPaint((Color) value);
} else if (vp == BasicVisualLexicon.NODE_LABEL_TRANSPARENCY) {
final int opacity = ((Number) value).intValue();
setLabelTransparency(opacity);
} else if (vp == DVisualLexicon.NODE_LABEL_FONT_FACE) {
final float currentFontSize = graphView.m_nodeDetails.getLabelFont(model, 0).getSize();
final Font newFont = ((Font) value).deriveFont(currentFontSize);
setFont(newFont);
} else if (vp == DVisualLexicon.NODE_LABEL_FONT_SIZE) {
final float newSize = ((Number) value).floatValue();
final Font newFont = graphView.m_nodeDetails.getLabelFont(model, 0).deriveFont(newSize);
setFont(newFont);
} else if (vp == DVisualLexicon.NODE_LABEL_POSITION) {
this.setLabelPosition((ObjectPosition) value);
} else if (vp == BasicVisualLexicon.NODE_NESTED_NETWORK_IMAGE_VISIBLE) {
setNestedNetworkImgVisible(Boolean.TRUE.equals(value));
} else if (vp instanceof CustomGraphicsVisualProperty) {
setCustomGraphics((CustomGraphicsVisualProperty) vp, (CyCustomGraphics<CustomGraphicLayer>) value);
} else if (vp instanceof ObjectPositionVisualProperty) {
setCustomGraphicsPosition(vp, (ObjectPosition) value);
} else if (CG_SIZE_PATTERN.matcher(vp.getIdString()).matches()) {
setCustomGraphicsSize((VisualProperty<Double>) vp, (Double) value);
}
}
Aggregations