civquest.swing.fieldview
Interface FieldView

All Known Subinterfaces:
QuadFieldView, QuadFlatFieldView, QuadIsoFieldView, TerrainView, UnitView
All Known Implementing Classes:
BasicFieldView, CompositeFieldView, QuadFlatLayeredFieldView, QuadFlatLayTerrainView, QuadFlatLayUnitView, QuadIsoLayeredFieldView, QuadIsoLayTerrainView, QuadIsoLayUnitView

public interface FieldView

Top of the FieldView-hierarchy.

A FieldView is responsible for painting (at least parts of) one Field. This means, it may paint an image representing the whole Field, but may also paint just an Image representing the Terrain and nothing else.


Method Summary
 Field getField()
          Returns the field this FieldView displays.
 java.util.List getListenerSectionsForParent()
          Returns a List of Sections defining which GameChanges this FieldView listens to.
 Coordinate getPaintSize()
          Returns the size of the area this FieldView paints to.
 void paint(Coordinate coord, java.awt.Graphics graphics)
          Paints (some parts of) the field this FieldView is assigned to.
 void updateImage()
          If this FieldView stores some images (and doesn't just load and calculate the needed images inside the paint-method), this method recalculates that images.
 

Method Detail

getField

public Field getField()
Returns the field this FieldView displays.

Returns:
the field this FieldView displays

paint

public void paint(Coordinate coord,
                  java.awt.Graphics graphics)
Paints (some parts of) the field this FieldView is assigned to. Painting is performed relative to the given Coordinate using the given Graphics-object.

Parameters:
coord - base-Coordinate used for painting
graphics - Graphics-object to paint with

getPaintSize

public Coordinate getPaintSize()
Returns the size of the area this FieldView paints to.

Returns:
size of the area this FieldView paints to

updateImage

public void updateImage()
If this FieldView stores some images (and doesn't just load and calculate the needed images inside the paint-method), this method recalculates that images.

So this method should be called whenever some data the FieldView displays changes.

Note: Subinterfaces / implementing classes may specify that they listen to all required GameChanges directly. Then, calling this method from the XXXChanged-methods inside the FieldView suffices. (This behaviour can't be standard since some thousand Fields listening to a GameChange affecting just one or two Fields would be pretty inefficient).


getListenerSectionsForParent

public java.util.List getListenerSectionsForParent()
Returns a List of Sections defining which GameChanges this FieldView listens to. Only those sections which have to be processed by the parent of this FieldView (because this FieldView doesn't process them itself) are inserted into this List.

Returns:
a List of Section as defined