relationreflexivity.java

来自「toocom源代码,主要应用在本体匹配方面!」· Java 代码 · 共 50 行

JAVA
50 行
字号
package toocom.ocgl;

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

/**
 * This class represents the reflexivity of a relation.
 *
 * @author Fr閐閞ic F黵st
 */
public class RelationReflexivity extends AxiomSchemaOne{
	
	public RelationReflexivity(RelationType r){
		super(CGConstants.getRelationReflexivityTerms(),r);
	}
		
	/** A primitive can be reflexive 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 irreflexive. */
	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.RelationIrreflexivity");
	}
	
	public Axiom getAxiomForm(){
		Axiom axiom = new Axiom(CGConstants.getRelationReflexivityTerms());
		axiom.getTerms().appendWithSeparator(((RelationType) super.cp).getTerms()," - ");
		Relation r = new Relation((RelationType) super.cp);
		ConceptType ct = ((RelationType) super.cp).getSignature().getConceptType(1);
		Concept c = new Concept(ct);
		r.setLinkedConcept(c,1);
		r.setLinkedConcept(c,2);
		axiom.addHypothesisConcept(c);
		axiom.addConclusionRelation(r);
		return axiom;
	}
	
	public LinkedList getOperationalForm(Ontology onto,Language l){
		return new LinkedList();
	}
	
	public void paint(Graphics g,Language l){
		g.setColor(CGConstants.REFLEXIVITY_COLOR);
		g.drawString("R",super.cp.x - (CGConstants.PROPERTY_SYMBOLS_SPACING * 5),super.cp.y - (CGConstants.PROPERTY_SYMBOLS_SPACING * 4));	
	}
	
}

⌨️ 快捷键说明

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