ch.sahits.game.graphic.display.dialog
Class ConsumtionProductionStockDialog

java.lang.Object
  extended by ch.sahits.game.graphic.display.dialog.OpenPatricianGameDialog
      extended by ch.sahits.game.graphic.display.dialog.ConsumtionProductionStockDialog
All Implemented Interfaces:
IEventListener, Renderable, RenderablePart

public class ConsumtionProductionStockDialog
extends OpenPatricianGameDialog
implements IEventListener, RenderablePart

This is a statistical dialog displaying the socked wares in the city and their prices.

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

Nested Class Summary
private static class ConsumtionProductionStockDialog.DialogPositions
          This class holds the positions where different elements are placed on the dialog.
 
Nested classes/interfaces inherited from class ch.sahits.game.graphic.display.dialog.OpenPatricianGameDialog
OpenPatricianGameDialog.CloseAction
 
Field Summary
private  boolean enabled
           
private  ClickablePolygons footerPolygons
           
private  IImageUtilities imageUtils
          reference to the utilities for image manipulation
private  IOpenPatricianPainter opPainter
           
private  ConsumtionProductionStockDialog.DialogPositions positions
          Hold all the positioning information, initialized in initBackgroundImage
 
Fields inherited from class ch.sahits.game.graphic.display.dialog.OpenPatricianGameDialog
city, inset, loader
 
Constructor Summary
ConsumtionProductionStockDialog(Point topLeft, double scale, CityPlayerProxy cityProxy)
           
 
Method Summary
private  int computeCitizenConsumtion(DisplayImageDIResolver resolver, ICity city, EWare ware)
          Compute the amount that all the citizens consume
private  boolean contains(IWare[] array, IWare item)
          check if the array contains the item
private  int drawAvailableAmount(Graphics2D g2d, ICity city, IWare ware, BufferedImage barrel, BufferedImage bale, int y)
          Draw the available amount (second column).
private  void drawChandlerConsumption(Graphics2D g2d, DisplayImageDIResolver resolver, ICity cityModel, EWare ware, BufferedImage barrel, BufferedImage bale, int y)
          Draw the amount the workshops consume of a ware
private  void drawChandlerProduction(Graphics2D g2d, DisplayImageDIResolver resolver, ICity cityModel, EWare ware, BufferedImage barrel, BufferedImage bale, int y)
          Draw the amount all the chandlers produce
private  void drawCitizensConsumtion(Graphics2D g2d, DisplayImageDIResolver resolver, ICity cityModel, EWare ware, BufferedImage barrel, BufferedImage bale, int y)
          Draw the amount the citizens consume
private  void drawCityProduction(Graphics2D g2d, DisplayImageDIResolver resolver, ICity city, EWare ware, BufferedImage barrel, BufferedImage bale, int y)
          Draw the amount the city produces per week
private  void drawTableHeader(Graphics2D g2d, int y)
          Draw the table header
private  void drawTotalConsumtion(Graphics2D g2d, DisplayImageDIResolver resolver, ICity cityModel, EWare ware, BufferedImage barrel, BufferedImage bale, int y)
          Draw the total amount that is consumed of the ware
private  void drawWareAmount(Graphics2D g2d, EWare ware, BufferedImage barrel, BufferedImage bale, int y, int amount, int xPadding)
          Optionally draw the amoount of wares (if positive) together with the correct icon
 void gameRender(Graphics gScr)
           
 void gameUpdate(Event e, Object notice)
           
protected  void init()
          Initialize class specific stuff which might be need later in the initialisation
protected  BufferedImage initBackgroundImage(IImageLoader loader, Point topLeft)
          Initialize the background image that is stored as a reference.
protected  void initiatePolygons()
          Instanciate the any polygon member variables.
protected  void initInsets(double scale)
          Compute the insets as a factor of the scaling
 boolean isEnabled()
           
 void setEnabled(boolean flag)
           
 
Methods inherited from class ch.sahits.game.graphic.display.dialog.OpenPatricianGameDialog
getBounds, getInset
 
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.rendering.RenderablePart
getBounds
 

Field Detail

enabled

private boolean enabled

footerPolygons

private ClickablePolygons footerPolygons

positions

private ConsumtionProductionStockDialog.DialogPositions positions
Hold all the positioning information, initialized in initBackgroundImage


imageUtils

private IImageUtilities imageUtils
reference to the utilities for image manipulation


opPainter

private IOpenPatricianPainter opPainter
Constructor Detail

ConsumtionProductionStockDialog

public ConsumtionProductionStockDialog(Point topLeft,
                                       double scale,
                                       CityPlayerProxy cityProxy)
Method Detail

init

protected void init()
Description copied from class: OpenPatricianGameDialog
Initialize class specific stuff which might be need later in the initialisation

Overrides:
init in class OpenPatricianGameDialog

initInsets

protected void initInsets(double scale)
Compute the insets as a factor of the scaling

Overrides:
initInsets in class OpenPatricianGameDialog
Parameters:
scale -

initiatePolygons

protected void initiatePolygons()
Description copied from class: OpenPatricianGameDialog
Instanciate the any polygon member variables. This method is intended to be overriden if the dialog uses polygons.

Overrides:
initiatePolygons in class OpenPatricianGameDialog

gameUpdate

public void gameUpdate(Event e,
                       Object notice)
Specified by:
gameUpdate in interface IEventListener
Specified by:
gameUpdate in interface Renderable

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface Renderable

setEnabled

public void setEnabled(boolean flag)
Specified by:
setEnabled in interface Renderable

drawTableHeader

private void drawTableHeader(Graphics2D g2d,
                             int y)
                      throws FontFormatException,
                             IOException
Draw the table header

Parameters:
g2d -
y - position of the table header baseline
Throws:
FontFormatException
IOException

initBackgroundImage

protected BufferedImage initBackgroundImage(IImageLoader loader,
                                            Point topLeft)
Description copied from class: OpenPatricianGameDialog
Initialize the background image that is stored as a reference. This method should be overridden by any subclass that contains static elements in the dialog. This implementation returns a copy of the background image stored in the cache, so that image can be further processed, without inflicting conflicts.

Overrides:
initBackgroundImage in class OpenPatricianGameDialog
Parameters:
loader - ImageLoader to retrieve images
Returns:
Image that will be stored as background

gameRender

public void gameRender(Graphics gScr)
Specified by:
gameRender in interface Renderable
Overrides:
gameRender in class OpenPatricianGameDialog

drawTotalConsumtion

private void drawTotalConsumtion(Graphics2D g2d,
                                 DisplayImageDIResolver resolver,
                                 ICity cityModel,
                                 EWare ware,
                                 BufferedImage barrel,
                                 BufferedImage bale,
                                 int y)
                          throws FontFormatException,
                                 IOException
Draw the total amount that is consumed of the ware

Parameters:
g2d - 2D graphics context used for drawing
resolver - Spring bean resolver
city - Reference to the city
ware - Reference to the ware
barrel - icon
bale - icon
y - position of from the top
Throws:
IOException
FontFormatException

drawChandlerConsumption

private void drawChandlerConsumption(Graphics2D g2d,
                                     DisplayImageDIResolver resolver,
                                     ICity cityModel,
                                     EWare ware,
                                     BufferedImage barrel,
                                     BufferedImage bale,
                                     int y)
                              throws FontFormatException,
                                     IOException
Draw the amount the workshops consume of a ware

Parameters:
g2d - 2D graphics context used for drawing
resolver - Spring bean resolver
city - Reference to the city
ware - Reference to the ware
barrel - icon
bale - icon
y - position of from the top
Throws:
IOException
FontFormatException

drawCitizensConsumtion

private void drawCitizensConsumtion(Graphics2D g2d,
                                    DisplayImageDIResolver resolver,
                                    ICity cityModel,
                                    EWare ware,
                                    BufferedImage barrel,
                                    BufferedImage bale,
                                    int y)
                             throws FontFormatException,
                                    IOException
Draw the amount the citizens consume

Parameters:
g2d - 2D graphics context used for drawing
resolver - Spring bean resolver
city - Reference to the city
ware - Reference to the ware
barrel - icon
bale - icon
y - position of from the top
Throws:
IOException
FontFormatException

computeCitizenConsumtion

private int computeCitizenConsumtion(DisplayImageDIResolver resolver,
                                     ICity city,
                                     EWare ware)
Compute the amount that all the citizens consume

Parameters:
resolver - Spring bean resolver
city - Reference to the city
ware - Reference to the ware
Returns:
amount all the citizens consume of that ware

drawChandlerProduction

private void drawChandlerProduction(Graphics2D g2d,
                                    DisplayImageDIResolver resolver,
                                    ICity cityModel,
                                    EWare ware,
                                    BufferedImage barrel,
                                    BufferedImage bale,
                                    int y)
                             throws FontFormatException,
                                    IOException
Draw the amount all the chandlers produce

Parameters:
resolver - Spring bean resolver
g2d - 2D graphics context used for drawing
city - Reference to the city
ware - Reference to the ware
barrel - icon
bale - icon
y - position of from the top
Throws:
IOException
FontFormatException

drawCityProduction

private void drawCityProduction(Graphics2D g2d,
                                DisplayImageDIResolver resolver,
                                ICity city,
                                EWare ware,
                                BufferedImage barrel,
                                BufferedImage bale,
                                int y)
                         throws FontFormatException,
                                IOException
Draw the amount the city produces per week

Parameters:
g2d - 2D graphics context used for drawing
resolver - Spring bean resolver
city - Reference to the city
ware - Reference to the ware
barrel - icon
bale - icon
y - position of from the top
Throws:
IOException
FontFormatException

drawWareAmount

private void drawWareAmount(Graphics2D g2d,
                            EWare ware,
                            BufferedImage barrel,
                            BufferedImage bale,
                            int y,
                            int amount,
                            int xPadding)
                     throws FontFormatException,
                            IOException
Optionally draw the amoount of wares (if positive) together with the correct icon

Parameters:
g2d -
ware -
barrel -
bale -
y -
amount -
xPadding -
Throws:
FontFormatException
IOException

contains

private boolean contains(IWare[] array,
                         IWare item)
check if the array contains the item

Parameters:
array -
item -
Returns:

drawAvailableAmount

private int drawAvailableAmount(Graphics2D g2d,
                                ICity city,
                                IWare ware,
                                BufferedImage barrel,
                                BufferedImage bale,
                                int y)
                         throws FontFormatException,
                                IOException
Draw the available amount (second column). Available refers either to city or the storage based on the current dialog type.

Parameters:
g2d - 2D graphics context used for drawing
city - Reference to the city
ware - Reference to the ware
barrel - icon
bale - icon
y - position of from the top
Returns:
the available amount
Throws:
FontFormatException - Error while creating a font
IOException - Error while reading a resource


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