56 contentStarted_(false),
89 bool comp(
int a,
int b ) {
return a > b; } ;
98 out_ <<
"\\documentclass{article}" << endl;
99 out_ <<
"% This figure was generated by the Bio++ Pgf Graphic Device." << endl;
100 out_ <<
"% Althought this file can be compiled 'as is' it may not be displayed correctly, depending on the size of the picture." << endl;
101 out_ <<
"% You may consider copying the pgfpicture environment to your own LaTeX file and play with pgf settings (e.g. the pgfpages module)." << endl;
102 out_ <<
"% You can also use the geometry package, for instance:" << endl;
103 out_ <<
"% \\usepackage[a3paper]{geometry}" << endl;
104 out_ <<
"\\usepackage{pgf}" << endl;
107 if(it->second.substr(0,3) ==
"use")
108 out_ <<
"\\definecolor{" << it->second <<
"}{rgb}{" << it->first[0]/255. <<
"," << it->first[1]/255. <<
"," << it->first[2]/255. <<
"}" << endl;
110 out_ <<
"\\begin{document}" << endl;
117 for(
unsigned int i = 0; i <
layers_.size(); i++)
119 if(i > 0) tmp +=
",";
121 out_ <<
"\\pgfdeclarelayer{" <<
layers_[i] <<
"}" << endl;
123 out_ <<
"\\pgfsetlayers{" << tmp <<
"}" << endl;
127 out_ <<
"\\begin{pgfpicture}" << endl;
128 out_ <<
"\\pgfsetxvec{\\pgfpoint{" <<
getXUnit() <<
"cm}{0cm}}" << endl;
129 out_ <<
"\\pgfsetyvec{\\pgfpoint{0cm}{-" <<
getYUnit() <<
"cm}}" << endl;
131 for(
unsigned int i = 0; i <
content_.size(); i++)
136 out_ <<
"\\end{pgfpicture}" << endl;
137 out_ <<
"\\end{document}" << endl;
142 map<const RGBColor, string>::iterator it =
colorIndex_.find(color);
155 oss <<
"\\pgfsetstrokecolor{" <<
fgColorStr_ <<
"}" << endl;
161 map<const RGBColor, string>::iterator it =
colorIndex_.find(color);
174 oss <<
"\\pgfsetfillcolor{" <<
bgColorStr_ <<
"}" << endl;
182 oss <<
"\\fontfamily{" << font.
getFamily() <<
"}" << endl;
185 oss <<
"\\fontsize{" << font.
getSize() <<
"}{" << font.
getSize() <<
"}" << endl;
186 oss <<
"\\selectfont" << endl;
194 oss <<
"\\pgfsetlinewidth{" <<
x_(size) <<
"}" << endl;
201 if(type == LINE_SOLID)
204 oss <<
"\\pgfsetdash{}{0pt}" << endl;
205 content_.push_back(oss.str());
207 else if(type == LINE_DASHED)
210 oss <<
"\\pgfsetdash{{3mm}{2mm}}{0pt}" << endl;
211 content_.push_back(oss.str());
213 else if(type == LINE_DOTTED)
216 oss <<
"\\pgfsetdash{{" << (x_(getCurrentPointSize())) <<
"}{" << (x_(getCurrentPointSize())) <<
"}}{0pt}" << endl;
217 content_.push_back(oss.str());
225 throw Exception(
"PgfGraphicDevice::setCurrentLayer. A layer is specified after some content has been already added, this would result in a corrupted display.");
231 oss <<
"\\pgfsetstrokecolor{" <<
fgColorStr_ <<
"}" << endl;
232 oss <<
"\\pgfsetfillcolor{" <<
bgColorStr_ <<
"}" << endl;
243 oss <<
"\\pgfpathmoveto{\\pgfpointxy{" << x1 <<
"}{" << y1 <<
"}}" << endl;
244 oss <<
"\\pgfpathlineto{\\pgfpointxy{" << x2 <<
"}{" << y2 <<
"}}" << endl;
245 oss <<
"\\pgfpathclose" << endl;
246 oss <<
"\\pgfusepath{stroke}" << endl;
254 oss <<
"\\pgfpathrectangle{\\pgfpointxy{" << x <<
"}{" << y <<
"}}{\\pgfpointxy{" << width <<
"}{" << height <<
"}}" << endl;
256 oss <<
"\\pgfusepath{stroke,fill}" << endl;
258 oss <<
"\\pgfusepath{stroke}" << endl;
266 oss <<
"\\pgfpathcircle{\\pgfpointxy{" << x <<
"}{" << y <<
"}}{" << radius <<
"}" << endl;
268 oss <<
"\\pgfusepath{stroke,fill}" << endl;
270 oss <<
"\\pgfusepath{stroke}" << endl;
278 if(vpos == TEXT_VERTICAL_BOTTOM)
280 else if(vpos == TEXT_VERTICAL_TOP)
282 else if(vpos == TEXT_VERTICAL_CENTER)
284 else throw UnvalidFlagException(
"PgfGraphicDevice::drawText. Invalid vertical alignment option.");
285 if(hpos == TEXT_HORIZONTAL_LEFT)
287 else if(hpos == TEXT_HORIZONTAL_RIGHT)
289 else if(hpos == TEXT_HORIZONTAL_CENTER)
291 else throw UnvalidFlagException(
"PgfGraphicDevice::drawText. Invalid horizontal alignment option.");
294 oss <<
"\\pgftransformrotate{" << angle <<
"}" << endl;
295 oss <<
"\\pgftext[" << anchor <<
",at=\\pgfpointxy{" << x <<
"}{" << y <<
"}]{\\textcolor{" << fgColorStr_ <<
"}" << text <<
"}" << endl;
296 content_.push_back(oss.str());
297 contentStarted_ =
true;
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.
static const short int WEIGHT_NORMAL
static const short int STYLE_NORMAL
void drawRect(double x, double y, double width, double height, short fill=FILL_EMPTY)
Draw a rectangle.
Data structure for fonts.
void end()
End the painting.
std::map< const RGBColor, std::string > colorIndex_
This class allows to perform a correspondence analysis.
void drawCircle(double x, double y, double radius, short fill=FILL_EMPTY)
Draw a circle.
const short int getShape() const
Alias function for getStyle.
std::map< short int, std::string > fontShapes_
void setCurrentFont(const Font &font)
void setCurrentForegroundColor(const RGBColor &color)
const short int getSeries() const
Alias function for getWeight.
void setCurrentBackgroundColor(const RGBColor &color)
Describe a color according to its red, green and blue componants.
static const short int STYLE_ITALIC
double x_(double x) const
static std::string toString(T t)
General template method to convert to a string.
int getCurrentLayer() const
void setCurrentLineType(short type)
std::vector< std::string > content_
void setCurrentLayer(int layerIndex)
static const short int WEIGHT_BOLD
void setCurrentPointSize(unsigned int size)
void setCurrentForegroundColor(const RGBColor &color)
const unsigned int & getSize() const
void setCurrentLayer(int layerIndex)
std::map< short int, std::string > fontSeries_
void begin()
Start the painting.
std::vector< int > layers_
void setCurrentPointSize(unsigned int size)
PgfGraphicDevice(std::ostream &out, double unit)
Build a new Pgf device object.
const std::string & getFamily() const
void setCurrentBackgroundColor(const RGBColor &color)
void drawLine(double x1, double y1, double x2, double y2)
Draw a line between two points.
void setCurrentLineType(short type)
void setCurrentFont(const Font &font)