22 package com.realtime.crossfire.jxclient.faces;
24 import java.util.Collection;
25 import java.util.HashSet;
26 import java.util.concurrent.ExecutorService;
27 import java.util.concurrent.Executors;
28 import javax.swing.ImageIcon;
29 import org.jetbrains.annotations.NotNull;
41 private final Object
sync =
new Object();
103 synchronized (
sync) {
105 pendingLoadFaces.clear();
115 synchronized (
sync) {
116 doAdd = pendingLoadFaces.add(face);
119 executorService.submit(
new LoadTask(face));
130 executorService.submit(
new SaveTask(face, faceImages));
161 final Thread thread = Thread.currentThread();
162 final String name = thread.getName();
164 thread.setName(
"JXClient:LoadTask:face="+face.
getFaceName());
170 final ImageIcon originalImageIcon = imageCacheOriginal.
load(face);
171 if (originalImageIcon == null) {
176 final ImageIcon scaledImageIcon = imageCacheScaled.
load(face);
177 if (scaledImageIcon == null) {
182 final ImageIcon magicMapImageIcon = imageCacheMagicMap.
load(face);
183 if (magicMapImageIcon == null) {
190 synchronized (
sync) {
191 pendingLoadFaces.remove(face);
195 thread.setName(name);
226 this.faceImages = faceImages;
231 final Thread thread = Thread.currentThread();
232 final String name = thread.getName();
234 thread.setName(
"JXClient:SaveTask:face="+face.
getFaceName());
239 thread.setName(name);
void save(@NotNull Face face, @NotNull ImageIcon imageIcon)
Stores an ImageIcon into the cache.
void reset()
Reset the processing: forget about pending faces.This function is called whenever the server socket b...
ImageIcon getScaledImageIcon()
Returns the ImageIcon scaled for the map view.
FileCacheFaceQueue(@NotNull final ImageCache imageCacheOriginal, @NotNull final ImageCache imageCacheScaled, @NotNull final ImageCache imageCacheMagicMap)
Creates a new instance.
void saveFace(@NotNull final Face face, @NotNull final FaceImages faceImages)
Saves a face to the caches.
Interface for ImageIcon caching classes.
final int taskId
The expected task FileCacheFaceQueue#id.
Consists of three ImageIcons representing a Face.
ImageIcon getMagicMapImageIcon()
Returns the ImageIcon scaled for the magic map view.
void fireFaceLoaded(@NotNull final Face face, @NotNull final FaceImages faceImages)
Notify all listener with FaceImages).
Abstract base class for classes implementing FaceQueue.
final Face face
The face to load.
ImageIcon load(@NotNull Face face)
Retrieves an image from the cache.
final Collection< Face > pendingLoadFaces
The faces for which loadFace(Face) has been called but that are not yet processed.
void fireFaceFailed(@NotNull final Face face)
Notify all listener with FaceQueueListener#faceFailed(Face).
final FaceImages faceImages
The images to save.
final ImageCache imageCacheScaled
The image cache used for loading scaled images.
A thread which saves one face to the caches.
String getFaceName()
Returns the face name.
final ImageCache imageCacheMagicMap
The image cache used for loading magic map images.
final ImageCache imageCacheOriginal
The image cache used for loading original images.
SaveTask(@NotNull final Face face, @NotNull final FaceImages faceImages)
Creates a new instance.
final Object sync
The object used for synchronization.
LoadTask(@NotNull final Face face)
Creates a new instance.
int id
Counts the number of calls to reset().
final Face face
The face to save.
ImageIcon getOriginalImageIcon()
Returns the ImageIcon as sent by the Crossfire server.
A thread which loads one face from the caches.
final ExecutorService executorService
The ExecutorService used to execute face loading.
void loadFace(@NotNull final Face face)
Request a face.Must eventually call either FaceQueueListener#faceLoaded(Face, FaceImages) or FaceQueu...
A FaceQueue loading faces from ImageCache instances.