blob: 3975cd8395f6c1519974bf0656ee315ee6fcc18f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Copyright (C) 1999-2016
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"
#include "colortag.h"
#include "colorbar.h"
#include "util.h"
static int colorTagSeqID = 1;
ColorTag::ColorTag(Colorbar* p, int b, int e, const char* clr)
: parent_(p), start_(b), stop_(e)
{
id_ = colorTagSeqID++;
colorname_ = dupstr(clr);
color_ = parent_->getXColor(colorname_);
next_ =NULL;
previous_ =NULL;
}
ColorTag::~ColorTag()
{
if (colorname_)
delete [] colorname_;
}
void ColorTag::move(int xx, int yy)
{
int aa = start_+xx;
int bb = stop_+yy;
if (aa>=bb-20)
bb = aa+20;
if (bb>parent_->colorCount) {
bb = parent_->colorCount;
aa = parent_->colorCount - (stop_-start_);
}
if (aa<0) {
aa = 0;
bb = stop_-start_;
}
start_ =aa;
stop_ =bb;
}
void ColorTag::set(int start, int stop, const char* color)
{
start_ = start;
stop_ = stop;
if (colorname_)
delete [] colorname_;
colorname_ = dupstr(color);
color_ = parent_->getXColor(colorname_);
}
void ColorTag::width(int size)
{
int aa = start_-size/2;
int bb = stop_+size/2;
if (bb>parent_->colorCount) {
bb = parent_->colorCount;
aa = parent_->colorCount - size;
}
if (aa<0) {
aa = 0;
bb = size;
}
start_ =aa;
stop_ =bb;
}
|