From: <ton...@us...> - 2008-03-03 23:51:42
|
Revision: 679 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=679&view=rev Author: tonytacker Date: 2008-03-03 15:51:39 -0800 (Mon, 03 Mar 2008) Log Message: ----------- removed some bugs and outputs Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-03-03 23:51:39 UTC (rev 679) @@ -301,14 +301,18 @@ } /** - * Get time in ns for run of algorithm. + * Get time in ns for run of algorithm. If algorithm is still running return + * time between RunStartTime and now. * * @return time in ns */ public Long getAlgorithmRunTime() { - if (algorithmRunStartTime != null && algorithmRunStopTime != null) - if (algorithmRunStartTime < algorithmRunStopTime) - return algorithmRunStopTime - algorithmRunStartTime; + if (algorithmRunStartTime != null) + if (algorithmRunStopTime != null) { + if (algorithmRunStartTime < algorithmRunStopTime) + return algorithmRunStopTime - algorithmRunStartTime; + } else + return System.nanoTime() - algorithmRunStartTime; return null; } } Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-03-03 23:51:39 UTC (rev 679) @@ -169,6 +169,7 @@ config.getLearningAlgorithm().init(); config.setInitLearningAlgorithm(true); System.out.println("init LearningAlgorithm"); + startGUI.updateTabColors(); } catch (ComponentInitException e) { e.printStackTrace(); } Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-03-03 23:51:39 UTC (rev 679) @@ -95,7 +95,7 @@ if (choosenClassIndex != cb.getSelectedIndex()) { choosenClassIndex = cb.getSelectedIndex(); config.setInitKnowledgeSource(false); - setSource(); + init(); } if (e.getSource() == setButton) { @@ -120,6 +120,7 @@ * after this, next tab can be used */ public void init() { + setSource(); if (config.getKnowledgeSource() != null && config.isSetURL()) { try { config.getKnowledgeSource().init(); Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-03-03 23:51:39 UTC (rev 679) @@ -82,16 +82,16 @@ add(optionPanel, BorderLayout.CENTER); add(initPanel, BorderLayout.PAGE_END); + choosenClassIndex = cb.getSelectedIndex(); updateInitButtonColor(); } public void actionPerformed(ActionEvent e) { // read selected Class - // choosenClassIndex = cb.getSelectedIndex(); if (choosenClassIndex != cb.getSelectedIndex()) { choosenClassIndex = cb.getSelectedIndex(); config.setInitLearningAlgorithm(false); - setLearningAlgorithm(); + init(); } if (e.getSource() == autoInitButton) Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-03-03 23:51:39 UTC (rev 679) @@ -93,7 +93,7 @@ if (choosenClassIndex != cb.getSelectedIndex()) { this.choosenClassIndex = cb.getSelectedIndex(); config.setInitLearningProblem(false); - setLearningProblem(); + init(); } if (e.getSource() == setButton) Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-03-03 23:51:39 UTC (rev 679) @@ -94,7 +94,7 @@ if (choosenClassIndex != cb.getSelectedIndex()) { choosenClassIndex = cb.getSelectedIndex(); config.setInitReasoner(false); - setReasoner(); + init(); } if (e.getSource() == setButton) { Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-03 23:51:39 UTC (rev 679) @@ -23,9 +23,7 @@ import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; - import javax.swing.*; -import org.dllearner.utilities.Helper; /** * RunPanel let algorithm start and stop and show informations about. @@ -87,8 +85,10 @@ public void actionPerformed(ActionEvent e) { // start - if (e.getSource() == runButton && config.getLearningAlgorithm() != null) { + if (e.getSource() == runButton && config.getLearningAlgorithm() != null + && !config.getThreadIsRunning()) { thread = new ThreadRun(config); + config.getReasoningService().resetStatistics(); thread.start(); this.runBoolean = true; } @@ -98,17 +98,20 @@ } // getBestSolution if (e.getSource() == getBestSolutionButton && runBoolean) { - infoArea.setText(config.getLearningAlgorithm().getBestSolution().toString()); + if (config.getLearningAlgorithm().getBestSolution() != null) + infoArea.setText(config.getLearningAlgorithm().getBestSolution().toString()); } // getSolutionScore if (e.getSource() == getSolutionScoreButton && runBoolean) { - infoArea.setText(config.getLearningAlgorithm().getSolutionScore().toString()); + if (config.getLearningAlgorithm().getSolutionScore() != null) + infoArea.setText(config.getLearningAlgorithm().getSolutionScore().toString()); } // ReasonerStats - if (e.getSource() == getReasonerStatsButton /* && runBoolean*/) { -/* infoArea.setText(""); - infoArea.append("Algorithm Runtime: " - + makeTime(config.getAlgorithmRunTime()) + "\n"); + if (e.getSource() == getReasonerStatsButton && runBoolean) { + infoArea.setText(""); + if (config.getAlgorithmRunTime() != null) + infoArea.append("Algorithm Runtime: " + makeTime(config.getAlgorithmRunTime()) + + "\n"); infoArea.append("OverallReasoningTime: " + makeTime(config.getReasoningService().getOverallReasoningTimeNs()) + "\n"); infoArea.append("Instances (" + config.getReasoningService().getNrOfInstanceChecks() @@ -128,48 +131,32 @@ infoArea.append("Subsumption (" + config.getReasoningService().getNrOfSubsumptionChecks() + "): " + makeTime(config.getReasoningService().getTimePerSubsumptionCheckNs()) + "\n"); - -*/ infoArea.setText(makeTime(9927255727L)); - } } /** - * Build a String form nanoSeconds. + * Build a String from nanoSeconds. * * @param nanoSeconds * is type of Long and represent a time interval in ns - * @return a string like this: 3h 12min 46s 753ms + * @return a string like this: 3h 10min 46s 753ms */ - public String makeTime(long nanoSeconds) { + public String makeTime(Long nanoSeconds) { + Long hours = 0L, minutes = 0L, seconds = 0L, millis = 0L, mikros = 0L, nanos = 0L; String time = ""; - long hours, minutes, seconds, millis, mikros, nanos; - // it cuts last decimals - nanos = nanoSeconds; - mikros = nanos / 1000; - millis = mikros / 1000; - seconds = millis / 1000; - minutes = seconds / 60; - hours = minutes / 60; - - // and calculate back - minutes -= hours * 60; - seconds -= minutes * 60; - millis -= seconds * 1000; - mikros -= millis * 1000; - nanos -= mikros * 1000; - - System.out.println("TEST: " + hours + "h " + minutes + "min " + seconds + "s " + millis + "ms " + mikros + "mikro " + nanos + "nano "); - - - - - - System.out.println(Helper.prettyPrintNanoSeconds(nanoSeconds, true, true)); - - - + nanos = nanoSeconds % 1000; + nanoSeconds /= 1000; + mikros = nanoSeconds % 1000; + nanoSeconds /= 1000; + millis = nanoSeconds % 1000; + nanoSeconds /= 1000; + seconds = nanoSeconds % 60; + nanoSeconds /= 60; + minutes = nanoSeconds % 60; + nanoSeconds /= 60; + hours = nanoSeconds; + if (hours > 0) time += hours + "h "; if (minutes > 0) @@ -178,12 +165,10 @@ time += seconds + "s "; if (millis > 0) time += millis + "ms "; - if (mikros > 0) - time += mikros + "ms "; - if (nanos > 0) - time += nanos + "ms "; - - // System.out.println("time: " + time); + if (false) + time += mikros + "\xB5s "; + if (false) + time += nanos + "ns "; return time; } } Modified: trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-03-03 23:51:39 UTC (rev 679) @@ -51,6 +51,7 @@ public void exit() { if (config.getLearningAlgorithm() != null) config.getLearningAlgorithm().stop(); - System.out.println("stop"); + config.setThreadIsRunning(false); + System.out.println("stop run"); } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-03-03 23:51:39 UTC (rev 679) @@ -147,7 +147,8 @@ try { ConfigEntry<Boolean> specialEntry = new ConfigEntry<Boolean>(specialOption, value); config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out.println("set Boolean: " + configOption.getName() + " = " + value); + // System.out.println("set Boolean: " + configOption.getName() + + // " = " + value); } catch (InvalidConfigOptionValueException s) { s.printStackTrace(); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java 2008-03-03 23:51:39 UTC (rev 679) @@ -144,7 +144,8 @@ try { ConfigEntry<Double> specialEntry = new ConfigEntry<Double>(specialOption, value); config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out.println("set Double: " + configOption.getName() + " = " + value); + // System.out.println("set Double: " + configOption.getName() + + // " = " + value); } catch (InvalidConfigOptionValueException s) { s.printStackTrace(); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-03-03 23:51:39 UTC (rev 679) @@ -145,7 +145,8 @@ try { ConfigEntry<Integer> specialEntry = new ConfigEntry<Integer>(specialOption, value); config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out.println("set Integer: " + configOption.getName() + " = " + value); + // System.out.println("set Integer: " + configOption.getName() + + // " = " + value); } catch (InvalidConfigOptionValueException s) { s.printStackTrace(); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-03-03 23:51:39 UTC (rev 679) @@ -159,7 +159,8 @@ try { ConfigEntry<String> specialEntry = new ConfigEntry<String>(specialOption, value); config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out.println("set String: " + configOption.getName() + " = " + value); + // System.out.println("set String: " + configOption.getName() + + // " = " + value); } catch (InvalidConfigOptionValueException s) { s.printStackTrace(); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-03-03 23:51:39 UTC (rev 679) @@ -286,7 +286,8 @@ ConfigEntry<Set<String>> specialEntry = new ConfigEntry<Set<String>>(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(); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java 2008-03-03 20:06:17 UTC (rev 678) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java 2008-03-03 23:51:39 UTC (rev 679) @@ -233,8 +233,8 @@ ConfigEntry<List<StringTuple>> specialEntry = new ConfigEntry<List<StringTuple>>( specialOption, value); config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out - .println("set StringTupleList: " + configOption.getName() + " = " + value); + // System.out.println("set StringTupleList: " + + // configOption.getName() + " = " + value); } catch (InvalidConfigOptionValueException s) { s.printStackTrace(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-04 13:40:27
|
Revision: 686 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=686&view=rev Author: tonytacker Date: 2008-03-04 05:40:00 -0800 (Tue, 04 Mar 2008) Log Message: ----------- changed methods to get nanoseconds, add percent-method Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-04 12:02:49 UTC (rev 685) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-04 13:40:00 UTC (rev 686) @@ -90,36 +90,53 @@ * Show Statistics. */ public void showStats() { + Long algorithmRunTime = null; + Long overallReasoningTime = null; + Long instanceCheckReasoningTime = null; + Long retrievalReasoningTime = null; + Long subsumptionReasoningTime = null; infoArea.setText(""); - // best solution - if (config.getLearningAlgorithm().getBestSolution() != null) + // best solutions + if (config.getLearningAlgorithm().getBestSolutions(5) != null) infoArea.append("BestSolution:\n" - + config.getLearningAlgorithm().getBestSolution().toString() + "\n\n"); + + config.getLearningAlgorithm().getBestSolutions(5).toString() + "\n\n"); // solution score -// if (config.getLearningAlgorithm().getSolutionScore() != null) -// infoArea.append("SolutionScore:\n" -// + config.getLearningAlgorithm().getSolutionScore().toString() + "\n\n"); + // if (config.getLearningAlgorithm().getSolutionScore() != null) + // infoArea.append("SolutionScore:\n" + // + config.getLearningAlgorithm().getSolutionScore().toString() + // + "\n\n"); + // reasoner statistics - if (config.getAlgorithmRunTime() != null) - infoArea.append("Algorithm Runtime: " + makeTime(config.getAlgorithmRunTime()) + "\n"); - infoArea.append("OverallReasoningTime: " - + makeTime(config.getReasoningService().getOverallReasoningTimeNs()) + "\n"); + if (config.getAlgorithmRunTime() != null) { + algorithmRunTime = config.getAlgorithmRunTime(); + infoArea.append("Algorithm Runtime: " + makeTime(algorithmRunTime) + "\n"); + } + overallReasoningTime = config.getReasoningService().getOverallReasoningTimeNs(); + infoArea.append("OverallReasoningTime: " + makeTime(overallReasoningTime) + + Percent(overallReasoningTime, algorithmRunTime) + "\n"); infoArea.append("Instances (" + config.getReasoningService().getNrOfInstanceChecks() + "): "); - if (config.getReasoningService().getNrOfInstanceChecks() > 0) - infoArea.append(makeTime(config.getReasoningService().getTimePerInstanceCheckNs()) - + "\n"); - else + if (config.getReasoningService().getNrOfInstanceChecks() > 0) { + instanceCheckReasoningTime = config.getReasoningService() + .getInstanceCheckReasoningTimeNs(); + infoArea.append(makeTime(instanceCheckReasoningTime) + + Percent(instanceCheckReasoningTime, algorithmRunTime) + "\n"); + } else infoArea.append(" - \n"); infoArea.append("Retrieval (" + config.getReasoningService().getNrOfRetrievals() + "): "); - if (config.getReasoningService().getNrOfRetrievals() > 0) - infoArea.append(makeTime(config.getReasoningService().getTimePerRetrievalNs()) + "\n"); - else + if (config.getReasoningService().getNrOfRetrievals() > 0) { + retrievalReasoningTime = config.getReasoningService().getRetrievalReasoningTimeNs(); + infoArea.append(makeTime(retrievalReasoningTime) + + Percent(retrievalReasoningTime, algorithmRunTime) + "\n"); + } else infoArea.append(" - \n"); - if (config.getReasoningService().getNrOfSubsumptionChecks() > 0) + if (config.getReasoningService().getNrOfSubsumptionChecks() > 0) { + subsumptionReasoningTime = config.getReasoningService().getSubsumptionReasoningTimeNs(); infoArea.append("Subsumption (" + config.getReasoningService().getNrOfSubsumptionChecks() + "): " - + makeTime(config.getReasoningService().getTimePerSubsumptionCheckNs()) + "\n"); + + makeTime(subsumptionReasoningTime) + + Percent(subsumptionReasoningTime, algorithmRunTime) + "\n"); + } } /** @@ -161,4 +178,20 @@ time += nanos + "ns "; return time; } + + /** + * Get a percent string like this: "(10,5 %)" + * + * @param a + * @param b + * @return + */ + public String Percent(Long a, Long b) { + if (a != null && b != null) { + Double c = (double) a / (double) b * (double) 100; + c = Math.ceil(c * 10) / 10; + return " (" + c.toString() + " %) "; + } + return null; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java 2008-03-04 12:02:49 UTC (rev 685) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java 2008-03-04 13:40:00 UTC (rev 686) @@ -41,6 +41,11 @@ @Override public void run() { if (config.getThreadIsRunning()) { + try { + sleep(1000); // sleep 1 second + } catch (InterruptedException e) { + e.printStackTrace(); + } while (config.getThreadIsRunning()) { try { runPanel.showStats(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-08 04:16:37
|
Revision: 693 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=693&view=rev Author: tonytacker Date: 2008-03-07 20:16:34 -0800 (Fri, 07 Mar 2008) Log Message: ----------- changed layout for runPanel Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/Bar.java Added: trunk/src/dl-learner/org/dllearner/gui/Bar.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Bar.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/Bar.java 2008-03-08 04:16:34 UTC (rev 693) @@ -0,0 +1,71 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +import java.awt.*; +import javax.swing.*; + +/** + * @author Tilo Hielscher + * + */ +public class Bar extends JPanel { + + private static final long serialVersionUID = 8084274242520881523L; + private int height; + private int width; + private double factor; + + @Override + public void paint(Graphics g) { + super.paintComponent(g); + super.setSize(this.width, this.height); + g.fillRect(0, 0, (int) (this.width * this.factor), this.height); + } + + /** + * Make a horizontal bar. + * + * @param width + * in pixel + * @param height + * in pixel + * @param factor + * should between 0 and 1 (1 for 100%) + */ + public Bar(int width, int height, double factor) { + this.width = width; + this.height = height; + this.factor = factor; + repaint(); + } + + /** + * Update horizontal bar. + * + * @param factor + * should between 0 and 1 (1 for 100%) + */ + public void update(double factor) { + this.factor = factor; + repaint(); + } +} Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-07 08:44:10 UTC (rev 692) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-08 04:16:34 UTC (rev 693) @@ -21,13 +21,13 @@ */ import java.awt.BorderLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; /** - * RunPanel let algorithm start and stop and show informations about. - * * @author Tilo Hielscher * */ @@ -40,12 +40,25 @@ private Config config; private ThreadRun thread; - // private Boolean runBoolean = new Boolean(false); + private GridBagLayout gridbag = new GridBagLayout(); + private GridBagConstraints constraints = new GridBagConstraints(); + private GridBagLayout gridbag2 = new GridBagLayout(); + private GridBagConstraints constraints2 = new GridBagConstraints(); + private JPanel showPanel = new JPanel(); + private JPanel centerPanel = new JPanel(); + private JPanel solutionPanel = new JPanel(); private JPanel infoPanel = new JPanel(); - private JPanel solutionPanel = new JPanel(); + private String[] names = { "Algorithm Runtime", "OverallReasoningTime", "Instances", + "Retrieval", "Subsumption" }; + + private JLabel[] name = new JLabel[5]; + private Bar[] bar = new Bar[5]; + private JLabel[] time = new JLabel[5]; + private JLabel[] percent = new JLabel[5]; + RunPanel(Config config) { super(new BorderLayout()); @@ -56,16 +69,68 @@ stopButton = new JButton("Stop"); stopButton.addActionListener(this); + showPanel.add(runButton); + showPanel.add(stopButton); + + infoPanel.setLayout(gridbag); + constraints.anchor = GridBagConstraints.WEST; + constraints.ipadx = 20; + + // make names + for (int i = 0; i < 5; i++) { + name[i] = new JLabel(names[i]); + } + + // make bars + for (int i = 0; i < 5; i++) { + bar[i] = new Bar(100, 10, 0.0); + } + + // make time + for (int i = 0; i < 5; i++) { + time[i] = new JLabel("-"); + } + + // make percent + for (int i = 0; i < 5; i++) { + percent[i] = new JLabel("-"); + } + + // name, bar, time + for (int i = 0; i < 5; i++) { + buildConstraints(constraints, 0, i, 1, 1, 1, 1); + gridbag.setConstraints(name[i], constraints); + infoPanel.add(name[i], constraints); + buildConstraints(constraints, 1, i, 1, 1, 1, 1); + gridbag.setConstraints(bar[i], constraints); + infoPanel.add(bar[i], constraints); + buildConstraints(constraints, 2, i, 1, 1, 1, 1); + gridbag.setConstraints(time[i], constraints); + infoPanel.add(time[i], constraints); + buildConstraints(constraints, 3, i, 1, 1, 1, 1); + gridbag.setConstraints(percent[i], constraints); + infoPanel.add(percent[i], constraints); + } + + // text area infoArea = new JTextArea(20, 50); JScrollPane infoScroll = new JScrollPane(infoArea); - showPanel.add(runButton); - showPanel.add(stopButton); + // layout for centerPanel + centerPanel.setLayout(gridbag2); + constraints2.anchor = GridBagConstraints.CENTER; + constraints2.fill = GridBagConstraints.BOTH; + constraints2.ipadx = 10; + buildConstraints(constraints2, 0, 0, 1, 1, 1, 1); + gridbag2.setConstraints(infoPanel, constraints2); + centerPanel.add(infoPanel, constraints2); + buildConstraints(constraints2, 0, 1, 1, 1, 1, 1); + gridbag2.setConstraints(infoScroll, constraints2); + centerPanel.add(infoScroll, constraints2); - infoPanel.add(infoScroll); - + // layout for this panel add(showPanel, BorderLayout.PAGE_START); - add(infoPanel, BorderLayout.CENTER); + add(centerPanel, BorderLayout.CENTER); add(solutionPanel, BorderLayout.PAGE_END); } @@ -76,7 +141,6 @@ thread = new ThreadRun(config); config.getReasoningService().resetStatistics(); thread.start(); - // this.runBoolean = true; ThreadStatistics threadStatistics = new ThreadStatistics(config, this); threadStatistics.start(); } @@ -95,10 +159,11 @@ Long instanceCheckReasoningTime = null; Long retrievalReasoningTime = null; Long subsumptionReasoningTime = null; + infoArea.setText(""); // best solutions if (config.getLearningAlgorithm().getBestSolutions(5) != null) - infoArea.append("BestSolution:\n" + infoArea.append("BestSolutions:\n" + config.getLearningAlgorithm().getBestSolutions(5).toString() + "\n\n"); // solution score // if (config.getLearningAlgorithm().getSolutionScore() != null) @@ -109,34 +174,40 @@ // reasoner statistics if (config.getAlgorithmRunTime() != null) { algorithmRunTime = config.getAlgorithmRunTime(); - infoArea.append("Algorithm Runtime: " + makeTime(algorithmRunTime) + "\n"); + bar[0].update(1.0); + time[0].setText(makeTime(algorithmRunTime)); + percent[0].setText("100%"); } overallReasoningTime = config.getReasoningService().getOverallReasoningTimeNs(); - infoArea.append("OverallReasoningTime: " + makeTime(overallReasoningTime) - + Percent(overallReasoningTime, algorithmRunTime) + "\n"); - infoArea.append("Instances (" + config.getReasoningService().getNrOfInstanceChecks() - + "): "); + bar[1].update((double) overallReasoningTime / (double) algorithmRunTime); + time[1].setText(makeTime(overallReasoningTime)); + percent[1].setText(Percent(overallReasoningTime, algorithmRunTime)); if (config.getReasoningService().getNrOfInstanceChecks() > 0) { instanceCheckReasoningTime = config.getReasoningService() .getInstanceCheckReasoningTimeNs(); - infoArea.append(makeTime(instanceCheckReasoningTime) - + Percent(instanceCheckReasoningTime, algorithmRunTime) + "\n"); - } else - infoArea.append(" - \n"); - infoArea.append("Retrieval (" + config.getReasoningService().getNrOfRetrievals() + "): "); + name[2].setText(names[2] + " (" + config.getReasoningService().getNrOfInstanceChecks() + + ")"); + bar[2].update((double) instanceCheckReasoningTime / (double) algorithmRunTime); + time[2].setText(makeTime(instanceCheckReasoningTime)); + percent[2].setText(Percent(instanceCheckReasoningTime, algorithmRunTime)); + } if (config.getReasoningService().getNrOfRetrievals() > 0) { retrievalReasoningTime = config.getReasoningService().getRetrievalReasoningTimeNs(); - infoArea.append(makeTime(retrievalReasoningTime) - + Percent(retrievalReasoningTime, algorithmRunTime) + "\n"); - } else - infoArea.append(" - \n"); + name[3].setText(names[3] + " (" + config.getReasoningService().getNrOfRetrievals() + + ")"); + bar[3].update((double) retrievalReasoningTime / (double) algorithmRunTime); + time[3].setText(makeTime(retrievalReasoningTime)); + percent[3].setText(Percent(retrievalReasoningTime, algorithmRunTime)); + } if (config.getReasoningService().getNrOfSubsumptionChecks() > 0) { subsumptionReasoningTime = config.getReasoningService().getSubsumptionReasoningTimeNs(); - infoArea.append("Subsumption (" - + config.getReasoningService().getNrOfSubsumptionChecks() + "): " - + makeTime(subsumptionReasoningTime) - + Percent(subsumptionReasoningTime, algorithmRunTime) + "\n"); + name[4].setText(names[4] + " (" + + config.getReasoningService().getNrOfSubsumptionChecks() + ")"); + bar[4].update((double) subsumptionReasoningTime / (double) algorithmRunTime); + time[4].setText(makeTime(subsumptionReasoningTime)); + percent[4].setText(Percent(subsumptionReasoningTime, algorithmRunTime)); } + repaint(); } /** @@ -180,9 +251,9 @@ } /** - * Get a percent string like this: "(10,5 %)" + * Get a percent string like this: "10,5%" * - * @param a + * @param a * @param b * @return */ @@ -190,8 +261,21 @@ if (a != null && b != null) { Double c = (double) a / (double) b * (double) 100; c = Math.ceil(c * 10) / 10; - return " (" + c.toString() + " %) "; + return c.toString() + "% "; } return null; } + + /** + * 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-03-09 02:16:08
|
Revision: 696 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=696&view=rev Author: tonytacker Date: 2008-03-08 18:16:01 -0800 (Sat, 08 Mar 2008) Log Message: ----------- add an example tree in new window for tests Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-08 05:23:20 UTC (rev 695) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-09 02:16:01 UTC (rev 696) @@ -36,7 +36,7 @@ private static final long serialVersionUID = 1643304576470046636L; - private JButton runButton, stopButton; + private JButton runButton, stopButton, treeButton; private JTextArea infoArea; private Config config; @@ -67,11 +67,13 @@ runButton = new JButton("Run"); runButton.addActionListener(this); + showPanel.add(runButton); stopButton = new JButton("Stop"); stopButton.addActionListener(this); - - showPanel.add(runButton); showPanel.add(stopButton); + treeButton = new JButton("Tree"); + treeButton.addActionListener(this); + showPanel.add(treeButton); infoPanel.setLayout(gridbag); constraints.anchor = GridBagConstraints.WEST; @@ -149,6 +151,10 @@ if (e.getSource() == stopButton && config.getLearningAlgorithm() != null) { thread.exit(); } + // tree + if (e.getSource() == treeButton) { + TreeWindow a = new TreeWindow(config); + } } /** Added: trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java 2008-03-09 02:16:01 UTC (rev 696) @@ -0,0 +1,65 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +import javax.swing.*; +import javax.swing.tree.*; + +/** + * TreeWindow + * + * @author Tilo Hielscher + */ +public class TreeWindow extends JFrame { + + private static final long serialVersionUID = -5807192061389763835L; + + @SuppressWarnings("unused") + private Config config; + + public TreeWindow(Config config) { + this.config = config; + this.setTitle("DL-Learner Tree"); + this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); + this.setLocationByPlatform(true); + this.setSize(300, 400); + + // set icon + setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage( + this.getClass().getResource("icon.gif"))); + + // tree + DefaultMutableTreeNode root = new DefaultMutableTreeNode( "root" ); + for ( int knot = 0; knot < 4; knot++ ) + { + DefaultMutableTreeNode node = new DefaultMutableTreeNode( "knot " + knot ); + root.add( node ); + for ( int leaf = 1; leaf < 4; leaf++ ) + node.add( new DefaultMutableTreeNode("leaf " + (knot*3+leaf )) ); + } + JTree tree = new JTree( root ); + this.add( new JScrollPane( tree ) ); + + this.setVisible(true); + } + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-09 17:49:19
|
Revision: 698 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=698&view=rev Author: tonytacker Date: 2008-03-09 10:49:11 -0700 (Sun, 09 Mar 2008) Log Message: ----------- removed set-button from checkBoxList (special layout for WidgetPanelStringSet) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java Modified: trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-03-09 11:49:21 UTC (rev 697) +++ trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-03-09 17:49:11 UTC (rev 698) @@ -20,7 +20,8 @@ package org.dllearner.gui; import javax.swing.*; - +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.BorderLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; @@ -33,17 +34,19 @@ * * @author Tilo Hielscher */ -public class CheckBoxList extends JPanel { +public class CheckBoxList extends JPanel implements ActionListener { private static final long serialVersionUID = -7119007550662195455L; private JPanel checkBoxPanel = new JPanel(); private LinkedList<JCheckBox> list = new LinkedList<JCheckBox>(); private GridBagLayout gridbag = new GridBagLayout(); private GridBagConstraints constraints = new GridBagConstraints(); + private WidgetPanelStringSet panel; /** * Make a JPanel with GridBagLayout. */ - public CheckBoxList() { + public CheckBoxList(WidgetPanelStringSet panel) { + this.panel = panel; checkBoxPanel.setLayout(gridbag); add(checkBoxPanel, BorderLayout.CENTER); constraints.anchor = GridBagConstraints.WEST; @@ -57,7 +60,9 @@ * will add to list. */ public void add(String label) { - list.add(new JCheckBox(label)); + JCheckBox chkBox = new JCheckBox(label); + list.add(chkBox); + chkBox.addActionListener(this); update(); } @@ -113,4 +118,8 @@ gbc.weightx = wx; gbc.weighty = wy; } + + public void actionPerformed(ActionEvent e) { + panel.specialSet(); + } } \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-09 11:49:21 UTC (rev 697) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-09 17:49:11 UTC (rev 698) @@ -153,6 +153,7 @@ } // tree if (e.getSource() == treeButton) { + @SuppressWarnings("unused") TreeWindow a = new TreeWindow(config); } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-03-09 11:49:21 UTC (rev 697) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java 2008-03-09 17:49:11 UTC (rev 698) @@ -79,8 +79,7 @@ private JList stringList = new JList(); private DefaultListModel listModel = new DefaultListModel(); - private JButton setButton = new JButton("set"); - private CheckBoxList cBL = new CheckBoxList(); + private CheckBoxList cBL = new CheckBoxList(this); public WidgetPanelStringSet(Config config, Component component, Component oldComponent, Class<? extends Component> componentOption, ConfigOption<?> configOption) { @@ -100,7 +99,6 @@ addButton.addActionListener(this); removeButton.addActionListener(this); clearButton.addActionListener(this); - setButton.addActionListener(this); } public void actionPerformed(ActionEvent e) { @@ -132,15 +130,17 @@ // set entry value = exampleSet; setEntry(); - } else { - // SPECIAL LAYOUT - // setButton - if (e.getSource() == setButton) { - value = cBL.getSelections(); - setEntry(); - } } + } + /** + * Use this, to set entry for layout 2. + */ + public void specialSet() { + if (isSpecial()) { + this.value = cBL.getSelections(); + setEntry(); + } } @Override @@ -216,10 +216,6 @@ buildConstraints(constraints, 0, 1, 1, 1, 100, 100); gridbag.setConstraints(cBL, constraints); widgetPanel.add(cBL, constraints); - // setButton - buildConstraints(constraints, 1, 1, 1, 1, 100, 100); - gridbag.setConstraints(setButton, constraints); - widgetPanel.add(setButton, constraints); // DEFINE LIST // positiveExamples or negativeExamples if (configOption.getName().equalsIgnoreCase("positiveExamples") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-12 23:15:37
|
Revision: 706 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=706&view=rev Author: tonytacker Date: 2008-03-12 16:15:31 -0700 (Wed, 12 Mar 2008) Log Message: ----------- I reduced thread priorities to ensure main-thread (GUI) is fastest inside. All others have some lower levels. Tree-Window works now, but only 1st level of it. Means you cann't look at 2nd level of tree. It will be later integrated. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java Modified: trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-03-12 19:25:45 UTC (rev 705) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-03-12 23:15:31 UTC (rev 706) @@ -40,6 +40,7 @@ public void run() { if (config.getLearningAlgorithm() != null) { config.setThreadIsRunning(true); + this.setPriority(Thread.MIN_PRIORITY); config.getLearningAlgorithm().start(); config.setThreadIsRunning(false); } Modified: trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java 2008-03-12 19:25:45 UTC (rev 705) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java 2008-03-12 23:15:31 UTC (rev 706) @@ -40,6 +40,7 @@ */ @Override public void run() { + this.setPriority(4); if (config.getThreadIsRunning()) { try { sleep(1000); // sleep 1 second Modified: trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java 2008-03-12 19:25:45 UTC (rev 705) +++ trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java 2008-03-12 23:15:31 UTC (rev 706) @@ -22,6 +22,7 @@ import javax.swing.*; import javax.swing.tree.*; +import org.dllearner.algorithms.refexamples.*; /** * TreeWindow @@ -46,7 +47,7 @@ setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage( this.getClass().getResource("icon.gif"))); - // tree + // test example tree DefaultMutableTreeNode exampleRoot = new DefaultMutableTreeNode("root"); for (int knot = 0; knot < 4; knot++) { DefaultMutableTreeNode node = new DefaultMutableTreeNode("knot " + knot); @@ -54,23 +55,35 @@ for (int leaf = 1; leaf < 4; leaf++) node.add(new DefaultMutableTreeNode("leaf " + (knot * 3 + leaf))); } - + // tree model EBNodeTreeModel root = null; - if (config.getLearningAlgorithm() != null) { - //ExampleBasedNode rootNode = config.getLearningAlgorithm().getStartNode(); - //root = new EBNodeTreeModel(rootNode); - } - - // show tree - if (root != null) { - //JTree tree = new JTree(root); - //this.add(new JScrollPane(tree)); - } - else { + // if (config.getLearningAlgorithm() != null) { + if (config.getLearningAlgorithm() instanceof ExampleBasedROLComponent) { + ExampleBasedROLComponent ebrol = (ExampleBasedROLComponent) config + .getLearningAlgorithm(); + ExampleBasedNode rootNode = ebrol.getStartNode(); + root = new EBNodeTreeModel(rootNode); + + // show tree + if (root != null) { + //System.out.println("TEST: " + root.getChildCount(rootNode)); + for (int i = 0; i < root.getChildCount(rootNode); i++) { + // Object node = root.getChild(rootNode, i); + + root.getChild(rootNode, i); + //System.out.println("TEST: " + root.getChild(rootNode, i)); + } + JTree tree = new JTree(root); + this.add(new JScrollPane(tree)); + } + } else { JTree tree = new JTree(exampleRoot); this.add(new JScrollPane(tree)); } + + // } + this.repaint(); this.setVisible(true); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-14 22:58:38
|
Revision: 712 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=712&view=rev Author: tonytacker Date: 2008-03-14 15:58:35 -0700 (Fri, 14 Mar 2008) Log Message: ----------- fixes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java 2008-03-14 19:53:45 UTC (rev 711) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java 2008-03-14 22:58:35 UTC (rev 712) @@ -177,7 +177,6 @@ * @return a string to write */ public String getTypeForFile(Class<?> componentClass) { - System.out.println("getTypeForFile: " + componentClass); // reasoner if (DIGReasoner.class == componentClass) return ("dig"); Modified: trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java 2008-03-14 19:53:45 UTC (rev 711) +++ trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java 2008-03-14 22:58:35 UTC (rev 712) @@ -21,7 +21,6 @@ */ import javax.swing.*; -import javax.swing.tree.*; import org.dllearner.algorithms.refexamples.*; /** @@ -47,38 +46,12 @@ setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage( this.getClass().getResource("icon.gif"))); - // test example tree - DefaultMutableTreeNode exampleRoot = new DefaultMutableTreeNode("root"); - for (int knot = 0; knot < 4; knot++) { - DefaultMutableTreeNode node = new DefaultMutableTreeNode("knot " + knot); - exampleRoot.add(node); - for (int leaf = 1; leaf < 4; leaf++) - node.add(new DefaultMutableTreeNode("leaf " + (knot * 3 + leaf))); - } - // tree model - EBNodeTreeModel root = null; - // if (config.getLearningAlgorithm() != null) { if (config.getLearningAlgorithm() instanceof ExampleBasedROLComponent) { ExampleBasedROLComponent ebrol = (ExampleBasedROLComponent) config .getLearningAlgorithm(); ExampleBasedNode rootNode = ebrol.getStartNode(); - root = new EBNodeTreeModel(rootNode); - - // show tree - if (root != null) { - //System.out.println("TEST: " + root.getChildCount(rootNode)); - for (int i = 0; i < root.getChildCount(rootNode); i++) { - // Object node = root.getChild(rootNode, i); - - root.getChild(rootNode, i); - //System.out.println("TEST: " + root.getChild(rootNode, i)); - } - JTree tree = new JTree(root); - this.add(new JScrollPane(tree)); - } - } else { - JTree tree = new JTree(exampleRoot); + JTree tree = new JTree(new EBNodeTreeModel(rootNode)); this.add(new JScrollPane(tree)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-03-23 20:11:39
|
Revision: 721 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=721&view=rev Author: tonytacker Date: 2008-03-23 13:11:36 -0700 (Sun, 23 Mar 2008) Log Message: ----------- some changes for tree Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-20 20:16:04 UTC (rev 720) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-03-23 20:11:36 UTC (rev 721) @@ -266,7 +266,7 @@ * * @param a * @param b - * @return + * @return string that shows percent */ public String Percent(Long a, Long b) { if (a != null && b != null) { Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-03-20 20:16:04 UTC (rev 720) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-03-23 20:11:36 UTC (rev 721) @@ -70,8 +70,9 @@ this.setSize(800, 600); // set icon - setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage( - this.getClass().getResource("icon.gif"))); + if (this.getClass().getResource("icon.gif") != null) + setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage( + this.getClass().getResource("icon.gif"))); tab0 = new KnowledgeSourcePanel(config, this); tab1 = new ReasonerPanel(config, this); Modified: trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java 2008-03-20 20:16:04 UTC (rev 720) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadStatistics.java 2008-03-23 20:11:36 UTC (rev 721) @@ -40,7 +40,7 @@ */ @Override public void run() { - this.setPriority(4); + //this.setPriority(4); if (config.getThreadIsRunning()) { try { sleep(1000); // sleep 1 second Modified: trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java 2008-03-20 20:16:04 UTC (rev 720) +++ trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java 2008-03-23 20:11:36 UTC (rev 721) @@ -21,37 +21,56 @@ */ import javax.swing.*; +import javax.swing.event.TreeExpansionEvent; +import javax.swing.event.TreeExpansionListener; import org.dllearner.algorithms.refexamples.*; + /** * TreeWindow * * @author Tilo Hielscher */ -public class TreeWindow extends JFrame { +public class TreeWindow extends JFrame implements TreeExpansionListener { private static final long serialVersionUID = -5807192061389763835L; @SuppressWarnings("unused") private Config config; - + private EBNodeTreeModel ebNodeModel; + private ExampleBasedNode rootNode; + public TreeWindow(Config config) { this.config = config; this.setTitle("DL-Learner Tree"); this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); this.setLocationByPlatform(true); - this.setSize(300, 400); + this.setSize(640, 300); // set icon - setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage( - this.getClass().getResource("icon.gif"))); + if (this.getClass().getResource("icon.gif") != null) + setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage( + this.getClass().getResource("icon.gif"))); // tree model if (config.getLearningAlgorithm() instanceof ExampleBasedROLComponent) { ExampleBasedROLComponent ebrol = (ExampleBasedROLComponent) config .getLearningAlgorithm(); - ExampleBasedNode rootNode = ebrol.getStartNode(); - JTree tree = new JTree(new EBNodeTreeModel(rootNode)); + this.rootNode = ebrol.getStartNode(); + + System.out.println("childs1: " + rootNode.getChildren()); + + this.ebNodeModel = new EBNodeTreeModel(rootNode); + + // childrens to treeModel + Object first = ebNodeModel.getChild(rootNode, 0); + System.out.println("getIndexOfChild: " + ebNodeModel.getIndexOfChild(rootNode, first)); + + //System.out.println("childs2: " + ebNodeModel.getChildren((ExampleBasedNode) first)); + + + JTree tree = new JTree(ebNodeModel); + tree.addTreeExpansionListener(this); this.add(new JScrollPane(tree)); } @@ -60,4 +79,30 @@ this.setVisible(true); } + /* (non-Javadoc) + * @see javax.swing.event.TreeExpansionListener#treeCollapsed(javax.swing.event.TreeExpansionEvent) + */ + @Override + public void treeCollapsed(TreeExpansionEvent event) { + System.out.println("collapsed"); + } + + /* (non-Javadoc) + * @see javax.swing.event.TreeExpansionListener#treeExpanded(javax.swing.event.TreeExpansionEvent) + */ + @Override + public void treeExpanded(TreeExpansionEvent event) { + System.out.println("expanded: " + event.getPath()); + //Object path = event.getPath(); + + //System.out.println("childcount: " + ebNodeModel.getChildCount(path)); + + + //ebNodeModel.getChild(event.getSource(), 0); + System.out.println("getIndexOfChild: " + ebNodeModel.getIndexOfChild(rootNode, event.getPath())); + + + ebNodeModel.getChild(rootNode, 9); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-04-07 02:15:19
|
Revision: 766 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=766&view=rev Author: tonytacker Date: 2008-04-06 19:15:16 -0700 (Sun, 06 Apr 2008) Log Message: ----------- automatic init and reset while loading other config Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-04-07 00:18:05 UTC (rev 765) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-04-07 02:15:16 UTC (rev 766) @@ -315,4 +315,39 @@ return System.nanoTime() - algorithmRunStartTime; return null; } + + /** + * It is necessary for init LearningProblem. + * + * @return true, if necessary example was set otherwise false + */ + public Boolean isSetExample() { + if (lp.getClass().getSimpleName().equals("PosOnlyDefinitionLP")) { + if (cm.getConfigOptionValue(lp, "positiveExamples") != null) + return true; + } else if (cm.getConfigOptionValue(lp, "positiveExamples") != null + && cm.getConfigOptionValue(lp, "negativeExamples") != null) + return true; + return false; + } + + /** + * reInit ComponentManager. + */ + public void reInit() { + cm = ComponentManager.getInstance(); + source = null; + oldSource = null; + reasoner = null; + oldReasoner = null; + rs = null; + lp = null; + oldLearningProblem = null; + la = null; + oldLearningAlgorithm = null; + isInit = new boolean[4]; + threadIsRunning = false; + algorithmRunStartTime = null; + algorithmRunStopTime = null; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-04-07 00:18:05 UTC (rev 765) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-04-07 02:15:16 UTC (rev 766) @@ -74,6 +74,7 @@ * parse file */ public void startParser() { + config.reInit(); // new ComponentManager if (this.file.exists()) { ConfParser parser = ConfParser.parseFile(file); // create a mapping between components and prefixes in the conf file Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-04-07 00:18:05 UTC (rev 765) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-04-07 02:15:16 UTC (rev 766) @@ -46,6 +46,7 @@ private StartGUI startGUI; private JButton initButton; private JButton setButton; + private JButton clearButton; private String[] kbBoxItems = {}; private JComboBox cb = new JComboBox(kbBoxItems); private JPanel choosePanel = new JPanel(); @@ -63,6 +64,8 @@ setButton = new JButton("Set"); setButton.addActionListener(this); + setButton = new JButton("Clear All"); + setButton.addActionListener(this); initButton = new JButton("Init KnowledgeSource"); initButton.addActionListener(this); initButton.setEnabled(true); @@ -102,8 +105,13 @@ setSource(); } - if (e.getSource() == initButton) + if (e.getSource() == initButton) { init(); + } + + if (e.getSource() == clearButton) { + config.reInit(); + } } /** Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-04-07 00:18:05 UTC (rev 765) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-04-07 02:15:16 UTC (rev 766) @@ -118,9 +118,10 @@ /** * after this, next tab can be used */ - private void init() { + public void init() { setLearningProblem(); - if (config.getReasoner() != null && config.getLearningProblem() != null) { + if (config.getReasoner() != null && config.getLearningProblem() != null + && config.isSetExample()) { try { config.getLearningProblem().init(); config.setInitLearningProblem(true); Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-04-07 00:18:05 UTC (rev 765) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-04-07 02:15:16 UTC (rev 766) @@ -39,6 +39,7 @@ private JButton runButton, stopButton, treeButton; private JTextArea infoArea; private Config config; + private StartGUI startGUI; private ThreadRun thread; @@ -60,10 +61,11 @@ private JLabel[] time = new JLabel[5]; private JLabel[] percent = new JLabel[5]; - RunPanel(Config config) { + RunPanel(Config config, StartGUI startGUI) { super(new BorderLayout()); this.config = config; + this.startGUI = startGUI; runButton = new JButton("Run"); runButton.addActionListener(this); @@ -141,6 +143,7 @@ // start if (e.getSource() == runButton && config.getLearningAlgorithm() != null && !config.getThreadIsRunning()) { + startGUI.init(); thread = new ThreadRun(config); config.getReasoningService().resetStatistics(); thread.start(); Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-04-07 00:18:05 UTC (rev 765) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-04-07 02:15:16 UTC (rev 766) @@ -78,7 +78,7 @@ tab1 = new ReasonerPanel(config, this); tab2 = new LearningProblemPanel(config, this); tab3 = new LearningAlgorithmPanel(config, this); - tab4 = new RunPanel(config); + tab4 = new RunPanel(config, this); tabPane.addTab("Knowledge Source", tab0); tabPane.addTab("Reasoner", tab1); tabPane.addTab("Learning Problem", tab2); @@ -100,12 +100,19 @@ tabPane.addChangeListener(new ChangeListener() { // This method is called whenever the selected tab changes public void stateChanged(ChangeEvent evt) { - - updateTabColors(); + init(); } }); } + public void init() { + tab0.init(); + tab1.init(); + tab2.init(); + tab3.init(); + updateTabColors(); + } + public static void main(String[] args) { // create GUI logger SimpleLayout layout = new SimpleLayout(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |