本文整理汇总了Java中org.cytoscape.view.vizmap.VisualStyleFactory.createVisualStyle方法的典型用法代码示例。如果您正苦于以下问题:Java VisualStyleFactory.createVisualStyle方法的具体用法?Java VisualStyleFactory.createVisualStyle怎么用?Java VisualStyleFactory.createVisualStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.cytoscape.view.vizmap.VisualStyleFactory
的用法示例。
在下文中一共展示了VisualStyleFactory.createVisualStyle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createVisualStyleSingle
import org.cytoscape.view.vizmap.VisualStyleFactory; //导入方法依赖的package包/类
/**
* Create visual style for single condition
* @param vmmServiceRef
* @param vsfServiceRef
* @param vmfFactoryC
* @param vmfFactoryD
* @param vmfFactoryP
* @return
*/
private VisualStyle createVisualStyleSingle(
VisualMappingManager vmmServiceRef,
VisualStyleFactory vsfServiceRef,
VisualMappingFunctionFactory vmfFactoryC,
VisualMappingFunctionFactory vmfFactoryD,
VisualMappingFunctionFactory vmfFactoryP) {
// retrieve visual style if already exist
if(styleExist(vmmServiceRef, "KDDN visual style - single condition"))
return getVSstyle(vmmServiceRef, "KDDN visual style - single condition");
// node color setting
Color NODE_COLOR = new Color(230, 191, 85);
Color NODE_BORDER_COLOR = Color.WHITE;
Color NODE_LABEL_COLOR = new Color(50, 50, 50);
// To create a new VisualStyle object and set the mapping function
VisualStyle vs= vsfServiceRef.createVisualStyle("KDDN visual style - single condition");
// unlock node size
Set<VisualPropertyDependency<?>> deps = vs.getAllVisualPropertyDependencies();
for(VisualPropertyDependency<?> dep: deps) {
dep.setDependency(false);
}
// set node related default
vs.setDefaultValue(BasicVisualLexicon.NODE_SHAPE, NodeShapeVisualProperty.ELLIPSE);
vs.setDefaultValue(BasicVisualLexicon.NODE_FILL_COLOR, NODE_COLOR);
vs.setDefaultValue(BasicVisualLexicon.NODE_LABEL_COLOR, NODE_LABEL_COLOR);
vs.setDefaultValue(BasicVisualLexicon.NODE_BORDER_PAINT, NODE_BORDER_COLOR);
vs.setDefaultValue(BasicVisualLexicon.NODE_TRANSPARENCY, 220);
vs.setDefaultValue(BasicVisualLexicon.NODE_LABEL_FONT_SIZE, 20);
// map node names
String nodeName = "name";
PassthroughMapping nodeNameMapping = (PassthroughMapping)
vmfFactoryP.createVisualMappingFunction(nodeName, String.class,
BasicVisualLexicon.NODE_LABEL);
vs.addVisualMappingFunction(nodeNameMapping);
// map edge color
String edgeType = "interaction";
DiscreteMapping<String, Paint> edgeTypeMapping = (DiscreteMapping<String, Paint>)
vmfFactoryD.createVisualMappingFunction(edgeType, String.class,
BasicVisualLexicon.EDGE_STROKE_UNSELECTED_PAINT);
edgeTypeMapping.putMapValue("static edge", Color.DARK_GRAY);
vs.addVisualMappingFunction(edgeTypeMapping);
// add visual style if not added
if(!styleExist(vmmServiceRef, "KDDN visual style - single condition"))
vmmServiceRef.addVisualStyle(vs);
return vs;
}
示例2: createVisualStyleTwoCondition
import org.cytoscape.view.vizmap.VisualStyleFactory; //导入方法依赖的package包/类
/**
* Create visual style for two conditions
* @param vmmServiceRef
* @param vsfServiceRef
* @param vmfFactoryC
* @param vmfFactoryD
* @param vmfFactoryP
* @return
*/
private VisualStyle createVisualStyleTwoCondition(VisualMappingManager vmmServiceRef,
VisualStyleFactory vsfServiceRef,
VisualMappingFunctionFactory vmfFactoryC,
VisualMappingFunctionFactory vmfFactoryD,
VisualMappingFunctionFactory vmfFactoryP) {
// retrieve visual style if already exist
if(styleExist(vmmServiceRef, "KDDN visual style - two conditions"))
return getVSstyle(vmmServiceRef, "KDDN visual style - two conditions");
// node related color
Color NODE_COLOR = new Color(230, 191, 85);
Color NODE_BORDER_COLOR = Color.WHITE;
Color NODE_LABEL_COLOR = new Color(50, 50, 50);
// To create a new VisualStyle object and set the mapping function
VisualStyle vs= vsfServiceRef.createVisualStyle("KDDN visual style - two conditions");
// unlock node size
Set<VisualPropertyDependency<?>> deps = vs.getAllVisualPropertyDependencies();
for(VisualPropertyDependency<?> dep: deps) {
dep.setDependency(false);
}
// default node appearance
vs.setDefaultValue(BasicVisualLexicon.NODE_SHAPE, NodeShapeVisualProperty.ELLIPSE);
vs.setDefaultValue(BasicVisualLexicon.NODE_FILL_COLOR, NODE_COLOR);
vs.setDefaultValue(BasicVisualLexicon.NODE_LABEL_COLOR, NODE_LABEL_COLOR);
vs.setDefaultValue(BasicVisualLexicon.NODE_BORDER_PAINT, NODE_BORDER_COLOR);
vs.setDefaultValue(BasicVisualLexicon.NODE_TRANSPARENCY, 220);
vs.setDefaultValue(BasicVisualLexicon.NODE_LABEL_FONT_SIZE, 20);
// map node names
String nodeName = "name";
PassthroughMapping nodeNameMapping = (PassthroughMapping)
vmfFactoryP.createVisualMappingFunction(nodeName, String.class,
BasicVisualLexicon.NODE_LABEL);
vs.addVisualMappingFunction(nodeNameMapping);
// map edge color
String edgeType = "interaction";
DiscreteMapping<String, Paint> edgeTypeMapping = (DiscreteMapping<String, Paint>)
vmfFactoryD.createVisualMappingFunction(edgeType, String.class,
BasicVisualLexicon.EDGE_STROKE_UNSELECTED_PAINT);
edgeTypeMapping.putMapValue("condition 1", Color.RED);
edgeTypeMapping.putMapValue("condition 2", new Color(0,196,26));
vs.addVisualMappingFunction(edgeTypeMapping);
// add visual style is not added
if(!styleExist(vmmServiceRef, "KDDN visual style - two conditions"))
vmmServiceRef.addVisualStyle(vs);
return vs;
}