ch.sahits.game.graphic.display.gameplay.internal
Class AbstractSceneHandler

java.lang.Object
  extended by ch.sahits.game.graphic.display.gameplay.internal.AbstractSceneHandler
All Implemented Interfaces:
ISceneHandler
Direct Known Subclasses:
MarketPlaceScenehandler, PortSceneHandler

abstract class AbstractSceneHandler
extends Object
implements ISceneHandler

This abstract class provides base functionallyty for loading and initializing a scene as well as doing stuff on that scene

Author:
Andi Hotz, (c) Sahits GmbH, 2012 Created on Jul 17, 2012

Field Summary
protected  IImageUtilities imageUtils
           
private static org.apache.log4j.Logger logger
           
protected  Map<Integer,NamedPolygon> polygons
          Store the polygons for checking against clicking them Using a TreeMap so it may be possible do define polygons that cover the same are but in a different z-order.
private  Rectangle rect
           
protected  Map<String,Double> scaleMap
          This map holds the scaling factor for the different images
protected  String SCENE_IMAGE_NAME
          Name of the image for this scene
protected  IDataImageLoader xmlLoader
          Loader for data from the XML
 
Constructor Summary
AbstractSceneHandler(Rectangle parentBounds, IDataImageLoader xmlLoader, DisplayImageDIResolver resolver, String imageName)
           
 
Method Summary
protected  String findPolygon(int x, int y)
          Find the polygon name that contains the coordinates.
protected  Rectangle getBounds()
           
 BufferedImage getImage()
          Retrieve the image that is cached with this handler
protected  void initPolygons(DisplayImageDIResolver resolver, ImageData imgData, ImageScaleState state, Point offset)
          Setting the positions of the polygons on the screen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ch.sahits.game.graphic.display.gameplay.internal.ISceneHandler
init, updateScene
 

Field Detail

logger

private static final org.apache.log4j.Logger logger

polygons

protected Map<Integer,NamedPolygon> polygons
Store the polygons for checking against clicking them Using a TreeMap so it may be possible do define polygons that cover the same are but in a different z-order.


scaleMap

protected final Map<String,Double> scaleMap
This map holds the scaling factor for the different images


xmlLoader

protected final IDataImageLoader xmlLoader
Loader for data from the XML


imageUtils

protected final IImageUtilities imageUtils

rect

private final Rectangle rect

SCENE_IMAGE_NAME

protected final String SCENE_IMAGE_NAME
Name of the image for this scene

Constructor Detail

AbstractSceneHandler

public AbstractSceneHandler(Rectangle parentBounds,
                            IDataImageLoader xmlLoader,
                            DisplayImageDIResolver resolver,
                            String imageName)
Method Detail

findPolygon

protected String findPolygon(int x,
                             int y)
Find the polygon name that contains the coordinates. It is expected that the polygons are not overlapping. Is this not the case the first found polygon name is returned.

Parameters:
x - coordinate
y - coordinate
Returns:
name of the polygon

initPolygons

protected void initPolygons(DisplayImageDIResolver resolver,
                            ImageData imgData,
                            ImageScaleState state,
                            Point offset)
Setting the positions of the polygons on the screen


getBounds

protected Rectangle getBounds()

getImage

public BufferedImage getImage()
Retrieve the image that is cached with this handler

Specified by:
getImage in interface ISceneHandler
Returns:


Copyright © 2011-2012 Sahits GmbH. All Rights Reserved.