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

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

public class TradingStockDialog
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 TradingStockDialog.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  TradingStockDialog.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
TradingStockDialog(Point topLeft, double scale, CityPlayerProxy cityProxy)
           
 
Method Summary
private  int drawAvailableAmount(Graphics2D g2d, ICity city, IWare ware, BufferedImage barrel, BufferedImage bale, int y)
          Draw the available amount (second column).
private  void drawBuyFromCityPrice(Graphics2D g2d, int availableAmount, IWare ware, BufferedImage coin, int y)
          Draw the text on the wax seal corresponding to the buy button
private  void drawSellIconText(Graphics2D g2d, int availableAmount, IWare ware, BufferedImage coin, int y)
          Draw the text on the wax seal corresponding to the sell button
private  void drawTableHeader(Graphics2D g2d, int y)
          Draw the table header
 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 TradingStockDialog.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

TradingStockDialog

public TradingStockDialog(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

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

drawBuyFromCityPrice

private void drawBuyFromCityPrice(Graphics2D g2d,
                                  int availableAmount,
                                  IWare ware,
                                  BufferedImage coin,
                                  int y)
                           throws FontFormatException,
                                  IOException
Draw the text on the wax seal corresponding to the buy button

Parameters:
g2d - 2D graphics context used for drawing
availableAmount - amount that is actually available
ware - Reference to the ware
coin - icon
y - position of from the top
Throws:
FontFormatException - Error while creating a font
IOException - Error while reading a resource

drawSellIconText

private void drawSellIconText(Graphics2D g2d,
                              int availableAmount,
                              IWare ware,
                              BufferedImage coin,
                              int y)
                       throws FontFormatException,
                              IOException
Draw the text on the wax seal corresponding to the sell button

Parameters:
g2d - 2D graphics context used for drawing
availableAmount - amount that is actually available
ware - Reference to the ware
coin - icon
y - position of from the top
Throws:
FontFormatException - Error while creating a font
IOException - Error while reading a resource


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