13 namespace datastructure {
25 float width = 1.0, height = 1.0;
33 setRectangle(0., 0., 1., 1.);
42 setRectangle (0., 0., w, h);
53 Rectangle (
float locx,
float locy,
float w,
float h) {
54 setRectangle (locx, locy, w, h);
82 throw "Illegal Size Value! Please enter a value in the range(0-300)";
94 throw "Illegal Size Value! Please enter a value in the range(0-300)";
106 const float *loc = getLocation();
107 float myloc[] = {loc[0], loc[1]};
108 translatePoint (myloc, tx, ty);
109 setLocation(myloc[0], myloc[1]);
120 float pt[2] = {(float) width, (
float) height};
121 scalePoint (pt, sx, sy);
134 vector<float> dims(4);
135 const float *location = getLocation();
137 dims[0] = location[0];
138 dims[1] = location[0] + width;
139 dims[2] = location[1];
140 dims[3] = location[1] + height;
156 if (w <= 0 || h <= 0)
157 throw "Width, Height must be positive";
158 setLocation (
float(locx),
float(locy));
161 setShapeType(
"rect");
171 string shape_json = getSymbolAttributeRepresentation();
173 string shape = getShapeType();
180 shape_json +=
QUOTE +
"width" +
QUOTE +
COLON + to_string(width) + COMMA +
void setHeight(float h)
This method sets the shape height.
Definition: Rectangle.h:92
Rectangle(int w, int h)
create rectangle with width w and height h
Definition: Rectangle.h:41
void translate(float tx, float ty)
Translate the rectangle.
Definition: Rectangle.h:105
const string COLON
Definition: DataStructure.h:51
Rectangle(float locx, float locy, float w, float h)
create rectangle with width w and height h and located at given position
Definition: Rectangle.h:53
virtual const string getSymbolRepresentation() const
This method returns the JSON representation of the shape.
Definition: Rectangle.h:169
void setRectangle(float locx, float locy, float w, float h)
Definition: Rectangle.h:155
void scale(float sx, float sy)
Scale the rectangle about its center.
Definition: Rectangle.h:117
const string CLOSE_CURLY
Definition: DataStructure.h:53
string getDataStructType()
This method gets the data type name.
Definition: Rectangle.h:62
This is an abstract class for deriving a number of Symbol shape objects, for use in a SymbolCollectio...
Definition: Symbol.h:33
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4
void setWidth(float w)
This method sets the shape width.
Definition: Rectangle.h:80
string getName() const
This method gets the name of the shape.
Definition: Rectangle.h:71
Rectangle()
default constructor - rectangle with lower left at origin and unit length sides
Definition: Rectangle.h:32
vector< float > getDimensions() const
Definition: Rectangle.h:132
const string COMMA
Definition: DataStructure.h:50
const string QUOTE
Definition: DataStructure.h:49
This class defines a rectangle and is part of the symbol collection. A rectangle has height and width...
Definition: Rectangle.h:22