当前位置: 首页>>代码示例>>Java>>正文


Java Node类代码示例

本文整理汇总了Java中prefuse.data.Node的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Node类属于prefuse.data包,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addInstanceToClass

import prefuse.data.Node; //导入依赖的package包/类
/**
 * Add [howManyToAdd] instances to a given class [className].
 * Individuals, enumerations (e.g. owl:oneOf)
 *
 * @param className    the class name
 * @param howManyToAdd the count of instances that will be added
 */
public void addInstanceToClass(String className, int howManyToAdd) {
	for (int i = 0; i < GraphStorage.getGraph(viewManagerID).getNodeCount(); i++) {
		Node n = GraphStorage.getGraph(viewManagerID).getNode(i);
		int nameIndex = n.getColumnIndex(ColumnNames.FULL_NAME);
		try {
			String name = (String) n.get(nameIndex);
			if (name.equals(className)) {
				helperIncreaseClassSizeAfterAddingInstances(n, howManyToAdd);
				helperUpdateShortName(n);
			}
		} catch (NullPointerException npe) {
			// no class name? -> nothing to do
			logger.warn("possible mistake found: node without full name");
		}
	}
}
 
开发者ID:VisualDataWeb,项目名称:ProtegeVOWL,代码行数:24,代码来源:GraphDataModifier.java

示例2: removeInstanceFromClass

import prefuse.data.Node; //导入依赖的package包/类
/**
 * Removes [howManyToRemove] instances from a given class [classID].
 * Individuals, enumerations (e.g. owl:oneOf)
 *
 * @param id              the id of the class
 * @param howManyToRemove the cound if instances that will be removed
 */
public void removeInstanceFromClass(int id, int howManyToRemove) {
	for (int i = 0; i < GraphStorage.getGraph(viewManagerID).getNodeCount(); i++) {
		Node n = GraphStorage.getGraph(viewManagerID).getNode(i);
		int idIndex = n.getColumnIndex(ColumnNames.ID);
		try {
			int idOfNode = (Integer) n.get(idIndex);
			if (idOfNode == id) {
				// node(class) found
				helperDecreaseClassSizeAfterRemovingInstances(n, howManyToRemove);
				helperUpdateShortName(n);
			}
		} catch (NullPointerException npe) {
			// no class name? -> nothing to do
			logger.warn("possible mistake found: node without an id");
		}
	}
}
 
开发者ID:VisualDataWeb,项目名称:ProtegeVOWL,代码行数:25,代码来源:GraphDataModifier.java

示例3: addClassThingWithDetails

import prefuse.data.Node; //导入依赖的package包/类
/**
 * Adds the special Class "Thing", owl:Thing.
 * <p/>
 * NOTE. Yes you could call this function with a name unlike "Thing" or a different URI as
 * {@link TransformOWLtoGraph#OWL_THING_CLASS_URI} because a user can define an "own" class with the namespace of
 * OWLThing. In this case the class should be shown as a OWLThing class.
 * There are also several cases where user doesn't define the target or the source of a property. In this case the
 * target / source of this property should be an OWLThing class. It should be possible for the GraphDataModifier to
 * add an OWLClass with different or without an OWLClassThing Namespace (this may not be through for
 * TransformOWLToGraph).
 *
 * @param instances  the count of instances
 * @param classID    the id of this class
 * @param name       the name of this class
 * @param uri        an uri used as IRI of this class
 * @param comment    the comment of this class
 * @param definiedBy used as IRI
 */
public void addClassThingWithDetails(int instances, int classID, String name, String uri, String comment, String definiedBy,
                                     String owlVersion) {
	addClass(classID, name, uri, comment, definiedBy, owlVersion, false, false);
	if (instances != 0) {
		addInstanceToClass(classID, instances);
	}
	// change the parts which are special for  OWLClass Thing class types
	Node n = findNode(classID);
	// color 0080FF for classes
	n.set(ColumnNames.COLOR_RED, 255);
	n.set(ColumnNames.COLOR_GREEN, 255);
	n.set(ColumnNames.COLOR_BLUE, 255);
	// black text color
	n.set(ColumnNames.TEXT_COLOR_RED, 0);
	n.set(ColumnNames.TEXT_COLOR_GREEN, 0);
	n.set(ColumnNames.TEXT_COLOR_BLUE, 0);
	// changes the size of the OWLThing Class
	n.set(ColumnNames.NODE_HEIGHT, ((int) (MIN_CLASS_SIZE / 1.25)));
	n.set(ColumnNames.NODE_WIDTH, ((int) (MIN_CLASS_SIZE / 1.25)));
	n.set(ColumnNames.TEXT_SIZE, MIN_TEXT_SIZE);
	n.set(ColumnNames.NODE_VOWL_TYPE, Nodetype.vowltype[6]); // type OWLThing
}
 
开发者ID:VisualDataWeb,项目名称:ProtegeVOWL,代码行数:41,代码来源:GraphDataModifier.java

示例4: findClass

import prefuse.data.Node; //导入依赖的package包/类
/**
 * Finds a class with a given class name and class type.
 *
 * @param className the class name
 * @param classType the class type
 * @return classID the id of the found class
 */
public int findClass(String className, String classType) {
	for (int i = 0; i < GraphStorage.getGraph(viewManagerID).getNodeCount(); i++) {
		Node n = GraphStorage.getGraph(viewManagerID).getNode(i);
		int nameIndex = n.getColumnIndex(ColumnNames.FULL_NAME);
		int vowlTypeIndex = n.getColumnIndex(ColumnNames.NODE_VOWL_TYPE);
		int idIndex = n.getColumnIndex(ColumnNames.ID);
		try {
			String name = (String) n.get(nameIndex);
			String vowlType = (String) n.get(vowlTypeIndex);
			if (className.equals(name) && classType.equals(vowlType)) {
				return (Integer) n.get(idIndex);
			}
		} catch (NullPointerException npe) {
			// no class name? -> nothing to do
			logger.warn("possible mistake found: node without name or id or vowl type attribute");
			logger.error("findClass SearchCriterias : ClassName: " + className + " ClassType: " + classType);
		}
	}
	return -1;
}
 
开发者ID:VisualDataWeb,项目名称:ProtegeVOWL,代码行数:28,代码来源:GraphDataModifier.java

示例5: hasSubClassProperty

import prefuse.data.Node; //导入依赖的package包/类
/**
 * Checks whether the class has a subclass property.
 *
 * @param classID1 the id of the first class
 * @param classID2 the id of the second class
 * @return boolean true, if the class has a SubClassProperty
 */
public boolean hasSubClassProperty(int classID1, int classID2) {
	Node n1 = findNode(classID1);
	Node n2 = findNode(classID2);
	if (n1 != null && n2 != null) {
		for (int i = 0; i < GraphStorage.getGraph(viewManagerID).getEdgeCount(); i++) {
			Edge edge = GraphStorage.getGraph(viewManagerID).getEdge(i);
			int sourceNodeID = (Integer) edge.getSourceNode().get(ColumnNames.ID);
			int targetNodeID = (Integer) edge.getTargetNode().get(ColumnNames.ID);
			if (classID1 == sourceNodeID && classID2 == targetNodeID &&
					LanguageGraphEN.IS_SUB_CLASS_OF.equals(edge.get(ColumnNames.NAME))) {
				return true;
			}

		}
	}
	return false;
}
 
开发者ID:VisualDataWeb,项目名称:ProtegeVOWL,代码行数:25,代码来源:GraphDataModifier.java

示例6: findNode

import prefuse.data.Node; //导入依赖的package包/类
/**
 * Finds a node with the given id.
 *
 * @param id the id of the node
 * @return the found node or null
 */
public Node findNode(int id) {
	for (int i = 0; i < GraphStorage.getGraph(viewManagerID).getNodeCount(); i++) {
		Node n = GraphStorage.getGraph(viewManagerID).getNode(i);
		int nodeIDIndex = n.getColumnIndex(ColumnNames.ID);
		try {
			int nodeID = (Integer) n.get(nodeIDIndex);
			if (id == nodeID) {
				return n;
			}
		} catch (NullPointerException npe) {
			logger.warn("possible error found: node without id attribute");
		}
	}
	return null;
}
 
开发者ID:VisualDataWeb,项目名称:ProtegeVOWL,代码行数:22,代码来源:GraphDataModifier.java

示例7: calculateDefaultEdgeLength

import prefuse.data.Node; //导入依赖的package包/类
/**
 * This function calculates the edge length depending on the size of both nodes and the wanted minimum edge length.
 * If the edge is between classes the edge will be longer as between propertys
 * (within prefuse an edge seems so end before n2 but start at the center of n1)
 *
 * @param n1 the first node of the edge
 * @param n2 the second node of the edge
 * @return the length of the edge
 */
public int calculateDefaultEdgeLength(Node n1, Node n2) {
	int n1_h = (Integer) n1.get(n1.getColumnIndex(ColumnNames.NODE_HEIGHT)) / 2;
	int n1_w = (Integer) n1.get(n1.getColumnIndex(ColumnNames.NODE_WIDTH)) / 2;
	// int n2_h = (Integer) n2.get(n2.getColumnIndex(ColumnNames.NODE_HEIGHT))/2;
	// int n2_w = (Integer) n2.get(n2.getColumnIndex(ColumnNames.NODE_WIDTH))/2;
	int n1_size = (int) Math.sqrt(n1_h * n1_h + n1_w * n1_w);
	// int n2_size = (int) Math.sqrt(n2_h*n2_h + n2_w*n2_h);
	// int edge_length = n1_size + n2_size + MIN_EDGE_LENGTH_CLASSES;
	String node2Type = (String) n2.get(n2.getColumnIndex(ColumnNames.NODE_VOWL_TYPE));
	int edge_length;
	if (node2Type != null && (Nodetype.vowltype[3].equals(node2Type)
							  || Nodetype.vowltype[2].equals(node2Type)
							  || Nodetype.vowltype[1].equals(node2Type))) {
		// edge between classes
		edge_length = n1_size + MIN_EDGE_LENGTH_CLASSES;
	} else {
		// edge between other objects like properties
		edge_length = n1_size + MIN_EDGE_LENGTH_PROPERTYS;
	}
	return edge_length;
}
 
开发者ID:VisualDataWeb,项目名称:ProtegeVOWL,代码行数:31,代码来源:GraphDataModifier.java

示例8: helperDecreaseClassSizeAfterRemovingInstances

import prefuse.data.Node; //导入依赖的package包/类
/**
 * Decreases the visual size of a node after instances have been removed.
 *
 * @param n               the node
 * @param howManyToRemove the count of instances that will be removed
 */
private void helperDecreaseClassSizeAfterRemovingInstances(Node n, int howManyToRemove) {
	try {
		int instancesIndex = n.getColumnIndex(ColumnNames.CLASS_INSTANCE_COUNT);
		int instanceCount = (Integer) n.get(instancesIndex);
		int heightIndex = n.getColumnIndex(ColumnNames.NODE_HEIGHT);
		int widhtIndex = n.getColumnIndex(ColumnNames.NODE_WIDTH);
		int height = (Integer) n.get(heightIndex);
		int width = (Integer) n.get(widhtIndex);
		instanceCount = instanceCount - howManyToRemove;
		n.set(ColumnNames.CLASS_INSTANCE_COUNT, instanceCount);
		n.set(ColumnNames.NODE_HEIGHT, height - (int) Math.log(CLASS_INSTANCES_STEPS * howManyToRemove));
		n.set(ColumnNames.NODE_WIDTH, width - (int) Math.log(CLASS_INSTANCES_STEPS * howManyToRemove));
	} catch (NullPointerException npe) {
		logger.error("missing important data, wrong class : " + n.toString());
	}
}
 
开发者ID:VisualDataWeb,项目名称:ProtegeVOWL,代码行数:23,代码来源:GraphDataModifier.java

示例9: helperIncreaseClassSizeAfterAddingInstances

import prefuse.data.Node; //导入依赖的package包/类
/**
 * Increases the visual size of a node after instances have been removed.
 *
 * @param n            the node
 * @param howManyToAdd the count of instances that will be added
 */
private void helperIncreaseClassSizeAfterAddingInstances(Node n, int howManyToAdd) {
	try {
		int instancesIndex = n.getColumnIndex(ColumnNames.CLASS_INSTANCE_COUNT);
		int instanceCount = (Integer) n.get(instancesIndex);
		int heightIndex = n.getColumnIndex(ColumnNames.NODE_HEIGHT);
		int widhtIndex = n.getColumnIndex(ColumnNames.NODE_WIDTH);
		int height = (Integer) n.get(heightIndex);
		int width = (Integer) n.get(widhtIndex);
		instanceCount = instanceCount + howManyToAdd;
		n.set(ColumnNames.CLASS_INSTANCE_COUNT, instanceCount);
		// n.set(ColumnNames.NODE_HEIGHT, height + (int) Math.log(howManyToAdd * CLASS_INSTANCES_STEPS));
		// n.set(ColumnNames.NODE_WIDTH, width + (int) Math.log(howManyToAdd * CLASS_INSTANCES_STEPS));
		n.set(ColumnNames.NODE_HEIGHT, height + (howManyToAdd * CLASS_INSTANCES_STEPS));
		n.set(ColumnNames.NODE_WIDTH, width + (howManyToAdd * CLASS_INSTANCES_STEPS));
	} catch (NullPointerException npe) {
		logger.error("missing important data, wrong class : " + n.toString());
	}
}
 
开发者ID:VisualDataWeb,项目名称:ProtegeVOWL,代码行数:25,代码来源:GraphDataModifier.java

示例10: buildUsesNode

import prefuse.data.Node; //导入依赖的package包/类
private void buildUsesNode( Node parent, Iterable<LayerDetailDescriptor> iter )
{
    for( LayerDetailDescriptor descriptor : iter )
    {
        Node source = findNode( parent, descriptor );

        for( LayerDetailDescriptor usesDescriptor : descriptor.usedLayers() )
        {
            Node target = findNode( parent, usesDescriptor );
            if( target == null )
            {
                continue;
            }
            Edge edge = graph.addEdge( source, target );
            edge.setBoolean( GraphDisplay.USES_EDGES, true );
        }
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:19,代码来源:GraphBuilder.java

示例11: findNode

import prefuse.data.Node; //导入依赖的package包/类
private Node findNode( Node parent, Object userObject )
{
    Node node = null;

    for( int i = 0; i < parent.getChildCount(); i++ )
    {
        Node tNode = parent.getChild( i );
        Object obj = tNode.get( GraphDisplay.USER_OBJECT );
        if( obj.equals( userObject ) )
        {
            node = tNode;
            break;
        }
    }

    return node;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:18,代码来源:GraphBuilder.java

示例12: buildServicesNode

import prefuse.data.Node; //导入依赖的package包/类
private void buildServicesNode( Node parent, Iterable<ServiceDetailDescriptor> iter )
{
    sortTypeChildren( iter );

    boolean first = true;
    for( Object obj : childList )
    {
        ServiceDetailDescriptor descriptor = (ServiceDetailDescriptor) obj;
        if( first )
        {
            String name = "Services";
            parent = addChild( parent, name, name );
            first = false;
        }
        addChild( parent, descriptor.descriptor().toString(), descriptor );
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:18,代码来源:GraphBuilder.java

示例13: buildImportedServicesNode

import prefuse.data.Node; //导入依赖的package包/类
private void buildImportedServicesNode( Node parent, Iterable<ImportedServiceDetailDescriptor> iter )
{
    sortTypeChildren( iter );

    boolean first = true;
    for( Object obj : childList )
    {
        ImportedServiceDetailDescriptor descriptor = (ImportedServiceDetailDescriptor) obj;
        if( first )
        {
            String name = "Imported Services";
            parent = addChild( parent, name, name );
            first = false;
        }
        addChild( parent, descriptor.descriptor().primaryType().getSimpleName(), descriptor );
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:18,代码来源:GraphBuilder.java

示例14: buildEntitiesNode

import prefuse.data.Node; //导入依赖的package包/类
private void buildEntitiesNode( Node parent, Iterable<EntityDetailDescriptor> iter )
{
    sortTypeChildren( iter );

    boolean first = true;
    for( Object obj : childList )
    {
        EntityDetailDescriptor descriptor = (EntityDetailDescriptor) obj;
        if( first )
        {
            String name = "Entities";
            parent = addChild( parent, name, name );
            first = false;
        }
        addChild( parent, descriptor.descriptor().toString(), descriptor );
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:18,代码来源:GraphBuilder.java

示例15: buildTransientsNode

import prefuse.data.Node; //导入依赖的package包/类
private void buildTransientsNode( Node parent, Iterable<TransientDetailDescriptor> iter )
{
    sortTypeChildren( iter );

    boolean first = true;
    for( Object obj : childList )
    {
        TransientDetailDescriptor descriptor = (TransientDetailDescriptor) obj;
        if( first )
        {
            String name = "Transients";
            parent = addChild( parent, name, name );
            first = false;
        }
        addChild( parent, descriptor.descriptor().toString(), descriptor );
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:18,代码来源:GraphBuilder.java


注:本文中的prefuse.data.Node类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。