Rev 370 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
* Copyright (C) 2014 Steve Ratcliffe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 or
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
package test.svg.nod;
import org.dom4j.Element;
import test.svg.SvgDoc;
/**
* Holds the SVG document.
*
* Various elements are saved as fields, so that information can be added later.
*
* @author Steve Ratcliffe
*/
public class SvgRouteDoc
extends SvgDoc
{
// Layers for drawing to
private Element routing
; // The layer used to draw the route network
private Element roads
; // For roads
private Element info
; // For information boxes
private Element spokes
; // Lines from node to its center.
private Element marked
; // Routing info for the marked nodes.
protected void addLayers
(Element svg
) {
spokes = svg.
addElement("g")
.
addAttribute("inkscape:label",
"center spokes")
.
addAttribute("style",
"display:none")
.
addAttribute("inkscape:groupmode",
"layer");
roads = svg.
addElement("g")
.
addAttribute("inkscape:label",
"roads")
.
addAttribute("opacity",
"0.4")
.
addAttribute("inkscape:groupmode",
"layer");
marked = svg.
addElement("g")
.
addAttribute("inkscape:label",
"marked")
.
addAttribute("z-index",
"10")
.
addAttribute("inkscape:groupmode",
"layer");
routing = svg.
addElement("g")
.
addAttribute("inkscape:label",
"routing")
.
addAttribute("inkscape:groupmode",
"layer");
info = svg.
addElement("g")
.
addAttribute("inkscape:label",
"info")
.
addAttribute("inkscape:groupmode",
"layer");
}
public Element getRouting
() {
return routing
;
}
public Element getRoads
() {
return roads
;
}
public Element getInfo
() {
return info
;
}
public Element getSpokes
() {
return spokes
;
}
public void setTransform
(int leftOffset,
int topOffset
) {
int MARGIN =
30;
String translate =
String.
format("translate(%d,%d)", MARGIN - leftOffset, MARGIN - topOffset
);
spokes.
addAttribute("transform", translate
);
routing.
addAttribute("transform", translate
);
roads.
addAttribute("transform", translate
);
info.
addAttribute("transform", translate
);
marked.
addAttribute("transform", translate
);
}
public Element getMarked
() {
return marked
;
}
}