1 18 package org.apache.batik.ext.awt.image; 19 20 21 22 29 public class ConcreteComponentTransferFunction implements ComponentTransferFunction { 30 private int type; 31 private float slope; 32 private float[] tableValues; 33 private float intercept; 34 private float amplitude; 35 private float exponent; 36 private float offset; 37 38 42 private ConcreteComponentTransferFunction(){ 43 } 44 45 49 public static ComponentTransferFunction getIdentityTransfer(){ 50 ConcreteComponentTransferFunction f = new ConcreteComponentTransferFunction(); 51 f.type = IDENTITY; 52 return f; 53 } 54 55 58 public static ComponentTransferFunction 59 getTableTransfer(float tableValues[]){ 60 ConcreteComponentTransferFunction f = new ConcreteComponentTransferFunction(); 61 f.type = TABLE; 62 63 if(tableValues == null){ 64 throw new IllegalArgumentException (); 65 } 66 67 if(tableValues.length < 2){ 68 throw new IllegalArgumentException (); 69 } 70 71 f.tableValues = new float[tableValues.length]; 72 System.arraycopy(tableValues, 0, 73 f.tableValues, 0, 74 tableValues.length); 75 76 return f; 77 } 78 79 82 public static ComponentTransferFunction 83 getDiscreteTransfer(float tableValues[]){ 84 ConcreteComponentTransferFunction f = new ConcreteComponentTransferFunction(); 85 f.type = DISCRETE; 86 87 if(tableValues == null){ 88 throw new IllegalArgumentException (); 89 } 90 91 if(tableValues.length < 2){ 92 throw new IllegalArgumentException (); 93 } 94 95 f.tableValues = new float[tableValues.length]; 96 System.arraycopy(tableValues, 0, 97 f.tableValues, 0, 98 tableValues.length); 99 100 return f; 101 } 102 103 106 public static ComponentTransferFunction 107 getLinearTransfer(float slope, float intercept){ 108 ConcreteComponentTransferFunction f = new ConcreteComponentTransferFunction(); 109 f.type = LINEAR; 110 f.slope = slope; 111 f.intercept = intercept; 112 113 return f; 114 } 115 116 119 public static ComponentTransferFunction 120 getGammaTransfer(float amplitude, 121 float exponent, 122 float offset){ 123 ConcreteComponentTransferFunction f = new ConcreteComponentTransferFunction(); 124 f.type = GAMMA; 125 f.amplitude = amplitude; 126 f.exponent = exponent; 127 f.offset = offset; 128 129 return f; 130 } 131 132 135 public int getType(){ 136 return type; 137 } 138 139 142 public float getSlope(){ 143 return slope; 144 } 145 146 149 public float[] getTableValues(){ 150 return tableValues; 151 } 152 153 156 public float getIntercept(){ 157 return intercept; 158 } 159 160 163 public float getAmplitude(){ 164 return amplitude; 165 } 166 167 170 public float getExponent(){ 171 return exponent; 172 } 173 174 177 public float getOffset(){ 178 return offset; 179 } 180 } 181 182 | Popular Tags |