/** * the constructor of the class * * @param editor the editor */ public ResourceImageManager(Editor editor) { this.editor = editor; // the listener to the svg handle changes editor .getHandlesManager() .addHandlesListener( new HandlesListener() { @Override public void handleChanged(SVGHandle currentHandle, Set<SVGHandle> handles) { // removes the frames that have been closed from the map for (SVGHandle handle : new LinkedList<SVGHandle>(handleToIdToImages.keySet())) { if (handle != null && !handles.contains(handle)) { handleToIdToImages.remove(handle); } } // removes the image representations that belongs to disposed // svg handles for (ResourceRepresentation rep : new HashSet<ResourceRepresentation>(resourceRepresentationList)) { if (rep != null && !handles.contains(rep.getSVGHandle())) { rep.dispose(); resourceRepresentationList.remove(rep); } } } }); // sets the format used to convert numbers into a string DecimalFormatSymbols symbols = new DecimalFormatSymbols(); symbols.setDecimalSeparator('.'); format = new DecimalFormat("######.#", symbols); // the queue manager queueManager = new Thread() { @Override public void run() { Runnable runnable = null; while (true) { while (queue.size() > 0) { // getting the runnable runnable = queue.get(0); // removing it from the queue queue.remove(runnable); // running the runnable runnable.run(); runnable = null; } try { sleep(100); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } } } }; queueManager.start(); }