/** * Return a fresh weak set. */ public static WeakSet createWeakSet() { WeakSet ret = new WeakSet(); if(DEBUG) addCollection(ret); return ret; }
/** * Create a blocksworld panel. * @param table The table. * @param imaginary Flag indicating that its not the real world. */ public BlocksworldPanel(Table table, boolean imaginary) { this.table = table; this.imaginary = imaginary; this.blocksize = 100; this.blocks = new WeakSet<Block>(); // Update gui when table changes. this.pcl = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent pce) { // Update gui. BlocksworldPanel.this.invalidate(); BlocksworldPanel.this.repaint(); // Add listener for new blocks. BlocksworldPanel.this.observeNewBlocks(); } }; table.addPropertyChangeListener(pcl); // Add listener to blocks. observeNewBlocks(); }
/** * Create a blocksworld panel. * @param table The table. * @param imaginary Flag indicating that its not the real world. */ public BlocksworldPanel(Table table, boolean imaginary) { this.table = table; this.imaginary = imaginary; this.blocksize = 100; this.blocks = new WeakSet<Block>(); // Update gui when table changes. this.pcl = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent pce) { // Update gui. BlocksworldPanel.this.invalidate(); BlocksworldPanel.this.repaint(); // Add listener for new blocks. BlocksworldPanel.this.observeNewBlocks(); } }; table.addPropertyChangeListener(pcl); // Add listener to blocks. observeNewBlocks(); }