comparison dwtx/jface/resource/FileImageDescriptor.d @ 40:da5ad8eedf5d

debug prints, dwt.dwthelper restructure, ...
author Frank Benoit <benoit@tionex.de>
date Thu, 10 Apr 2008 08:59:39 +0200
parents c884a1ab6db3
children ea8ff534f622
comparison
equal deleted inserted replaced
39:644f1334b451 40:da5ad8eedf5d
28 import dwt.dwthelper.InputStream; 28 import dwt.dwthelper.InputStream;
29 import dwt.dwthelper.FileInputStream; 29 import dwt.dwthelper.FileInputStream;
30 import dwt.dwthelper.BufferedInputStream; 30 import dwt.dwthelper.BufferedInputStream;
31 import dwt.dwthelper.ByteArrayInputStream; 31 import dwt.dwthelper.ByteArrayInputStream;
32 32
33 import tango.util.log.Trace;
34
33 /** 35 /**
34 * An image descriptor that loads its image information 36 * An image descriptor that loads its image information
35 * from a file. 37 * from a file.
36 */ 38 */
37 class FileImageDescriptor : ImageDescriptor { 39 class FileImageDescriptor : ImageDescriptor {
43 // private ClassInfo location; 45 // private ClassInfo location;
44 46
45 /** 47 /**
46 * The name of the file. 48 * The name of the file.
47 */ 49 */
48 // private String name; 50 private String name;
49 private void[] importdata; 51 private void[] importdata;
50 52
51 /** 53 /**
52 * Creates a new file image descriptor. 54 * Creates a new file image descriptor.
53 * The file has the given file name and is located 55 * The file has the given file name and is located
60 * 62 *
61 * @param clazz class for resource directory, or 63 * @param clazz class for resource directory, or
62 * <code>null</code> 64 * <code>null</code>
63 * @param filename the name of the file 65 * @param filename the name of the file
64 */ 66 */
65 this(void[] importdata/+ClassInfo clazz, String filename+/) { 67 this(ImportData importdata) {
66 // this.location = clazz; 68 // this.location = clazz;
67 // this.name = filename; 69 this.name = importdata.name;
68 this.importdata = importdata; 70 this.importdata = importdata.data;
69 } 71 }
70 72
71 /* (non-Javadoc) 73 /* (non-Javadoc)
72 * Method declared on Object. 74 * Method declared on Object.
73 */ 75 */
97 ImageData result = null; 99 ImageData result = null;
98 if (in_ !is null) { 100 if (in_ !is null) {
99 try { 101 try {
100 result = new ImageData(in_); 102 result = new ImageData(in_);
101 } catch (DWTException e) { 103 } catch (DWTException e) {
102 if (e.code !is DWT.ERROR_INVALID_IMAGE) { 104 if (e.code !is DWT.ERROR_INVALID_IMAGE /+&& e.code !is DWT.ERROR_UNSUPPORTED_FORMAT+/) {
105 Trace.formatln( "FileImageDescriptor getImageData DWTException for name={}", name );
103 throw e; 106 throw e;
104 // fall through otherwise 107 // fall through otherwise
105 } 108 }
106 } finally { 109 } finally {
107 in_.close(); 110 in_.close();
119 */ 122 */
120 private InputStream getStream() { 123 private InputStream getStream() {
121 InputStream is_ = null; 124 InputStream is_ = null;
122 125
123 // if (location !is null) { 126 // if (location !is null) {
127 // Trace.formatln( "FileImageDescriptor getStream importdata.length={} name={}",importdata.length, name );
124 is_ = new ByteArrayInputStream(cast(byte[]) importdata); 128 is_ = new ByteArrayInputStream(cast(byte[]) importdata);
125 // is_ = ClassInfoGetResourceAsStream( location, name); 129 // is_ = ClassInfoGetResourceAsStream( location, name);
126 130
127 // } else { 131 // } else {
128 // try { 132 // try {