civquest.swing.quadmap
Class Properties

java.lang.Object
  extended bycivquest.swing.quadmap.Properties

public abstract class Properties
extends java.lang.Object

Every subclass of this class implements all data and function that is specific to the particular type of map (at present flat or iso) QuadMap runs on at the moment.

Some definitions:

The drawing-buffer-coordinate of a Field is the coordinate of the pixel in the column of the most western pixel and the row of the most northern pixel of the Field.

An absolute paint-coordinate is a coordinate relative to the viewportPosition (0,0). NOTE that no negative x or y-values are allowed for such a coordinate!!!

(Really?) An unscrolled array-coordinate is an array-coordinate that is not necessarily within map.


Field Summary
protected  QuadMap quadMap
           
 
Constructor Summary
Properties()
           
 
Method Summary
abstract  Coordinate adjustArrayCoordToScrolling(Coordinate coord)
          Adjusts the given array-coordinate to the scrolling; this means that coordinates east/west of the east/west map-edge are converted to the corresponding coordinate on the map.
 Coordinate adjustArrayCoordToScrolling(int x, int y)
           
abstract  civquest.swing.UnitPainter constructUnitPainter(QuadMap quadMap)
          Returns an UnitPainter appropriate for this type of map.
abstract  civquest.swing.UnitView constructUnitView(Unit unit)
          Constructs a UnitView for the given Unit.
abstract  Coordinate[] getAbsFieldEdgeCoords(Coordinate coord)
          Returns an array containing the (abs.
 Coordinate[] getAbsFieldEdgeCoords(Field field)
           
abstract  Coordinate getAbsImagePaintCoord(Coordinate coord)
          Returns the (absolute paint-)coordinate that must be used in order to paint an image for this field.
abstract  Rectangle getAbsImagePaintRectangle(Coordinate coord)
          Returns the smallest rectangle containing the complete image used for drawing the field at the given array-coordinate.
 Rectangle getAbsImagePaintRectangle(Field field)
           
abstract  Coordinate getAbsMiddlePaintCoord(Coordinate coord)
          Returns the "middle"-absolute-paintcoord of Field field.
abstract  Coordinate getAbsPaintCoord(Coordinate coord)
          Returns the drawing-buffer-coordinate of Field (array- x,y) (as an absolute paint-coordinate).
 java.util.Iterator getAbsRectFieldIterator(Buffer buffer)
           
abstract  java.util.Iterator getAbsRectFieldIterator(Coordinate c1, Coordinate c2)
          Returns an iterator that iterates through all Fields located within the specified rectangle, where the coords are given as absolute-paint-coords.
abstract  Field getFieldByAbs(Coordinate paintCoord)
          Returns a reference to the field that is at the given absolute paint-coordinate.
abstract  Rectangle getFieldRectangle(int x1, int y1, int x2, int y2)
           
 Rectangle getFieldRectangle(Rectangle paintRect)
          Returns the smallest rectangle (inside the fields-array) containing all fields displayed within the given rectangle (in absolute paint-coords).
abstract  Coordinate getPaintSize()
          Returns the number of pixels you need to paint the complete map.
abstract  Coordinate getScrollSize()
          Returns the number of pixels you need to scroll in a direction in order to end up at the same position again.
abstract  Registry getSpecializedRegistry()
          Returns the registry, where settings specific to _this_ type of map (for example "iso") get stored.
abstract  Coordinate getUnscrolledArrayCoord(Coordinate paintCoord)
          Transforms the given absolute paint-coordinate into an unscrolled array-coordinate.
 Coordinate getUnscrolledArrayCoord(int x, int y)
           
abstract  void paintField(civquest.swing.quadmap.PaintInfo paintInfo, Buffer buffer)
          Paint the field specified in the given paintInfo into the given buffer, using the unscrolled array-coordinate specified in the given paintInfo.
 void repaintBuffer(Buffer buffer)
          Repaint the whole buffer.
abstract  void updateDirtyFields(Buffer buffer)
          Update all fields marked for update within the given buffer.
abstract  void updateFields(Buffer buffer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

quadMap

protected QuadMap quadMap
Constructor Detail

Properties

public Properties()
Method Detail

getScrollSize

public abstract Coordinate getScrollSize()
Returns the number of pixels you need to scroll in a direction in order to end up at the same position again. Note that this is not necessarily the number of pixels you would need to draw the complete map.


getPaintSize

public abstract Coordinate getPaintSize()
Returns the number of pixels you need to paint the complete map.


adjustArrayCoordToScrolling

public abstract Coordinate adjustArrayCoordToScrolling(Coordinate coord)
Adjusts the given array-coordinate to the scrolling; this means that coordinates east/west of the east/west map-edge are converted to the corresponding coordinate on the map. For example, on a flat map, mapWidth is subtracted from / added to the x-coordinate until it is within map.

Parameters:
coord - a coordinate in the array-coordinate-system (not necessarily in the array)
Returns:
the adjusted coordinate as described; NOTE that this coordinate might not be located on the map.

adjustArrayCoordToScrolling

public Coordinate adjustArrayCoordToScrolling(int x,
                                              int y)

getUnscrolledArrayCoord

public abstract Coordinate getUnscrolledArrayCoord(Coordinate paintCoord)
Transforms the given absolute paint-coordinate into an unscrolled array-coordinate.


getUnscrolledArrayCoord

public Coordinate getUnscrolledArrayCoord(int x,
                                          int y)

getFieldByAbs

public abstract Field getFieldByAbs(Coordinate paintCoord)
Returns a reference to the field that is at the given absolute paint-coordinate. Uses adjustArrayCoordToScrolling. Returns null if no Field is at the given position.


getAbsPaintCoord

public abstract Coordinate getAbsPaintCoord(Coordinate coord)
Returns the drawing-buffer-coordinate of Field (array- x,y) (as an absolute paint-coordinate).


getAbsImagePaintCoord

public abstract Coordinate getAbsImagePaintCoord(Coordinate coord)
Returns the (absolute paint-)coordinate that must be used in order to paint an image for this field. May return the same value as getAbsPaintCoord or may not.


getAbsImagePaintRectangle

public abstract Rectangle getAbsImagePaintRectangle(Coordinate coord)
Returns the smallest rectangle containing the complete image used for drawing the field at the given array-coordinate.

Parameters:
coord - an array-coordinate
Returns:
a rectangle as defined; the corners of the rectangle are given by absolute paint-coords; the result is independent from the current scroll-position and (x1,y1) is always <= the scroll-size of the map.

getAbsImagePaintRectangle

public Rectangle getAbsImagePaintRectangle(Field field)

getAbsFieldEdgeCoords

public abstract Coordinate[] getAbsFieldEdgeCoords(Coordinate coord)
Returns an array containing the (abs. paint-coords) of all (four) edges of the field at the given array-coordinate. They will be returned in correct order, so if you link them with lines (0->1->2->3->0), you'll get exactly the edge of the Field.

Returns:
an array as described

getAbsFieldEdgeCoords

public Coordinate[] getAbsFieldEdgeCoords(Field field)

getFieldRectangle

public Rectangle getFieldRectangle(Rectangle paintRect)
Returns the smallest rectangle (inside the fields-array) containing all fields displayed within the given rectangle (in absolute paint-coords).

Parameters:
paintRect - a rectangle given by absolute paint-coords
Returns:
a rectangle as described; given by unscrolled array-coords

getFieldRectangle

public abstract Rectangle getFieldRectangle(int x1,
                                            int y1,
                                            int x2,
                                            int y2)

getAbsMiddlePaintCoord

public abstract Coordinate getAbsMiddlePaintCoord(Coordinate coord)
Returns the "middle"-absolute-paintcoord of Field field. What "middle" means, depends on the particular implementation. This function is for example used for painting move-paths.


getAbsRectFieldIterator

public abstract java.util.Iterator getAbsRectFieldIterator(Coordinate c1,
                                                           Coordinate c2)
Returns an iterator that iterates through all Fields located within the specified rectangle, where the coords are given as absolute-paint-coords. The Iterator returns Objects of type PaintInfo, where every object stores a reference to a field and its unscrolled array-coordinate (if you pass this coordinate to one of the getXXXPaintCoordinate - functions, you will get an absolute paint-coordinate usable for painting)

If the fields are painted in the iteration-order, they are painted correct (no field is painted above a possibly shadowing one).


getAbsRectFieldIterator

public java.util.Iterator getAbsRectFieldIterator(Buffer buffer)

updateFields

public abstract void updateFields(Buffer buffer)

getSpecializedRegistry

public abstract Registry getSpecializedRegistry()
Returns the registry, where settings specific to _this_ type of map (for example "iso") get stored.

Returns:
registry as described

constructUnitPainter

public abstract civquest.swing.UnitPainter constructUnitPainter(QuadMap quadMap)
Returns an UnitPainter appropriate for this type of map.

Returns:
a UnitPainter appropriate for this type of map

constructUnitView

public abstract civquest.swing.UnitView constructUnitView(Unit unit)
Constructs a UnitView for the given Unit.

Parameters:
unit - any Unit
Returns:
the UnitView constructed for the given Unit.

paintField

public abstract void paintField(civquest.swing.quadmap.PaintInfo paintInfo,
                                Buffer buffer)
Paint the field specified in the given paintInfo into the given buffer, using the unscrolled array-coordinate specified in the given paintInfo.

Parameters:
paintInfo - paintInfo-object storing a reference to the field we want to paint and the unscrolled array-coordinate (UAC) (remember: one field my have multiple UACs)
buffer - any buffer

updateDirtyFields

public abstract void updateDirtyFields(Buffer buffer)
Update all fields marked for update within the given buffer.

Afterwards, no field is marked for update within the given buffer.

Parameters:
buffer - any Buffer

repaintBuffer

public void repaintBuffer(Buffer buffer)
Repaint the whole buffer.

This means, start with a new/cleared buffer-image and paint all fields contained by this buffer into that image.

Parameters:
buffer - any Buffer