⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swoopmodel.java

📁 Semantic Web Ontology Editor
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
//The MIT License//// Copyright (c) 2004 Mindswap Research Group, University of Maryland, College Park//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions://// The above copyright notice and this permission notice shall be included in// all copies or substantial portions of the Software.//// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS// IN THE SOFTWARE.package org.mindswap.swoop;import java.awt.Font;import java.awt.GridLayout;import java.io.BufferedReader;import java.io.ByteArrayInputStream;import java.io.ByteArrayOutputStream;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.io.Reader;import java.io.StringReader;import java.io.StringWriter;import java.net.URI;import java.util.ArrayList;import java.util.Calendar;import java.util.Collection;import java.util.Collections;import java.util.HashMap;import java.util.HashSet;import java.util.Hashtable;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Properties;import java.util.Set;import java.util.TimeZone;import java.util.Timer;import java.util.prefs.Preferences;import javax.swing.ButtonGroup;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JRadioButton;import org.mindswap.swoop.annotea.Description;import org.mindswap.swoop.change.ChangeLog;import org.mindswap.swoop.change.SwoopChange;import org.mindswap.swoop.reasoner.PelletReasoner;import org.mindswap.swoop.reasoner.SwoopReasoner;import org.mindswap.swoop.reasoner.SwoopToldReasoner;import org.mindswap.swoop.renderer.entity.AbstractSyntaxEntityRenderer;import org.mindswap.swoop.renderer.entity.RDFXMLEntityRenderer;import org.mindswap.swoop.utils.RulesExpressivity;import org.mindswap.swoop.utils.SwoopCache;import org.mindswap.swoop.utils.SwoopStatistics;import org.mindswap.swoop.utils.WSPolicy;import org.mindswap.swoop.utils.change.BooleanElementChange;import org.mindswap.swoop.utils.change.EnumElementChange;import org.mindswap.swoop.utils.change.RevertCheckpointChange;import org.mindswap.swoop.utils.change.SaveCheckpointChange;import org.mindswap.swoop.utils.owlapi.CorrectedRDFRenderer;import org.mindswap.swoop.utils.owlapi.DefaultShortFormProvider;import org.mindswap.swoop.utils.owlapi.LabelShortFormProvider;import org.mindswap.swoop.utils.owlapi.OWLDescriptionFinder;import org.mindswap.swoop.utils.owlapi.OWLEntityRemover;import org.mindswap.swoop.utils.owlapi.OWLOntBuilder;import org.mindswap.swoop.utils.owlapi.QNameShortFormProvider;import org.mindswap.swoop.utils.owlapi.diff.FilteredDiff;import org.mindswap.swoop.utils.ui.SwingWorker;import org.semanticweb.owl.impl.model.OWLConnectionImpl;import org.semanticweb.owl.impl.model.OWLDataFactoryImpl;import org.semanticweb.owl.impl.model.OWLDataPropertyInstanceImpl;import org.semanticweb.owl.impl.model.OWLDataPropertyRangeAxiomImpl;import org.semanticweb.owl.impl.model.OWLFunctionalPropertyAxiomImpl;import org.semanticweb.owl.impl.model.OWLIndividualTypeAssertionImpl;import org.semanticweb.owl.impl.model.OWLInverseFunctionalPropertyAxiomImpl;import org.semanticweb.owl.impl.model.OWLInversePropertyAxiomImpl;import org.semanticweb.owl.impl.model.OWLObjectPropertyInstanceImpl;import org.semanticweb.owl.impl.model.OWLObjectPropertyRangeAxiomImpl;import org.semanticweb.owl.impl.model.OWLPropertyDomainAxiomImpl;import org.semanticweb.owl.impl.model.OWLSubPropertyAxiomImpl;import org.semanticweb.owl.impl.model.OWLSymmetricPropertyAxiomImpl;import org.semanticweb.owl.impl.model.OWLTransitivePropertyAxiomImpl;import org.semanticweb.owl.io.ShortFormProvider;import org.semanticweb.owl.io.abstract_syntax.AbstractOWLParser;import org.semanticweb.owl.io.owl_rdf.OWLRDFErrorHandler;import org.semanticweb.owl.io.owl_rdf.OWLRDFParser;import org.semanticweb.owl.model.OWLAnd;import org.semanticweb.owl.model.OWLAnnotationInstance;import org.semanticweb.owl.model.OWLBooleanDescription;import org.semanticweb.owl.model.OWLClass;import org.semanticweb.owl.model.OWLClassAxiom;import org.semanticweb.owl.model.OWLDataFactory;import org.semanticweb.owl.model.OWLDataProperty;import org.semanticweb.owl.model.OWLDataRange;import org.semanticweb.owl.model.OWLDataValue;import org.semanticweb.owl.model.OWLDescription;import org.semanticweb.owl.model.OWLDifferentIndividualsAxiom;import org.semanticweb.owl.model.OWLDisjointClassesAxiom;import org.semanticweb.owl.model.OWLEntity;import org.semanticweb.owl.model.OWLEnumeration;import org.semanticweb.owl.model.OWLEquivalentClassesAxiom;import org.semanticweb.owl.model.OWLException;import org.semanticweb.owl.model.OWLIndividual;import org.semanticweb.owl.model.OWLIndividualAxiom;import org.semanticweb.owl.model.OWLNamedObject;import org.semanticweb.owl.model.OWLNaryBooleanDescription;import org.semanticweb.owl.model.OWLNot;import org.semanticweb.owl.model.OWLObject;import org.semanticweb.owl.model.OWLObjectProperty;import org.semanticweb.owl.model.OWLOntology;import org.semanticweb.owl.model.OWLOr;import org.semanticweb.owl.model.OWLProperty;import org.semanticweb.owl.model.OWLSameIndividualsAxiom;import org.semanticweb.owl.model.OWLSubClassAxiom;import org.semanticweb.owl.model.change.AddAnnotationInstance;import org.semanticweb.owl.model.change.AddClassAxiom;import org.semanticweb.owl.model.change.AddDomain;import org.semanticweb.owl.model.change.AddEntity;import org.semanticweb.owl.model.change.AddEnumeration;import org.semanticweb.owl.model.change.AddEquivalentClass;import org.semanticweb.owl.model.change.AddImport;import org.semanticweb.owl.model.change.AddIndividualClass;import org.semanticweb.owl.model.change.AddSuperClass;import org.semanticweb.owl.model.change.AddSuperProperty;import org.semanticweb.owl.model.change.ChangeVisitor;import org.semanticweb.owl.model.change.OntologyChange;import org.semanticweb.owl.model.change.RemoveClassAxiom;import org.semanticweb.owl.model.change.RemoveEntity;import org.semanticweb.owl.model.change.RemoveEnumeration;import org.semanticweb.owl.model.change.RemoveEquivalentClass;import org.semanticweb.owl.model.change.RemoveImport;import org.semanticweb.owl.model.change.SetFunctional;import org.semanticweb.owl.model.helper.OntologyHelper;import org.semanticweb.owl.util.OWLConnection;import org.xml.sax.SAXException;public class SwoopModel implements ShortFormProvider {    	final public static int ALL            = 0;	final public static int INDIVIDUALS    = 1;	final public static int CLASSES        = 2;	final public static int PROPERTIES     = 3;	final public static int DATAPROPERTIES = 4;	final public static int OBJPROPERTIES  = 5;	final public static int IMPORTED_ONT  = 6;	final public static int BASE_ONT  = 7;	final public static int TRANSCLOSE_ONT  = 8;	final public static int RDFXML_SER = 9;	final public static int JAVA_SER = 10;	//**********************************************	//Added for Econnections	//**********************************************	final public static int FOREIGN_ENT = 11;	//***********************************************	final public static int GCI = 12;		private boolean show_imports = true; // show imported ontologies in class/prop tree    private boolean showQNames = false; // show QNames    private boolean showDivisions = true; // show divisions in the entity renderer pane    private boolean showInherited = false; // show inherited properties and individuals       private boolean enableAutoSaveChkPts = false; // enable auto-save checkpoints    private boolean logChanges = true; // log all changes    private boolean enableChangeLogDisplay = true; // enable change log display    private boolean enableDebugging = false; // enable ontology debugging (class expressions, pellet)    private boolean enableAutoRetrieve = false; // enable auto-retrieve of Annotea annotations whenever entity selection changes    private boolean highlightCode = true; // highlight entity in source code    private boolean enableRules = false; // enable definition rules    public static int changeSharingMethod = RDFXML_SER; // change sharing method for Ontology Change sets (RDF/XML or Java objects)    private String fontSize = "3";    private String fontFace = "Verdana";    private String treeThreshold = "200"; // number below this - tree is fully expanded    private String termListFilter = "Show All";    private boolean showChangeAnnotBar = false; // show Changes/Annotations sidebar    private boolean openLastWorkspace = false; // open last workspace when Swoop starts    private String lastWorkspaceURL = "";    private boolean saveCheckPtsDisk = false;    private boolean showCheckPts = true;    private SwoopReasoner reasoner;    private String defaultReasonerName;    private Map ontologies;    private Map ontologySettings; // key - uri, value - List of settings (imports, qnames, reasoner) in that order    protected OWLEntity selectedEntity;    protected OWLOntology selectedOntology;    public OWLNamedObject selectedOWLObject;    private List listeners;    private ShortFormProvider shortForms;    private List uncommittedChanges, committedChanges;        private boolean editorEnabled;    private Set changedOntologies; // ontologies changed at each check point (gets reset and created during apply changes)    public List bufferedChanges; // changes in the uncommitted list get saved to this buffer just before uncommitted is emptied (gets reset and created during apply changes)    private Set annotatedObjectURIs; // set of all OWLNamedObjects URI's that have one or more Annotea annotations on them    private Hashtable ResourceAnnotHash;    private boolean showIcons = false; // show Icons in renderer pane    private URI currentlyLoadingURI = null;    private boolean lookupAllOnts = false; // search across all ontologies    private boolean viewOWLVocabularyAsRDF = false;    private boolean viewRDFVocabularyAsRDF = false;    private SwoopCache classTreeCache, propTreeCache; // cache for class/property trees for ontologies    private SwoopCache annotationCache; // cache for Annotea annotations    private SwoopCache changesCache; // cache for committed ontology changes    private SwoopCache reasonerCache; // cache for reasoners    private HashMap reasonerMap; // key - reasoner name, value - SwoopReasoner instance    private File wkspcFile; // last workspace file used    private HashMap classExprHash; // hash for class expressions    private String userName = ""; // used for version control, general provenance info etc    public HashMap changeMap; // map for ontology changes (used in changelog)    public HashMap versionRepository; // map with key: repositoryURI, value: array of Description objects, each corresponding to version commit (first being header)    public String previousTimeStamp = "";     public SwoopFrame myFrame = null; // keeps track of the frame the model resides in.  Use getFrame/setFrame to access the frame.  Required so entityRenderer can have access to TermsDisplay from SwoopFrame.     private boolean debugGlass = false, debugBlack = false;    private HashMap ontStatMap; // hashmap for storing ontology statistics	private boolean useLabels; // display entities using rdfs:labels	private String useLanguage = ""; // display entities in this language	private String proxyHost = ""; // proxy host	private String proxyPort = ""; // proxy port	private boolean useHTTPProxy = false; // use HTTP proxy	public boolean useTableau = false, findAllMUPS = false; // advanced SOS options	private boolean autoSaveWkspc = false; // option to save workspace automatically	private float saveWkspcTime = 1; 	private String saveWkspcFile = "recentWkspc.swp";	private Timer swoopTimer; // timer to carry out operations at regular intervals	public boolean repairColor = false; // FOR Repair Purposes	public HashSet repairSet = new HashSet(); // FOR Repair Purposes	public RulesExpressivity ruleExpr = null;	private Preferences preferences;		//Added for Segmentation	public Map segmentation;//A mapping from each ontology object to its segmentation object.	//	    public SwoopModel() {            	ontologies = new Hashtable();    	ontologySettings = new HashMap();    	listeners = new ArrayList();    	    	reasoner = new SwoopToldReasoner();    	defaultReasonerName = "No Reasoner";    	shortForms = new QNameShortFormProvider();    	uncommittedChanges = new ArrayList();    	committedChanges = new ArrayList();    	annotatedObjectURIs = new HashSet();    	ResourceAnnotHash = new Hashtable();    	classTreeCache = new SwoopCache();    	propTreeCache = new SwoopCache();    	annotationCache = new SwoopCache();    	changesCache = new SwoopCache();    	reasonerCache = new SwoopCache();    	reasonerMap = new HashMap();    	classExprHash = new HashMap();    	changeMap = new HashMap();    	changedOntologies = new HashSet();    	versionRepository = new HashMap();    	    	//Added for Segmentation    	segmentation = new HashMap();    	//    	    	ontStatMap = new HashMap();      	preferences = Preferences.userNodeForPackage(this.getClass());//    	**************************************		// Added for rules		//**************************************		ruleExpr = new RulesExpressivity(this);		//Initializing prolog, consulting programs	//		if (ruleExpr.USE_PROLOG_ENGINE) {//		//	Query q1 = new Query("consult('~/rules/allog/preallogPP.qlf')");////			Query q1 = new Query("consult('allog/preallogPP.pl')");//			System.out.println("consult q1 " + (q1.hasSolution() ? "succeeded" : "failed"));//			q1 = new Query("compile");//			System.out.println("consult q1 " + (q1.hasSolution() ? "succeeded" : "failed"));//		}	}        public Map getSegmentation(){    	return segmentation;    }        public void setSegmentation(Map seg){    	segmentation = seg;    }        public void addAnnotatedObjectURI(URI annObjURI) {    	this.annotatedObjectURIs.add(annObjURI);    }        public Set getAnnotatedObjectURIs() {    	return this.annotatedObjectURIs;    }        public void setAnnotatedObjectURIs(Set annotURIs) {    	this.annotatedObjectURIs = annotURIs;    }        public boolean getEnableAutoSaveChkPts() {    	return this.enableAutoSaveChkPts;    }        public boolean getEnableChangeLogDisplay() {    	return this.enableChangeLogDisplay;    }        public boolean getEnableRules() {		return enableRules;	}        public boolean getEnableAutoRetrieve() {    	return this.enableAutoRetrieve;    }       public void setEnableAutoRetrieve(boolean mode) {    	this.enableAutoRetrieve = mode;    	notifyListeners(new ModelChangeEvent(this, ModelChangeEvent.AUTORETRIEVE_CHANGED, null));    }        public void setEnableAutoSaveChkPts(boolean mode, boolean notify) {    	    	this.enableAutoSaveChkPts = mode;    	if (notify) notifyListeners(new ModelChangeEvent(this, ModelChangeEvent.ENABLED_CHECKPOINT, null));    }        public void setEnableChangeLogDisplay(boolean mode) {    	this.enableChangeLogDisplay = mode;    	notifyListeners(new ModelChangeEvent(this, ModelChangeEvent.ENABLED_CHANGELOG, null));	    }        public boolean getEditorEnabled() {    	return editorEnabled;    }        public boolean getEnableDebugging() {    	return enableDebugging;    }

⌨️ 快捷键说明

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