Search in sources :

Example 1 with ObjectPosition

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);
    }
}
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)

Example 2 with ObjectPosition

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;
}
Also used : ObjectPosition(org.cytoscape.view.presentation.property.values.ObjectPosition) ObjectPosition(org.cytoscape.view.presentation.property.values.ObjectPosition) Position(org.cytoscape.view.presentation.property.values.Position)

Example 3 with ObjectPosition

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;
}
Also used : ObjectPosition(org.cytoscape.view.presentation.property.values.ObjectPosition) Justification(org.cytoscape.view.presentation.property.values.Justification)

Example 4 with ObjectPosition

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();
    }
}
Also used : ObjectPosition(org.cytoscape.view.presentation.property.values.ObjectPosition)

Example 5 with ObjectPosition

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;
    }
}
Also used : ObjectPosition(org.cytoscape.view.presentation.property.values.ObjectPosition)

Aggregations

ObjectPosition (org.cytoscape.view.presentation.property.values.ObjectPosition)13 Position (org.cytoscape.view.presentation.property.values.Position)4 Color (java.awt.Color)2 Font (java.awt.Font)2 CustomGraphicLayer (org.cytoscape.view.presentation.customgraphics.CustomGraphicLayer)2 NodeShape (org.cytoscape.view.presentation.property.values.NodeShape)2 Paint (java.awt.Paint)1 TexturePaint (java.awt.TexturePaint)1 AffineTransform (java.awt.geom.AffineTransform)1 ArrayList (java.util.ArrayList)1 Icon (javax.swing.Icon)1 JLabel (javax.swing.JLabel)1 DArrowShape (org.cytoscape.ding.DArrowShape)1 DNodeShape (org.cytoscape.ding.DNodeShape)1 DLineType (org.cytoscape.ding.impl.DLineType)1 CustomGraphicsVisualProperty (org.cytoscape.ding.impl.visualproperty.CustomGraphicsVisualProperty)1 ObjectPositionVisualProperty (org.cytoscape.ding.impl.visualproperty.ObjectPositionVisualProperty)1 CyNode (org.cytoscape.model.CyNode)1 CyCustomGraphics (org.cytoscape.view.presentation.customgraphics.CyCustomGraphics)1 ImageCustomGraphicLayer (org.cytoscape.view.presentation.customgraphics.ImageCustomGraphicLayer)1