Java Doc for LabelCacheDefault.java in  » GIS » GeoTools-2.4.1 » org » geotools » renderer » lite » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.renderer.lite 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.geotools.renderer.lite.LabelCacheDefault

LabelCacheDefault
final public class LabelCacheDefault implements LabelCache(Code)
Default LabelCache Implementation DJB (major changes on May 11th, 2005): 1.The old version of the labeler, if given a *set* of points, lines, or polygons justed labels the first item in the set. The sets are formed when you want to only put a single "Main St" on the map even if you have a bunch of small "Main St" segments. I changed this to be much much wiser. Basically, the new way looks at the set of geometries that its going to put a label on and find the "best" one that represents it. That geometry is then labeled (see below for details on where that label is placed). 2. I changed the actual drawing routines; 1. get the "representative geometry" 2. for points, label as before 3. for lines, find the middle point on the line (old version just averaged start and end points) and centre label on that point (rotated) 4. for polygon, put the label in the middle 3. ie. for lines, try the label at the 1/3, 1/2, and 2/3 location. Metric is how close the label bounding box is to the line. ie. for polygons, bisect the polygon (about the centroid) in to North, South, East and West polygons. Use the location that has the label best inside the polygon. After this is done, you can start doing constraint relaxation... 4. TODO: deal with labels going off the edge of the screen (much reduced now). 5. TODO: add a "minimum quality" parameter (ie. if you're labeling a tiny polygon with a tiny label, dont bother). Metrics are descibed in #3. 6. TODO: add ability for SLD to tweak parameters (ie. "always label"). ------------------------------------------------------------------------------------------ I've added extra functionality; a) priority -- if you set the in a TextSymbolizer, then you can control the order of labelling ** see mailing list for more details b) no --- turns off grouping for this symbolizer c) 5 -- do not put labels within 5 pixels of this label.
author:
   jeichar
author:
   dblasby


Field Summary
public  booleanDEFAULT_GROUP
    
public  doubleDEFAULT_PRIORITY
    
public  intDEFAULT_SPACEAROUND
    
public  doubleMIN_GOODNESS_FIT
    
 SetactiveLayers
    
 SetenabledLayers
    
protected  MaplabelCache
    
protected  ArrayListlabelCacheNonGrouped
    
 LineLengthComparatorlineLengthComparator
    
protected  booleanoutlineRenderingEnabled
     When true, the text is rendered as its GlyphVector outline (as a geometry) instead of using drawGlypVector.
 booleanstop
    
protected  SLDStyleFactorystyleFactory
    


Method Summary
public  voidclear()
    
public  voidclear(String layerId)
    
public  MultiLineStringclipLineString(LineString line, Polygon bbox, Envelope displayGeomEnv)
     try to be more robust dont bother returning points This will try to solve robustness problems, but read code as to what it does.
public  MultiPolygonclipPolygon(Polygon poly, Polygon bbox, Envelope displayGeomEnv)
     try to do a more robust way of clipping a polygon to a bounding box.
public  voiddisableLayer(String layerId)
    
public  voidenableLayer(String layerId)
    
public  voidend(Graphics2D graphics, Rectangle displayArea)
    
public  voidendLayer(String layerId, Graphics2D graphics, Rectangle displayArea)
    
 LineStringgetLineSetRepresentativeLocation(List geoms, Geometry displayGeometry)
     1.
public  LineStringgetLongest(ArrayList al)
    
 PointgetPointSetRepresentativeLocation(List geoms, Geometry displayGeometry)
     1.
 PolygongetPolySetRepresentativeLocation(List geoms, Geometry displayGeometry)
     1.
public  doublegetPriority(TextSymbolizer symbolizer, Feature feature)
     get the priority from the symbolizer its an expression, so it will try to evaluate it: 1.
public  booleanisOutlineRenderingEnabled()
    
 LineStringmerge(LineString major, LineString minor)
     if possible, merge the two lines together (ie.
 CollectionmergeLines(Collection lines)
    
 CollectionmergeLines2(Collection lines)
     merges a set of lines together into a (usually) smaller set.
 PointmiddleLine(LineString l, double percent)
     calculate the middle of a line.
 doublemiddleTheta(LineString l, double percent)
     see middlePoint() find the segment that the point is apart of, and return the slope.
public  ListorderedLabels()
     return a list with all the values in priority order.
public  voidprocessNodes(List edges, Hashtable nodes, ArrayList result)
     pull a line from the list, and: 1.
public  voidput(String layerId, TextSymbolizer symbolizer, Feature feature, LiteShape2 shape, Range scaleRange)
    
public  voidputInNodeHash(LineString ls, Hashtable nodes)
    
public  voidremoveFromHash(Hashtable nodes, LineString ls)
    
 ArrayListremoveNulls(List l)
     given a list, return a new list thats the same as the first, but has no null values in it.
 LineStringreverse(LineString l)
    
public  voidsetOutlineRenderingEnabled(boolean outlineRenderingEnabled)
     Sets the text rendering mode.
public  voidstart()
    
public  voidstartLayer(String layerId)
    
public  voidstop()
    

Field Detail
DEFAULT_GROUP
public boolean DEFAULT_GROUP(Code)



DEFAULT_PRIORITY
public double DEFAULT_PRIORITY(Code)



DEFAULT_SPACEAROUND
public int DEFAULT_SPACEAROUND(Code)



MIN_GOODNESS_FIT
public double MIN_GOODNESS_FIT(Code)
labels that arent this good will not be shown



activeLayers
Set activeLayers(Code)



enabledLayers
Set enabledLayers(Code)



labelCache
protected Map labelCache(Code)
Map the label cache



labelCacheNonGrouped
protected ArrayList labelCacheNonGrouped(Code)
non-grouped labels get thrown in here*



lineLengthComparator
LineLengthComparator lineLengthComparator(Code)



outlineRenderingEnabled
protected boolean outlineRenderingEnabled(Code)
When true, the text is rendered as its GlyphVector outline (as a geometry) instead of using drawGlypVector. Pro: labels and halos are perfectly centered, some people prefer the extra antialiasing obtained. Cons: possibly slower, some people do not like the extra antialiasing :)



stop
boolean stop(Code)



styleFactory
protected SLDStyleFactory styleFactory(Code)





Method Detail
clear
public void clear()(Code)



clear
public void clear(String layerId)(Code)



clipLineString
public MultiLineString clipLineString(LineString line, Polygon bbox, Envelope displayGeomEnv)(Code)
try to be more robust dont bother returning points This will try to solve robustness problems, but read code as to what it does. It might return the unclipped line if there's a problem!
Parameters:
  line -
Parameters:
  bbox - MUST BE A BOUNDING BOX



clipPolygon
public MultiPolygon clipPolygon(Polygon poly, Polygon bbox, Envelope displayGeomEnv)(Code)
try to do a more robust way of clipping a polygon to a bounding box. This might return the orginal polygon if it cannot clip TODO: this is a bit simplistic, there's lots more to do.
Parameters:
  poly -
Parameters:
  bbox -
Parameters:
  displayGeomEnv - a MutliPolygon



disableLayer
public void disableLayer(String layerId)(Code)



enableLayer
public void enableLayer(String layerId)(Code)



end
public void end(Graphics2D graphics, Rectangle displayArea)(Code)

See Also:   org.geotools.renderer.lite.LabelCache.end(java.awt.Graphics2Djava.awt.Rectangle)



endLayer
public void endLayer(String layerId, Graphics2D graphics, Rectangle displayArea)(Code)

See Also:   org.geotools.renderer.lite.LabelCache.endLayer(java.awt.Graphics2Djava.awt.Rectangle)



getLineSetRepresentativeLocation
LineString getLineSetRepresentativeLocation(List geoms, Geometry displayGeometry)(Code)
1. make a list of all the geoms (not clipped) NOTE: reject points, convert polygons to their exterior ring (you shouldnt be calling this function with points and polys) 2. join the lines together 3. clip resulting lines to display geometry 4. return longest line NOTE: the joining has multiple solution. For example, consider a Y (3 lines): * * 1 2 * * * 3 * solutions are: 1->2 and 3 1->3 and 2 2->3 and 1 (see mergeLines() below for detail of the algorithm; its basically a greedy algorithm that should form the 'longest' possible route through the linework) NOTE: we clip after joining because there could be connections "going on" outside the display bbox
Parameters:
  geoms -
Parameters:
  displayGeometry - must be poly



getLongest
public LineString getLongest(ArrayList al)(Code)



getPointSetRepresentativeLocation
Point getPointSetRepresentativeLocation(List geoms, Geometry displayGeometry)(Code)
1. get a list of points from the input geometries that are inside the displayGeom NOTE: lines and polygons are reduced to their centroids (you shouldnt really calling this with lines and polys) 2. choose the most "central" of the points METRIC - choose anyone TODO: change metric to be "closest to the centoid of the possible points"
Parameters:
  geoms - list of Point or MultiPoint (any other geometry types arerejected
Parameters:
  displayGeometry - a point or null (if there's nothing to draw)



getPolySetRepresentativeLocation
Polygon getPolySetRepresentativeLocation(List geoms, Geometry displayGeometry)(Code)
1. make a list of all the polygons clipped to the displayGeometry NOTE: reject any points or lines 2. choose the largest of the clipped geometries
Parameters:
  geoms -
Parameters:
  displayGeometry -



getPriority
public double getPriority(TextSymbolizer symbolizer, Feature feature)(Code)
get the priority from the symbolizer its an expression, so it will try to evaluate it: 1. if its missing --> DEFAULT_PRIORITY 2. if its a number, return that number 3. if its not a number, convert to string and try to parse the number; return the number 4. otherwise, return DEFAULT_PRIORITY
Parameters:
  symbolizer -
Parameters:
  feature -



isOutlineRenderingEnabled
public boolean isOutlineRenderingEnabled()(Code)



merge
LineString merge(LineString major, LineString minor)(Code)
if possible, merge the two lines together (ie. their start/end points are equal) returns null if not possible
Parameters:
  major -
Parameters:
  minor -



mergeLines
Collection mergeLines(Collection lines)(Code)



mergeLines2
Collection mergeLines2(Collection lines)(Code)
merges a set of lines together into a (usually) smaller set. This one's pretty dumb, we use the JTS method (which doesnt merge on degree 3 nodes) and try to construct less lines. There's multiple solutions, but we do this the easy way. Usually you will not be given more than 3 lines (especially after jts is finished with). Find a line, find a lines that it "connects" to and add it. Keep going. DONE: be smarter - use length so the algorithm becomes greedy. This isnt 100% correct, but usually it does the right thing. NOTE: this is O(N^2), but N tends to be <10
Parameters:
  lines -



middleLine
Point middleLine(LineString l, double percent)(Code)
calculate the middle of a line. The returning point will be x% (0.5 = 50%) along the line and on the line.
Parameters:
  l -
Parameters:
  percent - 0=start, 0.5=middle, 1.0=end



middleTheta
double middleTheta(LineString l, double percent)(Code)
see middlePoint() find the segment that the point is apart of, and return the slope.
Parameters:
  l -
Parameters:
  percent -



orderedLabels
public List orderedLabels()(Code)
return a list with all the values in priority order. Both grouped and non-grouped



processNodes
public void processNodes(List edges, Hashtable nodes, ArrayList result)(Code)
pull a line from the list, and: 1. if nothing connects to it (its issolated), add it to "result" 2. otherwise, merge it at the start/end with the LONGEST line there. 3. remove the original line, and the lines it merged with from the hashtables 4. go again, with the merged line
Parameters:
  edges -
Parameters:
  nodes -
Parameters:
  result -



put
public void put(String layerId, TextSymbolizer symbolizer, Feature feature, LiteShape2 shape, Range scaleRange)(Code)

See Also:   org.geotools.renderer.lite.LabelCache.put(org.geotools.renderer.style.TextStyle2Dorg.geotools.renderer.lite.LiteShape)



putInNodeHash
public void putInNodeHash(LineString ls, Hashtable nodes)(Code)



removeFromHash
public void removeFromHash(Hashtable nodes, LineString ls)(Code)



removeNulls
ArrayList removeNulls(List l)(Code)
given a list, return a new list thats the same as the first, but has no null values in it.
Parameters:
  l -



reverse
LineString reverse(LineString l)(Code)
reverse direction of points in a line



setOutlineRenderingEnabled
public void setOutlineRenderingEnabled(boolean outlineRenderingEnabled)(Code)
Sets the text rendering mode. When true, the text is rendered as its GlyphVector outline (as a geometry) instead of using drawGlypVector. Pro: labels and halos are perfectly centered, some people prefer the extra antialiasing obtained. Cons: possibly slower, some people do not like the extra antialiasing :)



start
public void start()(Code)

See Also:   org.geotools.renderer.lite.LabelCache.start



startLayer
public void startLayer(String layerId)(Code)

See Also:   org.geotools.renderer.lite.LabelCache.startLayer



stop
public void stop()(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.