QGIS API Documentation  2.99.0-Master (d55fa22)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsColorBrewerColorRamp Class Reference

Color ramp utilising "Color Brewer" preset color schemes. More...

#include <qgscolorramp.h>

Inheritance diagram for QgsColorBrewerColorRamp:
Inheritance graph
[legend]

Public Member Functions

 QgsColorBrewerColorRamp (const QString &schemeName=DEFAULT_COLORBREWER_SCHEMENAME, int colors=DEFAULT_COLORBREWER_COLORS, bool inverted=false)
 Constructor for QgsColorBrewerColorRamp. More...
 
virtual QgsColorBrewerColorRampclone () const override
 Creates a clone of the color ramp. More...
 
virtual QColor color (double value) const override
 Returns the color corresponding to a specified value. More...
 
int colors () const
 Returns the number of colors in the ramp. More...
 
virtual int count () const override
 Returns number of defined colors, or -1 if undefined. More...
 
virtual void invert () override
 Inverts the ordering of the color ramp. More...
 
virtual QgsStringMap properties () const override
 Returns a string map containing all the color ramp's properties. More...
 
QString schemeName () const
 Returns the name of the color brewer color scheme. More...
 
void setColors (int colors)
 Sets the number of colors in the ramp. More...
 
void setSchemeName (const QString &schemeName)
 Sets the name of the color brewer color scheme. More...
 
virtual QString type () const override
 Returns a string representing the color ramp type. More...
 
virtual double value (int index) const override
 Returns relative value between [0,1] of color at specified index. More...
 
- Public Member Functions inherited from QgsColorRamp
virtual ~QgsColorRamp ()=default
 

Static Public Member Functions

static QgsColorRampcreate (const QgsStringMap &properties=QgsStringMap())
 Returns a new QgsColorBrewerColorRamp color ramp created using the properties encoded in a string map. More...
 
static QStringList listSchemeNames ()
 Returns a list of all valid color brewer scheme names. More...
 
static QList< int > listSchemeVariants (const QString &schemeName)
 Returns a list of the valid variants (numbers of colors) for a specified color brewer scheme name. More...
 

Protected Member Functions

void loadPalette ()
 Generates the scheme using the current name and number of colors. More...
 

Protected Attributes

int mColors
 
bool mInverted
 
QList< QColor > mPalette
 
QString mSchemeName
 

Detailed Description

Color ramp utilising "Color Brewer" preset color schemes.

Since
QGIS 3.0

Definition at line 479 of file qgscolorramp.h.

Constructor & Destructor Documentation

◆ QgsColorBrewerColorRamp()

QgsColorBrewerColorRamp::QgsColorBrewerColorRamp ( const QString &  schemeName = DEFAULT_COLORBREWER_SCHEMENAME,
int  colors = DEFAULT_COLORBREWER_COLORS,
bool  inverted = false 
)

Constructor for QgsColorBrewerColorRamp.

Parameters
schemeNamecolor brewer scheme name
colorsnumber of colors in ramp
invertedinvert ramp ordering

Definition at line 499 of file qgscolorramp.cpp.

Member Function Documentation

◆ clone()

QgsColorBrewerColorRamp * QgsColorBrewerColorRamp::clone ( ) const
overridevirtual

Creates a clone of the color ramp.

Implements QgsColorRamp.

Definition at line 572 of file qgscolorramp.cpp.

◆ color()

QColor QgsColorBrewerColorRamp::color ( double  value) const
overridevirtual

Returns the color corresponding to a specified value.

Parameters
valuevalue between [0, 1] inclusive
Returns
color for value

Implements QgsColorRamp.

Definition at line 555 of file qgscolorramp.cpp.

◆ colors()

int QgsColorBrewerColorRamp::colors ( ) const
inline

Returns the number of colors in the ramp.

See also
setColors()

Definition at line 515 of file qgscolorramp.h.

◆ count()

virtual int QgsColorBrewerColorRamp::count ( ) const
inlineoverridevirtual

Returns number of defined colors, or -1 if undefined.

Implements QgsColorRamp.

Definition at line 505 of file qgscolorramp.h.

◆ create()

QgsColorRamp * QgsColorBrewerColorRamp::create ( const QgsStringMap properties = QgsStringMap())
static

Returns a new QgsColorBrewerColorRamp color ramp created using the properties encoded in a string map.

Parameters
propertiescolor ramp properties
See also
properties()

Definition at line 507 of file qgscolorramp.cpp.

◆ invert()

void QgsColorBrewerColorRamp::invert ( )
overridevirtual

Inverts the ordering of the color ramp.

Reimplemented from QgsColorRamp.

Definition at line 566 of file qgscolorramp.cpp.

◆ listSchemeNames()

QStringList QgsColorBrewerColorRamp::listSchemeNames ( )
static

Returns a list of all valid color brewer scheme names.

See also
listSchemeVariants()

Definition at line 539 of file qgscolorramp.cpp.

◆ listSchemeVariants()

QList< int > QgsColorBrewerColorRamp::listSchemeVariants ( const QString &  schemeName)
static

Returns a list of the valid variants (numbers of colors) for a specified color brewer scheme name.

Parameters
schemeNamecolor brewer scheme name
See also
listSchemeNames()

Definition at line 544 of file qgscolorramp.cpp.

◆ loadPalette()

void QgsColorBrewerColorRamp::loadPalette ( )
protected

Generates the scheme using the current name and number of colors.

Definition at line 523 of file qgscolorramp.cpp.

◆ properties()

QgsStringMap QgsColorBrewerColorRamp::properties ( ) const
overridevirtual

Returns a string map containing all the color ramp's properties.

Implements QgsColorRamp.

Definition at line 577 of file qgscolorramp.cpp.

◆ schemeName()

QString QgsColorBrewerColorRamp::schemeName ( ) const
inline

Returns the name of the color brewer color scheme.

See also
setSchemeName()

Definition at line 510 of file qgscolorramp.h.

◆ setColors()

void QgsColorBrewerColorRamp::setColors ( int  colors)
inline

Sets the number of colors in the ramp.

Parameters
colorsnumber of colors. Must match a valid value for the scheme, which can be retrieved using listSchemeVariants()
See also
colors()

Definition at line 529 of file qgscolorramp.h.

◆ setSchemeName()

void QgsColorBrewerColorRamp::setSchemeName ( const QString &  schemeName)
inline

Sets the name of the color brewer color scheme.

Parameters
schemeNamescheme name, must match a valid color brewer scheme name
See also
schemeName()
listSchemeNames()

Definition at line 522 of file qgscolorramp.h.

◆ type()

virtual QString QgsColorBrewerColorRamp::type ( ) const
inlineoverridevirtual

Returns a string representing the color ramp type.

Implements QgsColorRamp.

Definition at line 501 of file qgscolorramp.h.

◆ value()

double QgsColorBrewerColorRamp::value ( int  index) const
overridevirtual

Returns relative value between [0,1] of color at specified index.

Implements QgsColorRamp.

Definition at line 549 of file qgscolorramp.cpp.

Member Data Documentation

◆ mColors

int QgsColorBrewerColorRamp::mColors
protected

Definition at line 549 of file qgscolorramp.h.

◆ mInverted

bool QgsColorBrewerColorRamp::mInverted
protected

Definition at line 551 of file qgscolorramp.h.

◆ mPalette

QList<QColor> QgsColorBrewerColorRamp::mPalette
protected

Definition at line 550 of file qgscolorramp.h.

◆ mSchemeName

QString QgsColorBrewerColorRamp::mSchemeName
protected

Definition at line 548 of file qgscolorramp.h.


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