Search in sources :

Example 6 with LineType

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

the class DEdgeDetails method getStroke.

@Override
public Stroke getStroke(final CyEdge edge) {
    Stroke stroke = null;
    final DEdgeView dev = dGraphView.getDEdgeView(edge);
    if (dev == null)
        return null;
    if (dev.isValueLocked(EDGE_LINE_TYPE) || dev.isValueLocked(EDGE_WIDTH)) {
        // If one of these properties are locked, the stroke has to be recreated
        final LineType lineType = dev.getVisualProperty(EDGE_LINE_TYPE);
        stroke = DLineType.getDLineType(lineType).getStroke(getWidth(edge));
        // We need to handle animated edges with some care...
        if (stroke instanceof AnimatedStroke) {
            Stroke oldStroke = m_strokes.get(edge);
            if (oldStroke != null && oldStroke.getClass().equals(stroke.getClass()))
                stroke = ((WidthStroke) oldStroke).newInstanceForWidth(getWidth(edge));
        }
    } else {
        stroke = m_strokes.get(edge);
        if (stroke == null) {
            if (m_strokeDefault == null)
                stroke = super.getStroke(edge);
            else
                stroke = m_strokeDefault;
        }
    }
    if (stroke instanceof AnimatedStroke)
        dGraphView.addAnimatedEdge(dev);
    else
        dGraphView.removeAnimatedEdge(dev);
    return stroke;
}
Also used : WidthStroke(org.cytoscape.ding.impl.strokes.WidthStroke) WidthStroke(org.cytoscape.ding.impl.strokes.WidthStroke) BasicStroke(java.awt.BasicStroke) AnimatedStroke(org.cytoscape.ding.impl.strokes.AnimatedStroke) Stroke(java.awt.Stroke) AnimatedStroke(org.cytoscape.ding.impl.strokes.AnimatedStroke) LineType(org.cytoscape.view.presentation.property.values.LineType)

Example 7 with LineType

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

the class DNodeDetails method getBorderStroke.

@Override
public Stroke getBorderStroke(final CyNode node) {
    final float borderWidth = getBorderWidth(node);
    // Check bypass
    final DNodeView dnv = dGraphView.getDNodeView(node);
    if (dnv.isValueLocked(NODE_BORDER_LINE_TYPE)) {
        final LineType lockedLineType = dnv.getVisualProperty(NODE_BORDER_LINE_TYPE);
        return DLineType.getDLineType(lockedLineType).getStroke(borderWidth);
    }
    final Stroke stroke = m_borderStrokes.get(node);
    if (stroke == null) {
        if (m_borderStrokeDefault == null) {
            final LineType vpDefaultLineType = dnv.getVisualProperty(NODE_BORDER_LINE_TYPE);
            return DLineType.getDLineType(vpDefaultLineType).getStroke(borderWidth);
        } else {
            return DLineType.getDLineType(m_borderStrokeDefault).getStroke(borderWidth);
        }
    } else {
        return stroke;
    }
}
Also used : Stroke(java.awt.Stroke) LineType(org.cytoscape.view.presentation.property.values.LineType)

Example 8 with LineType

use of org.cytoscape.view.presentation.property.values.LineType 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

LineType (org.cytoscape.view.presentation.property.values.LineType)8 Color (java.awt.Color)4 Paint (java.awt.Paint)4 Font (java.awt.Font)3 Stroke (java.awt.Stroke)3 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)3 ContinuousMapping (org.cytoscape.view.vizmap.mappings.ContinuousMapping)3 DiscreteMapping (org.cytoscape.view.vizmap.mappings.DiscreteMapping)3 PassthroughMapping (org.cytoscape.view.vizmap.mappings.PassthroughMapping)3 Properties (java.util.Properties)2 DArrowShape (org.cytoscape.ding.DArrowShape)2 AnimatedStroke (org.cytoscape.ding.impl.strokes.AnimatedStroke)2 Inject (com.google.inject.Inject)1 BasicStroke (java.awt.BasicStroke)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Icon (javax.swing.Icon)1 Continuous (org.baderlab.csplugins.enrichmentmap.CytoscapeServiceModule.Continuous)1 Discrete (org.baderlab.csplugins.enrichmentmap.CytoscapeServiceModule.Discrete)1