Search in sources :

Example 11 with ObjectPosition

use of org.cytoscape.view.presentation.property.values.ObjectPosition in project cytoscape-impl by cytoscape.

the class DNodeDetails method getLabelNodeAnchor.

@Override
public Position getLabelNodeAnchor(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.getTargetAnchor();
        // return convertG2ND(anchor.getConversionConstant());
        return anchor;
    }
    final Position o = m_labelNodeAnchors.get(node);
    if (o == null)
        if (m_labelNodeAnchorDefault == null)
            return super.getLabelNodeAnchor(node, labelInx);
        else
            return m_labelNodeAnchorDefault;
    return o;
}
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 12 with ObjectPosition

use of org.cytoscape.view.presentation.property.values.ObjectPosition in project cytoscape-impl by cytoscape.

the class DNodeDetails method getLabelOffsetVectorY.

@Override
public float getLabelOffsetVectorY(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);
        return (float) lp.getOffsetY();
    }
    final Object o = m_labelOffsetYs.get(node);
    if (o == null)
        if (m_labelOffsetVectorYDefault == null)
            return super.getLabelOffsetVectorY(node, labelInx);
        else
            return m_labelOffsetVectorYDefault.floatValue();
    return ((Double) o).floatValue();
}
Also used : ObjectPosition(org.cytoscape.view.presentation.property.values.ObjectPosition)

Example 13 with ObjectPosition

use of org.cytoscape.view.presentation.property.values.ObjectPosition 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;
}
Also used : CyCustomGraphics(org.cytoscape.view.presentation.customgraphics.CyCustomGraphics) Bend(org.cytoscape.view.presentation.property.values.Bend) Color(java.awt.Color) Font(java.awt.Font) ObjectPosition(org.cytoscape.view.presentation.property.values.ObjectPosition) DNodeShape(org.cytoscape.ding.DNodeShape) ArrowShape(org.cytoscape.view.presentation.property.values.ArrowShape) DArrowShape(org.cytoscape.ding.DArrowShape) DArrowShape(org.cytoscape.ding.DArrowShape) NodeShape(org.cytoscape.view.presentation.property.values.NodeShape) DNodeShape(org.cytoscape.ding.DNodeShape) Icon(javax.swing.Icon) LineType(org.cytoscape.view.presentation.property.values.LineType) DLineType(org.cytoscape.ding.impl.DLineType)

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