View Javadoc

1   package erland.game.tileadventure;
2   /*
3    * Copyright (C) 2004 Erland Isaksson (erland_i@hotmail.com)
4    *
5    * This program is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU General Public License
7    * as published by the Free Software Foundation; either version 2
8    * of the License, or (at your option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18   *
19   */
20  
21  import java.awt.*;
22  import java.util.Vector;
23  import java.util.Arrays;
24  
25  public abstract class DrawMap implements MapDrawInterface {
26      private IrregularBlockContainerInterface cont;
27      private MapObjectContainerInterface[] maps = new MapObjectContainerInterface[0];
28  
29      public void setContainer(IrregularBlockContainerInterface cont) {
30          this.cont = cont;
31      }
32  
33      protected IrregularBlockContainerInterface getContainer() {
34          return cont;
35      }
36  
37      public void removeAllObjectMaps() {
38          maps = new MapObjectContainerInterface[0];
39      }
40      public void addObjectMap(MapObjectContainerInterface map) {
41          Vector tmp = new Vector(Arrays.asList(maps));
42          tmp.addElement(map);
43          maps = (MapObjectContainerInterface[]) tmp.toArray(new MapObjectContainerInterface[0]);
44      }
45  
46      protected MapObjectContainerInterface[] getMaps() {
47          return maps;
48      }
49  
50  
51      public abstract void draw(Graphics g);
52  }
53