QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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 <qgscolorrampimpl.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...
 
QgsColorBrewerColorRampclone () const override
 Creates a clone of the color ramp. More...
 
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...
 
int count () const override
 Returns number of defined colors, or -1 if undefined. More...
 
void invert () override
 Inverts the ordering of the color ramp. More...
 
QVariantMap 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...
 
QString type () const override
 Returns a string representing the color ramp type. More...
 
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 ()
 
virtual QgsColorRampclone () const =0
 Creates a clone of the color ramp. More...
 
virtual QColor color (double value) const =0
 Returns the color corresponding to a specified value. More...
 
virtual int count () const =0
 Returns number of defined colors, or -1 if undefined. More...
 
virtual void invert ()
 Inverts the ordering of the color ramp. More...
 
virtual QVariantMap properties () const =0
 Returns a string map containing all the color ramp's properties. More...
 
virtual QString type () const =0
 Returns a string representing the color ramp type. More...
 
virtual double value (int index) const =0
 Returns relative value between [0,1] of color at specified index. More...
 

Static Public Member Functions

static QgsColorRampcreate (const QVariantMap &properties=QVariantMap())
 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...
 
static QString typeString ()
 Returns the string identifier for QgsColorBrewerColorRamp. More...
 
- Static Public Member Functions inherited from QgsColorRamp
static QList< QPair< QString, QString > > rampTypes ()
 Returns a list of available ramp types, where the first value in each item is the QgsColorRamp::type() string and the second is a user friendly, translated name for the color ramp type. 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.

Definition at line 606 of file qgscolorrampimpl.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 823 of file qgscolorrampimpl.cpp.

Member Function Documentation

◆ clone()

QgsColorBrewerColorRamp * QgsColorBrewerColorRamp::clone ( ) const
overridevirtual

Creates a clone of the color ramp.

Implements QgsColorRamp.

Definition at line 897 of file qgscolorrampimpl.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 880 of file qgscolorrampimpl.cpp.

◆ colors()

int QgsColorBrewerColorRamp::colors ( ) const
inline

Returns the number of colors in the ramp.

See also
setColors()

Definition at line 654 of file qgscolorrampimpl.h.

◆ count()

int QgsColorBrewerColorRamp::count ( ) const
inlineoverridevirtual

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

Implements QgsColorRamp.

Definition at line 642 of file qgscolorrampimpl.h.

◆ create()

QgsColorRamp * QgsColorBrewerColorRamp::create ( const QVariantMap &  properties = QVariantMap())
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 831 of file qgscolorrampimpl.cpp.

◆ invert()

void QgsColorBrewerColorRamp::invert ( )
overridevirtual

Inverts the ordering of the color ramp.

Reimplemented from QgsColorRamp.

Definition at line 891 of file qgscolorrampimpl.cpp.

◆ listSchemeNames()

QStringList QgsColorBrewerColorRamp::listSchemeNames ( )
static

Returns a list of all valid color brewer scheme names.

See also
listSchemeVariants()

Definition at line 863 of file qgscolorrampimpl.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 868 of file qgscolorrampimpl.cpp.

◆ loadPalette()

void QgsColorBrewerColorRamp::loadPalette ( )
protected

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

Definition at line 847 of file qgscolorrampimpl.cpp.

◆ properties()

QVariantMap QgsColorBrewerColorRamp::properties ( ) const
overridevirtual

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

Implements QgsColorRamp.

Definition at line 902 of file qgscolorrampimpl.cpp.

◆ schemeName()

QString QgsColorBrewerColorRamp::schemeName ( ) const
inline

Returns the name of the color brewer color scheme.

See also
setSchemeName()

Definition at line 648 of file qgscolorrampimpl.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 670 of file qgscolorrampimpl.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 662 of file qgscolorrampimpl.h.

◆ type()

QString QgsColorBrewerColorRamp::type ( ) const
inlineoverridevirtual

Returns a string representing the color ramp type.

Implements QgsColorRamp.

Definition at line 638 of file qgscolorrampimpl.h.

◆ typeString()

static QString QgsColorBrewerColorRamp::typeString ( )
inlinestatic

Returns the string identifier for QgsColorBrewerColorRamp.

Since
QGIS 3.16

Definition at line 636 of file qgscolorrampimpl.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 873 of file qgscolorrampimpl.cpp.

Member Data Documentation

◆ mColors

int QgsColorBrewerColorRamp::mColors
protected

Definition at line 692 of file qgscolorrampimpl.h.

◆ mInverted

bool QgsColorBrewerColorRamp::mInverted
protected

Definition at line 694 of file qgscolorrampimpl.h.

◆ mPalette

QList<QColor> QgsColorBrewerColorRamp::mPalette
protected

Definition at line 693 of file qgscolorrampimpl.h.

◆ mSchemeName

QString QgsColorBrewerColorRamp::mSchemeName
protected

Definition at line 691 of file qgscolorrampimpl.h.


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