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

📄 relationtypestoolbar.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.*;

/**
 * This class represents the graphical window used for building the relation types hierarchy.
 * It provides creation and structuration fonctions by using its own toolbar or right
 * mouse click. The buttons of the toolbar allow to create, destroy or link relations with 
 * a is-a link. Right-clicking on a relation open a window with the properties of the relation.
 *
 * @author Fr閐閞ic F黵st
 */
public class RelationTypesToolBar extends JToolBar{
	
	// The mode of interaction : -1 = disabled, 0=creation, 1=destruction, 2=linking
	private int mode;
	private JButton createRelationType;
	private JButton destroyRelationType;
	private JButton linkRelationTypes;
	private JButton drawingHelp;
	private RelationTypesFrame rf;

	public void setEnabled(boolean b){
		if(b) this.setRelationTypeMode(0);
		else this.setRelationTypeMode(-1);
	}
	
	public void setRelationTypeMode(int mode){
		this.mode = mode;
		rf.setRelationTypeMode(mode);
		if(mode == 0){
			createRelationType.setBackground(Constants.SELECTED_BUTTON_COLOR);
			destroyRelationType.setBackground(null);
			linkRelationTypes.setBackground(null);
		}
		if(mode == 1){
			createRelationType.setBackground(null);
			destroyRelationType.setBackground(Constants.SELECTED_BUTTON_COLOR);
			linkRelationTypes.setBackground(null);
		}
		if(mode == 2){
			createRelationType.setBackground(null);
			destroyRelationType.setBackground(null);
			linkRelationTypes.setBackground(Constants.SELECTED_BUTTON_COLOR);
		}
	}

	public RelationTypesToolBar(RelationTypesFrame rf){
		super();
		this.rf = rf;
		final RelationTypesFrame rfLink = rf;
		mode = -1;

		// Create the button panel
		this.setBackground(Constants.RELATION_TYPES_FRAME_COLOR);
		this.setLayout(new FlowLayout(FlowLayout.CENTER));
		this.setFloatable(false);
		// Create Button
		createRelationType = new JButton(new InterfaceIcon(Constants.CREATE_RELATION_TYPE_ICON));
		createRelationType.setMaximumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
		createRelationType.setMinimumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
		createRelationType.setBorder(BorderFactory.createRaisedBevelBorder());
		createRelationType.addActionListener(new ActionListener(){
    		public void actionPerformed(ActionEvent e){
    			setRelationTypeMode(0);
    		}
    	});
    	createRelationType.setToolTipText(Constants.CREATE_RELATION_TYPE_TIPTEXT);
    	createRelationType.setEnabled(true);
    	createRelationType.setVisible(true);
    	createRelationType.setSelected(true);
    	createRelationType.setBackground(Constants.SELECTED_BUTTON_COLOR);
    	this.add(createRelationType);
		// Destroy Button
		destroyRelationType = new JButton(new InterfaceIcon(Constants.DESTROY_RELATION_TYPE_ICON));
		destroyRelationType.setMaximumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
		destroyRelationType.setMinimumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
		destroyRelationType.setBorder(BorderFactory.createRaisedBevelBorder());
		destroyRelationType.addActionListener(new ActionListener(){
    		public void actionPerformed(ActionEvent e){
    			setRelationTypeMode(1);
    		}
    	});
    	destroyRelationType.setToolTipText(Constants.DESTROY_RELATION_TYPE_TIPTEXT);
    	destroyRelationType.setEnabled(true);
    	destroyRelationType.setSelected(false);
    	this.add(destroyRelationType);
		// Link Button
		linkRelationTypes = new JButton(new InterfaceIcon(Constants.LINK_RELATION_TYPES_ICON));
		linkRelationTypes.setMaximumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
		linkRelationTypes.setMinimumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
		linkRelationTypes.setBorder(BorderFactory.createRaisedBevelBorder());
		linkRelationTypes.addActionListener(new ActionListener(){
    		public void actionPerformed(ActionEvent e){
    			setRelationTypeMode(2);
    		}
    	});
    	linkRelationTypes.setToolTipText(Constants.LINK_RELATION_TYPES_TIPTEXT);
    	linkRelationTypes.setEnabled(true);
    	linkRelationTypes.setSelected(false);
    	this.add(linkRelationTypes);

    	// Drawing Help Button
		drawingHelp = new JButton(new InterfaceIcon(Constants.DRAWING_HELP_ICON));
		drawingHelp.setMaximumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
		drawingHelp.setMinimumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
		drawingHelp.setBorder(BorderFactory.createRaisedBevelBorder());
		drawingHelp.addActionListener(new ActionListener(){
    		public void actionPerformed(ActionEvent e){
				rfLink.refreshTree();
    		}
    	});
    	drawingHelp.setToolTipText(Constants.DRAWING_HELP_OFF_TIPTEXT);
    	this.add(drawingHelp);

	}
	
}

⌨️ 快捷键说明

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