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

📄 ontotestresult.java

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

import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/**
 * This class represents the results of a test of an ontology.
 *
 * @author Fr閐閞ic F黵st
 */
public class OntoTestResult{
	
	private Ontology onto;
	private Language l;
	private LinkedList results;
	private JTextArea text;
	private JDialog displayFrame;
	private JButton hideWarning;
	private boolean warnings;
	
	public OntoTestResult(Ontology onto,Language l){
		this.results = new LinkedList();
		this.onto = onto;
		this.l = l;
		this.warnings = true;
	}
	
	public void addResult(String r){
		this.results.add(r);
	}
	
	public LinkedList getResults(){
		return results;
	}
	
	/** Add the given results to this result. */
	public void addResults(OntoTestResult otr){
		this.results.addAll(otr.getResults());
	}

	public void hideWarning(){
		text.setText(null);
		this.warnings = !this.warnings;
		int cpt = 0;
		for(Iterator i = results.iterator();i.hasNext();){
			String s = (String) i.next();
			if(!this.warnings){
				if(!s.startsWith(CGConstants.WARNING_IN)){
					text.append(s);
					text.append(new String("\n"));
					cpt ++;
				}
			}
			else{
				text.append(s);
				text.append(new String("\n"));
				cpt ++;
			}
		}
		if((results.size() == 0) || (cpt == 0)) text.append(CGConstants.NO_PROBLEM);
		if(warnings) hideWarning.setText(CGConstants.HIDE_WARNINGS_TEXT);
		else hideWarning.setText(CGConstants.SHOW_WARNINGS_TEXT);
		displayFrame.repaint();
	}
	
	public void displayResults(JFrame frame,String testType){
		displayFrame = new JDialog(frame,CGConstants.ONTOLOGY + onto.getTerm(l) + " : " + testType + CGConstants.TESTS_RESULTS);
		displayFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		Box b = new Box(BoxLayout.Y_AXIS);
		displayFrame.getContentPane().add(b);
		hideWarning = new JButton(CGConstants.HIDE_WARNINGS_TEXT);
		hideWarning.setMaximumSize(new Dimension(CGConstants.Y_BUTTON_DIM,CGConstants.X_BUTTON_DIM));
		hideWarning.setMinimumSize(new Dimension(CGConstants.Y_BUTTON_DIM,CGConstants.X_BUTTON_DIM));
		hideWarning.setPreferredSize(new Dimension(CGConstants.Y_BUTTON_DIM,CGConstants.X_BUTTON_DIM));
		hideWarning.setBorder(BorderFactory.createRaisedBevelBorder());
		hideWarning.addActionListener(new ActionListener(){
    		public void actionPerformed(ActionEvent e){
    			hideWarning();
    		}
    	});
    	hideWarning.setToolTipText(CGConstants.HIDE_WARNINGS_TEXT);
    	hideWarning.setVisible(true);
    	b.add(hideWarning);
		text = new JTextArea();
		text.setEditable(false);
		if(results.size() == 0) text.append(CGConstants.NO_PROBLEM);
		for(Iterator i = results.iterator();i.hasNext();){
			text.append((String) i.next());
			text.append(new String("\n"));
		}
		JScrollPane scrollPanel = new JScrollPane(text);
		b.add(scrollPanel);
		//displayFrame.addWindowListener(new WindowAdapter(){});
	    displayFrame.setResizable(true);
	    displayFrame.pack();
		displayFrame.setVisible(true);
	}
	
}

⌨️ 快捷键说明

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