34#include "drain/Dictionary.h"
35#include "drain/util/JSON.h"
36#include "drain/util/StringMapper.h"
41#include "PaletteEntry.h"
72 Palette(std::initializer_list<std::pair<Variable, PaletteEntry> > inits);
89 const value_type &
getEntryByCode(
const std::string & code,
bool lenient=
true)
const;
101 void addEntry(
double min,
double red=0.0,
double green=0.0,
double blue=0.0,
const std::string &
id=
"",
const std::string & label =
"");
107 void load(
const std::string & filename,
bool flexible =
false);
110 void loadTXT(std::istream & ifstr);
113 void loadJSON(std::istream & ifstr);
115 void write(
const std::string & filename)
const;
117 void exportTXT(std::ostream & ostr,
char separator=
'\t',
char separator2=0)
const;
120 void exportJSON(drain::JSONtree & json)
const;
123 void exportFMT(std::ostream & ostr,
const std::string & format)
const;
155 typedef std::map<std::string,PaletteEntry>
spec_t;
183 void importJSON(
const drain::JSONtree & json);
193std::ostream & operator<<(std::ostream &ostr,
const Palette & p){
201class PaletteMap :
public std::map<std::string,drain::image::Palette> {
206 Palette & get(
const std::string & key){
207 if (aliases.hasKey(key)){
208 return (*
this)[aliases.
getValue(key)];
216 void addAlias(
const std::string & key,
const std::string & aliasKey){
217 aliases.add(aliasKey,key);
Two-way mapping between strings and objects of template class T.
Definition Dictionary.h:61
const V & getValue(const K &key, bool lenient=true) const
Given a key, return the first value associated with it.
Definition Dictionary.h:147
Definition ImageCodebook.h:52
static std::ostream & toStream(std::ostream &ostr, const std::initializer_list< T > &x, const SprinterLayout &layout=defaultLayout)
New (experimental)
Definition Sprinter.h:423
Container for color, transparency (alpha) and textual id and description. Does not contain intensity ...
Definition PaletteEntry.h:142
size_t refinement
void updateDictionary();
Definition Palette.h:169
Palette()
Basic constructor.
Definition Palette.h:64
void exportSVGLegend(TreeSVG &svg, bool up=true) const
Returns a legend as an SVG graphic.
Definition Palette.cpp:1122
void loadTXT(std::istream &ifstr)
Loads a palette from a text file.
Definition Palette.cpp:476
void addEntry(double min, double red=0.0, double green=0.0, double blue=0.0, const std::string &id="", const std::string &label="")
Add one color. Deprecating; brace-enclosed initialization more preferable.
Definition Palette.cpp:94
std::map< std::string, PaletteEntry > spec_t
Some kind of identity key for the palette, typically filename to avoid reloading.
Definition Palette.h:155
const ChannelGeometry & getChannels() const
Export palette such.
Definition Palette.h:143
key_type getValueByCode(const std::string &code, bool lenient=true) const
Shorthand invoking fgetEntryByCode for retrieving the code.
Definition Palette.h:93
void load(const std::string &filename, bool flexible=false)
Loads a palette from text file.
Definition Palette.cpp:329
void refine(size_t n=0)
Extend palette to contain n entries ("colors") by adding intermediate entries.
Definition Palette.cpp:259
void importJSON(const drain::JSONtree &json)
Creates a palette from json object.
Definition Palette.cpp:717
std::string title
Name of the palette. In reading files, the first comment line (without the prefix '#') is copied to t...
Definition Palette.h:149
const value_type & getEntryByCode(const std::string &code, bool lenient=true) const
Definition Palette.cpp:117
void update() const
Container for special codes ??
Definition Palette.cpp:211
void loadJSON(std::istream &ifstr)
Loads a palette from a json file. Under revision; support may be dropped later.
Definition Palette.cpp:689
void exportSLD(TreeSLD &sld) const
Export as SLD structure supported by GeoServer.
Definition Palette.cpp:1305
Definition Sprinter.h:136