StanfordCPPLib
Public Member Functions | List of all members
GDimension Class Reference

This class contains real-valued width and height fields. More...

#include "gtypes.h"

Public Member Functions

 GDimension(double width=0, double height=0)
 Creates a GDimension object with the specified width and height coordinates. More...
 
double getHeight() const
 Returns the height component of the GDimension object. More...
 
double getWidth() const
 Returns the width component of the GDimension object. More...
 
string toString() const
 Converts the GDimension to a string in the form "(</code><i>width</i><code>,</code>&nbsp;<i>height</i><code>)". More...
 

Detailed Description

This class contains real-valued width and height fields.

It is used to indicate the size of a graphical object.

Constructor & Destructor Documentation

◆ GDimension()

GDimension ( double  width = 0,
double  height = 0 
)

Creates a GDimension object with the specified width and height coordinates.

If the coordinates are not supplied, the default constructor sets these fields to 0.

Member Function Documentation

◆ getHeight()

double getHeight ( ) const

Returns the height component of the GDimension object.

◆ getWidth()

double getWidth ( ) const

Returns the width component of the GDimension object.

◆ toString()

string toString ( ) const

Converts the GDimension to a string in the form "(</code><i>width</i><code>,</code>&nbsp;<i>height</i><code>)".

Friends And Related Function Documentation

◆ hashCode

int hashCode ( const GDimension dim)
friend

Hashing function for GDimension objects.

◆ operator!=

bool operator!= ( const GDimension d1,
const GDimension d2 
)
friend

Compares two GDimension objects for inequality.

◆ operator*

GDimension operator* ( const GDimension d,
double  scale 
)
friend

Multiplies the width and height of the given GDimension object by the given scale factor and returns the scaled dimension object.

◆ operator<

bool operator< ( const GDimension d1,
const GDimension d2 
)
friend

Relational operators that compare two GDimension objects by width and then by height.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const GDimension dim 
)
friend

Writes the GDimension to the given output stream.

◆ operator<=

bool operator<= ( const GDimension d1,
const GDimension d2 
)
friend

Relational operators that compare two GDimension objects by width and then by height.

◆ operator==

bool operator== ( const GDimension d1,
const GDimension d2 
)
friend

Compares two GDimension objects for equality.

◆ operator>

bool operator> ( const GDimension d1,
const GDimension d2 
)
friend

Relational operators that compare two GDimension objects by width and then by height.

◆ operator>=

bool operator>= ( const GDimension d1,
const GDimension d2 
)
friend

Relational operators that compare two GDimension objects by width and then by height.