public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; bg.paintIcon(this, g2, 0, 0); TreeMap<Integer, FactoryObject> to = (TreeMap<Integer, FactoryObject>) fos.clone(); for (Integer i : to.keySet()) { FactoryObject t = to.get(i); if (t.getIsLine()) { g2.setColor(Color.WHITE); g2.drawLine(t.getPositionX(), t.getPositionY(), t.getPositionXF(), t.getPositionYF()); } else { if (t.getImageIndex() >= 0) { ImageIcon tmp = images.getIcon(t.getImageIndex()); tmp.paintIcon(this, g2, t.getPositionX(), t.getPositionY()); } } } }
public void syncChanges(ArrayList<TreeMap<Integer, FactoryObject>> dataArray) { if (dataArray.size() == 1) { TreeMap<Integer, FactoryObject> changeData = dataArray.get(0); fos.clear(); fos = changeData; } else { System.out.println("Warning: Corrupt frame data"); } repaint(); }
// client specific public void mergeChanges( ArrayList<TreeMap<Integer, Boolean>> mapArray, ArrayList<TreeMap<Integer, FactoryObject>> dataArray) { if (mapArray.size() == 1) { TreeMap<Integer, Boolean> changeMap = mapArray.get(0); TreeMap<Integer, FactoryObject> changeData = dataArray.get(0); // iterate over all the keys present in changeMap // after this loop is complete, the frameAnimationData map will be accurately synced with the // server copy Set<Integer> t = changeMap.keySet(); for (Integer i : t) { if (changeMap.get(i)) { fos.put(i, changeData.get(i)); } else { fos.remove(i); } } } else { System.out.println("Warning: Corrupt frame data"); } repaint(); }