|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.web.map.DocumentGenerator
The core of the SVG generation. We get a Vector of MapNode objects, do all our calculations to figure out how to draw the map, where everything goes, and generate the SVG here.
Field Summary | |
private javax.servlet.ServletContext |
ctx
|
private org.w3c.dom.Document |
document
|
private int |
documentHeight
|
private int |
documentWidth
|
private java.util.Hashtable |
iconNames
|
private java.lang.String |
mapType
|
private java.lang.String |
namespace
|
private java.util.Vector |
nodes
|
private java.lang.String |
urlBase
|
Constructor Summary | |
DocumentGenerator()
constructor |
Method Summary | |
private void |
calculateBalancedTreeCoordinates(MapNode parent)
calculate coordinates for all hosts, doing a balanced-tree drawing thingie. |
private void |
calculateBoringHostCoordinates()
do a really stupid and simple "draw hosts left to right, 10 columns by as many rows as necessary |
private void |
calculateDocumentWidthAndHeight()
figure out the width and height of the document |
void |
calculateHostCoordinates()
calculate the coordinates of each node in the map based on the map type |
private void |
calculateTreeHostCoordinates()
start the job of figuring out where on the screen to draw each host by starting to calculate the Balanced Tree coordinates from the root node (node "0") |
private org.w3c.dom.Element |
createHostElement(MapNode n,
boolean loadIcons)
create an SVG subtree, contained inside |
private void |
drawHosts(boolean loadIcons)
generate SVG for each host |
private void |
drawLine(MapNode parent,
MapNode child)
draw a line from parent to child |
private void |
drawLines(MapNode parent)
draw the lines between parents and children |
private int |
findMaxChildWidth(MapNode parent)
figure out the max child width for the map. |
int |
getDocumentHeight()
get the height of the SVG created. |
int |
getDocumentWidth()
get the width of the SVG created. |
org.w3c.dom.Document |
getHostDocument(boolean loadIcons)
create a SVGDOMDocument containing all the elements for each host including icon, hostname, IP address and status. |
java.lang.String |
getImageMap(java.lang.String mapname,
java.lang.String uri)
generate HTML that will output imagemap information for the map that corresponds to the HostDocument created later. |
private boolean |
isChildNode(MapNode parent,
MapNode child)
tell me if a given node is child of another node |
private void |
loadIcons()
load the SVG icon data so we can embed it directly into the SVG we output instead of loading each icon as an external entity. |
private void |
log(java.lang.String message)
log a message. |
private int |
numberOfImmediateParents(MapNode child)
find out how many immediate parent hosts for this host. |
void |
setMapType(java.lang.String type)
set the type of map we want to draw: "tree" or "boring" |
void |
setNodes(java.util.Vector nodes)
set the Vector of nodes that we need to map |
void |
setServletContext(javax.servlet.ServletContext ctx)
set the ServletContext so we can find the path to load icons from the filesystem directly and use the log method. |
void |
setUrlBase(java.lang.String base)
set the URL base so we can create absolute references to content embedded in our SVG |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private int documentWidth
private int documentHeight
private org.w3c.dom.Document document
private java.lang.String namespace
private java.util.Vector nodes
private java.util.Hashtable iconNames
private javax.servlet.ServletContext ctx
private java.lang.String mapType
private java.lang.String urlBase
Constructor Detail |
public DocumentGenerator()
Method Detail |
private void log(java.lang.String message)
public void setNodes(java.util.Vector nodes)
public void setServletContext(javax.servlet.ServletContext ctx)
public void setUrlBase(java.lang.String base)
public void setMapType(java.lang.String type)
private void loadIcons()
private boolean isChildNode(MapNode parent, MapNode child)
parent
- the parent node you are testing for the parent-child
relationshipchild
- the child node you are testing for the parent-child
relationshipprivate int numberOfImmediateParents(MapNode child)
child
- the child node for which you wish to find the number of
parentsprivate int findMaxChildWidth(MapNode parent)
parent
- the parent node for which you wish to find the maximum width
of children somewhere down its tree of child nodesprivate void calculateBalancedTreeCoordinates(MapNode parent)
parent
- the parent node for which you will start to calculate the rest
of the tree coordinatesprivate void calculateTreeHostCoordinates()
private void calculateBoringHostCoordinates()
private void drawLine(MapNode parent, MapNode child)
parent
- the starting point of the linechild
- the ending point of the lineprivate void drawLines(MapNode parent)
private void drawHosts(boolean loadIcons)
loadIcons
- tell me whether I should generate file:// references to load
icons from the filesystem or generate URL references. "true"
will generate file:// references for when we are sending the
output to the Batik Transcoder, while "false" will generate
http:// references for when we are downloading the SVG
directly into an external viewer.private void calculateDocumentWidthAndHeight()
private org.w3c.dom.Element createHostElement(MapNode n, boolean loadIcons)
loadIcons
- tell me whether I should generate file:// references to load
icons from the filesystem or generate URL references. "true"
will generate file:// references for when we are sending the
output to the Batik Transcoder, while "false" will generate
http:// references for when we are downloading the SVG
directly into an external viewer.public void calculateHostCoordinates()
public java.lang.String getImageMap(java.lang.String mapname, java.lang.String uri)
mapname
- the "name" of the HTML element that will have the imagemap
attached. e.g. public org.w3c.dom.Document getHostDocument(boolean loadIcons)
loadIcons
- tell me whether I should load the icons from the filesystem
(true) or generate them as URLs (false)public int getDocumentWidth()
public int getDocumentHeight()
|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |