From: <ton...@us...> - 2008-02-01 07:58:33
|
Revision: 482 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=482&view=rev Author: tonytacker Date: 2008-01-31 23:58:29 -0800 (Thu, 31 Jan 2008) Log Message: ----------- run algorithm in extra thread to stop if you want Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-01 06:38:03 UTC (rev 481) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-02-01 07:58:29 UTC (rev 482) @@ -38,10 +38,13 @@ private static final long serialVersionUID = 1643304576470046636L; - private JButton runButton; + private JButton runButton, stopButton; private JTextArea infoArea; private Config config; + + private ThreadRun thread; + RunPanel(Config config) { super(new BorderLayout()); @@ -49,12 +52,15 @@ runButton = new JButton("Run"); runButton.addActionListener(this); - + stopButton = new JButton("Stop"); + stopButton.addActionListener(this); + infoArea = new JTextArea(20, 50); JScrollPane infoScroll = new JScrollPane(infoArea); JPanel showPanel = new JPanel(); showPanel.add(runButton); + showPanel.add(stopButton); JPanel infoPanel = new JPanel(); infoPanel.add(infoScroll); @@ -64,9 +70,17 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == runButton && config.getLearningAlgorithm() != null) { - config.getLearningAlgorithm().start(); - Concept solution = config.getLearningAlgorithm().getBestSolution(); - infoArea.setText(solution.toString()); + //config.getLearningAlgorithm().start(); + //thread = new ThreadRun(config); + thread = new ThreadRun(config); + thread.start(); + //Concept solution = config.getLearningAlgorithm().getBestSolution(); + //infoArea.setText(solution.toString()); } + if (e.getSource() == stopButton && config.getLearningAlgorithm() != null) { + //config.getLearningAlgorithm().stop(); + thread.exit(); + } } + } Added: trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java 2008-02-01 07:58:29 UTC (rev 482) @@ -0,0 +1,46 @@ +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/>. + * + */ + +/** + * threadRun + * + * @author Tilo Hielscher + */ +public class ThreadRun extends Thread { + + Config config; + + public ThreadRun(Config config) { + this.config = config; + } + + // method to start thread + public void run() { + if (config.getLearningAlgorithm() != null) + config.getLearningAlgorithm().start(); + } + + public void exit() { + if (config.getLearningAlgorithm() != null) + config.getLearningAlgorithm().stop(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |