34 #include <drain/UniTuple.h>
35 #include "ImageFile.h"
39 #include "drain/util/BeanLike.h"
41 #include "drain/util/JSON.h"
42 #include "drain/util/Dictionary.h"
44 #include "PaletteEntry.h"
58 class Palette :
public ImageCodeMap<PaletteEntry> {
63 const SprinterLayout cppLayout2;
67 Palette() : ImageCodeMap<PaletteEntry>(), refinement(0) {
75 Palette(std::initializer_list<std::pair<Variable, PaletteEntry> > inits);
92 const value_type & getEntryByCode(
const std::string & code,
bool lenient=
true)
const;
96 const key_type getValueByCode(
const std::string & code,
bool lenient=
true)
const {
97 const value_type & entry = getEntryByCode(code, lenient);
104 void addEntry(
double min,
double red=0.0,
double green=0.0,
double blue=0.0,
const std::string &
id=
"",
const std::string & label =
"");
110 void load(
const std::string & filename,
bool flexible =
false);
113 void loadTXT(std::istream & ifstr);
116 void loadJSON(std::istream & ifstr);
118 void write(
const std::string & filename)
const;
120 void exportTXT(std::ostream & ostr,
char separator=
'\t',
char separator2=0)
const;
123 void exportJSON(drain::JSONtree2 & json)
const;
126 void exportFMT(std::ostream & ostr,
const std::string & format)
const;
129 void exportSVGLegend(TreeSVG & svg,
bool up =
true)
const;
143 const ChannelGeometry & getChannels()
const {
155 typedef std::map<std::string,PaletteEntry> spec_t;
159 void refine(
size_t n=0);
183 void importJSON(
const drain::JSONtree2 & json);
186 ChannelGeometry channels;
193 std::ostream & operator<<(std::ostream &ostr,
const Palette & p){
201 class 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);
static std::ostream & toStream(std::ostream &ostr, const std::initializer_list< T > &x, const SprinterLayout &layout=defaultLayout)
New (experimental)
Definition: Sprinter.h:420
Definition: DataSelector.cpp:1277
Definition: Sprinter.h:137