1 13 48 package org.pentaho.plugin.jfreereport.reportcharts; 49 50 import java.awt.Image ; 51 import java.net.URL ; 52 53 import org.jfree.report.LocalImageContainer; 54 import org.jfree.report.URLImageContainer; 55 56 61 public class ChartImageContainer 62 implements URLImageContainer, LocalImageContainer 63 { 64 private static class ChartImageKey 65 { 66 private int row; 67 private String expressionName; 68 69 public ChartImageKey(final int row, final String expressionName) 70 { 71 this.row = row; 72 this.expressionName = expressionName; 73 } 74 75 public boolean equals(final Object o) 76 { 77 if (this == o) 78 { 79 return true; 80 } 81 if (o == null || getClass() != o.getClass()) 82 { 83 return false; 84 } 85 86 final ChartImageKey that = (ChartImageKey) o; 87 88 if (row != that.row) 89 { 90 return false; 91 } 92 if (!expressionName.equals(that.expressionName)) 93 { 94 return false; 95 } 96 97 return true; 98 } 99 100 public int hashCode() 101 { 102 int result; 103 result = row; 104 result = 29 * result + expressionName.hashCode(); 105 return result; 106 } 107 } 108 109 private String target; 110 private Image image; 111 private int width; 112 private int height; 113 private ChartImageKey key; 114 115 public ChartImageContainer(final String target, 116 final Image image, 117 final int width, 118 final int height, 119 final int row, 120 final String keyName) 121 { 122 if (target == null) 123 { 124 throw new NullPointerException (); 125 } 126 if (image == null) 127 { 128 throw new NullPointerException (); 129 } 130 if (keyName == null) 131 { 132 throw new NullPointerException (); 133 } 134 135 this.target = target; 136 this.image = image; 137 this.width = width; 138 this.height = height; 139 this.key = new ChartImageKey(row, keyName); 140 } 141 142 public Object getIdentity() 143 { 144 return key; 145 } 146 147 public Image getImage() 148 { 149 return image; 150 } 151 152 public String getName() 153 { 154 return getSourceURLString(); 155 } 156 157 public boolean isIdentifiable() 158 { 159 return true; 160 } 161 162 public int getImageHeight() 163 { 164 return height; 165 } 166 167 public int getImageWidth() 168 { 169 return width; 170 } 171 172 public float getScaleX() 173 { 174 return 1; 175 } 176 177 public float getScaleY() 178 { 179 return 1; 180 } 181 182 public URL getSourceURL() 183 { 184 return null; 185 } 186 187 public String getSourceURLString() 188 { 189 return target; 190 } 191 192 197 public boolean isLoadable() 198 { 199 return false; 200 } 201 } 202 | Popular Tags |