conciseformatentityrenderer.java

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

JAVA
1,805
字号
			else			if (oc instanceof AddInverse){				AddInverse change = (AddInverse) oc;				if(code.equals("P-INV")				&& change.getProperty().equals(subj)) {					added.put(change.getInverse(), oc);				}				// also inverse gets added				if(code.equals("P-INV")				&& change.getInverse().equals(subj)) {					added.put(change.getProperty(), oc);				}			}			else 			if (oc instanceof AddDataPropertyRange) {					AddDataPropertyRange change = (AddDataPropertyRange) oc;					if(code.equals("P-RAN")					&& change.getRange().equals(subj)					) {						added.put(change.getProperty(), oc);					}					if(code.equals("C-HASRAN")					&& change.getProperty().equals(subj)					) {						added.put(change.getRange(), oc);					}				}			else			if (oc instanceof AddPropertyAxiom) {				AddPropertyAxiom change = (AddPropertyAxiom) oc;				if (change.getAxiom() instanceof OWLEquivalentPropertiesAxiom && code.equals("P-EQU")) {					OWLEquivalentPropertiesAxiom propAxiom = (OWLEquivalentPropertiesAxiom) change.getAxiom();					if (code.equals("P-EQU") && propAxiom.getProperties().contains(subj)) {						Set equSet = new HashSet(propAxiom.getProperties());						equSet.remove(subj);						Iterator iter = equSet.iterator();						while (iter.hasNext()) {							added.put(iter.next(), oc);						}					}				}			}			if (oc instanceof AddSuperProperty) {				AddSuperProperty change = (AddSuperProperty) oc;				if ((code.equals("P-SUB")) && (change.getProperty().equals(subj))) {					added.put(change.getSuperProperty(), oc);				}				if ((code.equals("P-SUP")) && (change.getSuperProperty().equals(subj))) {					added.put(change.getProperty(), oc);				}			}			else 			if (oc instanceof AddIndividualClass) {				AddIndividualClass change = (AddIndividualClass) oc;				OWLIndividual ind = change.getIndividual();				OWLDescription desc = change.getDescription();				if (code.equals("I-INS") && desc.equals(subj)) {					added.put(change.getIndividual(), oc);				}				else				if (code.equals("C-TYP") && ind.equals(subj)) {					added.put(change.getDescription(), oc);				}			}			else			if (oc instanceof EnumElementChange) {				EnumElementChange change = (EnumElementChange) oc;				if ((code.equals("I-ONE")) && (change.getChangeType().equals("Add")) && (change.getOWLClass().equals(subj))) {					added.put(change.getOWLIndividual(), oc);					}			}			else			if (oc instanceof RemoveEnumeration) {				RemoveEnumeration change = (RemoveEnumeration) oc;				if ((code.equals("I-ONE")) && (change.getOWLClass().equals(subj))) {					OWLEnumeration enumElem = change.getEnumeration();					added.keySet().removeAll(enumElem.getIndividuals());									}			}			else			if (oc instanceof AddIndividualAxiom) {				AddIndividualAxiom change = (AddIndividualAxiom) oc;				if (code.equals("I-SAM")) {										if (change.getAxiom() instanceof OWLSameIndividualsAxiom) {						OWLSameIndividualsAxiom sameAxiom = (OWLSameIndividualsAxiom) change.getAxiom();						if (sameAxiom.getIndividuals().contains(subj)) {							Iterator j = sameAxiom.getIndividuals().iterator();												while(j.hasNext())								added.put(j.next(), oc);							added.remove(subj);						}					}				}				if (code.equals("I-DIF")) {										if (change.getAxiom() instanceof OWLDifferentIndividualsAxiom) {						OWLDifferentIndividualsAxiom diffAxiom = (OWLDifferentIndividualsAxiom) change.getAxiom();						if (diffAxiom.getIndividuals().contains(subj)) {							Iterator j = diffAxiom.getIndividuals().iterator();												while(j.hasNext())								added.put(j.next(), oc);							added.remove(subj);						}					}				}			}		}					return added;	}		private void printConciseObject(OWLEntity obj) {		try {			if (obj==null) return;			String objURI = obj.getURI().toString();			String objName = shortForm(obj.getURI());//			String imageURI = baseImageURI; // JAVA WEBSTART STUFF						boolean showIcon = swoopModel.getShowIcons();			if (obj instanceof OWLClass && swoopModel.getEnableDebugging()) showIcon = true;						if (showIcon || swoopModel.getEnableDebugging()) {								String imageURI = "http://www.mindswap.org/2004/SWOOP/icons/"; // JAVA WEBSTART STUFF				if (obj instanceof OWLClass) {										boolean isConsistent = reasoner.isConsistent((OWLClass) obj);										if (isConsistent) imageURI += "InconsistentClass.gif";					else imageURI += "Class.gif"; 				}			    //*************************************************			    //changed for Econns			    //*************************************************				else if (obj instanceof OWLObjectProperty){				  if(((OWLObjectProperty)obj).isLink())	{				  	imageURI += "LinkProperty.GIF";				  }				  else{					imageURI += "Property.gif";				  }				}				else if (obj instanceof OWLDataProperty) imageURI += "DataProperty.gif";				else if (obj instanceof OWLIndividual) imageURI += "Instance.gif";				if (imageURI.endsWith(".gif") || imageURI.endsWith(".GIF") ) print("<img src=\""+imageURI+"\">");			}						print("<a href=\""+StringEscapeUtils.escapeHtml(objURI)+"\">"+StringEscapeUtils.escapeHtml(objName)+"</a>");		}		catch (Exception e) {			e.printStackTrace();		}			}		private void printLine(OWLObject obj, String title) throws OWLException {		String code = getCode(title);		boolean explicit = isExplicit(displayedEntity, code, obj);		OntologyChange oc = editorEnabled ?	isDeleted(displayedEntity, code, obj) : null;		boolean deleted = (oc != null);				if(deleted) print("<font color=\"red\"><strike>");		else if(!explicit) print("<i>");				printObject(obj);				if (editorEnabled && !deleted && explicit) {			// add delete hyperlink in editable mode			// store object hash			addDelete(obj, title);										}				if(!explicit) {			print("</i>");			if (reasoner.supportsExplanation()) addWhy(obj, title);		}		else if(deleted) {			print("</strike></font>");			addUndo(oc, "Delete", title);		}				println();			}		private void printCollection(Collection coll, String title) throws OWLException {		if(coll.isEmpty()) 			return;					if(title != null) {			println();			println(title);		}		Iterator i = coll.iterator();		while(i.hasNext()) {			Object obj = i.next();				// if there is more than one element for this line			// we only print the first one. rest are either			// equivalent classes (or properties) 			if(obj instanceof Collection) {				if (((Collection) obj).size()>0)					obj = ((Collection)obj).iterator().next();				else 					return; // empty set			}						// if debugging is enabled, for each class description, check consistency			if (swoopModel.getEnableDebugging() && obj instanceof OWLDescription && !(obj instanceof OWLClass)) {				URL imageURI; // = baseImageURI;				OWLDescription claExpr = (OWLDescription) obj;				boolean isConsistent = reasoner.isConsistent(claExpr);								if (!isConsistent) {					imageURI = SwoopIcons.getImageURL("InconsistentClassExpression.gif");				}				else {					imageURI = SwoopIcons.getImageURL("ClassExpression.gif");				}				String hashCode = String.valueOf(claExpr.hashCode()); 				OWLDescHash.put(hashCode, claExpr);				print("<a href=\"<CE:"+hashCode+"\"><img src=\""+imageURI+"\"></a>");							}						printLine((OWLObject) obj, title);		}							insertAddedChanges(coll, displayedEntity, title, "");			}		/**	 * Accepts a collection (coll) of objects already displayed,	 * gets all added objects on (displayedEntity), matching the (title)/code,	 * inserts added objects not present in collection 	 * @param coll	 * @param displayedEntity	 * @param title	 * @param titleHead	 * @throws OWLException	 */	protected boolean insertAddedChanges(Collection coll, OWLEntity displayedEntity, String title, String titleHead) throws OWLException {				boolean printed = false;		String code = getCode(title);		if(editorEnabled) {			Map added = getAdded(displayedEntity, code);			if(!added.isEmpty()) {								printed = true;				if (!titleHead.equals("")) {					println();					println(titleHead+addTitle(code));				}								Iterator j = added.entrySet().iterator();				while(j.hasNext()) {					Map.Entry entry = (Map.Entry) j.next();					OWLObject obj = (OWLObject) entry.getKey();					if(coll.contains(obj))						continue;					Object change = entry.getValue();					print("<font color=\"green\">");					printObject(obj);					print("</font>");					addUndo(change, "Add", title);					println();				}			}		}				return printed;	}			protected void renderClass(OWLClass clazz) throws OWLException {				// check if class being rendered is a class expression		if (clazz.getURI().toString().indexOf("#ClassExpression")>=0) {			String uri = clazz.getURI().toString();			String hashCode = uri.substring(uri.indexOf("#ClassExpression")+16, uri.length());								// obtain class expression from hash			OWLDescription claExpr = swoopModel.getCEfromHash(hashCode);						// turn editable off			boolean saveEditable = this.editorEnabled;			this.editorEnabled = false;						// print class expression			print("Class Expression: ");			printLine((OWLObject) claExpr, "");						// print equivalent classes of CE			String equTitle = "<b>Equivalent to:</b>";			Set eqs = reasoner.equivalentClassesOf(claExpr);			printCollection(eqs, equTitle);			// print subclasses of CE			String subTitle = "<b>Sub-Class of:</b>";			Set sub = reasoner.superClassesOf(claExpr);			printCollection(sub, subTitle);			// print superclasses of CE			String supTitle = "<b>Super-Class of:</b>";			Set sup = reasoner.subClassesOf(claExpr);			printCollection(sup, supTitle);									// restore editable setting			this.editorEnabled = saveEditable;			return;		}				// check if class is in current ontology or imported		String importedLbl = "";		imported = false;				if (!clazz.getOntologies().contains(swoopModel.getSelectedOntology())) {			importedLbl = "Imported ";			imported = true;		}				Iterator i = null;		List notPrinted = new ArrayList();				OWLClass owlThing = reasoner.getOntology().getOWLDataFactory().getOWLThing();		OWLClass owlNothing = reasoner.getOntology().getOWLDataFactory().getOWLNothing();				//****** TESTING PURPOSES ONLY ***************//		print("<a href=\"PELLET-SATURATION\">SATURATION TEST</a><br>");		// *******************************************				print("<b>"+importedLbl+"OWL-Class:</b>&nbsp;");		printObject(clazz);				if (importedLbl.length()>0) {						println();			// print("<b>Imported from Ontology(s):</b>&nbsp;");			// also print where the class is imported from			Iterator ontIter = clazz.getOntologies().iterator();			while (ontIter.hasNext()) {				OWLOntology ont = (OWLOntology) ontIter.next();				String ontURI = ont.getURI().toString();				String ontName = ontURI.substring(ontURI.lastIndexOf("/")+1, ontURI.length());				String classXPtrURI = clazz.getURI() + XPointers.asDefinedIn + "(" + ontURI + ")";				print("See its definition in Imported Ontology: <a href=\""+escape(classXPtrURI)+"\">" + escape(ontName) + "</a>");				// print("<a href=\""+ontURI+"asDefinedIn("+ontURI+")\">"+className+"</a>&nbsp;&nbsp;");				println();			}			println();		} 		println();				//*** explanations for inconsistent class	    if(!reasoner.isConsistent( clazz )) {			println("<font color=\"red\"><b>Unsatisfiable concept</b></font>");			if (reasoner instanceof PelletReasoner && swoopModel.isDebugGlass()) {								if (swoopModel.findAllMUPS)  parseTime = 0;				Timer mupsTimer = new Timer("MUPS Processing Time");			    mupsTimer.start();								// create a set of sets for MUPS				List MUPS = new ArrayList();				List explStr = new ArrayList(); // also get explanation strings if using tableau								Set explanationSet = new HashSet();				if (swoopModel.isUseTableau()) {				    // call debugging version of Pellet instead

⌨️ 快捷键说明

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