1 7 package com.sun.java.swing.plaf.nimbus; 8 9 import sun.awt.AppContext; 10 11 import java.awt.image.BufferedImage ; 12 import java.lang.ref.SoftReference ; 13 14 20 abstract class Effect { 21 enum EffectType { 22 UNDER, BLENDED, OVER 23 } 24 25 28 35 abstract EffectType getEffectType(); 36 37 42 abstract float getOpacity(); 43 44 56 abstract BufferedImage applyEffect(BufferedImage src, BufferedImage dst, int w, int h); 57 58 61 protected static ArrayCache getArrayCache() { 62 ArrayCache cache = (ArrayCache)AppContext.getAppContext().get(ArrayCache.class); 63 if (cache == null){ 64 cache = new ArrayCache(); 65 AppContext.getAppContext().put(ArrayCache.class,cache); 66 } 67 return cache; 68 } 69 70 protected static class ArrayCache { 71 private SoftReference <int[]> tmpIntArray = null; 72 private SoftReference <byte[]> tmpByteArray1 = null; 73 private SoftReference <byte[]> tmpByteArray2 = null; 74 private SoftReference <byte[]> tmpByteArray3 = null; 75 76 protected int[] getTmpIntArray(int size) { 77 int[] tmp; 78 if (tmpIntArray == null || (tmp = tmpIntArray.get()) == null || tmp.length < size) { 79 tmp = new int[size]; 81 tmpIntArray = new SoftReference <int[]>(tmp); 82 } 83 return tmp; 84 } 85 86 protected byte[] getTmpByteArray1(int size) { 87 byte[] tmp; 88 if (tmpByteArray1 == null || (tmp = tmpByteArray1.get()) == null || tmp.length < size) { 89 tmp = new byte[size]; 91 tmpByteArray1 = new SoftReference <byte[]>(tmp); 92 } 93 return tmp; 94 } 95 96 protected byte[] getTmpByteArray2(int size) { 97 byte[] tmp; 98 if (tmpByteArray2 == null || (tmp = tmpByteArray2.get()) == null || tmp.length < size) { 99 tmp = new byte[size]; 101 tmpByteArray2 = new SoftReference <byte[]>(tmp); 102 } 103 return tmp; 104 } 105 106 protected byte[] getTmpByteArray3(int size) { 107 byte[] tmp; 108 if (tmpByteArray3 == null || (tmp = tmpByteArray3.get()) == null || tmp.length < size) { 109 tmp = new byte[size]; 111 tmpByteArray3 = new SoftReference <byte[]>(tmp); 112 } 113 return tmp; 114 } 115 } 116 } 117 | Popular Tags |