Board 0.9.6
Public Member Functions | Protected Attributes | List of all members
LibBoard::Text Struct Reference

A piece of text. More...

#include <Text.h>

Inheritance diagram for LibBoard::Text:
LibBoard::ShapeWithStyle LibBoard::Shape

Public Member Functions

 Text (double x, double y, const std::string &text, const Fonts::Font font, double size, Color color=Color::Black)
 
 Text (Point p, const std::string &text, const Fonts::Font font, double size, Color color=Color::Black)
 
 Text (double x, double y, const std::string &text, const Fonts::Font font, const std::string &svgFont, double size, Color color=Color::Black)
 
 Text (Point p, const std::string &text, const Fonts::Font font, const std::string &svgFont, double size, Color color=Color::Black)
 
const std::string & name () const override
 
Point center (LineWidthFlag lineWidthFlag=IgnoreLineWidth) const override
 
Textrotate (double angle, const Point &center) override
 
Text rotated (double angle, const Point &center) const
 
Textrotate (double angle) override
 
Text rotated (double angle) const
 
Texttranslate (double dx, double dy) override
 
Text translated (double dx, double dy) const
 
Textscale (double sx, double sy) override
 
Textscale (double s) override
 
Text scaled (double sx, double sy) const
 
Text scaled (double s) const
 
void scaleAll (double s) override
 
void flushPostscript (std::ostream &stream, const TransformEPS &transform) const override
 
void flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< Color, int > &colormap) const override
 
void flushSVG (std::ostream &stream, const TransformSVG &transform) const override
 
void flushTikZ (std::ostream &stream, const TransformTikZ &transform) const override
 
virtual void accept (ShapeVisitor &visitor) override
 Accepts a visitor object.
 
virtual void accept (const ShapeVisitor &visitor) override
 Accepts a visitor object.
 
virtual void accept (ConstShapeVisitor &visitor) const override
 Accepts a const-shape visitor object.
 
virtual void accept (const ConstShapeVisitor &visitor) const override
 Accepts a const-shape visitor object.
 
virtual Shapeaccept (CompositeShapeTransform &transform) const override
 Accept a composite shape transform.
 
virtual Shapeaccept (const CompositeShapeTransform &transform) const override
 Accept a constant composite shape transform.
 
Rect boundingBox (LineWidthFlag) const override
 
Textclone () const override
 
 Text (const Text &)=default
 
 Text (Text &&)=default
 
Textoperator= (Text &&)=default
 
Textoperator= (const Text &)=default
 
 ~Text () override=default
 
- Public Member Functions inherited from LibBoard::ShapeWithStyle
 ShapeWithStyle (Color penColor, Color fillColor, double lineWidth, LineStyle style, const LineCap cap, const LineJoin join)
 
 ShapeWithStyle (const Style &style)
 
 ShapeWithStyle (const ShapeWithStyle &other)
 
ShapeWithStyleoperator= (const ShapeWithStyle &other)
 
 ~ShapeWithStyle ()
 
const std::string & name () const
 
Shapeclone () const =0
 
const ColorpenColor () const
 
ShapeWithStylesetPenColor (const Color &)
 
const ColorfillColor () const
 
ShapeWithStylesetFillColor (const Color &)
 
double lineWidth () const
 
ShapeWithStylesetLineWidth (double)
 
LineStyle lineStyle () const
 
ShapeWithStylesetLineStyle (LineStyle)
 
LineCap lineCap () const
 
ShapeWithStylesetLineCap (LineCap)
 
LineJoin lineJoin () const
 
ShapeWithStylesetLineJoin (LineJoin)
 
Style style () const
 
ShapeWithStylesetStyle (const Style &)
 
bool filled () const
 
- Public Member Functions inherited from LibBoard::Shape
 Shape ()
 
virtual ~Shape ()
 
virtual const std::string & name () const
 
virtual Shapeclone () const =0
 
virtual Point center (LineWidthFlag lineWidthFlag=IgnoreLineWidth) const
 
virtual Shaperotate (double angle, const Point &center)=0
 
virtual Shaperotate (double angle)=0
 
ShaperotateDeg (double angle, const Point &center)
 
ShaperotateDeg (double angle)
 
virtual Shapetranslate (double dx, double dy)=0
 
ShapemoveCenter (double x, double y, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
ShapemoveCenter (Point p, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
virtual Shapescale (double sx, double sy)=0
 
virtual Shapescale (double s)=0
 
Shaperesize (double width, double height, LineWidthFlag lineWidthFlag)
 
ShapescaleToWidth (double w, LineWidthFlag lineWidthFlag)
 
ShapescaleToHeight (double h, LineWidthFlag lineWidthFlag)
 
virtual Rect boundingBox (LineWidthFlag) const =0
 
Rect bbox (LineWidthFlag) const
 
virtual void scaleAll (double s)=0
 
virtual void flushPostscript (std::ostream &stream, const TransformEPS &transform) const =0
 
virtual void flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< Color, int > &colormap) const =0
 
virtual void flushSVG (std::ostream &stream, const TransformSVG &transform) const =0
 
virtual void flushTikZ (std::ostream &stream, const TransformTikZ &transform) const =0
 
virtual void accept (ShapeVisitor &visitor)
 Accepts a visitor object.
 
virtual void accept (const ShapeVisitor &visitor)
 Accepts a visitor object.
 
virtual void accept (ConstShapeVisitor &visitor) const
 Accepts a const-shape visitor object.
 
virtual void accept (const ConstShapeVisitor &visitor) const
 Accepts a const-shape visitor object.
 
virtual Shapeaccept (CompositeShapeTransform &transform) const
 Accept a composite shape transform.
 
virtual Shapeaccept (const CompositeShapeTransform &transform) const
 Accept a constant composite shape transform.
 
 Shape (const Shape &other)
 

Protected Attributes

std::string _text
 
Fonts::Font _font
 
std::string _svgFont
 
double _size
 
double _xScale
 
double _yScale
 
Path _box
 
- Protected Attributes inherited from LibBoard::ShapeWithStyle
Style _style
 

Additional Inherited Members

- Static Public Member Functions inherited from LibBoard::ShapeWithStyle
static void setLineWidthScaling (bool)
 
- Protected Member Functions inherited from LibBoard::ShapeWithStyle
void updateLineWidth (double s)
 

Detailed Description

A piece of text.

The text structure.

Examples
examples/example2.cpp, examples/images.cpp, examples/logo.cpp, examples/ruler.cpp, examples/stroke_path.cpp, and examples/traversal.cpp.

Constructor & Destructor Documentation

◆ Text() [1/6]

LibBoard::Text::Text ( double  x,
double  y,
const std::string &  text,
const Fonts::Font  font,
double  size,
Color  color = Color::Black 
)

Create a Text sctucture.

Parameters
xx-coordinate of the bottom-left corner.
yy-coordinate of the bottom-left corner.
text
font
size
color

References _box, LibBoard::Path::close(), and text().

◆ Text() [2/6]

LibBoard::Text::Text ( Point  p,
const std::string &  text,
const Fonts::Font  font,
double  size,
Color  color = Color::Black 
)

Create a Text sctucture.

Parameters
pPosition of the bottom-left corner.
text
font
size
color

References _box, LibBoard::Path::close(), and text().

◆ Text() [3/6]

LibBoard::Text::Text ( double  x,
double  y,
const std::string &  text,
const Fonts::Font  font,
const std::string &  svgFont,
double  size,
Color  color = Color::Black 
)

Create a Text sctucture.

Parameters
xx-coordinate of the bottom-left corner.
yy-coordinate of the bottom-left corner.
text
font
svgFontThe font family for an SVG file. (E.g. "Verdana, Arial" or "'Time New Roman', Serif" )
size
color

References _box, LibBoard::Path::close(), and text().

◆ Text() [4/6]

LibBoard::Text::Text ( Point  p,
const std::string &  text,
const Fonts::Font  font,
const std::string &  svgFont,
double  size,
Color  color = Color::Black 
)

Create a Text sctucture.

Parameters
pPosition of the bottom-left corner.
text
font
svgFontThe font family for an SVG file. (E.g. "Verdana, Arial" or "'Time New Roman', Serif" )
size
color

References _box, LibBoard::Path::close(), and text().

◆ Text() [5/6]

LibBoard::Text::Text ( const Text )
default

◆ Text() [6/6]

LibBoard::Text::Text ( Text &&  )
default

◆ ~Text()

LibBoard::Text::~Text ( )
overridedefault

Member Function Documentation

◆ accept() [1/6]

Shape * LibBoard::Text::accept ( CompositeShapeTransform transform) const
overridevirtual

Accept a composite shape transform.

Parameters
transformA composite shape transform object.

Reimplemented from LibBoard::Shape.

References LibBoard::CompositeShapeTransform::map().

◆ accept() [2/6]

Shape * LibBoard::Text::accept ( const CompositeShapeTransform transform) const
overridevirtual

Accept a constant composite shape transform.

Parameters
transformA constant composite shape transform object..

Reimplemented from LibBoard::Shape.

References LibBoard::CompositeShapeTransform::map().

◆ accept() [3/6]

void LibBoard::Text::accept ( const ConstShapeVisitor visitor) const
overridevirtual

Accepts a const-shape visitor object.

Parameters
visitorA const-shape visitor object.

Reimplemented from LibBoard::Shape.

References LibBoard::ConstShapeVisitor::visit().

◆ accept() [4/6]

void LibBoard::Text::accept ( const ShapeVisitor visitor)
overridevirtual

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

References LibBoard::ShapeVisitor::visit().

◆ accept() [5/6]

void LibBoard::Text::accept ( ConstShapeVisitor visitor) const
overridevirtual

Accepts a const-shape visitor object.

Parameters
visitorA const-shape visitor object.

Reimplemented from LibBoard::Shape.

References LibBoard::ConstShapeVisitor::visit().

◆ accept() [6/6]

void LibBoard::Text::accept ( ShapeVisitor visitor)
overridevirtual

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

References LibBoard::ShapeVisitor::visit().

◆ boundingBox()

Rect LibBoard::Text::boundingBox ( LineWidthFlag  ) const
overridevirtual

Compute the bounding box of the figure.

Returns
The rectangle of the bounding box.

Implements LibBoard::Shape.

References _box, and LibBoard::Path::boundingBox().

◆ center()

Point LibBoard::Text::center ( LineWidthFlag  lineWidthFlag = IgnoreLineWidth) const
overridevirtual

Returns the center of the shape.

Parameters
lineWidthFlagShould the line width be considered when computing bounding boxes.
Returns
The center of the shape, i.e. the center of its bounding box.

Reimplemented from LibBoard::Shape.

References _box, and LibBoard::Path::center().

Referenced by rotate(), and rotated().

◆ clone()

Text * LibBoard::Text::clone ( ) const
overridevirtual

Return a copy of the shape.

Returns
A copy of the shape.

Implements LibBoard::ShapeWithStyle.

◆ flushFIG()

void LibBoard::Text::flushFIG ( std::ostream &  stream,
const TransformFIG transform,
std::map< Color, int > &  colormap 
) const
overridevirtual

Write the FIG code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.
colormap

Implements LibBoard::Shape.

References _font, _text, LibBoard::Transform::mapX(), LibBoard::TransformFIG::mapY(), LibBoard::ShapeWithStyle::penColor(), and LibBoard::TransformFIG::shapeDepth().

◆ flushPostscript()

void LibBoard::Text::flushPostscript ( std::ostream &  stream,
const TransformEPS transform 
) const
overridevirtual

Write the EPS code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

References _font, _text, M_PI, LibBoard::Transform::mapX(), LibBoard::TransformEPS::mapY(), LibBoard::ShapeWithStyle::penColor(), LibBoard::Color::postscript(), and LibBoard::PSFontNames.

◆ flushSVG()

void LibBoard::Text::flushSVG ( std::ostream &  stream,
const TransformSVG transform 
) const
overridevirtual

Write the SVG code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

References _font, _svgFont, _text, LibBoard::ShapeWithStyle::fillColor(), M_PI, LibBoard::Transform::mapX(), LibBoard::TransformSVG::mapY(), LibBoard::ShapeWithStyle::penColor(), LibBoard::PSFontNames, LibBoard::Color::svg(), and LibBoard::Color::svgAlpha().

◆ flushTikZ()

void LibBoard::Text::flushTikZ ( std::ostream &  stream,
const TransformTikZ transform 
) const
overridevirtual

Write the TikZ code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

References _font, LibBoard::ShapeWithStyle::_style, _text, LibBoard::Transform::mapX(), LibBoard::TransformSVG::mapY(), and LibBoard::Style::tikzProperties().

◆ name()

const std::string & LibBoard::Text::name ( ) const
overridevirtual

Returns the generic name of the shape (e.g., Circle, Rectangle, etc.)

Returns

Reimplemented from LibBoard::ShapeWithStyle.

◆ operator=() [1/2]

Text & LibBoard::Text::operator= ( const Text )
default

◆ operator=() [2/2]

Text & LibBoard::Text::operator= ( Text &&  )
default

◆ rotate() [1/2]

Text & LibBoard::Text::rotate ( double  angle)
overridevirtual

Rotate the shape around its center.

Parameters
angleThe rotation angle in radian.
Returns
A reference to the shape itself.

Implements LibBoard::Shape.

References _box, and LibBoard::Path::rotate().

◆ rotate() [2/2]

Text & LibBoard::Text::rotate ( double  angle,
const Point center 
)
overridevirtual

Rotate the shape around a given center of rotation.

Parameters
angleThe rotation angle in radian.
centerThe center of rotation.
Returns
A reference to the shape itself.

Implements LibBoard::Shape.

References _box, center(), and LibBoard::Path::rotate().

Referenced by rotated(), and rotated().

◆ rotated() [1/2]

Text LibBoard::Text::rotated ( double  angle) const

References rotate().

◆ rotated() [2/2]

Text LibBoard::Text::rotated ( double  angle,
const Point center 
) const

References center(), and rotate().

◆ scale() [1/2]

Text & LibBoard::Text::scale ( double  s)
overridevirtual

Scale the text, given a scaling factor.

Parameters
sScaling factor.
Returns
A reference to the text itself, once scaled.

Implements LibBoard::Shape.

References _box, _xScale, _yScale, and LibBoard::Path::scale().

◆ scale() [2/2]

Text & LibBoard::Text::scale ( double  sx,
double  sy 
)
overridevirtual

Scale the text, given two scaling factors.

Parameters
sxScaling factor along the x axis.
syScaling factor along the y axis.
Returns
A reference to the text itself, once scaled.

Implements LibBoard::Shape.

References _box, _xScale, _yScale, and LibBoard::Path::scale().

Referenced by scaled(), and scaled().

◆ scaleAll()

void LibBoard::Text::scaleAll ( double  s)
overridevirtual

Scales all the values (positions, dimensions, etc.) associated with the shape.

Parameters
sThe scaling factor.

Implements LibBoard::Shape.

References _box, and LibBoard::Path::scaleAll().

◆ scaled() [1/2]

Text LibBoard::Text::scaled ( double  s) const

Returns a scaled copy of the text.

Parameters
sThe scaling factor.
Returns
A scaled copy of the text.

References scale().

◆ scaled() [2/2]

Text LibBoard::Text::scaled ( double  sx,
double  sy 
) const

Returns a scaled copy of the text.

Parameters
sxThe scaling factor along the x axis.
syThe scaling factor along the y axis.
Returns
A scaled copy of the text.

References scale().

◆ translate()

Text & LibBoard::Text::translate ( double  dx,
double  dy 
)
overridevirtual

Translate the text by a given offset.

Parameters
dxThe x offset.
dyThe y offset.
Returns
A reference to the text itself.

Implements LibBoard::Shape.

References _box, and LibBoard::Path::translate().

Referenced by translated().

◆ translated()

Text LibBoard::Text::translated ( double  dx,
double  dy 
) const

Returns a translated copy of the text.

Parameters
dxShift of the first coordinate.
dyShift of the second coordinate.
Returns
A copy of the text, translated.

References translate().

Member Data Documentation

◆ _box

Path LibBoard::Text::_box
protected

◆ _font

Fonts::Font LibBoard::Text::_font
protected

◆ _size

double LibBoard::Text::_size
protected

◆ _svgFont

std::string LibBoard::Text::_svgFont
protected

Referenced by flushSVG().

◆ _text

std::string LibBoard::Text::_text
protected

◆ _xScale

double LibBoard::Text::_xScale
protected

Referenced by scale(), and scale().

◆ _yScale

double LibBoard::Text::_yScale
protected

Referenced by scale(), and scale().


The documentation for this struct was generated from the following files: