|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.shapelogic.polygon.BaseAnnotatedShape org.shapelogic.polygon.Polygon
public class Polygon
Polygon is the bottom class for polygon works for points on any kind Almost immutable: you can extend it by adding more but you cannot change the element, and the underlying points are mutable. So point should not be changed after they are added. Note that this and the sub class MultiLinePolygon has the exactly same interface
Field Summary | |
---|---|
protected AnnotatedShapeImplementation |
_annotatedShape
|
protected double |
_aspectRatio
|
protected BBox |
_bBox
|
protected boolean |
_closed
|
protected MultiLine |
_currentMultiLine
|
protected boolean |
_dirty
|
protected int |
_endPointCount
|
protected java.util.List<java.util.Set<IPoint2D>> |
_endPointsClusters
|
protected java.util.Set<CLine> |
_lines
|
protected java.lang.Double |
_perimeter
|
protected java.util.Set<IPoint2D> |
_points
|
protected java.util.Map<IPoint2D,java.lang.Integer> |
_pointsCountMap
|
protected java.util.Map<IPoint2D,java.util.Set<CLine>> |
_pointsToLineMap
|
protected java.util.List<Improver<Polygon>> |
_polygonImprovers
|
protected int |
_version
|
Constructor Summary | |
---|---|
Polygon()
|
|
Polygon(AnnotatedShapeImplementation annotatedShape)
|
Method Summary | ||
---|---|---|
void |
addAfterEnd(IPoint2D newPoint)
|
|
void |
addBeforeStart(IPoint2D newPoint)
|
|
protected CLine |
addIndependentLine(CLine line)
Most of the time this should not be used use the version taking input points instead |
|
CLine |
addIndependentLine(IPoint2D point1,
IPoint2D point2)
To have the same interface as MultiLinePolygon |
|
protected CLine |
addLine(CLine line)
Deprecated. |
|
CLine |
addLine(IPoint2D point1,
IPoint2D point2)
this should not be used use addIndependentLine() instead |
|
void |
addMultiLine(MultiLine multiLine)
|
|
Polygon |
cleanUp(boolean onlyInt,
double procentage)
Return a cleaned up polygon |
|
java.lang.Object |
clone()
|
|
boolean |
containsLine(ILine2D line)
|
|
boolean |
containsPoint(IPoint2D point)
|
|
void |
endMultiLine()
Add all the lines segments in the multi line to _lines |
|
|
filter(IFilter<Polygon,Element> filterObject)
|
|
|
filter(java.lang.String inputExpression)
|
|
int |
findPointCount()
|
|
double |
getAspectRatio()
|
|
BBox |
getBBox()
|
|
IPoint2D |
getCenter()
|
|
MultiLine |
getCurrentMultiLine()
|
|
double |
getDiameter()
|
|
int |
getEndPointCount()
|
|
java.util.List<java.util.Set<IPoint2D>> |
getEndPointsClusters()
|
|
java.util.List<java.util.Set<IPoint2D>> |
getEndPointsMultiClusters()
|
|
int |
getHoleCount()
|
|
java.util.List<CLine> |
getHorizontalLines()
|
|
java.util.Set<CLine> |
getIndependentLines()
To have the same interface as MultiLinePolygon |
|
java.util.Set<CLine> |
getLines()
|
|
java.util.Collection<CLine> |
getLinesForPoint(IPoint2D point)
|
|
java.util.List<MultiLine> |
getMultiLines()
To have the same interface as MultiLinePolygon returns null since this and the independent lines are supposed to be all the lines |
|
java.lang.Double |
getPerimeter()
|
|
java.util.Set<IPoint2D> |
getPoints()
|
|
java.util.Map<IPoint2D,java.lang.Integer> |
getPointsCountMap()
Find how many lines each point is part of by making a map |
|
java.util.Map<IPoint2D,java.util.Set<CLine>> |
getPointsToLineMap()
Find how many lines each point is part of by making a map |
|
Polygon |
getValue()
Starts a lazy calculation. |
|
int |
getVersion()
|
|
java.util.List<CLine> |
getVerticalLines()
|
|
Polygon |
improve()
register a list of improvers and call them here |
|
protected void |
internalFactory()
All the objects that needs special version should be created here. |
|
java.lang.String |
internalInfo(java.lang.StringBuffer sb)
|
|
Polygon |
invoke()
|
|
boolean |
isClosed()
|
|
boolean |
isDirty()
When dirty is false that means that the calculated value can be used |
|
java.lang.String |
printAnnotation(java.lang.StringBuffer result)
|
|
Polygon |
replacePointsInMap(java.util.Map<IPoint2D,IPoint2D> pointReplacementMap,
AnnotatedShapeImplementation annotatedShape)
No filtering in first version |
|
void |
setPerimeter(java.lang.Double perimeter)
|
|
void |
setPolygonImprovers(java.util.List<Improver<Polygon>> improvers)
|
|
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 |
setVersion(int version)
|
|
void |
startMultiLine()
|
|
java.lang.String |
toString()
|
Methods inherited from class org.shapelogic.polygon.BaseAnnotatedShape |
---|
getAnnotatedShape, getAnnotationForShapes, getMap, getShapesForAnnotation, putAllAnnotation, putAnnotation |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected BBox _bBox
protected java.util.Set<CLine> _lines
protected java.util.Set<IPoint2D> _points
protected boolean _dirty
protected double _aspectRatio
protected boolean _closed
protected int _endPointCount
protected java.util.Map<IPoint2D,java.lang.Integer> _pointsCountMap
protected java.util.Map<IPoint2D,java.util.Set<CLine>> _pointsToLineMap
protected int _version
protected MultiLine _currentMultiLine
protected java.util.List<java.util.Set<IPoint2D>> _endPointsClusters
protected AnnotatedShapeImplementation _annotatedShape
protected java.util.List<Improver<Polygon>> _polygonImprovers
protected java.lang.Double _perimeter
Constructor Detail |
---|
public Polygon()
public Polygon(AnnotatedShapeImplementation annotatedShape)
Method Detail |
---|
protected void internalFactory()
public BBox getBBox()
getBBox
in interface IPolygon2D
public java.util.Set<CLine> getLines()
getLines
in interface IPolygon2D
public java.util.Set<IPoint2D> getPoints()
getPoints
in interface IPolygon2D
public double getAspectRatio()
getAspectRatio
in interface IPolygon2D
public boolean isClosed()
isClosed
in interface IPolygon2D
public boolean isDirty()
LazyCalc
isDirty
in interface LazyCalc<Polygon>
public void setup()
LazyCalc
setup
in interface LazyCalc<Polygon>
setup
in interface AnnotatedShape
setup
in class BaseAnnotatedShape
public boolean containsPoint(IPoint2D point)
public boolean containsLine(ILine2D line)
public CLine addLine(IPoint2D point1, IPoint2D point2)
@Deprecated protected CLine addLine(CLine line)
public Polygon invoke()
invoke
in interface Calc0<Polygon>
public Polygon cleanUp(boolean onlyInt, double procentage)
onlyInt
- Change all coordinates to integersprocentage
- of diagonal of b box that should be considered as same pointpublic Polygon improve()
public Polygon getValue()
CalcValue
getValue
in interface CalcValue<Polygon>
public java.util.List<CLine> getVerticalLines()
public java.util.List<CLine> getHorizontalLines()
public java.util.Map<IPoint2D,java.lang.Integer> getPointsCountMap()
public java.util.Map<IPoint2D,java.util.Set<CLine>> getPointsToLineMap()
public int findPointCount()
public int getEndPointCount()
public java.util.Collection<CLine> getLinesForPoint(IPoint2D point)
public int getVersion()
public void setVersion(int version)
public void startMultiLine()
public void addBeforeStart(IPoint2D newPoint)
public void addAfterEnd(IPoint2D newPoint)
public void endMultiLine()
public void addMultiLine(MultiLine multiLine)
public MultiLine getCurrentMultiLine()
public java.util.List<java.util.Set<IPoint2D>> getEndPointsClusters()
public java.util.List<java.util.Set<IPoint2D>> getEndPointsMultiClusters()
public java.lang.Object clone()
clone
in class java.lang.Object
public Polygon replacePointsInMap(java.util.Map<IPoint2D,IPoint2D> pointReplacementMap, AnnotatedShapeImplementation annotatedShape)
replacePointsInMap
in interface PointReplacable<Polygon>
public IPoint2D getCenter()
getCenter
in interface GeometricShape2D
public double getDiameter()
getDiameter
in interface GeometricShape2D
public void setPolygonImprovers(java.util.List<Improver<Polygon>> improvers)
public CLine addIndependentLine(IPoint2D point1, IPoint2D point2)
protected CLine addIndependentLine(CLine line)
public java.util.Set<CLine> getIndependentLines()
public java.util.List<MultiLine> getMultiLines()
public <Element> java.util.Collection<Element> filter(IFilter<Polygon,Element> filterObject)
public <Element> java.util.Collection<Element> filter(java.lang.String inputExpression)
public int getHoleCount()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String internalInfo(java.lang.StringBuffer sb)
public java.lang.String printAnnotation(java.lang.StringBuffer result)
public java.lang.Double getPerimeter()
public void setPerimeter(java.lang.Double perimeter)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |