Search in sources :

Example 1 with LineType

use of org.cytoscape.view.presentation.property.values.LineType in project EnrichmentMapApp by BaderLab.

the class EMStyleBuilder method setEdgeLineType.

private void setEdgeLineType(VisualStyle vs, EMStyleOptions options) {
    String col = CyEdge.INTERACTION;
    DiscreteMapping<String, LineType> dm = (DiscreteMapping<String, LineType>) dmFactory.createVisualMappingFunction(col, String.class, EDGE_LINE_TYPE);
    // Silence events fired by this mapping to prevent unnecessary style and view updates
    eventHelper.silenceEventSource(dm);
    try {
        LineType sigLineType = LineTypeVisualProperty.DOT;
        if (EDGE_LINE_TYPE.getRange().isDiscrete()) {
            DiscreteRange<LineType> range = (DiscreteRange<LineType>) EDGE_LINE_TYPE.getRange();
            Optional<LineType> first = range.values().stream().filter(v -> "MARQUEE_EQUAL".equalsIgnoreCase(v.getSerializableString())).findFirst();
            if (first.isPresent())
                sigLineType = first.get();
        }
        dm.putMapValue(Columns.EDGE_DATASET_VALUE_COMPOUND, LineTypeVisualProperty.SOLID);
        dm.putMapValue(Columns.EDGE_INTERACTION_VALUE_SIG, sigLineType);
    } finally {
        eventHelper.unsilenceEventSource(dm);
    }
    vs.addVisualMappingFunction(dm);
}
Also used : Color(java.awt.Color) NODE_SHAPE(org.cytoscape.view.presentation.property.BasicVisualLexicon.NODE_SHAPE) RECTANGLE(org.cytoscape.view.presentation.property.NodeShapeVisualProperty.RECTANGLE) NODE_BORDER_TRANSPARENCY(org.cytoscape.view.presentation.property.BasicVisualLexicon.NODE_BORDER_TRANSPARENCY) NodeShape(org.cytoscape.view.presentation.property.values.NodeShape) Inject(com.google.inject.Inject) EDGE_UNSELECTED_PAINT(org.cytoscape.view.presentation.property.BasicVisualLexicon.EDGE_UNSELECTED_PAINT) LineType(org.cytoscape.view.presentation.property.values.LineType) ColorBrewer(org.jcolorbrewer.ColorBrewer) View(org.cytoscape.view.model.View) CyCustomGraphics2(org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2) NODE_TOOLTIP(org.cytoscape.view.presentation.property.BasicVisualLexicon.NODE_TOOLTIP) Discrete(org.baderlab.csplugins.enrichmentmap.CytoscapeServiceModule.Discrete) CyNetwork(org.cytoscape.model.CyNetwork) NODE_SIZE(org.cytoscape.view.presentation.property.BasicVisualLexicon.NODE_SIZE) NODE_FILL_COLOR(org.cytoscape.view.presentation.property.BasicVisualLexicon.NODE_FILL_COLOR) VisualStyleChangedEvent(org.cytoscape.view.vizmap.events.VisualStyleChangedEvent) BasicVisualLexicon(org.cytoscape.view.presentation.property.BasicVisualLexicon) RenderingEngineManager(org.cytoscape.view.presentation.RenderingEngineManager) VisualLexicon(org.cytoscape.view.model.VisualLexicon) Collectors(java.util.stream.Collectors) AbstractDataSet(org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet) List(java.util.List) NETWORK_BACKGROUND_PAINT(org.cytoscape.view.presentation.property.BasicVisualLexicon.NETWORK_BACKGROUND_PAINT) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) Paint(java.awt.Paint) DIAMOND(org.cytoscape.view.presentation.property.NodeShapeVisualProperty.DIAMOND) Optional(java.util.Optional) NODE_LABEL(org.cytoscape.view.presentation.property.BasicVisualLexicon.NODE_LABEL) LineTypeVisualProperty(org.cytoscape.view.presentation.property.LineTypeVisualProperty) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) ContinuousMapping(org.cytoscape.view.vizmap.mappings.ContinuousMapping) Passthrough(org.baderlab.csplugins.enrichmentmap.CytoscapeServiceModule.Passthrough) EDGE_LINE_TYPE(org.cytoscape.view.presentation.property.BasicVisualLexicon.EDGE_LINE_TYPE) EDGE_STROKE_UNSELECTED_PAINT(org.cytoscape.view.presentation.property.BasicVisualLexicon.EDGE_STROKE_UNSELECTED_PAINT) CyNode(org.cytoscape.model.CyNode) PassthroughMapping(org.cytoscape.view.vizmap.mappings.PassthroughMapping) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) EDGE_LABEL_TRANSPARENCY(org.cytoscape.view.presentation.property.BasicVisualLexicon.EDGE_LABEL_TRANSPARENCY) EDGE_WIDTH(org.cytoscape.view.presentation.property.BasicVisualLexicon.EDGE_WIDTH) ELLIPSE(org.cytoscape.view.presentation.property.NodeShapeVisualProperty.ELLIPSE) DiscreteMapping(org.cytoscape.view.vizmap.mappings.DiscreteMapping) NODE_BORDER_PAINT(org.cytoscape.view.presentation.property.BasicVisualLexicon.NODE_BORDER_PAINT) NODE_BORDER_WIDTH(org.cytoscape.view.presentation.property.BasicVisualLexicon.NODE_BORDER_WIDTH) Continuous(org.baderlab.csplugins.enrichmentmap.CytoscapeServiceModule.Continuous) NODE_TRANSPARENCY(org.cytoscape.view.presentation.property.BasicVisualLexicon.NODE_TRANSPARENCY) VisualMappingFunctionFactory(org.cytoscape.view.vizmap.VisualMappingFunctionFactory) CyEventHelper(org.cytoscape.event.CyEventHelper) DiscreteRange(org.cytoscape.view.model.DiscreteRange) NODE_LABEL_TRANSPARENCY(org.cytoscape.view.presentation.property.BasicVisualLexicon.NODE_LABEL_TRANSPARENCY) EDGE_TRANSPARENCY(org.cytoscape.view.presentation.property.BasicVisualLexicon.EDGE_TRANSPARENCY) VisualProperty(org.cytoscape.view.model.VisualProperty) ContinuousMappingPoint(org.cytoscape.view.vizmap.mappings.ContinuousMappingPoint) BoundaryRangeValues(org.cytoscape.view.vizmap.mappings.BoundaryRangeValues) CyNetworkView(org.cytoscape.view.model.CyNetworkView) VisualMappingFunction(org.cytoscape.view.vizmap.VisualMappingFunction) EMSignatureDataSet(org.baderlab.csplugins.enrichmentmap.model.EMSignatureDataSet) CyEdge(org.cytoscape.model.CyEdge) VisualStyleChangeRecord(org.cytoscape.view.vizmap.events.VisualStyleChangeRecord) DiscreteMapping(org.cytoscape.view.vizmap.mappings.DiscreteMapping) LineType(org.cytoscape.view.presentation.property.values.LineType) DiscreteRange(org.cytoscape.view.model.DiscreteRange)

Example 2 with LineType

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

the class DEdgeView method applyVisualProperty.

/**
 * This method sets a mapped value.  NOT Defaults.
 */
@SuppressWarnings("unchecked")
@Override
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.getEdgeView(this.getModel()) == null)
        return;
    // If value is null, simply use the VP's default value.
    if (value == null)
        value = (V) vp.getDefault();
    if (vp == DVisualLexicon.EDGE_STROKE_SELECTED_PAINT) {
        setSelectedPaint((Paint) value);
    } else if (vp == DVisualLexicon.EDGE_STROKE_UNSELECTED_PAINT) {
        setUnselectedPaint((Paint) value);
    } else if (vp == DVisualLexicon.EDGE_WIDTH) {
        final float w = ((Number) value).floatValue();
        setStrokeWidth(w);
        setStroke(DLineType.getDLineType(lineType).getStroke(w));
    } else if (vp == DVisualLexicon.EDGE_LINE_TYPE) {
        lineType = (LineType) value;
        final Stroke newStroke = DLineType.getDLineType(lineType).getStroke(graphView.m_edgeDetails.getWidth(model));
        setStroke(newStroke);
    } else if (vp == DVisualLexicon.EDGE_TRANSPARENCY) {
        setTransparency(((Number) value).intValue());
    } else if (vp == DVisualLexicon.EDGE_LABEL_TRANSPARENCY) {
        final int labelTransparency = ((Number) value).intValue();
        setLabelTransparency(labelTransparency);
    } else if (vp == DVisualLexicon.EDGE_SOURCE_ARROW_SELECTED_PAINT) {
        setSourceEdgeEndSelectedPaint((Paint) value);
    } else if (vp == DVisualLexicon.EDGE_TARGET_ARROW_SELECTED_PAINT) {
        setTargetEdgeEndSelectedPaint((Paint) value);
    } else if (vp == DVisualLexicon.EDGE_SOURCE_ARROW_UNSELECTED_PAINT) {
        setSourceEdgeEndPaint((Paint) value);
    } else if (vp == DVisualLexicon.EDGE_TARGET_ARROW_UNSELECTED_PAINT) {
        setTargetEdgeEndPaint((Paint) value);
    } else if (vp == DVisualLexicon.EDGE_SOURCE_ARROW_SIZE) {
        setSourceArrowSize(((Number) value).doubleValue());
    } else if (vp == DVisualLexicon.EDGE_TARGET_ARROW_SIZE) {
        setTargetArrowSize(((Number) value).doubleValue());
    } else if (vp == BasicVisualLexicon.EDGE_SELECTED) {
        setSelected((Boolean) value);
    } else if (vp == BasicVisualLexicon.EDGE_TARGET_ARROW_SHAPE) {
        final ArrowShape shape = (ArrowShape) value;
        final String shapeID = shape.getSerializableString();
        setTargetEdgeEnd(DArrowShape.parseArrowText(shapeID).getPresentationShape());
    } else if (vp == BasicVisualLexicon.EDGE_SOURCE_ARROW_SHAPE) {
        final ArrowShape shape = (ArrowShape) value;
        final String shapeID = shape.getSerializableString();
        setSourceEdgeEnd(DArrowShape.parseArrowText(shapeID).getPresentationShape());
    } else if (vp == BasicVisualLexicon.EDGE_LABEL) {
        setText(value.toString());
    } else if (vp == BasicVisualLexicon.EDGE_LABEL_WIDTH) {
        setLabelWidth(((Number) value).doubleValue());
    } else if (vp == DVisualLexicon.EDGE_TOOLTIP) {
        setToolTip(value.toString());
    } else if (vp == DVisualLexicon.EDGE_LABEL_FONT_FACE) {
        Font newFont = (Font) value;
        final Font f = getFont();
        if (f != null)
            newFont = f.deriveFont((float) f.getSize());
        setFont(newFont);
    } else if (vp == DVisualLexicon.EDGE_LABEL_FONT_SIZE) {
        float fontSize = ((Number) value).floatValue();
        final Font f = getFont();
        if (f != null)
            setFont(f.deriveFont(fontSize));
    } else if (vp == BasicVisualLexicon.EDGE_LABEL_COLOR) {
        setTextPaint((Paint) value);
    } else if (vp == BasicVisualLexicon.EDGE_VISIBLE) {
        if (((Boolean) value).booleanValue()) {
            graphView.showGraphObject(this);
            isVisible = true;
        } else {
            graphView.hideGraphObject(this);
            isVisible = false;
        }
    } else if (vp == DVisualLexicon.EDGE_CURVED) {
        final Boolean curved = (Boolean) value;
        if (curved)
            setLineCurved(EdgeView.CURVED_LINES);
        else
            setLineCurved(EdgeView.STRAIGHT_LINES);
    } else if (vp == DVisualLexicon.EDGE_BEND) {
        setBend((Bend) value);
    }
}
Also used : Stroke(java.awt.Stroke) AnimatedStroke(org.cytoscape.ding.impl.strokes.AnimatedStroke) ArrowShape(org.cytoscape.view.presentation.property.values.ArrowShape) DArrowShape(org.cytoscape.ding.DArrowShape) Bend(org.cytoscape.view.presentation.property.values.Bend) Paint(java.awt.Paint) LineType(org.cytoscape.view.presentation.property.values.LineType) Font(java.awt.Font)

Example 3 with LineType

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

the class VisualStyleSerializerTest method testCy283Vizmap.

@Test
@SuppressWarnings("unchecked")
public void testCy283Vizmap() throws Exception {
    Properties props = loadVizmapProps("v283_vizmap.props");
    Set<VisualStyle> styles = serializer.createVisualStyles(props);
    assertEquals(6, styles.size());
    assertVisualStylesNotNull(styles, new String[] { "default", "Sample1", "Solid", "Universe", "{Gal_Filt}: -(1:2),&[A*|B?]+%$#@!\\/;", /*Testing special chars*/
    "Nested Network Style" });
    // Test visual styles (defaults, mappings and dependencies)
    // -----
    VisualStyle sample1 = getVisualStyleByTitle(styles, "Sample1");
    assertEquals(new Color(255, 255, 204), sample1.getDefaultValue(NETWORK_BACKGROUND_PAINT));
    assertEquals(Color.BLACK, sample1.getDefaultValue(EDGE_UNSELECTED_PAINT));
    assertEquals(Color.BLACK, sample1.getDefaultValue(EDGE_STROKE_UNSELECTED_PAINT));
    assertEquals(new Color(255, 0, 1), sample1.getDefaultValue(EDGE_STROKE_SELECTED_PAINT));
    assertEquals(Font.decode("Default-PLAIN-10"), sample1.getDefaultValue(EDGE_LABEL_FONT_FACE));
    assertEquals(10, sample1.getDefaultValue(EDGE_LABEL_FONT_SIZE).intValue());
    assertEquals(new Color(0, 10, 0), sample1.getDefaultValue(EDGE_LABEL_COLOR));
    assertEquals(120, sample1.getDefaultValue(EDGE_LABEL_TRANSPARENCY).intValue());
    assertEquals("", sample1.getDefaultValue(EDGE_LABEL));
    assertEquals(LineTypeVisualProperty.SOLID, sample1.getDefaultValue(EDGE_LINE_TYPE));
    assertEquals(1, sample1.getDefaultValue(EDGE_WIDTH).intValue());
    assertEquals(180, sample1.getDefaultValue(EDGE_TRANSPARENCY).intValue());
    assertEquals(ArrowShapeVisualProperty.NONE, sample1.getDefaultValue(EDGE_SOURCE_ARROW_SHAPE));
    assertEquals(ArrowShapeVisualProperty.CIRCLE, sample1.getDefaultValue(EDGE_TARGET_ARROW_SHAPE));
    assertEquals("", sample1.getDefaultValue(EDGE_TOOLTIP));
    assertEquals(new Color(10, 20, 0), sample1.getDefaultValue(NODE_BORDER_PAINT));
    assertEquals(242, sample1.getDefaultValue(NODE_BORDER_TRANSPARENCY).intValue());
    assertEquals(new Color(204, 204, 255), sample1.getDefaultValue(NODE_FILL_COLOR));
    assertEquals(new Color(255, 255, 1), sample1.getDefaultValue(NODE_SELECTED_PAINT));
    assertEquals(Font.decode("Dialog-BOLD-12"), sample1.getDefaultValue(NODE_LABEL_FONT_FACE));
    assertEquals(12, sample1.getDefaultValue(NODE_LABEL_FONT_SIZE).intValue());
    assertEquals("node", sample1.getDefaultValue(NODE_LABEL));
    assertEquals(new Color(0, 0, 255), sample1.getDefaultValue(NODE_LABEL_COLOR));
    assertEquals(220, sample1.getDefaultValue(NODE_LABEL_TRANSPARENCY).intValue());
    assertEquals(30, sample1.getDefaultValue(NODE_HEIGHT).intValue());
    assertEquals(70, sample1.getDefaultValue(NODE_WIDTH).intValue());
    assertEquals(40, sample1.getDefaultValue(NODE_SIZE).intValue());
    assertEquals(LineTypeVisualProperty.LONG_DASH, sample1.getDefaultValue(NODE_BORDER_LINE_TYPE));
    assertEquals(0, sample1.getDefaultValue(NODE_BORDER_WIDTH).intValue());
    assertEquals(250, sample1.getDefaultValue(NODE_TRANSPARENCY).intValue());
    assertEquals(NodeShapeVisualProperty.ELLIPSE, sample1.getDefaultValue(NODE_SHAPE));
    assertEquals(true, sample1.getDefaultValue(NODE_NESTED_NETWORK_IMAGE_VISIBLE));
    assertEquals("My test...", sample1.getDefaultValue(NODE_TOOLTIP));
    PassthroughMapping<String, String> nLabelMp = (PassthroughMapping<String, String>) sample1.getVisualMappingFunction(NODE_LABEL);
    assertEquals(NAME, nLabelMp.getMappingColumnName());
    assertEquals(String.class, nLabelMp.getMappingColumnType());
    PassthroughMapping<String, String> eLabelMp = (PassthroughMapping<String, String>) sample1.getVisualMappingFunction(EDGE_LABEL);
    assertEquals(INTERACTION, eLabelMp.getMappingColumnName());
    DiscreteMapping<String, Paint> eColorMp1 = (DiscreteMapping<String, Paint>) sample1.getVisualMappingFunction(EDGE_UNSELECTED_PAINT);
    assertEquals(INTERACTION, eColorMp1.getMappingColumnName());
    assertEquals(String.class, eColorMp1.getMappingColumnType());
    assertEquals(new Color(255, 0, 51), eColorMp1.getMapValue("pd"));
    assertEquals(new Color(0, 204, 0), eColorMp1.getMapValue("pp"));
    DiscreteMapping<String, Paint> eColorMp2 = (DiscreteMapping<String, Paint>) sample1.getVisualMappingFunction(EDGE_STROKE_UNSELECTED_PAINT);
    assertEquals(INTERACTION, eColorMp2.getMappingColumnName());
    assertEquals(String.class, eColorMp2.getMappingColumnType());
    assertEquals(new Color(255, 0, 51), eColorMp2.getMapValue("pd"));
    assertEquals(new Color(0, 204, 0), eColorMp2.getMapValue("pp"));
    DiscreteMapping<String, LineType> eTypeMp = (DiscreteMapping<String, LineType>) sample1.getVisualMappingFunction(EDGE_LINE_TYPE);
    assertEquals(INTERACTION, eTypeMp.getMappingColumnName());
    assertEquals(LineTypeVisualProperty.LONG_DASH, eTypeMp.getMapValue("pd"));
    assertEquals(LineTypeVisualProperty.SOLID, eTypeMp.getMapValue("pp"));
    VisualPropertyDependency<?> dep1 = getDependency(sample1, NODE_SIZE_LOCKED_DEPENDENCY);
    assertFalse(dep1.isDependencyEnabled());
    // -----
    VisualStyle galFiltered = getVisualStyleByTitle(styles, "{Gal_Filt}: -(1:2),&[A*|B?]+%$#@!\\/;");
    ContinuousMapping<Double, Paint> nColorMp = (ContinuousMapping<Double, Paint>) galFiltered.getVisualMappingFunction(NODE_FILL_COLOR);
    assertEquals("gal4RGexp", nColorMp.getMappingColumnName());
    assertEquals(Number.class, nColorMp.getMappingColumnType());
    assertEquals(3, nColorMp.getPointCount());
    assertEquals(-2.0249776914715767, nColorMp.getPoint(0).getValue(), 0.0001);
    assertEquals(new Color(255, 0, 0), nColorMp.getPoint(0).getRange().equalValue);
    assertEquals(new Color(255, 0, 0), nColorMp.getPoint(0).getRange().greaterValue);
    assertEquals(Color.BLACK, nColorMp.getPoint(0).getRange().lesserValue);
    assertEquals(0.20517408847808838, nColorMp.getPoint(1).getValue(), 0.0001);
    assertEquals(Color.WHITE, nColorMp.getPoint(1).getRange().equalValue);
    assertEquals(Color.WHITE, nColorMp.getPoint(1).getRange().greaterValue);
    assertEquals(Color.WHITE, nColorMp.getPoint(1).getRange().lesserValue);
    assertEquals(2.5, nColorMp.getPoint(2).getValue(), 0.0001);
    assertEquals(new Color(0, 153, 0), nColorMp.getPoint(2).getRange().equalValue);
    assertEquals(new Color(0, 0, 204), nColorMp.getPoint(2).getRange().greaterValue);
    assertEquals(new Color(0, 153, 0), nColorMp.getPoint(2).getRange().lesserValue);
    VisualPropertyDependency<?> dep2 = getDependency(galFiltered, NODE_SIZE_LOCKED_DEPENDENCY);
    assertTrue(dep2.isDependencyEnabled());
    // -----
    VisualStyle nested = getVisualStyleByTitle(styles, "Nested Network Style");
    DiscreteMapping<Boolean, Paint> nLabelColorMp = (DiscreteMapping<Boolean, Paint>) nested.getVisualMappingFunction(NODE_LABEL_COLOR);
    assertEquals("has_nested_network", nLabelColorMp.getMappingColumnName());
    assertEquals(Boolean.class, nLabelColorMp.getMappingColumnType());
    assertEquals(new Color(0, 102, 204), nLabelColorMp.getMapValue(true));
}
Also used : ContinuousMapping(org.cytoscape.view.vizmap.mappings.ContinuousMapping) Color(java.awt.Color) DiscreteMapping(org.cytoscape.view.vizmap.mappings.DiscreteMapping) Matchers.anyString(org.mockito.Matchers.anyString) Paint(java.awt.Paint) Properties(java.util.Properties) PassthroughMapping(org.cytoscape.view.vizmap.mappings.PassthroughMapping) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) LineType(org.cytoscape.view.presentation.property.values.LineType) Test(org.junit.Test)

Example 4 with LineType

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

the class LineTypeVisualProperty method parseSerializableString.

@Override
public LineType parseSerializableString(String value) {
    LineType lineType = null;
    if (value != null) {
        value = value.toUpperCase();
        lineType = lineTypes.get(value);
    }
    if (lineType == null) {
        // Try to find it in the range (it might have been added by a private visual lexicon)
        for (final LineType lt : LINE_TYPE_RANGE.values()) {
            if (lt.getSerializableString().equalsIgnoreCase(value)) {
                lineType = lt;
                break;
            }
        }
    }
    if (lineType == null)
        lineType = SOLID;
    return lineType;
}
Also used : LineType(org.cytoscape.view.presentation.property.values.LineType)

Example 5 with LineType

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

the class VisualStyleSerializerTest method testCy252Vizmap.

@Test
@SuppressWarnings("unchecked")
public void testCy252Vizmap() throws Exception {
    Properties props = loadVizmapProps("v252_vizmap.props");
    Set<VisualStyle> styles = serializer.createVisualStyles(props);
    assertEquals(5, styles.size());
    assertVisualStylesNotNull(styles, new String[] { "default", "Sample1", "Sample2", "Sample3", "SimpleBioMoleculeEditor" });
    // Test one style
    // -----
    VisualStyle s3 = getVisualStyleByTitle(styles, "Sample3");
    assertEquals(new Color(0, 0, 0), s3.getDefaultValue(NETWORK_BACKGROUND_PAINT));
    assertEquals(new Color(255, 255, 255), s3.getDefaultValue(NODE_FILL_COLOR));
    assertEquals(new Color(255, 255, 0), s3.getDefaultValue(NODE_SELECTED_PAINT));
    assertEquals(NodeShapeVisualProperty.ROUND_RECTANGLE, s3.getDefaultValue(NODE_SHAPE));
    assertEquals(80, s3.getDefaultValue(NODE_WIDTH).intValue());
    assertEquals(30, s3.getDefaultValue(NODE_HEIGHT).intValue());
    assertEquals(180, s3.getDefaultValue(NODE_TRANSPARENCY).intValue());
    assertEquals(new Color(153, 153, 255), s3.getDefaultValue(NODE_BORDER_PAINT));
    assertEquals(2, s3.getDefaultValue(NODE_BORDER_WIDTH).intValue());
    assertEquals(255, s3.getDefaultValue(NODE_BORDER_TRANSPARENCY).intValue());
    assertEquals(new Font("Arial-BoldMT", Font.PLAIN, 12), s3.getDefaultValue(NODE_LABEL_FONT_FACE));
    assertEquals(16, s3.getDefaultValue(NODE_LABEL_FONT_SIZE).intValue());
    assertEquals(new Color(255, 255, 255), s3.getDefaultValue(NODE_LABEL_COLOR));
    assertEquals(255, s3.getDefaultValue(NODE_LABEL_TRANSPARENCY).intValue());
    assertEquals(LineTypeVisualProperty.SOLID, s3.getDefaultValue(NODE_BORDER_LINE_TYPE));
    assertEquals("", s3.getDefaultValue(NODE_TOOLTIP));
    assertEquals(1, s3.getDefaultValue(EDGE_WIDTH).intValue());
    assertEquals(new Color(153, 153, 255), s3.getDefaultValue(EDGE_UNSELECTED_PAINT));
    assertEquals(new Color(153, 153, 255), s3.getDefaultValue(EDGE_STROKE_UNSELECTED_PAINT));
    assertEquals(new Color(255, 0, 0), s3.getDefaultValue(EDGE_STROKE_SELECTED_PAINT));
    assertEquals(255, s3.getDefaultValue(EDGE_TRANSPARENCY).intValue());
    assertEquals(LineTypeVisualProperty.SOLID, s3.getDefaultValue(EDGE_LINE_TYPE));
    assertEquals(Font.decode("SanSerif-PLAIN-10"), s3.getDefaultValue(EDGE_LABEL_FONT_FACE));
    assertEquals(14, s3.getDefaultValue(EDGE_LABEL_FONT_SIZE).intValue());
    assertEquals(new Color(255, 255, 204), s3.getDefaultValue(EDGE_LABEL_COLOR));
    assertEquals(255, s3.getDefaultValue(EDGE_LABEL_TRANSPARENCY).intValue());
    assertEquals(ArrowShapeVisualProperty.NONE, s3.getDefaultValue(EDGE_SOURCE_ARROW_SHAPE));
    assertEquals(ArrowShapeVisualProperty.NONE, s3.getDefaultValue(EDGE_TARGET_ARROW_SHAPE));
    assertEquals("", s3.getDefaultValue(EDGE_TOOLTIP));
    PassthroughMapping<String, String> nLabelMp = (PassthroughMapping<String, String>) s3.getVisualMappingFunction(NODE_LABEL);
    assertEquals(NAME, nLabelMp.getMappingColumnName());
    assertEquals(String.class, nLabelMp.getMappingColumnType());
    PassthroughMapping<String, String> eLabelMp = (PassthroughMapping<String, String>) s3.getVisualMappingFunction(EDGE_LABEL);
    assertEquals(INTERACTION, eLabelMp.getMappingColumnName());
    assertEquals(String.class, eLabelMp.getMappingColumnType());
    PassthroughMapping<String, String> nTooltipMp = (PassthroughMapping<String, String>) s3.getVisualMappingFunction(NODE_TOOLTIP);
    assertEquals("gal4RGexp", nTooltipMp.getMappingColumnName());
    assertEquals(String.class, nTooltipMp.getMappingColumnType());
    ContinuousMapping<Double, Paint> nColorMp = (ContinuousMapping<Double, Paint>) s3.getVisualMappingFunction(NODE_FILL_COLOR);
    assertEquals("gal4RGexp", nColorMp.getMappingColumnName());
    assertEquals(Number.class, nColorMp.getMappingColumnType());
    assertEquals(3, nColorMp.getPointCount());
    assertEquals(-2.4059998989105242, nColorMp.getPoint(0).getValue(), 0.0001);
    assertEquals(new Color(0, 153, 0), nColorMp.getPoint(0).getRange().equalValue);
    assertEquals(new Color(0, 153, 0), nColorMp.getPoint(0).getRange().greaterValue);
    assertEquals(Color.BLACK, nColorMp.getPoint(0).getRange().lesserValue);
    assertEquals(-3.254413627473696E-8, nColorMp.getPoint(1).getValue(), 0.0001);
    assertEquals(Color.WHITE, nColorMp.getPoint(1).getRange().equalValue);
    assertEquals(Color.WHITE, nColorMp.getPoint(1).getRange().greaterValue);
    assertEquals(Color.WHITE, nColorMp.getPoint(1).getRange().lesserValue);
    assertEquals(1.2239999999999998, nColorMp.getPoint(2).getValue(), 0.0001);
    assertEquals(new Color(255, 0, 0), nColorMp.getPoint(2).getRange().equalValue);
    assertEquals(new Color(255, 255, 255), nColorMp.getPoint(2).getRange().greaterValue);
    assertEquals(new Color(255, 0, 0), nColorMp.getPoint(2).getRange().lesserValue);
    DiscreteMapping<String, Paint> eColorMp = (DiscreteMapping<String, Paint>) s3.getVisualMappingFunction(EDGE_STROKE_UNSELECTED_PAINT);
    assertEquals(INTERACTION, eColorMp.getMappingColumnName());
    assertEquals(String.class, eColorMp.getMappingColumnType());
    assertEquals(new Color(102, 255, 255), eColorMp.getMapValue("pd"));
    assertEquals(new Color(255, 255, 255), eColorMp.getMapValue("pp"));
    DiscreteMapping<String, LineType> eTypeMp = (DiscreteMapping<String, LineType>) s3.getVisualMappingFunction(EDGE_LINE_TYPE);
    assertEquals(INTERACTION, eTypeMp.getMappingColumnName());
    assertEquals(LineTypeVisualProperty.LONG_DASH, eTypeMp.getMapValue("pd"));
    assertEquals(LineTypeVisualProperty.SOLID, eTypeMp.getMapValue("pp"));
    VisualPropertyDependency<?> dep1 = getDependency(s3, NODE_SIZE_LOCKED_DEPENDENCY);
    assertFalse(dep1.isDependencyEnabled());
}
Also used : ContinuousMapping(org.cytoscape.view.vizmap.mappings.ContinuousMapping) Color(java.awt.Color) DiscreteMapping(org.cytoscape.view.vizmap.mappings.DiscreteMapping) Matchers.anyString(org.mockito.Matchers.anyString) Paint(java.awt.Paint) Properties(java.util.Properties) Font(java.awt.Font) PassthroughMapping(org.cytoscape.view.vizmap.mappings.PassthroughMapping) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) LineType(org.cytoscape.view.presentation.property.values.LineType) Test(org.junit.Test)

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