PageRenderTime 19ms CodeModel.GetById 15ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/java/com/googlecode/charts4j/AbstractPoliticalBoundary.java

http://charts4j.googlecode.com/
Java | 81 lines | 21 code | 11 blank | 49 comment | 1 complexity | e3322535bc355abb0dc43d391e37b5be MD5 | raw file
 1/**
 2 *
 3 * The MIT License
 4 *
 5 * Copyright (c) 2011 the original author or authors.
 6 *
 7 * Permission is hereby granted, free of charge, to any person obtaining a copy
 8 * of this software and associated documentation files (the "Software"), to deal
 9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
24 */
25
26package com.googlecode.charts4j;
27
28import static com.googlecode.charts4j.collect.Preconditions.*;
29
30/**
31 * Common code to political boundary classes.
32 *
33 * @author Julien Chastang (julien.c.chastang at gmail dot com)
34 *
35 */
36abstract class AbstractPoliticalBoundary implements PoliticalBoundary {
37
38    /** Max color along gradient. **/
39    private static final int         MAX_COLOR      = 100;
40
41    /** Min color along gradient. **/
42    private static final int         MIN_COLOR      = 0;
43
44
45    /** Political boundary code. **/
46    private final String code;
47
48    /** Political boundary color. **/
49    private final int    color;
50
51    /**
52     * AbstractPoliticalBoundary constructor.
53     *
54     * @param code
55     *            political boundary code. Cannot be null.
56     * @param color
57     *            color code. Must be >= 0 and <= 100.
58     *
59     */
60    AbstractPoliticalBoundary(final String code, final int color) {
61        super();
62        checkNotNull(code);
63        checkArgument(color >= MIN_COLOR && color <= MAX_COLOR);
64        this.code = code;
65        this.color = color;
66    }
67
68    /**
69     * {@inheritDoc}
70     */
71    public String getCode() {
72        return code;
73    }
74
75    /**
76     * {@inheritDoc}
77     */
78    public int getColor() {
79        return color;
80    }
81}