📄 concepttypestoolbar.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 concept 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 concepts with
* a is-a link. Right-clicking on a concept open a window with the properties of the concept.
*
* @author Fr閐閞ic F黵st
*/
public class ConceptTypesToolBar extends JToolBar{
// The mode of interaction : -1 = disabled, 0=creation, 1=destruction, 2=linking
private int mode;
private JButton createConceptType;
private JButton destroyConceptType;
private JButton linkConceptTypes;
private JButton drawingHelp;
private ConceptTypesFrame cf;
public void setEnabled(boolean b){
if(b) this.setConceptTypeMode(0);
else this.setConceptTypeMode(-1);
}
public void setConceptTypeMode(int mode){
this.mode = mode;
cf.setConceptTypeMode(mode);
if(mode == 0){
createConceptType.setBackground(Constants.SELECTED_BUTTON_COLOR);
destroyConceptType.setBackground(null);
linkConceptTypes.setBackground(null);
}
if(mode == 1){
createConceptType.setBackground(null);
destroyConceptType.setBackground(Constants.SELECTED_BUTTON_COLOR);
linkConceptTypes.setBackground(null);
}
if(mode == 2){
createConceptType.setBackground(null);
destroyConceptType.setBackground(null);
linkConceptTypes.setBackground(Constants.SELECTED_BUTTON_COLOR);
}
}
public ConceptTypesToolBar(ConceptTypesFrame cf){
super();
this.cf = cf;
final ConceptTypesFrame cfLink = cf;
mode = -1;
// Create the button panel
this.setBackground(Constants.CONCEPT_TYPES_FRAME_COLOR);
this.setLayout(new FlowLayout(FlowLayout.CENTER));
this.setFloatable(false);
// Create Button
createConceptType = new JButton(new InterfaceIcon(Constants.CREATE_CONCEPT_TYPE_ICON));
createConceptType.setMaximumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
createConceptType.setMinimumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
createConceptType.setBorder(BorderFactory.createRaisedBevelBorder());
createConceptType.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setConceptTypeMode(0);
}
});
createConceptType.setToolTipText(Constants.CREATE_CONCEPT_TYPE_TIPTEXT);
createConceptType.setEnabled(true);
createConceptType.setVisible(true);
createConceptType.setSelected(true);
createConceptType.setBackground(Constants.SELECTED_BUTTON_COLOR);
this.add(createConceptType);
// Destroy Button
destroyConceptType = new JButton(new InterfaceIcon(Constants.DESTROY_CONCEPT_TYPE_ICON));
destroyConceptType.setMaximumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
destroyConceptType.setMinimumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
destroyConceptType.setBorder(BorderFactory.createRaisedBevelBorder());
destroyConceptType.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setConceptTypeMode(1);
}
});
destroyConceptType.setToolTipText(Constants.DESTROY_CONCEPT_TYPE_TIPTEXT);
destroyConceptType.setEnabled(true);
destroyConceptType.setSelected(false);
this.add(destroyConceptType);
// Link Button
linkConceptTypes = new JButton(new InterfaceIcon(Constants.LINK_CONCEPT_TYPES_ICON));
linkConceptTypes.setMaximumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
linkConceptTypes.setMinimumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
linkConceptTypes.setBorder(BorderFactory.createRaisedBevelBorder());
linkConceptTypes.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setConceptTypeMode(2);
}
});
linkConceptTypes.setToolTipText(Constants.LINK_CONCEPT_TYPES_TIPTEXT);
linkConceptTypes.setEnabled(true);
linkConceptTypes.setSelected(false);
this.add(linkConceptTypes);
// 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){
cfLink.refreshTree();
}
});
drawingHelp.setToolTipText(Constants.DRAWING_HELP_OFF_TIPTEXT);
this.add(drawingHelp);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -