コード例 #1
0
ファイル: SVGImage.cpp プロジェクト: loongfee/ossim-svn
  std::string SVGImage::convertStrokeStyle (const StrokeStyle& ss) const
  {
    using namespace std;
    stringstream ostr(stringstream::in | stringstream::out); 

    if(ss.getColor().isClear())
    {
      ostr << "stroke-opacity:0;";
      return string(ostr.str());        
    }

    // Color
    if(ss.getColor()!=Color::BLACK)
    {
      ostr << "stroke:rgb(";
      short red, blue, green;
      ss.getColor().getRGBTriplet(red, blue, green);
      ostr << red << "," << blue << "," << green;
      ostr << ");";
    }

    // Width
    if(ss.getWidth()!=1)
      ostr << "stroke-width:" << ss.getWidth() << "pt;";

    if (!ss.getSolid())
    {
      // Dash array list: comma separated variables
      ostr << "stroke-dasharray:";

      StrokeStyle::dashLengthList dll=ss.getDashList();
      StrokeStyle::dashLengthList::iterator i, inext;

      for (i=dll.begin(); i!=dll.end(); i++)
      {
        ostr << (i==dll.begin()?"":",") << *i;
        inext = i; inext++; 
        if (inext!=dll.end())
          cout << ",";
      }
      // Final delimiter
      ostr << ";";   
    }

    return string(ostr.str());
  }