Search in sources :

Example 1 with ObjectPositionVisualProperty

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);
    }
}
Also used : CustomGraphicsVisualProperty(org.cytoscape.ding.impl.visualproperty.CustomGraphicsVisualProperty) Color(java.awt.Color) ObjectPositionVisualProperty(org.cytoscape.ding.impl.visualproperty.ObjectPositionVisualProperty) TexturePaint(java.awt.TexturePaint) Paint(java.awt.Paint) Font(java.awt.Font) ObjectPosition(org.cytoscape.view.presentation.property.values.ObjectPosition) CustomGraphicLayer(org.cytoscape.view.presentation.customgraphics.CustomGraphicLayer) NodeShape(org.cytoscape.view.presentation.property.values.NodeShape)

Aggregations

Color (java.awt.Color)1 Font (java.awt.Font)1 Paint (java.awt.Paint)1 TexturePaint (java.awt.TexturePaint)1 CustomGraphicsVisualProperty (org.cytoscape.ding.impl.visualproperty.CustomGraphicsVisualProperty)1 ObjectPositionVisualProperty (org.cytoscape.ding.impl.visualproperty.ObjectPositionVisualProperty)1 CustomGraphicLayer (org.cytoscape.view.presentation.customgraphics.CustomGraphicLayer)1 NodeShape (org.cytoscape.view.presentation.property.values.NodeShape)1 ObjectPosition (org.cytoscape.view.presentation.property.values.ObjectPosition)1