ch.sahits.game.graphic.display.notice
Class NoticeView

java.lang.Object
  extended by ch.sahits.game.rendering.AbstractRenderPart
      extended by ch.sahits.game.graphic.display.notice.NoticeView
All Implemented Interfaces:
IEventListener, Renderable, RenderablePart

public class NoticeView
extends AbstractRenderPart
implements IEventListener

This represents the notice view

Author:
Andi Hotz, (c) Sahits GmbH, 2011 Created on Sep 30, 2011

Nested Class Summary
private  class NoticeView.MarketBoothChangeAction
          Inner class handling the clicks on the notice for the market booth
private  class NoticeView.ScrollDownAction
          Action for the scrolling down
private  class NoticeView.ScrollUpAction
          Action for the scrolling up
private  class NoticeView.TradeDialogeChangeAction
           
private  class NoticeView.TradingOfficeChangeAction
          Inner class handling the clicks on the notice for the trading office
 
Field Summary
private  int font18Height
          height of the font in size 18
private  IFontLoader fontLoader
           
private  BufferedImage fullNotice
          Full notice, not all may be visible
private static org.apache.log4j.Logger logger
           
private  INoticeMetaData metaData
          Data object that corresponds to the rendered data in fullNotice.
private  int noticeOffset
          Offset indicating how far the fullNotice is scrolled down.
private  ClickableOffsetPolygons offsetPolys
          Polygons in the fullNotice image
private  IOpenPatricianPainter opPainter
           
private  ClickablePolygons polygons
          Polygons of the scrollbar
private static int SCROLL_OFFSET
          Offset that is scrolled with one click on the scroll bar
private  BufferedImage scrollDown
           
private  BufferedImage scrollUp
           
 
Fields inherited from class ch.sahits.game.rendering.AbstractRenderPart
rect
 
Constructor Summary
NoticeView(Rectangle rect, IImageLoader loader)
           
 
Method Summary
private  void addOffsetPolygon(Rectangle bounds, GlyphVector gv, int x, int y, String polyName, Runnable action)
          Add a named polygon to the offset polygon list.
private  void createMarketBoothNotice(ViewChangeCityPlayerProxy n)
          Initialize the full notice with the market boot notice
private  void createOrUpdateTradeNotice()
           
private  void createOrUpdateTradingOfficeNotice()
          Create or update the trading office notice based on the meta data object
private  void createTradeNotice(ICityPlayerProxy proxy)
          Initialize the full notice with the trade notice
private  void createTradingOfficeNotice(ViewChangeCityPlayerProxy proxy)
          Initialize the full notice with the trading office
private  void creatOrUpdateMarketBoothNotice()
          Create or update the market booth notice based on the meta data object
private  void drawNotice(Graphics gScr)
          Draw the visible part of the notice image
private  void drawScrollBar(Graphics gScr)
          Draw the scrollbar only if needed
 void gameRender(Graphics gScr)
           
 void gameUpdate(Event e, Object notice)
           
 Insets getInsets()
          Insets for the notice board
private  void initPolygons()
          Initialize common polygons
private  boolean isScrolledToBottom()
          Check if the bottom of the notice is shown
private  boolean isScrolledToTop()
          check if the top of the notice is shown
private  boolean needsScrollBar()
          check if the notice is to large to be displayed without scrolling
private  void resetNoticeView()
          Reset the notice view and other affiliated members
 
Methods inherited from class ch.sahits.game.rendering.AbstractRenderPart
getBounds, isEnabled, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final org.apache.log4j.Logger logger

opPainter

private final IOpenPatricianPainter opPainter

fontLoader

private final IFontLoader fontLoader

SCROLL_OFFSET

private static final int SCROLL_OFFSET
Offset that is scrolled with one click on the scroll bar

See Also:
Constant Field Values

scrollUp

private final BufferedImage scrollUp

scrollDown

private final BufferedImage scrollDown

fullNotice

private BufferedImage fullNotice
Full notice, not all may be visible


noticeOffset

private int noticeOffset
Offset indicating how far the fullNotice is scrolled down. The value is always positive. Zero indicates no scroll


font18Height

private final int font18Height
height of the font in size 18


polygons

private final ClickablePolygons polygons
Polygons of the scrollbar


offsetPolys

private ClickableOffsetPolygons offsetPolys
Polygons in the fullNotice image


metaData

private INoticeMetaData metaData
Data object that corresponds to the rendered data in fullNotice. The meta data provide the necessairy informations to process updates in the notice.

Constructor Detail

NoticeView

public NoticeView(Rectangle rect,
                  IImageLoader loader)
Method Detail

initPolygons

private void initPolygons()
Initialize common polygons


gameRender

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

drawScrollBar

private void drawScrollBar(Graphics gScr)
Draw the scrollbar only if needed

Parameters:
gScr -

getInsets

public Insets getInsets()
Insets for the notice board

Returns:

drawNotice

private void drawNotice(Graphics gScr)
Draw the visible part of the notice image

Parameters:
gScr -

gameUpdate

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

resetNoticeView

private void resetNoticeView()
Reset the notice view and other affiliated members


createMarketBoothNotice

private void createMarketBoothNotice(ViewChangeCityPlayerProxy n)
                              throws FontFormatException,
                                     IOException
Initialize the full notice with the market boot notice

Parameters:
n -
Throws:
IOException
FontFormatException

createTradingOfficeNotice

private void createTradingOfficeNotice(ViewChangeCityPlayerProxy proxy)
                                throws FontFormatException,
                                       IOException
Initialize the full notice with the trading office

Parameters:
n -
Throws:
IOException
FontFormatException

createTradeNotice

private void createTradeNotice(ICityPlayerProxy proxy)
                        throws FontFormatException,
                               IOException
Initialize the full notice with the trade notice

Throws:
IOException
FontFormatException

createOrUpdateTradingOfficeNotice

private void createOrUpdateTradingOfficeNotice()
                                        throws FontFormatException,
                                               IOException
Create or update the trading office notice based on the meta data object

Throws:
IOException
FontFormatException

creatOrUpdateMarketBoothNotice

private void creatOrUpdateMarketBoothNotice()
                                     throws FontFormatException,
                                            IOException
Create or update the market booth notice based on the meta data object

Throws:
IOException
FontFormatException

createOrUpdateTradeNotice

private void createOrUpdateTradeNotice()
                                throws FontFormatException,
                                       IOException
Throws:
FontFormatException
IOException

addOffsetPolygon

private void addOffsetPolygon(Rectangle bounds,
                              GlyphVector gv,
                              int x,
                              int y,
                              String polyName,
                              Runnable action)
Add a named polygon to the offset polygon list. the contour of the polygon is computed by the outline of the string that makes out the GlyphVector added at position x,y within bounds. (x,y) are relative coordinates to bounds.

Parameters:
bounds - Bounds of the view
gv - GlyphVector holding the string
x - position of the left most character
y - position of the strings baseline
polyName - name of the Polygon
action - to be executed when run.

needsScrollBar

private boolean needsScrollBar()
check if the notice is to large to be displayed without scrolling

Returns:

isScrolledToTop

private boolean isScrolledToTop()
check if the top of the notice is shown

Returns:

isScrolledToBottom

private boolean isScrolledToBottom()
Check if the bottom of the notice is shown

Returns:


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