2010-08-10 08:25:09 +00:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
|
|
|
*
|
2011-10-23 13:04:25 +00:00
|
|
|
* Copyright (C) 2011 Artem Pavlenko
|
2010-08-10 08:25:09 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
// mapnik
|
2012-11-01 17:05:50 +00:00
|
|
|
#include <mapnik/svg/output/svg_output_attributes.hpp>
|
2010-08-10 08:25:09 +00:00
|
|
|
|
|
|
|
namespace mapnik { namespace svg {
|
|
|
|
|
|
|
|
// path_output_attributes
|
|
|
|
|
|
|
|
void path_output_attributes::set_fill_color(color const& fill_color)
|
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
fill_color_ = fill_color.to_hex_string();
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
void path_output_attributes::set_fill_opacity(double fill_opacity)
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
fill_opacity_ = fill_opacity;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void path_output_attributes::set_stroke_color(color const& stroke_color)
|
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
stroke_color_ = stroke_color.to_hex_string();
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
void path_output_attributes::set_stroke_opacity(double stroke_opacity)
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
stroke_opacity_ = stroke_opacity;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
void path_output_attributes::set_stroke_width(double stroke_width)
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
stroke_width_ = stroke_width;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
2012-02-02 01:53:35 +00:00
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
void path_output_attributes::set_stroke_linecap(line_cap_e stroke_linecap)
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2012-02-02 01:53:35 +00:00
|
|
|
switch(stroke_linecap)
|
|
|
|
{
|
|
|
|
case BUTT_CAP:
|
|
|
|
stroke_linecap_ = "butt";
|
|
|
|
break;
|
|
|
|
case SQUARE_CAP:
|
|
|
|
stroke_linecap_ = "square";
|
|
|
|
break;
|
|
|
|
case ROUND_CAP:
|
|
|
|
stroke_linecap_ = "round";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
stroke_linecap_ = "butt";
|
|
|
|
}
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
void path_output_attributes::set_stroke_linejoin(line_join_e stroke_linejoin)
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2012-02-02 01:53:35 +00:00
|
|
|
switch(stroke_linejoin)
|
|
|
|
{
|
|
|
|
case MITER_JOIN:
|
|
|
|
stroke_linejoin_ = "miter";
|
|
|
|
break;
|
|
|
|
case MITER_REVERT_JOIN:
|
|
|
|
stroke_linejoin_ = "miter";
|
|
|
|
break;
|
|
|
|
case ROUND_JOIN:
|
|
|
|
stroke_linejoin_ = "round";
|
|
|
|
break;
|
|
|
|
case BEVEL_JOIN:
|
|
|
|
stroke_linejoin_ = "bevel";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
stroke_linejoin_ = "miter";
|
|
|
|
}
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
void path_output_attributes::set_stroke_dasharray(dash_array const& stroke_dasharray)
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
stroke_dasharray_ = stroke_dasharray;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
void path_output_attributes::set_stroke_dashoffset(double stroke_dashoffset)
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
stroke_dashoffset_ = stroke_dashoffset;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
std::string const& path_output_attributes::fill_color() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return fill_color_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
2011-05-04 15:53:36 +00:00
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
double path_output_attributes::fill_opacity() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return fill_opacity_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
std::string const& path_output_attributes::stroke_color() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return stroke_color_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
2011-05-04 15:53:36 +00:00
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
double path_output_attributes::stroke_opacity() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return stroke_opacity_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
double path_output_attributes::stroke_width() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return stroke_width_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
2011-05-04 15:53:36 +00:00
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
std::string const& path_output_attributes::stroke_linecap() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return stroke_linecap_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
std::string const& path_output_attributes::stroke_linejoin() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return stroke_linejoin_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
dash_array const& path_output_attributes::stroke_dasharray() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return stroke_dasharray_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
double path_output_attributes::stroke_dashoffset() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return stroke_dashoffset_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void path_output_attributes::reset()
|
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
fill_color_ = "none";
|
|
|
|
fill_opacity_ = 1.0;
|
|
|
|
stroke_color_ = "none";
|
|
|
|
stroke_opacity_ = 1.0;
|
|
|
|
stroke_width_ = 0.0;
|
|
|
|
stroke_linecap_ = "butt";
|
|
|
|
stroke_linejoin_ = "miter";
|
|
|
|
stroke_dasharray_.clear();
|
|
|
|
stroke_dashoffset_ = 0.0;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// rect_output_attributes
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
void rect_output_attributes::set_x(int x)
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
x_ = x;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
2011-05-04 15:53:36 +00:00
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
void rect_output_attributes::set_y(int y)
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
y_ = y;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
void rect_output_attributes::set_width(unsigned width)
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
width_ = width;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
2011-05-04 15:53:36 +00:00
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
void rect_output_attributes::set_height(unsigned height)
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
height_ = height;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void rect_output_attributes::set_fill_color(color const& fill_color)
|
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
fill_color_ = fill_color.to_hex_string();
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
int rect_output_attributes::x() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return x_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
2011-05-04 15:53:36 +00:00
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
int rect_output_attributes::y() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return y_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
int rect_output_attributes::width() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return width_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
int rect_output_attributes::height() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return height_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
std::string const& rect_output_attributes::fill_color() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return fill_color_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void rect_output_attributes::reset()
|
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
x_ = 0;
|
|
|
|
y_ = 0;
|
|
|
|
width_ = 400;
|
|
|
|
height_ = 400;
|
|
|
|
fill_color_ = "#000000";
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// rect_output_attributes
|
|
|
|
|
2012-02-02 01:53:35 +00:00
|
|
|
const double root_output_attributes::SVG_VERSION = 1.1;
|
|
|
|
const std::string root_output_attributes::SVG_NAMESPACE_URL = "http://www.w3.org/2000/svg";
|
2010-08-10 08:25:09 +00:00
|
|
|
|
|
|
|
root_output_attributes::root_output_attributes()
|
2012-02-02 01:53:35 +00:00
|
|
|
: width_(400),
|
|
|
|
height_(400),
|
|
|
|
svg_version_(SVG_VERSION),
|
|
|
|
svg_namespace_url_(SVG_NAMESPACE_URL)
|
2010-08-10 08:25:09 +00:00
|
|
|
{}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
root_output_attributes::root_output_attributes(unsigned width, unsigned height)
|
2012-02-02 01:53:35 +00:00
|
|
|
: width_(width),
|
|
|
|
height_(height),
|
|
|
|
svg_version_(SVG_VERSION),
|
|
|
|
svg_namespace_url_(SVG_NAMESPACE_URL)
|
2010-08-10 08:25:09 +00:00
|
|
|
{}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
void root_output_attributes::set_width(unsigned width)
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
width_ = width;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
void root_output_attributes::set_height(unsigned height)
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
height_ = height;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
void root_output_attributes::set_svg_version(double svg_version)
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
svg_version_ = svg_version;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void root_output_attributes::set_svg_namespace_url(std::string const& svg_namespace_url)
|
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
svg_namespace_url_ = svg_namespace_url;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
unsigned root_output_attributes::width() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return width_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
unsigned root_output_attributes::height() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return height_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
double root_output_attributes::svg_version() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return svg_version_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 20:01:14 +00:00
|
|
|
std::string const& root_output_attributes::svg_namespace_url() const
|
2010-08-10 08:25:09 +00:00
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
return svg_namespace_url_;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void root_output_attributes::reset()
|
|
|
|
{
|
2011-05-04 15:53:36 +00:00
|
|
|
width_ = 400;
|
|
|
|
height_ = 400;
|
|
|
|
svg_version_ = SVG_VERSION;
|
|
|
|
svg_namespace_url_ = SVG_NAMESPACE_URL;
|
2010-08-10 08:25:09 +00:00
|
|
|
}
|
2012-02-02 01:53:35 +00:00
|
|
|
}}
|