1 50 51 package com.lowagie.text.pdf; 52 53 import java.awt.Color ; 54 58 public class ExtendedColor extends Color { 59 60 private static final long serialVersionUID = 2722660170712380080L; 61 62 public static final int TYPE_RGB = 0; 63 64 public static final int TYPE_GRAY = 1; 65 66 public static final int TYPE_CMYK = 2; 67 68 public static final int TYPE_SEPARATION = 3; 69 70 public static final int TYPE_PATTERN = 4; 71 72 public static final int TYPE_SHADING = 5; 73 74 protected int type; 75 76 80 public ExtendedColor(int type) { 81 super(0, 0, 0); 82 this.type = type; 83 } 84 85 92 public ExtendedColor(int type, float red, float green, float blue) { 93 super(normalize(red), normalize(green), normalize(blue)); 94 this.type = type; 95 } 96 97 101 public int getType() { 102 return type; 103 } 104 105 110 public static int getType(Color color) { 111 if (color instanceof ExtendedColor) 112 return ((ExtendedColor)color).getType(); 113 return TYPE_RGB; 114 } 115 116 static final float normalize(float value) { 117 if (value < 0) 118 return 0; 119 if (value > 1) 120 return 1; 121 return value; 122 } 123 } | Popular Tags |