Package gov.nih.mipav.model.algorithms
Class AlgorithmBase
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
- Direct Known Subclasses:
AgglomerativeInformationBottleneck
,Algorithm4DImageCalculator
,AlgorithmActiveContoursWithoutEdges
,AlgorithmAdaptiveKuwaharaFilter
,AlgorithmAddMargins
,AlgorithmAGCIE
,AlgorithmAGVF
,AlgorithmAHE
,AlgorithmAHElocal
,AlgorithmAINDANE
,AlgorithmAnisotropicDiffusion
,AlgorithmAntigradient2
,AlgorithmAnyTwoImagesSNR
,AlgorithmArcLength
,AlgorithmASM
,AlgorithmAutoCorrelation
,AlgorithmAutoCovariance
,AlgorithmAutoSeedWatershed
,AlgorithmBarrelDistortion
,AlgorithmBilateralFilter
,AlgorithmBoundaryAttenuation
,AlgorithmBoxCount
,AlgorithmBrainExtractor
,AlgorithmBrainSurfaceExtractor
,AlgorithmBRISK
,AlgorithmBSmooth
,AlgorithmBSnake
,AlgorithmBSpline
,AlgorithmBSplineControlPointImageFilter
,AlgorithmCannyEdgeDetection
,AlgorithmCenterOfMass
,AlgorithmCenterOfMassRGB
,AlgorithmChangeType
,AlgorithmCircleGeneration
,AlgorithmCircleToRectangle
,AlgorithmCircularSectorToRectangle
,AlgorithmCoherenceEnhancingDiffusion
,AlgorithmColocalizationEM
,AlgorithmColocalizationRegression
,AlgorithmColorEdge
,AlgorithmColorSaturation
,AlgorithmComplexConcat
,AlgorithmComplexToReal
,AlgorithmConcat
,AlgorithmConcatMult
,AlgorithmConstELSUNCOpt3D
,AlgorithmConstPowellOptBase
,AlgorithmConstrainedELSUNCOAR3D
,AlgorithmConstrainedOAR3D
,AlgorithmContrastEnhancementUsingExposureFusion
,AlgorithmConvergenceField
,AlgorithmConvert3Dto4D
,AlgorithmConvert4Dto3D
,AlgorithmConvolver
,AlgorithmCorrectSpacing
,AlgorithmCrop
,AlgorithmCropTilted
,AlgorithmCubicLagrangian
,AlgorithmCumulativeHistogram
,AlgorithmCyclicPermutation
,AlgorithmDConvolver
,AlgorithmDemonsLite
,AlgorithmDEMRI3
,AlgorithmDicomOrder
,AlgorithmDICOMtoAVI
,AlgorithmDistanceFilter
,AlgorithmDTI2EGFA
,AlgorithmDTIColorDisplay
,AlgorithmDTIColorDisplay
,AlgorithmDTICreateListFile
,AlgorithmDTITract
,AlgorithmDualContourSearch
,AlgorithmDWI2DTI
,AlgorithmEdgeDetection3D
,AlgorithmEdgeLaplacian
,AlgorithmEdgeLaplacianSep
,AlgorithmEdgeNMSuppression
,AlgorithmEdgePreservingSmoothing
,AlgorithmEfficientWatershed
,AlgorithmEllipseGeneration
,AlgorithmEllipseToCircle
,AlgorithmEllipseToRectangle
,AlgorithmEllipticFilter
,AlgorithmEllipticFourierDescriptors
,AlgorithmELSUNCOpt2D
,AlgorithmELSUNCOpt3D
,AlgorithmEmbeddedConfidenceEdgeDetection
,AlgorithmEntropicEdgeDetection
,AlgorithmEntropyMinimization
,AlgorithmEvaluateMaskSegmentation
,AlgorithmEvaluateSegmentation
,AlgorithmExtractSlices
,AlgorithmExtractSlicesVolumes
,AlgorithmExtractSurface
,AlgorithmExtractSurfaceCubes
,AlgorithmFaceAnonymizer
,AlgorithmFaceAnonymizerBET
,AlgorithmFacetModel
,AlgorithmFastMarching
,AlgorithmFastMarching
,AlgorithmFFT
,AlgorithmFFT2
,AlgorithmFIREEdgeExtraction
,AlgorithmFlip
,AlgorithmFloodFill
,AlgorithmFRAP
,AlgorithmFrequencyFilter
,AlgorithmFrequencyFilterColor
,AlgorithmFRETAcceptorPhotobleach
,AlgorithmFRETBleedThrough
,AlgorithmFRETEfficiency
,AlgorithmFuzzMinDeAndChatterji
,AlgorithmFuzzyCMeans
,AlgorithmFuzzyConnectednessSegmentation
,AlgorithmFuzzyMinimization
,AlgorithmGaussianBlur
,AlgorithmGaussianBlurSep
,AlgorithmGaussianMixtureModelEM
,AlgorithmGenerateIsolines
,AlgorithmGradientInverseWeightedSmoothing
,AlgorithmGradientMagnitude
,AlgorithmGradientMagnitudeSep
,AlgorithmGraphBasedSegmentation
,AlgorithmGrayScaleMorphology25D
,AlgorithmGrayScaleMorphology2D
,AlgorithmGrayScaleMorphology3D
,AlgorithmGuidedFilter
,AlgorithmGVF
,AlgorithmHaralickTexture
,AlgorithmHarrisCornerDetector
,AlgorithmHarrisLaplace
,AlgorithmHeightFunction
,AlgorithmHepticLagrangian
,AlgorithmHessian
,AlgorithmHilbertTransform
,AlgorithmHillClimbingWatershed
,AlgorithmHistogram
,AlgorithmHistogram2Dim
,AlgorithmHistogramMatch
,AlgorithmHistogramSliceMatch
,AlgorithmHMRF_EM
,AlgorithmHoughCardioid
,AlgorithmHoughCircle
,AlgorithmHoughEllipse
,AlgorithmHoughHyperbola
,AlgorithmHoughLine
,AlgorithmHoughParabola
,AlgorithmHurstIndex
,AlgorithmIAGCWD
,AlgorithmIHN3Correction
,AlgorithmImageCalculator
,AlgorithmImageHessian
,AlgorithmImageMath
,AlgorithmIndependentComponents
,AlgorithmInsertSlice
,AlgorithmInsertVolume
,AlgorithmIsophoteCurvature
,AlgorithmIteratedBlindDeconvolution
,AlgorithmKernelRegression
,AlgorithmKMeans
,AlgorithmLaplacian
,AlgorithmLapMedianess
,AlgorithmLawsTexture
,AlgorithmLearnFromFailure64
,AlgorithmLearnFromFailure64Knees
,AlgorithmLevelSet
,AlgorithmLevelSetDiffusion
,AlgorithmLLE
,AlgorithmLocalNormalization
,AlgorithmLocalVariance
,AlgorithmLogSlopeMapping
,AlgorithmLowerCompletion
,AlgorithmLuminanceAdaptation
,AlgorithmMarkovSegment
,AlgorithmMarkovSmooth
,AlgorithmMask
,AlgorithmMatchForReference
,AlgorithmMatchImages
,AlgorithmMaximumIntensityProjection
,AlgorithmMaximumLikelihoodIteratedBlindDeconvolution
,AlgorithmMean
,AlgorithmMeanShiftClustering
,AlgorithmMeanShiftSegmentation
,AlgorithmMedian
,AlgorithmMidsagittal
,AlgorithmMinimumPerimeterPolygon
,AlgorithmMixGaussEM
,AlgorithmMode
,AlgorithmMorphologicalFilter
,AlgorithmMorphology25D
,AlgorithmMorphology2D
,AlgorithmMorphology3D
,AlgorithmMosaicToSlices
,AlgorithmMRIShadingCorrection
,AlgorithmMSER
,AlgorithmMSpectralFuzzyCMeans
,AlgorithmMultiExponentialFitting
,AlgorithmN4MRIBiasFieldCorrectionFilter
,AlgorithmNearlyCircleToCircle
,AlgorithmNetworkSnake
,AlgorithmNLNoiseReduction
,AlgorithmNMSuppression
,AlgorithmNoise
,AlgorithmNonlocalMeansFilter
,AlgorithmNonMaxSuppts
,AlgorithmNonparametricSegmentation
,AlgorithmObjectExtractor
,AlgorithmPbBoundaryDetection
,AlgorithmPhaseCongruency
,AlgorithmPointArea
,AlgorithmPointSetToImageFilter
,AlgorithmPowellOptBase
,AlgorithmPowerWatershed
,AlgorithmPrincipalComponents
,AlgorithmProstateBoundaryExt
,AlgorithmProstateBoundaryFeature2D
,AlgorithmProstateFeatures
,AlgorithmProstateFeatures2D
,AlgorithmProstateFeaturesSaveAutoTrain
,AlgorithmQuantify
,AlgorithmQuantifyMask
,AlgorithmQuinticLagrangian
,AlgorithmRandSliceOrder
,AlgorithmRegBSpline
,AlgorithmRegChamfer
,AlgorithmRegELSUNCOAR25D
,AlgorithmRegELSUNCOAR2D
,AlgorithmRegELSUNCOAR35D
,AlgorithmRegELSUNCOAR3D
,AlgorithmRegionGrow
,AlgorithmRegionMergingViaBoundaryMelting
,AlgorithmRegionsFromPartialBorders
,AlgorithmRegLeastSquares
,AlgorithmRegOAR25D2
,AlgorithmRegOAR2D
,AlgorithmRegOAR35D
,AlgorithmRegOAR3D
,AlgorithmRegPatientPos
,AlgorithmRegularizedIsotropicDiffusion
,AlgorithmRegValidation
,AlgorithmRegVOILandmark
,AlgorithmRemoveSlices
,AlgorithmRemoveTSlices
,AlgorithmReplaceBlankSlicesWithAverages
,AlgorithmReplaceRemovedSlices
,AlgorithmReplaceSlice
,AlgorithmReplaceValue
,AlgorithmReslice
,AlgorithmRGBConcat
,AlgorithmRGBtoGray
,AlgorithmRGBtoGrays
,AlgorithmRGBtoHSB
,AlgorithmRiceWaveletTools
,AlgorithmRotate
,AlgorithmRuleBasedContrastEnhancement
,AlgorithmScaleSaliency
,AlgorithmSCDSegmentation
,AlgorithmSeparableConvolver
,AlgorithmSequentialScanningWatershed
,AlgorithmSFTA
,AlgorithmShortestPathWatershed
,AlgorithmSimulatedExposureFusion
,AlgorithmSingleMRIImageSNR
,AlgorithmSkullRemoval
,AlgorithmSliceAveraging
,AlgorithmSM2
,AlgorithmSnake
,AlgorithmSobel
,AlgorithmSpectralClustering
,AlgorithmSphereGeneration
,AlgorithmSplitAndMergeWatershed
,AlgorithmStandardDeviationThreshold
,AlgorithmSubsample
,AlgorithmSubset
,AlgorithmSubtractVOI
,AlgorithmSwap34
,AlgorithmSwapDims
,AlgorithmSwapSlicesVolume
,AlgorithmSWI
,AlgorithmSymmetricNearestNeighbor
,AlgorithmTalairachTransform
,AlgorithmTamuraTexture
,AlgorithmTextureAnalysis
,AlgorithmTextureSegmentation
,AlgorithmThinning2D
,AlgorithmThresholdDual
,AlgorithmThresholdDualRGB
,AlgorithmTiltCorrection
,AlgorithmTimeFitting
,AlgorithmTProcess
,AlgorithmTPSpline
,AlgorithmTranscode
,AlgorithmTransform
,AlgorithmTransformBSpline
,AlgorithmTransformVOI
,AlgorithmTrilateralFilter
,AlgorithmTwoMRIImagesSNR
,AlgorithmUnionFindComponentLabelling
,AlgorithmUnionFindWatershed
,AlgorithmUnsharpMask
,AlgorithmVesselEnhancement
,AlgorithmVOIExtraction
,AlgorithmVOIExtractionPaint
,AlgorithmVOIHausdorffDistance
,AlgorithmVOILogicalOperations
,AlgorithmVOIProps
,AlgorithmVOIShapeInterpolation
,AlgorithmVOISimplexOpt
,AlgorithmWatershed
,AlgorithmWaveletFuse
,AlgorithmWaveletThreshold
,AlgorithmWSinc
,Backpropagation
,BiorthogonalWavelets
,BlindDeblur
,BM3D
,ChirpZTransform
,ContourPlot
,CopyMoveAttackDetection
,CopyMoveAttackDetection2
,Covdet
,DBSCANClusteringSegment
,DiscreteCosineTransform
,DiscreteSineTransform
,DoublyConnectedSC
,DTIGradTableCorrectionAfterTrans
,FFTUtility
,FFTUtilityEP
,fMRIBlindDeconvolution
,GaussianMixtureModelsIncompleteSamples
,HaarTransform
,HartleyTransform
,HartleyTransform2
,HistogramOfOrientedGradients
,HornSchunk
,ImageQuality
,ImRegPOC
,InverseLaplaceTest
,JDialogLoadImage.AlgorithmLoadB
,libdt
,LIBSVM
,LightboxGenerator
,LocalIntensityOrderPattern
,LSCM
,LSQR
,MotionDetection
,MultiGuidedFilter
,MultiResolutionBilateralFilter
,NLMeans_filt2D
,NoiseLevel
,OpenCLAlgorithmBase
,OpticalFlowToolbox
,PhasePreservingDenoising
,PseudoPolarFourierTransform
,PyramidToolbox
,PyWavelets
,Quaternions
,RectangularConformalMap
,SchwarzChristoffelMapping
,SchwarzChristoffelMapping2
,SIFT
,SIFT3D
,SIFTImageSimilarity
,SlantTransform
,SpatialBroxOpticalFlow
,StochasticForests
,SVM
,SymmsIntegralMapping
,TemporalBroxOpticalFlow
,TVL1FLOW
,WalshHadamardTransform
,WalshHadamardTransform2
,WalshHadamardTransform3
public abstract class AlgorithmBase extends java.lang.Thread implements java.awt.event.ActionListener, java.awt.event.WindowListener
Base abstract class for algorithms.- Version:
- 0.1 Feburary 11, 1998
- Author:
- Matthew J. McAuliffe, Ph.D.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
completed
This flag will be set to true when the algorithm has completed.protected boolean
destFlag
Destination flag indicating if a destination (result) image is generated.protected ModelImage
destImage
Destination image.private double
elapsedTime
Elapsed time (in milliseconds) -- time it took for algorithm to run.protected boolean
image25D
If true process each image of a 3D volume independently.private javax.swing.event.EventListenerList
listenerList
A list of the ChangeListeners which are interested in the ChangeEvent.protected java.util.BitSet
mask
Mask indicating which voxels to process.protected int
maxProgressValue
Used to store the maximum value of the progress bar.protected int
minProgressValue
Used to store the minimum value of the progress bar.protected boolean
multiThreadingEnabled
Indicates if multi-threading will be used to optimize the algorithm.protected int
nthreads
The number of threads will be used to execute the algorithm if multi-threading is enabledprivate java.util.Vector<AlgorithmInterface>
objectList
Vector list of AlgorithmInterface objects.protected float
progress
Store the progress being made.protected int
progressModulus
protected float
progressStep
protected boolean
runningInSeparateThread
Should be set to true if NOT in a single thread - will NOT force a graphics update of the progress bar.protected boolean
separable
If true convolution kernels are separable.protected ModelImage
srcImage
Source image.private long
startTime
Start time (in milliseconds) to be used to compute elapsed time.protected boolean
threadStopped
Flag indicating whether or not the thread is stopped.
-
Constructor Summary
Constructors Constructor Description AlgorithmBase()
Default constructor which sets thread stopped to false, source and destination images to null, and destination flag to false.AlgorithmBase(ModelImage destImage, ModelImage srcImage)
Constructor which sets thread stopped to false and sets source and destination images.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
Routine to catch action eventsvoid
addListener(AlgorithmInterface obj)
Add a listener to this class so that when when the algorithm has completed processing it can use notifyListener to notify all listeners that the algorithm has completed.void
addProgressChangeListener(ProgressChangeListener l)
Adds the ProgressChangeListener to this FileBase object.static int
calculateImageSize(int[] dims)
Calculate the size of the image.void
calculatePrincipleAxis(ModelImage image, boolean doColor)
Working ...double
computeElapsedTime()
Computes the elapased time as the difference between the start time and the current time (both of which are in milliseconds).static double
computeElapsedTime(long start)
Computes the elapased time as the difference between the start time and the current time (both of which are in milliseconds).protected float[]
convertIntoFloat(java.lang.String[] str)
Takes an array of strings and converts each entry into a float value.protected void
delinkProgressToAlgorithm(AlgorithmBase baseAlgo)
Disconnect this algorithm with the progress bar which holds a reference to this algorithm.protected void
delinkProgressToAlgorithmMulti(AlgorithmBase baseAlgo)
void
displayError(java.lang.String error)
Displays an error in a frame.void
errorCleanUp(java.lang.String strErr, boolean gcFlag)
Display string pass into the method.void
finalize()
Calls garbage collector to release system resources.protected void
fireProgressStateChanged(float fVal, java.lang.String title, java.lang.String message)
Updates listeners of progress status.protected void
fireProgressStateChanged(int value)
Notifies all listeners that have registered interest for notification on this event type.protected void
fireProgressStateChanged(int value, java.lang.String title, java.lang.String message)
Notifies all listeners that have registered interest for notification on this event type.protected void
fireProgressStateChanged(java.lang.String message)
Notifies listeners that have registered interest for notification on this event type.protected void
fireProgressStateChanged(java.lang.String imageName, java.lang.String message)
Updates listeners of progress status.int[]
generateProgressValues(int currentProgress, int desiredMaxProgress)
Helper function to determine which values to pass on to linked algorithms (that will fire progress changes to the same progress bar).ModelImage
getDestImage()
Accessor to return the destination imagedouble
getElapsedTime()
Returns the elapsed time in seconds.java.util.BitSet
getMask()
Gets the Bitset mask object.int
getMaxProgressValue()
Returns the max progress value.int
getMinProgressValue()
Returns the min progress value.int
getNumberOfThreads()
float
getProgress()
ViewJProgressBar
getProgressChangeListener()
If there is a progress bar that is listening to the algorithm's progress change events, this will retrieve that progress bar.ProgressChangeListener[]
getProgressChangeListeners()
Returns the progress change event listener list.int
getProgressModulus()
float
getProgressStep()
int[]
getProgressValues()
Gets the current stored min and max progress values.ModelImage
getSrcImage()
Gets the current source image for the algorithmboolean
isCompleted()
Returns flag that indicates that the algorithm has been sucessfully completed.boolean
isImage25D()
Returns flag that indicates if the image should be processed slice by slice.boolean
isMultiThreadingEnabled()
boolean
isRunningInSeparateThread()
Should be set to true if NOT in a single thread (i.e., the main gui and this algo are in different threads) - will NOT force a graphics update of the progress bar.boolean
isThreadStopped()
Returns flag that indicates that the algorithm thread has been stopped.protected void
linkProgressToAlgorithm(AlgorithmBase baseAlgo)
Helper function to link the currently listening progress bar with an algorithm created within an algorithm.protected void
linkProgressToAlgorithm(AlgorithmBase baseAlgo, java.lang.String title, int min, int max)
New helper function for use with the ViewJProgressBarMulti.void
makeProgress(float step)
void
notifyListeners(AlgorithmBase algorithm)
Used to notify all listeners that the algorithm has completed.void
removeListener(AlgorithmInterface obj)
Remove a listener from the class.void
removeProgressChangeListener(ProgressChangeListener l)
Removes the ChangeListener from the FileBase object.void
run()
Performs start-up and tear-down operations that should be done by all algorithms (timing, history log).abstract void
runAlgorithm()
Actually runs the algorithm.void
setCompleted(boolean flag)
Sets completed to flag indicating if algorithm has sucessfully completed.void
setImage25D(boolean flag)
Sets a flag to indicate the image has dimensions of (i.e. spacial, spacial, time) and image processing routines should apply 2.5D algorithm.void
setMask(java.util.BitSet imageMask)
Sets the mask (BitSet object).void
setMaxProgressValue(int maxProgressValue)
Sets the max progress value.void
setMinProgressValue(int minProgressValue)
Sets the min progress value.void
setMultiThreadingEnabled(boolean multiThreadingEnabled)
void
setNumberOfThreads(int nthreads)
void
setProgress(int progress)
void
setProgressModulus(int progressModulus)
void
setProgressStep(float progressStep)
void
setProgressValues(int[] minmax)
Sets the min and max progress values from an array of two ints.void
setProgressValues(int min, int max)
Sets both the min and max progress values.void
setRunningInSeparateThread(boolean separateThread)
Sets the running in separate thread flag which controls how the progress bar is updated.void
setSrcImage(ModelImage srcImage)
Sets the source image of the algorithmvoid
setStartTime()
Sets the start time to the current time.void
setThreadStopped(boolean flag)
Sets the thread stopped to flag indicating if algorithm has stopped.boolean
startMethod(int priority)
Checks to see if a thread is already running on this object.void
windowActivated(java.awt.event.WindowEvent event)
Do nothing.void
windowClosed(java.awt.event.WindowEvent event)
Do nothing.void
windowClosing(java.awt.event.WindowEvent event)
Sets completed to false, disposes the progress bar and notifies all listeners that the algorithm is stopped.void
windowDeactivated(java.awt.event.WindowEvent event)
Do nothing.void
windowDeiconified(java.awt.event.WindowEvent event)
Do nothing.void
windowIconified(java.awt.event.WindowEvent event)
Do nothing.void
windowOpened(java.awt.event.WindowEvent event)
Do nothing.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
destFlag
protected boolean destFlag
Destination flag indicating if a destination (result) image is generated.
-
destImage
protected ModelImage destImage
Destination image.
-
image25D
protected boolean image25D
If true process each image of a 3D volume independently.
-
separable
protected boolean separable
If true convolution kernels are separable.
-
mask
protected java.util.BitSet mask
Mask indicating which voxels to process. If true process voxel else skip.
-
runningInSeparateThread
protected boolean runningInSeparateThread
Should be set to true if NOT in a single thread - will NOT force a graphics update of the progress bar. Should be set to false if in a single thread - will force a graphics update of the progress bar. This defaults to false, since we can automatically set it to true when startMethod() is called. When starting the algorithm with run(), this boolean should remain false.- See Also:
startMethod(int)
,run()
-
srcImage
protected ModelImage srcImage
Source image.
-
threadStopped
protected volatile boolean threadStopped
Flag indicating whether or not the thread is stopped.
-
completed
private boolean completed
This flag will be set to true when the algorithm has completed.
-
elapsedTime
private double elapsedTime
Elapsed time (in milliseconds) -- time it took for algorithm to run.
-
listenerList
private javax.swing.event.EventListenerList listenerList
A list of the ChangeListeners which are interested in the ChangeEvent.
-
maxProgressValue
protected int maxProgressValue
Used to store the maximum value of the progress bar.
-
minProgressValue
protected int minProgressValue
Used to store the minimum value of the progress bar.
-
objectList
private java.util.Vector<AlgorithmInterface> objectList
Vector list of AlgorithmInterface objects. When the algorithm has been stopped or completed, all listeners in this list are notified.
-
startTime
private long startTime
Start time (in milliseconds) to be used to compute elapsed time.
-
progress
protected float progress
Store the progress being made.
-
progressStep
protected float progressStep
-
progressModulus
protected int progressModulus
-
multiThreadingEnabled
protected boolean multiThreadingEnabled
Indicates if multi-threading will be used to optimize the algorithm.
-
nthreads
protected int nthreads
The number of threads will be used to execute the algorithm if multi-threading is enabled
-
-
Constructor Detail
-
AlgorithmBase
public AlgorithmBase()
Default constructor which sets thread stopped to false, source and destination images to null, and destination flag to false.
-
AlgorithmBase
public AlgorithmBase(ModelImage destImage, ModelImage srcImage)
Constructor which sets thread stopped to false and sets source and destination images.- Parameters:
destImage
- Destination image, can be null.srcImage
- Source image, should not be null.
-
-
Method Detail
-
runAlgorithm
public abstract void runAlgorithm()
Actually runs the algorithm. Implemented by inheriting algorithms.
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
Routine to catch action events- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
- Parameters:
e
- ActionEvent
-
addListener
public void addListener(AlgorithmInterface obj)
Add a listener to this class so that when when the algorithm has completed processing it can use notifyListener to notify all listeners that the algorithm has completed.- Parameters:
obj
- AlgorithmInterface "object' to be added to the list
-
addProgressChangeListener
public void addProgressChangeListener(ProgressChangeListener l)
Adds the ProgressChangeListener to this FileBase object.- Parameters:
l
- the ProgressChangeListener object
-
calculatePrincipleAxis
public void calculatePrincipleAxis(ModelImage image, boolean doColor)
Working ... This function is never used. It doesn't modify any parameters or data members and returns void.- Parameters:
image
- DOCUMENT ME!doColor
- DOCUMENT ME!
-
computeElapsedTime
public double computeElapsedTime()
Computes the elapased time as the difference between the start time and the current time (both of which are in milliseconds).- Returns:
- the elapsed time in seconds -- this is a double value
-
computeElapsedTime
public static double computeElapsedTime(long start)
Computes the elapased time as the difference between the start time and the current time (both of which are in milliseconds).- Returns:
- the elapsed time in seconds -- this is a double value
-
displayError
public void displayError(java.lang.String error)
Displays an error in a frame.- Parameters:
error
- string that is displayed
-
errorCleanUp
public void errorCleanUp(java.lang.String strErr, boolean gcFlag)
Display string pass into the method. If the string is null no message is displayed. The completed flag is set tofalse
and the progress bar is disposed;- Parameters:
strErr
- the string that is to be displayed. If the string is null no message is displayed.gcFlag
- iftrue
call the garbage collector.
-
finalize
public void finalize()
Calls garbage collector to release system resources.- Overrides:
finalize
in classjava.lang.Object
-
generateProgressValues
public int[] generateProgressValues(int currentProgress, int desiredMaxProgress)
Helper function to determine which values to pass on to linked algorithms (that will fire progress changes to the same progress bar). You pass in the current progress and then the max desired progress.... you do NOT adjust the progress yourself, you assume a 0-100 range always, so if the current progress of a certain algorithm was 50%, and you want the helper algorithm to run on an adjusted scale of 50% to 70%, then you pass 50 and 70 as current & desiredMax respectively. if the algorithm passing this in was on a scale of 0->50, then the displayed progress will range from 25% to 35% (50% of 50->70)- Parameters:
currentProgress
- current progress of algorithm on a 0->100 scaledesiredMaxProgress
- max progress desired for linked algorithm- Returns:
- array of 2 ints [current, max]
-
getDestImage
public ModelImage getDestImage()
Accessor to return the destination image- Returns:
- ModelImage destination image
-
getElapsedTime
public double getElapsedTime()
Returns the elapsed time in seconds. This does not compute a new elapsed time.- Returns:
- the elapsed time, in seconds computed earlier
- See Also:
computeElapsedTime()
-
getMask
public java.util.BitSet getMask()
Gets the Bitset mask object.- Returns:
- The mask indicating which voxels of the image to process
-
getMaxProgressValue
public int getMaxProgressValue()
Returns the max progress value.- Returns:
- max progress value
-
getMinProgressValue
public int getMinProgressValue()
Returns the min progress value.- Returns:
- min progress value
-
getProgressChangeListener
public ViewJProgressBar getProgressChangeListener()
If there is a progress bar that is listening to the algorithm's progress change events, this will retrieve that progress bar. This function is really only here to support AlgorithmExtractSurface, AlgorithmExtractSurfaceCubes, and AlgorithmHeightFunction which use ModelQuadMesh and ModelTriangle Mesh (which do not follow the standard algorithmbase setup). This function should not be used elsewhere and will probably be removed (and modelquad/trianglemesh will be changed).- Returns:
- a progressbar if there is one listening, null otherwise.
-
getProgressChangeListeners
public ProgressChangeListener[] getProgressChangeListeners()
Returns the progress change event listener list.- Returns:
- the progress change event listener list.
-
getProgressValues
public int[] getProgressValues()
Gets the current stored min and max progress values.- Returns:
- int [] { currentMin, currentMax}
-
getSrcImage
public ModelImage getSrcImage()
Gets the current source image for the algorithm- Returns:
- the source image
-
isCompleted
public boolean isCompleted()
Returns flag that indicates that the algorithm has been sucessfully completed.- Returns:
true
if algorithm completed successfully,false
if it was stopped or had an error.
-
isImage25D
public boolean isImage25D()
Returns flag that indicates if the image should be processed slice by slice.- Returns:
true
if image should be processed slice by slice.
-
isRunningInSeparateThread
public boolean isRunningInSeparateThread()
Should be set to true if NOT in a single thread (i.e., the main gui and this algo are in different threads) - will NOT force a graphics update of the progress bar. Should be set to false if in a single thread - will force a graphics update of the progress bar.- Returns:
- boolean true if this algorithm is in a different thread from the main mipav gui thread.
-
isThreadStopped
public boolean isThreadStopped()
Returns flag that indicates that the algorithm thread has been stopped.- Returns:
true
if thread has stopped.
-
notifyListeners
public void notifyListeners(AlgorithmBase algorithm)
Used to notify all listeners that the algorithm has completed.- Parameters:
algorithm
- algorithm class that has completed the function
-
removeListener
public void removeListener(AlgorithmInterface obj)
Remove a listener from the class.- Parameters:
obj
- the algorithm listener to be removed from the list for this algo
-
removeProgressChangeListener
public void removeProgressChangeListener(ProgressChangeListener l)
Removes the ChangeListener from the FileBase object.- Parameters:
l
- the ProgressChangeListener object
-
run
public void run()
Performs start-up and tear-down operations that should be done by all algorithms (timing, history log). Since this class extends the Thread class it can be run in its own thread by invoking object.start(); It can also be invoked without a new thread by calling the the run() method directly (ie. object.run()).- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
setCompleted
public void setCompleted(boolean flag)
Sets completed to flag indicating if algorithm has sucessfully completed.- Parameters:
flag
- Flag to set totrue
if the algorithm has completed.
-
setImage25D
public void setImage25D(boolean flag)
Sets a flag to indicate the image has dimensions of (i.e. spacial, spacial, time) and image processing routines should apply 2.5D algorithm.- Parameters:
flag
- flag to set to
-
setMask
public void setMask(java.util.BitSet imageMask)
Sets the mask (BitSet object).- Parameters:
imageMask
- BitSet object indicating which voxels to process
-
setMaxProgressValue
public void setMaxProgressValue(int maxProgressValue)
Sets the max progress value.- Parameters:
maxProgressValue
- the maximum progress value
-
setMinProgressValue
public void setMinProgressValue(int minProgressValue)
Sets the min progress value.- Parameters:
minProgressValue
- the minimum progress value
-
setProgressValues
public void setProgressValues(int[] minmax)
Sets the min and max progress values from an array of two ints.- Parameters:
minmax
- array of two ints [min, max]
-
setProgressValues
public void setProgressValues(int min, int max)
Sets both the min and max progress values.- Parameters:
min
- the min progress valuemax
- the max progress value
-
setRunningInSeparateThread
public void setRunningInSeparateThread(boolean separateThread)
Sets the running in separate thread flag which controls how the progress bar is updated. If true the progress bar is not forced to update.- Parameters:
separateThread
- Should be set to true if NOT in a single thread (i.e., the main gui and this algo are in different threads) - will NOT force a graphics update of the progress bar. Should be set to false if in a single thread - will force a graphics update of the progress bar.
-
setSrcImage
public void setSrcImage(ModelImage srcImage)
Sets the source image of the algorithm- Parameters:
srcImage
- the source image
-
setStartTime
public void setStartTime()
Sets the start time to the current time. This should be called at the beginning of the run() method.
-
setThreadStopped
public void setThreadStopped(boolean flag)
Sets the thread stopped to flag indicating if algorithm has stopped.- Parameters:
flag
- flag to set to
-
startMethod
public final boolean startMethod(int priority)
Checks to see if a thread is already running on this object. If so, it returns false, else it starts the thread and returns true.- Parameters:
priority
- thread priority- Returns:
- false if a thread is already running this algorithm, true otherwise
-
windowActivated
public void windowActivated(java.awt.event.WindowEvent event)
Do nothing.- Specified by:
windowActivated
in interfacejava.awt.event.WindowListener
- Parameters:
event
- the window activated event
-
windowClosed
public void windowClosed(java.awt.event.WindowEvent event)
Do nothing.- Specified by:
windowClosed
in interfacejava.awt.event.WindowListener
- Parameters:
event
- the window closed event
-
windowClosing
public void windowClosing(java.awt.event.WindowEvent event)
Sets completed to false, disposes the progress bar and notifies all listeners that the algorithm is stopped.- Specified by:
windowClosing
in interfacejava.awt.event.WindowListener
- Parameters:
event
- event that triggered function
-
windowDeactivated
public void windowDeactivated(java.awt.event.WindowEvent event)
Do nothing.- Specified by:
windowDeactivated
in interfacejava.awt.event.WindowListener
- Parameters:
event
- the window deactivated event
-
windowDeiconified
public void windowDeiconified(java.awt.event.WindowEvent event)
Do nothing.- Specified by:
windowDeiconified
in interfacejava.awt.event.WindowListener
- Parameters:
event
- the window deiconified event
-
windowIconified
public void windowIconified(java.awt.event.WindowEvent event)
Do nothing.- Specified by:
windowIconified
in interfacejava.awt.event.WindowListener
- Parameters:
event
- the window iconified event
-
windowOpened
public void windowOpened(java.awt.event.WindowEvent event)
Do nothing.- Specified by:
windowOpened
in interfacejava.awt.event.WindowListener
- Parameters:
event
- the window opened event
-
convertIntoFloat
protected float[] convertIntoFloat(java.lang.String[] str)
Takes an array of strings and converts each entry into a float value. Useful for updating DICOM file information.- Parameters:
str
- Some number of strings in an array- Returns:
- An array of floats; the same number of entries in str are returned in the array.
-
fireProgressStateChanged
protected void fireProgressStateChanged(java.lang.String message)
Notifies listeners that have registered interest for notification on this event type.- Parameters:
message
- the new message to display on the progress bar
-
fireProgressStateChanged
protected void fireProgressStateChanged(int value)
Notifies all listeners that have registered interest for notification on this event type.- Parameters:
value
- the value of the progress bar.
-
fireProgressStateChanged
protected void fireProgressStateChanged(java.lang.String imageName, java.lang.String message)
Updates listeners of progress status. Without actually changing the numerical value- Parameters:
imageName
- the name of the imagemessage
- the new message to display
-
fireProgressStateChanged
protected void fireProgressStateChanged(int value, java.lang.String title, java.lang.String message)
Notifies all listeners that have registered interest for notification on this event type.- Parameters:
value
- the value of the progress bar.title
- the title of the progress dialog.message
- the message for that specific progress value.
-
fireProgressStateChanged
protected void fireProgressStateChanged(float fVal, java.lang.String title, java.lang.String message)
Updates listeners of progress status.- Parameters:
fVal
- the percent progress of the algorithm so fartitle
- the title to send to the listenersmessage
- the message to send to the listeners
-
linkProgressToAlgorithm
protected void linkProgressToAlgorithm(AlgorithmBase baseAlgo)
Helper function to link the currently listening progress bar with an algorithm created within an algorithm. This function should only be called when the other algorithm is expected to update the progress bar seamlessly. It should be called in conjuction with AlgorithmBase's setProgressValues() so that the sub-algorithm will have know the min and max progress values.Generally this will be called with the following lines: linkProgressToAlgorithm(theSubAlgorithm); theSubAlgorithm.setProgressValues(generateProgressValues(currentProgressOfAlgorithm, desiredMaxProgressOfSubAlgorithm));
- Parameters:
baseAlgo
- the subalgorithm created within current algorithm
-
linkProgressToAlgorithm
protected void linkProgressToAlgorithm(AlgorithmBase baseAlgo, java.lang.String title, int min, int max)
New helper function for use with the ViewJProgressBarMulti. This allows for keeping track of multi-threaded algorithms and allow the user to better keep track of multiple processes being run. Any linked algorithms should update together in the manner specificed by min/max.- Parameters:
baseAlgo
- the subalgorithm created within current algorithmtitle
- the title shown in the progress bar panelmin
- the lower bound of the updating portion of the parent algorithmmax
- the upper bound of the updating portion of the parent algorithm
-
delinkProgressToAlgorithm
protected void delinkProgressToAlgorithm(AlgorithmBase baseAlgo)
Disconnect this algorithm with the progress bar which holds a reference to this algorithm. In order to release the memory of this algorithm, this function should be called after the algorithm was finished.- Parameters:
baseAlgo
-
-
delinkProgressToAlgorithmMulti
protected void delinkProgressToAlgorithmMulti(AlgorithmBase baseAlgo)
-
getProgress
public float getProgress()
-
setProgress
public void setProgress(int progress)
-
makeProgress
public void makeProgress(float step)
-
getProgressStep
public float getProgressStep()
-
setProgressStep
public void setProgressStep(float progressStep)
-
isMultiThreadingEnabled
public boolean isMultiThreadingEnabled()
-
setMultiThreadingEnabled
public void setMultiThreadingEnabled(boolean multiThreadingEnabled)
-
getNumberOfThreads
public int getNumberOfThreads()
-
setNumberOfThreads
public void setNumberOfThreads(int nthreads)
-
getProgressModulus
public int getProgressModulus()
-
setProgressModulus
public void setProgressModulus(int progressModulus)
-
calculateImageSize
public static int calculateImageSize(int[] dims)
Calculate the size of the image.- Parameters:
dims
-- Returns:
-
-