whistlesAndMoans
Class FragmentingFragmenter

java.lang.Object
  extended by whistlesAndMoans.DiscardingFragmenter
      extended by whistlesAndMoans.FragmentingFragmenter
All Implemented Interfaces:
RegionFragmenter
Direct Known Subclasses:
RejoiningFragmenter

public class FragmentingFragmenter
extends DiscardingFragmenter


Field Summary
private  boolean discardSmallOnes
           
protected  java.util.Vector<ConnectedRegion> fragments
           
protected  WhistleMoanControl whistleMoanControl
           
 
Fields inherited from class whistlesAndMoans.DiscardingFragmenter
maxPeaks, motherRegion, nFragments, nSlices, slicePeaks, totalPeaks
 
Constructor Summary
FragmentingFragmenter(WhistleMoanControl whistleMoanControl)
           
 
Method Summary
protected  void cleanFragments()
          Clean up fragments - mostly sorting out links between peaks.
private  void clearIntArray(int[] array)
          Doesn't really zero the array but sets all elements to -1 so that we know they don't contain a valid index to any other peak.
protected  boolean closeRegion(ConnectedRegion region, int nJoinedEnd)
          Finish off a region if no more bits are to be added to it.
 void createFragments()
          Split the mother region up into fragments, breaking at every branch and join
 int fragmentRegion(ConnectedRegion connectedRegion)
          Fragment a connected region
 ConnectedRegion getFragment(int fragment)
          Get a specific fragment
 int getNumFragments()
          Get the number of fragments
 boolean isDiscardSmallOnes()
           
protected  boolean matchPeak(int[] peak1, int[] peak2, int connectType)
          Match to peaks - return true if they merge into one another.
protected  void sayFragment(int iFrag, ConnectedRegion region)
          Dump information on a single fragment ot screen.
protected  void sayFragments()
          Dump information to screen.
 void setDiscardSmallOnes(boolean discardSmallOnes)
          Set by teh RejoinFragments superclass so that all fragments are kept
private  void zeroIintArray(int[] array)
          Set all array elements to zero
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fragments

protected java.util.Vector<ConnectedRegion> fragments

whistleMoanControl

protected WhistleMoanControl whistleMoanControl

discardSmallOnes

private boolean discardSmallOnes
Constructor Detail

FragmentingFragmenter

public FragmentingFragmenter(WhistleMoanControl whistleMoanControl)
Method Detail

fragmentRegion

public int fragmentRegion(ConnectedRegion connectedRegion)
Description copied from interface: RegionFragmenter
Fragment a connected region

Specified by:
fragmentRegion in interface RegionFragmenter
Overrides:
fragmentRegion in class DiscardingFragmenter
Parameters:
connectedRegion - region to fragment
Returns:
number of fragments.

createFragments

public void createFragments()
Split the mother region up into fragments, breaking at every branch and join


closeRegion

protected boolean closeRegion(ConnectedRegion region,
                              int nJoinedEnd)
Finish off a region if no more bits are to be added to it.

Parameters:
region - region to close
nJoinedEnd - number of other bits coming out of this point
Returns:
true if the region is big enough to be worth keeping.

matchPeak

protected boolean matchPeak(int[] peak1,
                            int[] peak2,
                            int connectType)
Match to peaks - return true if they merge into one another.

Parameters:
peak1 - first peak
peak2 - second peak
connectType - connect 4 or connect 8
Returns:
true if they touch according to 4 / 8 rule

clearIntArray

private void clearIntArray(int[] array)
Doesn't really zero the array but sets all elements to -1 so that we know they don't contain a valid index to any other peak.

Parameters:
array -

zeroIintArray

private void zeroIintArray(int[] array)
Set all array elements to zero

Parameters:
array -

cleanFragments

protected void cleanFragments()
Clean up fragments - mostly sorting out links between peaks.


getFragment

public ConnectedRegion getFragment(int fragment)
Description copied from interface: RegionFragmenter
Get a specific fragment

Specified by:
getFragment in interface RegionFragmenter
Overrides:
getFragment in class DiscardingFragmenter
Parameters:
fragment - fragment number (0 to getNumFragments);
Returns:
the ith fragment

getNumFragments

public int getNumFragments()
Description copied from interface: RegionFragmenter
Get the number of fragments

Specified by:
getNumFragments in interface RegionFragmenter
Overrides:
getNumFragments in class DiscardingFragmenter
Returns:
the number of fragments

isDiscardSmallOnes

public boolean isDiscardSmallOnes()

setDiscardSmallOnes

public void setDiscardSmallOnes(boolean discardSmallOnes)
Set by teh RejoinFragments superclass so that all fragments are kept

Parameters:
discardSmallOnes -

sayFragments

protected void sayFragments()
Dump information to screen.


sayFragment

protected void sayFragment(int iFrag,
                           ConnectedRegion region)
Dump information on a single fragment ot screen.

Parameters:
iFrag -
region -