Added 3 events to the InteractiveActionThread class

This commit is contained in:
Andras Fuchs 2020-02-04 22:14:56 +01:00
parent 038f8a8626
commit 085ca90a94
3 changed files with 30 additions and 0 deletions

View File

@ -53,6 +53,9 @@ public class BatchAutorouterThread extends InteractiveActionThread
protected void thread_action()
{
for (ThreadActionListener hl : this.listeners)
hl.autorouterStarted();
FRLogger.traceEntry("BatchAutorouterThread.thread_action()");
try
@ -133,6 +136,16 @@ public class BatchAutorouterThread extends InteractiveActionThread
}
FRLogger.traceExit("BatchAutorouterThread.thread_action()");
for (ThreadActionListener hl : this.listeners)
{
if (this.is_stop_requested()) {
hl.autorouterAborted();
}
else {
hl.autorouterFinished();
}
}
}
public void draw(java.awt.Graphics p_graphics)

View File

@ -23,6 +23,10 @@
*/
package eu.mihosoft.freerouting.interactive;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
/**
* Used for running an eu.mihosoft.freerouting.interactive action in a seperate Thread,
* that can be stopped by the user.
@ -31,6 +35,11 @@ package eu.mihosoft.freerouting.interactive;
*/
public abstract class InteractiveActionThread extends Thread implements eu.mihosoft.freerouting.datastructures.Stoppable
{
protected List<ThreadActionListener> listeners = new ArrayList<ThreadActionListener>();
public void addListener(ThreadActionListener toAdd) {
listeners.add(toAdd);
}
public static InteractiveActionThread get_autoroute_instance(BoardHandling p_board_handling)
{
@ -234,3 +243,4 @@ public abstract class InteractiveActionThread extends Thread implements eu.mihos
private final java.io.InputStream input_stream;
}
}

View File

@ -0,0 +1,7 @@
package eu.mihosoft.freerouting.interactive;
public interface ThreadActionListener {
void autorouterStarted();
void autorouterAborted();
void autorouterFinished();
}