popupaddclass.java
来自「Semantic Web Ontology Editor」· Java 代码 · 共 1,635 行 · 第 1/5 页
JAVA
1,635 行
tab1.add(classBar, "South"); if (this.typeIntCode>=0) mainTab.addTab("Defined", tab1); // draw restriction panel JPanel restPanel = new JPanel(); restPanel.setLayout(new BorderLayout()); restrPropOntologyCombo = new JComboBox(); restrPropOntologyCombo.addItemListener(this); restrPropOntologyCombo.setFont(tahoma); //Ontology source of the restriction JPanel ontPanel2 = createRowPanel("Select Ontology", restrPropOntologyCombo); resPropBox = new JComboBox(); resPropBox.setFont(tahoma); resPropBox.setEditable(true); resPropBox.setRenderer(new SwoopCellRenderer(swoopModel)); // create restriction property panel propTypeBox = new JComboBox(); propTypeBox.setFont(new Font("Tahoma", Font.PLAIN, 12)); propTypeBox.addItem("[D]"); propTypeBox.addItem("[O]"); propTypeBox.setVisible(false); propTypeBox.addItemListener(this); JPanel resPropLeft = createRowPanel("Select Property", propTypeBox); JPanel resPropPanel = new JPanel(); resPropPanel.setLayout(new BorderLayout()); resPropPanel.add(resPropLeft, "West"); resPropPanel.add(resPropBox, "Center"); // create restriction type panel resNameCombo = new JComboBox(); resNameCombo.setFont(new Font("Verdana", Font.PLAIN, 10)); resNameCombo.addItem("cardinality"); resNameCombo.addItem("MIN cardinality"); resNameCombo.addItem("MAX cardinality"); resNameCombo.addItem("has-value"); resNameCombo.addItem("some-values-from"); resNameCombo.addItem("all-values-from"); resNameCombo.addItemListener(this); JPanel resTypePanel = createRowPanel("Select Restriction Type", resNameCombo, "BOLD"); restrClassOntologyCombo = new JComboBox(); restrClassOntologyCombo.addItemListener(this); restrClassOntologyCombo.setFont(tahoma); JPanel ontPanel3 = createRowPanel("Select Ontology", restrClassOntologyCombo); resClassBox = new JComboBox(); resClassBox.setFont(tahoma); resClassBox.setEditable(true); resClassBox.setRenderer(new SwoopCellRenderer(swoopModel)); // add datatype value fields resDTypeBox = new JComboBox(); resDTypeBox.setFont(tahoma); resDTypeBox.setEditable(true);// resDTypeBox.setRenderer(new SwoopCellRenderer(swoopModel)); resDTypeFld = new JTextField(); resDTypeFld.setFont(tahoma); dTypePanel = new JPanel(); dTypePanel.setLayout(new BorderLayout()); Box dTypeBox = Box.createHorizontalBox(); dTypeBox.add(resDTypeBox); dTypeBox.add(resDTypeFld); JLabel dTypeLbl = new JLabel("Enter Datatype Value:"); dTypeLbl.setFont(tahoma); dTypePanel.add(dTypeLbl, "West"); dTypePanel.add(dTypeBox, "Center"); for (int i = 0; i < dataTypeURIs.size(); i++) { String dt = dataTypeURIs.get(i).toString(); resDTypeBox.addItem(dt); } resDTypeBox.setRenderer(new CellRenderer()); objResLbl = new JLabel("Select Class: "); objResLbl.setFont(tahoma); resClassPanel = new JPanel(); resClassPanel.setLayout(new BorderLayout()); resClassPanel.add(objResLbl, "West"); resClassPanel.add(resClassBox, "Center"); JPanel restPanelN = new JPanel(); restPanelN.setLayout(new GridLayout(10, 1)); JLabel propLbl = new JLabel("Subject of Restriction (Property)"); propLbl.setFont(tahomaB); restPanelN.add(propLbl); restPanelN.add(ontPanel2); restPanelN.add(resPropPanel); restPanelN.add(resTypePanel); JLabel claLbl = new JLabel( "Object of Restriction (Integer/Class/Value)"); claLbl.setFont(tahomaB); restPanelN.add(claLbl); restPanelN.add(ontPanel3); restPanelN.add(resClassPanel); restPanelN.add(dTypePanel); restrictionBar = new AddCloseBar(); restrictionBar.addActionListener(this); restPanelN.add(restrictionBar); restPanel.add(restPanelN, "Center"); simpleClassOntologyCombo.setRenderer(new CellRenderer()); restrPropOntologyCombo.setRenderer(new CellRenderer()); restrClassOntologyCombo.setRenderer(new CellRenderer()); if (this.typeIntCode>=0) mainTab.addTab("Restriction", restPanel); // create class expression panel JPanel cePanel = new JPanel(); cePanel.setLayout(new BorderLayout()); JPanel propBar = new JPanel(); propBar.setLayout(new GridLayout(1,5)); someBtn = new JButton("<html>"+ConciseFormat.EXISTS+"</html>"); someBtn.setToolTipText("<html>Used to create: <br> - someValuesFrom(OBJECT_PROP, CLASS) <br> - hasValue(OBJECT_PROP, INDIVIDUAL) <br> - someValuesFrom(DATA_PROP, DATATYPE) <br> - hasValue(DATA_PROP, DATA_VALUE)</html>"); allBtn = new JButton("<html>"+ConciseFormat.FORALL+"</html>"); allBtn.setToolTipText("<html>Used to create: <br> - allValuesFrom(OBJECT_PROP, CLASS) <br> - allValuesFrom(DATA_PROP, DATATYPE)</html>"); equBtn = new JButton("<html>"+ConciseFormat.EQU+"</html>"); equBtn.setToolTipText("<html>Used to create: <br> - cardinality(OBJECT_PROP, INTEGER) <br> - cardinality(DATA_PROP, INTEGER)</html>"); maxBtn = new JButton("<html>"+ConciseFormat.LESSEQU+"</html>"); maxBtn.setToolTipText("<html>Used to create: <br> - maxCardinality(OBJECT_PROP, INTEGER) <br> - maxCardinality(DATA_PROP, INTEGER)</html>"); minBtn = new JButton("<html>"+ConciseFormat.GREATEQU+"</html>"); minBtn.setToolTipText("<html>Used to create: <br> - minCardinality(OBJECT_PROP, INTEGER) <br> - minCardinality(DATA_PROP, INTEGER)</html>"); oneBtn = new JButton("{}"); oneBtn.setToolTipText("<html>Used to create: <br> - oneOf(IND_1, IND_2...,IND_n)</html>"); intBtn = new JButton("<html>"+ConciseFormat.INTERSECTION+"</html>"); intBtn.setToolTipText("<html>Used to create: <br> - intersection(CLASS_1, CLASS_2...,CLASS_n)</html>"); uniBtn = new JButton("<html>"+ConciseFormat.UNION+"</html>"); uniBtn.setToolTipText("<html>Used to create: <br> - union(CLASS_1, CLASS_2...,CLASS_n)</html>"); negBtn = new JButton("<html>"+ConciseFormat.COMPLEMENT+"</html>"); negBtn.setToolTipText("<html>Used to create: <br> - complement(CLASS)</html>"); ontPropBox = new JComboBox(); ontPropBox.setRenderer(new CellRenderer()); ontValBox = new JComboBox(); ontValBox.setRenderer(new CellRenderer()); propBar.add(someBtn); propBar.add(allBtn); propBar.add(equBtn); propBar.add(maxBtn); propBar.add(minBtn); JPanel valBar = new JPanel(); valBar.setLayout(new GridLayout(1,4)); valBar.add(intBtn); valBar.add(uniBtn); valBar.add(oneBtn); valBar.add(negBtn); propList = new JList(); propList.setFont(tahoma); propList.addKeyListener(this); propList.setCellRenderer(new SwoopCellRenderer(swoopModel)); valList = new JList(); valList.setFont(tahoma); valList.setCellRenderer(new SwoopCellRenderer(swoopModel)); ceList = new JList(); ceList.setCellRenderer(new ClassExprRenderer(swoopModel)); ceList.addKeyListener(this); valChooser = new JComboBox(); valChooser.setFont(tahoma); valChooser.addItem("Show Classes"); valChooser.addItem("Show Individuals"); valChooser.addItem("Show Datatypes"); valChooser.addItemListener(this); JSplitPane ceSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); JPanel leftPanel = new JPanel(); leftPanel.setLayout(new BorderLayout()); JPanel propNorth = new JPanel(); propNorth.setLayout(new BorderLayout()); propNorth.add(propBar, "North"); propNorth.add(ontPropBox, "Center"); leftPanel.add(propNorth, "North"); JPanel propListPanel = new JPanel(); propListPanel.setLayout(new BorderLayout()); JPanel propListNorth = new JPanel(); propListNorth.setLayout(new BorderLayout()); clearSelBtn1 = new JButton("Clear Sel"); clearSelBtn1.setFont(new Font("Tahoma", Font.PLAIN, 9)); propListNorth.add(clearSelBtn1, "East"); propListPanel.add(propListNorth, "North"); propListPanel.add(new JScrollPane(propList), "Center"); dataFld = new JTextField(); propListPanel.add(this.createRowPanel("Data", dataFld), "South"); leftPanel.add(propListPanel, "Center"); ceSplit.add(leftPanel, JSplitPane.LEFT); JSplitPane valSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); JPanel valPanel = new JPanel(); valPanel.setLayout(new BorderLayout()); valPanel.add(valChooser, BorderLayout.NORTH); valPanel.add(new JScrollPane(valList), BorderLayout.CENTER); valSplit.add(valPanel, JSplitPane.TOP); JPanel ceListPanel = new JPanel(); ceListPanel.setLayout(new BorderLayout()); JPanel ceListNorth = new JPanel(); ceListNorth.setLayout(new BorderLayout()); clearSelBtn3 = new JButton("Clear Sel"); clearSelBtn3.setFont(new Font("Tahoma", Font.PLAIN, 9)); ceListNorth.add(clearSelBtn3, "East"); ceListPanel.add(ceListNorth, "North"); ceListPanel.add(new JScrollPane(ceList), "Center"); valSplit.add(ceListPanel, JSplitPane.BOTTOM); JPanel rightPanel = new JPanel(); rightPanel.setLayout(new BorderLayout()); JPanel valNorth = new JPanel(); valNorth.setLayout(new BorderLayout()); valNorth.add(valBar, "North"); valNorth.add(ontValBox, "Center"); JPanel valSelPanel = new JPanel(); valSelPanel.setLayout(new BorderLayout()); clearSelBtn2 = new JButton("Clear Sel"); clearSelBtn2.setFont(new Font("Tahoma", Font.PLAIN, 9)); valSelPanel.add(clearSelBtn2, "East"); valNorth.add(valSelPanel, "South"); rightPanel.add(valNorth, "North"); rightPanel.add(valSplit, "Center"); ceSplit.add(rightPanel, JSplitPane.RIGHT); cePanel.add(ceSplit, "Center"); JPanel southPanel = new JPanel(); southPanel.setLayout(new GridLayout(2,1)); ceStatusLbl = new JLabel(); southPanel.add(this.createRowPanel("Status", ceStatusLbl, "BOLD")); if (this.typeIntCode >= 0) { ceBar = new AddCloseBar(); ceBar.addActionListener(this); southPanel.add(ceBar); } else { addCEBtn = new JButton("Add"); if (this.typeIntCode == -1) addCEBtn.setText("Specify LHS of GCI and Proceed.."); else if (this.typeIntCode == -2) addCEBtn.setText("Specify RHS of GCI & Add GCI"); addCEBtn.setFont(tahoma); cancelBtn3 = new JButton("Cancel"); cancelBtn3.setFont(tahoma); JPanel ceBtnPanel = new JPanel(); ceBtnPanel.setLayout(new GridLayout(1, 3)); ceBtnPanel.add(addCEBtn); ceBtnPanel.add(cancelBtn3); southPanel.add(ceBtnPanel); addCEBtn.addActionListener(this); cancelBtn3.addActionListener(this); } cePanel.add(southPanel, "South"); mainTab.addTab("Class Expression", cePanel); // setup action listeners for CE panel someBtn.addActionListener(this); allBtn.addActionListener(this); equBtn.addActionListener(this); maxBtn.addActionListener(this); minBtn.addActionListener(this); oneBtn.addActionListener(this); intBtn.addActionListener(this); uniBtn.addActionListener(this); negBtn.addActionListener(this); clearSelBtn1.addActionListener(this); clearSelBtn2.addActionListener(this); clearSelBtn3.addActionListener(this); fillValues(); // fill values for UI in cePanel this.fillPropList(); this.fillValList(); resNameCombo.setSelectedIndex(5); // add tabbed pane to frame container Container content = getContentPane(); content.setLayout(new BorderLayout()); JLabel typeLbl = new JLabel("[ ADDING " + type + ".. ]"); typeLbl.setFont(tahoma); content.add(typeLbl, "North"); if (swoopModel.getSelectedEntity() instanceof OWLDataProperty && type.equals("RANGE CLASS")) { // special case: adding range for datatype property JPanel dtypePanel = new JPanel(); dtypePanel.setLayout(new BorderLayout()); // add list of datatypes dtypeList = new JList(); dtypeList.setCellRenderer(new SwoopCellRenderer(swoopModel)); dtypeList.setListData(dataTypes.toArray()); dtypeList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent arg0) { try { newClassFld.setText(((OWLDataType) dtypeList.getSelectedValue()).getURI().toString()); } catch (OWLException e) { e.printStackTrace(); } } }); dtypePanel.add(new JScrollPane(dtypeList), "Center"); dtypePanel.add(classBar, "South"); content.add(dtypePanel); } else { content.add(mainTab, "Center"); } pack(); setTitle("Specify Class"); setSize(450, 410); setResizable(true); tab1Split.setDividerLocation(140); valSplit.setDividerLocation(140); } private JPanel createRowPanel(String lblStr, Component comp) { return createRowPanel(lblStr, comp, "PLAIN"); } private JPanel createRowPanel(String lblStr, Component comp, String font) { JLabel lbl = new JLabel(lblStr + ": "); if (font.equals("PLAIN")) lbl.setFont(tahoma); else if (font.equals("BOLD")) lbl.setFont(tahomaB); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(lbl, "West"); panel.add(comp, "Center"); return panel; } /* * Fill values in Ontology Combo Boxes (i.e populate it with ontologies * from SwoopModel) */ public void fillValues() { // get swoopModel ontology list // fill ontCombos with ontology list // turn off listeners simpleClassOntologyCombo.removeItemListener(this);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?