From: <ton...@us...> - 2008-02-10 10:54:49
|
Revision: 533 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=533&view=rev Author: tonytacker Date: 2008-02-10 02:54:40 -0800 (Sun, 10 Feb 2008) Log Message: ----------- new layout for StringSet without specials (i.e. positive/negative examples) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-09 10:10:22 UTC (rev 532) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-10 10:54:40 UTC (rev 533) @@ -22,6 +22,8 @@ import java.awt.BorderLayout; import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.Color; @@ -33,6 +35,7 @@ import javax.swing.JPanel; import javax.swing.JButton; import javax.swing.JScrollPane; +import javax.swing.JTextField; import org.dllearner.core.Component; import org.dllearner.core.config.ConfigEntry; @@ -52,9 +55,16 @@ private static final long serialVersionUID = 7832726987046601916L; private Config config; private ConfigOption<?> configOption; + private GridBagLayout gridbag = new GridBagLayout(); + private GridBagConstraints constraints = new GridBagConstraints(); + private JLabel nameLabel; private JPanel widgetPanel = new JPanel(); - private JButton changeButton = new JButton("Change"); + private JButton addButton = new JButton("add"); + private JButton removeButton = new JButton("remove"); + private JButton clearButton = new JButton("clear"); + private JTextField stringField = new JTextField(25); + private Component component; private Class<? extends Component> componentOption; @@ -62,18 +72,25 @@ private JList stringList = new JList(); private DefaultListModel listModel = new DefaultListModel(); - public WidgetPanelStringSet(Config config, Component component, Class<? extends Component> componentOption, ConfigOption<?> configOption) { + this.config = config; this.configOption = configOption; this.component = component; this.componentOption = componentOption; + widgetPanel.setLayout(gridbag); + add(widgetPanel, BorderLayout.CENTER); showLabel(); // name of option and tooltip showThingToChange(); // textfield, setbutton - add(widgetPanel, BorderLayout.CENTER); + + stringList.setModel(listModel); + + addButton.addActionListener(this); + removeButton.addActionListener(this); + clearButton.addActionListener(this); } public JPanel getPanel() { @@ -81,16 +98,43 @@ } public void actionPerformed(ActionEvent e) { - if (e.getSource() == changeButton) { - setEntry(); + Set<String> exampleSet = new HashSet<String>(); + // add to list + if (e.getSource() == addButton + && !listModel.contains(stringField.getText())) { + listModel.addElement(stringField.getText()); } + // remove selection + if (e.getSource() == removeButton) { + int[] selectedIndices = stringList.getSelectedIndices(); + int count = 0; // remove i.e. index 2 and 4: after delete 2, 4 is + // now index 3 + for (int i : selectedIndices) + listModel.remove(i - count++); + } + // clear list + if (e.getSource() == clearButton) { + listModel.clear(); + } + // update + // stringList.setModel(listModel); + for (int i = 0; i < listModel.size(); i++) { + if (!listModel.get(i).toString().equalsIgnoreCase("")) + exampleSet.add(listModel.get(i).toString()); + } + // set entry + value = exampleSet; + setEntry(); } @Override protected void showLabel() { nameLabel = new JLabel(configOption.getName()); nameLabel.setToolTipText(configOption.getDescription()); - widgetPanel.add(nameLabel); + buildConstraints(constraints, 0, 0, 1, 1, 100, 100); + constraints.anchor = GridBagConstraints.WEST; + gridbag.setConstraints(nameLabel, constraints); + widgetPanel.add(nameLabel, constraints); } @SuppressWarnings("unchecked") @@ -115,23 +159,46 @@ } } } + buildConstraints(constraints, 0, 1, 1, 1, 100, 100); + gridbag.setConstraints(stringField, constraints); + widgetPanel.add(stringField, constraints); + + buildConstraints(constraints, 1, 1, 1, 1, 100, 100); + gridbag.setConstraints(addButton, constraints); + widgetPanel.add(addButton, constraints); + + // list stringList.setModel(listModel); stringList.setLayoutOrientation(JList.VERTICAL); stringList.setVisibleRowCount(-1); JScrollPane stringListScroller = new JScrollPane(stringList); - stringListScroller.setPreferredSize(new Dimension(200, 100)); - widgetPanel.add(stringListScroller); - widgetPanel.add(changeButton); - changeButton.addActionListener(this); + stringListScroller.setPreferredSize(new Dimension(280, 100)); + + buildConstraints(constraints, 0, 2, 1, 2, 100, 100); + gridbag.setConstraints(stringListScroller, constraints); + widgetPanel.add(stringListScroller, constraints); + + buildConstraints(constraints, 1, 2, 1, 1, 100, 100); + gridbag.setConstraints(removeButton, constraints); + widgetPanel.add(removeButton, constraints); + + buildConstraints(constraints, 1, 3, 1, 1, 100, 100); + gridbag.setConstraints(clearButton, constraints); + widgetPanel.add(clearButton, constraints); + + // widgetPanel.add(setButton); + // setButton.addActionListener(this); } // UNKNOWN else { JLabel notImplementedLabel = new JLabel("not a set of strings"); notImplementedLabel.setForeground(Color.RED); + buildConstraints(constraints, 0, 1, 1, 1, 100, 100); + gridbag.setConstraints(notImplementedLabel, constraints); widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no instance (StringSet)"); + JLabel noConfigOptionLabel = new JLabel("no init (StringSet)"); noConfigOptionLabel.setForeground(Color.MAGENTA); widgetPanel.add(noConfigOptionLabel); } @@ -149,12 +216,25 @@ specialOption, value); config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out.println("set StringSet: " + configOption.getName() + " = " - + value); + System.out.println("set StringSet: " + configOption.getName() + + " = " + value); } catch (InvalidConfigOptionValueException s) { s.printStackTrace(); } } + /** + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, + int gw, int gh, int wx, int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-11 15:00:59
|
Revision: 538 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=538&view=rev Author: tonytacker Date: 2008-02-11 07:00:55 -0800 (Mon, 11 Feb 2008) Log Message: ----------- special option for positiveExamples, negativeExamples, allowedConcepts, ignoredConcepts, allowedRoles, ignoredRoles for StringSet Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-11 14:30:50 UTC (rev 537) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-02-11 15:00:55 UTC (rev 538) @@ -42,6 +42,8 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.StringSetConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.dl.AtomicConcept; +import org.dllearner.core.dl.AtomicRole; import org.dllearner.core.dl.Individual; /** @@ -224,6 +226,31 @@ for (Individual ind : individuals) cBL.add(ind.getName()); } + // allowedConcepts or ignoredConcepts + if (configOption.getName().equalsIgnoreCase( + "allowedConcepts") + || configOption.getName().equalsIgnoreCase( + "ignoredConcepts")) { + // fill lists + Set<AtomicConcept> atomicsSet = config + .getReasoningService().getAtomicConcepts(); + LinkedList<AtomicConcept> atomicConcepts = new LinkedList<AtomicConcept>( + atomicsSet); + for (AtomicConcept ind : atomicConcepts) + cBL.add(ind.getName()); + } + // allowedRoles or ignoredRoles + if (configOption.getName().equalsIgnoreCase("allowedRoles") + || configOption.getName().equalsIgnoreCase( + "ignoredRoles")) { + // fill lists + Set<AtomicRole> atomicsSet = config + .getReasoningService().getAtomicRoles(); + LinkedList<AtomicRole> atomicRoles = new LinkedList<AtomicRole>( + atomicsSet); + for (AtomicRole ind : atomicRoles) + cBL.add(ind.getName()); + } } } // UNKNOWN @@ -279,7 +306,11 @@ */ private boolean isSpecial() { if (configOption.getName().equalsIgnoreCase("positiveExamples") - || configOption.getName().equalsIgnoreCase("negativeExamples")) + || configOption.getName().equalsIgnoreCase("negativeExamples") + || configOption.getName().equalsIgnoreCase("allowedConcepts") + || configOption.getName().equalsIgnoreCase("ignoredConcepts") + || configOption.getName().equalsIgnoreCase("allowedRoles") + || configOption.getName().equalsIgnoreCase("ignoredRoles")) return true; else return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-04-07 00:18:14
|
Revision: 765 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=765&view=rev Author: tonytacker Date: 2008-04-06 17:18:05 -0700 (Sun, 06 Apr 2008) Log Message: ----------- wider textarea for stringset Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-04-03 14:03:19 UTC (rev 764) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-04-07 00:18:05 UTC (rev 765) @@ -69,7 +69,7 @@ private JButton addButton = new JButton("add"); private JButton removeButton = new JButton("remove"); private JButton clearButton = new JButton("clear"); - private JTextField stringField = new JTextField(25); + private JTextField stringField = new JTextField(30); private Component component; private Component oldComponent; @@ -198,7 +198,7 @@ stringList.setLayoutOrientation(JList.VERTICAL); stringList.setVisibleRowCount(-1); JScrollPane stringListScroller = new JScrollPane(stringList); - stringListScroller.setPreferredSize(new Dimension(280, 100)); + stringListScroller.setPreferredSize(new Dimension(380, 100)); buildConstraints(constraints, 0, 2, 1, 2, 100, 100); gridbag.setConstraints(stringListScroller, constraints); widgetPanel.add(stringListScroller, constraints); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |