📄 axiomstoolbar.java
字号:
package toocom.ui;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
import java.lang.*;
import toocom.ocgl.*;
/**
* This class is used by AxiomsFrame, as it's ToolBar. It groups all the buttons
* for acting on the loaded axiom.
*
* @author Fr閐閞ic F黵st
* @author Nicolas Roy
* @author Matthieu Legall
* @author Dounia K閐a
*/
public class AxiomsToolBar extends JToolBar {
// The mode of interaction : -1 = disabled, 0=concept creation, 1=relation creation,
// 2=destruction, 3=linking
private boolean drawingHelpEnabled=false;
private JButton newAxiom;
private JButton logical;
private JButton note;
private JButton removeAxiom;
private JButton createConcept;
private JButton createRelation;
private JButton destroyPrimitive;
private JButton linkPrimitives;
private JButton drawingHelp;
private AxiomsFrame af;
private void setButtonVisibility(boolean b){
newAxiom.setVisible(b);
removeAxiom.setVisible(b);
createConcept.setVisible(b);
createRelation.setVisible(b);
destroyPrimitive.setVisible(b);
linkPrimitives.setVisible(b);
drawingHelp.setVisible(b);
this.repaint();
}
public void setEnabled(boolean b){
this.newAxiom.setEnabled(b);
this.removeAxiom.setEnabled(b);
}
public void setEnable(boolean b){
this.createConcept.setEnabled(b);
this.createRelation.setEnabled(b);
this.destroyPrimitive.setEnabled(b);
this.linkPrimitives.setEnabled(b);
this.drawingHelp.setEnabled(b);
if(b) this.setPrimitiveMode(0);
}
public void setPrimitiveMode(int mode){
af.setPrimitiveMode(mode);
if(mode == 0){
createConcept.setBackground(Constants.SELECTED_BUTTON_COLOR);
createRelation.setBackground(null);
destroyPrimitive.setBackground(null);
linkPrimitives.setBackground(null);
}
if(mode == 1){
createConcept.setBackground(null);
createRelation.setBackground(Constants.SELECTED_BUTTON_COLOR);
destroyPrimitive.setBackground(null);
linkPrimitives.setBackground(null);
}
if(mode == 2){
createConcept.setBackground(null);
createRelation.setBackground(null);
destroyPrimitive.setBackground(Constants.SELECTED_BUTTON_COLOR);
linkPrimitives.setBackground(null);
}
if(mode == 3){
createConcept.setBackground(null);
createRelation.setBackground(null);
destroyPrimitive.setBackground(null);
linkPrimitives.setBackground(Constants.SELECTED_BUTTON_COLOR);
}
}
public AxiomsToolBar(AxiomsFrame af){
super();
this.af = af;
final AxiomsFrame afLink=af;
final AxiomsToolBar me=this;
this.setBackground(Constants.AXIOMS_TOOLBAR_COLOR);
this.setLayout(new FlowLayout(FlowLayout.CENTER));
this.setFloatable(false);
// Axiom list
removeAxiom = new JButton(new InterfaceIcon(Constants.REMOVE_AXIOM_ICON));
removeAxiom.setMaximumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
removeAxiom.setMinimumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
removeAxiom.setBorder(BorderFactory.createRaisedBevelBorder());
removeAxiom.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
afLink.removeAxiom();
}
});
removeAxiom.setToolTipText(Constants.REMOVE_AXIOM_TIPTEXT);
removeAxiom.setVisible(true);
this.add(removeAxiom);
// New Axiom Button
newAxiom = new JButton(new InterfaceIcon(Constants.NEW_AXIOM_ICON));
newAxiom.setMaximumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
newAxiom.setMinimumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
newAxiom.setBorder(BorderFactory.createRaisedBevelBorder());
newAxiom.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
afLink.newAxiom();
}
});
newAxiom.setToolTipText(Constants.NEW_AXIOM_TIPTEXT);
newAxiom.setVisible(true);
this.add(newAxiom);
// Logical form Button
logical = new JButton(new InterfaceIcon(Constants.LOGICAL_FORM_ICON));
logical.setMaximumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
logical.setMinimumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
logical.setBorder(BorderFactory.createRaisedBevelBorder());
logical.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
afLink.logicalForm();
}
});
logical.setToolTipText(Constants.LOGICAL_FORM_TIPTEXT);
logical.setVisible(true);
this.add(logical);
// Note Button
note = new JButton(new InterfaceIcon(Constants.NOTE_ICON));
note.setMaximumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
note.setMinimumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
note.setBorder(BorderFactory.createRaisedBevelBorder());
note.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
afLink.note();
}
});
note.setToolTipText(Constants.NOTE_TIPTEXT);
note.setVisible(true);
this.add(note);
// Create Concept Button
createConcept = new JButton(new InterfaceIcon(Constants.CREATE_CONCEPT_ICON));
createConcept.setMaximumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
createConcept.setMinimumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
createConcept.setBorder(BorderFactory.createRaisedBevelBorder());
createConcept.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setPrimitiveMode(0);
}
});
createConcept.setToolTipText(Constants.CREATE_CONCEPT_TIPTEXT);
createConcept.setVisible(true);
this.add(createConcept);
// Create Button
createRelation = new JButton(new InterfaceIcon(Constants.CREATE_RELATION_ICON));
createRelation.setMaximumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
createRelation.setMinimumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
createRelation.setBorder(BorderFactory.createRaisedBevelBorder());
createRelation.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setPrimitiveMode(1);
}
});
createRelation.setToolTipText(Constants.CREATE_RELATION_TIPTEXT);
createRelation.setVisible(true);
this.add(createRelation);
// Destroy Button
destroyPrimitive = new JButton(new InterfaceIcon(Constants.DESTROY_PRIMITIVE_ICON));
destroyPrimitive.setMaximumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
destroyPrimitive.setMinimumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
destroyPrimitive.setBorder(BorderFactory.createRaisedBevelBorder());
destroyPrimitive.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setPrimitiveMode(2);
}
});
destroyPrimitive.setToolTipText(Constants.DESTROY_PRIMITIVE_TIPTEXT);
this.add(destroyPrimitive);
// Link Button
linkPrimitives = new JButton(new InterfaceIcon(Constants.LINK_PRIMITIVES_ICON));
linkPrimitives.setMaximumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
linkPrimitives.setMinimumSize(new Dimension(Constants.INTERNAL_FRAME_BUTTON_DIM,Constants.INTERNAL_FRAME_BUTTON_DIM));
linkPrimitives.setBorder(BorderFactory.createRaisedBevelBorder());
linkPrimitives.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setPrimitiveMode(3);
}
});
linkPrimitives.setToolTipText(Constants.LINK_PRIMITIVES_TIPTEXT);
this.add(linkPrimitives);
// Drawing Help Button
drawingHelp = new JButton(new InterfaceIcon(Constants.DRAWING_HELP_OFF_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){
drawingHelpEnabled=!(drawingHelpEnabled);
if (drawingHelpEnabled)
{
afLink.startDrawingHelp();
drawingHelp.setIcon(new InterfaceIcon(Constants.DRAWING_HELP_ON_ICON));
drawingHelp.setToolTipText(Constants.DRAWING_HELP_ON_TIPTEXT);
}
else
{
//Disable the graph drawing algorithm
afLink.stopDrawingHelp();
drawingHelp.setIcon(new InterfaceIcon(Constants.DRAWING_HELP_OFF_ICON));
drawingHelp.setToolTipText(Constants.DRAWING_HELP_OFF_TIPTEXT);
}
}
});
drawingHelp.setToolTipText(Constants.DRAWING_HELP_OFF_TIPTEXT);
this.add(drawingHelp);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -