Board  0.9.5
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. More...
 
virtual void accept (const ShapeVisitor &visitor) override
 Accepts a visitor object. More...
 
virtual void accept (ConstShapeVisitor &visitor) const override
 Accepts a const-shape visitor object. More...
 
virtual void accept (const ConstShapeVisitor &visitor) const override
 Accepts a const-shape visitor object. More...
 
virtual Shapeaccept (CompositeShapeTransform &transform) const override
 Accept a composite shape transform. More...
 
virtual Shapeaccept (const CompositeShapeTransform &transform) const override
 Accept a constant composite shape transform. More...
 
Rect boundingBox (LineWidthFlag) const override
 
Textclone () const override
 
 Text (const Text &)=default
 
 Text (Text &&)=default
 
Textoperator= (Text &&)=default
 
Textoperator= (const Text &)=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 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 ()
 
ShaperotateDeg (double angle, const Point &center)
 
ShaperotateDeg (double angle)
 
ShapemoveCenter (double x, double y, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
ShapemoveCenter (Point p, LineWidthFlag lineWidthFlag=IgnoreLineWidth)
 
Shaperesize (double width, double height, LineWidthFlag lineWidthFlag)
 
ShapescaleToWidth (double w, LineWidthFlag lineWidthFlag)
 
ShapescaleToHeight (double h, LineWidthFlag lineWidthFlag)
 
Rect bbox (LineWidthFlag) const
 
 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/4]

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

Referenced by clone(), scaled(), and translated().

◆ Text() [2/4]

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

◆ Text() [3/4]

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

◆ Text() [4/4]

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

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.

◆ 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.

◆ 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.

◆ accept() [4/6]

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

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

◆ 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.

◆ accept() [6/6]

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

Accepts a visitor object.

Parameters
visitorA visitor object.

Reimplemented from LibBoard::Shape.

◆ 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 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 LibBoard::Path::center().

Referenced by rotate().

◆ clone()

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

Return a copy of the shape.

Returns
A copy of the shape.

Implements LibBoard::ShapeWithStyle.

References Text().

◆ 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.

◆ 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.

◆ 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.

◆ 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 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.

◆ 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 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 center(), and LibBoard::Path::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 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 LibBoard::Path::scale().

◆ 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 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 Text().

◆ 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 Text().

◆ 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 LibBoard::Path::translate().

◆ 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 Text().


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