Package org.apache.pdfbox.jbig2.segments
Class TextRegion
- java.lang.Object
-
- org.apache.pdfbox.jbig2.segments.TextRegion
-
- All Implemented Interfaces:
Region
,SegmentData
public class TextRegion extends java.lang.Object implements Region
This class represented the segment type "Text region", 7.4.3, page 56.
-
-
Field Summary
Fields Modifier and Type Field Description private long
amountOfSymbolInstances
Number of symbol instances, 7.4.3.1.4private int
amountOfSymbols
private ArithmeticDecoder
arithmeticDecoder
private CombinationOperator
combinationOperator
private long
currentS
Further parametersprivate CX
cx
private CX
cxIADS
private CX
cxIADT
private CX
cxIAFS
private CX
cxIAID
private CX
cxIAIT
private CX
cxIARDH
private CX
cxIARDW
private CX
cxIARDX
private CX
cxIARDY
private CX
cxIARI
private short
defaultPixel
private HuffmanTable
dsTable
private HuffmanTable
fsTable
User-supplied tables *private GenericRefinementRegion
genericRefinementRegion
private ArithmeticIntegerDecoder
integerDecoder
private boolean
isHuffmanEncoded
private short
isTransposed
private short
logSBStrips
private HuffmanTable
rdhTable
private HuffmanTable
rdwTable
private HuffmanTable
rdxTable
private HuffmanTable
rdyTable
private short
referenceCorner
private Bitmap
regionBitmap
private RegionSegmentInformation
regionInfo
Region segment information field, 7.4.1private HuffmanTable
rSizeTable
private short
sbdsOffset
private short
sbHuffDS
private short
sbHuffDT
private short
sbHuffFS
private short
sbHuffRDHeight
private short
sbHuffRDWidth
private short
sbHuffRDX
private short
sbHuffRDY
private short
sbHuffRSize
Text region segment Huffman flags, 7.4.3.1.2private short[]
sbrATX
Text region refinement AT flags, 7.4.3.1.3private short[]
sbrATY
private short
sbrTemplate
Text region segment flags, 7.4.3.1.1private int
sbStrips
private SegmentHeader
segmentHeader
private SubInputStream
subInputStream
private int
symbolCodeLength
codeTable including a code to each symbol used in that regionprivate FixedSizeTable
symbolCodeTable
private java.util.ArrayList<Bitmap>
symbols
private HuffmanTable
table
private boolean
useRefinement
-
Constructor Summary
Constructors Constructor Description TextRegion()
TextRegion(SubInputStream subInputStream, SegmentHeader segmentHeader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
blit(Bitmap ib, long t)
private void
checkInput()
private void
computeSymbolCodeLength()
private void
createRegionBitmap()
private long
decodeCurrentT()
private long
decodeDfS()
private long
decodeDT()
private Bitmap
decodeIb(long r, long id)
private long
decodeID()
private long
decodeIdS()
private long
decodeRdh()
private long
decodeRdw()
private long
decodeRdx()
private long
decodeRdy()
private long
decodeRI()
private long
decodeStripT()
private void
decodeSymbolInstances()
private long
decodeSymInRefSize()
Bitmap
getRegionBitmap()
Decodes and returns a regions content.RegionSegmentInformation
getRegionInfo()
Simply returns theRegionSegmentInformation
.private void
getSymbols()
private HuffmanTable
getUserTable(int tablePosition)
void
init(SegmentHeader header, SubInputStream sis)
Parse the stream and read information of header.private void
initSymbols()
private void
parseHeader()
private void
readAmountOfSymbolInstances()
private void
readHuffmanFlags()
private void
readRegionFlags()
private void
readUseRefinement()
private void
setCodingStatistics()
protected void
setContexts(CX cx, CX cxIADT, CX cxIAFS, CX cxIADS, CX cxIAIT, CX cxIAID, CX cxIARDW, CX cxIARDH, CX cxIARDX, CX cxIARDY)
protected void
setParameters(ArithmeticDecoder arithmeticDecoder, ArithmeticIntegerDecoder iDecoder, boolean isHuffmanEncoded, boolean sbRefine, int sbw, int sbh, long sbNumInstances, int sbStrips, int sbNumSyms, short sbDefaultPixel, short sbCombinationOperator, short transposed, short refCorner, short sbdsOffset, short sbHuffFS, short sbHuffDS, short sbHuffDT, short sbHuffRDWidth, short sbHuffRDHeight, short sbHuffRDX, short sbHuffRDY, short sbHuffRSize, short sbrTemplate, short[] sbrATX, short[] sbrATY, java.util.ArrayList<Bitmap> sbSyms, int sbSymCodeLen)
private void
symbolIDCodeLengths()
-
-
-
Field Detail
-
subInputStream
private SubInputStream subInputStream
-
regionInfo
private RegionSegmentInformation regionInfo
Region segment information field, 7.4.1
-
sbrTemplate
private short sbrTemplate
Text region segment flags, 7.4.3.1.1
-
sbdsOffset
private short sbdsOffset
-
defaultPixel
private short defaultPixel
-
combinationOperator
private CombinationOperator combinationOperator
-
isTransposed
private short isTransposed
-
referenceCorner
private short referenceCorner
-
logSBStrips
private short logSBStrips
-
useRefinement
private boolean useRefinement
-
isHuffmanEncoded
private boolean isHuffmanEncoded
-
sbHuffRSize
private short sbHuffRSize
Text region segment Huffman flags, 7.4.3.1.2
-
sbHuffRDY
private short sbHuffRDY
-
sbHuffRDX
private short sbHuffRDX
-
sbHuffRDHeight
private short sbHuffRDHeight
-
sbHuffRDWidth
private short sbHuffRDWidth
-
sbHuffDT
private short sbHuffDT
-
sbHuffDS
private short sbHuffDS
-
sbHuffFS
private short sbHuffFS
-
sbrATX
private short[] sbrATX
Text region refinement AT flags, 7.4.3.1.3
-
sbrATY
private short[] sbrATY
-
amountOfSymbolInstances
private long amountOfSymbolInstances
Number of symbol instances, 7.4.3.1.4
-
currentS
private long currentS
Further parameters
-
sbStrips
private int sbStrips
-
amountOfSymbols
private int amountOfSymbols
-
regionBitmap
private Bitmap regionBitmap
-
symbols
private java.util.ArrayList<Bitmap> symbols
-
arithmeticDecoder
private ArithmeticDecoder arithmeticDecoder
-
integerDecoder
private ArithmeticIntegerDecoder integerDecoder
-
genericRefinementRegion
private GenericRefinementRegion genericRefinementRegion
-
cxIADT
private CX cxIADT
-
cxIAFS
private CX cxIAFS
-
cxIADS
private CX cxIADS
-
cxIAIT
private CX cxIAIT
-
cxIARI
private CX cxIARI
-
cxIARDW
private CX cxIARDW
-
cxIARDH
private CX cxIARDH
-
cxIAID
private CX cxIAID
-
cxIARDX
private CX cxIARDX
-
cxIARDY
private CX cxIARDY
-
cx
private CX cx
-
symbolCodeLength
private int symbolCodeLength
codeTable including a code to each symbol used in that region
-
symbolCodeTable
private FixedSizeTable symbolCodeTable
-
segmentHeader
private SegmentHeader segmentHeader
-
fsTable
private HuffmanTable fsTable
User-supplied tables *
-
dsTable
private HuffmanTable dsTable
-
table
private HuffmanTable table
-
rdwTable
private HuffmanTable rdwTable
-
rdhTable
private HuffmanTable rdhTable
-
rdxTable
private HuffmanTable rdxTable
-
rdyTable
private HuffmanTable rdyTable
-
rSizeTable
private HuffmanTable rSizeTable
-
-
Constructor Detail
-
TextRegion
public TextRegion()
-
TextRegion
public TextRegion(SubInputStream subInputStream, SegmentHeader segmentHeader)
-
-
Method Detail
-
parseHeader
private void parseHeader() throws java.io.IOException, InvalidHeaderValueException, IntegerMaxValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
IntegerMaxValueException
-
readRegionFlags
private void readRegionFlags() throws java.io.IOException
- Throws:
java.io.IOException
-
readHuffmanFlags
private void readHuffmanFlags() throws java.io.IOException
- Throws:
java.io.IOException
-
readUseRefinement
private void readUseRefinement() throws java.io.IOException
- Throws:
java.io.IOException
-
readAmountOfSymbolInstances
private void readAmountOfSymbolInstances() throws java.io.IOException
- Throws:
java.io.IOException
-
getSymbols
private void getSymbols() throws java.io.IOException, IntegerMaxValueException, InvalidHeaderValueException
- Throws:
java.io.IOException
IntegerMaxValueException
InvalidHeaderValueException
-
computeSymbolCodeLength
private void computeSymbolCodeLength() throws java.io.IOException
- Throws:
java.io.IOException
-
checkInput
private void checkInput() throws InvalidHeaderValueException
- Throws:
InvalidHeaderValueException
-
getRegionBitmap
public Bitmap getRegionBitmap() throws java.io.IOException, IntegerMaxValueException, InvalidHeaderValueException
Description copied from interface:Region
Decodes and returns a regions content.- Specified by:
getRegionBitmap
in interfaceRegion
- Returns:
- The decoded region as
Bitmap
. - Throws:
java.io.IOException
- if an underlying IO operation failsIntegerMaxValueException
- if the maximum value limit of an integer is exceededInvalidHeaderValueException
- if the segment header value is invalid
-
setCodingStatistics
private void setCodingStatistics() throws java.io.IOException
- Throws:
java.io.IOException
-
createRegionBitmap
private void createRegionBitmap()
-
decodeStripT
private final long decodeStripT() throws java.io.IOException, InvalidHeaderValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
-
decodeSymbolInstances
private void decodeSymbolInstances() throws java.io.IOException, InvalidHeaderValueException, IntegerMaxValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
IntegerMaxValueException
-
decodeDT
private final long decodeDT() throws java.io.IOException
- Throws:
java.io.IOException
-
decodeDfS
private final long decodeDfS() throws java.io.IOException, InvalidHeaderValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
-
decodeIdS
private final long decodeIdS() throws java.io.IOException, InvalidHeaderValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
-
decodeCurrentT
private final long decodeCurrentT() throws java.io.IOException
- Throws:
java.io.IOException
-
decodeID
private final long decodeID() throws java.io.IOException
- Throws:
java.io.IOException
-
decodeRI
private final long decodeRI() throws java.io.IOException
- Throws:
java.io.IOException
-
decodeIb
private final Bitmap decodeIb(long r, long id) throws java.io.IOException, InvalidHeaderValueException, IntegerMaxValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
IntegerMaxValueException
-
decodeRdw
private final long decodeRdw() throws java.io.IOException, InvalidHeaderValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
-
decodeRdh
private final long decodeRdh() throws java.io.IOException, InvalidHeaderValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
-
decodeRdx
private final long decodeRdx() throws java.io.IOException, InvalidHeaderValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
-
decodeRdy
private final long decodeRdy() throws java.io.IOException, InvalidHeaderValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
-
decodeSymInRefSize
private final long decodeSymInRefSize() throws java.io.IOException, InvalidHeaderValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
-
blit
private final void blit(Bitmap ib, long t)
-
initSymbols
private void initSymbols() throws java.io.IOException, IntegerMaxValueException, InvalidHeaderValueException
- Throws:
java.io.IOException
IntegerMaxValueException
InvalidHeaderValueException
-
getUserTable
private HuffmanTable getUserTable(int tablePosition) throws InvalidHeaderValueException, java.io.IOException
- Throws:
InvalidHeaderValueException
java.io.IOException
-
symbolIDCodeLengths
private void symbolIDCodeLengths() throws java.io.IOException
- Throws:
java.io.IOException
-
init
public void init(SegmentHeader header, SubInputStream sis) throws InvalidHeaderValueException, IntegerMaxValueException, java.io.IOException
Description copied from interface:SegmentData
Parse the stream and read information of header.- Specified by:
init
in interfaceSegmentData
- Parameters:
header
- - The segments' header (to make referred-to segments available in data part).sis
- - WrappedImageInputStream
intoSubInputStream
.- Throws:
InvalidHeaderValueException
- if the segment header value is invalidIntegerMaxValueException
- if the maximum value limit of an integer is exceededjava.io.IOException
- if an underlying IO operation fails
-
setContexts
protected void setContexts(CX cx, CX cxIADT, CX cxIAFS, CX cxIADS, CX cxIAIT, CX cxIAID, CX cxIARDW, CX cxIARDH, CX cxIARDX, CX cxIARDY)
-
setParameters
protected void setParameters(ArithmeticDecoder arithmeticDecoder, ArithmeticIntegerDecoder iDecoder, boolean isHuffmanEncoded, boolean sbRefine, int sbw, int sbh, long sbNumInstances, int sbStrips, int sbNumSyms, short sbDefaultPixel, short sbCombinationOperator, short transposed, short refCorner, short sbdsOffset, short sbHuffFS, short sbHuffDS, short sbHuffDT, short sbHuffRDWidth, short sbHuffRDHeight, short sbHuffRDX, short sbHuffRDY, short sbHuffRSize, short sbrTemplate, short[] sbrATX, short[] sbrATY, java.util.ArrayList<Bitmap> sbSyms, int sbSymCodeLen)
-
getRegionInfo
public RegionSegmentInformation getRegionInfo()
Description copied from interface:Region
Simply returns theRegionSegmentInformation
.- Specified by:
getRegionInfo
in interfaceRegion
- Returns:
- The
RegionSegmentInformation
.
-
-