From: cmzmasek Date: Mon, 21 May 2012 03:06:59 +0000 (+0000) Subject: in progress X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=48d8b16f44043d4bfe721af7be48e15b31fb3f18;p=jalview.git in progress --- diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index 1913555..551c07c 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -677,6 +677,7 @@ public final class MainFrameApplication extends MainFrame { } void buildPhylogeneticInferenceMenu() { + final InferenceManager inference_manager = InferenceManager.getInstance(); _inference_menu = MainFrame.createMenu( "Inference", getConfiguration() ); _inference_menu .add( _inference_from_msa_item = new JMenuItem( "From Multiple Sequence Alignment..." ) ); diff --git a/forester/java/src/org/forester/archaeopteryx/tools/ProcessPool.java b/forester/java/src/org/forester/archaeopteryx/tools/ProcessPool.java new file mode 100644 index 0000000..0c4ed99 --- /dev/null +++ b/forester/java/src/org/forester/archaeopteryx/tools/ProcessPool.java @@ -0,0 +1,82 @@ +// $Id: +// FORESTER -- software libraries and applications +// for evolutionary biology research and applications. +// +// Copyright (C) 2008-2012 Christian M. Zmasek +// Copyright (C) 2008-2012 Sanford Burnham Medical Research Institute +// All rights reserved +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +// +// Contact: phylosoft @ gmail . com +// WWW: www.phylosoft.org/forester + +package org.forester.archaeopteryx.tools; + +import java.util.ArrayList; +import java.util.List; + +public class ProcessPool { + + final static private ArrayList _processes = new ArrayList(); + + public synchronized ProcessRunning getProcessByIndex( final int i ) { + return getProcesses().get( i ); + } + + public synchronized int size() { + return getProcesses().size(); + } + + public synchronized ProcessRunning getProcessById( final int id ) { + for( final ProcessRunning p : getProcesses() ) { + if ( p.getId() == id ) { + return p; + } + } + return null; + } + + public synchronized int addProcess( final String name ) { + final ProcessRunning p = ProcessRunning.createInstance( name ); + final int id = p.getId(); + if ( getProcessById( id ) != null ) { + throw new IllegalStateException( "process with id " + id + "already exists" ); + } + getProcesses().add( p ); + return id; + } + + public synchronized boolean removeProcess( final int id ) { + final int i = getProcessIndexById( id ); + if ( i >= 0 ) { + getProcesses().remove( i ); + return true; + } + return false; + } + + private synchronized int getProcessIndexById( final int id ) { + final ProcessRunning p = getProcessById( id ); + if ( p != null ) { + return p.getId(); + } + return -1; + } + + private synchronized List getProcesses() { + return _processes; + } +} diff --git a/forester/java/src/org/forester/archaeopteryx/tools/ProcessRunning.java b/forester/java/src/org/forester/archaeopteryx/tools/ProcessRunning.java new file mode 100644 index 0000000..4630f28 --- /dev/null +++ b/forester/java/src/org/forester/archaeopteryx/tools/ProcessRunning.java @@ -0,0 +1,66 @@ +// $Id: +// FORESTER -- software libraries and applications +// for evolutionary biology research and applications. +// +// Copyright (C) 2008-2012 Christian M. Zmasek +// Copyright (C) 2008-2012 Sanford Burnham Medical Research Institute +// All rights reserved +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +// +// Contact: phylosoft @ gmail . com +// WWW: www.phylosoft.org/forester + +package org.forester.archaeopteryx.tools; + +import java.text.SimpleDateFormat; +import java.util.Calendar; + +final class ProcessRunning { + + private static int count = 0; + final private int _id; + final private String _name; + final private String _start; + + int getId() { + return _id; + } + + String getName() { + return _name; + } + + String getStart() { + return _start; + } + + public String toString() { + return getName() + " [id=" + getId() + "] [start=" + getStart() + "]"; + } + + synchronized static ProcessRunning createInstance( final String name ) { + final Calendar cal = Calendar.getInstance(); + final SimpleDateFormat sdf = new SimpleDateFormat( "HH:mm:ss" ); + return new ProcessRunning( count++, name, sdf.format( cal.getTime() ) ); + } + + private ProcessRunning( final int id, final String name, final String start ) { + _id = id; + _name = name; + _start = start; + } + +}