conciseformatentityrenderer.java

来自「Semantic Web Ontology Editor」· Java 代码 · 共 1,805 行 · 第 1/5 页

JAVA
1,805
字号
					List explSOS = this.getTableauSOS(swoopModel.getSelectedOntology(), clazz);	//				String explanation = explSOS.get(0).toString();					// get explanation set from pellet					explanationSet = (HashSet) explSOS.get(1);					explStr.add(explSOS.get(0).toString());				}					else {					// use black box method instead					explanationSet = this.getBlackBoxSOS(swoopModel.getSelectedOntology(), clazz);									}				MUPS.add(explanationSet);												// find all MUPS using Hitting Set Trees approach				if (swoopModel.isFindAllMUPS()) HSTMUPS(explanationSet, swoopModel.getSelectedOntology(), MUPS, explStr, new HashSet(), new HashSet());								mupsTimer.stop();				System.out.println("------ MUPS PROCEDURE COMPLETE -------");				if (swoopModel.findAllMUPS) {					System.out.println(mupsTimer);					System.out.println("parse time: "+parseTime);					System.out.println("net time: "+ String.valueOf(mupsTimer.getTotal() - parseTime));					netTime = mupsTimer.getTotal() - parseTime;					mupsCount = MUPS.size();				}				Object[] explObj = explStr.toArray();    			int o = 0;    			HashMap explMap = new HashMap();    			Set mupsSet = new HashSet();    			for (Iterator iter = MUPS.iterator(); iter.hasNext();) {    				Set explSet = (HashSet) iter.next();    				mupsSet.add(explSet);    				if (o<explObj.length && explObj[o]!=null) {    					String expl = explObj[o].toString();    					explMap.put(explSet, expl);    				}    				o++;    			}								for (Iterator iter = mupsSet.iterator(); iter.hasNext();) {					Set m = (HashSet) iter.next();					print("<FONT FACE=\""+swoopModel.getFontFace()+"\" SIZE="+fontSize+">");					if (explMap.containsKey(m)) println(explMap.get(m).toString());					this.printExplanationSOS(m, clazz, false);									}						}		}		//***//	  rules stuff		if (swoopModel.getEnableRules()) {			RulesExpressivity ruleExpr = swoopModel.getRuleExpr();			Set rules = ruleExpr.getRules(clazz);			String ruleTitle = "<b>Rules:</b>";			if (editorEnabled)				ruleTitle += addTitle("RULE");			pw.println( "\n" + ruleTitle + " \n<br>" );			for (Iterator iter = rules.iterator(); iter.hasNext();) {			    OWLRule rule = ((RuleValue) iter.next()).getRule();				String ruleDesc = rule.toString();				int ptr;				ptr = ruleDesc.indexOf(">")+1;			    String consequent = ruleDesc.substring(ptr,ruleDesc.indexOf("."));			    String varConsequent = consequent.substring((consequent.indexOf("(")+1),consequent.indexOf(")"));			    ruleDesc = ruleDesc.substring(0,ptr-2)+".";			    ruleDesc = consequent + "  <b>:-</b>  " + ruleDesc;				ptr = 0;				ruleDesc = " " + ruleDesc;				String hyperRule = ruleDesc;				while ((ptr = ruleDesc.indexOf("(", ptr))>=0) {					String name = ruleDesc.substring(ruleDesc.lastIndexOf(" ", ptr), ptr);					String uri = this.getURIForTerm(name.trim());					hyperRule = hyperRule.replaceAll(name, "<a href=\""+uri+"\">"+name+"</a>");					ptr++;				}								if ( editorEnabled ) {				    pw.print( hyperRule );				    					String hash = String.valueOf(rule.hashCode());					OWLDescHash.put(hash, rule);					String titleCode = "RULE"; //getCode(title);					pw.print("&nbsp;&nbsp;(<font color=\"red\"><a href=\"<Delete:" + hash							+ ":" + titleCode + "\">Delete</a></font>) ");					pw.print("&nbsp;&nbsp;(<font color=\"red\"><a href=\"<Edit:" + hash							+ ":" + titleCode + "\">Edit</a></font>)");					pw.print("&nbsp;&nbsp;(<font color=\"red\"><a href=\"<Publish:" + hash							+ ":" + titleCode + "\">Publish</a></font>)");				    					pw.println( "<br>" );									} else {				    pw.println( hyperRule + "<br>"); 				}			}		}		if (showDivisions) {			print("<table cellpadding=\"5\"><tr bgcolor=\"#FFF68F\"><FONT FACE=\""+swoopModel.getFontFace()+"\" SIZE="+fontSize+">");		}				boolean printedAnn = renderAnnotations(clazz);		if (!printedAnn) notPrinted.add("A-ANN");		else if (showDivisions) print(HR+"<FONT FACE=\""+swoopModel.getFontFace()+"\" SIZE="+fontSize+">");				int notPrintedSize = notPrinted.size();				i = OWLDescriptionFinder.getIntersections(clazz, reasoner.getOntologies()).iterator();				if (!i.hasNext()) {			// insert added elements			boolean printed = insertAddedChanges(new HashSet(), clazz, "C-INT", "<b>Intersection of:</b>");			if (!printed) notPrinted.add("C-INT");		}		while(i.hasNext()) {			OWLAnd intersection = (OWLAnd) i.next();			String title = "<b>Intersection of:</b>";			if (editorEnabled) title += addTitle("C-INT");						// check for empty collection			if (intersection.getOperands().size()==0) {				// copy from above				boolean printed = insertAddedChanges(new HashSet(), clazz, "C-INT", "<b>Intersection of:</b>");				if (!printed) notPrinted.add("C-INT");			}			else printCollection(intersection.getOperands(), title);				}				i = OWLDescriptionFinder.getUnions(clazz, reasoner.getOntologies()).iterator();		if (!i.hasNext()) {			boolean printed = insertAddedChanges(new HashSet(), clazz, "C-UNI", "<b>Union of:</b>");			if (!printed) notPrinted.add("C-UNI");		}		while(i.hasNext()) {			OWLOr union = (OWLOr) i.next();			String title = "<b>Union of:</b>";			if (editorEnabled) title += addTitle("C-UNI");						// check for empty collection			if (union.getOperands().size()==0) {				//copy from above				boolean printed = insertAddedChanges(new HashSet(), clazz, "C-UNI", "<b>Union of:</b>");				if (!printed) notPrinted.add("C-UNI");			}			else printCollection(union.getOperands(), title);				}					i = OWLDescriptionFinder.getEnumerations(clazz, reasoner.getOntologies()).iterator();		if (!i.hasNext()) {			boolean printed = insertAddedChanges(new HashSet(), clazz, "I-ONE", "<b>One of:</b>");			if (!printed) notPrinted.add("I-ONE");		}		while(i.hasNext()) {			OWLEnumeration oneOf = (OWLEnumeration) i.next();			String title = "<b>One of:</b>";			if (editorEnabled) title += addTitle("I-ONE");						// check for empty collection			if (oneOf.getIndividuals().size()==0) {				//copy from above				boolean printed = insertAddedChanges(new HashSet(), clazz, "I-ONE", "<b>One of:</b>");				if (!printed) notPrinted.add("I-ONE");			}			else printCollection(oneOf.getIndividuals(), title);				}				if ((notPrinted.size()-notPrintedSize<3) && (showDivisions)) print(HR+"<FONT FACE=\""+swoopModel.getFontFace()+"\" SIZE="+fontSize+">");		notPrintedSize = notPrinted.size();				// print equivalent classes		String equTitle = "<b>Equivalent to:</b>";		if (editorEnabled) equTitle += addTitle("C-EQU");		// get defined equivalentclasses		Set eqs = OWLDescriptionFinder.getEquivalentClasses(clazz, reasoner.getOntologies());		// remove all complements		i = eqs.iterator();		while(i.hasNext()) {			OWLDescription desc = (OWLDescription) i.next();			if(!(desc instanceof OWLClass || desc instanceof OWLRestriction))				i.remove();			}		if(reasoner.isConsistent(clazz)) {			// add all the named equivalent classes			eqs.addAll(reasoner.equivalentClassesOf(clazz));		}		else		    eqs.add(owlNothing);				// title is not printed if there was no equivalent class		if (!eqs.isEmpty()) {			printCollection(eqs, equTitle);		}		else {			boolean printed = insertAddedChanges(new HashSet(), clazz, "C-EQU", "<b>Equivalent to:</b>");			if (!printed) notPrinted.add("C-EQU");		}				// print complements		String notTitle = "<b>Complement of:</b>";		if (editorEnabled) notTitle += addTitle("C-NOT");		// get complements		Set nots = OWLDescriptionFinder.getComplements(clazz, reasoner.getOntologies());		if (nots.isEmpty()) {			boolean printed = insertAddedChanges(new HashSet(), clazz, "C-NOT", "<b>Complement of:</b>");			if (!printed) notPrinted.add("C-NOT");		}		else {//			if(reasoner.isConsistent(clazz)) {//				// add all the named equivalent classes//				nots.addAll(reasoner.equivalentClassesOf(clazz));//			}//			else//			    nots.add(owlNothing);			printCollection(nots, notTitle);		}									// print named disjoints		String disTitle = "<b>Disjoint with:</b>";		Set disjoints = OWLDescriptionFinder.getDisjoints(clazz, reasoner.getOntologies());		if (disjoints.size()==0) {			boolean printed = insertAddedChanges(new HashSet(), clazz, "C-DIS", disTitle);			if (!printed) notPrinted.add("C-DIS");		}		else {			if (editorEnabled) disTitle += addTitle("C-DIS");				printCollection(disjoints, disTitle);		}				// get defined superclasses		Set supers = OWLDescriptionFinder.getSuperClasses(clazz, reasoner.getOntologies());				if(reasoner.isConsistent(clazz)) {			// remove all the named classes because reasoner will eventually add them			i = supers.iterator();			while(i.hasNext())				if(i.next() instanceof OWLClass)					i.remove();					// add all the named superclasses			supers.addAll(reasoner.superClassesOf(clazz));			// remove owl:Thing from the superclass set			i = supers.iterator();			while(i.hasNext()) {				Object o = i.next();				if(o instanceof Set && ((Set)o).contains(owlThing))					i.remove();				}		}		String subTitle = "<b>Subclass of:</b>";		if(supers.size() == 0) {			boolean printed = insertAddedChanges(new HashSet(), clazz, "C-SUB", "<b>Subclass of:</b>");			if (!printed) notPrinted.add("C-SUB");		}		else {			if (editorEnabled) subTitle += addTitle("C-SUB");				printCollection(supers, subTitle);					}					// print named subclasses		// and asserted complex subclasses		String supTitle = "<b>Superclass of:</b>";		if (editorEnabled) supTitle += addTitle("C-SUP");							Set subs = reasoner.subClassesOf(clazz);		subs = SetUtils.union(subs);		subs.addAll(OWLDescriptionFinder.getSubClasses(clazz, reasoner.getOntologies()));		subs.remove(owlNothing);		subs.removeAll(reasoner.equivalentClassesOf(owlNothing));				if(subs.size() >= 1) 			printCollection(subs, supTitle);		else {			boolean printed = insertAddedChanges(new HashSet(), clazz, "C-SUP", "<b>Superclass of:</b>");			if (!printed) notPrinted.add("C-SUP");		}				if ((notPrinted.size()-notPrintedSize<5) && (showDivisions)) print(HR+"<FONT FACE=\""+swoopModel.getFontFace()+"\" SIZE="+fontSize+">");		notPrintedSize = notPrinted.size();				// start printing properties whose domain/range is this class		String domTitle = "<b>Domain of:</b>";		if (editorEnabled) domTitle += addTitle("P-DOM");		if (getPropertiesWithDomain(clazz, showInherited).size()==0) {			boolean printed = insertAddedChanges(new HashSet(), clazz, "P-DOM", "<b>Domain of:</b>");			if (!printed) notPrinted.add("P-DOM");		}		else printCollection(getPropertiesWithDomain(clazz, showInherited), domTitle);				String ranTitle = "<b>Range of:</b>";		if (editorEnabled) ranTitle += addTitle("P-RAN");		if (getPropertiesWithRange(clazz, showInherited).size()==0) {			boolean printed = insertAddedChanges(new HashSet(), clazz, "P-RAN", "<b>Range of:</b>");			if (!printed) notPrinted.add("P-RAN");		}		else printCollection(getPropertiesWithRange(clazz, showInherited), ranTitle);				if ((notPrinted.size()-notPrintedSize<2) && (showDivisions)) print(HR+"<FONT FACE=\""+swoopModel.getFontFace()+"\" SIZE="+fontSize+">");		notPrintedSize = notPrinted.size();				Set instances = new HashSet();		if (showInherited) instances = reasoner.allInstancesOf(clazz);		else instances = reasoner.instancesOf(clazz);		String insTitle = "<b>Instances:</b>";		if (editorEnabled) insTitle += addTitle("I-INS");		if (instances.size()==0) {			boolean printed = insertAddedChanges(new HashSet(), clazz, "I-INS", "<b>Instances:</b>");			if (!printed) notPrinted.add("I-INS");		}		else printCollection(instances, insTitle);				if ((notPrinted.size()-notPrintedSize<1) && (showDivisions)) print(HR+"<FONT FACE=\""+swoopModel.getFontFace()+"\" SIZE="+fontSize+">");		notPrintedSize = notPrinted.size();				if (showDivisions && !editorEnabled) {			print("</tr>");		}				// add unprinted titles at the bottom		addUnprinted(notPrinted);			}	/**	 * Add all the unprinted parameters at the end of the CF pane if editor is enabled	 * @param notPrinted	 */	protected void addUnprinted(List notPrinted) {				if (editorEnabled) {			Iterator npIter = notPrinted.iterator();			boolean div1 = false, div2 = false, div3 = false, div4 = false, div5 = false, div6 = false, div7 = false;			while (npIter.hasNext()) {								String typeCode = npIter.next().toString();								if (typeCode.equals("A-ANN")) {					println();					println(" <b>Annotations</b>:"+addTitle(typeCode));					if (showDivisions) print(HR+"<FONT FACE=\""+swoopModel.getFontFace()+"\" SIZE="+fontSize+">");				}								if (typeCode.equals("C-INT")) {					div1 = true;					println();					println(" <b>Intersection of:</b>"+addTitle(typeCode));				}				else if (typeCode.equals("C-UNI")) {					div1 = true;					println();					println(" <b>Union of:</b>"+addTitle(typeCode));				}				else if (typeCode.equals("I-ONE")) {					div1 = true;					println();					println(" <b>One of:</b>"+addTitle(typeCode));				}				else if (showDivisions && div1) {					print(HR+"<FONT FACE=\""+swoopModel.getFontFace()+"\" SIZE="+fontSize+">");					div1 = false;				}								if (typeCode.equals("C-EQU")) {					div2 = true;					println();					pri

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?