inpro.incremental.sink
Class IUNetworkToDOT

java.lang.Object
  extended by inpro.incremental.PushBuffer
      extended by inpro.incremental.sink.IUNetworkToDOT
All Implemented Interfaces:
edu.cmu.sphinx.instrumentation.Resetable, edu.cmu.sphinx.util.props.Configurable

public class IUNetworkToDOT
extends PushBuffer

A viewer for IU networks that calls graphviz for laying out the graph

Author:
Okko Buss

Field Summary
private  boolean display
          Whether to show dot output images.
private  java.io.File dot
          The dot executable
(package private)  javax.swing.JFrame f
          Frame for display of output
private static int File_idCounter
          Output file ID counter.
private  java.util.List<java.lang.String> iuTypes
          The string of comma separated iu types
(package private)  javax.swing.JLabel l
          Label for display of output
private  java.util.List<java.util.List<IU>> nodeClusters
          List of lists of nodes to cluster
private  java.io.File out
          The current .dot output file.
private  java.lang.String outputFormat
          String for image extension, defaults to .png
private  java.io.PrintStream outStream
          PrintStream to write dot output to.
static java.lang.String PROP_DISPLAY_OUTPUT
          Boolean for whether to show dot output images
static java.lang.String PROP_DOT
          String for dot executable
static java.lang.String PROP_FAST_SCALE
          Boolean for determining whether to scale output images quickly rather than smoothly
static java.lang.String PROP_IU_TYPES
          String, comma-separated, for what iu types to display
static java.lang.String PROP_OUTPUT_FORMAT
          String for image extension, defaults to .png
static java.lang.String PROP_RUN_DOT
          Boolean for determining whether to turn dot output into images
static java.lang.String PROP_TMP_DIR
          String for the temporary directory
private  boolean runDot
          Whether to turn dot output into images
private  int scale
          Setting for scaling images smooth or fast
private  java.lang.String tmpDir
          The dot executable
 
Constructor Summary
IUNetworkToDOT()
           
 
Method Summary
private  void addToIUCluster(IU iu)
           
private  int getNewFileID()
           
 void hypChange(java.util.Collection<? extends IU> ius, java.util.List<? extends EditMessage<? extends IU>> edits)
          this should receive a list of current IUs and a list of edit messages since the last call to hypChange
 void newProperties(edu.cmu.sphinx.util.props.PropertySheet ps)
          Sets up the dot listener
private  void printGrin(IU iu, IU gr)
           
private  void printHead()
           
private  void printNode(IU iu)
           
private  void printSLL(IU iu, IU sll)
           
private  void printTail()
           
private  void runDot()
          Runs dot for the output .dot file with the configured output format and displays in window (if so configured).
 
Methods inherited from class inpro.incremental.PushBuffer
reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_DOT

@S4String(defaultValue="/usr/bin/dot")
public static final java.lang.String PROP_DOT
String for dot executable

See Also:
Constant Field Values

dot

private java.io.File dot
The dot executable


PROP_TMP_DIR

@S4String(defaultValue="/tmp")
public static final java.lang.String PROP_TMP_DIR
String for the temporary directory

See Also:
Constant Field Values

tmpDir

private java.lang.String tmpDir
The dot executable


PROP_IU_TYPES

@S4String(defaultValue="")
public static final java.lang.String PROP_IU_TYPES
String, comma-separated, for what iu types to display

See Also:
Constant Field Values

iuTypes

private java.util.List<java.lang.String> iuTypes
The string of comma separated iu types


PROP_RUN_DOT

@S4Boolean(defaultValue=false)
public static final java.lang.String PROP_RUN_DOT
Boolean for determining whether to turn dot output into images

See Also:
Constant Field Values

runDot

private boolean runDot
Whether to turn dot output into images


PROP_FAST_SCALE

@S4Boolean(defaultValue=false)
public static final java.lang.String PROP_FAST_SCALE
Boolean for determining whether to scale output images quickly rather than smoothly

See Also:
Constant Field Values

scale

private int scale
Setting for scaling images smooth or fast


PROP_DISPLAY_OUTPUT

@S4Boolean(defaultValue=false)
public static final java.lang.String PROP_DISPLAY_OUTPUT
Boolean for whether to show dot output images

See Also:
Constant Field Values

display

private boolean display
Whether to show dot output images. This is not thread-safe and makes system calls. Use for debug or inspection only!


PROP_OUTPUT_FORMAT

@S4String(defaultValue="png")
public static final java.lang.String PROP_OUTPUT_FORMAT
String for image extension, defaults to .png

See Also:
Constant Field Values

outputFormat

private java.lang.String outputFormat
String for image extension, defaults to .png


File_idCounter

private static int File_idCounter
Output file ID counter. Increases with each edit.


outStream

private java.io.PrintStream outStream
PrintStream to write dot output to.


out

private java.io.File out
The current .dot output file.


nodeClusters

private java.util.List<java.util.List<IU>> nodeClusters
List of lists of nodes to cluster


f

javax.swing.JFrame f
Frame for display of output


l

javax.swing.JLabel l
Label for display of output

Constructor Detail

IUNetworkToDOT

public IUNetworkToDOT()
Method Detail

newProperties

public void newProperties(edu.cmu.sphinx.util.props.PropertySheet ps)
                   throws edu.cmu.sphinx.util.props.PropertyException
Sets up the dot listener

Specified by:
newProperties in interface edu.cmu.sphinx.util.props.Configurable
Overrides:
newProperties in class PushBuffer
Throws:
edu.cmu.sphinx.util.props.PropertyException

hypChange

public void hypChange(java.util.Collection<? extends IU> ius,
                      java.util.List<? extends EditMessage<? extends IU>> edits)
Description copied from class: PushBuffer
this should receive a list of current IUs and a list of edit messages since the last call to hypChange

Specified by:
hypChange in class PushBuffer
Parameters:
ius - while this is a (plain) collection, the collection's iterator() method must ensure a sensible ordering of the returned elements. For now we have only used Lists (which are ordered), but a Tree of IUs should also be possible and this should gracefully work together with processors that expect lists
edits - a list of edits since the last call to hypChange

getNewFileID

private int getNewFileID()

printHead

private void printHead()

printNode

private void printNode(IU iu)

printSLL

private void printSLL(IU iu,
                      IU sll)

printGrin

private void printGrin(IU iu,
                       IU gr)

addToIUCluster

private void addToIUCluster(IU iu)

printTail

private void printTail()

runDot

private void runDot()
Runs dot for the output .dot file with the configured output format and displays in window (if so configured).
Stops running dot or displaying if something goes awry (IO exceptions etc.).