1 |
/* ImageReader.java -- Decodes raster images. |
/* ImageReader.java -- Decodes raster images. |
2 |
Copyright (C) 2004 Free Software Foundation, Inc. |
Copyright (C) 2004, 2005 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
185 |
{ |
{ |
186 |
if (listener == null) |
if (listener == null) |
187 |
return; |
return; |
188 |
|
if (progressListeners == null) |
189 |
progressListeners.add(listener); |
progressListeners = new ArrayList (); |
190 |
|
progressListeners.add(listener); |
191 |
} |
} |
192 |
|
|
193 |
/** |
/** |
200 |
{ |
{ |
201 |
if (listener == null) |
if (listener == null) |
202 |
return; |
return; |
203 |
|
if (updateListeners == null) |
204 |
updateListeners.add(listener); |
updateListeners = new ArrayList (); |
205 |
|
updateListeners.add(listener); |
206 |
} |
} |
207 |
|
|
208 |
/** |
/** |
209 |
* Install a read warning listener. This method will return |
* Install a read warning listener. This method will return |
210 |
* immediately if listener is null. Warning messages sent to this |
* immediately if listener is null. Warning messages sent to this |
218 |
{ |
{ |
219 |
if (listener == null) |
if (listener == null) |
220 |
return; |
return; |
221 |
|
if (warningListeners == null) |
222 |
warningListeners.add(listener); |
warningListeners = new ArrayList (); |
223 |
|
warningListeners.add(listener); |
224 |
} |
} |
225 |
|
|
226 |
/** |
/** |
766 |
*/ |
*/ |
767 |
protected void processImageComplete() |
protected void processImageComplete() |
768 |
{ |
{ |
769 |
Iterator it = progressListeners.iterator(); |
if (progressListeners != null) |
|
|
|
|
while (it.hasNext()) |
|
770 |
{ |
{ |
771 |
IIOReadProgressListener listener = (IIOReadProgressListener) it.next(); |
Iterator it = progressListeners.iterator(); |
772 |
listener.imageComplete (this); |
|
773 |
|
while (it.hasNext()) |
774 |
|
{ |
775 |
|
IIOReadProgressListener listener = |
776 |
|
(IIOReadProgressListener) it.next(); |
777 |
|
listener.imageComplete (this); |
778 |
|
} |
779 |
} |
} |
780 |
} |
} |
781 |
|
|
789 |
*/ |
*/ |
790 |
protected void processImageProgress(float percentageDone) |
protected void processImageProgress(float percentageDone) |
791 |
{ |
{ |
792 |
Iterator it = progressListeners.iterator(); |
if (progressListeners != null) |
|
|
|
|
while (it.hasNext()) |
|
793 |
{ |
{ |
794 |
IIOReadProgressListener listener = (IIOReadProgressListener) it.next(); |
Iterator it = progressListeners.iterator(); |
795 |
listener.imageProgress(this, percentageDone); |
|
796 |
|
while (it.hasNext()) |
797 |
|
{ |
798 |
|
IIOReadProgressListener listener = |
799 |
|
(IIOReadProgressListener) it.next(); |
800 |
|
listener.imageProgress(this, percentageDone); |
801 |
|
} |
802 |
} |
} |
803 |
} |
} |
|
|
|
804 |
/** |
/** |
805 |
* Notifies all installed read progress listeners, by calling their |
* Notifies all installed read progress listeners, by calling their |
806 |
* imageStarted methods, that image loading has started on the given |
* imageStarted methods, that image loading has started on the given |
811 |
*/ |
*/ |
812 |
protected void processImageStarted(int imageIndex) |
protected void processImageStarted(int imageIndex) |
813 |
{ |
{ |
814 |
Iterator it = progressListeners.iterator(); |
if (progressListeners != null) |
|
|
|
|
while (it.hasNext()) |
|
815 |
{ |
{ |
816 |
IIOReadProgressListener listener = (IIOReadProgressListener) it.next(); |
Iterator it = progressListeners.iterator(); |
817 |
listener.imageStarted(this, imageIndex); |
|
818 |
|
while (it.hasNext()) |
819 |
|
{ |
820 |
|
IIOReadProgressListener listener = |
821 |
|
(IIOReadProgressListener) it.next(); |
822 |
|
listener.imageStarted(this, imageIndex); |
823 |
|
} |
824 |
} |
} |
825 |
} |
} |
826 |
|
|
843 |
int width, int height, int periodX, |
int width, int height, int periodX, |
844 |
int periodY, int[] bands) |
int periodY, int[] bands) |
845 |
{ |
{ |
846 |
Iterator it = updateListeners.iterator(); |
if (updateListeners != null) |
|
|
|
|
while (it.hasNext()) |
|
847 |
{ |
{ |
848 |
IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next(); |
Iterator it = updateListeners.iterator(); |
849 |
listener.imageUpdate(this, image, minX, minY, width, height, periodX, |
|
850 |
periodY, bands); |
while (it.hasNext()) |
851 |
|
{ |
852 |
|
IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next(); |
853 |
|
listener.imageUpdate(this, image, minX, minY, width, height, |
854 |
|
periodX, periodY, bands); |
855 |
|
} |
856 |
} |
} |
857 |
} |
} |
858 |
|
|
865 |
*/ |
*/ |
866 |
protected void processPassComplete(BufferedImage image) |
protected void processPassComplete(BufferedImage image) |
867 |
{ |
{ |
868 |
Iterator it = updateListeners.iterator(); |
if (updateListeners != null) |
|
|
|
|
while (it.hasNext()) |
|
869 |
{ |
{ |
870 |
IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next(); |
Iterator it = updateListeners.iterator(); |
871 |
listener.passComplete(this, image); |
|
872 |
|
while (it.hasNext()) |
873 |
|
{ |
874 |
|
IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next(); |
875 |
|
listener.passComplete(this, image); |
876 |
|
} |
877 |
} |
} |
878 |
} |
} |
879 |
|
|
899 |
int maxPass, int minX, int minY, |
int maxPass, int minX, int minY, |
900 |
int periodX, int periodY, int[] bands) |
int periodX, int periodY, int[] bands) |
901 |
{ |
{ |
902 |
Iterator it = updateListeners.iterator(); |
if (updateListeners != null) |
|
|
|
|
while (it.hasNext()) |
|
903 |
{ |
{ |
904 |
IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next(); |
Iterator it = updateListeners.iterator(); |
905 |
listener.passStarted(this, image, pass, minPass, maxPass, minX, minY, |
|
906 |
periodX, periodY, bands); |
while (it.hasNext()) |
907 |
|
{ |
908 |
|
IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next(); |
909 |
|
listener.passStarted(this, image, pass, minPass, maxPass, minX, |
910 |
|
minY, periodX, periodY, bands); |
911 |
|
} |
912 |
} |
} |
913 |
} |
} |
914 |
|
|
918 |
*/ |
*/ |
919 |
protected void processReadAborted() |
protected void processReadAborted() |
920 |
{ |
{ |
921 |
Iterator it = progressListeners.iterator(); |
if (progressListeners != null) |
|
|
|
|
while (it.hasNext()) |
|
922 |
{ |
{ |
923 |
IIOReadProgressListener listener = (IIOReadProgressListener) it.next(); |
Iterator it = progressListeners.iterator(); |
924 |
listener.readAborted(this); |
|
925 |
|
while (it.hasNext()) |
926 |
|
{ |
927 |
|
IIOReadProgressListener listener = |
928 |
|
(IIOReadProgressListener) it.next(); |
929 |
|
listener.readAborted(this); |
930 |
|
} |
931 |
} |
} |
932 |
} |
} |
|
|
|
933 |
/** |
/** |
934 |
* Notifies all installed read progress listeners, by calling their |
* Notifies all installed read progress listeners, by calling their |
935 |
* sequenceComplete methods, that a sequence of images has completed |
* sequenceComplete methods, that a sequence of images has completed |
937 |
*/ |
*/ |
938 |
protected void processSequenceComplete() |
protected void processSequenceComplete() |
939 |
{ |
{ |
940 |
Iterator it = progressListeners.iterator(); |
if (progressListeners != null) |
|
|
|
|
while (it.hasNext()) |
|
941 |
{ |
{ |
942 |
IIOReadProgressListener listener = (IIOReadProgressListener) it.next(); |
Iterator it = progressListeners.iterator(); |
943 |
listener.sequenceComplete(this); |
|
944 |
|
while (it.hasNext()) |
945 |
|
{ |
946 |
|
IIOReadProgressListener listener = |
947 |
|
(IIOReadProgressListener) it.next(); |
948 |
|
listener.sequenceComplete(this); |
949 |
|
} |
950 |
} |
} |
951 |
} |
} |
952 |
|
|
959 |
*/ |
*/ |
960 |
protected void processSequenceStarted(int minIndex) |
protected void processSequenceStarted(int minIndex) |
961 |
{ |
{ |
|
Iterator it = progressListeners.iterator(); |
|
962 |
|
|
963 |
while (it.hasNext()) |
if (progressListeners != null) |
964 |
{ |
{ |
965 |
IIOReadProgressListener listener = (IIOReadProgressListener) it.next(); |
Iterator it = progressListeners.iterator(); |
966 |
listener.sequenceStarted(this, minIndex); |
|
967 |
|
while (it.hasNext()) |
968 |
|
{ |
969 |
|
IIOReadProgressListener listener = |
970 |
|
(IIOReadProgressListener) it.next(); |
971 |
|
listener.sequenceStarted(this, minIndex); |
972 |
|
} |
973 |
} |
} |
974 |
} |
} |
975 |
|
|
980 |
*/ |
*/ |
981 |
protected void processThumbnailComplete() |
protected void processThumbnailComplete() |
982 |
{ |
{ |
983 |
Iterator it = progressListeners.iterator(); |
if (progressListeners != null) |
|
|
|
|
while (it.hasNext()) |
|
984 |
{ |
{ |
985 |
IIOReadProgressListener listener = (IIOReadProgressListener) it.next(); |
Iterator it = progressListeners.iterator(); |
986 |
listener.thumbnailComplete(this); |
|
987 |
|
while (it.hasNext()) |
988 |
|
{ |
989 |
|
IIOReadProgressListener listener = |
990 |
|
(IIOReadProgressListener) it.next(); |
991 |
|
listener.thumbnailComplete(this); |
992 |
|
} |
993 |
} |
} |
994 |
} |
} |
995 |
|
|
1002 |
*/ |
*/ |
1003 |
protected void processThumbnailPassComplete(BufferedImage thumbnail) |
protected void processThumbnailPassComplete(BufferedImage thumbnail) |
1004 |
{ |
{ |
1005 |
Iterator it = updateListeners.iterator(); |
if (updateListeners != null) |
|
|
|
|
while (it.hasNext()) |
|
1006 |
{ |
{ |
1007 |
IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next(); |
Iterator it = updateListeners.iterator(); |
1008 |
listener.thumbnailPassComplete(this, thumbnail); |
|
1009 |
|
while (it.hasNext()) |
1010 |
|
{ |
1011 |
|
IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next(); |
1012 |
|
listener.thumbnailPassComplete(this, thumbnail); |
1013 |
|
} |
1014 |
} |
} |
1015 |
} |
} |
1016 |
|
|
1037 |
int minY, int periodX, int periodY, |
int minY, int periodX, int periodY, |
1038 |
int[] bands) |
int[] bands) |
1039 |
{ |
{ |
1040 |
Iterator it = updateListeners.iterator(); |
if (updateListeners != null) |
|
|
|
|
while (it.hasNext()) |
|
1041 |
{ |
{ |
1042 |
IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next(); |
Iterator it = updateListeners.iterator(); |
1043 |
listener.thumbnailPassStarted(this, thumbnail, pass, minPass, maxPass, |
|
1044 |
minX, minY, periodX, periodY, bands); |
while (it.hasNext()) |
1045 |
|
{ |
1046 |
|
IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next(); |
1047 |
|
listener.thumbnailPassStarted(this, thumbnail, pass, minPass, |
1048 |
|
maxPass, minX, minY, periodX, |
1049 |
|
periodY, bands); |
1050 |
|
} |
1051 |
} |
} |
1052 |
} |
} |
1053 |
|
|
1054 |
/** |
/** |
1055 |
* Notifies all installed read progress listeners that a certain |
* Notifies all installed read progress listeners that a certain |
1056 |
* percentage of a thumbnail has been loaded, by calling their |
* percentage of a thumbnail has been loaded, by calling their |
1061 |
*/ |
*/ |
1062 |
protected void processThumbnailProgress(float percentageDone) |
protected void processThumbnailProgress(float percentageDone) |
1063 |
{ |
{ |
1064 |
Iterator it = progressListeners.iterator(); |
if (progressListeners != null) |
|
|
|
|
while (it.hasNext()) |
|
1065 |
{ |
{ |
1066 |
IIOReadProgressListener listener = (IIOReadProgressListener) it.next(); |
Iterator it = progressListeners.iterator(); |
1067 |
listener.thumbnailProgress(this, percentageDone); |
|
1068 |
|
while (it.hasNext()) |
1069 |
|
{ |
1070 |
|
IIOReadProgressListener listener = |
1071 |
|
(IIOReadProgressListener) it.next(); |
1072 |
|
listener.thumbnailProgress(this, percentageDone); |
1073 |
|
} |
1074 |
} |
} |
1075 |
} |
} |
1076 |
|
|
1086 |
*/ |
*/ |
1087 |
protected void processThumbnailStarted(int imageIndex, int thumbnailIndex) |
protected void processThumbnailStarted(int imageIndex, int thumbnailIndex) |
1088 |
{ |
{ |
1089 |
Iterator it = progressListeners.iterator(); |
if (progressListeners != null) |
|
|
|
|
while (it.hasNext()) |
|
1090 |
{ |
{ |
1091 |
IIOReadProgressListener listener = (IIOReadProgressListener) it.next(); |
Iterator it = progressListeners.iterator(); |
1092 |
listener.thumbnailStarted(this, imageIndex, thumbnailIndex); |
|
1093 |
|
while (it.hasNext()) |
1094 |
|
{ |
1095 |
|
IIOReadProgressListener listener = |
1096 |
|
(IIOReadProgressListener) it.next(); |
1097 |
|
listener.thumbnailStarted(this, imageIndex, thumbnailIndex); |
1098 |
|
} |
1099 |
} |
} |
1100 |
} |
} |
1101 |
|
|
1118 |
int width, int height, int periodX, |
int width, int height, int periodX, |
1119 |
int periodY, int[] bands) |
int periodY, int[] bands) |
1120 |
{ |
{ |
1121 |
Iterator it = updateListeners.iterator(); |
if (updateListeners != null) |
|
|
|
|
while (it.hasNext()) |
|
1122 |
{ |
{ |
1123 |
IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next(); |
Iterator it = updateListeners.iterator(); |
1124 |
listener.thumbnailUpdate(this, image, minX, minY, width, height, |
|
1125 |
periodX, periodY, bands); |
while (it.hasNext()) |
1126 |
|
{ |
1127 |
|
IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next(); |
1128 |
|
listener.thumbnailUpdate(this, image, minX, minY, width, height, |
1129 |
|
periodX, periodY, bands); |
1130 |
|
} |
1131 |
} |
} |
1132 |
} |
} |
1133 |
|
|
1143 |
{ |
{ |
1144 |
if (warning == null) |
if (warning == null) |
1145 |
throw new IllegalArgumentException ("null argument"); |
throw new IllegalArgumentException ("null argument"); |
1146 |
|
if (warningListeners != null) |
|
Iterator it = warningListeners.iterator(); |
|
|
|
|
|
while (it.hasNext()) |
|
1147 |
{ |
{ |
1148 |
IIOReadWarningListener listener = (IIOReadWarningListener) it.next(); |
Iterator it = warningListeners.iterator(); |
1149 |
listener.warningOccurred(this, warning); |
|
1150 |
|
while (it.hasNext()) |
1151 |
|
{ |
1152 |
|
IIOReadWarningListener listener = |
1153 |
|
(IIOReadWarningListener) it.next(); |
1154 |
|
listener.warningOccurred(this, warning); |
1155 |
|
} |
1156 |
} |
} |
1157 |
} |
} |
1158 |
|
|
1265 |
{ |
{ |
1266 |
if (listener == null) |
if (listener == null) |
1267 |
return; |
return; |
1268 |
|
if (progressListeners != null) |
1269 |
progressListeners.remove(listener); |
{ |
1270 |
|
progressListeners.remove(listener); |
1271 |
|
} |
1272 |
} |
} |
1273 |
|
|
1274 |
/** |
/** |
1275 |
* Uninstall the given read update listener. |
* Uninstall the given read update listener. |
1276 |
* |
* |
1280 |
{ |
{ |
1281 |
if (listener == null) |
if (listener == null) |
1282 |
return; |
return; |
1283 |
|
|
1284 |
updateListeners.remove(listener); |
if (updateListeners != null) |
1285 |
|
{ |
1286 |
|
updateListeners.remove(listener); |
1287 |
|
} |
1288 |
} |
} |
1289 |
|
|
1290 |
/** |
/** |
1291 |
* Uninstall the given read warning listener. |
* Uninstall the given read warning listener. |
1292 |
* |
* |
1296 |
{ |
{ |
1297 |
if (listener == null) |
if (listener == null) |
1298 |
return; |
return; |
1299 |
|
if (warningListeners != null) |
1300 |
warningListeners.remove(listener); |
{ |
1301 |
|
warningListeners.remove(listener); |
1302 |
|
} |
1303 |
} |
} |
1304 |
|
|
1305 |
/** |
/** |