/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. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. * THE SOFTWARE.
  22. */
  23. package com.googlecode.charts4j;
  24. import static com.googlecode.charts4j.collect.Preconditions.*;
  25. /**
  26. * Common code to political boundary classes.
  27. *
  28. * @author Julien Chastang (julien.c.chastang at gmail dot com)
  29. *
  30. */
  31. abstract class AbstractPoliticalBoundary implements PoliticalBoundary {
  32. /** Max color along gradient. **/
  33. private static final int MAX_COLOR = 100;
  34. /** Min color along gradient. **/
  35. private static final int MIN_COLOR = 0;
  36. /** Political boundary code. **/
  37. private final String code;
  38. /** Political boundary color. **/
  39. private final int color;
  40. /**
  41. * AbstractPoliticalBoundary constructor.
  42. *
  43. * @param code
  44. * political boundary code. Cannot be null.
  45. * @param color
  46. * color code. Must be >= 0 and <= 100.
  47. *
  48. */
  49. AbstractPoliticalBoundary(final String code, final int color) {
  50. super();
  51. checkNotNull(code);
  52. checkArgument(color >= MIN_COLOR && color <= MAX_COLOR);
  53. this.code = code;
  54. this.color = color;
  55. }
  56. /**
  57. * {@inheritDoc}
  58. */
  59. public String getCode() {
  60. return code;
  61. }
  62. /**
  63. * {@inheritDoc}
  64. */
  65. public int getColor() {
  66. return color;
  67. }
  68. }