Search this API

y.io
Class TiledImageOutputHandler

java.lang.Object
  extended by y.io.IOHandler
      extended by y.io.TiledImageOutputHandler

public class TiledImageOutputHandler
extends IOHandler

This output handler is responsible for exporting a diagram to multiple image tiles that make up a complete image. The generation of the single image tiles will be handled by a output handler delegate. Optionally this class can also generate a html page that displays the tiles in one large table.

 

Constructor Summary
TiledImageOutputHandler(IOHandler delegate)
          Creates a new instance of TiledImageOutputHandler.
 
Method Summary
 boolean canRead()
          Returns false.
 boolean canWrite()
          This method is delegated to the internal IOHandler.
protected  java.lang.String createTileFileName(Graph2D graph, IOHandler delegateIO, java.lang.String baseName, int row, int col)
          Creates the file name for a specific tile.
 java.lang.String getFileFormatString()
          This method is delegated to the internal IOHandler.
 java.lang.String getFileNameExtension()
          This method is delegated to the internal IOHandler.
 boolean isHTMLTableGenerationActive()
          Returns whether or not to produce an HTL page.
 void read(Graph2D graph, java.io.InputStream in)
          This method is delegated to the internal IOHandler.
 void setColumnCount(int cols)
          Sets the number of columns the output image will be split into.
 void setHTMLTableGenerationActive(boolean generate)
          Whether or not to generate an HTML page that displays the image tiles in one large table.
 void setMaximumTileSize(int width, int height)
          Sets the maximum size for each output image tile.
 void setRowCount(int rows)
          Sets the number of rows the output image will be split into.
 void write(Graph2D graph, java.io.OutputStream out)
          This method is delegated to the internal IOHandler.
 void write(Graph2D graph, java.lang.String name)
          Exports a diagram to multiple output files.
protected  void writeTile(Graph2D graph, IOHandler delegateIO, java.lang.String tileName, int row, int col)
          Writes a specific tile of the image by the means of a delegate IOHandler.
 
Methods inherited from class y.io.IOHandler
canWriteSubset, createObjectInputStream, createObjectOutputStream, hide, read, read, shouldSerialize, shouldSerialize, writeSubset, writeSubset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TiledImageOutputHandler

public TiledImageOutputHandler(IOHandler delegate)
Creates a new instance of TiledImageOutputHandler.

Parameters:
delegate - the delegate IOHandler that will be invoked for each image tile with a different viewport.
Method Detail

getFileFormatString

public java.lang.String getFileFormatString()
This method is delegated to the internal IOHandler.

Specified by:
getFileFormatString in class IOHandler

setHTMLTableGenerationActive

public void setHTMLTableGenerationActive(boolean generate)
Whether or not to generate an HTML page that displays the image tiles in one large table. The name of the generated HTML file will bear the ending .html Its base name will be the same as the output file. By default this feature is deactivated.


isHTMLTableGenerationActive

public boolean isHTMLTableGenerationActive()
Returns whether or not to produce an HTL page.

See Also:
setHTMLTableGenerationActive(boolean)

setMaximumTileSize

public void setMaximumTileSize(int width,
                               int height)
Sets the maximum size for each output image tile. Invoking this method will invalidate the values set by the methods setRowCount(int) and setColumnCount(int).


setRowCount

public void setRowCount(int rows)
Sets the number of rows the output image will be split into. The height of each tile will be the height of the original image divided by row count. Invoking this method will invalidate the values set by the method setMaximumTileSize(int,int).


setColumnCount

public void setColumnCount(int cols)
Sets the number of columns the output image will be split into. The width of each tile will be the width of the original image divided by column count. Invoking this method will invalidate the values set by the method setMaximumTileSize(int,int).


canRead

public boolean canRead()
Returns false.

Overrides:
canRead in class IOHandler

canWrite

public boolean canWrite()
This method is delegated to the internal IOHandler.

Overrides:
canWrite in class IOHandler

write

public void write(Graph2D graph,
                  java.lang.String name)
           throws java.io.IOException
Exports a diagram to multiple output files. The file format of the output files is determined by the delegate IOHandler of this class.

The number of generated output files can be controlled by either the methods setRowCount(int) and setColumnCount(int) or the method setMaximumTileSize(int, int).

The names of the output files will have the form {base name}{row}_{column}.{extension} given that the name parameter has the form {base name}.{extension}.

Additionally this method creates HTML file when requested.

Overrides:
write in class IOHandler
name - The name of the output file
Throws:
java.io.IOException

writeTile

protected void writeTile(Graph2D graph,
                         IOHandler delegateIO,
                         java.lang.String tileName,
                         int row,
                         int col)
                  throws java.io.IOException
Writes a specific tile of the image by the means of a delegate IOHandler.

Parameters:
graph - the graph comprising the diagram to be serialized
delegateIO - the IOHandler used to write the image tile
tileName - the file name of the tile being written.
row - the tile row currently written. Row numbers start with 0
col - the tile column currently written. Column numbers start with 0
Throws:
java.io.IOException

createTileFileName

protected java.lang.String createTileFileName(Graph2D graph,
                                              IOHandler delegateIO,
                                              java.lang.String baseName,
                                              int row,
                                              int col)
Creates the file name for a specific tile.

Parameters:
graph - the graph comprising the diagram to be serialized
delegateIO - the IOHandler used to write the image tile
baseName - the original file name with the dot-separated name suffix already stripped off.
row - the tile row currently written. Row numbers start with 0
col - the tile column currently written. Column numbers start with 0
Returns:
the tile name.

getFileNameExtension

public java.lang.String getFileNameExtension()
This method is delegated to the internal IOHandler.

Specified by:
getFileNameExtension in class IOHandler

read

public void read(Graph2D graph,
                 java.io.InputStream in)
          throws java.io.IOException
This method is delegated to the internal IOHandler.

Specified by:
read in class IOHandler
Throws:
java.io.IOException

write

public void write(Graph2D graph,
                  java.io.OutputStream out)
           throws java.io.IOException
This method is delegated to the internal IOHandler.

Specified by:
write in class IOHandler
Throws:
java.io.IOException

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.