org.shapelogic.imageprocessing
Class ChainCodeHandler

java.lang.Object
  extended by org.shapelogic.polygon.BaseAnnotatedShape
      extended by org.shapelogic.imageprocessing.ChainCodeHandler
All Implemented Interfaces:
Calc0<MultiLine>, CalcInvoke<MultiLine>, CalcValue<MultiLine>, LazyCalc<MultiLine>, AnnotatedShape

public class ChainCodeHandler
extends BaseAnnotatedShape
implements CalcInvoke<MultiLine>

Chain Code For MultiLine. Assume that there is no intersection.

Author:
Sami Badawi

Field Summary
protected  int _accumulatedAbsoluteDirectionChange
           
protected  int _accumulatedDirectionChange
           
protected  BBox _bBox
           
protected  byte[] _chainCodeForMultiLine
           
protected  int _diagonalElementCount
           
protected  boolean _dirty
           
protected  CPointInt _firstPoint
           
protected  int _lastChain
           
protected  CPointInt _lastPoint
           
protected  java.util.List<LineProperties> _linePropertiesList
          Line number N should have end point on point number N.
protected  MultiLine _multiLine
           
protected  double _perimeter
           
protected  java.util.TreeMap<java.lang.Integer,CPointInt> _pointMap
           
protected  java.util.List<PointProperties> _pointPropertiesList
          What should happen to the last point if the first and the last point is the same.
protected static int CHAIN_CODE_FOR_MULTI_LINE_MAX_LENGTH
           
protected static double LIMIT_FOR_HARD_CORNER
           
protected static int SHORT_LINE_LENGTH
           
 
Fields inherited from class org.shapelogic.polygon.BaseAnnotatedShape
_annotatedShape
 
Constructor Summary
ChainCodeHandler(AnnotatedShapeImplementation annotatedShape)
           
 
Method Summary
 boolean addChainCode(byte chainCode)
           
 void findAccumulatedDirectionChange()
          Find the accumulated direction change, the sum of all turns.
 byte[] getChainCodeForMultiLine()
           
protected  double getDistLimit(int pixelCountInCurrentLineInterval)
          DistLimit is half based on the diameter of the polygon half on the length of the line.
 CPointInt getFirstPoint()
           
 int getLastChain()
           
 CPointInt getLastPoint()
           
 double getPerimeter()
           
 MultiLine getValue()
          Starts a lazy calculation.
 MultiLine invoke()
           
 boolean isClosed()
          Last point is a running point so this will not always work.
 boolean isDirty()
          When dirty is false that means that the calculated value can be used
 void setFirstPoint(IPoint2D firstPoint)
           
 void setMultiLine(MultiLine line)
           
 void setPerimeter(double perimeter)
           
 void setup()
          Currently not super well define used for 2 purposes: Reset: called from the outside if you want to reuse it init: Called from the inside when calculation start to have everything setup maybe the semantic could work for both? TODO: This should be separated better.
 void swapChainCodeInOppositeDirection()
          Opposite Direction.
 
Methods inherited from class org.shapelogic.polygon.BaseAnnotatedShape
getAnnotatedShape, getAnnotationForShapes, getMap, getShapesForAnnotation, putAllAnnotation, putAnnotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHAIN_CODE_FOR_MULTI_LINE_MAX_LENGTH

protected static final int CHAIN_CODE_FOR_MULTI_LINE_MAX_LENGTH
See Also:
Constant Field Values

SHORT_LINE_LENGTH

protected static final int SHORT_LINE_LENGTH
See Also:
Constant Field Values

LIMIT_FOR_HARD_CORNER

protected static final double LIMIT_FOR_HARD_CORNER
See Also:
Constant Field Values

_chainCodeForMultiLine

protected byte[] _chainCodeForMultiLine

_lastChain

protected int _lastChain

_firstPoint

protected CPointInt _firstPoint

_lastPoint

protected CPointInt _lastPoint

_multiLine

protected MultiLine _multiLine

_dirty

protected boolean _dirty

_bBox

protected BBox _bBox

_pointMap

protected java.util.TreeMap<java.lang.Integer,CPointInt> _pointMap

_accumulatedDirectionChange

protected int _accumulatedDirectionChange

_accumulatedAbsoluteDirectionChange

protected int _accumulatedAbsoluteDirectionChange

_diagonalElementCount

protected int _diagonalElementCount

_pointPropertiesList

protected java.util.List<PointProperties> _pointPropertiesList
What should happen to the last point if the first and the last point is the same. I think that there should be 2 points, in the list of points, but as far as PointProperties I think that there should only be one, maybe I could just use the same. How would that work? I could have a map Another thing is if I count the number of point in a closed multi line it will be one too many.


_linePropertiesList

protected java.util.List<LineProperties> _linePropertiesList
Line number N should have end point on point number N. The first line should be null if the multi line is open and from the last to the first if closed I could possibly also have the first LineProperties have an extra reference at the end


_perimeter

protected double _perimeter
Constructor Detail

ChainCodeHandler

public ChainCodeHandler(AnnotatedShapeImplementation annotatedShape)
Method Detail

setup

public void setup()
Description copied from interface: LazyCalc
Currently not super well define used for 2 purposes: Reset: called from the outside if you want to reuse it init: Called from the inside when calculation start to have everything setup maybe the semantic could work for both? TODO: This should be separated better.

Specified by:
setup in interface LazyCalc<MultiLine>
Specified by:
setup in interface AnnotatedShape
Overrides:
setup in class BaseAnnotatedShape

invoke

public MultiLine invoke()
Specified by:
invoke in interface Calc0<MultiLine>

getValue

public MultiLine getValue()
Description copied from interface: CalcValue
Starts a lazy calculation. If dirty do calc() else return cached value. This should maybe be moved up in the hierarchy

Specified by:
getValue in interface CalcValue<MultiLine>

findAccumulatedDirectionChange

public void findAccumulatedDirectionChange()
Find the accumulated direction change, the sum of all turns.


addChainCode

public boolean addChainCode(byte chainCode)

swapChainCodeInOppositeDirection

public void swapChainCodeInOppositeDirection()
Opposite Direction.


isDirty

public boolean isDirty()
Description copied from interface: LazyCalc
When dirty is false that means that the calculated value can be used

Specified by:
isDirty in interface LazyCalc<MultiLine>

getDistLimit

protected double getDistLimit(int pixelCountInCurrentLineInterval)
DistLimit is half based on the diameter of the polygon half on the length of the line.


setFirstPoint

public void setFirstPoint(IPoint2D firstPoint)

getFirstPoint

public CPointInt getFirstPoint()

getChainCodeForMultiLine

public byte[] getChainCodeForMultiLine()

setMultiLine

public void setMultiLine(MultiLine line)

isClosed

public boolean isClosed()
Last point is a running point so this will not always work.


getLastChain

public int getLastChain()

getLastPoint

public CPointInt getLastPoint()

getPerimeter

public double getPerimeter()

setPerimeter

public void setPerimeter(double perimeter)


Copyright © 2009. All Rights Reserved.