Internet Chess ToolKit
v0.2.0

ictk.boardgame.chess.io
Class PGNWriter

java.lang.Object
  extended byjava.io.Writer
      extended byjava.io.PrintWriter
          extended byictk.boardgame.io.GameWriter
              extended byictk.boardgame.chess.io.ChessWriter
                  extended byictk.boardgame.chess.io.PGNWriter

public class PGNWriter
extends ChessWriter

PGNWriter writes Portable Game Notation chess files


Field Summary
static long DEBUG
           
static int NO_GLYPH
          do not output symbolic nor numeric NAGs
static int NUMERIC_GLYPH
          do not output symbolic nor numeric NAGs
static int SUFFIX_ONLY_GLYPH
          do not output symbolic nor numeric NAGs
static int SYMBOLIC_AND_NUMERIC_GLYPH
          do not output symbolic nor numeric NAGs
static int SYMBOLIC_ONLY_GLYPH
          do not output symbolic nor numeric NAGs
 
Constructor Summary
PGNWriter(java.io.OutputStream _out)
           
PGNWriter(java.io.Writer _out)
           
 
Method Summary
 int getAnnotationGlyphStyle()
          returns the currect Glyph Style setting.
 int getColumnWidth()
          returns the current column width.
 MoveNotation getMoveNotation()
          returns the currect move notation style.
 boolean isExportComments()
          returns true if prenotationa and annotations are allowed in the output stream.
 boolean isExportVariations()
          returns true if variations are allowed in the output stream.
 boolean isIndentComments()
           
 boolean isIndentVariations()
           
 void setAnnotationGlyphStyle(int style)
          sets the annotation glyph style.
 void setColumnWidth(int col)
          sets the width of the output for the move list.
 void setExportComments(boolean t)
          turns on or off whether prenotation and annotation comments are output.
 void setExportVariations(boolean t)
          turns on or off whether variations are in the output stream.
 void setIndentComments(boolean t)
          indent the main-line comments.
 void setIndentVariations(boolean t)
          indent the main-line variatins.
 void setMoveNotation(MoveNotation notation)
          set the move notation style you wish the output to be in.
 void writeBoard(Board board)
          writeBoard(Board) writes the current board
 void writeGame(Game game)
          write the full game (GameInfo, History & Board) to the output buffer.
 void writeGameInfo(GameInfo gameinfo)
          write the GameInfo to the output buffer
 void writeHistory(History history)
          write the history list.
 
Methods inherited from class java.io.PrintWriter
checkError, close, flush, print, print, print, print, print, print, print, print, print, println, println, println, println, println, println, println, println, println, println, write, write, write, write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final long DEBUG

NO_GLYPH

public static final int NO_GLYPH
do not output symbolic nor numeric NAGs

See Also:
Constant Field Values

SYMBOLIC_AND_NUMERIC_GLYPH

public static final int SYMBOLIC_AND_NUMERIC_GLYPH
do not output symbolic nor numeric NAGs

See Also:
Constant Field Values

NUMERIC_GLYPH

public static final int NUMERIC_GLYPH
do not output symbolic nor numeric NAGs

See Also:
Constant Field Values

SYMBOLIC_ONLY_GLYPH

public static final int SYMBOLIC_ONLY_GLYPH
do not output symbolic nor numeric NAGs

See Also:
Constant Field Values

SUFFIX_ONLY_GLYPH

public static final int SUFFIX_ONLY_GLYPH
do not output symbolic nor numeric NAGs

See Also:
Constant Field Values
Constructor Detail

PGNWriter

public PGNWriter(java.io.OutputStream _out)

PGNWriter

public PGNWriter(java.io.Writer _out)
Method Detail

setMoveNotation

public void setMoveNotation(MoveNotation notation)
Description copied from class: GameWriter
set the move notation style you wish the output to be in.

Specified by:
setMoveNotation in class GameWriter

getMoveNotation

public MoveNotation getMoveNotation()
Description copied from class: GameWriter
returns the currect move notation style.

Specified by:
getMoveNotation in class GameWriter

setColumnWidth

public void setColumnWidth(int col)
sets the width of the output for the move list. Setting this to a rediculously small value is not advised.
DEFAULT: 80


getColumnWidth

public int getColumnWidth()
returns the current column width.


setExportComments

public void setExportComments(boolean t)
turns on or off whether prenotation and annotation comments are output. This does not affect whether NAGs are output.
DEFAULT: true

Specified by:
setExportComments in class GameWriter

isExportComments

public boolean isExportComments()
returns true if prenotationa and annotations are allowed in the output stream.

Specified by:
isExportComments in class GameWriter

setExportVariations

public void setExportVariations(boolean t)
turns on or off whether variations are in the output stream.
DEFAULT: true

Specified by:
setExportVariations in class GameWriter

isExportVariations

public boolean isExportVariations()
returns true if variations are allowed in the output stream.

Specified by:
isExportVariations in class GameWriter

setIndentComments

public void setIndentComments(boolean t)
indent the main-line comments. This only affects comments on the main-line. Variation comments are not affected.
DEFAULT: false


isIndentComments

public boolean isIndentComments()

setIndentVariations

public void setIndentVariations(boolean t)
indent the main-line variatins. This only affects variations off of the main-line. Variation comments are not affected.
DEFAULT: false


isIndentVariations

public boolean isIndentVariations()

setAnnotationGlyphStyle

public void setAnnotationGlyphStyle(int style)
sets the annotation glyph style. This determins how NAGs and other symbolic annotations such as !, ?, !?, +=, -/+ etc wll be presented.
DEFAULT: SYMBOLIC_AND_NUMERIC_GLYPH


getAnnotationGlyphStyle

public int getAnnotationGlyphStyle()
returns the currect Glyph Style setting.


writeGame

public void writeGame(Game game)
               throws java.io.IOException
Description copied from class: GameWriter
write the full game (GameInfo, History & Board) to the output buffer.

Specified by:
writeGame in class GameWriter
Throws:
java.io.IOException

writeGameInfo

public void writeGameInfo(GameInfo gameinfo)
                   throws java.io.IOException
Description copied from class: GameWriter
write the GameInfo to the output buffer

Specified by:
writeGameInfo in class GameWriter
Throws:
java.io.IOException

writeHistory

public void writeHistory(History history)
                  throws java.io.IOException
write the history list.

Prenotations: Might not be recognized by all readers.
If there are Prenotation on moves that is not the head of a variation, or the game, or are not following a move with an Annotation, the Prenotation will probably be interpreted by the next reader as an Annotation of the previous move. (there is a way around this by making empty annotations, but it's unclear how much adding Prenotations to PGN will make the output incompadible with other readers).

Specified by:
writeHistory in class GameWriter
Throws:
java.io.IOException

writeBoard

public void writeBoard(Board board)
                throws java.io.IOException
writeBoard(Board) writes the current board

Specified by:
writeBoard in class GameWriter
Throws:
java.io.IOException

Submit a bug or feature
Visit the Website
Internet Chess ToolKit is licensed under the GPL v2 .