/** * Creates relationships between entityOfInterest and its' direct parents. * * @return A list of child to parent relationships. */ protected Set<GraphArc> loadParents(OWLEntity entityOfInterest, boolean mustBeVisible) { Set<GraphArc> parents = new HashSet<GraphArc>(); if(!(entityOfInterest instanceof OWLClass)) return parents; if(!filterManager.isArcTypeVisible(DIRECT_SUBCLASS_SLOT_TYPE)) return parents; OWLClass clsOfInterest = (OWLClass)entityOfInterest; for(OWLClass parentCls : owlEditorKit.getOWLModelManager().getOWLHierarchyManager().getOWLClassHierarchyProvider().getParents(clsOfInterest)) { if (isDisplayableNode(parentCls, mustBeVisible)) { GraphArc arc = createArc(parentCls, clsOfInterest, DIRECT_SUBCLASS_SLOT_TYPE); arc.setInverted(false); parents.add(arc); } } return parents; }
/** * Finds relationships between an artifact as a item in the domain, and the ranges of its * properties */ private Set<GraphArc> loadDomainRangeRels(OWLEntity entityOfInterest, boolean outgoing, boolean mustBeVisible) { Set<GraphArc> domainRangeArcs = new HashSet<GraphArc>(); getDomainRangeRelationships(); // ensures that domain range rels are created for (GraphArc relationship : domainRangeRelsBuffer) { if(!filterManager.isArcTypeVisible(relationship.getType())) continue; OWLEntity sourceObject = (OWLEntity) relationship.getSource().getUserObject(); OWLEntity destObject = (OWLEntity) relationship.getDestination().getUserObject(); if (!isDisplayableNode(sourceObject, mustBeVisible) || !isDisplayableNode(destObject, mustBeVisible)) { continue; } if ((outgoing && sourceObject.equals(entityOfInterest)) || destObject.equals(entityOfInterest)) { if(outgoing) relationship.setInverted(false); domainRangeArcs.add(relationship); } } return domainRangeArcs; }
/** * Adds the list of arcs to the graph model. All nodes included in the arc relationships are * also added to the model if necessary. * * @param arcs */ private void addArcsToModel(Collection<GraphArc> arcs, boolean removeOldNodes) { Set<GraphNode> newGraphNodes = new HashSet<GraphNode>(); for (GraphArc arc : arcs) { GraphArc createdArc = addArc((OWLEntity) arc.getSource().getUserObject(), (OWLEntity) arc.getDestination().getUserObject(), arc.getType().toString(), arc.getIcon()); if (createdArc != null) { newGraphNodes.add(createdArc.getSource()); newGraphNodes.add(createdArc.getDestination()); createdArc.setInverted(arc.isInverted()); //PNode n = (PNode)createdArc.getDestination(); //System.out.println(n.getRoot().getClass()); } } if (removeOldNodes) { // remove all old nodes GraphNode[] allNodes = getAllNodes().toArray(new GraphNode[getAllNodes().size()]); for (GraphNode node : allNodes) { if (!newGraphNodes.contains(node)) { removeNode(node.getUserObject()); } } } }