00001 #pragma ident "$Id: Helper.hpp 1644 2009-01-27 19:26:14Z ckiesch $"
00002
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef VDRAW_HELPER_H
00029 #define VDRAW_HELPER_H
00030
00031 #include "VGImage.hpp"
00032 #include "SVGImage.hpp"
00033 #include "PSImage.hpp"
00034 #include "EPSImage.hpp"
00035
00036 namespace vdraw
00037 {
00040
00045 class Helper
00046 {
00047 public:
00060 static VGImage* create(std::string fname,
00061 double width=VGImage::US_LETTER_WIDTH_PTS,
00062 double height=VGImage::US_LETTER_HEIGHT_PTS,
00063 VGImage::ORIGIN_LOCATION iloc=VGImage::LOWER_LEFT) throw (VDrawException)
00064 {
00065 using namespace std;
00066 size_t i = fname.find_last_of('.');
00067 if ((string::npos != i) && (i != fname.length()-1))
00068 {
00069 string ext = fname.substr(i+1);
00070 if( ext == "ps" )
00071 return new PSImage(fname.c_str(),width,height,iloc);
00072 else if( ext == "eps" )
00073 return new EPSImage(fname.c_str(),0,0,width,height,iloc);
00074 else if( ext == "svg" )
00075 return new SVGImage(fname.c_str(),width,height,iloc);
00076 }
00077 throw VDrawException("Non-supported file name...");
00078 }
00079
00080 };
00081
00083
00084 }
00085
00086 #endif //VDRAW_HELPER_H