Add init_alignment() function.

This commit is contained in:
Hermann Kraus 2012-07-28 02:04:01 +02:00
parent 716dd1c79e
commit 6b3810c9b0
2 changed files with 55 additions and 0 deletions

View file

@ -101,6 +101,7 @@ public:
bool next_position();
private:
void init_alignment();
Feature const& feature_;
DetectorType const& detector_;
box2d<double> const& extent_;
@ -108,6 +109,10 @@ private:
text_layout layout_;
text_placement_info_ptr info_;
bool valid_;
vertical_alignment_e valign_;
horizontal_alignment_e halign_;
justify_alignment_e jalign_;
};
typedef boost::shared_ptr<placement_finder_ng> placement_finder_ng_ptr;

View file

@ -68,10 +68,60 @@ bool placement_finder_ng::next_position()
} else {
angle_ = 0.0;
}
init_alignment();
return true;
}
void placement_finder_ng::init_alignment()
{
text_symbolizer_properties const& p = info_->properties;
valign_ = p.valign;
if (valign_ == V_AUTO)
{
if (p.displacement.second > 0.0)
{
valign_ = V_BOTTOM;
} else if (p.displacement.second < 0.0)
{
valign_ = V_TOP;
} else
{
valign_ = V_MIDDLE;
}
}
halign_ = p.halign;
if (halign_ == H_AUTO)
{
if (p.displacement.first > 0.0)
{
halign_ = H_RIGHT;
} else if (p.displacement.first < 0.0)
{
halign_ = H_LEFT;
} else
{
halign_ = H_MIDDLE;
}
}
jalign_ = p.jalign;
if (jalign_ == J_AUTO)
{
if (p.displacement.first > 0.0)
{
jalign_ = J_LEFT;
} else if (p.displacement.first < 0.0)
{
jalign_ = J_RIGHT;
} else {
jalign_ = J_MIDDLE;
}
}
}
glyph_positions::glyph_positions()
: base_point_(), const_angle_(true)
{