QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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...
 
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...
 
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...
 
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 ()=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 535 of file qgscolorramp.h.

Constructor & Destructor Documentation

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 495 of file qgscolorramp.cpp.

Member Function Documentation

QgsColorBrewerColorRamp * QgsColorBrewerColorRamp::clone ( ) const
overridevirtual

Creates a clone of the color ramp.

Implements QgsColorRamp.

Definition at line 569 of file qgscolorramp.cpp.

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 552 of file qgscolorramp.cpp.

int QgsColorBrewerColorRamp::colors ( ) const
inline

Returns the number of colors in the ramp.

See also
setColors()

Definition at line 575 of file qgscolorramp.h.

int QgsColorBrewerColorRamp::count ( ) const
inlineoverridevirtual

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

Implements QgsColorRamp.

Definition at line 563 of file qgscolorramp.h.

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 503 of file qgscolorramp.cpp.

void QgsColorBrewerColorRamp::invert ( )
overridevirtual

Inverts the ordering of the color ramp.

Reimplemented from QgsColorRamp.

Definition at line 563 of file qgscolorramp.cpp.

QStringList QgsColorBrewerColorRamp::listSchemeNames ( )
static

Returns a list of all valid color brewer scheme names.

See also
listSchemeVariants()

Definition at line 535 of file qgscolorramp.cpp.

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 540 of file qgscolorramp.cpp.

void QgsColorBrewerColorRamp::loadPalette ( )
protected

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

Definition at line 519 of file qgscolorramp.cpp.

QgsStringMap QgsColorBrewerColorRamp::properties ( ) const
overridevirtual

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

Implements QgsColorRamp.

Definition at line 574 of file qgscolorramp.cpp.

QString QgsColorBrewerColorRamp::schemeName ( ) const
inline

Returns the name of the color brewer color scheme.

See also
setSchemeName()

Definition at line 569 of file qgscolorramp.h.

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 591 of file qgscolorramp.h.

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 583 of file qgscolorramp.h.

QString QgsColorBrewerColorRamp::type ( ) const
inlineoverridevirtual

Returns a string representing the color ramp type.

Implements QgsColorRamp.

Definition at line 559 of file qgscolorramp.h.

double QgsColorBrewerColorRamp::value ( int  index) const
overridevirtual

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

Implements QgsColorRamp.

Definition at line 545 of file qgscolorramp.cpp.

Member Data Documentation

int QgsColorBrewerColorRamp::mColors
protected

Definition at line 613 of file qgscolorramp.h.

bool QgsColorBrewerColorRamp::mInverted
protected

Definition at line 615 of file qgscolorramp.h.

QList<QColor> QgsColorBrewerColorRamp::mPalette
protected

Definition at line 614 of file qgscolorramp.h.

QString QgsColorBrewerColorRamp::mSchemeName
protected

Definition at line 612 of file qgscolorramp.h.


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