use of org.cytoscape.view.presentation.property.values.ObjectPosition 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);
}
}
use of org.cytoscape.view.presentation.property.values.ObjectPosition in project cytoscape-impl by cytoscape.
the class DNodeDetails method getLabelTextAnchor.
@Override
public Position getLabelTextAnchor(final CyNode node, final int labelInx) {
// Check bypass
final DNodeView dnv = dGraphView.getDNodeView(node);
if (dnv.isValueLocked(NODE_LABEL_POSITION)) {
final ObjectPosition lp = dnv.getVisualProperty(NODE_LABEL_POSITION);
final Position anchor = lp.getAnchor();
return anchor;
}
final Position p = m_labelTextAnchors.get(node);
if (p == null)
if (m_labelTextAnchorDefault == null)
return super.getLabelTextAnchor(node, labelInx);
else
return m_labelTextAnchorDefault;
return p;
}
use of org.cytoscape.view.presentation.property.values.ObjectPosition in project cytoscape-impl by cytoscape.
the class DNodeDetails method getLabelJustify.
@Override
public Justification getLabelJustify(final CyNode node, final int labelInx) {
// Check bypass
final DNodeView dnv = dGraphView.getDNodeView(node);
if (dnv.isValueLocked(NODE_LABEL_POSITION)) {
final ObjectPosition lp = dnv.getVisualProperty(NODE_LABEL_POSITION);
final Justification justify = lp.getJustify();
return justify;
}
Justification o = m_labelJustifys.get(node);
if (o == null)
if (m_labelJustifyDefault == null)
return super.getLabelJustify(node, labelInx);
else
return m_labelJustifyDefault;
return o;
}
use of org.cytoscape.view.presentation.property.values.ObjectPosition in project cytoscape-impl by cytoscape.
the class ObjectPositionValueEditor method showEditor.
@Override
public <S extends ObjectPosition> ObjectPosition showEditor(final Component parent, final S initialValue) {
if (!initialized) {
init(parent);
initialized = true;
}
ObjectPosition pos;
if (initialValue == null) {
oldValue = null;
pos = new ObjectPosition();
} else {
oldValue = initialValue;
pos = new ObjectPosition(initialValue);
}
control.setPosition(pos);
graphic.setPosition(pos);
if (parent != null)
dialog.setLocationRelativeTo(parent);
else
dialog.setLocationByPlatform(true);
dialog.pack();
dialog.setVisible(true);
if (canceled) {
canceled = false;
return oldValue;
} else {
return control.getPosition();
}
}
use of org.cytoscape.view.presentation.property.values.ObjectPosition in project cytoscape-impl by cytoscape.
the class CyObjectPositionPropertyEditor method editObjectPosition.
private void editObjectPosition() {
// TODO: set correct parent
final ObjectPosition newVal = valueEditor.showEditor(null, position);
if (newVal != null) {
setValue(newVal);
firePropertyChange(null, newVal);
oldPosition = newVal;
}
}
Aggregations