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

📄 relationsymmetry.java

📁 toocom源代码,主要应用在本体匹配方面!
💻 JAVA
字号:
package toocom.ocgl;

import java.util.*;
import java.awt.Graphics;

/**
 * This class represents the symmetry of a relation.
 *
 * @author Fr閐閞ic F黵st
 */
public class RelationSymmetry extends AxiomSchemaOne{
	
	public RelationSymmetry(RelationType r){
		super(CGConstants.getRelationSymmetryTerms(),r);
	}
		
	/** A primitive can be symmetric if it is a relation, if its arity is 2, if the two 
	 *  concepts of its signature are defined and have the same type and if it is not antisymmetric. */
	public boolean isValid(){
		return (super.cp instanceof RelationType) &&
				(((RelationType) super.cp).getArity() == 2) &&
				(((RelationType) super.cp).getSignature().getConceptType(1) != null) &&
				(((RelationType) super.cp).getSignature().getConceptType(2) != null) &&
				((RelationType) super.cp).getSignature().getConceptType(1).equals(((RelationType) super.cp).getSignature().getConceptType(2)) &&
			    !super.cp.hasAxiomSchema("toocom.ocgl.RelationAntisymmetry");
	}
	
	public Axiom getAxiomForm(){
		Axiom axiom = new Axiom(CGConstants.getRelationSymmetryTerms());
		axiom.getTerms().appendWithSeparator(((RelationType) super.cp).getTerms()," - ");
		Relation r1 = new Relation((RelationType) super.cp);
		Relation r2 = new Relation((RelationType) super.cp);
		axiom.addHypothesisRelation(r1);
		axiom.addConclusionRelation(r2);
		ConceptType ct1 = ((RelationType) super.cp).getSignature().getConceptType(1);
		ConceptType ct2 = ((RelationType) super.cp).getSignature().getConceptType(2);
		Concept c1 = new Concept(ct1);
		Concept c2 = new Concept(ct2);
		r1.setLinkedConcept(c1,1);
		r1.setLinkedConcept(c2,2);
		r2.setLinkedConcept(c2,1);
		r2.setLinkedConcept(c1,2);
		axiom.addHypothesisConcept(c1);
		axiom.addHypothesisConcept(c2);
		return axiom;
	}
	
	public LinkedList getOperationalForm(Ontology onto,Language l){
	/** Returs the Rule which represents the symmetry of the difference relation type. */
	/*public Rule getDifferenceSymmetryOperationalForm(Language l){
		Rule r = new Rule(CGConstants.getDifferenceSymmetryTerms());
		Concept c1 = new Concept(this.getUniversalConceptType());
		Concept c2 = new Concept(this.getUniversalConceptType());
		r.addHypothesisConcept(c1);
		r.addHypothesisConcept(c2);
		Relation r1 = new Relation(this.getDifferenceRelationType());
		Relation r2 = new Relation(this.getDifferenceRelationType());
		r1.setLinkedConcept(c1,1);
		r1.setLinkedConcept(c2,2);
		r2.setLinkedConcept(c1,2);
		r2.setLinkedConcept(c2,1);
		r.addHypothesisRelation(r1);
		r.addConclusionRelation(r2);
		return r;
	}*/
	return new LinkedList();
	}
	
	public void paint(Graphics g,Language l){
		g.setColor(CGConstants.SYMMETRY_COLOR);
		g.drawString("S",super.cp.x - (CGConstants.PROPERTY_SYMBOLS_SPACING),super.cp.y - (CGConstants.PROPERTY_SYMBOLS_SPACING * 4));	
	}
	
}

⌨️ 快捷键说明

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