本文整理汇总了Java中prefuse.data.Node.get方法的典型用法代码示例。如果您正苦于以下问题:Java Node.get方法的具体用法?Java Node.get怎么用?Java Node.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prefuse.data.Node
的用法示例。
在下文中一共展示了Node.get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
}
}
示例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");
}
}
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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());
}
}
示例7: 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());
}
}
示例8: 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;
}
示例9: findNodeElement
import prefuse.data.Node; //导入方法依赖的package包/类
/**
* Searches for an node element with the given classURI.
*
* @param classURI the uri of a class
* @return the id of the element that was found, otherwise -1.
*/
public int findNodeElement(String classURI) {
if (classURI != null && classURI.length() != 0) {
for (int i = 0; i < GraphStorage.getGraph(viewManagerID).getNodeCount(); i++) {
Node n = GraphStorage.getGraph(viewManagerID).getNode(i);
String classURIOfNode = (String) n.get(n.getColumnIndex(ColumnNames.RDFS_URI));
if (classURIOfNode != null && classURIOfNode.length() != 0) {
if (classURI.equals(classURIOfNode)) {
return (Integer) n.get(n.getColumnIndex(ColumnNames.ID));
}
}
Object testObject = n.get(ColumnNames.EQUIVALENT_CLASSES);
if (testObject != null) {
@SuppressWarnings("unchecked")
ArrayList<EquivalentClassDataStructure> iriList = (ArrayList<EquivalentClassDataStructure>) testObject;
for (EquivalentClassDataStructure ecds : iriList) {
String equiClassURI = ecds.getClassIRI();
if (equiClassURI != null && equiClassURI.length() != 0) {
if (classURI.equals(equiClassURI)) {
return (Integer) n.get(n.getColumnIndex(ColumnNames.ID));
}
}
}
}
}
}
return -1;
}
示例10: helperUpdateShortName
import prefuse.data.Node; //导入方法依赖的package包/类
/**
* Updates the shorter name and the additional informations like instance count.
*
* @param n a node
*/
private void helperUpdateShortName(Node n) {
try {
int instanceCount = (Integer) n.get(n.getColumnIndex(ColumnNames.CLASS_INSTANCE_COUNT));
String fullName = (String) n.get(n.getColumnIndex(ColumnNames.FULL_NAME));
String shortName = helperGetShortName(fullName, MAX_CLASS_NAME_LENGT);
shortName = "[" + Integer.toString(instanceCount) + "]" + "\n" + shortName;
String vowlType = (String) n.get(n.getColumnIndex(ColumnNames.NODE_VOWL_TYPE));
if (vowlType != null) {
if (vowlType.equals(Nodetype.vowltype[2])) {
n.set(ColumnNames.NAME_DATA, DEPRECATED);
}
if (vowlType.equals(Nodetype.vowltype[3])) {
n.set(ColumnNames.NAME_DATA, ISEXTERNAL);
}
if (vowlType.equals(Nodetype.vowltype[8])) {
ArrayList<EquivalentClassDataStructure> iriList = new ArrayList<EquivalentClassDataStructure>(); // TODO list is always empty
String extraName = getEnoughLineBreaksForSecondLine(helperGetShortName(shortName, MAX_CLASS_NAME_LENGT));
extraName = extraName + "[";
for (int i = 0; i < iriList.size(); i++) {
extraName = extraName + iriList.get(i).getClassName();
}
extraName = helperGetShortName(extraName, (int) (MAX_CLASS_NAME_LENGT * (1 / RenderPrefuseGraph.NameExtraDataSize)));
extraName = extraName + "]"; // even when it's cut it should have a closing bracket
n.set(ColumnNames.NAME_DATA, extraName);
}
}
n.set(ColumnNames.NAME, shortName);
} catch (NullPointerException npe) {
logger.error("missing important data within class : " + n.toString());
}
}
示例11: calcAngularBounds
import prefuse.data.Node; //导入方法依赖的package包/类
/**
* Calculates the angular bounds of the layout, attempting to
* preserve the angular orientation of the display across transitions.
*/
private void calcAngularBounds(NodeItem r) {
if ( m_prevRoot == null || !m_prevRoot.isValid() || r == m_prevRoot )
{
m_prevRoot = r;
return;
}
// try to find previous parent of root
NodeItem p = m_prevRoot;
while ( true ) {
NodeItem pp = (NodeItem)p.getParent();
if ( pp == r ) {
break;
} else if ( pp == null ) {
m_prevRoot = r;
return;
}
p = pp;
}
// compute offset due to children's angular width
double dt = 0;
Iterator iter = sortedChildren(r);
while ( iter.hasNext() ) {
Node n = (Node)iter.next();
if ( n == p ) break;
dt += ((Params)n.get(PARAMS)).width;
}
double rw = ((Params)r.get(PARAMS)).width;
double pw = ((Params)p.get(PARAMS)).width;
dt = -MathLib.TWO_PI * (dt+pw/2)/rw;
// set angular bounds
m_theta1 = dt + Math.atan2(p.getY()-r.getY(), p.getX()-r.getX());
m_theta2 = m_theta1 + MathLib.TWO_PI;
m_prevRoot = r;
}
示例12: addEquivalentClass
import prefuse.data.Node; //导入方法依赖的package包/类
/**
* Adds a class IRI and class name to the specified (by it's node id) equivalent class.
*
* @param nodeID the id of the node
* @param iriOfEquivalentClass the IRI of the equivalent class
* @param nameOfEquivalentClass the name of the equivalent class
* @param classComment a comment
* @param definedBy the defined by value
* @param owlVersion the owl version
* @param isDeprecated whether the class is deprecated
* @param isExternal whether the class is external
* @param uniqueNS add each namespace only once
*/
public void addEquivalentClass(int nodeID, String iriOfEquivalentClass, String nameOfEquivalentClass, String classComment, String definedBy, String owlVersion,
Boolean isDeprecated, Boolean isExternal, Boolean uniqueNS) {
Node n = findNode(nodeID);
String nName = (String) n.get(ColumnNames.NAME);
if (nName != null && nName.length() > 2 && !nName.contains("\n")) {
n.set(ColumnNames.NAME, n.get(ColumnNames.NAME) + "\n");
}
Object testObject = n.get(ColumnNames.EQUIVALENT_CLASSES);
try {
@SuppressWarnings("unchecked")
ArrayList<EquivalentClassDataStructure> iriList = (ArrayList<EquivalentClassDataStructure>) testObject;
if (iriList == null) {
iriList = new ArrayList<EquivalentClassDataStructure>();
}
EquivalentClassDataStructure ecds = new EquivalentClassDataStructure();
ecds.setClassIRI(iriOfEquivalentClass);
ecds.setClassName(nameOfEquivalentClass);
ecds.setDeprecated(isDeprecated);
ecds.setExternal(isExternal);
if (uniqueNS) {
if (!iriList.contains(ecds) && !iriOfEquivalentClass.equals(n.get(ColumnNames.RDFS_URI))) {
iriList.add(ecds);
}
} else {
iriList.add(ecds);
}
n.set(ColumnNames.EQUIVALENT_CLASSES, iriList);
String extraName = getEnoughLineBreaksForSecondLine(helperGetShortName(nameOfEquivalentClass, (int) (1 / RenderPrefuseGraph.NameExtraDataSize) * MAX_CLASS_NAME_LENGT));
extraName = extraName + "[";
for (int i = 0; i < iriList.size(); i++) {
if (i > 0) {
extraName = extraName + EQUIVALENT_CLASS_NAME_SEPERATOR + iriList.get(i).getClassName();
} else {
extraName = extraName + iriList.get(i).getClassName();
}
}
extraName = helperGetShortName(extraName, (int) (MAX_CLASS_NAME_LENGT * (1 / RenderPrefuseGraph.NameExtraDataSize)));
extraName = extraName + "]"; // even with a cut, it should have a closing bracket
n.set(ColumnNames.NAME_DATA, extraName);
n.set(ColumnNames.NODE_VOWL_TYPE, Nodetype.vowltype[8]);
} catch (Exception e) {
e.printStackTrace();
}
}
示例13: extractFromNode
import prefuse.data.Node; //导入方法依赖的package包/类
/**
* extracts informations from a given node and show them within the info panel
*
* @param node Node
* @param ipm InfoPanelManager
*/
private void extractFromNode(Node node, InfoPanelManager ipm) {
String vowlType = translateVOWLNodeType((String) node.get(node.getColumnIndex(ColumnNames.NODE_VOWL_TYPE)));
addHelper(ipm, LanguageInfoPanelEN.TYPE, vowlType);
/* disabled for release, not used yet
Object testClassInstanceCount = node.get(node.getColumnIndex(ColumnNames.CLASS_INSTANCE_COUNT));
if (testClassInstanceCount != null) {
// data property nodes don't have a instance count, so this object could be a null pointer
ipm.add(LanguageInfoPanelEN.INSTANCES, testClassInstanceCount.toString());
} */
String nodeName = (String) node.get(node.getColumnIndex(ColumnNames.FULL_NAME));
String uri = (String) node.get(node.getColumnIndex(ColumnNames.RDFS_URI));
addNameUriHelper(ipm, LanguageInfoPanelEN.NAME, nodeName, uri);
String comment = (String) node.get(node.getColumnIndex(ColumnNames.RDFS_COMMENT));
addHelper(ipm, LanguageInfoPanelEN.COMMENT, comment);
/* disabled, information is 'useless'
String definedBy = (String) node.get(node.getColumnIndex(ColumnNames.RDFS_DEFINED_BY));
addHelper(ipm, LanguageInfoPanelEN.DEFINIED_BY, definedBy); */
String owlVersionInfo = (String) node.get(node.getColumnIndex(ColumnNames.OWL_VERSION_INFO));
addHelper(ipm, LanguageInfoPanelEN.OWL_VERS_INFO, owlVersionInfo);
String rdfsInverseOf = (String) node.get(node.getColumnIndex(ColumnNames.RDFS_INVERSE_OF));
addHelper(ipm, LanguageInfoPanelEN.RDFS_INVERSE_OF_URI, rdfsInverseOf);
GraphDataModifier mod = new GraphDataModifier(viewManagerID);
int rdfsInverseOfID = mod.findNodeElement(rdfsInverseOf);
if (rdfsInverseOfID != -1) {
String rdfsInverseOfLabel = (String) mod.findNode(rdfsInverseOfID).get(ColumnNames.FULL_NAME);
addNameUriHelper(ipm, LanguageInfoPanelEN.RDFS_INVERSE_OF_LABEL, rdfsInverseOfLabel, rdfsInverseOf);
} else {
addHelper(ipm, LanguageInfoPanelEN.RDFS_INVERSE_OF_LABEL, rdfsInverseOf);
}
try {
@SuppressWarnings("unchecked")
ArrayList<EquivalentClassDataStructure> iriList = (ArrayList<EquivalentClassDataStructure>) node.get(ColumnNames.EQUIVALENT_CLASSES);
if (iriList != null && iriList.size() != 0) {
for (EquivalentClassDataStructure ecds : iriList) {
addNameUriHelper(ipm, LanguageInfoPanelEN.EQUIVALENT_CLASS_NAME, ecds.getClassName(), ecds.getClassIRI());
addHelper(ipm, LanguageInfoPanelEN.EQUIVALENT_CLASS_COMMENT, ecds.getClassComment());
addHelper(ipm, LanguageInfoPanelEN.EQUIVALENT_CLASS_OWL_VERSION, ecds.getOWLVersion());
addHelper(ipm, LanguageInfoPanelEN.EQUIVALENT_CLASS_EXTERNAL, ecds.getExternalStatus(), false);
addHelper(ipm, LanguageInfoPanelEN.EQUIVALENT_CLASS_DEPRECATED, ecds.getDeprecatedStatus(), false);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}