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

📄 axiompropertyframe.java

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

import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.lang.*;
import toocom.ocgl.*;

/**
 * @author Fr閐閞ic F黵st
 * 
 * This class represents the graphical window used to specify the properties of an axiom.
 */
public class AxiomPropertyFrame extends JDialog implements ActionListener{
	
	private Axiom a;
	private MainFrame mf;
	private GridBagLayout lay;
	private GridBagConstraints gbc;
	private JTextField termTextField;
	private JComboBox languageMenu;
	private Language currentLanguage;
	private boolean editable;
	
	public AxiomPropertyFrame(Axiom a, MainFrame mf,boolean editable){
		super(mf,Constants.PROPERTIES_OF_LABEL + a.getTerm(mf.getOntologyLanguage()),true);
		this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		this.mf = mf;
		this.a = a;
		this.editable = editable;
		currentLanguage = mf.getOntologyLanguage();
		lay = new GridBagLayout();
		this.getContentPane().setLayout(lay);
		gbc = new GridBagConstraints();
		gbc.fill = GridBagConstraints.BOTH;
		gbc.weightx = 1.0;
		// Terms
		Label lab = new Label(Constants.TERM_LABEL);
		lay.setConstraints(lab,gbc);
		this.getContentPane().add(lab);
		termTextField = new JTextField(a.getTerm(mf.getOntologyLanguage()));
		termTextField.setEditable(editable);
		lay.setConstraints(termTextField,gbc);
		this.getContentPane().add(termTextField);
		languageMenu = new JComboBox(Language.getAllLanguages().toArray());
		if(editable){
			languageMenu.addActionListener(new ActionListener(){
	    		public void actionPerformed(ActionEvent e){
	    			setLanguage();
	    		}
	    	});
	    }
    	languageMenu.setSelectedItem(mf.getOntologyLanguage());
    	gbc.gridwidth = GridBagConstraints.REMAINDER;
    	lay.setConstraints(languageMenu,gbc);
    	this.getContentPane().add(languageMenu,gbc);
    	// Hard/soft
    	lab = new Label(Constants.HARD_AXIOM_LABEL);
		gbc.weightx = 1.0;
		gbc.gridwidth = 1;
		lay.setConstraints(lab,gbc);
		this.getContentPane().add(lab);
		JCheckBox cb = new JCheckBox();
		cb.setEnabled(editable);
		if(a.isHard()) cb.setSelected(true);
		if(editable){
			cb.addActionListener(new ActionListener(){
	    		public void actionPerformed(ActionEvent e){
	    			setHard();
	    		}
	    	});
	    }
		gbc.weightx = 1.0;
		gbc.gridwidth = GridBagConstraints.REMAINDER;
		lay.setConstraints(cb,gbc);
		this.getContentPane().add(cb);
    	// OK button
		JButton ok = new JButton(Constants.OK_LABEL);
		if(editable){
			ok.addActionListener(new ActionListener(){
	    		public void actionPerformed(ActionEvent e){
	    			setValues();
	    		}
	    	});
	    }
	    else{
	    	ok.addActionListener(new ActionListener(){
	    		public void actionPerformed(ActionEvent e){
	    			dispose();
	    		}
	    	});
	    }
    	gbc.weightx = 2.0;
		gbc.gridx = 0;
		gbc.gridwidth = GridBagConstraints.REMAINDER;
		lay.setConstraints(ok,gbc);
		this.getContentPane().add(ok);
		this.pack();
		this.setLocation((mf.getWidth() - this.getWidth())/2,(mf.getHeight() - this.getHeight())/2);
		this.getRootPane().registerKeyboardAction(this,"ok",KeyStroke.getKeyStroke(Constants.OK_KEY),JComponent.WHEN_IN_FOCUSED_WINDOW);
		this.setVisible(true);
		this.toFront();
	}
	
	public void actionPerformed(ActionEvent event){
		if(event.getActionCommand().equals("ok")){
			if(editable) this.setValues();
			else this.dispose();
		}
	}
			
	public void processWindowEvent(WindowEvent e){
		if(e.getID() == WindowEvent.WINDOW_CLOSING) this.setValues();	
	}

	public void setValues(){
		Language l = (Language) languageMenu.getSelectedItem();
		a.setTerm(termTextField.getText(),l);
		mf.getOntologySummaryFrame().refresh();
		mf.repaint();
		this.dispose();
	}
	
	public void setHard(){
		if(a.isHard()) a.setHard(false);
		else a.setHard(true);
	}
	
	public void setLanguage(){
		a.setTerm(termTextField.getText(),currentLanguage);
		currentLanguage = (Language) languageMenu.getSelectedItem();
		termTextField.setText(a.getTerm(currentLanguage));
	}
	
}

⌨️ 快捷键说明

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