48 minx_ = maxx_ = miny_ = maxy_ = 0;
54 out_ <<
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << endl;
55 out_ <<
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD Svg 1.1//EN\"" << endl;
56 out_ <<
"\"http://www.w3.org/Graphics/Svg/1.1/DTD/svg11.dtd\">" << endl;
57 out_ <<
"<svg width=\"" << (maxx_ - minx_) <<
"\" height=\"" << (maxy_ - miny_) <<
"\" version=\"1.1\"" << endl;
58 out_ <<
" xmlns=\"http://www.w3.org/2000/svg\"" << endl;
60 out_ <<
" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"";
63 out_ <<
"<g transform=\"translate(" << (-minx_) <<
"," << (-miny_) <<
")\">" << endl;
65 for(map<
int, vector<string> >::iterator it = layers_.begin(); it != layers_.end(); it++)
67 out_ <<
"<g id=\"layer" << it->first <<
"\"";
70 out_ <<
" inkscape:groupmode=\"layer\"";
73 vector<string> * v = &it->second;
74 for(
unsigned int i = 0; i < v->size(); i++)
76 out_ << (*v)[i] << endl;
78 out_ <<
"</g>" << endl;
80 out_ <<
"</g>" << endl;
82 out_ <<
"</svg>" << endl;
91 string style =
"stroke:" + colorToText(getCurrentForegroundColor()) +
";stroke-width:" +
TextTools::toString(getCurrentPointSize());
92 if(getCurrentLineType() == LINE_DASHED)
93 style +=
";stroke-dasharray:4,4";
94 else if(getCurrentLineType() == LINE_DOTTED)
95 style +=
";stroke-dasharray:1,2";
97 oss <<
"<line x1=\"" << x1 <<
"\" y1=\"" << y1 <<
"\" x2=\"" << x2 <<
"\" y2=\"" << y2 <<
"\" style=\"" << style <<
"\" />";
98 layers_[getCurrentLayer()].push_back(oss.str());
99 if (x1 < minx_) minx_ = x1;
100 if (x2 < minx_) minx_ = x2;
101 if (y1 < miny_) miny_ = y1;
102 if (y2 < miny_) miny_ = y2;
103 if (x1 > maxx_) maxx_ = x1;
104 if (x2 > maxx_) maxx_ = x2;
105 if (y1 > maxy_) maxy_ = y1;
106 if (y2 > maxy_) maxy_ = y2;
115 string style =
"stroke:" + colorToText(getCurrentForegroundColor()) +
";stroke-width:" +
TextTools::toString(getCurrentPointSize());
116 if(fill == FILL_FILLED)
118 style +=
";fill:" + colorToText(getCurrentBackgroundColor());
121 oss <<
"<rect x=\"" << x <<
"\" y=\"" << y <<
"\" width=\"" << width <<
"\" height=\"" << height <<
"\" style=\"" << style <<
"\" />";
122 layers_[getCurrentLayer()].push_back(oss.str());
123 if (x < minx_) minx_ = x;
124 if (y < miny_) miny_ = y;
125 if (x + width > maxx_) maxx_ = x + width;
126 if (y + height > maxy_) maxx_ = y + height;
134 string style =
"stroke:" + colorToText(getCurrentForegroundColor()) +
";stroke-width:" +
TextTools::toString(getCurrentPointSize());
135 if(fill == FILL_FILLED)
137 style +=
";fill:" + colorToText(getCurrentBackgroundColor());
140 oss <<
"<rect cx=\"" << x <<
"\" cy=\"" << y <<
"\" cr=\"" << radius <<
"\" style=\"" << style <<
"\" />";
141 layers_[getCurrentLayer()].push_back(oss.str());
148 string style =
"font-family:" + getCurrentFont().getFamily() +
";font-style:" + fontStyles_[getCurrentFont().getStyle()] +
";font-weight:" + fontWeights_[getCurrentFont().getWeight()] +
";font-size:" +
TextTools::toString(getCurrentFont().getSize()) +
"px";
149 style +=
";dominant-baseline:";
150 if (vpos == TEXT_VERTICAL_BOTTOM)
151 style +=
"before-edge";
152 else if (vpos == TEXT_VERTICAL_TOP)
153 style +=
"after-edge";
154 else if (vpos == TEXT_VERTICAL_CENTER)
156 else throw UnvalidFlagException(
"SvgGraphicDevice::drawText. Invalid vertical alignment option.");
157 style +=
";text-anchor:";
158 if (hpos == TEXT_HORIZONTAL_LEFT)
160 else if (hpos == TEXT_HORIZONTAL_RIGHT)
162 else if (hpos == TEXT_HORIZONTAL_CENTER)
164 else throw UnvalidFlagException(
"SvgGraphicDevice::drawText. Invalid horizontal alignment option.");
165 style +=
";fill:" + colorToText(getCurrentForegroundColor());
168 oss <<
"<text x=\"" << x <<
"\" y=\"" << y <<
"\" rotate=\"" << angle <<
"\" style=\"" << style <<
"\" >" << text <<
"</text>";
169 layers_[getCurrentLayer()].push_back(oss.str());
void drawCircle(double x, double y, double radius, short fill=FILL_EMPTY)
Draw a circle.
void begin()
Start the painting.
void drawRect(double x, double y, double width, double height, short fill=FILL_EMPTY)
Draw a rectangle.
This class allows to perform a correspondence analysis.
void drawLine(double x1, double y1, double x2, double y2)
Draw a line between two points.
static std::string toString(T t)
General template method to convert to a string.
void end()
End the painting.
void drawText(double x, double y, const std::string &text, short hpos=TEXT_HORIZONTAL_LEFT, short vpos=TEXT_VERTICAL_BOTTOM, double angle=0)
Draw some characters.