aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java')
-rw-r--r--src/java/META-INF/services/org.apache.fop.fo.ElementMapping1
-rw-r--r--src/java/META-INF/services/org.apache.fop.render.Renderer4
-rw-r--r--src/java/META-INF/services/org.apache.fop.render.afp.AFPImageHandler5
-rw-r--r--src/java/META-INF/services/org.apache.fop.render.pdf.PDFImageHandler5
-rw-r--r--src/java/org/apache/fop/ResourceEventProducer.java5
-rw-r--r--src/java/org/apache/fop/afp/AFPBorderPainter.java97
-rw-r--r--src/java/org/apache/fop/afp/AFPConstants.java4
-rw-r--r--src/java/org/apache/fop/afp/AFPDataObjectFactory.java2
-rw-r--r--src/java/org/apache/fop/afp/AFPDataObjectInfo.java8
-rw-r--r--src/java/org/apache/fop/afp/AFPEventProducer.java5
-rw-r--r--src/java/org/apache/fop/afp/AFPGraphics2D.java24
-rw-r--r--src/java/org/apache/fop/afp/AFPLineDataInfo.java14
-rw-r--r--src/java/org/apache/fop/afp/AFPRectanglePainter.java43
-rw-r--r--src/java/org/apache/fop/afp/AFPResourceManager.java55
-rw-r--r--src/java/org/apache/fop/afp/AFPStreamer.java19
-rw-r--r--src/java/org/apache/fop/afp/AbstractAFPPainter.java4
-rw-r--r--src/java/org/apache/fop/afp/DataStream.java17
-rw-r--r--src/java/org/apache/fop/afp/Factory.java10
-rw-r--r--src/java/org/apache/fop/afp/GrayScaleColorConverter.java122
-rw-r--r--src/java/org/apache/fop/afp/Startable.java2
-rw-r--r--src/java/org/apache/fop/afp/apps/FontPatternExtractor.java157
-rw-r--r--src/java/org/apache/fop/afp/fonts/AFPFontCollection.java2
-rw-r--r--src/java/org/apache/fop/afp/fonts/AFPFontInfo.java6
-rw-r--r--src/java/org/apache/fop/afp/fonts/CharacterSet.java4
-rw-r--r--src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java5
-rw-r--r--src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java4
-rw-r--r--src/java/org/apache/fop/afp/fonts/DoubleByteFont.java2
-rw-r--r--src/java/org/apache/fop/afp/fonts/OutlineFont.java6
-rw-r--r--src/java/org/apache/fop/afp/fonts/RasterFont.java10
-rw-r--r--src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java3
-rw-r--r--src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java1
-rw-r--r--src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java2
-rw-r--r--src/java/org/apache/fop/afp/goca/GraphicsFillet.java1
-rw-r--r--src/java/org/apache/fop/afp/goca/GraphicsSetMix.java3
-rw-r--r--src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java2
-rw-r--r--src/java/org/apache/fop/afp/ioca/IDEStructureParameter.java6
-rw-r--r--src/java/org/apache/fop/afp/ioca/ImageRasterPattern.java5
-rw-r--r--src/java/org/apache/fop/afp/modca/AbstractAFPObject.java9
-rw-r--r--src/java/org/apache/fop/afp/modca/AbstractEnvironmentGroup.java7
-rw-r--r--src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java4
-rw-r--r--src/java/org/apache/fop/afp/modca/AbstractPageObject.java4
-rw-r--r--src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java4
-rw-r--r--src/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java6
-rw-r--r--src/java/org/apache/fop/afp/modca/GraphicsObject.java8
-rw-r--r--src/java/org/apache/fop/afp/modca/ImageDataDescriptor.java3
-rw-r--r--src/java/org/apache/fop/afp/modca/IncludeObject.java5
-rw-r--r--src/java/org/apache/fop/afp/modca/IncludePageOverlay.java4
-rw-r--r--src/java/org/apache/fop/afp/modca/IncludePageSegment.java8
-rw-r--r--src/java/org/apache/fop/afp/modca/IncludedResourceObject.java3
-rw-r--r--src/java/org/apache/fop/afp/modca/InterchangeSet.java28
-rw-r--r--src/java/org/apache/fop/afp/modca/InvokeMediumMap.java2
-rw-r--r--src/java/org/apache/fop/afp/modca/MapCodedFont.java9
-rw-r--r--src/java/org/apache/fop/afp/modca/MapPageOverlay.java10
-rw-r--r--src/java/org/apache/fop/afp/modca/MapPageSegment.java6
-rw-r--r--src/java/org/apache/fop/afp/modca/ObjectContainer.java4
-rw-r--r--src/java/org/apache/fop/afp/modca/PageGroup.java1
-rw-r--r--src/java/org/apache/fop/afp/modca/PageSegment.java16
-rw-r--r--src/java/org/apache/fop/afp/modca/PreprocessPresentationObject.java4
-rw-r--r--src/java/org/apache/fop/afp/modca/TagLogicalElement.java6
-rw-r--r--src/java/org/apache/fop/afp/modca/TagLogicalElementBean.java6
-rw-r--r--src/java/org/apache/fop/afp/modca/triplets/CommentTriplet.java5
-rw-r--r--src/java/org/apache/fop/afp/modca/triplets/ObjectClassificationTriplet.java3
-rw-r--r--src/java/org/apache/fop/afp/modca/triplets/Triplet.java61
-rw-r--r--src/java/org/apache/fop/afp/parser/MODCAParser.java80
-rw-r--r--src/java/org/apache/fop/afp/parser/UnparsedStructuredField.java355
-rw-r--r--src/java/org/apache/fop/afp/ptoca/LineDataInfoProducer.java4
-rw-r--r--src/java/org/apache/fop/afp/svg/AFPBridgeContext.java9
-rw-r--r--src/java/org/apache/fop/afp/svg/AFPGraphicsConfiguration.java9
-rw-r--r--src/java/org/apache/fop/afp/svg/AFPTextHandler.java14
-rw-r--r--src/java/org/apache/fop/afp/svg/AFPTextPainter.java2
-rw-r--r--src/java/org/apache/fop/afp/util/AFPResourceUtil.java214
-rw-r--r--src/java/org/apache/fop/afp/util/BinaryUtils.java3
-rw-r--r--src/java/org/apache/fop/afp/util/CubicBezierApproximator.java5
-rw-r--r--src/java/org/apache/fop/afp/util/DTDEntityResolver.java2
-rw-r--r--src/java/org/apache/fop/afp/util/StringUtils.java5
-rw-r--r--src/java/org/apache/fop/afp/util/StructuredFieldReader.java79
-rw-r--r--src/java/org/apache/fop/apps/FOUserAgent.java3
-rw-r--r--src/java/org/apache/fop/apps/FopFactory.java39
-rw-r--r--src/java/org/apache/fop/apps/FopFactoryConfigurator.java162
-rw-r--r--src/java/org/apache/fop/area/Area.java5
-rw-r--r--src/java/org/apache/fop/area/AreaEventProducer.java5
-rw-r--r--src/java/org/apache/fop/area/AreaTreeHandler.java1
-rw-r--r--src/java/org/apache/fop/area/AreaTreeModel.java2
-rw-r--r--src/java/org/apache/fop/area/AreaTreeParser.java11
-rw-r--r--src/java/org/apache/fop/area/BeforeFloat.java3
-rw-r--r--src/java/org/apache/fop/area/Block.java6
-rw-r--r--src/java/org/apache/fop/area/BlockParent.java2
-rw-r--r--src/java/org/apache/fop/area/BlockViewport.java3
-rw-r--r--src/java/org/apache/fop/area/BodyRegion.java3
-rw-r--r--src/java/org/apache/fop/area/CTM.java2
-rw-r--r--src/java/org/apache/fop/area/DestinationData.java2
-rw-r--r--src/java/org/apache/fop/area/Footnote.java3
-rw-r--r--src/java/org/apache/fop/area/IDTracker.java14
-rw-r--r--src/java/org/apache/fop/area/LineArea.java25
-rw-r--r--src/java/org/apache/fop/area/LinkResolver.java3
-rw-r--r--src/java/org/apache/fop/area/MainReference.java2
-rw-r--r--src/java/org/apache/fop/area/NormalFlow.java3
-rw-r--r--src/java/org/apache/fop/area/Page.java13
-rw-r--r--src/java/org/apache/fop/area/PageViewport.java19
-rw-r--r--src/java/org/apache/fop/area/RegionReference.java7
-rw-r--r--src/java/org/apache/fop/area/RegionViewport.java3
-rw-r--r--src/java/org/apache/fop/area/Span.java3
-rw-r--r--src/java/org/apache/fop/area/Trait.java272
-rw-r--r--src/java/org/apache/fop/area/inline/AbstractTextArea.java10
-rw-r--r--src/java/org/apache/fop/area/inline/Anchor.java2
-rw-r--r--src/java/org/apache/fop/area/inline/Container.java3
-rw-r--r--src/java/org/apache/fop/area/inline/FilledArea.java3
-rw-r--r--src/java/org/apache/fop/area/inline/Image.java5
-rw-r--r--src/java/org/apache/fop/area/inline/InlineArea.java14
-rw-r--r--src/java/org/apache/fop/area/inline/InlineBlockParent.java3
-rw-r--r--src/java/org/apache/fop/area/inline/InlineParent.java29
-rw-r--r--src/java/org/apache/fop/area/inline/Leader.java3
-rw-r--r--src/java/org/apache/fop/area/inline/Space.java2
-rw-r--r--src/java/org/apache/fop/area/inline/SpaceArea.java9
-rw-r--r--src/java/org/apache/fop/area/inline/TextArea.java2
-rw-r--r--src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java3
-rw-r--r--src/java/org/apache/fop/area/inline/Viewport.java3
-rw-r--r--src/java/org/apache/fop/area/inline/WordArea.java3
-rw-r--r--src/java/org/apache/fop/cli/CommandLineOptions.java65
-rw-r--r--src/java/org/apache/fop/cli/InputHandler.java5
-rw-r--r--src/java/org/apache/fop/cli/Main.java5
-rw-r--r--src/java/org/apache/fop/datatypes/FODimension.java15
-rw-r--r--src/java/org/apache/fop/datatypes/LengthBase.java2
-rw-r--r--src/java/org/apache/fop/datatypes/Numeric.java19
-rw-r--r--src/java/org/apache/fop/datatypes/PercentBaseContext.java2
-rw-r--r--src/java/org/apache/fop/datatypes/URISpecification.java7
-rw-r--r--src/java/org/apache/fop/events/Event.java13
-rw-r--r--src/java/org/apache/fop/events/EventExceptionManager.java16
-rw-r--r--src/java/org/apache/fop/events/PropertyExceptionFactory.java2
-rw-r--r--src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java2
-rw-r--r--src/java/org/apache/fop/events/ValidationExceptionFactory.java2
-rw-r--r--src/java/org/apache/fop/events/model/EventModelParser.java9
-rw-r--r--src/java/org/apache/fop/fo/ElementMapping.java6
-rw-r--r--src/java/org/apache/fop/fo/ElementMappingRegistry.java16
-rw-r--r--src/java/org/apache/fop/fo/FOElementMapping.java2
-rw-r--r--src/java/org/apache/fop/fo/FOEventHandler.java5
-rw-r--r--src/java/org/apache/fop/fo/FONode.java10
-rw-r--r--src/java/org/apache/fop/fo/FOPropertyMapping.java217
-rw-r--r--src/java/org/apache/fop/fo/FOText.java6
-rw-r--r--src/java/org/apache/fop/fo/FOTreeBuilder.java4
-rw-r--r--src/java/org/apache/fop/fo/FObj.java8
-rw-r--r--src/java/org/apache/fop/fo/InlineCharIterator.java94
-rw-r--r--src/java/org/apache/fop/fo/NullCharIterator.java4
-rw-r--r--src/java/org/apache/fop/fo/PropertyListMaker.java7
-rw-r--r--src/java/org/apache/fop/fo/StaticPropertyList.java11
-rw-r--r--src/java/org/apache/fop/fo/ValidationException.java10
-rw-r--r--src/java/org/apache/fop/fo/expr/BodyStartFunction.java5
-rw-r--r--src/java/org/apache/fop/fo/expr/NumericOp.java131
-rw-r--r--src/java/org/apache/fop/fo/expr/PropertyInfo.java2
-rw-r--r--src/java/org/apache/fop/fo/expr/PropertyTokenizer.java22
-rw-r--r--src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java16
-rw-r--r--src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java19
-rw-r--r--src/java/org/apache/fop/fo/extensions/ExtensionObj.java8
-rw-r--r--src/java/org/apache/fop/fo/extensions/ExternalDocument.java27
-rw-r--r--src/java/org/apache/fop/fo/extensions/InternalElementMapping.java4
-rw-r--r--src/java/org/apache/fop/fo/extensions/OldExtensionElementMapping.java2
-rw-r--r--src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java5
-rw-r--r--src/java/org/apache/fop/fo/extensions/svg/SVGDOMContentHandlerFactory.java2
-rw-r--r--src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java2
-rw-r--r--src/java/org/apache/fop/fo/extensions/xmp/RDFElementMapping.java2
-rw-r--r--src/java/org/apache/fop/fo/extensions/xmp/XMPElementMapping.java2
-rw-r--r--src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java4
-rw-r--r--src/java/org/apache/fop/fo/flow/Block.java3
-rw-r--r--src/java/org/apache/fop/fo/flow/BlockContainer.java3
-rw-r--r--src/java/org/apache/fop/fo/flow/Float.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/Footnote.java4
-rw-r--r--src/java/org/apache/fop/fo/flow/Inline.java3
-rw-r--r--src/java/org/apache/fop/fo/flow/Leader.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/ListItem.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/Marker.java46
-rw-r--r--src/java/org/apache/fop/fo/flow/MultiCase.java4
-rw-r--r--src/java/org/apache/fop/fo/flow/MultiProperties.java6
-rw-r--r--src/java/org/apache/fop/fo/flow/MultiPropertySet.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/MultiSwitch.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/MultiToggle.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/RetrieveTableMarker.java5
-rw-r--r--src/java/org/apache/fop/fo/flow/Wrapper.java3
-rw-r--r--src/java/org/apache/fop/fo/flow/table/ColumnNumberManager.java3
-rw-r--r--src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java9
-rw-r--r--src/java/org/apache/fop/fo/flow/table/GridUnit.java8
-rw-r--r--src/java/org/apache/fop/fo/flow/table/PendingSpan.java20
-rw-r--r--src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java12
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableAndCaption.java4
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableCaption.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableCellContainer.java12
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableEventProducer.java5
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableFObj.java26
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TablePart.java10
-rw-r--r--src/java/org/apache/fop/fo/flow/table/TableRow.java1
-rw-r--r--src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java3
-rw-r--r--src/java/org/apache/fop/fo/pagination/Declarations.java6
-rw-r--r--src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java34
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageProductionException.java2
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageSequence.java17
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java13
-rw-r--r--src/java/org/apache/fop/fo/pagination/Region.java8
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionAfter.java7
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionBefore.java31
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionBody.java10
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionEnd.java7
-rw-r--r--src/java/org/apache/fop/fo/pagination/RegionStart.java7
-rw-r--r--src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java8
-rw-r--r--src/java/org/apache/fop/fo/pagination/Root.java20
-rw-r--r--src/java/org/apache/fop/fo/pagination/SimplePageMaster.java17
-rw-r--r--src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java1
-rw-r--r--src/java/org/apache/fop/fo/properties/BackgroundPositionShorthand.java3
-rw-r--r--src/java/org/apache/fop/fo/properties/BorderSpacingShorthandParser.java1
-rw-r--r--src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java11
-rw-r--r--src/java/org/apache/fop/fo/properties/BreakPropertySet.java6
-rw-r--r--src/java/org/apache/fop/fo/properties/CharacterProperty.java13
-rw-r--r--src/java/org/apache/fop/fo/properties/ColorProperty.java8
-rw-r--r--src/java/org/apache/fop/fo/properties/CommonAbsolutePosition.java12
-rw-r--r--src/java/org/apache/fop/fo/properties/CommonAccessibility.java5
-rw-r--r--src/java/org/apache/fop/fo/properties/CommonAural.java36
-rw-r--r--src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java59
-rw-r--r--src/java/org/apache/fop/fo/properties/CommonFont.java46
-rw-r--r--src/java/org/apache/fop/fo/properties/CommonHyphenation.java71
-rw-r--r--src/java/org/apache/fop/fo/properties/CommonMarginBlock.java17
-rw-r--r--src/java/org/apache/fop/fo/properties/CommonMarginInline.java13
-rw-r--r--src/java/org/apache/fop/fo/properties/CommonRelativePosition.java11
-rw-r--r--src/java/org/apache/fop/fo/properties/CompoundPropertyMaker.java24
-rw-r--r--src/java/org/apache/fop/fo/properties/CondLengthProperty.java5
-rw-r--r--src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java43
-rw-r--r--src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java23
-rw-r--r--src/java/org/apache/fop/fo/properties/EnumLength.java5
-rw-r--r--src/java/org/apache/fop/fo/properties/EnumNumber.java5
-rw-r--r--src/java/org/apache/fop/fo/properties/EnumProperty.java19
-rw-r--r--src/java/org/apache/fop/fo/properties/FixedLength.java5
-rw-r--r--src/java/org/apache/fop/fo/properties/FontFamilyProperty.java8
-rw-r--r--src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java3
-rw-r--r--src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java12
-rw-r--r--src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java13
-rw-r--r--src/java/org/apache/fop/fo/properties/KeepProperty.java16
-rw-r--r--src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java1
-rw-r--r--src/java/org/apache/fop/fo/properties/NumberProperty.java14
-rw-r--r--src/java/org/apache/fop/fo/properties/PageDimensionMaker.java8
-rw-r--r--src/java/org/apache/fop/fo/properties/PercentLength.java3
-rw-r--r--src/java/org/apache/fop/fo/properties/Property.java4
-rw-r--r--src/java/org/apache/fop/fo/properties/PropertyCache.java30
-rw-r--r--src/java/org/apache/fop/fo/properties/ShorthandParser.java2
-rw-r--r--src/java/org/apache/fop/fo/properties/SpaceProperty.java13
-rw-r--r--src/java/org/apache/fop/fo/properties/SpacingPropertyMaker.java5
-rw-r--r--src/java/org/apache/fop/fo/properties/StringProperty.java10
-rw-r--r--src/java/org/apache/fop/fo/properties/TableBorderPrecedence.java13
-rw-r--r--src/java/org/apache/fop/fo/properties/TextDecorationProperty.java21
-rw-r--r--src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java15
-rw-r--r--src/java/org/apache/fop/fo/properties/VerticalAlignShorthandParser.java19
-rw-r--r--src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java6
-rw-r--r--src/java/org/apache/fop/fonts/AbstractCodePointMapping.java14
-rw-r--r--src/java/org/apache/fop/fonts/CIDFontType.java3
-rw-r--r--src/java/org/apache/fop/fonts/CIDSubset.java23
-rw-r--r--src/java/org/apache/fop/fonts/CustomFont.java24
-rw-r--r--src/java/org/apache/fop/fonts/CustomFontCollection.java8
-rw-r--r--src/java/org/apache/fop/fonts/EmbedFontInfo.java6
-rw-r--r--src/java/org/apache/fop/fonts/EncodingMode.java35
-rw-r--r--src/java/org/apache/fop/fonts/Font.java11
-rw-r--r--src/java/org/apache/fop/fonts/FontAdder.java18
-rw-r--r--src/java/org/apache/fop/fonts/FontCache.java194
-rw-r--r--src/java/org/apache/fop/fonts/FontDetector.java17
-rw-r--r--src/java/org/apache/fop/fonts/FontInfo.java109
-rw-r--r--src/java/org/apache/fop/fonts/FontInfoConfigurator.java64
-rw-r--r--src/java/org/apache/fop/fonts/FontLoader.java2
-rw-r--r--src/java/org/apache/fop/fonts/FontManager.java101
-rw-r--r--src/java/org/apache/fop/fonts/FontManagerConfigurator.java53
-rw-r--r--src/java/org/apache/fop/fonts/FontMetrics.java4
-rw-r--r--src/java/org/apache/fop/fonts/FontReader.java22
-rw-r--r--src/java/org/apache/fop/fonts/FontSetup.java23
-rw-r--r--src/java/org/apache/fop/fonts/FontTriplet.java6
-rw-r--r--src/java/org/apache/fop/fonts/FontType.java3
-rw-r--r--src/java/org/apache/fop/fonts/FontUtil.java5
-rw-r--r--src/java/org/apache/fop/fonts/Glyphs.java11
-rw-r--r--src/java/org/apache/fop/fonts/LazyFont.java4
-rw-r--r--src/java/org/apache/fop/fonts/MultiByteFont.java4
-rw-r--r--src/java/org/apache/fop/fonts/MutableFont.java4
-rw-r--r--src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java20
-rw-r--r--src/java/org/apache/fop/fonts/SingleByteFont.java37
-rw-r--r--src/java/org/apache/fop/fonts/Typeface.java9
-rw-r--r--src/java/org/apache/fop/fonts/autodetect/FontDirFinder.java (renamed from src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java)25
-rw-r--r--src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java20
-rw-r--r--src/java/org/apache/fop/fonts/autodetect/FontFinder.java7
-rw-r--r--src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java80
-rw-r--r--src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java6
-rw-r--r--src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java6
-rw-r--r--src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java2
-rw-r--r--src/java/org/apache/fop/fonts/substitute/FontWeightRange.java2
-rw-r--r--src/java/org/apache/fop/fonts/truetype/FontFileReader.java1
-rw-r--r--src/java/org/apache/fop/fonts/truetype/TTFCmapEntry.java11
-rw-r--r--src/java/org/apache/fop/fonts/truetype/TTFFile.java87
-rw-r--r--src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java23
-rw-r--r--src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java4
-rw-r--r--src/java/org/apache/fop/fonts/type1/PFBParser.java2
-rw-r--r--src/java/org/apache/fop/hyphenation/ByteVector.java47
-rw-r--r--src/java/org/apache/fop/hyphenation/CharVector.java49
-rw-r--r--src/java/org/apache/fop/hyphenation/Hyphen.java28
-rw-r--r--src/java/org/apache/fop/hyphenation/Hyphenation.java3
-rw-r--r--src/java/org/apache/fop/hyphenation/HyphenationException.java5
-rw-r--r--src/java/org/apache/fop/hyphenation/HyphenationTree.java44
-rw-r--r--src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java23
-rw-r--r--src/java/org/apache/fop/hyphenation/Hyphenator.java241
-rw-r--r--src/java/org/apache/fop/hyphenation/PatternConsumer.java2
-rw-r--r--src/java/org/apache/fop/hyphenation/PatternParser.java60
-rw-r--r--src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java4
-rw-r--r--src/java/org/apache/fop/hyphenation/TernaryTree.java106
-rw-r--r--src/java/org/apache/fop/image/loader/batik/BatikUtil.java5
-rw-r--r--src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java3
-rw-r--r--src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java6
-rw-r--r--src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java6
-rw-r--r--src/java/org/apache/fop/layoutmgr/AbstractBreaker.java388
-rw-r--r--src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java4
-rw-r--r--src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java5
-rw-r--r--src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java5
-rw-r--r--src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java41
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java14
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java4
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java10
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java44
-rw-r--r--src/java/org/apache/fop/layoutmgr/BreakElement.java3
-rw-r--r--src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java151
-rw-r--r--src/java/org/apache/fop/layoutmgr/ElementListObserver.java5
-rw-r--r--src/java/org/apache/fop/layoutmgr/ElementListUtils.java80
-rw-r--r--src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java13
-rw-r--r--src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java5
-rw-r--r--src/java/org/apache/fop/layoutmgr/Keep.java26
-rw-r--r--src/java/org/apache/fop/layoutmgr/KnuthGlue.java10
-rw-r--r--src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java17
-rw-r--r--src/java/org/apache/fop/layoutmgr/KnuthSequence.java19
-rw-r--r--src/java/org/apache/fop/layoutmgr/LMiter.java21
-rw-r--r--src/java/org/apache/fop/layoutmgr/LayoutContext.java41
-rw-r--r--src/java/org/apache/fop/layoutmgr/LayoutException.java4
-rw-r--r--src/java/org/apache/fop/layoutmgr/LayoutManager.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java19
-rw-r--r--src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java96
-rw-r--r--src/java/org/apache/fop/layoutmgr/LeafPosition.java14
-rw-r--r--src/java/org/apache/fop/layoutmgr/NonLeafPosition.java8
-rw-r--r--src/java/org/apache/fop/layoutmgr/Page.java6
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageBreaker.java26
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java60
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageProvider.java20
-rw-r--r--src/java/org/apache/fop/layoutmgr/Position.java48
-rw-r--r--src/java/org/apache/fop/layoutmgr/PositionIterator.java20
-rw-r--r--src/java/org/apache/fop/layoutmgr/SpaceResolver.java92
-rw-r--r--src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java1
-rw-r--r--src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java6
-rw-r--r--src/java/org/apache/fop/layoutmgr/TraitSetter.java15
-rw-r--r--src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java4
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java22
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.java59
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java10
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java8
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java40
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java5
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/HyphContext.java6
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java9
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java19
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java5
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java31
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java157
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java6
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java6
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java43
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java396
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java76
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java3
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java5
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java211
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/CellPart.java3
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java15
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java34
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java9
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java2
-rw-r--r--src/java/org/apache/fop/pdf/AbstractPDFStream.java11
-rw-r--r--src/java/org/apache/fop/pdf/AlphaRasterImage.java2
-rw-r--r--src/java/org/apache/fop/pdf/CMapBuilder.java40
-rw-r--r--src/java/org/apache/fop/pdf/DestinationComparator.java1
-rw-r--r--src/java/org/apache/fop/pdf/PDFArray.java7
-rw-r--r--src/java/org/apache/fop/pdf/PDFCIDFont.java7
-rw-r--r--src/java/org/apache/fop/pdf/PDFDocument.java13
-rw-r--r--src/java/org/apache/fop/pdf/PDFEmbeddedFile.java59
-rw-r--r--src/java/org/apache/fop/pdf/PDFEmbeddedFiles.java66
-rw-r--r--src/java/org/apache/fop/pdf/PDFEncryptionJCE.java21
-rw-r--r--src/java/org/apache/fop/pdf/PDFEncryptionManager.java23
-rw-r--r--src/java/org/apache/fop/pdf/PDFFactory.java166
-rw-r--r--src/java/org/apache/fop/pdf/PDFFileSpec.java43
-rw-r--r--src/java/org/apache/fop/pdf/PDFFontDescriptor.java9
-rw-r--r--src/java/org/apache/fop/pdf/PDFFunction.java11
-rw-r--r--src/java/org/apache/fop/pdf/PDFGoTo.java8
-rw-r--r--src/java/org/apache/fop/pdf/PDFGoToRemote.java25
-rw-r--r--src/java/org/apache/fop/pdf/PDFJavaScriptLaunchAction.java72
-rw-r--r--src/java/org/apache/fop/pdf/PDFLaunch.java28
-rw-r--r--src/java/org/apache/fop/pdf/PDFMetadata.java9
-rw-r--r--src/java/org/apache/fop/pdf/PDFName.java4
-rw-r--r--src/java/org/apache/fop/pdf/PDFNameTreeNode.java2
-rw-r--r--src/java/org/apache/fop/pdf/PDFNames.java23
-rw-r--r--src/java/org/apache/fop/pdf/PDFNull.java1
-rw-r--r--src/java/org/apache/fop/pdf/PDFObject.java4
-rw-r--r--src/java/org/apache/fop/pdf/PDFPattern.java11
-rw-r--r--src/java/org/apache/fop/pdf/PDFProfile.java12
-rw-r--r--src/java/org/apache/fop/pdf/PDFResources.java8
-rw-r--r--src/java/org/apache/fop/pdf/PDFShading.java44
-rw-r--r--src/java/org/apache/fop/pdf/PDFText.java36
-rw-r--r--src/java/org/apache/fop/pdf/PDFToUnicodeCMap.java4
-rw-r--r--src/java/org/apache/fop/pdf/TransitionDictionary.java2
-rw-r--r--src/java/org/apache/fop/render/AbstractConfigurator.java4
-rw-r--r--src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java9
-rw-r--r--src/java/org/apache/fop/render/AbstractImageHandlerGraphics2D.java3
-rw-r--r--src/java/org/apache/fop/render/AbstractImageHandlerRegistry.java209
-rw-r--r--src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java27
-rw-r--r--src/java/org/apache/fop/render/AbstractRenderer.java9
-rw-r--r--src/java/org/apache/fop/render/DummyPercentBaseContext.java2
-rw-r--r--src/java/org/apache/fop/render/ImageHandlerRegistry.java1
-rw-r--r--src/java/org/apache/fop/render/ImageHandlerUtil.java5
-rw-r--r--src/java/org/apache/fop/render/PrintRenderer.java9
-rw-r--r--src/java/org/apache/fop/render/PrintRendererConfigurator.java13
-rw-r--r--src/java/org/apache/fop/render/Renderer.java4
-rw-r--r--src/java/org/apache/fop/render/RendererEventProducer.java5
-rw-r--r--src/java/org/apache/fop/render/XMLHandlerConfigurator.java2
-rw-r--r--src/java/org/apache/fop/render/XMLHandlerRegistry.java20
-rw-r--r--src/java/org/apache/fop/render/afp/AFPDocumentHandler.java23
-rw-r--r--src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java10
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandler.java41
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java41
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java27
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java2
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandlerXML.java77
-rw-r--r--src/java/org/apache/fop/render/afp/AFPInfo.java8
-rw-r--r--src/java/org/apache/fop/render/afp/AFPPainter.java69
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRenderer.java920
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java25
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRendererMaker.java58
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRenderingContext.java2
-rw-r--r--src/java/org/apache/fop/render/afp/AFPSVGHandler.java10
-rw-r--r--src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java15
-rw-r--r--src/java/org/apache/fop/render/afp/PageSegmentDescriptor.java57
-rw-r--r--src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java4
-rw-r--r--src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java31
-rw-r--r--src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java2
-rw-r--r--src/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java2
-rw-r--r--src/java/org/apache/fop/render/afp/extensions/AFPPageSegmentElement.java149
-rw-r--r--src/java/org/apache/fop/render/awt/AWTRenderer.java14
-rw-r--r--src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java2
-rw-r--r--src/java/org/apache/fop/render/awt/viewer/PageChangeEvent.java2
-rw-r--r--src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java11
-rw-r--r--src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java5
-rw-r--r--src/java/org/apache/fop/render/bitmap/PNGRenderer_onthefly.java147
-rw-r--r--src/java/org/apache/fop/render/bitmap/TIFFRenderer.java12
-rw-r--r--src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java6
-rw-r--r--src/java/org/apache/fop/render/intermediate/BorderPainter.java5
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFConstants.java17
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFContentHandler.java12
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFDocumentNavigationHandler.java8
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFGraphicContext.java40
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFParser.java2
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFRenderer.java8
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFSerializer.java7
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFState.java8
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFUtil.java5
-rw-r--r--src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java2
-rw-r--r--src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java10
-rw-r--r--src/java/org/apache/fop/render/intermediate/util/IFConcatenator.java11
-rw-r--r--src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java2
-rw-r--r--src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java6
-rw-r--r--src/java/org/apache/fop/render/java2d/FontMetricsMapper.java2
-rw-r--r--src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java7
-rw-r--r--src/java/org/apache/fop/render/java2d/Java2DImageHandlerRenderedImage.java3
-rw-r--r--src/java/org/apache/fop/render/java2d/Java2DPainter.java6
-rw-r--r--src/java/org/apache/fop/render/java2d/Java2DRenderer.java8
-rw-r--r--src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java13
-rw-r--r--src/java/org/apache/fop/render/java2d/Java2DUtil.java5
-rw-r--r--src/java/org/apache/fop/render/pcl/HardcodedFonts.java9
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLEventProducer.java5
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java123
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLPainter.java9
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLRenderer.java1514
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java16
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLRendererContext.java3
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLRendererMaker.java57
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLRenderingContext.java1
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLSVGHandler.java3
-rw-r--r--src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java2
-rw-r--r--src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java2
-rw-r--r--src/java/org/apache/fop/render/pdf/CTMHelper.java4
-rw-r--r--src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java2
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFBorderPainter.java32
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFContentGenerator.java10
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java26
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java7
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java132
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFImageHandler.java52
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java29
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java29
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java29
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java29
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java27
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java72
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java4
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFPainter.java10
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFRenderer.java1352
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java40
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFRendererMaker.java55
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java69
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFSVGHandler.java185
-rw-r--r--src/java/org/apache/fop/render/pdf/extensions/AbstractPDFExtensionElement.java73
-rw-r--r--src/java/org/apache/fop/render/pdf/extensions/PDFElementMapping.java51
-rw-r--r--src/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileElement.java106
-rw-r--r--src/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileExtensionAttachment.java154
-rw-r--r--src/java/org/apache/fop/render/pdf/extensions/PDFExtensionAttachment.java65
-rw-r--r--src/java/org/apache/fop/render/pdf/extensions/PDFExtensionHandler.java98
-rw-r--r--src/java/org/apache/fop/render/ps/FontResourceCache.java9
-rw-r--r--src/java/org/apache/fop/render/ps/PSBorderPainter.java16
-rw-r--r--src/java/org/apache/fop/render/ps/PSBridgeContext.java1
-rw-r--r--src/java/org/apache/fop/render/ps/PSEventProducer.java5
-rw-r--r--src/java/org/apache/fop/render/ps/PSFontUtils.java53
-rw-r--r--src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java14
-rw-r--r--src/java/org/apache/fop/render/ps/PSImageHandler.java3
-rw-r--r--src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java9
-rw-r--r--src/java/org/apache/fop/render/ps/PSPainter.java3
-rw-r--r--src/java/org/apache/fop/render/ps/PSRenderer.java1289
-rw-r--r--src/java/org/apache/fop/render/ps/PSRendererConfigurator.java16
-rw-r--r--src/java/org/apache/fop/render/ps/PSRendererContextConstants.java5
-rw-r--r--src/java/org/apache/fop/render/ps/PSRendererMaker.java54
-rw-r--r--src/java/org/apache/fop/render/ps/PSRenderingUtil.java1
-rw-r--r--src/java/org/apache/fop/render/ps/PSSVGHandler.java7
-rw-r--r--src/java/org/apache/fop/render/ps/PSTextPainter.java2
-rw-r--r--src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java2
-rw-r--r--src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java5
-rw-r--r--src/java/org/apache/fop/render/rtf/FoUnitsConverter.java5
-rw-r--r--src/java/org/apache/fop/render/rtf/RTFEventProducer.java5
-rw-r--r--src/java/org/apache/fop/render/rtf/RTFHandler.java27
-rw-r--r--src/java/org/apache/fop/render/rtf/TableAttributesConverter.java12
-rw-r--r--src/java/org/apache/fop/render/rtf/TextAttributesConverter.java45
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java18
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBookmark.java4
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java4
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java7
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java11
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFootnote.java27
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfGenerator.java7
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java17
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfJforCmd.java2
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfList.java3
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java2
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfString.java5
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStringConverter.java7
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java5
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java4
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTemplate.java5
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java3
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java140
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/WhitespaceCollapser.java16
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java34
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/tools/ImageConstants.java6
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java5
-rw-r--r--src/java/org/apache/fop/render/txt/TXTRenderer.java3
-rw-r--r--src/java/org/apache/fop/render/txt/TXTStream.java5
-rw-r--r--src/java/org/apache/fop/render/xml/AbstractXMLRenderer.java5
-rw-r--r--src/java/org/apache/fop/servlet/FopPrintServlet.java2
-rw-r--r--src/java/org/apache/fop/servlet/FopServlet.java2
-rw-r--r--src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java12
-rw-r--r--src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java5
-rw-r--r--src/java/org/apache/fop/svg/AbstractFOPTranscoder.java17
-rw-r--r--src/java/org/apache/fop/svg/FOPTextHandler.java3
-rw-r--r--src/java/org/apache/fop/svg/FOPTextHandlerAdapter.java (renamed from src/java/org/apache/fop/render/afp/AFPImageHandlerRegistry.java)25
-rw-r--r--src/java/org/apache/fop/svg/GraphicsConfiguration.java9
-rw-r--r--src/java/org/apache/fop/svg/NativeImageHandler.java1
-rw-r--r--src/java/org/apache/fop/svg/NativeTextPainter.java38
-rw-r--r--src/java/org/apache/fop/svg/PDFBridgeContext.java1
-rw-r--r--src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java6
-rw-r--r--src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java34
-rw-r--r--src/java/org/apache/fop/svg/PDFGraphics2D.java21
-rw-r--r--src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java8
-rw-r--r--src/java/org/apache/fop/svg/PDFGraphicsDevice.java4
-rw-r--r--src/java/org/apache/fop/svg/PDFTextPainter.java2
-rw-r--r--src/java/org/apache/fop/svg/PDFTranscoder.java4
-rw-r--r--src/java/org/apache/fop/svg/SVGEventProducer.java5
-rw-r--r--src/java/org/apache/fop/svg/SVGUtilities.java40
-rw-r--r--src/java/org/apache/fop/text/linebreak/LineBreakStatus.java6
-rw-r--r--src/java/org/apache/fop/text/linebreak/LineBreakUtils.java364
-rw-r--r--src/java/org/apache/fop/tools/anttasks/FileCompare.java27
-rw-r--r--src/java/org/apache/fop/tools/anttasks/Fop.java50
-rw-r--r--src/java/org/apache/fop/tools/fontlist/FontSpec.java7
-rw-r--r--src/java/org/apache/fop/traits/BorderProps.java10
-rw-r--r--src/java/org/apache/fop/traits/MinOptMax.java42
-rw-r--r--src/java/org/apache/fop/traits/SpaceVal.java16
-rw-r--r--src/java/org/apache/fop/traits/TraitEnum.java2
-rw-r--r--src/java/org/apache/fop/util/AbstractPaintingState.java3
-rw-r--r--src/java/org/apache/fop/util/ColorExt.java3
-rw-r--r--src/java/org/apache/fop/util/ColorProfileUtil.java5
-rw-r--r--src/java/org/apache/fop/util/ColorUtil.java4
-rw-r--r--src/java/org/apache/fop/util/CommandLineLogger.java13
-rw-r--r--src/java/org/apache/fop/util/ConversionUtils.java3
-rw-r--r--src/java/org/apache/fop/util/DataURIResolver.java4
-rw-r--r--src/java/org/apache/fop/util/DataURLUtil.java17
-rw-r--r--src/java/org/apache/fop/util/DecimalFormatCache.java5
-rw-r--r--src/java/org/apache/fop/util/LogUtil.java5
-rw-r--r--src/java/org/apache/fop/util/UnitConv.java5
-rw-r--r--src/java/org/apache/fop/util/WriterOutputStream.java37
-rw-r--r--src/java/org/apache/fop/util/XMLUtil.java5
-rw-r--r--src/java/org/apache/fop/util/bitmap/BitmapImageUtil.java26
-rw-r--r--src/java/org/apache/fop/util/bitmap/DitherUtil.java5
-rw-r--r--src/java/org/apache/fop/util/text/AdvancedMessageFormat.java75
609 files changed, 8387 insertions, 10598 deletions
diff --git a/src/java/META-INF/services/org.apache.fop.fo.ElementMapping b/src/java/META-INF/services/org.apache.fop.fo.ElementMapping
index b62f36196..6f4374a93 100644
--- a/src/java/META-INF/services/org.apache.fop.fo.ElementMapping
+++ b/src/java/META-INF/services/org.apache.fop.fo.ElementMapping
@@ -9,3 +9,4 @@ org.apache.fop.fo.extensions.xmp.RDFElementMapping
org.apache.fop.render.ps.extensions.PSExtensionElementMapping
org.apache.fop.render.afp.extensions.AFPElementMapping
org.apache.fop.render.pcl.extensions.PCLElementMapping
+org.apache.fop.render.pdf.extensions.PDFElementMapping
diff --git a/src/java/META-INF/services/org.apache.fop.render.Renderer b/src/java/META-INF/services/org.apache.fop.render.Renderer
index 0e6f12cb5..2bf59a805 100644
--- a/src/java/META-INF/services/org.apache.fop.render.Renderer
+++ b/src/java/META-INF/services/org.apache.fop.render.Renderer
@@ -1,10 +1,6 @@
-org.apache.fop.render.pdf.PDFRendererMaker
-org.apache.fop.render.ps.PSRendererMaker
org.apache.fop.render.txt.TXTRendererMaker
org.apache.fop.render.bitmap.PNGRendererMaker
org.apache.fop.render.bitmap.TIFFRendererMaker
org.apache.fop.render.xml.XMLRendererMaker
org.apache.fop.render.awt.AWTRendererMaker
org.apache.fop.render.print.PrintRendererMaker
-org.apache.fop.render.afp.AFPRendererMaker
-org.apache.fop.render.pcl.PCLRendererMaker \ No newline at end of file
diff --git a/src/java/META-INF/services/org.apache.fop.render.afp.AFPImageHandler b/src/java/META-INF/services/org.apache.fop.render.afp.AFPImageHandler
deleted file mode 100644
index 3f8c8dea6..000000000
--- a/src/java/META-INF/services/org.apache.fop.render.afp.AFPImageHandler
+++ /dev/null
@@ -1,5 +0,0 @@
-org.apache.fop.render.afp.AFPImageHandlerRenderedImage
-org.apache.fop.render.afp.AFPImageHandlerRawCCITTFax
-org.apache.fop.render.afp.AFPImageHandlerRawStream
-org.apache.fop.render.afp.AFPImageHandlerGraphics2D
-org.apache.fop.render.afp.AFPImageHandlerXML
diff --git a/src/java/META-INF/services/org.apache.fop.render.pdf.PDFImageHandler b/src/java/META-INF/services/org.apache.fop.render.pdf.PDFImageHandler
deleted file mode 100644
index 18fc3e96a..000000000
--- a/src/java/META-INF/services/org.apache.fop.render.pdf.PDFImageHandler
+++ /dev/null
@@ -1,5 +0,0 @@
-org.apache.fop.render.pdf.PDFImageHandlerRawJPEG
-org.apache.fop.render.pdf.PDFImageHandlerRawCCITTFax
-org.apache.fop.render.pdf.PDFImageHandlerGraphics2D
-org.apache.fop.render.pdf.PDFImageHandlerRenderedImage
-org.apache.fop.render.pdf.PDFImageHandlerXML
diff --git a/src/java/org/apache/fop/ResourceEventProducer.java b/src/java/org/apache/fop/ResourceEventProducer.java
index a87b2d0ec..926b7c92b 100644
--- a/src/java/org/apache/fop/ResourceEventProducer.java
+++ b/src/java/org/apache/fop/ResourceEventProducer.java
@@ -39,7 +39,10 @@ public interface ResourceEventProducer extends EventProducer {
/**
* Provider class for the event producer.
*/
- class Provider {
+ final class Provider {
+
+ private Provider() {
+ }
/**
* Returns an event producer.
diff --git a/src/java/org/apache/fop/afp/AFPBorderPainter.java b/src/java/org/apache/fop/afp/AFPBorderPainter.java
index 85046dbed..958a955b8 100644
--- a/src/java/org/apache/fop/afp/AFPBorderPainter.java
+++ b/src/java/org/apache/fop/afp/AFPBorderPainter.java
@@ -40,7 +40,7 @@ public class AFPBorderPainter extends AbstractAFPPainter {
}
/** {@inheritDoc} */
- public void paint(PaintingInfo paintInfo) {
+ public void paint(PaintingInfo paintInfo) { // CSOK: MethodLength
BorderPaintingInfo borderPaintInfo = (BorderPaintingInfo)paintInfo;
float w = borderPaintInfo.getX2() - borderPaintInfo.getX1();
float h = borderPaintInfo.getY2() - borderPaintInfo.getY1();
@@ -60,6 +60,7 @@ public class AFPBorderPainter extends AbstractAFPPainter {
float y2 = unitConv.pt2units(borderPaintInfo.getY2());
switch (paintingState.getRotation()) {
+ default:
case 0:
x1 += at.getTranslateX();
y1 += at.getTranslateY();
@@ -89,8 +90,8 @@ public class AFPBorderPainter extends AbstractAFPPainter {
AFPLineDataInfo lineDataInfo = new AFPLineDataInfo();
lineDataInfo.setColor(borderPaintInfo.getColor());
lineDataInfo.setRotation(paintingState.getRotation());
- lineDataInfo.x1 = Math.round(x1);
- lineDataInfo.y1 = Math.round(y1);
+ lineDataInfo.setX1 ( Math.round(x1) );
+ lineDataInfo.setY1 ( Math.round(y1) );
float thickness;
if (borderPaintInfo.isHorizontal()) {
thickness = y2 - y1;
@@ -105,83 +106,91 @@ public class AFPBorderPainter extends AbstractAFPPainter {
int thickness3 = (int)Math.floor(thickness / 3f);
lineDataInfo.setThickness(thickness3);
if (borderPaintInfo.isHorizontal()) {
- lineDataInfo.x2 = Math.round(x2);
- lineDataInfo.y2 = lineDataInfo.y1;
+ lineDataInfo.setX2 ( Math.round(x2) );
+ lineDataInfo.setY2 ( lineDataInfo.getY1() );
dataStream.createLine(lineDataInfo);
int distance = thickness3 * 2;
lineDataInfo = new AFPLineDataInfo(lineDataInfo);
- lineDataInfo.y1 += distance;
- lineDataInfo.y2 += distance;
+ lineDataInfo.setY1 ( lineDataInfo.getY1() + distance );
+ lineDataInfo.setY2 ( lineDataInfo.getY2() + distance );
dataStream.createLine(lineDataInfo);
} else {
- lineDataInfo.x2 = lineDataInfo.x1;
- lineDataInfo.y2 = Math.round(y2);
+ lineDataInfo.setX2 ( lineDataInfo.getX1() );
+ lineDataInfo.setY2 ( Math.round(y2) );
dataStream.createLine(lineDataInfo);
int distance = thickness3 * 2;
lineDataInfo = new AFPLineDataInfo(lineDataInfo);
- lineDataInfo.x1 += distance;
- lineDataInfo.x2 += distance;
+ lineDataInfo.setX1 ( lineDataInfo.getX1() + distance );
+ lineDataInfo.setX2 ( lineDataInfo.getX2() + distance );
dataStream.createLine(lineDataInfo);
}
break;
case Constants.EN_DASHED:
- int thick = lineDataInfo.thickness * 3;
+ int thick = lineDataInfo.getThickness() * 3;
if (borderPaintInfo.isHorizontal()) {
- lineDataInfo.x2 = lineDataInfo.x1 + thick;
- lineDataInfo.y2 = lineDataInfo.y1;
+ lineDataInfo.setX2 ( lineDataInfo.getX1() + thick );
+ lineDataInfo.setY2 ( lineDataInfo.getY1() );
int ex2 = Math.round(x2);
- while (lineDataInfo.x1 + thick < ex2) {
+ while (lineDataInfo.getX1() + thick < ex2) {
dataStream.createLine(lineDataInfo);
- lineDataInfo.x1 += 2 * thick;
- lineDataInfo.x2 = lineDataInfo.x1 + thick;
+ lineDataInfo.setX1 ( lineDataInfo.getX1() + 2 * thick );
+ lineDataInfo.setX2 ( lineDataInfo.getX1() + thick );
}
} else {
- lineDataInfo.x2 = lineDataInfo.x1;
- lineDataInfo.y2 = lineDataInfo.y1 + thick;
+ lineDataInfo.setX2 ( lineDataInfo.getX1() );
+ lineDataInfo.setY2 ( lineDataInfo.getY1() + thick );
int ey2 = Math.round(y2);
- while (lineDataInfo.y1 + thick < ey2) {
+ while (lineDataInfo.getY1() + thick < ey2) {
dataStream.createLine(lineDataInfo);
- lineDataInfo.y1 += 2 * thick;
- lineDataInfo.y2 = lineDataInfo.y1 + thick;
+ lineDataInfo.setY1 ( lineDataInfo.getY1() + 2 * thick );
+ lineDataInfo.setY2 ( lineDataInfo.getY1() + thick );
}
}
break;
case Constants.EN_DOTTED:
if (borderPaintInfo.isHorizontal()) {
- lineDataInfo.x2 = lineDataInfo.x1 + lineDataInfo.thickness;
- lineDataInfo.y2 = lineDataInfo.y1;
+ lineDataInfo.setX2 ( lineDataInfo.getX1() + lineDataInfo.getThickness() );
+ lineDataInfo.setY2 ( lineDataInfo.getY1() );
int ex2 = Math.round(x2);
- while (lineDataInfo.x1 + lineDataInfo.thickness < ex2) {
+ while (lineDataInfo.getX1() + lineDataInfo.getThickness() < ex2) {
dataStream.createLine(lineDataInfo);
- lineDataInfo.x1 += 3 * lineDataInfo.thickness;
- lineDataInfo.x2 = lineDataInfo.x1 + lineDataInfo.thickness;
+ lineDataInfo.setX1 ( lineDataInfo.getX1() + 3 * lineDataInfo.getThickness() );
+ lineDataInfo.setX2 ( lineDataInfo.getX1() + lineDataInfo.getThickness() );
}
} else {
- lineDataInfo.x2 = lineDataInfo.x1;
- lineDataInfo.y2 = lineDataInfo.y1 + lineDataInfo.thickness;
+ lineDataInfo.setX2 ( lineDataInfo.getX1() );
+ lineDataInfo.setY2 ( lineDataInfo.getY1() + lineDataInfo.getThickness() );
int ey2 = Math.round(y2);
- while (lineDataInfo.y1 + lineDataInfo.thickness < ey2) {
+ while (lineDataInfo.getY1() + lineDataInfo.getThickness() < ey2) {
dataStream.createLine(lineDataInfo);
- lineDataInfo.y1 += 3 * lineDataInfo.thickness;
- lineDataInfo.y2 = lineDataInfo.y1 + lineDataInfo.thickness;
+ lineDataInfo.setY1 ( lineDataInfo.getY1() + 3 * lineDataInfo.getThickness() );
+ lineDataInfo.setY2 ( lineDataInfo.getY1() + lineDataInfo.getThickness() );
}
}
break;
case Constants.EN_GROOVE:
case Constants.EN_RIDGE:
//TODO
- lineDataInfo.x2 = Math.round(x2);
+ int yNew;
+ lineDataInfo.setX2 ( Math.round(x2) );
float colFactor = (borderPaintInfo.getStyle() == Constants.EN_GROOVE ? 0.4f : -0.4f);
float h3 = (y2 - y1) / 3;
- lineDataInfo.color = ColorUtil.lightenColor(borderPaintInfo.getColor(), -colFactor);
- lineDataInfo.thickness = Math.round(h3);
- lineDataInfo.y1 = lineDataInfo.y2 = Math.round(y1);
+ lineDataInfo.setColor
+ ( ColorUtil.lightenColor(borderPaintInfo.getColor(), -colFactor) );
+ lineDataInfo.setThickness ( Math.round(h3) );
+ yNew = Math.round(y1);
+ lineDataInfo.setY1 ( yNew );
+ lineDataInfo.setY2 ( yNew );
dataStream.createLine(lineDataInfo);
- lineDataInfo.color = borderPaintInfo.getColor();
- lineDataInfo.y1 = lineDataInfo.y2 = Math.round(y1 + h3);
+ lineDataInfo.setColor ( borderPaintInfo.getColor() );
+ yNew = Math.round(y1 + h3);
+ lineDataInfo.setY1 ( yNew );
+ lineDataInfo.setY2 ( yNew );
dataStream.createLine(lineDataInfo);
- lineDataInfo.color = ColorUtil.lightenColor(borderPaintInfo.getColor(), colFactor);
- lineDataInfo.y1 = lineDataInfo.y2 = Math.round(y1 + h3 + h3);
+ lineDataInfo.setColor ( ColorUtil.lightenColor(borderPaintInfo.getColor(), colFactor) );
+ yNew = Math.round(y1 + h3 + h3);
+ lineDataInfo.setY1 ( yNew );
+ lineDataInfo.setY2 ( yNew );
dataStream.createLine(lineDataInfo);
break;
case Constants.EN_HIDDEN:
@@ -191,11 +200,11 @@ public class AFPBorderPainter extends AbstractAFPPainter {
case Constants.EN_SOLID:
default:
if (borderPaintInfo.isHorizontal()) {
- lineDataInfo.x2 = Math.round(x2);
- lineDataInfo.y2 = lineDataInfo.y1;
+ lineDataInfo.setX2 ( Math.round(x2) );
+ lineDataInfo.setY2 ( lineDataInfo.getY1() );
} else {
- lineDataInfo.x2 = lineDataInfo.x1;
- lineDataInfo.y2 = Math.round(y2);
+ lineDataInfo.setX2 ( lineDataInfo.getX1() );
+ lineDataInfo.setY2 ( Math.round(y2) );
}
dataStream.createLine(lineDataInfo);
}
diff --git a/src/java/org/apache/fop/afp/AFPConstants.java b/src/java/org/apache/fop/afp/AFPConstants.java
index 3462ddfe6..6b26c18fd 100644
--- a/src/java/org/apache/fop/afp/AFPConstants.java
+++ b/src/java/org/apache/fop/afp/AFPConstants.java
@@ -39,13 +39,13 @@ public interface AFPConstants {
* The encoding to use to convert to US ASCII (7 bit)
*/
String US_ASCII_ENCODING = "US-ASCII";
-
+
/**
* The scaling of the default transform is set to
* approximately 72 user space coordinates per square inch
*/
int DPI_72 = 72;
-
+
/**
* 72dpi in millipoints
*/
diff --git a/src/java/org/apache/fop/afp/AFPDataObjectFactory.java b/src/java/org/apache/fop/afp/AFPDataObjectFactory.java
index 58321e546..d7e8ea5f9 100644
--- a/src/java/org/apache/fop/afp/AFPDataObjectFactory.java
+++ b/src/java/org/apache/fop/afp/AFPDataObjectFactory.java
@@ -167,7 +167,7 @@ public class AFPDataObjectFactory {
//set color converter (i.e. an rgb to grayscale converter)
graphicsObj.setColorConverter(g2d.getPaintingState().getColorConverter());
-
+
// paint to graphics object
Graphics2DImagePainter painter = graphicsObjectInfo.getPainter();
Rectangle2D area = graphicsObjectInfo.getArea();
diff --git a/src/java/org/apache/fop/afp/AFPDataObjectInfo.java b/src/java/org/apache/fop/afp/AFPDataObjectInfo.java
index 158189b76..7589ef4fe 100644
--- a/src/java/org/apache/fop/afp/AFPDataObjectInfo.java
+++ b/src/java/org/apache/fop/afp/AFPDataObjectInfo.java
@@ -19,9 +19,6 @@
package org.apache.fop.afp;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import org.apache.fop.afp.modca.Registry;
import org.apache.fop.afp.modca.triplets.MappingOptionTriplet;
@@ -29,7 +26,6 @@ import org.apache.fop.afp.modca.triplets.MappingOptionTriplet;
* A list of parameters associated with an AFP data objects
*/
public class AFPDataObjectInfo {
- private static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp");
/** the object area info */
private AFPObjectAreaInfo objectAreaInfo;
@@ -197,9 +193,9 @@ public class AFPDataObjectInfo {
}
/**
- * Sets the data width resolution
+ * Sets the data height resolution
*
- * @param dataWidthRes the data width resolution
+ * @param dataHeightRes the data height resolution
*/
public void setDataHeightRes(int dataHeightRes) {
this.dataHeightRes = dataHeightRes;
diff --git a/src/java/org/apache/fop/afp/AFPEventProducer.java b/src/java/org/apache/fop/afp/AFPEventProducer.java
index 6e6cb529e..87f978add 100644
--- a/src/java/org/apache/fop/afp/AFPEventProducer.java
+++ b/src/java/org/apache/fop/afp/AFPEventProducer.java
@@ -28,7 +28,10 @@ import org.apache.fop.events.EventProducer;
public interface AFPEventProducer extends EventProducer {
/** Provider class for the event producer. */
- class Provider {
+ static final class Provider {
+
+ private Provider() {
+ }
/**
* Returns an event producer.
diff --git a/src/java/org/apache/fop/afp/AFPGraphics2D.java b/src/java/org/apache/fop/afp/AFPGraphics2D.java
index fa9c0d7bf..af58b5471 100644
--- a/src/java/org/apache/fop/afp/AFPGraphics2D.java
+++ b/src/java/org/apache/fop/afp/AFPGraphics2D.java
@@ -75,7 +75,7 @@ import org.apache.fop.svg.NativeImageHandler;
*/
public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHandler {
- private static final Log log = LogFactory.getLog(AFPGraphics2D.class);
+ private static final Log LOG = LogFactory.getLog(AFPGraphics2D.class);
private static final int X = 0;
@@ -321,7 +321,7 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
graphicsObj.setLineType(type);
}
} else {
- log.warn("Unsupported Stroke: " + stroke.getClass().getName());
+ LOG.warn("Unsupported Stroke: " + stroke.getClass().getName());
}
}
@@ -339,7 +339,7 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
if (paint instanceof Color) {
return true;
}
- log.debug("NYI: applyPaint() " + paint + " fill=" + fill);
+ LOG.debug("NYI: applyPaint() " + paint + " fill=" + fill);
if (paint instanceof TexturePaint) {
// TexturePaint texturePaint = (TexturePaint)paint;
// BufferedImage bufferedImage = texturePaint.getImage();
@@ -490,7 +490,7 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
currentPosition = new double[]{openingCoords[0], openingCoords[1]};
break;
default:
- log.debug("Unrecognised path iterator type");
+ LOG.debug("Unrecognised path iterator type");
break;
}
}
@@ -498,13 +498,13 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
/** {@inheritDoc} */
public void draw(Shape shape) {
- log.debug("draw() shape=" + shape);
+ LOG.debug("draw() shape=" + shape);
doDrawing(shape, false);
}
/** {@inheritDoc} */
public void fill(Shape shape) {
- log.debug("fill() shape=" + shape);
+ LOG.debug("fill() shape=" + shape);
doDrawing(shape, true);
}
@@ -516,7 +516,7 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
*/
public void handleIOException(IOException ioe) {
// TODO Surely, there's a better way to do this.
- log.error(ioe.getMessage());
+ LOG.error(ioe.getMessage());
ioe.printStackTrace();
}
@@ -659,29 +659,29 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
/** {@inheritDoc} */
public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
- log.debug("drawRenderableImage() NYI: img=" + img + ", xform=" + xform);
+ LOG.debug("drawRenderableImage() NYI: img=" + img + ", xform=" + xform);
}
/** {@inheritDoc} */
public FontMetrics getFontMetrics(Font f) {
- log.debug("getFontMetrics() NYI: f=" + f);
+ LOG.debug("getFontMetrics() NYI: f=" + f);
return null;
}
/** {@inheritDoc} */
public void setXORMode(Color col) {
- log.debug("setXORMode() NYI: col=" + col);
+ LOG.debug("setXORMode() NYI: col=" + col);
}
/** {@inheritDoc} */
public void addNativeImage(org.apache.xmlgraphics.image.loader.Image image,
float x, float y, float width, float height) {
- log.debug("NYI: addNativeImage() " + "image=" + image
+ LOG.debug("NYI: addNativeImage() " + "image=" + image
+ ",x=" + x + ",y=" + y + ",width=" + width + ",height=" + height);
}
/** {@inheritDoc} */
public void copyArea(int x, int y, int width, int height, int dx, int dy) {
- log.debug("copyArea() NYI: ");
+ LOG.debug("copyArea() NYI: ");
}
}
diff --git a/src/java/org/apache/fop/afp/AFPLineDataInfo.java b/src/java/org/apache/fop/afp/AFPLineDataInfo.java
index a056ebf1f..108b98596 100644
--- a/src/java/org/apache/fop/afp/AFPLineDataInfo.java
+++ b/src/java/org/apache/fop/afp/AFPLineDataInfo.java
@@ -25,25 +25,25 @@ import java.awt.Color;
public class AFPLineDataInfo {
/** the x1 coordinate */
- int x1;
+ private int x1;
/** the y1 coordinate */
- int y1;
+ private int y1;
/** the x2 coordinate */
- int x2;
+ private int x2;
/** the y2 coordinate */
- int y2;
+ private int y2;
/** the thickness */
- int thickness;
+ private int thickness;
/** the painting color */
- Color color;
+ private Color color;
/** the rotation */
- int rotation = 0;
+ private int rotation = 0;
/**
* Default constructor
diff --git a/src/java/org/apache/fop/afp/AFPRectanglePainter.java b/src/java/org/apache/fop/afp/AFPRectanglePainter.java
index 5b79a3f57..7b8a616da 100644
--- a/src/java/org/apache/fop/afp/AFPRectanglePainter.java
+++ b/src/java/org/apache/fop/afp/AFPRectanglePainter.java
@@ -42,6 +42,7 @@ public class AFPRectanglePainter extends AbstractAFPPainter {
RectanglePaintingInfo rectanglePaintInfo = (RectanglePaintingInfo)paintInfo;
int pageWidth = dataStream.getCurrentPage().getWidth();
int pageHeight = dataStream.getCurrentPage().getHeight();
+ int yNew;
AFPUnitConverter unitConv = paintingState.getUnitConverter();
float width = unitConv.pt2units(rectanglePaintInfo.getWidth());
@@ -52,31 +53,39 @@ public class AFPRectanglePainter extends AbstractAFPPainter {
AffineTransform at = paintingState.getData().getTransform();
AFPLineDataInfo lineDataInfo = new AFPLineDataInfo();
- lineDataInfo.color = paintingState.getColor();
- lineDataInfo.rotation = paintingState.getRotation();
- lineDataInfo.thickness = Math.round(height);
+ lineDataInfo.setColor ( paintingState.getColor() );
+ lineDataInfo.setRotation ( paintingState.getRotation() );
+ lineDataInfo.setThickness ( Math.round(height) );
- switch (lineDataInfo.rotation) {
+ switch (lineDataInfo.getRotation()) {
+ default:
case 0:
- lineDataInfo.x1 = Math.round((float)at.getTranslateX() + x);
- lineDataInfo.y1 = lineDataInfo.y2 = Math.round((float)at.getTranslateY() + y);
- lineDataInfo.x2 = Math.round((float)at.getTranslateX() + x + width);
+ lineDataInfo.setX1 ( Math.round((float)at.getTranslateX() + x) );
+ yNew = Math.round((float)at.getTranslateY() + y);
+ lineDataInfo.setY1 ( yNew );
+ lineDataInfo.setY2 ( yNew );
+ lineDataInfo.setX2 ( Math.round((float)at.getTranslateX() + x + width) );
break;
case 90:
- lineDataInfo.x1 = Math.round((float)at.getTranslateY() + x);
- lineDataInfo.y1 = lineDataInfo.y2
- = pageWidth - Math.round((float)at.getTranslateX()) + Math.round(y);
- lineDataInfo.x2 = Math.round(width + (float)at.getTranslateY() + x);
+ lineDataInfo.setX1 ( Math.round((float)at.getTranslateY() + x) );
+ yNew = pageWidth - Math.round((float)at.getTranslateX()) + Math.round(y);
+ lineDataInfo.setY1 ( yNew );
+ lineDataInfo.setY2 ( yNew );
+ lineDataInfo.setX2 ( Math.round(width + (float)at.getTranslateY() + x) );
break;
case 180:
- lineDataInfo.x1 = pageWidth - Math.round((float)at.getTranslateX() - x);
- lineDataInfo.y1 = lineDataInfo.y2 = pageHeight - Math.round((float)at.getTranslateY() - y);
- lineDataInfo.x2 = pageWidth - Math.round((float)at.getTranslateX() - x - width);
+ lineDataInfo.setX1 ( pageWidth - Math.round((float)at.getTranslateX() - x) );
+ yNew = pageHeight - Math.round((float)at.getTranslateY() - y);
+ lineDataInfo.setY1 ( yNew );
+ lineDataInfo.setY2 ( yNew );
+ lineDataInfo.setX2 ( pageWidth - Math.round((float)at.getTranslateX() - x - width) );
break;
case 270:
- lineDataInfo.x1 = pageHeight - Math.round((float)at.getTranslateY() - x);
- lineDataInfo.y1 = lineDataInfo.y2 = Math.round((float)at.getTranslateX() + y);
- lineDataInfo.x2 = pageHeight - Math.round((float)at.getTranslateY() - x - width);
+ lineDataInfo.setX1 ( pageHeight - Math.round((float)at.getTranslateY() - x) );
+ yNew = Math.round((float)at.getTranslateX() + y);
+ lineDataInfo.setY1 ( yNew );
+ lineDataInfo.setY2 ( yNew );
+ lineDataInfo.setX2 ( pageHeight - Math.round((float)at.getTranslateY() - x - width) );
break;
}
dataStream.createLine(lineDataInfo);
diff --git a/src/java/org/apache/fop/afp/AFPResourceManager.java b/src/java/org/apache/fop/afp/AFPResourceManager.java
index b7e1abc01..ae759e14a 100644
--- a/src/java/org/apache/fop/afp/AFPResourceManager.java
+++ b/src/java/org/apache/fop/afp/AFPResourceManager.java
@@ -19,12 +19,15 @@
package org.apache.fop.afp;
+import java.io.BufferedInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -38,6 +41,7 @@ import org.apache.fop.afp.modca.PageSegment;
import org.apache.fop.afp.modca.Registry;
import org.apache.fop.afp.modca.ResourceGroup;
import org.apache.fop.afp.modca.ResourceObject;
+import org.apache.fop.afp.util.AFPResourceUtil;
import org.apache.fop.afp.util.ResourceAccessor;
/**
@@ -314,6 +318,57 @@ public class AFPResourceManager {
}
/**
+ * Creates an included resource extracting the named resource from an external source.
+ * @param resourceName the name of the resource
+ * @param uri the URI for the resource
+ * @param accessor resource accessor to access the resource with
+ * @throws IOException if an I/O error occurs while loading the resource
+ */
+ public void createIncludedResourceFromExternal(final String resourceName,
+ final URI uri, final ResourceAccessor accessor) throws IOException {
+
+ AFPResourceLevel resourceLevel = new AFPResourceLevel(AFPResourceLevel.PRINT_FILE);
+
+ AFPResourceInfo resourceInfo = new AFPResourceInfo();
+ resourceInfo.setLevel(resourceLevel);
+ resourceInfo.setName(resourceName);
+ resourceInfo.setUri(uri.toASCIIString());
+
+ String resource = (String)includeNameMap.get(resourceInfo);
+ if (resource == null) {
+
+ ResourceGroup resourceGroup = streamer.getResourceGroup(resourceLevel);
+
+ //resourceObject delegates write commands to copyNamedResource()
+ //The included resource may already be wrapped in a resource object
+ AbstractNamedAFPObject resourceObject = new AbstractNamedAFPObject(null) {
+
+ protected void writeContent(OutputStream os) throws IOException {
+ InputStream inputStream = null;
+ try {
+ inputStream = accessor.createInputStream(uri);
+ BufferedInputStream bin = new BufferedInputStream(inputStream);
+ AFPResourceUtil.copyNamedResource(resourceName, bin, os);
+ } finally {
+ IOUtils.closeQuietly(inputStream);
+ }
+ }
+
+ //bypass super.writeStart
+ protected void writeStart(OutputStream os) throws IOException { }
+ //bypass super.writeEnd
+ protected void writeEnd(OutputStream os) throws IOException { }
+ };
+
+ resourceGroup.addObject(resourceObject);
+
+ includeNameMap.put(resourceInfo, resourceName);
+
+ }
+ }
+
+
+ /**
* Sets resource level defaults. The existing defaults over merged with the ones passed in
* as parameter.
* @param defaults the new defaults
diff --git a/src/java/org/apache/fop/afp/AFPStreamer.java b/src/java/org/apache/fop/afp/AFPStreamer.java
index 7e208bb6e..65686b92a 100644
--- a/src/java/org/apache/fop/afp/AFPStreamer.java
+++ b/src/java/org/apache/fop/afp/AFPStreamer.java
@@ -31,6 +31,7 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.afp.modca.ResourceGroup;
import org.apache.fop.afp.modca.StreamedResourceGroup;
@@ -39,7 +40,7 @@ import org.apache.fop.afp.modca.StreamedResourceGroup;
*/
public class AFPStreamer implements Streamable {
/** Static logging instance */
- private static final Log log = LogFactory.getLog(AFPStreamer.class);
+ private static final Log LOG = LogFactory.getLog(AFPStreamer.class);
private static final String AFPDATASTREAM_TEMP_FILE_PREFIX = "AFPDataStream_";
@@ -119,7 +120,7 @@ public class AFPStreamer implements Streamable {
if (level.isExternal()) {
String filePath = level.getExternalFilePath();
if (filePath == null) {
- log.warn("No file path provided for external resource, using default.");
+ LOG.warn("No file path provided for external resource, using default.");
filePath = defaultResourceGroupFilePath;
}
resourceGroup = (ResourceGroup)pathResourceGroupMap.get(filePath);
@@ -128,7 +129,7 @@ public class AFPStreamer implements Streamable {
try {
os = new BufferedOutputStream(new FileOutputStream(filePath));
} catch (FileNotFoundException fnfe) {
- log.error("Failed to create/open external resource group file '"
+ LOG.error("Failed to create/open external resource group file '"
+ filePath + "'");
} finally {
if (os != null) {
@@ -157,7 +158,7 @@ public class AFPStreamer implements Streamable {
*/
// write out any external resource groups
public void close() throws IOException {
- Iterator it = pathResourceGroupMap.entrySet().iterator();
+ Iterator it = pathResourceGroupMap.values().iterator();
while (it.hasNext()) {
StreamedResourceGroup resourceGroup = (StreamedResourceGroup)it.next();
resourceGroup.close();
@@ -173,6 +174,14 @@ public class AFPStreamer implements Streamable {
outputStream.close();
+
+ if (documentOutputStream != null) {
+ documentOutputStream.close();
+ }
+
+ if (documentFile != null) {
+ documentFile.close();
+ }
// delete temporary file
tempFile.delete();
}
@@ -212,4 +221,4 @@ public class AFPStreamer implements Streamable {
// long end = System.currentTimeMillis();
// log.debug("writing time " + (end - start) + "ms");
}
-} \ No newline at end of file
+}
diff --git a/src/java/org/apache/fop/afp/AbstractAFPPainter.java b/src/java/org/apache/fop/afp/AbstractAFPPainter.java
index 1358f8072..a2a128be5 100644
--- a/src/java/org/apache/fop/afp/AbstractAFPPainter.java
+++ b/src/java/org/apache/fop/afp/AbstractAFPPainter.java
@@ -30,9 +30,11 @@ import org.apache.commons.logging.LogFactory;
public abstract class AbstractAFPPainter {
/** Static logging instance */
- protected static Log log = LogFactory.getLog("org.apache.xmlgraphics.afp");
+ protected static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp");
+ /** data stream */
protected final DataStream dataStream;
+ /** painting state */
protected final AFPPaintingState paintingState;
/**
diff --git a/src/java/org/apache/fop/afp/DataStream.java b/src/java/org/apache/fop/afp/DataStream.java
index 110fd2773..a437c3004 100644
--- a/src/java/org/apache/fop/afp/DataStream.java
+++ b/src/java/org/apache/fop/afp/DataStream.java
@@ -30,8 +30,8 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.afp.fonts.AFPFontAttributes;
import org.apache.fop.afp.fonts.AFPFont;
+import org.apache.fop.afp.fonts.AFPFontAttributes;
import org.apache.fop.afp.fonts.CharacterSet;
import org.apache.fop.afp.modca.AbstractPageObject;
import org.apache.fop.afp.modca.Document;
@@ -42,10 +42,10 @@ import org.apache.fop.afp.modca.PageObject;
import org.apache.fop.afp.modca.ResourceGroup;
import org.apache.fop.afp.modca.TagLogicalElementBean;
import org.apache.fop.afp.modca.triplets.FullyQualifiedNameTriplet;
-import org.apache.fop.afp.ptoca.PtocaProducer;
import org.apache.fop.afp.ptoca.PtocaBuilder;
-import org.apache.fop.util.CharUtilities;
+import org.apache.fop.afp.ptoca.PtocaProducer;
import org.apache.fop.fonts.Font;
+import org.apache.fop.util.CharUtilities;
/**
* A data stream is a continuous ordered stream of data elements and objects
@@ -65,7 +65,7 @@ import org.apache.fop.fonts.Font;
public class DataStream {
/** Static logging instance */
- protected static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp");
+ protected static final Log LOG = LogFactory.getLog("org.apache.xmlgraphics.afp");
/** Boolean completion indicator */
private boolean complete = false;
@@ -162,7 +162,7 @@ public class DataStream {
public void endDocument() throws IOException {
if (complete) {
String msg = "Invalid state - document already ended.";
- log.warn("endDocument():: " + msg);
+ LOG.warn("endDocument():: " + msg);
throw new IllegalStateException(msg);
}
@@ -356,11 +356,12 @@ public class DataStream {
* @param letterSpacing letter spacing to draw text with
* @param wordSpacing word Spacing to draw text with
* @param font is the font to draw text with
- * @param charSet is the AFP Character Set to use with the text
+ * @param charSet is the AFP Character Set to use with the text
* @throws UnsupportedEncodingException thrown if character encoding is not supported
*/
- public void createText(final AFPTextDataInfo textDataInfo, final int letterSpacing, final int wordSpacing,
- final Font font, final CharacterSet charSet) throws UnsupportedEncodingException {
+ public void createText(final AFPTextDataInfo textDataInfo, final int letterSpacing,
+ final int wordSpacing, final Font font, final CharacterSet charSet)
+ throws UnsupportedEncodingException {
int rotation = paintingState.getRotation();
if (rotation != 0) {
textDataInfo.setRotation(rotation);
diff --git a/src/java/org/apache/fop/afp/Factory.java b/src/java/org/apache/fop/afp/Factory.java
index 9d9b83875..ef68a22fb 100644
--- a/src/java/org/apache/fop/afp/Factory.java
+++ b/src/java/org/apache/fop/afp/Factory.java
@@ -21,8 +21,6 @@ package org.apache.fop.afp;
import java.io.OutputStream;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.fop.afp.goca.GraphicsData;
import org.apache.fop.afp.ioca.ImageContent;
import org.apache.fop.afp.ioca.ImageRasterData;
@@ -65,9 +63,6 @@ import org.apache.fop.afp.util.StringUtils;
*/
public class Factory {
- /** Static logging instance */
- private static final Log log = LogFactory.getLog(Factory.class);
-
private static final String OBJECT_ENVIRONMENT_GROUP_NAME_PREFIX = "OEG";
private static final String ACTIVE_ENVIRONMENT_GROUP_NAME_PREFIX = "AEG";
@@ -541,7 +536,10 @@ public class Factory {
/**
* Creates a new PTOCA {@link PresentationTextDescriptor}
- *
+ * @param width presentation width
+ * @param height presentation height
+ * @param widthRes resolution of presentation width
+ * @param heightRes resolution of presentation height
* @return a new {@link PresentationTextDescriptor}
*/
public PresentationTextDescriptor createPresentationTextDataDescriptor(
diff --git a/src/java/org/apache/fop/afp/GrayScaleColorConverter.java b/src/java/org/apache/fop/afp/GrayScaleColorConverter.java
index d9c85ca96..c7daf20c6 100644
--- a/src/java/org/apache/fop/afp/GrayScaleColorConverter.java
+++ b/src/java/org/apache/fop/afp/GrayScaleColorConverter.java
@@ -1,61 +1,61 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.afp;
-
-import java.awt.Color;
-
-import org.apache.xmlgraphics.java2d.color.ColorConverter;
-
-import org.apache.fop.util.ColorUtil;
-
-/**
- * Converts to grayscale using the standard RED=30%, GREEN=59% and BLUE=11%
- * weights (see http://en.wikipedia.org/wiki/Grayscale)
- */
-final class GrayScaleColorConverter implements ColorConverter {
-
- private static final int RED_WEIGHT = 77;
- private static final int GREEN_WEIGTH = 150;
- private static final int BLUE_WEIGHT = 28;
-
- private static final GrayScaleColorConverter SINGLETON = new GrayScaleColorConverter();
-
- private GrayScaleColorConverter() { }
-
- /**
- * static factory
- *
- * @return singleton instance of GrayScaleColorConverter
- */
- public static GrayScaleColorConverter getInstance() {
- return SINGLETON;
- }
-
- /**
- * The color is converted to CMYK with just the K component {@inheritDoc}
- */
- public Color convert(Color color) {
-
- float kValue = (RED_WEIGHT * color.getRed() + GREEN_WEIGTH * color.getGreen() + BLUE_WEIGHT
- * color.getBlue()) / 255.0f / 255.0f;
-
- return ColorUtil.toCMYKGrayColor(kValue);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.afp;
+
+import java.awt.Color;
+
+import org.apache.xmlgraphics.java2d.color.ColorConverter;
+
+import org.apache.fop.util.ColorUtil;
+
+/**
+ * Converts to grayscale using the standard RED=30%, GREEN=59% and BLUE=11%
+ * weights (see http://en.wikipedia.org/wiki/Grayscale)
+ */
+final class GrayScaleColorConverter implements ColorConverter {
+
+ private static final int RED_WEIGHT = 77;
+ private static final int GREEN_WEIGTH = 150;
+ private static final int BLUE_WEIGHT = 28;
+
+ private static final GrayScaleColorConverter SINGLETON = new GrayScaleColorConverter();
+
+ private GrayScaleColorConverter() { }
+
+ /**
+ * static factory
+ *
+ * @return singleton instance of GrayScaleColorConverter
+ */
+ public static GrayScaleColorConverter getInstance() {
+ return SINGLETON;
+ }
+
+ /**
+ * The color is converted to CMYK with just the K component {@inheritDoc}
+ */
+ public Color convert(Color color) {
+
+ float kValue = (RED_WEIGHT * color.getRed() + GREEN_WEIGTH * color.getGreen() + BLUE_WEIGHT
+ * color.getBlue()) / 255.0f / 255.0f;
+
+ return ColorUtil.toCMYKGrayColor(kValue);
+ }
+}
diff --git a/src/java/org/apache/fop/afp/Startable.java b/src/java/org/apache/fop/afp/Startable.java
index fd05b8455..62995d4d5 100644
--- a/src/java/org/apache/fop/afp/Startable.java
+++ b/src/java/org/apache/fop/afp/Startable.java
@@ -27,7 +27,7 @@ public interface Startable {
/**
* Sets whether or not this object has started or not
*
- * @param complete true if this object has started
+ * @param started true if this object has started
*/
void setStarted(boolean started);
diff --git a/src/java/org/apache/fop/afp/apps/FontPatternExtractor.java b/src/java/org/apache/fop/afp/apps/FontPatternExtractor.java
new file mode 100644
index 000000000..0adffcd8b
--- /dev/null
+++ b/src/java/org/apache/fop/afp/apps/FontPatternExtractor.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.afp.apps;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+import org.apache.commons.io.HexDump;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+
+import org.apache.fop.afp.parser.MODCAParser;
+import org.apache.fop.afp.parser.UnparsedStructuredField;
+
+/**
+ * This class represents a tool for extracting the Type 1 PFB file from an AFP outline font.
+ */
+public class FontPatternExtractor {
+
+ private PrintStream printStream = System.out;
+
+ /**
+ * Extracts the Type1 PFB file from the given AFP outline font.
+ * @param file the AFP file to read from
+ * @param targetDir the target directory where the PFB file is to be placed.
+ * @throws IOException if an I/O error occurs
+ */
+ public void extract(File file, File targetDir) throws IOException {
+ InputStream in = new java.io.FileInputStream(file);
+ try {
+ MODCAParser parser = new MODCAParser(in);
+ ByteArrayOutputStream baout = new ByteArrayOutputStream();
+ UnparsedStructuredField strucField;
+ while ((strucField = parser.readNextStructuredField()) != null) {
+ if (strucField.getSfTypeID() == 0xD3EE89) {
+ println(strucField.toString());
+ HexDump.dump(strucField.getData(), 0, printStream, 0);
+ baout.write(strucField.getData());
+ }
+ }
+
+ ByteArrayInputStream bin = new ByteArrayInputStream(baout.toByteArray());
+ DataInputStream din = new DataInputStream(bin);
+ long len = din.readInt() & 0xFFFFFFFFL;
+ println("Length: " + len);
+ din.skip(4); //checksum
+ int tidLen = din.readUnsignedShort() - 2;
+ byte[] tid = new byte[tidLen];
+ din.readFully(tid);
+ String filename = new String(tid, "ISO-8859-1");
+ int asciiCount1 = countUSAsciiCharacters(filename);
+ String filenameEBCDIC = new String(tid, "Cp1146");
+ int asciiCount2 = countUSAsciiCharacters(filenameEBCDIC);
+ println("TID: " + filename + " " + filenameEBCDIC);
+
+ if (asciiCount2 > asciiCount1) {
+ //Haven't found an indicator if the name is encoded in EBCDIC or not
+ //so we use a trick.
+ filename = filenameEBCDIC;
+ }
+ if (!filename.toLowerCase().endsWith(".pfb")) {
+ filename = filename + ".pfb";
+ }
+ println("Output filename: " + filename);
+ File out = new File(targetDir, filename);
+
+ OutputStream fout = new java.io.FileOutputStream(out);
+ try {
+ IOUtils.copyLarge(din, fout);
+ } finally {
+ IOUtils.closeQuietly(fout);
+ }
+
+
+ } finally {
+ IOUtils.closeQuietly(in);
+ }
+ }
+
+ private void println(String s) {
+ printStream.println(s);
+ }
+
+ private void println() {
+ printStream.println();
+ }
+
+ private int countUSAsciiCharacters(String filename) {
+ int count = 0;
+ for (int i = 0, c = filename.length(); i < c; i++) {
+ if (filename.charAt(i) < 128) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ /**
+ * Main method
+ * @param args the command-line arguments
+ */
+ public static void main(String[] args) {
+ try {
+ FontPatternExtractor app = new FontPatternExtractor();
+
+ app.println("Font Pattern Extractor");
+ app.println();
+
+ if (args.length > 0) {
+ String filename = args[0];
+ File file = new File(filename);
+
+ File targetDir = file.getParentFile();
+ if (args.length > 1) {
+ targetDir = new File(args[1]);
+ targetDir.mkdirs();
+ }
+
+ app.extract(file, targetDir);
+ } else {
+ app.println("This tool tries to extract the PFB file from an AFP outline font.");
+ app.println();
+ app.println("Usage: Java -cp ... " + FontPatternExtractor.class.getName()
+ + " <afp-font-file> [<target-dir>]");
+ System.exit(-1);
+ }
+
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(-1);
+ }
+ }
+
+}
diff --git a/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java b/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java
index 66b3f5564..b7db6a74e 100644
--- a/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java
+++ b/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java
@@ -61,9 +61,9 @@ public class AFPFontCollection implements FontCollection {
List/*<FontTriplet>*/ tripletList = afpFontInfo.getFontTriplets();
for (Iterator it2 = tripletList.iterator(); it2.hasNext();) {
FontTriplet triplet = (FontTriplet)it2.next();
+ fontInfo.addMetrics("F" + num, afpFont);
fontInfo.addFontProperties("F" + num,
triplet.getName(), triplet.getStyle(), triplet.getWeight());
- fontInfo.addMetrics("F" + num, afpFont);
num++;
}
}
diff --git a/src/java/org/apache/fop/afp/fonts/AFPFontInfo.java b/src/java/org/apache/fop/afp/fonts/AFPFontInfo.java
index 0259435c6..02e542419 100644
--- a/src/java/org/apache/fop/afp/fonts/AFPFontInfo.java
+++ b/src/java/org/apache/fop/afp/fonts/AFPFontInfo.java
@@ -32,7 +32,7 @@ public class AFPFontInfo {
/**
* Main constructor
- *
+ *
* @param afpFont The AFP Font
* @param tripletList List of font triplets to associate with this font
*/
@@ -43,7 +43,7 @@ public class AFPFontInfo {
/**
* Returns the afp font
- *
+ *
* @return the afp font
*/
public AFPFont getAFPFont() {
@@ -52,7 +52,7 @@ public class AFPFontInfo {
/**
* Returns the list of font triplets associated with this font.
- *
+ *
* @return List of font triplets
*/
public List/*<FontTriplet>*/ getFontTriplets() {
diff --git a/src/java/org/apache/fop/afp/fonts/CharacterSet.java b/src/java/org/apache/fop/afp/fonts/CharacterSet.java
index fec2e6741..7123d4138 100644
--- a/src/java/org/apache/fop/afp/fonts/CharacterSet.java
+++ b/src/java/org/apache/fop/afp/fonts/CharacterSet.java
@@ -21,7 +21,6 @@ package org.apache.fop.afp.fonts;
import java.io.File;
import java.io.UnsupportedEncodingException;
-import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
@@ -102,7 +101,8 @@ public class CharacterSet {
* @param encoding the encoding of the font
* @param name the character set name
* @param path the path to the installed afp fonts
- * @deprecated Please use {@link #CharacterSet(String, String, String, URI)} instead.
+ * @deprecated Please use
+ * {@link #CharacterSet(String, String, String, ResourceAccessor)} instead.
*/
public CharacterSet(String codePage, String encoding, String name, String path) {
this(codePage, encoding, name,
diff --git a/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java b/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java
index 7d2c46bc6..d575e2ae1 100644
--- a/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java
+++ b/src/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java
@@ -114,8 +114,9 @@ public class CharacterSetBuilder {
*/
private final SoftMapCache characterSetsCache = new SoftMapCache(true);
-
- private CharacterSetBuilder() { }
+ /** Default constructor. */
+ protected CharacterSetBuilder() {
+ }
/**
* Factory method for the single-byte implementation of AFPFontReader.
diff --git a/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java b/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java
index 84e4b7a69..b7246f35b 100644
--- a/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java
+++ b/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java
@@ -279,7 +279,7 @@ public class CharacterSetOrientation {
* Returns the space increment.
* @return the space increment
*/
- public int getSpaceIncrement(){
+ public int getSpaceIncrement() {
return this.spaceIncrement;
}
@@ -295,7 +295,7 @@ public class CharacterSetOrientation {
* Returns the em space increment.
* @return the em space increment
*/
- public int getEmSpaceIncrement(){
+ public int getEmSpaceIncrement() {
return this.emSpaceIncrement;
}
diff --git a/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java b/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java
index 9f5dcbcf7..4514eac5d 100644
--- a/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java
+++ b/src/java/org/apache/fop/afp/fonts/DoubleByteFont.java
@@ -36,7 +36,7 @@ public class DoubleByteFont extends AbstractOutlineFont {
private static final Set IDEOGRAPHIC = new java.util.HashSet();
static {
IDEOGRAPHIC.add(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS);
- //IDEOGRAPHIC.add(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT); //Java 1.5
+ //IDEOGRAPHIC.add(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT);//Java 1.5
IDEOGRAPHIC.add(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS);
IDEOGRAPHIC.add(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A);
//IDEOGRAPHIC.add(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B); //Java 1.1
diff --git a/src/java/org/apache/fop/afp/fonts/OutlineFont.java b/src/java/org/apache/fop/afp/fonts/OutlineFont.java
index 26488e54d..d4fd0624d 100644
--- a/src/java/org/apache/fop/afp/fonts/OutlineFont.java
+++ b/src/java/org/apache/fop/afp/fonts/OutlineFont.java
@@ -24,7 +24,11 @@ package org.apache.fop.afp.fonts;
*/
public class OutlineFont extends AbstractOutlineFont {
- /** {@inheritDoc} */
+ /**
+ * Construct outline font with specified name and character set.
+ * @param name font's name
+ * @param charSet font's character set
+ */
public OutlineFont(String name, CharacterSet charSet) {
super(name, charSet);
}
diff --git a/src/java/org/apache/fop/afp/fonts/RasterFont.java b/src/java/org/apache/fop/afp/fonts/RasterFont.java
index cba608471..2a4d5d270 100644
--- a/src/java/org/apache/fop/afp/fonts/RasterFont.java
+++ b/src/java/org/apache/fop/afp/fonts/RasterFont.java
@@ -37,7 +37,7 @@ import org.apache.commons.logging.LogFactory;
public class RasterFont extends AFPFont {
/** Static logging instance */
- protected static final Log log = LogFactory.getLog("org.apache.fop.afp.fonts");
+ protected static final Log LOG = LogFactory.getLog("org.apache.fop.afp.fonts");
private final SortedMap/*<Integer,CharacterSet>*/ charSets
= new java.util.TreeMap/*<Integer,CharacterSet>*/();
@@ -117,7 +117,7 @@ public class RasterFont extends AFPFont {
substitutionCharSets.put(requestedSize, csm);
String msg = "No " + (size / 1000f) + "pt font " + getFontName()
+ " found, substituted with " + fontSize.intValue() / 1000f + "pt font";
- log.warn(msg);
+ LOG.warn(msg);
}
}
@@ -125,7 +125,7 @@ public class RasterFont extends AFPFont {
// Still no match -> error
String msg = "No font found for font " + getFontName()
+ " with point size " + size / 1000f;
- log.error(msg);
+ LOG.error(msg);
throw new FontRuntimeException(msg);
}
@@ -144,7 +144,7 @@ public class RasterFont extends AFPFont {
return csm.getFirstChar();
} else {
String msg = "getFirstChar() - No character set found for font:" + getFontName();
- log.error(msg);
+ LOG.error(msg);
throw new FontRuntimeException(msg);
}
}
@@ -161,7 +161,7 @@ public class RasterFont extends AFPFont {
return csm.getLastChar();
} else {
String msg = "getLastChar() - No character set found for font:" + getFontName();
- log.error(msg);
+ LOG.error(msg);
throw new FontRuntimeException(msg);
}
diff --git a/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java b/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java
index 3c3442def..f5db5ce46 100644
--- a/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java
+++ b/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java
@@ -32,6 +32,7 @@ public abstract class AbstractGraphicsCoord extends AbstractGraphicsDrawingOrder
/** array of x/y coordinates */
protected int[] coords = null;
+ /** if true, then uses relative drawing order */
protected boolean relative = false;
/**
@@ -51,7 +52,7 @@ public abstract class AbstractGraphicsCoord extends AbstractGraphicsDrawingOrder
* Constructor
*
* @param coords the x/y coordinates for this object
- * @param relative
+ * @param relative true if relative drawing order
*/
public AbstractGraphicsCoord(int[] coords, boolean relative) {
this(coords);
diff --git a/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java b/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java
index 1162e83aa..8d94bf9fc 100644
--- a/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java
+++ b/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java
@@ -73,7 +73,6 @@ public final class GraphicsChainedSegment extends AbstractGraphicsDrawingOrderCo
return NAME_LENGTH;
}
- /** {@inheritDoc} */
byte getOrderCode() {
return 0x70;
}
diff --git a/src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java b/src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java
index 6d6e44c97..dc61f1034 100644
--- a/src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java
+++ b/src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java
@@ -52,8 +52,6 @@ public class GraphicsCharacterString extends AbstractGraphicsCoord {
* Constructor (relative positioning)
*
* @param str the character string
- * @param x the x coordinate
- * @param y the y coordinate
*/
public GraphicsCharacterString(String str) {
super(null);
diff --git a/src/java/org/apache/fop/afp/goca/GraphicsFillet.java b/src/java/org/apache/fop/afp/goca/GraphicsFillet.java
index 9dad2fe1c..d935f6550 100644
--- a/src/java/org/apache/fop/afp/goca/GraphicsFillet.java
+++ b/src/java/org/apache/fop/afp/goca/GraphicsFillet.java
@@ -29,6 +29,7 @@ public final class GraphicsFillet extends AbstractGraphicsCoord {
* Constructor
*
* @param coords the x/y coordinates for this object
+ * @param relative true if uses relative drawing order
*/
public GraphicsFillet(int[] coords, boolean relative) {
super(coords, relative);
diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java b/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java
index dfb5ae0d2..6551470cc 100644
--- a/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java
+++ b/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java
@@ -27,7 +27,10 @@ import java.io.OutputStream;
*/
public class GraphicsSetMix extends AbstractGraphicsDrawingOrder {
+ /** default mode */
public static final byte MODE_DEFAULT = 0x00;
+
+ /** overpaint mode */
public static final byte MODE_OVERPAINT = 0x02;
/** the mix mode value */
diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java b/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java
index e2cc081ce..e3968d824 100644
--- a/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java
+++ b/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java
@@ -84,7 +84,7 @@ public class GraphicsSetPatternSymbol extends AbstractGraphicsDrawingOrder {
/**
* Main constructor
*
- * @param symb the pattern symbol to use
+ * @param pattern the pattern symbol to use
*/
public GraphicsSetPatternSymbol(byte pattern) {
this.pattern = pattern;
diff --git a/src/java/org/apache/fop/afp/ioca/IDEStructureParameter.java b/src/java/org/apache/fop/afp/ioca/IDEStructureParameter.java
index 5c1b9da94..b0cce02e1 100644
--- a/src/java/org/apache/fop/afp/ioca/IDEStructureParameter.java
+++ b/src/java/org/apache/fop/afp/ioca/IDEStructureParameter.java
@@ -85,9 +85,9 @@ public class IDEStructureParameter implements Streamable {
}
/**
- * Sets
- * @param numComponents
- * @param bitsPerComponent
+ * Sets uniform bits per component.
+ * @param numComponents the number of components
+ * @param bitsPerComponent number of bits per component
*/
public void setUniformBitsPerComponent(int numComponents, int bitsPerComponent) {
if (bitsPerComponent < 0 || bitsPerComponent >= 256) {
diff --git a/src/java/org/apache/fop/afp/ioca/ImageRasterPattern.java b/src/java/org/apache/fop/afp/ioca/ImageRasterPattern.java
index 789eeb950..9a5d4b402 100644
--- a/src/java/org/apache/fop/afp/ioca/ImageRasterPattern.java
+++ b/src/java/org/apache/fop/afp/ioca/ImageRasterPattern.java
@@ -26,7 +26,10 @@ package org.apache.fop.afp.ioca;
* shades of grey (betweeen 0 and 16) the lower the number being the
* darker the shade. The image data dimensions are 64 x 8.
*/
-public class ImageRasterPattern {
+public final class ImageRasterPattern {
+
+ private ImageRasterPattern() {
+ }
/**
* The Raster Pattern for Greyscale 16
diff --git a/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java b/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java
index 45239a6cf..af679fa25 100644
--- a/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java
+++ b/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java
@@ -27,6 +27,7 @@ import java.util.Iterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.afp.Streamable;
import org.apache.fop.afp.util.BinaryUtils;
@@ -38,12 +39,13 @@ import org.apache.fop.afp.util.BinaryUtils;
public abstract class AbstractAFPObject implements Streamable {
/** Static logging instance */
- protected static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp.modca");
+ protected static final Log LOG = LogFactory.getLog("org.apache.xmlgraphics.afp.modca");
/** the structured field class id */
protected static final byte SF_CLASS = (byte)0xD3;
- protected static final byte[] SF_HEADER = new byte[] {
+ /** the structure field header */
+ static final byte[] SF_HEADER = new byte[] {
0x5A, // Structured field identifier
0x00, // Length byte 1
0x10, // Length byte 2
@@ -187,7 +189,8 @@ public abstract class AbstractAFPObject implements Streamable {
protected String truncate(String str, int maxLength) {
if (str.length() > maxLength) {
str = str.substring(0, maxLength);
- log.warn("truncated character string '" + str + "', longer than " + maxLength + " chars");
+ LOG.warn("truncated character string '"
+ + str + "', longer than " + maxLength + " chars");
}
return str;
}
diff --git a/src/java/org/apache/fop/afp/modca/AbstractEnvironmentGroup.java b/src/java/org/apache/fop/afp/modca/AbstractEnvironmentGroup.java
index abc3aea87..d06311a47 100644
--- a/src/java/org/apache/fop/afp/modca/AbstractEnvironmentGroup.java
+++ b/src/java/org/apache/fop/afp/modca/AbstractEnvironmentGroup.java
@@ -73,7 +73,7 @@ public abstract class AbstractEnvironmentGroup extends AbstractNamedAFPObject {
mpo.addOverlay(name);
} catch (MaximumSizeExceededException ex) {
// Should never happen (but log just in case)
- log.error("createOverlay():: resulted in a MaximumSizeExceededException");
+ LOG.error("createOverlay():: resulted in a MaximumSizeExceededException");
}
}
}
@@ -88,6 +88,11 @@ public abstract class AbstractEnvironmentGroup extends AbstractNamedAFPObject {
return (MapPageOverlay)getLastElement(this.mapPageOverlays);
}
+ /**
+ * Get last element.
+ * @param list of elements
+ * @return last element or null if none
+ */
protected Object getLastElement(List list) {
if (list != null && list.size() > 0) {
return list.get(list.size() - 1);
diff --git a/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java b/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java
index 4e0dbc349..b349e1f7d 100644
--- a/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java
+++ b/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java
@@ -73,7 +73,7 @@ public abstract class AbstractNamedAFPObject extends AbstractTripletStructuredOb
name = (name + " ").substring(0, afpNameLen);
} else if (name.length() > afpNameLen) {
String truncatedName = name.substring(nameLen - afpNameLen, nameLen);
- log.warn("Constructor:: name '" + name + "'"
+ LOG.warn("Constructor:: name '" + name + "'"
+ " truncated to " + afpNameLen + " chars"
+ " ('" + truncatedName + "')");
name = truncatedName;
@@ -83,7 +83,7 @@ public abstract class AbstractNamedAFPObject extends AbstractTripletStructuredOb
nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
} catch (UnsupportedEncodingException usee) {
nameBytes = name.getBytes();
- log.warn(
+ LOG.warn(
"Constructor:: UnsupportedEncodingException translating the name "
+ name);
}
diff --git a/src/java/org/apache/fop/afp/modca/AbstractPageObject.java b/src/java/org/apache/fop/afp/modca/AbstractPageObject.java
index af676410f..1454cf96d 100644
--- a/src/java/org/apache/fop/afp/modca/AbstractPageObject.java
+++ b/src/java/org/apache/fop/afp/modca/AbstractPageObject.java
@@ -166,8 +166,7 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject implemen
* Helper method to create text on the current page, this method delegates
* to the presentation text object in order to construct the text.
*
- * @param textDataInfo
- * the afp text data
+ * @param producer the producer
* @throws UnsupportedEncodingException thrown if character encoding is not supported
*/
public void createText(PtocaProducer producer) throws UnsupportedEncodingException {
@@ -258,6 +257,7 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject implemen
* the x coordinate of the page segment.
* @param y
* the y coordinate of the page segment.
+ * @param hard true if hard page segment possible
*/
public void createIncludePageSegment(String name, int x, int y, boolean hard) {
IncludePageSegment ips = factory.createIncludePageSegment(name, x, y);
diff --git a/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java b/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java
index efc38f3b8..4b269086e 100644
--- a/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java
+++ b/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java
@@ -27,8 +27,6 @@ import java.util.List;
import org.apache.fop.afp.modca.Registry.ObjectType;
import org.apache.fop.afp.modca.triplets.AbstractTriplet;
-import org.apache.fop.afp.modca.triplets.AttributeQualifierTriplet;
-import org.apache.fop.afp.modca.triplets.AttributeValueTriplet;
import org.apache.fop.afp.modca.triplets.CommentTriplet;
import org.apache.fop.afp.modca.triplets.FullyQualifiedNameTriplet;
import org.apache.fop.afp.modca.triplets.ObjectClassificationTriplet;
@@ -150,7 +148,7 @@ public class AbstractTripletStructuredObject extends AbstractStructuredObject {
if (fqNameTriplet != null) {
return fqNameTriplet.getFullyQualifiedName();
}
- log.warn(this + " has no fully qualified name");
+ LOG.warn(this + " has no fully qualified name");
return null;
}
diff --git a/src/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java b/src/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java
index ecdfa0157..696787bc4 100644
--- a/src/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java
+++ b/src/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java
@@ -185,7 +185,7 @@ public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup {
mapCodedFont.addFont(fontRef, font, size, orientation);
} catch (MaximumSizeExceededException ex) {
// Should never happen (but log just in case)
- log.error("createFont():: resulted in a MaximumSizeExceededException");
+ LOG.error("createFont():: resulted in a MaximumSizeExceededException");
}
}
}
@@ -205,6 +205,10 @@ public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup {
}
}
+ /**
+ * Add map page segment.
+ * @param name of segment to add
+ */
public void addMapPageSegment(String name) {
try {
needMapPageSegment().addPageSegment(name);
diff --git a/src/java/org/apache/fop/afp/modca/GraphicsObject.java b/src/java/org/apache/fop/afp/modca/GraphicsObject.java
index 350a602bf..c94ad5ffc 100644
--- a/src/java/org/apache/fop/afp/modca/GraphicsObject.java
+++ b/src/java/org/apache/fop/afp/modca/GraphicsObject.java
@@ -100,7 +100,7 @@ public class GraphicsObject extends AbstractDataObject {
getObjectEnvironmentGroup().setDataDescriptor(graphicsDataDescriptor);
}
- /** {@inheritDoc} */
+ /** @param object the structured data */
public void addObject(StructuredData object) {
if (currentData == null) {
newData();
@@ -392,7 +392,11 @@ public class GraphicsObject extends AbstractDataObject {
}
/** the internal graphics state */
- private static class GraphicsState {
+ private static final class GraphicsState {
+
+ private GraphicsState() {
+ }
+
/** the current color */
private Color color;
diff --git a/src/java/org/apache/fop/afp/modca/ImageDataDescriptor.java b/src/java/org/apache/fop/afp/modca/ImageDataDescriptor.java
index 386d2f40f..f11201c88 100644
--- a/src/java/org/apache/fop/afp/modca/ImageDataDescriptor.java
+++ b/src/java/org/apache/fop/afp/modca/ImageDataDescriptor.java
@@ -29,8 +29,11 @@ import org.apache.fop.afp.util.BinaryUtils;
*/
public class ImageDataDescriptor extends AbstractDescriptor {
+ /** function set fs10 */
public static final byte FUNCTION_SET_FS10 = 0x0A;
+ /** function set fs11 */
public static final byte FUNCTION_SET_FS11 = 0x0B;
+ /** function set fs45 */
public static final byte FUNCTION_SET_FS45 = 45;
private byte functionSet = FUNCTION_SET_FS11; // FCNSET = IOCA FS 11
diff --git a/src/java/org/apache/fop/afp/modca/IncludeObject.java b/src/java/org/apache/fop/afp/modca/IncludeObject.java
index 2dff6bd87..46b4a31f2 100644
--- a/src/java/org/apache/fop/afp/modca/IncludeObject.java
+++ b/src/java/org/apache/fop/afp/modca/IncludeObject.java
@@ -116,8 +116,9 @@ public class IncludeObject extends AbstractNamedAFPObject {
/**
* Sets the x and y offset of the content area to the object area
- * used in conjunction with the {@link MappingOptionTriplet.POSITION} and
- * {@link MappingOptionTriplet.POSITION_AND_TRIM}.
+ * used in conjunction with the
+ * {@link MappingOptionTriplet#POSITION} and
+ * {@link MappingOptionTriplet#POSITION_AND_TRIM}.
*
* @param x the X-axis origin defined in the object
* @param y the Y-axis origin defined in the object
diff --git a/src/java/org/apache/fop/afp/modca/IncludePageOverlay.java b/src/java/org/apache/fop/afp/modca/IncludePageOverlay.java
index 44f0edc5b..5a3d13f61 100644
--- a/src/java/org/apache/fop/afp/modca/IncludePageOverlay.java
+++ b/src/java/org/apache/fop/afp/modca/IncludePageOverlay.java
@@ -56,7 +56,7 @@ public class IncludePageOverlay extends AbstractNamedAFPObject {
/**
* Constructor for the Include Page Overlay
- *
+ *
* @param overlayName Name of the page segment
* @param x The x position
* @param y The y position
@@ -64,7 +64,7 @@ public class IncludePageOverlay extends AbstractNamedAFPObject {
*/
public IncludePageOverlay(String overlayName, int x, int y, int orientation) {
super(overlayName);
-
+
this.x = x;
this.y = y;
setOrientation(orientation);
diff --git a/src/java/org/apache/fop/afp/modca/IncludePageSegment.java b/src/java/org/apache/fop/afp/modca/IncludePageSegment.java
index 7355e3b1a..c6eceafea 100644
--- a/src/java/org/apache/fop/afp/modca/IncludePageSegment.java
+++ b/src/java/org/apache/fop/afp/modca/IncludePageSegment.java
@@ -46,22 +46,22 @@ public class IncludePageSegment extends AbstractNamedAFPObject {
* The x position where we need to put this object on the page
*/
private int x;
-
+
/**
* The y position where we need to put this object on the page
*/
private int y;
-
+
/**
* Constructor for the Include Page Segment
- *
+ *
* @param name Name of the page segment
* @param x The x position
* @param y The y position
*/
public IncludePageSegment(String name, int x, int y) {
super(name);
-
+
this.x = x;
this.y = y;
}
diff --git a/src/java/org/apache/fop/afp/modca/IncludedResourceObject.java b/src/java/org/apache/fop/afp/modca/IncludedResourceObject.java
index 296ab2d9d..dc841bd40 100644
--- a/src/java/org/apache/fop/afp/modca/IncludedResourceObject.java
+++ b/src/java/org/apache/fop/afp/modca/IncludedResourceObject.java
@@ -26,6 +26,7 @@ import java.net.URI;
import org.apache.commons.io.IOUtils;
+import org.apache.fop.afp.util.AFPResourceUtil;
import org.apache.fop.afp.util.ResourceAccessor;
@@ -54,7 +55,7 @@ public class IncludedResourceObject extends AbstractNamedAFPObject {
public void writeToStream(OutputStream os) throws IOException {
InputStream in = resourceAccessor.createInputStream(this.uri);
try {
- IOUtils.copy(in, os);
+ AFPResourceUtil.copyResourceFile(in, os);
} finally {
IOUtils.closeQuietly(in);
}
diff --git a/src/java/org/apache/fop/afp/modca/InterchangeSet.java b/src/java/org/apache/fop/afp/modca/InterchangeSet.java
index f4b020239..35919af15 100644
--- a/src/java/org/apache/fop/afp/modca/InterchangeSet.java
+++ b/src/java/org/apache/fop/afp/modca/InterchangeSet.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,10 +25,10 @@ package org.apache.fop.afp.modca;
public class InterchangeSet {
/** interchange set 1 string value */
public static final String MODCA_PRESENTATION_INTERCHANGE_SET_1 = "MO:DCA-P IS/1";
-
+
/** interchange set 2 string value */
public static final String MODCA_PRESENTATION_INTERCHANGE_SET_2 = "MO:DCA-P IS/2";
-
+
/** resource interchange set string value */
public static final String MODCA_RESOURCE_INTERCHANGE_SET = "MO:DCA-L";
@@ -47,7 +47,7 @@ public class InterchangeSet {
/**
* Returns the interchange set value of a given string
- *
+ *
* @param str an interchange set value
* @return an interchange set
*/
@@ -65,7 +65,7 @@ public class InterchangeSet {
/**
* Main constructor
- *
+ *
* @param value the interchange set value
*/
public InterchangeSet(int value) {
@@ -74,39 +74,39 @@ public class InterchangeSet {
/**
* Returns true if complies with MOD:CA interchange set 1
- *
+ *
* @return true if complies with MOD:CA interchange set 1
*/
protected boolean is1() {
return value == SET_1;
}
-
+
/**
* Returns true if complies with MOD:CA interchange set 2
- *
+ *
* @return true if complies with MOD:CA interchange set 2
*/
public boolean is2() {
return value == SET_2;
}
-
+
/**
* Returns true if complies with MOD:CA resource set
- *
+ *
* @return true if complies with MOD:CA resource set
*/
public boolean isResource() {
return value == RESOURCE_SET;
}
-
+
/** {@inheritDoc} */
public String toString() {
return NAMES[value];
}
-
+
/**
* Returns true if MOD:CA interchange set 2 (resource groups) is supported
- *
+ *
* @return true if MOD:CA interchange set 2 (resource groups) is supported
*/
public boolean supportsLevel2() {
diff --git a/src/java/org/apache/fop/afp/modca/InvokeMediumMap.java b/src/java/org/apache/fop/afp/modca/InvokeMediumMap.java
index f910a0b9c..02031003b 100644
--- a/src/java/org/apache/fop/afp/modca/InvokeMediumMap.java
+++ b/src/java/org/apache/fop/afp/modca/InvokeMediumMap.java
@@ -34,7 +34,7 @@ public class InvokeMediumMap extends AbstractNamedAFPObject {
/**
* Constructor for the Invoke Medium Map
- *
+ *
* @param name the name of the medium map
*/
public InvokeMediumMap(String name) {
diff --git a/src/java/org/apache/fop/afp/modca/MapCodedFont.java b/src/java/org/apache/fop/afp/modca/MapCodedFont.java
index 084ae4b4c..69d8ccf31 100644
--- a/src/java/org/apache/fop/afp/modca/MapCodedFont.java
+++ b/src/java/org/apache/fop/afp/modca/MapCodedFont.java
@@ -180,7 +180,7 @@ public class MapCodedFont extends AbstractStructuredObject {
if (cs == null) {
String msg = "Character set not found for font "
+ font.getFontName() + " with point size " + size;
- log.error(msg);
+ LOG.error(msg);
throw new FontRuntimeException(msg);
}
@@ -243,7 +243,7 @@ public class MapCodedFont extends AbstractStructuredObject {
} else {
String msg = "Font of type " + font.getClass().getName()
+ " not recognized.";
- log.error(msg);
+ LOG.error(msg);
throw new FontRuntimeException(msg);
}
@@ -264,7 +264,10 @@ public class MapCodedFont extends AbstractStructuredObject {
/**
* Private utility class used as a container for font attributes
*/
- private class FontDefinition {
+ private static final class FontDefinition {
+
+ private FontDefinition() {
+ }
/**
* The code page of the font
diff --git a/src/java/org/apache/fop/afp/modca/MapPageOverlay.java b/src/java/org/apache/fop/afp/modca/MapPageOverlay.java
index 9fd3c7059..cf22e3502 100644
--- a/src/java/org/apache/fop/afp/modca/MapPageOverlay.java
+++ b/src/java/org/apache/fop/afp/modca/MapPageOverlay.java
@@ -35,7 +35,7 @@ import org.apache.fop.afp.util.BinaryUtils;
public class MapPageOverlay extends AbstractAFPObject {
private static final int MAX_SIZE = 253;
-
+
/**
* The collection of overlays (maximum of 254 stored as byte[])
*/
@@ -53,7 +53,7 @@ public class MapPageOverlay extends AbstractAFPObject {
}
return this.overLays;
}
-
+
/**
* Add an overlay to to the map page overlay object.
*
@@ -69,14 +69,14 @@ public class MapPageOverlay extends AbstractAFPObject {
throw new IllegalArgumentException("The name of overlay " + name
+ " must be 8 characters");
}
- if (log.isDebugEnabled()) {
- log.debug("addOverlay():: adding overlay " + name);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("addOverlay():: adding overlay " + name);
}
try {
byte[] data = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
getOverlays().add(data);
} catch (UnsupportedEncodingException usee) {
- log.error("addOverlay():: UnsupportedEncodingException translating the name "
+ LOG.error("addOverlay():: UnsupportedEncodingException translating the name "
+ name);
}
}
diff --git a/src/java/org/apache/fop/afp/modca/MapPageSegment.java b/src/java/org/apache/fop/afp/modca/MapPageSegment.java
index e2afd0257..8bb7afe46 100644
--- a/src/java/org/apache/fop/afp/modca/MapPageSegment.java
+++ b/src/java/org/apache/fop/afp/modca/MapPageSegment.java
@@ -67,8 +67,8 @@ public class MapPageSegment extends AbstractAFPObject {
throw new IllegalArgumentException("The name of page segment " + name
+ " must not be longer than 8 characters");
}
- if (log.isDebugEnabled()) {
- log.debug("addPageSegment():: adding page segment " + name);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("addPageSegment():: adding page segment " + name);
}
getPageSegments().add(name);
}
@@ -124,7 +124,7 @@ public class MapPageSegment extends AbstractAFPObject {
byte[] nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
System.arraycopy(nameBytes, 0, data, pos, nameBytes.length);
} catch (UnsupportedEncodingException usee) {
- log.error("UnsupportedEncodingException translating the name "
+ LOG.error("UnsupportedEncodingException translating the name "
+ name);
}
pos += 8;
diff --git a/src/java/org/apache/fop/afp/modca/ObjectContainer.java b/src/java/org/apache/fop/afp/modca/ObjectContainer.java
index e5a57ebe9..9bc8dc594 100644
--- a/src/java/org/apache/fop/afp/modca/ObjectContainer.java
+++ b/src/java/org/apache/fop/afp/modca/ObjectContainer.java
@@ -113,9 +113,9 @@ public class ObjectContainer extends AbstractDataObject {
}
/**
- * Sets the inputstream for the the object container data
+ * Sets the data for the object container
*
- * @param inputStream the inputstream for the object container data
+ * @param data a byte array
*/
public void setData(byte[] data) {
this.data = data;
diff --git a/src/java/org/apache/fop/afp/modca/PageGroup.java b/src/java/org/apache/fop/afp/modca/PageGroup.java
index f70b6fc52..895ec1259 100644
--- a/src/java/org/apache/fop/afp/modca/PageGroup.java
+++ b/src/java/org/apache/fop/afp/modca/PageGroup.java
@@ -100,6 +100,7 @@ public class PageGroup extends AbstractResourceEnvironmentGroupContainer {
return this.getName();
}
+ /** @return the TLE sequence number */
public int getTleSequence() {
return tleSequence;
}
diff --git a/src/java/org/apache/fop/afp/modca/PageSegment.java b/src/java/org/apache/fop/afp/modca/PageSegment.java
index b765d6c2f..333608d7f 100644
--- a/src/java/org/apache/fop/afp/modca/PageSegment.java
+++ b/src/java/org/apache/fop/afp/modca/PageSegment.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,10 +32,10 @@ import java.util.List;
public class PageSegment extends AbstractNamedAFPObject {
private List/*<AbstractAFPObject>*/ objects = null;
-
+
/**
* Main constructor
- *
+ *
* @param name the name of this object
*/
public PageSegment(String name) {
@@ -44,7 +44,7 @@ public class PageSegment extends AbstractNamedAFPObject {
/**
* Returns a list of objects contained withing this page segment
- *
+ *
* @return a list of objects contained within this page segment
*/
public List/*<AbstractAFPObject>*/ getObjects() {
@@ -56,13 +56,13 @@ public class PageSegment extends AbstractNamedAFPObject {
/**
* Adds a resource object (image/graphic) to this page segment
- *
+ *
* @param object the resource objec to add to this page segment
*/
public void addObject(AbstractAFPObject object) {
getObjects().add(object);
}
-
+
/** {@inheritDoc} */
protected void writeStart(OutputStream os) throws IOException {
byte[] data = new byte[17];
@@ -82,7 +82,7 @@ public class PageSegment extends AbstractNamedAFPObject {
copySF(data, Type.END, Category.PAGE_SEGMENT);
os.write(data);
}
-
+
/** {@inheritDoc} */
public String toString() {
return this.name;
diff --git a/src/java/org/apache/fop/afp/modca/PreprocessPresentationObject.java b/src/java/org/apache/fop/afp/modca/PreprocessPresentationObject.java
index ff16e89b6..a7ce0ea0b 100644
--- a/src/java/org/apache/fop/afp/modca/PreprocessPresentationObject.java
+++ b/src/java/org/apache/fop/afp/modca/PreprocessPresentationObject.java
@@ -60,9 +60,13 @@ public class PreprocessPresentationObject extends AbstractTripletStructuredObjec
}
}
+ /** 0 degrees orientation */
public static final byte ORIENTATION_ZERO_DEGREES = 1;
+ /** 90 degrees orientation */
public static final byte ORIENTATION_90_DEGREES = 2;
+ /** 180 degrees orientation */
public static final byte ORIENTATION_180_DEGREES = 4;
+ /** 270 degrees orientation */
public static final byte ORIENTATION_270_DEGREES = 8;
/**
diff --git a/src/java/org/apache/fop/afp/modca/TagLogicalElement.java b/src/java/org/apache/fop/afp/modca/TagLogicalElement.java
index 12cb427ef..ab2c52143 100644
--- a/src/java/org/apache/fop/afp/modca/TagLogicalElement.java
+++ b/src/java/org/apache/fop/afp/modca/TagLogicalElement.java
@@ -102,11 +102,11 @@ public class TagLogicalElement extends AbstractTripletStructuredObject {
FullyQualifiedNameTriplet.FORMAT_CHARSTR,
name);
setAttributeValue(value);
- setAttributeQualifier(tleID, 1);
-
+ setAttributeQualifier(tleID, 1);
+
byte[] data = new byte[SF_HEADER.length];
copySF(data, Type.ATTRIBUTE, Category.PROCESS_ELEMENT);
-
+
int tripletDataLength = getTripletDataLength();
byte[] l = BinaryUtils.convert(data.length + tripletDataLength - 1, 2);
data[1] = l[0];
diff --git a/src/java/org/apache/fop/afp/modca/TagLogicalElementBean.java b/src/java/org/apache/fop/afp/modca/TagLogicalElementBean.java
index 5d4523777..923a5d590 100644
--- a/src/java/org/apache/fop/afp/modca/TagLogicalElementBean.java
+++ b/src/java/org/apache/fop/afp/modca/TagLogicalElementBean.java
@@ -34,7 +34,7 @@ public class TagLogicalElementBean {
/**
* Constructor for the TagLogicalElementBean.
- *
+ *
* @param key the key attribute
* @param value the value attribute
*/
@@ -45,7 +45,7 @@ public class TagLogicalElementBean {
/**
* Getter for the key attribute.
- *
+ *
* @return the key
*/
public String getKey() {
@@ -54,7 +54,7 @@ public class TagLogicalElementBean {
/**
* Getter for the value attribute.
- *
+ *
* @return the value
*/
public String getValue() {
diff --git a/src/java/org/apache/fop/afp/modca/triplets/CommentTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/CommentTriplet.java
index 9b15de8c1..ee48f86be 100644
--- a/src/java/org/apache/fop/afp/modca/triplets/CommentTriplet.java
+++ b/src/java/org/apache/fop/afp/modca/triplets/CommentTriplet.java
@@ -31,6 +31,11 @@ public class CommentTriplet extends AbstractTriplet {
private final String commentString;
+ /**
+ * Construct a triplet.
+ * @param id the triplet identification number
+ * @param commentString a comment
+ */
public CommentTriplet(byte id, String commentString) {
super(id);
this.commentString = commentString;
diff --git a/src/java/org/apache/fop/afp/modca/triplets/ObjectClassificationTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/ObjectClassificationTriplet.java
index 8430a47ee..df5d7553d 100644
--- a/src/java/org/apache/fop/afp/modca/triplets/ObjectClassificationTriplet.java
+++ b/src/java/org/apache/fop/afp/modca/triplets/ObjectClassificationTriplet.java
@@ -182,7 +182,8 @@ public class ObjectClassificationTriplet extends AbstractTriplet {
data[5] = 0x00; // reserved (must be zero)
// StrucFlgs - Information on the structure of the object container
- byte[] structureFlagsBytes = getStructureFlagsAsBytes(dataInContainer, containerHasOEG, dataInOCD);
+ byte[] structureFlagsBytes
+ = getStructureFlagsAsBytes(dataInContainer, containerHasOEG, dataInOCD);
data[6] = structureFlagsBytes[0];
data[7] = structureFlagsBytes[1];
diff --git a/src/java/org/apache/fop/afp/modca/triplets/Triplet.java b/src/java/org/apache/fop/afp/modca/triplets/Triplet.java
index 726727e3e..7234645f8 100644
--- a/src/java/org/apache/fop/afp/modca/triplets/Triplet.java
+++ b/src/java/org/apache/fop/afp/modca/triplets/Triplet.java
@@ -22,64 +22,123 @@ package org.apache.fop.afp.modca.triplets;
import org.apache.fop.afp.Streamable;
import org.apache.fop.afp.StructuredData;
+/**
+ * Triplet interface.
+ */
public interface Triplet extends Streamable, StructuredData {
+
+ /** maximum length */
int MAX_LENGTH = 254;
+ /** CODED_GRAPHIC_CHARACTER_SET_GLOBAL_IDENTIFIER identifier */
byte CODED_GRAPHIC_CHARACTER_SET_GLOBAL_IDENTIFIER = 0x01;
- /** Triplet identifiers */
+ /** FULLY_QUALIFIED_NAME triplet identifier */
byte FULLY_QUALIFIED_NAME = 0x02;
+ /** MAPPING_OPTION triplet identifier */
byte MAPPING_OPTION = 0x04;
+ /** OBJECT_CLASSIFICATION triplet identifier */
byte OBJECT_CLASSIFICATION = 0x10;
+ /** MODCA_INTERCHANGE_SET triplet identifier */
byte MODCA_INTERCHANGE_SET = 0x18;
+ /** FONT_DESCRIPTOR_SPECIFICATION triplet identifier */
byte FONT_DESCRIPTOR_SPECIFICATION = 0x1F;
+ /** OBJECT_FUNCTION_SET_SPECIFICATION triplet identifier */
byte OBJECT_FUNCTION_SET_SPECIFICATION = 0x21;
+ /** EXTENDED_RESOURCE_LOCAL_IDENTIFIER triplet identifier */
byte EXTENDED_RESOURCE_LOCAL_IDENTIFIER = 0x22;
+ /** RESOURCE_LOCAL_IDENTIFIER triplet identifier */
byte RESOURCE_LOCAL_IDENTIFIER = 0x24;
+ /** RESOURCE_SECTION_NUMBER triplet identifier */
byte RESOURCE_SECTION_NUMBER = 0x25;
+ /** CHARACTER_ROTATION triplet identifier */
byte CHARACTER_ROTATION = 0x26;
+ /** OBJECT_BYTE_OFFSET triplet identifier */
byte OBJECT_BYTE_OFFSET = 0x2D;
+ /** ATTRIBUTE_VALUE triplet identifier */
byte ATTRIBUTE_VALUE = 0x36;
+ /** DESCRIPTOR_POSITION triplet identifier */
byte DESCRIPTOR_POSITION = 0x43;
+ /** MEDIA_EJECT_CONTROL triplet identifier */
byte MEDIA_EJECT_CONTROL = 0x45;
+ /** PAGE_OVERLAY_CONDITIONAL_PROCESSING triplet identifier */
byte PAGE_OVERLAY_CONDITIONAL_PROCESSING = 0x46;
+ /** RESOURCE_USAGE_ATTRIBUTE triplet identifier */
byte RESOURCE_USAGE_ATTRIBUTE = 0x47;
+ /** MEASUREMENT_UNITS triplet identifier */
byte MEASUREMENT_UNITS = 0x4B;
+ /** OBJECT_AREA_SIZE triplet identifier */
byte OBJECT_AREA_SIZE = 0x4C;
+ /** AREA_DEFINITION triplet identifier */
byte AREA_DEFINITION = 0x4D;
+ /** COLOR_SPECIFICATION triplet identifier */
byte COLOR_SPECIFICATION = 0x4E;
+ /** ENCODING_SCHEME_ID triplet identifier */
byte ENCODING_SCHEME_ID = 0x50;
+ /** MEDIUM_MAP_PAGE_NUMBER triplet identifier */
byte MEDIUM_MAP_PAGE_NUMBER = 0x56;
+ /** OBJECT_BYTE_EXTENT triplet identifier */
byte OBJECT_BYTE_EXTENT = 0x57;
+ /** OBJECT_STRUCTURED_FIELD_OFFSET triplet identifier */
byte OBJECT_STRUCTURED_FIELD_OFFSET = 0x58;
+ /** OBJECT_STRUCTURED_FIELD_EXTENT triplet identifier */
byte OBJECT_STRUCTURED_FIELD_EXTENT = 0x59;
+ /** OBJECT_OFFSET triplet identifier */
byte OBJECT_OFFSET = 0x5A;
+ /** FONT_HORIZONTAL_SCALE_FACTOR triplet identifier */
byte FONT_HORIZONTAL_SCALE_FACTOR = 0x5D;
+ /** OBJECT_COUNT triplet identifier */
byte OBJECT_COUNT = 0x5E;
+ /** OBJECT_DATE_AND_TIMESTAMP triplet identifier */
byte OBJECT_DATE_AND_TIMESTAMP = 0x62;
+ /** COMMENT triplet identifier */
byte COMMENT = 0x65;
+ /** MEDIUM_ORIENTATION triplet identifier */
byte MEDIUM_ORIENTATION = 0x68;
+ /** RESOURCE_OBJECT_INCLUDE triplet identifier */
byte RESOURCE_OBJECT_INCLUDE = 0x6C;
+ /** PRESENTATION_SPACE_RESET_MIXING triplet identifier */
byte PRESENTATION_SPACE_RESET_MIXING = 0x70;
+ /** PRESENTATION_SPACE_MIXING_RULE triplet identifier */
byte PRESENTATION_SPACE_MIXING_RULE = 0x71;
+ /** UNIVERSAL_DATE_AND_TIMESTAMP triplet identifier */
byte UNIVERSAL_DATE_AND_TIMESTAMP = 0x72;
+ /** TONER_SAVER triplet identifier */
byte TONER_SAVER = 0x74;
+ /** COLOR_FIDELITY triplet identifier */
byte COLOR_FIDELITY = 0x75;
+ /** FONT_FIDELITY triplet identifier */
byte FONT_FIDELITY = 0x78;
+ /** ATTRIBUTE_QUALIFIER triplet identifier */
byte ATTRIBUTE_QUALIFIER = (byte)0x80;
+ /** PAGE_POSITION_INFORMATION triplet identifier */
byte PAGE_POSITION_INFORMATION = (byte)0x81;
+ /** PARAMETER_VALUE triplet identifier */
byte PARAMETER_VALUE = (byte)0x82;
+ /** PRESENTATION_CONTROL triplet identifier */
byte PRESENTATION_CONTROL = (byte)0x83;
+ /** FONT_RESOLUTION_AND_METRIC_TECHNOLOGY triplet identifier */
byte FONT_RESOLUTION_AND_METRIC_TECHNOLOGY = (byte)0x84;
+ /** FINISHING_OPERATION triplet identifier */
byte FINISHING_OPERATION = (byte)0x85;
+ /** TEXT_FIDELITY triplet identifier */
byte TEXT_FIDELITY = (byte)0x86;
+ /** MEDIA_FIDELITY triplet identifier */
byte MEDIA_FIDELITY = (byte)0x87;
+ /** FINISHING_FIDELITY triplet identifier */
byte FINISHING_FIDELITY = (byte)0x88;
+ /** DATA_OBJECT_FONT_DESCRIPTOR triplet identifier */
byte DATA_OBJECT_FONT_DESCRIPTOR = (byte)0x8B;
+ /** LOCALE_SELECTOR triplet identifier */
byte LOCALE_SELECTOR = (byte)0x8C;
+ /** UP3I_FINISHING_OPERATION triplet identifier */
byte UP3I_FINISHING_OPERATION = (byte)0x8E;
+ /** COLOR_MANAGEMENT_RESOURCE_DESCRIPTOR triplet identifier */
byte COLOR_MANAGEMENT_RESOURCE_DESCRIPTOR = (byte)0x91;
+ /** RENDERING_INTENT triplet identifier */
byte RENDERING_INTENT = (byte)0x95;
+ /** CMR_TAG_FIDELITY triplet identifier */
byte CMR_TAG_FIDELITY = (byte)0x96;
+ /** DEVICE_APPEARANCE triplet identifier */
byte DEVICE_APPEARANCE = (byte)0x97;
}
diff --git a/src/java/org/apache/fop/afp/parser/MODCAParser.java b/src/java/org/apache/fop/afp/parser/MODCAParser.java
new file mode 100644
index 000000000..356d4f169
--- /dev/null
+++ b/src/java/org/apache/fop/afp/parser/MODCAParser.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.afp.parser;
+
+import java.io.DataInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * An simple MO:DCA/AFP parser.
+ */
+public class MODCAParser {
+
+ /** The carriage control character (0x5A) used to indicate the start of a structured field. */
+ public static final byte CARRIAGE_CONTROL_CHAR = (byte)(0x5A & 0xFF);
+
+ private DataInputStream din;
+
+ /**
+ * Main constructor
+ * @param in the {@link InputStream} to read the AFP file from.
+ */
+ public MODCAParser(InputStream in) {
+ if (!in.markSupported()) {
+ in = new java.io.BufferedInputStream(in);
+ }
+ this.din = new DataInputStream(in);
+ }
+
+ /**
+ * Returns the {@link DataInputStream} used for parsing structured fields.
+ * @return the data input stream
+ */
+ public DataInputStream getDataInputStream() {
+ return this.din;
+ }
+
+ /**
+ * Reads the next structured field from the input stream.
+ * <p>
+ * No structure validation of the MO:DCA file is performed.
+ * @return a new unparsed structured field (or null when parsing is finished).
+ * @throws IOException if an I/O error occurs
+ */
+ public UnparsedStructuredField readNextStructuredField() throws IOException {
+ try {
+ while (true) {
+ byte b = din.readByte(); //Skip 0x5A character if necessary (ex. AFP)
+ if (b == 0x0D || b == 0x0A) {
+ //CR and LF may be used as field delimiters
+ continue;
+ } else if (b == CARRIAGE_CONTROL_CHAR) {
+ break; //Signals the start of a new structured field
+ }
+ }
+ } catch (EOFException eof) {
+ return null;
+ }
+ return UnparsedStructuredField.readStructuredField(getDataInputStream());
+ }
+
+}
diff --git a/src/java/org/apache/fop/afp/parser/UnparsedStructuredField.java b/src/java/org/apache/fop/afp/parser/UnparsedStructuredField.java
new file mode 100644
index 000000000..f775c05ee
--- /dev/null
+++ b/src/java/org/apache/fop/afp/parser/UnparsedStructuredField.java
@@ -0,0 +1,355 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.afp.parser;
+
+import java.io.DataInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.text.DecimalFormat;
+
+import org.apache.commons.io.HexDump;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Represents an unparsed (generic) AFP structured field.
+ */
+public class UnparsedStructuredField {
+
+ private static final Log LOG = LogFactory.getLog(UnparsedStructuredField.class);
+
+ private static final int INTRODUCER_LENGTH = 8;
+
+ private short sfLength;
+ private byte sfClassCode;
+ private byte sfTypeCode;
+ private byte sfCategoryCode;
+ private boolean sfiExtensionPresent;
+ private boolean sfiSegmentedData;
+ private boolean sfiPaddingPresent;
+ private short extLength;
+ private byte[] introducerData;
+ private byte[] extData;
+ private byte[] data;
+
+ /**
+ * Default constructor.
+ */
+ public UnparsedStructuredField() {
+ //nop
+ }
+
+ /**
+ * Reads a structured field from a {@link DataInputStream}. The resulting object can be
+ * further interpreted be follow-up code.
+ * @param din the stream to read from
+ * @return the generic structured field
+ * @throws IOException if an I/O error occurs
+ */
+ public static UnparsedStructuredField readStructuredField(DataInputStream din)
+ throws IOException {
+ UnparsedStructuredField sf = new UnparsedStructuredField();
+
+ //Read introducer as byte array to preserve any data not parsed below
+ din.mark(INTRODUCER_LENGTH);
+ sf.introducerData = new byte[INTRODUCER_LENGTH]; //Length of introducer
+ din.readFully(sf.introducerData);
+ din.reset();
+
+ //Parse the introducer
+ short len;
+ try {
+ len = din.readShort();
+ } catch (EOFException eof) {
+ return null;
+ }
+ sf.sfLength = len;
+ sf.sfClassCode = din.readByte();
+ sf.sfTypeCode = din.readByte();
+ sf.sfCategoryCode = din.readByte();
+
+ //Flags
+ byte f = din.readByte();
+ sf.sfiExtensionPresent = (f & 0x01) != 0;
+ sf.sfiSegmentedData = (f & 0x04) != 0;
+ sf.sfiPaddingPresent = (f & 0x10) != 0;
+ din.skip(2); //Reserved
+
+ int dataLength = sf.sfLength - INTRODUCER_LENGTH;
+
+ //Handle optional extension
+ if (sf.sfiExtensionPresent) {
+ sf.extLength = (short)(((short)din.readByte()) & 0xFF);
+ if (sf.extLength > 0) {
+ sf.extData = new byte[sf.extLength - 1];
+ din.readFully(sf.extData);
+ dataLength -= sf.extLength;
+ }
+ }
+
+ //Read payload
+ sf.data = new byte[dataLength];
+ din.readFully(sf.data);
+
+ if (LOG.isTraceEnabled()) {
+ LOG.trace(sf);
+ }
+
+ return sf;
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ StringBuffer sb = new StringBuffer("Structured Field: ");
+ sb.append(Integer.toHexString(getSfTypeID()).toUpperCase());
+ sb.append(", len=");
+ sb.append(new DecimalFormat("00000").format(getSfLength()));
+ sb.append(" ").append(getTypeCodeAsString());
+ sb.append(" ").append(getCategoryCodeAsString());
+ if (isSfiExtensionPresent()) {
+ sb.append(", SFI extension present");
+ }
+ if (isSfiSegmentedData()) {
+ sb.append(", segmented data");
+ }
+ if (isSfiPaddingPresent()) {
+ sb.append(", with padding");
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Dump the structured field as hex data to the given {@link PrintStream}.
+ * @param out the {@link PrintStream} to dump to
+ * @throws IOException if an I/O error occurs
+ */
+ public void dump(PrintStream out) throws IOException {
+ out.println(toString());
+ HexDump.dump(getData(), 0, out, 0);
+ }
+
+ /**
+ * Dump the structured field as hex data to <code>System.out</code>.
+ * @throws IOException if an I/O error occurs
+ */
+ public void dump() throws IOException {
+ dump(System.out);
+ }
+
+ /**
+ * Returns type code function name for this field.
+ * @return the type code function name
+ */
+ public String getTypeCodeAsString() {
+ switch ((int)getSfTypeCode() & 0xFF) {
+ case 0xA0: return "Attribute";
+ case 0xA2: return "CopyCount";
+ case 0xA6: return "Descriptor";
+ case 0xA7: return "Control";
+ case 0xA8: return "Begin";
+ case 0xA9: return "End";
+ case 0xAB: return "Map";
+ case 0xAC: return "Position";
+ case 0xAD: return "Process";
+ case 0xAF: return "Include";
+ case 0xB0: return "Table";
+ case 0xB1: return "Migration";
+ case 0xB2: return "Variable";
+ case 0xB4: return "Link";
+ case 0xEE: return "Data";
+ default: return "Unknown:" + Integer.toHexString((int)getSfTypeCode()).toUpperCase();
+ }
+ }
+
+ /**
+ * Returns category code function name for this field.
+ * @return the category code function name
+ */
+ public String getCategoryCodeAsString() {
+ switch ((int)getSfCategoryCode() & 0xFF) {
+ case 0x5F: return "Page Segment";
+ case 0x6B: return "Object Area";
+ case 0x77: return "Color Attribute Table";
+ case 0x7B: return "IM Image";
+ case 0x88: return "Medium";
+ case 0x89: return "Font";
+ case 0x8A: return "Coded Font";
+ case 0x90: return "Process Element";
+ case 0x92: return "Object Container";
+ case 0x9B: return "Presentation Text";
+ case 0xA7: return "Index";
+ case 0xA8: return "Document";
+ case 0xAD: return "Page Group";
+ case 0xAF: return "Page";
+ case 0xBB: return "Graphics";
+ case 0xC3: return "Data Resource";
+ case 0xC4: return "Document Environment Group (DEG)";
+ case 0xC6: return "Resource Group";
+ case 0xC7: return "Object Environment Group (OEG)";
+ case 0xC9: return "Active Environment Group (AEG)";
+ case 0xCC: return "Medium Map";
+ case 0xCD: return "Form Map";
+ case 0xCE: return "Name Resource";
+ case 0xD8: return "Page Overlay";
+ case 0xD9: return "Resource Environment Group (REG)";
+ case 0xDF: return "Overlay";
+ case 0xEA: return "Data Supression";
+ case 0xEB: return "Bar Code";
+ case 0xEE: return "No Operation";
+ case 0xFB: return "Image";
+ default: return "Unknown:" + Integer.toHexString((int)getSfTypeCode()).toUpperCase();
+ }
+ }
+
+ /**
+ * Returns the structured field's length.
+ * @return the field length
+ */
+ public short getSfLength() {
+ return this.sfLength;
+ }
+
+ /**
+ * Returns the structured field's identifier.
+ * @return the field identifier
+ */
+ public int getSfTypeID() {
+ return ((getSfClassCode() & 0xFF) << 16)
+ | ((getSfTypeCode() & 0xFF) << 8)
+ | (getSfCategoryCode() & 0xFF);
+ }
+
+ /**
+ * Returns the structured field's class code.
+ * @return the field class code
+ */
+ public byte getSfClassCode() {
+ return this.sfClassCode;
+ }
+
+ /**
+ * Returns the structured field's type code.
+ * @return the type code
+ */
+ public byte getSfTypeCode() {
+ return this.sfTypeCode;
+ }
+
+ /**
+ * Returns the structured field's category code.
+ * @return the sfCategoryCode
+ */
+ public byte getSfCategoryCode() {
+ return this.sfCategoryCode;
+ }
+
+ /**
+ * Indicates whether an field introducer extension is present.
+ * @return true if an field introducer extension is present
+ */
+ public boolean isSfiExtensionPresent() {
+ return this.sfiExtensionPresent && (this.extData != null);
+ }
+
+ /**
+ * Indicates whether segmented data is present.
+ * @return true if the data is segmented
+ */
+ public boolean isSfiSegmentedData() {
+ return this.sfiSegmentedData;
+ }
+
+ /**
+ * Indicates whether the data is padded.
+ * @return true if the data is padded
+ */
+ public boolean isSfiPaddingPresent() {
+ return this.sfiPaddingPresent;
+ }
+
+ /**
+ * Returns the length of the extension if present.
+ * @return the length of the extension (or 0 if no extension is present)
+ */
+ public short getExtLength() {
+ return this.extLength;
+ }
+
+ /**
+ * Returns the extension data if present.
+ * @return the extension data (or null if no extension is present)
+ */
+ public byte[] getExtData() {
+ return this.extData;
+ }
+
+ /**
+ * Returns the structured field's payload.
+ * @return the field's data
+ */
+ public byte[] getData() {
+ return this.data;
+ }
+
+ /**
+ * Returns the structured field's introducer data.
+ * @return the introducer data
+ */
+ public byte[] getIntroducerData() {
+ return this.introducerData;
+ }
+
+ /**
+ * Returns the complete structured field as a byte array.
+ * @return the complete field data
+ */
+ public byte[] getCompleteFieldAsBytes() {
+ int len = INTRODUCER_LENGTH;
+ if (isSfiExtensionPresent()) {
+ len += getExtLength();
+ }
+ len += getData().length;
+ byte[] bytes = new byte[len];
+ int pos = 0;
+ System.arraycopy(getIntroducerData(), 0, bytes, pos, INTRODUCER_LENGTH);
+ pos += INTRODUCER_LENGTH;
+ if (isSfiExtensionPresent()) {
+ System.arraycopy(getExtData(), 0, bytes, pos, getExtLength());
+ pos += getExtLength();
+ }
+ System.arraycopy(getData(), 0, bytes, pos, getData().length);
+ return bytes;
+ }
+
+ /**
+ * Writes this structured field to the given {@link OutputStream}.
+ * @param out the output stream
+ * @throws IOException if an I/O error occurs
+ */
+ public void writeTo(OutputStream out) throws IOException {
+ out.write(this.introducerData);
+ if (isSfiExtensionPresent()) {
+ out.write(this.extData);
+ }
+ out.write(this.data);
+ }
+}
diff --git a/src/java/org/apache/fop/afp/ptoca/LineDataInfoProducer.java b/src/java/org/apache/fop/afp/ptoca/LineDataInfoProducer.java
index c702d72a8..cf00674fb 100644
--- a/src/java/org/apache/fop/afp/ptoca/LineDataInfoProducer.java
+++ b/src/java/org/apache/fop/afp/ptoca/LineDataInfoProducer.java
@@ -32,7 +32,7 @@ import org.apache.fop.afp.AFPLineDataInfo;
public class LineDataInfoProducer implements PtocaProducer, PtocaConstants {
/** Static logging instance */
- private static final Log log = LogFactory.getLog(LineDataInfoProducer.class);
+ private static final Log LOG = LogFactory.getLog(LineDataInfoProducer.class);
private AFPLineDataInfo lineDataInfo;
@@ -61,7 +61,7 @@ public class LineDataInfoProducer implements PtocaProducer, PtocaConstants {
} else if (x1 == x2) {
builder.drawBaxisRule(y2 - y1, thickness);
} else {
- log.error("Invalid axis rule: unable to draw line");
+ LOG.error("Invalid axis rule: unable to draw line");
return;
}
}
diff --git a/src/java/org/apache/fop/afp/svg/AFPBridgeContext.java b/src/java/org/apache/fop/afp/svg/AFPBridgeContext.java
index 48c1001ef..883414fda 100644
--- a/src/java/org/apache/fop/afp/svg/AFPBridgeContext.java
+++ b/src/java/org/apache/fop/afp/svg/AFPBridgeContext.java
@@ -60,22 +60,21 @@ public class AFPBridgeContext extends AbstractFOPBridgeContext {
/**
* Constructs a new bridge context.
* @param userAgent the user agent
- * @param loader the Document Loader to use for referenced documents.
+ * @param documentLoader the Document Loader to use for referenced documents.
* @param fontInfo the font list for the text painter, may be null
* in which case text is painted as shapes
- * @param linkTransform AffineTransform to properly place links,
- * may be null
* @param imageManager an image manager
* @param imageSessionContext an image session context
* @param linkTransform AffineTransform to properly place links,
* may be null
- * @param an AFPGraphics 2D implementation
+ * @param g2d an AFPGraphics 2D implementation
*/
public AFPBridgeContext(UserAgent userAgent, DocumentLoader documentLoader,
FontInfo fontInfo, ImageManager imageManager,
ImageSessionContext imageSessionContext,
AffineTransform linkTransform, AFPGraphics2D g2d) {
- super(userAgent, documentLoader, fontInfo, imageManager, imageSessionContext, linkTransform);
+ super(userAgent, documentLoader, fontInfo, imageManager,
+ imageSessionContext, linkTransform);
this.g2d = g2d;
}
diff --git a/src/java/org/apache/fop/afp/svg/AFPGraphicsConfiguration.java b/src/java/org/apache/fop/afp/svg/AFPGraphicsConfiguration.java
index 832397ea6..0a051e675 100644
--- a/src/java/org/apache/fop/afp/svg/AFPGraphicsConfiguration.java
+++ b/src/java/org/apache/fop/afp/svg/AFPGraphicsConfiguration.java
@@ -109,7 +109,8 @@ public class AFPGraphicsConfiguration extends GraphicsConfiguration {
}
}
- private static final Log log = LogFactory.getLog(AFPGraphicsConfiguration.class);
+ private static final Log LOG
+ = LogFactory.getLog(AFPGraphicsConfiguration.class);
private AffineTransform defaultTransform = null;
private AffineTransform normalizingTransform = null;
@@ -121,7 +122,7 @@ public class AFPGraphicsConfiguration extends GraphicsConfiguration {
* @return the default transform for the configuration
*/
public AffineTransform getDefaultTransform() {
- log.debug("getDefaultTransform()");
+ LOG.debug("getDefaultTransform()");
if (defaultTransform == null) {
defaultTransform = new AffineTransform();
}
@@ -136,7 +137,7 @@ public class AFPGraphicsConfiguration extends GraphicsConfiguration {
* @return the normalizing transform for the configuration
*/
public AffineTransform getNormalizingTransform() {
- log.debug("getNormalizingTransform()");
+ LOG.debug("getNormalizingTransform()");
if (normalizingTransform == null) {
normalizingTransform = new AffineTransform(2, 0, 0, 2, 0, 0);
}
@@ -145,7 +146,7 @@ public class AFPGraphicsConfiguration extends GraphicsConfiguration {
/** {@inheritDoc} */
public GraphicsDevice getDevice() {
- log.debug("getDevice()");
+ LOG.debug("getDevice()");
return graphicsDevice;
}
}
diff --git a/src/java/org/apache/fop/afp/svg/AFPTextHandler.java b/src/java/org/apache/fop/afp/svg/AFPTextHandler.java
index b7393a3b2..13a32ee78 100644
--- a/src/java/org/apache/fop/afp/svg/AFPTextHandler.java
+++ b/src/java/org/apache/fop/afp/svg/AFPTextHandler.java
@@ -21,7 +21,6 @@ package org.apache.fop.afp.svg;
import java.awt.Color;
import java.awt.Graphics2D;
-import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -34,13 +33,13 @@ import org.apache.fop.afp.fonts.AFPPageFonts;
import org.apache.fop.afp.modca.GraphicsObject;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
-import org.apache.fop.svg.FOPTextHandler;
+import org.apache.fop.svg.FOPTextHandlerAdapter;
/**
* Specialized TextHandler implementation that the AFPGraphics2D class delegates to to paint text
* using AFP GOCA text operations.
*/
-public class AFPTextHandler implements FOPTextHandler {
+public class AFPTextHandler extends FOPTextHandlerAdapter {
/** logging instance */
private static Log log = LogFactory.getLog(AFPTextHandler.class);
@@ -73,7 +72,6 @@ public class AFPTextHandler implements FOPTextHandler {
* Registers a page font
*
* @param internalFontName the internal font name
- * @param internalFontName the internal font name
* @param fontSize the font size
* @return a font reference
*/
@@ -88,19 +86,13 @@ public class AFPTextHandler implements FOPTextHandler {
return afpFontAttributes.getFontReference();
}
- /** {@inheritDoc} */
- public void drawString(String text, float x, float y) throws IOException {
- // TODO Remove me after removing the deprecated method in TextHandler.
- throw new UnsupportedOperationException("Deprecated method!");
- }
-
/**
* Add a text string to the current data object of the AFP datastream.
* The text is painted using text operations.
*
* {@inheritDoc}
*/
- public void drawString(Graphics2D g, String str, float x, float y) throws IOException {
+ public void drawString(Graphics2D g, String str, float x, float y) {
if (log.isDebugEnabled()) {
log.debug("drawString() str=" + str + ", x=" + x + ", y=" + y);
}
diff --git a/src/java/org/apache/fop/afp/svg/AFPTextPainter.java b/src/java/org/apache/fop/afp/svg/AFPTextPainter.java
index 3bf4983bb..3815c9eae 100644
--- a/src/java/org/apache/fop/afp/svg/AFPTextPainter.java
+++ b/src/java/org/apache/fop/afp/svg/AFPTextPainter.java
@@ -26,7 +26,7 @@ import org.apache.fop.svg.AbstractFOPTextPainter;
import org.apache.fop.svg.FOPTextHandler;
/**
- * Renders the attributed character iterator of a {@link TextNode}.
+ * Renders the attributed character iterator of some text.
* This class draws the text directly into the AFPGraphics2D so that
* the text is not drawn using shapes.
* If the text is simple enough to draw then it sets the font and calls
diff --git a/src/java/org/apache/fop/afp/util/AFPResourceUtil.java b/src/java/org/apache/fop/afp/util/AFPResourceUtil.java
new file mode 100644
index 000000000..ebb318046
--- /dev/null
+++ b/src/java/org/apache/fop/afp/util/AFPResourceUtil.java
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.afp.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Collection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.afp.AFPConstants;
+import org.apache.fop.afp.modca.ResourceObject;
+import org.apache.fop.afp.modca.AbstractAFPObject.Category;
+import org.apache.fop.afp.parser.MODCAParser;
+import org.apache.fop.afp.parser.UnparsedStructuredField;
+
+/**
+ * TODO better docs
+ * Utility for AFP resource handling
+ *
+ *
+ * A utility class to read structured fields from a MO:DCA document. Each
+ * component of a mixed object document is explicitly defined and delimited
+ * in the data. This is accomplished through the use of MO:DCA data structures,
+ * called structured fields. Structured fields are used to envelop document
+ * components and to provide commands and information to applications using
+ * the data. Structured fields may contain one or more parameters. Each
+ * parameter provides one value from a set of values defined by the architecture.
+ * <p/>
+ * MO:DCA structured fields consist of two parts: an introducer that identifies
+ * the length and type of the structured field, and data that provides the
+ * structured field's effect. The data is contained in a set of parameters,
+ * which can consist of other data structures and data elements. The maximum
+ * length of a structured field is 32767 bytes.
+ * <p/>
+ */
+public final class AFPResourceUtil {
+
+ private static final byte TYPE_CODE_BEGIN = (byte)(0xA8 & 0xFF);
+ private static final byte TYPE_CODE_END = (byte)(0xA9 & 0xFF);
+
+ private static final Log LOG = LogFactory.getLog(AFPResourceUtil.class);
+
+ private AFPResourceUtil() {
+ //nop
+ }
+
+ /**
+ * Get the next structured field as identified by the identifier
+ * parameter (this must be a valid MO:DCA structured field).
+ * @param identifier the three byte identifier
+ * @param inputStream the inputStream
+ * @throws IOException if an I/O exception occurred
+ * @return the next structured field or null when there are no more
+ */
+ public static byte[] getNext(byte[] identifier, InputStream inputStream) throws IOException {
+ MODCAParser parser = new MODCAParser(inputStream);
+ while (true) {
+ UnparsedStructuredField field = parser.readNextStructuredField();
+ if (field == null) {
+ return null;
+ }
+ if (field.getSfClassCode() == identifier[0]
+ && field.getSfTypeCode() == identifier[1]
+ && field.getSfCategoryCode() == identifier[2]) {
+ return field.getCompleteFieldAsBytes();
+ }
+ }
+ }
+
+ private static String getResourceName(UnparsedStructuredField field)
+ throws UnsupportedEncodingException {
+ //The first 8 bytes of the field data represent the resource name
+ byte[] nameBytes = new byte[8];
+ System.arraycopy(field.getData(), 0, nameBytes, 0, 8);
+ String asciiName;
+ asciiName = new String(nameBytes, AFPConstants.EBCIDIC_ENCODING);
+ return asciiName;
+ }
+
+ /**
+ * Copy a complete resource file to a given {@link OutputStream}.
+ * @param in external resource input
+ * @param out output destination
+ * @throws IOException if an I/O error occurs
+ */
+ public static void copyResourceFile(final InputStream in, OutputStream out)
+ throws IOException {
+ MODCAParser parser = new MODCAParser(in);
+ while (true) {
+ UnparsedStructuredField field = parser.readNextStructuredField();
+ if (field == null) {
+ break;
+ }
+ out.write(MODCAParser.CARRIAGE_CONTROL_CHAR);
+ field.writeTo(out);
+ }
+ }
+
+ /**
+ * Copy a named resource to a given {@link OutputStream}. The MO:DCA fields read from the
+ * {@link InputStream} are scanned for the resource with the given name.
+ * @param name name of structured field
+ * @param in external resource input
+ * @param out output destination
+ * @throws IOException if an I/O error occurs
+ */
+ public static void copyNamedResource(String name,
+ final InputStream in, final OutputStream out) throws IOException {
+ final MODCAParser parser = new MODCAParser(in);
+ Collection resourceNames = new java.util.HashSet();
+
+ //Find matching "Begin" field
+ final UnparsedStructuredField fieldBegin;
+ while (true) {
+ UnparsedStructuredField field = parser.readNextStructuredField();
+ if (field == null) {
+ throw new IOException("Requested resource '" + name
+ + "' not found. Encountered resource names: " + resourceNames);
+ }
+
+ if (field.getSfTypeCode() != TYPE_CODE_BEGIN) { //0xA8=Begin
+ continue; //Not a "Begin" field
+ }
+ String resourceName = getResourceName(field);
+ resourceNames.add(resourceName);
+ if (resourceName.equals(name)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Start of requested structured field found:\n"
+ + field);
+ }
+ fieldBegin = field;
+ break; //Name doesn't match
+ }
+ }
+
+ //Decide whether the resource file has to be wrapped in a resource object
+ boolean wrapInResource;
+ if (fieldBegin.getSfCategoryCode() == Category.PAGE_SEGMENT) {
+ //A naked page segment must be wrapped in a resource object
+ wrapInResource = true;
+ } else if (fieldBegin.getSfCategoryCode() == Category.NAME_RESOURCE) {
+ //A resource object can be copied directly
+ wrapInResource = false;
+ } else {
+ throw new IOException("Cannot handle resource: " + fieldBegin);
+ }
+
+ //Copy structured fields (wrapped or as is)
+ if (wrapInResource) {
+ ResourceObject resourceObject = new ResourceObject(name) {
+ protected void writeContent(OutputStream os) throws IOException {
+ copyStructuredFields(name, fieldBegin, parser, out);
+ }
+ };
+ resourceObject.setType(ResourceObject.TYPE_PAGE_SEGMENT);
+ resourceObject.writeToStream(out);
+ } else {
+ copyStructuredFields(name, fieldBegin, parser, out);
+ }
+ }
+
+ private static void copyStructuredFields(String name, UnparsedStructuredField fieldBegin,
+ MODCAParser parser, OutputStream out) throws IOException {
+ boolean inRequestedResource;
+
+ //The "Begin" field first
+ out.write(MODCAParser.CARRIAGE_CONTROL_CHAR);
+ fieldBegin.writeTo(out);
+ UnparsedStructuredField field;
+
+ //Then the rest of the fields until the corresponding "End" field
+ inRequestedResource = true;
+ do {
+ field = parser.readNextStructuredField();
+ if (field == null) {
+ break; //Unexpected EOF
+ }
+
+ if (field.getSfTypeCode() == TYPE_CODE_END) {
+ String resourceName = getResourceName(field);
+ if (resourceName.equals(name)) {
+ inRequestedResource = false; //Signal end of loop
+ }
+ }
+ out.write(MODCAParser.CARRIAGE_CONTROL_CHAR);
+ field.writeTo(out);
+ } while (inRequestedResource);
+ if (inRequestedResource) {
+ throw new IOException("Ending structured field not found for resource " + name);
+ }
+ }
+
+}
diff --git a/src/java/org/apache/fop/afp/util/BinaryUtils.java b/src/java/org/apache/fop/afp/util/BinaryUtils.java
index 2b2649415..2b4197b36 100644
--- a/src/java/org/apache/fop/afp/util/BinaryUtils.java
+++ b/src/java/org/apache/fop/afp/util/BinaryUtils.java
@@ -27,6 +27,9 @@ import java.io.ByteArrayOutputStream;
*/
public final class BinaryUtils {
+ private BinaryUtils() {
+ }
+
/**
* Convert an int into the corresponding byte array by encoding each
* two hexadecimal digits as a char. This will return a byte array
diff --git a/src/java/org/apache/fop/afp/util/CubicBezierApproximator.java b/src/java/org/apache/fop/afp/util/CubicBezierApproximator.java
index d3ed41c76..e5980c3dd 100644
--- a/src/java/org/apache/fop/afp/util/CubicBezierApproximator.java
+++ b/src/java/org/apache/fop/afp/util/CubicBezierApproximator.java
@@ -29,7 +29,10 @@ import java.awt.geom.Point2D.Double;
* The various techniques are described here:
* http://www.timotheegroleau.com/Flash/articles/cubic_bezier_in_flash.htm
*/
-public class CubicBezierApproximator {
+public final class CubicBezierApproximator {
+
+ private CubicBezierApproximator() {
+ }
/**
* This method will take in an array containing the x and y coordinates of the four control
diff --git a/src/java/org/apache/fop/afp/util/DTDEntityResolver.java b/src/java/org/apache/fop/afp/util/DTDEntityResolver.java
index dcf5ad7d9..b4eb7fc23 100644
--- a/src/java/org/apache/fop/afp/util/DTDEntityResolver.java
+++ b/src/java/org/apache/fop/afp/util/DTDEntityResolver.java
@@ -98,7 +98,7 @@ public class DTDEntityResolver implements EntityResolver {
/**
* Returns the URL of a resource on the classpath
- * @param resourceName the path to the resource relative to the root of the
+ * @param resourcePath the path to the resource relative to the root of the
* classpath.
* @return the URL of the required resource
* @throws FontRuntimeException if the resource could not be found.
diff --git a/src/java/org/apache/fop/afp/util/StringUtils.java b/src/java/org/apache/fop/afp/util/StringUtils.java
index ce68d27be..5014089da 100644
--- a/src/java/org/apache/fop/afp/util/StringUtils.java
+++ b/src/java/org/apache/fop/afp/util/StringUtils.java
@@ -23,7 +23,10 @@ package org.apache.fop.afp.util;
* Library of utility methods useful in dealing with strings.
*
*/
-public class StringUtils {
+public final class StringUtils {
+
+ private StringUtils() {
+ }
/**
* Padds the string to the left with the given character for
diff --git a/src/java/org/apache/fop/afp/util/StructuredFieldReader.java b/src/java/org/apache/fop/afp/util/StructuredFieldReader.java
index 34add3bbe..1fc6d8369 100644
--- a/src/java/org/apache/fop/afp/util/StructuredFieldReader.java
+++ b/src/java/org/apache/fop/afp/util/StructuredFieldReader.java
@@ -54,80 +54,27 @@ public class StructuredFieldReader {
}
/**
- * Get the next structured field as identified by the identifer
- * parameter (this must be a valid MO:DCA structured field.
+ * Get the next structured field as identified by the identifier
+ * parameter (this must be a valid MO:DCA structured field).
+ * Note: The returned data does not include the field length and identifier!
* @param identifier the three byte identifier
* @throws IOException if an I/O exception occurred
* @return the next structured field or null when there are no more
*/
public byte[] getNext(byte[] identifier) throws IOException {
- int bufferPointer = 0;
- byte[] bufferData = new byte[identifier.length + 2];
- for (int x = 0; x < identifier.length; x++) {
- bufferData[x] = 0x00;
- }
-
- int c;
- while ((c = inputStream.read()) > -1) {
-
- bufferData[bufferPointer] = (byte) c;
-
- // Check the last characters in the buffer
- int index = 0;
- boolean found = true;
-
- for (int i = identifier.length - 1; i > -1; i--) {
-
- int p = bufferPointer - index;
- if (p < 0) {
- p = bufferData.length + p;
- }
-
- index++;
-
- if (identifier[i] != bufferData[p]) {
- found = false;
- break;
- }
-
- }
-
- if (found) {
-
- byte[] length = new byte[2];
-
- int a = bufferPointer - identifier.length;
- if (a < 0) {
- a = bufferData.length + a;
- }
-
- int b = bufferPointer - identifier.length - 1;
- if (b < 0) {
- b = bufferData.length + b;
- }
-
- length[0] = bufferData[b];
- length[1] = bufferData[a];
-
- int reclength = ((length[0] & 0xFF) << 8)
- + (length[1] & 0xFF) - identifier.length - 2;
-
- byte[] retval = new byte[reclength];
-
- inputStream.read(retval, 0, reclength);
-
- return retval;
-
- }
-
- bufferPointer++;
- if (bufferPointer >= bufferData.length) {
- bufferPointer = 0;
- }
+ byte[] bytes = AFPResourceUtil.getNext(identifier, this.inputStream);
+ if (bytes != null) {
+ //Users of this class expect the field data without length and identifier
+ int srcPos = 2 + identifier.length;
+ byte[] tmp = new byte[bytes.length - srcPos];
+ System.arraycopy(bytes, srcPos, tmp, 0, tmp.length);
+ bytes = tmp;
}
- return null;
+ return bytes;
+
}
+
}
diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java
index 0a65203cc..071066e04 100644
--- a/src/java/org/apache/fop/apps/FOUserAgent.java
+++ b/src/java/org/apache/fop/apps/FOUserAgent.java
@@ -35,6 +35,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.xmlgraphics.image.loader.ImageContext;
import org.apache.xmlgraphics.image.loader.ImageSessionContext;
import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext;
+import org.apache.xmlgraphics.util.UnitConv;
import org.apache.fop.Version;
import org.apache.fop.accessibility.Accessibility;
@@ -450,7 +451,7 @@ public class FOUserAgent {
* @see #getTargetResolution()
*/
public float getTargetPixelUnitToMillimeter() {
- return 25.4f / this.targetResolution;
+ return UnitConv.IN2MM / this.targetResolution;
}
/** @return the resolution for resolution-dependant output */
diff --git a/src/java/org/apache/fop/apps/FopFactory.java b/src/java/org/apache/fop/apps/FopFactory.java
index 7e97442e6..a85b2d305 100644
--- a/src/java/org/apache/fop/apps/FopFactory.java
+++ b/src/java/org/apache/fop/apps/FopFactory.java
@@ -24,8 +24,11 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
+import java.net.URI;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
import javax.xml.transform.Source;
@@ -41,6 +44,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.xmlgraphics.image.loader.ImageContext;
import org.apache.xmlgraphics.image.loader.ImageManager;
import org.apache.xmlgraphics.java2d.color.RenderingIntent;
+import org.apache.xmlgraphics.util.UnitConv;
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.ElementMappingRegistry;
@@ -110,6 +114,11 @@ public class FopFactory implements ImageContext {
private String hyphenBase = null;
/**
+ * Map of configured names of hyphenation pattern file names: ll_CC => name
+ */
+ private Map/*<String,String>*/ hyphPatNames = null;
+
+ /**
* FOP has the ability, for some FO's, to continue processing even if the
* input XSL violates that FO's content model. This is the default
* behavior for FOP. However, this flag, if set, provides the user the
@@ -411,6 +420,23 @@ public class FopFactory implements ImageContext {
}
/**
+ * @return the hyphPatNames
+ */
+ public Map getHyphPatNames() {
+ return hyphPatNames;
+ }
+
+ /**
+ * @param hyphPatNames the hyphPatNames to set
+ */
+ public void setHyphPatNames(Map hyphPatNames) {
+ if (hyphPatNames == null) {
+ hyphPatNames = new HashMap();
+ }
+ this.hyphPatNames = hyphPatNames;
+ }
+
+ /**
* Sets the URI Resolver. It is used for resolving factory-level URIs like hyphenation
* patterns and as backup for URI resolution performed during a rendering run.
* @param uriResolver the new URI resolver
@@ -521,7 +547,7 @@ public class FopFactory implements ImageContext {
* @see #getSourceResolution()
*/
public float getSourcePixelUnitToMillimeter() {
- return 25.4f / getSourceResolution();
+ return UnitConv.IN2MM / getSourceResolution();
}
/**
@@ -549,7 +575,7 @@ public class FopFactory implements ImageContext {
* @see #getTargetResolution()
*/
public float getTargetPixelUnitToMillimeter() {
- return 25.4f / this.targetResolution;
+ return UnitConv.IN2MM / this.targetResolution;
}
/**
@@ -682,6 +708,15 @@ public class FopFactory implements ImageContext {
}
/**
+ * Set the base URI for the user configuration
+ * Useful for programmatic configurations
+ * @param baseURI the base URI
+ */
+ public void setUserConfigBaseURI(URI baseURI) {
+ config.setBaseURI(baseURI);
+ }
+
+ /**
* Get the user configuration.
* @return the user configuration
*/
diff --git a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java b/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
index 736ae05d8..9de00cd85 100644
--- a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
+++ b/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
@@ -22,6 +22,10 @@ package org.apache.fop.apps;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
import org.xml.sax.SAXException;
@@ -31,11 +35,12 @@ import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.image.GraphicsConstants;
import org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry;
import org.apache.xmlgraphics.image.loader.util.Penalty;
-import org.apache.fop.fonts.FontManager;
import org.apache.fop.fonts.FontManagerConfigurator;
+import org.apache.fop.hyphenation.HyphenationTreeCache;
import org.apache.fop.util.LogUtil;
/**
@@ -59,10 +64,10 @@ public class FopFactoryConfigurator {
public static final String DEFAULT_PAGE_HEIGHT = "11in";
/** Defines the default source resolution (72dpi) for FOP */
- public static final float DEFAULT_SOURCE_RESOLUTION = 72.0f; //dpi
+ public static final float DEFAULT_SOURCE_RESOLUTION = GraphicsConstants.DEFAULT_DPI; //dpi
/** Defines the default target resolution (72dpi) for FOP */
- public static final float DEFAULT_TARGET_RESOLUTION = 72.0f; //dpi
+ public static final float DEFAULT_TARGET_RESOLUTION = GraphicsConstants.DEFAULT_DPI; //dpi
private static final String PREFER_RENDERER = "prefer-renderer";
@@ -75,6 +80,9 @@ public class FopFactoryConfigurator {
/** Fop factory configuration */
private Configuration cfg = null;
+ /** The base URI of the configuration file **/
+ private URI baseURI = null;
+
/**
* Default constructor
* @param factory fop factory
@@ -90,20 +98,7 @@ public class FopFactoryConfigurator {
* @param factory fop factory
* @throws FOPException fop exception
*/
- public void configure(FopFactory factory) throws FOPException {
- if (log.isDebugEnabled()) {
- log.debug("Initializing FopFactory Configuration");
- }
-
- if (cfg.getChild("accessibility", false) != null) {
- try {
- this.factory.setAccessibility(
- cfg.getChild("accessibility").getValueAsBoolean());
- } catch (ConfigurationException e) {
- throw new FOPException(e);
- }
- }
-
+ public void configure(FopFactory factory) throws FOPException { // CSOK: MethodLength
// strict configuration
if (cfg.getChild("strict-configuration", false) != null) {
try {
@@ -114,6 +109,19 @@ public class FopFactoryConfigurator {
}
}
boolean strict = factory.validateUserConfigStrictly();
+ if (log.isDebugEnabled()) {
+ log.debug("Initializing FopFactory Configuration"
+ + "with " + (strict ? "strict" : "permissive") + " validation");
+ }
+
+ if (cfg.getChild("accessibility", false) != null) {
+ try {
+ this.factory.setAccessibility(
+ cfg.getChild("accessibility").getValueAsBoolean());
+ } catch (ConfigurationException e) {
+ LogUtil.handleException(log, e, strict);
+ }
+ }
// strict fo validation
if (cfg.getChild("strict-validation", false) != null) {
@@ -127,22 +135,86 @@ public class FopFactoryConfigurator {
// base definitions for relative path resolution
if (cfg.getChild("base", false) != null) {
+ String path = cfg.getChild("base").getValue(null);
+ if (baseURI != null) {
+ path = baseURI.resolve(path).normalize().toString();
+ }
try {
- factory.setBaseURL(
- cfg.getChild("base").getValue(null));
+ factory.setBaseURL(path);
} catch (MalformedURLException mfue) {
LogUtil.handleException(log, mfue, strict);
}
}
if (cfg.getChild("hyphenation-base", false) != null) {
+ String path = cfg.getChild("hyphenation-base").getValue(null);
+ if (baseURI != null) {
+ path = baseURI.resolve(path).normalize().toString();
+ }
try {
- factory.setHyphenBaseURL(
- cfg.getChild("hyphenation-base").getValue(null));
+ factory.setHyphenBaseURL(path);
} catch (MalformedURLException mfue) {
LogUtil.handleException(log, mfue, strict);
}
}
+ /**
+ * Read configuration elements hyphenation-pattern,
+ * construct a map ll_CC => filename, and set it on the factory
+ */
+ Configuration[] hyphPatConfig = cfg.getChildren("hyphenation-pattern");
+ if (hyphPatConfig.length != 0) {
+ Map/*<String,String>*/ hyphPatNames = new HashMap/*<String,String>*/();
+ for (int i = 0; i < hyphPatConfig.length; ++i) {
+ String lang, country, filename;
+ StringBuffer error = new StringBuffer();
+ String location = hyphPatConfig[i].getLocation();
+
+ lang = hyphPatConfig[i].getAttribute("lang", null);
+ if (lang == null) {
+ addError("The lang attribute of a hyphenation-pattern configuration"
+ + " element must exist (" + location + ")", error);
+ } else if (!lang.matches("[a-zA-Z]{2}")) {
+ addError("The lang attribute of a hyphenation-pattern configuration"
+ + " element must consist of exactly two letters ("
+ + location + ")", error);
+ }
+ lang = lang.toLowerCase();
+
+ country = hyphPatConfig[i].getAttribute("country", null);
+ if ("".equals(country)) {
+ country = null;
+ }
+ if (country != null) {
+ if (!country.matches("[a-zA-Z]{2}")) {
+ addError("The country attribute of a hyphenation-pattern configuration"
+ + " element must consist of exactly two letters ("
+ + location + ")", error);
+ }
+ country = country.toUpperCase();
+ }
+
+ filename = hyphPatConfig[i].getValue(null);
+ if (filename == null) {
+ addError("The value of a hyphenation-pattern configuration"
+ + " element may not be empty (" + location + ")", error);
+ }
+
+ if (error.length() != 0) {
+ LogUtil.handleError(log, error.toString(), strict);
+ continue;
+ }
+
+ String llccKey = HyphenationTreeCache.constructLlccKey(lang, country);
+ hyphPatNames.put(llccKey, filename);
+ if (log.isDebugEnabled()) {
+ log.debug("Using hyphenation pattern filename " + filename
+ + " for lang=\"" + lang + "\""
+ + (country != null ? ", country=\"" + country + "\"" : ""));
+ }
+ }
+ factory.setHyphPatNames(hyphPatNames);
+ }
+
// renderer options
if (cfg.getChild("source-resolution", false) != null) {
factory.setSourceResolution(
@@ -198,14 +270,19 @@ public class FopFactoryConfigurator {
}
// configure font manager
- FontManager fontManager = factory.getFontManager();
- FontManagerConfigurator fontManagerConfigurator = new FontManagerConfigurator(cfg);
- fontManagerConfigurator.configure(fontManager, strict);
+ new FontManagerConfigurator(cfg, baseURI).configure(factory.getFontManager(), strict);
// configure image loader framework
configureImageLoading(cfg.getChild("image-loading", false), strict);
}
+ private static void addError(String message, StringBuffer error) {
+ if (error.length() != 0) {
+ error.append(". ");
+ }
+ error.append(message);
+ }
+
private void configureImageLoading(Configuration parent, boolean strict) throws FOPException {
if (parent == null) {
return;
@@ -273,6 +350,7 @@ public class FopFactoryConfigurator {
*/
public void setUserConfig(Configuration cfg) throws FOPException {
this.cfg = cfg;
+ setBaseURI();
configure(this.factory);
}
@@ -283,4 +361,40 @@ public class FopFactoryConfigurator {
public Configuration getUserConfig() {
return this.cfg;
}
+
+ /**
+ * @return the baseURI
+ */
+ public URI getBaseURI() {
+ return baseURI;
+ }
+
+ /**
+ * @param baseURI the baseURI to set
+ */
+ public void setBaseURI(URI baseURI) {
+ this.baseURI = baseURI;
+ }
+
+ private void setBaseURI() throws FOPException {
+ String loc = cfg.getLocation();
+ String[] locationParts = (loc != null ? cfg.getLocation().split(":") : null);
+ try {
+ if (locationParts != null && locationParts.length >= 2
+ && "file".equals(locationParts[0])) {
+ StringBuilder sb = new StringBuilder(locationParts[1]);
+ for (int idx = 2; idx < locationParts.length; idx++) {
+ sb.append(":").append(locationParts[idx]);
+ }
+ baseURI = new URI(locationParts[0], sb.toString(), null);
+ baseURI = baseURI.resolve(".").normalize();
+ }
+ if (baseURI == null) {
+ baseURI = new File(System.getProperty("user.dir")).toURI();
+ }
+ } catch (URISyntaxException e) {
+ throw new FOPException(e);
+ }
+ }
+
}
diff --git a/src/java/org/apache/fop/area/Area.java b/src/java/org/apache/fop/area/Area.java
index ddf2f5198..f94c68454 100644
--- a/src/java/org/apache/fop/area/Area.java
+++ b/src/java/org/apache/fop/area/Area.java
@@ -38,6 +38,9 @@ import org.apache.fop.traits.BorderProps;
* Base object for all areas.
*/
public class Area extends AreaTreeObject implements Serializable {
+
+ private static final long serialVersionUID = 6342888466142626492L;
+
// stacking directions
/**
* Stacking left to right
@@ -134,7 +137,7 @@ public class Area extends AreaTreeObject implements Serializable {
/**
* logging instance
*/
- protected static Log log = LogFactory.getLog(Area.class);
+ protected static final Log log = LogFactory.getLog(Area.class);
/**
diff --git a/src/java/org/apache/fop/area/AreaEventProducer.java b/src/java/org/apache/fop/area/AreaEventProducer.java
index 325367199..c4f5a7a35 100644
--- a/src/java/org/apache/fop/area/AreaEventProducer.java
+++ b/src/java/org/apache/fop/area/AreaEventProducer.java
@@ -30,7 +30,10 @@ public interface AreaEventProducer extends EventProducer {
/**
* Provider class for the event producer.
*/
- class Provider {
+ static final class Provider {
+
+ private Provider() {
+ }
/**
* Returns an event producer.
diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java
index 298cf263b..87c681ed6 100644
--- a/src/java/org/apache/fop/area/AreaTreeHandler.java
+++ b/src/java/org/apache/fop/area/AreaTreeHandler.java
@@ -305,6 +305,7 @@ public class AreaTreeHandler extends FOEventHandler {
model.handleOffDocumentItem(data);
}
}
+ idTracker.signalIDProcessed(rootFObj.getId());
}
model.endDocument();
diff --git a/src/java/org/apache/fop/area/AreaTreeModel.java b/src/java/org/apache/fop/area/AreaTreeModel.java
index e5f6db17b..8659b4cca 100644
--- a/src/java/org/apache/fop/area/AreaTreeModel.java
+++ b/src/java/org/apache/fop/area/AreaTreeModel.java
@@ -42,7 +42,7 @@ public class AreaTreeModel {
protected PageSequence currentPageSequence;
// private List offDocumentItems = new java.util.ArrayList();
/** logger instance */
- protected static Log log = LogFactory.getLog(AreaTreeModel.class);
+ protected static final Log log = LogFactory.getLog(AreaTreeModel.class);
/**
* Create a new store pages model
diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java
index e41f5e873..ae7c0a7c3 100644
--- a/src/java/org/apache/fop/area/AreaTreeParser.java
+++ b/src/java/org/apache/fop/area/AreaTreeParser.java
@@ -98,7 +98,7 @@ import org.apache.fop.util.XMLUtil;
public class AreaTreeParser {
/** Logger instance */
- protected static Log log = LogFactory.getLog(AreaTreeParser.class);
+ protected static final Log log = LogFactory.getLog(AreaTreeParser.class);
private static SAXTransformerFactory tFactory
= (SAXTransformerFactory)SAXTransformerFactory.newInstance();
@@ -228,8 +228,13 @@ public class AreaTreeParser {
if (areaStack.size() > 0) {
int pos = areaStack.size() - 1;
Object obj = null;
- while (pos >= 0 && !(clazz.isInstance(obj = areaStack.get(pos)))) {
- pos--;
+ while ( pos >= 0 ) {
+ obj = areaStack.get(pos);
+ if ( clazz.isInstance ( obj ) ) {
+ break;
+ } else {
+ pos--;
+ }
}
if (pos >= 0) {
return (Area)obj;
diff --git a/src/java/org/apache/fop/area/BeforeFloat.java b/src/java/org/apache/fop/area/BeforeFloat.java
index 490476368..b64eff556 100644
--- a/src/java/org/apache/fop/area/BeforeFloat.java
+++ b/src/java/org/apache/fop/area/BeforeFloat.java
@@ -25,6 +25,9 @@ package org.apache.fop.area;
* See fo:region-body definition in the XSL Rec for more information.
*/
public class BeforeFloat extends BlockParent {
+
+ private static final long serialVersionUID = 4101415711488333380L;
+
// this is an optional block area that will be rendered
// as the separator only if there are float areas
private Block separator = null;
diff --git a/src/java/org/apache/fop/area/Block.java b/src/java/org/apache/fop/area/Block.java
index 5faec9f7a..423dcfafa 100644
--- a/src/java/org/apache/fop/area/Block.java
+++ b/src/java/org/apache/fop/area/Block.java
@@ -32,6 +32,9 @@ package org.apache.fop.area;
* It holds child block areas such as other blocks or lines.
*/
public class Block extends BlockParent {
+
+ private static final long serialVersionUID = 6843727817993665788L;
+
/**
* Normally stacked with other blocks.
*/
@@ -58,6 +61,7 @@ public class Block extends BlockParent {
private int stacking = TB;
private int positioning = STACK;
+ /** if true, allow BPD update */
protected transient boolean allowBPDUpdate = true;
// a block with may contain the dominant styling info in
@@ -126,7 +130,7 @@ public class Block extends BlockParent {
*/
public int getStartIndent() {
Integer startIndent = (Integer)getTrait(Trait.START_INDENT);
- return (startIndent != null ? startIndent.intValue() : 0);
+ return (startIndent != null ? startIndent : 0);
}
}
diff --git a/src/java/org/apache/fop/area/BlockParent.java b/src/java/org/apache/fop/area/BlockParent.java
index 1be0b785d..18f9056da 100644
--- a/src/java/org/apache/fop/area/BlockParent.java
+++ b/src/java/org/apache/fop/area/BlockParent.java
@@ -27,6 +27,8 @@ import java.util.List;
*/
public class BlockParent extends Area {
+ private static final long serialVersionUID = 7076916890348533805L;
+
// this position is used for absolute position
// or as an indent
// this has the size in the block progression dimension
diff --git a/src/java/org/apache/fop/area/BlockViewport.java b/src/java/org/apache/fop/area/BlockViewport.java
index 60bf1fb22..032b39f95 100644
--- a/src/java/org/apache/fop/area/BlockViewport.java
+++ b/src/java/org/apache/fop/area/BlockViewport.java
@@ -25,6 +25,9 @@ package org.apache.fop.area;
* The block-container creates this area.
*/
public class BlockViewport extends Block {
+
+ private static final long serialVersionUID = -7840580922580735157L;
+
// clipping for this viewport
private boolean clip = false;
// transform if rotated or absolute
diff --git a/src/java/org/apache/fop/area/BodyRegion.java b/src/java/org/apache/fop/area/BodyRegion.java
index 7b183a188..2dd8a9a7c 100644
--- a/src/java/org/apache/fop/area/BodyRegion.java
+++ b/src/java/org/apache/fop/area/BodyRegion.java
@@ -30,6 +30,9 @@ import org.apache.fop.fo.pagination.RegionBody;
* See fo:region-body definition in the XSL Rec for more information.
*/
public class BodyRegion extends RegionReference {
+
+ private static final long serialVersionUID = -1848872997724078080L;
+
private BeforeFloat beforeFloat; // optional
private MainReference mainReference; // mandatory
private Footnote footnote; // optional
diff --git a/src/java/org/apache/fop/area/CTM.java b/src/java/org/apache/fop/area/CTM.java
index 099ab38fa..eb6207c42 100644
--- a/src/java/org/apache/fop/area/CTM.java
+++ b/src/java/org/apache/fop/area/CTM.java
@@ -34,6 +34,8 @@ import org.apache.fop.fo.Constants;
*/
public class CTM implements Serializable {
+ private static final long serialVersionUID = -8743287485623778341L;
+
private double a, b, c, d, e, f;
private static final CTM CTM_LRTB = new CTM(1, 0, 0, 1, 0, 0);
diff --git a/src/java/org/apache/fop/area/DestinationData.java b/src/java/org/apache/fop/area/DestinationData.java
index cb2d6eccb..f8d906b91 100644
--- a/src/java/org/apache/fop/area/DestinationData.java
+++ b/src/java/org/apache/fop/area/DestinationData.java
@@ -98,7 +98,7 @@ public class DestinationData extends AbstractOffDocumentItem implements Resolvab
* object that corresponds to the IDRef
*
* {@inheritDoc} List)
- * @todo check to make sure it works if multiple bookmark-items
+ * TODO check to make sure it works if multiple bookmark-items
* have the same idref
*/
public void resolveIDRef(String id, List pages) {
diff --git a/src/java/org/apache/fop/area/Footnote.java b/src/java/org/apache/fop/area/Footnote.java
index a25f5467e..72b9f2ed0 100644
--- a/src/java/org/apache/fop/area/Footnote.java
+++ b/src/java/org/apache/fop/area/Footnote.java
@@ -27,6 +27,9 @@ package org.apache.fop.area;
* See fo:region-body definition in the XSL Rec for more information.
*/
public class Footnote extends BlockParent {
+
+ private static final long serialVersionUID = -7907428219886367161L;
+
private Block separator = null;
// footnote has an optional separator
diff --git a/src/java/org/apache/fop/area/IDTracker.java b/src/java/org/apache/fop/area/IDTracker.java
index b55ed7983..829c8c58d 100644
--- a/src/java/org/apache/fop/area/IDTracker.java
+++ b/src/java/org/apache/fop/area/IDTracker.java
@@ -34,7 +34,7 @@ import org.apache.commons.logging.LogFactory;
*/
public class IDTracker {
- private static final Log log = LogFactory.getLog(IDTracker.class);
+ private static final Log LOG = LogFactory.getLog(IDTracker.class);
// HashMap of ID's whose area is located on one or more consecutive
// PageViewports. Each ID has an arraylist of PageViewports that
@@ -58,8 +58,8 @@ public class IDTracker {
* @param pv a page viewport that contains the area with this ID
*/
public void associateIDWithPageViewport(String id, PageViewport pv) {
- if (log.isDebugEnabled()) {
- log.debug("associateIDWithPageViewport(" + id + ", " + pv + ")");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("associateIDWithPageViewport(" + id + ", " + pv + ")");
}
List pvList = (List) idLocations.get(id);
if (pvList == null) { // first time ID located
@@ -92,8 +92,8 @@ public class IDTracker {
* @param id the id of the object being processed
*/
public void signalPendingID(String id) {
- if (log.isDebugEnabled()) {
- log.debug("signalPendingID(" + id + ")");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("signalPendingID(" + id + ")");
}
unfinishedIDs.add(id);
}
@@ -106,8 +106,8 @@ public class IDTracker {
* @param id the id of the formatting object which was just finished
*/
public void signalIDProcessed(String id) {
- if (log.isDebugEnabled()) {
- log.debug("signalIDProcessed(" + id + ")");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("signalIDProcessed(" + id + ")");
}
alreadyResolvedIDs.add(id);
diff --git a/src/java/org/apache/fop/area/LineArea.java b/src/java/org/apache/fop/area/LineArea.java
index bbf947499..b33b5da14 100644
--- a/src/java/org/apache/fop/area/LineArea.java
+++ b/src/java/org/apache/fop/area/LineArea.java
@@ -19,25 +19,30 @@
package org.apache.fop.area;
-import org.apache.fop.area.inline.InlineArea;
-import org.apache.fop.fo.Constants;
-
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
+import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.fo.Constants;
+
/**
* The line area.
* This is a line area that contains inline areas.
*/
public class LineArea extends Area {
+ private static final long serialVersionUID = 7670235908329290684L;
+
/**
* this class stores information about line width and potential adjustments
* that can be used in order to re-compute adjustement and / or indents when a
* page-number or a page-number-citation is resolved
*/
- private class LineAdjustingInfo implements Serializable {
+ private final class LineAdjustingInfo implements Serializable {
+
+ private static final long serialVersionUID = -6103629976229458273L;
+
private int lineAlignment;
private int difference;
private int availableStretch;
@@ -54,6 +59,15 @@ public class LineArea extends Area {
variationFactor = 1.0;
bAddedToAreaTree = false;
}
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return getClass().getSimpleName()
+ + ": diff=" + difference
+ + ", variation=" + variationFactor
+ + ", stretch=" + availableStretch
+ + ", shrink=" + availableShrink;
+ }
}
private LineAdjustingInfo adjustingInfo = null;
@@ -194,6 +208,9 @@ public class LineArea extends Area {
*/
public void finalise() {
if (adjustingInfo.lineAlignment == Constants.EN_JUSTIFY) {
+ if (log.isTraceEnabled()) {
+ log.trace("Applying variation factor to justified line: " + adjustingInfo);
+ }
// justified line: apply the variation factor
boolean bUnresolvedAreasPresent = false;
// recursively apply variation factor to descendant areas
diff --git a/src/java/org/apache/fop/area/LinkResolver.java b/src/java/org/apache/fop/area/LinkResolver.java
index 51a952ddc..70bdfdf91 100644
--- a/src/java/org/apache/fop/area/LinkResolver.java
+++ b/src/java/org/apache/fop/area/LinkResolver.java
@@ -33,6 +33,9 @@ import org.apache.fop.area.Area;
* Link resolving for resolving internal links.
*/
public class LinkResolver implements Resolvable, Serializable {
+
+ private static final long serialVersionUID = -7102134165192960718L;
+
private boolean resolved = false;
private String idRef;
private Area area;
diff --git a/src/java/org/apache/fop/area/MainReference.java b/src/java/org/apache/fop/area/MainReference.java
index dd53113af..87e594169 100644
--- a/src/java/org/apache/fop/area/MainReference.java
+++ b/src/java/org/apache/fop/area/MainReference.java
@@ -31,6 +31,8 @@ import java.util.List;
*/
public class MainReference extends Area {
+ private static final long serialVersionUID = 7635126485620012448L;
+
private BodyRegion parent;
private List spanAreas = new java.util.ArrayList();
private boolean isEmpty = true;
diff --git a/src/java/org/apache/fop/area/NormalFlow.java b/src/java/org/apache/fop/area/NormalFlow.java
index 5e0192389..3daf2dafd 100644
--- a/src/java/org/apache/fop/area/NormalFlow.java
+++ b/src/java/org/apache/fop/area/NormalFlow.java
@@ -25,6 +25,9 @@ package org.apache.fop.area;
* See fo:region-body definition in the XSL Rec for more information.
*/
public class NormalFlow extends BlockParent {
+
+ private static final long serialVersionUID = -3753538631016929004L;
+
/**
* Constructor.
* @param ipd of Normal flow object
diff --git a/src/java/org/apache/fop/area/Page.java b/src/java/org/apache/fop/area/Page.java
index 4607dfb74..715bcfe85 100644
--- a/src/java/org/apache/fop/area/Page.java
+++ b/src/java/org/apache/fop/area/Page.java
@@ -47,6 +47,9 @@ import org.apache.fop.layoutmgr.TraitSetter;
* the top level page and regions.
*/
public class Page extends AreaTreeObject implements Serializable, Cloneable {
+
+ private static final long serialVersionUID = 6272157047421543866L;
+
// contains before, start, body, end and after regions
private RegionViewport regionBefore = null;
private RegionViewport regionStart = null;
@@ -120,7 +123,7 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable {
for (Iterator regenum = spm.getRegions().values().iterator();
regenum.hasNext();) {
Region r = (Region)regenum.next();
- RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM, spm);
+ RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM);
if (r.getNameId() == Constants.FO_REGION_BODY) {
rr = new BodyRegion((RegionBody) r, rvp);
} else {
@@ -135,7 +138,7 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable {
setRegionReferencePosition(rr, r, rvp.getViewArea());
rvp.setRegionReference(rr);
setRegionViewport(r.getNameId(), rvp);
- }
+ }
}
/**
@@ -150,12 +153,10 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable {
* @param r the region the viewport is to be created for
* @param reldims relative dimensions
* @param pageCTM page coordinate transformation matrix
- * @param spm the simple-page-master for this page
* @return the new region viewport
*/
- private RegionViewport makeRegionViewport(Region r, FODimension reldims, CTM pageCTM,
- SimplePageMaster spm) {
- Rectangle2D relRegionRect = r.getViewportRectangle(reldims, spm);
+ private RegionViewport makeRegionViewport(Region r, FODimension reldims, CTM pageCTM) {
+ Rectangle2D relRegionRect = r.getViewportRectangle(reldims);
Rectangle2D absRegionRect = pageCTM.transform(relRegionRect);
// Get the region viewport rectangle in absolute coords by
// transforming it using the page CTM
diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java
index 63740386e..a4fcb61a8 100644
--- a/src/java/org/apache/fop/area/PageViewport.java
+++ b/src/java/org/apache/fop/area/PageViewport.java
@@ -87,7 +87,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl
/**
* logging instance
*/
- protected static Log log = LogFactory.getLog(PageViewport.class);
+ protected static final Log log = LogFactory.getLog(PageViewport.class);
/**
* Create a page viewport.
@@ -95,8 +95,10 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl
* @param pageNumber the page number
* @param pageStr String representation of the page number
* @param blank true if this is a blank page
+ * @param spanAll true if the first span area spans all columns
*/
- public PageViewport(SimplePageMaster spm, int pageNumber, String pageStr, boolean blank) {
+ public PageViewport(SimplePageMaster spm, int pageNumber, String pageStr,
+ boolean blank, boolean spanAll) {
this.simplePageMasterName = spm.getMasterName();
setExtensionAttachments(spm.getExtensionAttachments());
setForeignAttributes(spm.getForeignAttributes());
@@ -107,7 +109,18 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl
this.pageNumberString = pageStr;
this.viewArea = new Rectangle(0, 0, pageWidth, pageHeight);
this.page = new Page(spm);
- createSpan(false);
+ createSpan(spanAll);
+ }
+
+ /**
+ * Create a page viewport.
+ * @param spm SimplePageMaster indicating the page and region dimensions
+ * @param pageNumber the page number
+ * @param pageStr String representation of the page number
+ * @param blank true if this is a blank page
+ */
+ public PageViewport(SimplePageMaster spm, int pageNumber, String pageStr, boolean blank) {
+ this(spm, pageNumber, pageStr, blank, false);
}
/**
diff --git a/src/java/org/apache/fop/area/RegionReference.java b/src/java/org/apache/fop/area/RegionReference.java
index 200f0bff3..a727f9029 100644
--- a/src/java/org/apache/fop/area/RegionReference.java
+++ b/src/java/org/apache/fop/area/RegionReference.java
@@ -31,17 +31,16 @@ import org.apache.fop.fo.pagination.Region;
*/
public class RegionReference extends Area implements Cloneable {
- /** Reference to the region FO. */
- //protected Region regionFO;
+ private static final long serialVersionUID = -298980963268244238L;
+
private int regionClass;
private String regionName;
private CTM ctm;
-
// the list of block areas from the static flow
private ArrayList blocks = new ArrayList();
- /** the parent RegionViewport for this object */
+ /** the parent {@link RegionViewport} for this object */
protected RegionViewport regionViewport;
/**
diff --git a/src/java/org/apache/fop/area/RegionViewport.java b/src/java/org/apache/fop/area/RegionViewport.java
index d55ecefbb..0654c5f6b 100644
--- a/src/java/org/apache/fop/area/RegionViewport.java
+++ b/src/java/org/apache/fop/area/RegionViewport.java
@@ -30,6 +30,9 @@ import java.util.HashMap;
* in the fo:region-body description in the XSL Recommendation.
*/
public class RegionViewport extends Area implements Cloneable {
+
+ private static final long serialVersionUID = 505781815165102572L;
+
// this rectangle is relative to the page
private RegionReference regionReference;
private Rectangle2D viewArea;
diff --git a/src/java/org/apache/fop/area/Span.java b/src/java/org/apache/fop/area/Span.java
index 69b37f4b3..e2ef90432 100644
--- a/src/java/org/apache/fop/area/Span.java
+++ b/src/java/org/apache/fop/area/Span.java
@@ -30,6 +30,9 @@ import java.util.List;
* See fo:region-body definition in the XSL Rec for more information.
*/
public class Span extends Area {
+
+ private static final long serialVersionUID = -5551430053660081549L;
+
// the list of flow reference areas in this span area
private List flowAreas;
private int colCount;
diff --git a/src/java/org/apache/fop/area/Trait.java b/src/java/org/apache/fop/area/Trait.java
index 27ce39252..a8e1db186 100644
--- a/src/java/org/apache/fop/area/Trait.java
+++ b/src/java/org/apache/fop/area/Trait.java
@@ -34,169 +34,121 @@ import org.apache.fop.util.ColorUtil;
* Area traits used for rendering.
* This class represents an area trait that specifies a value for rendering.
*/
-public class Trait implements Serializable {
+public final class Trait implements Serializable {
- /**
- * Id reference line, not resolved.
- * not sure if this is needed.
- */
+ private static final long serialVersionUID = 3234280285391611437L;
+
+ private Trait() {
+ }
+
+ /** Id reference line, not resolved. (not sure if this is needed.) */
//public static final Integer ID_LINK = new Integer(0);
/**
* Internal link trait.
* Contains the PageViewport key and the PROD_ID of the target area
*/
- public static final Integer INTERNAL_LINK = new Integer(1);
+ public static final Integer INTERNAL_LINK = 1;
- /**
- * External link. A URL link to an external resource.
- */
- public static final Integer EXTERNAL_LINK = new Integer(2);
+ /** * External link. A URL link to an external resource. */
+ public static final Integer EXTERNAL_LINK = 2;
- /**
- * The font triplet for the current font.
- */
- public static final Integer FONT = new Integer(3);
+ /** The font triplet for the current font. */
+ public static final Integer FONT = 3;
- /**
- * Font size for the current font.
- */
- public static final Integer FONT_SIZE = new Integer(4);
+ /** Font size for the current font. */
+ public static final Integer FONT_SIZE = 4;
- /**
- * The current color.
- */
- public static final Integer COLOR = new Integer(7);
+ /** The current color. */
+ public static final Integer COLOR = 7;
- /**
- * The ID of the FO that produced an area.
- */
- public static final Integer PROD_ID = new Integer(8);
+ /** The ID of the FO that produced an area. */
+ public static final Integer PROD_ID = 8;
- /**
- * Background trait for an area.
- */
- public static final Integer BACKGROUND = new Integer(9);
+ /** Background trait for an area. */
+ public static final Integer BACKGROUND = 9;
- /**
- * Underline trait used when rendering inline parent.
- */
- public static final Integer UNDERLINE = new Integer(10);
+ /** Underline trait used when rendering inline parent. */
+ public static final Integer UNDERLINE = 10;
- /**
- * Overline trait used when rendering inline parent.
- */
- public static final Integer OVERLINE = new Integer(11);
+ /** Overline trait used when rendering inline parent. */
+ public static final Integer OVERLINE = 11;
- /**
- * Linethrough trait used when rendering inline parent.
- */
- public static final Integer LINETHROUGH = new Integer(12);
+ /** Linethrough trait used when rendering inline parent. */
+ public static final Integer LINETHROUGH = 12;
- /**
- * Shadow offset.
- */
+ /** Shadow offset. */
//public static final Integer OFFSET = new Integer(13);
- /**
- * The shadow for text.
- */
+ /** The shadow for text. */
//public static final Integer SHADOW = new Integer(14);
- /**
- * The border start.
- */
- public static final Integer BORDER_START = new Integer(15);
+ /** The border start. */
+ public static final Integer BORDER_START = 15;
- /**
- * The border end.
- */
- public static final Integer BORDER_END = new Integer(16);
+ /** The border end. */
+ public static final Integer BORDER_END = 16;
- /**
- * The border before.
- */
- public static final Integer BORDER_BEFORE = new Integer(17);
+ /** The border before. */
+ public static final Integer BORDER_BEFORE = 17;
- /**
- * The border after.
- */
- public static final Integer BORDER_AFTER = new Integer(18);
+ /** The border after. */
+ public static final Integer BORDER_AFTER = 18;
- /**
- * The padding start.
- */
- public static final Integer PADDING_START = new Integer(19);
+ /** The padding start. */
+ public static final Integer PADDING_START = 19;
- /**
- * The padding end.
- */
- public static final Integer PADDING_END = new Integer(20);
+ /** The padding end. */
+ public static final Integer PADDING_END = 20;
- /**
- * The padding before.
- */
- public static final Integer PADDING_BEFORE = new Integer(21);
+ /** The padding before. */
+ public static final Integer PADDING_BEFORE = 21;
- /**
- * The padding after.
- */
- public static final Integer PADDING_AFTER = new Integer(22);
+ /** The padding after. */
+ public static final Integer PADDING_AFTER = 22;
- /**
- * The space start.
- */
- public static final Integer SPACE_START = new Integer(23);
+ /** The space start. */
+ public static final Integer SPACE_START = 23;
- /**
- * The space end.
- */
- public static final Integer SPACE_END = new Integer(24);
+ /** The space end. */
+ public static final Integer SPACE_END = 24;
- /**
- * break before
- */
+ /** break before */
//public static final Integer BREAK_BEFORE = new Integer(25);
- /**
- * break after
- */
+ /** break after */
//public static final Integer BREAK_AFTER = new Integer(26);
- /**
- * The start-indent trait.
- */
- public static final Integer START_INDENT = new Integer(27);
+ /** The start-indent trait. */
+ public static final Integer START_INDENT = 27;
- /**
- * The end-indent trait.
- */
- public static final Integer END_INDENT = new Integer(28);
+ /** The end-indent trait. */
+ public static final Integer END_INDENT = 28;
/** The space-before trait. */
- public static final Integer SPACE_BEFORE = new Integer(29);
+ public static final Integer SPACE_BEFORE = 29;
/** The space-after trait. */
- public static final Integer SPACE_AFTER = new Integer(30);
+ public static final Integer SPACE_AFTER = 30;
/** The is-reference-area trait. */
- public static final Integer IS_REFERENCE_AREA = new Integer(31);
+ public static final Integer IS_REFERENCE_AREA = 31;
/** The is-viewport-area trait. */
- public static final Integer IS_VIEWPORT_AREA = new Integer(32);
+ public static final Integer IS_VIEWPORT_AREA = 32;
/** Blinking trait used when rendering inline parent. */
- public static final Integer BLINK = new Integer(33);
+ public static final Integer BLINK = 33;
/** Trait for color of underline decorations when rendering inline parent. */
- public static final Integer UNDERLINE_COLOR = new Integer(34);
+ public static final Integer UNDERLINE_COLOR = 34;
/** Trait for color of overline decorations when rendering inline parent. */
- public static final Integer OVERLINE_COLOR = new Integer(35);
+ public static final Integer OVERLINE_COLOR = 35;
/** Trait for color of linethrough decorations when rendering inline parent. */
- public static final Integer LINETHROUGH_COLOR = new Integer(36);
-
+ public static final Integer LINETHROUGH_COLOR = 36;
+
/** The ptr trait. Used for accessibility */
- public static final Integer PTR = new Integer(37);
+ public static final Integer PTR = 37;
/** Maximum value used by trait keys */
public static final int MAX_TRAIT_KEY = 37;
@@ -222,65 +174,47 @@ public class Trait implements Serializable {
}
private static void put(Integer key, TraitInfo info) {
- TRAIT_INFO[key.intValue()] = info;
+ TRAIT_INFO[key] = info;
}
static {
// Create a hashmap mapping trait code to name for external representation
//put(ID_LINK, new TraitInfo("id-link", String.class));
- put(PTR, new TraitInfo("ptr", String.class));
- put(INTERNAL_LINK, new TraitInfo("internal-link", InternalLink.class));
- put(EXTERNAL_LINK, new TraitInfo("external-link", ExternalLink.class));
- put(FONT, new TraitInfo("font", FontTriplet.class));
- put(FONT_SIZE, new TraitInfo("font-size", Integer.class));
- put(COLOR, new TraitInfo("color", Color.class));
- put(PROD_ID, new TraitInfo("prod-id", String.class));
- put(BACKGROUND, new TraitInfo("background", Background.class));
- put(UNDERLINE, new TraitInfo("underline-score", Boolean.class));
+ put(PTR, new TraitInfo("ptr", String.class));
+ put(INTERNAL_LINK, new TraitInfo("internal-link", InternalLink.class));
+ put(EXTERNAL_LINK, new TraitInfo("external-link", ExternalLink.class));
+ put(FONT, new TraitInfo("font", FontTriplet.class));
+ put(FONT_SIZE, new TraitInfo("font-size", Integer.class));
+ put(COLOR, new TraitInfo("color", Color.class));
+ put(PROD_ID, new TraitInfo("prod-id", String.class));
+ put(BACKGROUND, new TraitInfo("background", Background.class));
+ put(UNDERLINE, new TraitInfo("underline-score", Boolean.class));
put(UNDERLINE_COLOR, new TraitInfo("underline-score-color", Color.class));
- put(OVERLINE, new TraitInfo("overline-score", Boolean.class));
+ put(OVERLINE, new TraitInfo("overline-score", Boolean.class));
put(OVERLINE_COLOR, new TraitInfo("overline-score-color", Color.class));
- put(LINETHROUGH, new TraitInfo("through-score", Boolean.class));
+ put(LINETHROUGH, new TraitInfo("through-score", Boolean.class));
put(LINETHROUGH_COLOR, new TraitInfo("through-score-color", Color.class));
- put(BLINK, new TraitInfo("blink", Boolean.class));
- //put(OFFSET, new TraitInfo("offset", Integer.class));
- //put(SHADOW, new TraitInfo("shadow", Integer.class));
- put(BORDER_START,
- new TraitInfo("border-start", BorderProps.class));
- put(BORDER_END,
- new TraitInfo("border-end", BorderProps.class));
- put(BORDER_BEFORE,
- new TraitInfo("border-before", BorderProps.class));
- put(BORDER_AFTER,
- new TraitInfo("border-after", BorderProps.class));
- put(PADDING_START,
- new TraitInfo("padding-start", Integer.class));
- put(PADDING_END,
- new TraitInfo("padding-end", Integer.class));
- put(PADDING_BEFORE,
- new TraitInfo("padding-before", Integer.class));
- put(PADDING_AFTER,
- new TraitInfo("padding-after", Integer.class));
- put(SPACE_START,
- new TraitInfo("space-start", Integer.class));
- put(SPACE_END,
- new TraitInfo("space-end", Integer.class));
- //put(BREAK_BEFORE,
- // new TraitInfo("break-before", Integer.class));
- //put(BREAK_AFTER,
- // new TraitInfo("break-after", Integer.class));
- put(START_INDENT,
- new TraitInfo("start-indent", Integer.class));
- put(END_INDENT,
- new TraitInfo("end-indent", Integer.class));
- put(SPACE_BEFORE,
- new TraitInfo("space-before", Integer.class));
- put(SPACE_AFTER,
- new TraitInfo("space-after", Integer.class));
- put(IS_REFERENCE_AREA,
- new TraitInfo("is-reference-area", Boolean.class));
- put(IS_VIEWPORT_AREA,
- new TraitInfo("is-viewport-area", Boolean.class));
+ put(BLINK, new TraitInfo("blink", Boolean.class));
+ //put(OFFSET, new TraitInfo("offset", Integer.class));
+ //put(SHADOW, new TraitInfo("shadow", Integer.class));
+ put(BORDER_START, new TraitInfo("border-start", BorderProps.class));
+ put(BORDER_END, new TraitInfo("border-end", BorderProps.class));
+ put(BORDER_BEFORE, new TraitInfo("border-before", BorderProps.class));
+ put(BORDER_AFTER, new TraitInfo("border-after", BorderProps.class));
+ put(PADDING_START, new TraitInfo("padding-start", Integer.class));
+ put(PADDING_END, new TraitInfo("padding-end", Integer.class));
+ put(PADDING_BEFORE, new TraitInfo("padding-before", Integer.class));
+ put(PADDING_AFTER, new TraitInfo("padding-after", Integer.class));
+ put(SPACE_START, new TraitInfo("space-start", Integer.class));
+ put(SPACE_END, new TraitInfo("space-end", Integer.class));
+ //put(BREAK_BEFORE, new TraitInfo("break-before", Integer.class));
+ //put(BREAK_AFTER, new TraitInfo("break-after", Integer.class));
+ put(START_INDENT, new TraitInfo("start-indent", Integer.class));
+ put(END_INDENT, new TraitInfo("end-indent", Integer.class));
+ put(SPACE_BEFORE, new TraitInfo("space-before", Integer.class));
+ put(SPACE_AFTER, new TraitInfo("space-after", Integer.class));
+ put(IS_REFERENCE_AREA, new TraitInfo("is-reference-area", Boolean.class));
+ put(IS_VIEWPORT_AREA, new TraitInfo("is-viewport-area", Boolean.class));
}
@@ -291,7 +225,7 @@ public class Trait implements Serializable {
* @return the trait name
*/
public static String getTraitName(Object traitCode) {
- return TRAIT_INFO[((Integer)traitCode).intValue()].getName();
+ return TRAIT_INFO[(Integer)traitCode].getName();
}
/**
@@ -301,7 +235,7 @@ public class Trait implements Serializable {
* @return the class type for the trait
*/
public static Class getTraitClass(Object traitCode) {
- return TRAIT_INFO[((Integer)traitCode).intValue()].getClazz();
+ return TRAIT_INFO[(Integer)traitCode].getClazz();
}
/**
@@ -310,6 +244,8 @@ public class Trait implements Serializable {
*/
public static class InternalLink implements Serializable {
+ private static final long serialVersionUID = -8993505060996723039L;
+
/** The unique key of the PageViewport. */
private String pvKey;
@@ -444,6 +380,8 @@ public class Trait implements Serializable {
*/
public static class ExternalLink implements Serializable {
+ private static final long serialVersionUID = -3720707599232620946L;
+
private String destination;
private boolean newWindow;
@@ -473,7 +411,7 @@ public class Trait implements Serializable {
if (v.startsWith("dest=")) {
dest = v.substring(5);
} else if (v.startsWith("newWindow=")) {
- newWindow = Boolean.valueOf(v.substring(10)).booleanValue();
+ newWindow = Boolean.valueOf(v.substring(10));
} else {
throw new IllegalArgumentException(
"Malformed trait value for Trait.ExternalLink: " + traitValue);
@@ -517,6 +455,8 @@ public class Trait implements Serializable {
*/
public static class Background implements Serializable {
+ private static final long serialVersionUID = 8452078676273242870L;
+
/** The background color if any. */
private Color color = null;
diff --git a/src/java/org/apache/fop/area/inline/AbstractTextArea.java b/src/java/org/apache/fop/area/inline/AbstractTextArea.java
index e73a8355c..08997a817 100644
--- a/src/java/org/apache/fop/area/inline/AbstractTextArea.java
+++ b/src/java/org/apache/fop/area/inline/AbstractTextArea.java
@@ -24,6 +24,8 @@ package org.apache.fop.area.inline;
*/
public abstract class AbstractTextArea extends InlineParent {
+ private static final long serialVersionUID = -1246306443569094371L;
+
/**
* this class stores information about spaces and potential adjustments
* that can be used in order to re-compute adjustments when a
@@ -31,6 +33,8 @@ public abstract class AbstractTextArea extends InlineParent {
*/
protected class TextAdjustingInfo extends InlineAdjustingInfo {
+ private static final long serialVersionUID = -2412095162983479947L;
+
/** difference between the optimal width of a space
* and the default width of a space according to the font
* (this is equivalent to the property word-spacing.optimum)
@@ -140,12 +144,14 @@ public abstract class AbstractTextArea extends InlineParent {
if (textWordSpaceAdjust < 0) {
// from a negative adjustment to a positive one
balancingFactor
- = ((double) textAdjustingInfo.availableStretch / textAdjustingInfo.availableShrink)
+ = ((double) textAdjustingInfo.availableStretch
+ / textAdjustingInfo.availableShrink)
* ((double) lineShrink / lineStretch);
} else {
// from a positive adjustment to a negative one
balancingFactor
- = ((double) textAdjustingInfo.availableShrink / textAdjustingInfo.availableStretch)
+ = ((double) textAdjustingInfo.availableShrink
+ / textAdjustingInfo.availableStretch)
* ((double) lineStretch / lineShrink);
}
}
diff --git a/src/java/org/apache/fop/area/inline/Anchor.java b/src/java/org/apache/fop/area/inline/Anchor.java
index ec6dbbcfb..8ad663111 100644
--- a/src/java/org/apache/fop/area/inline/Anchor.java
+++ b/src/java/org/apache/fop/area/inline/Anchor.java
@@ -25,6 +25,8 @@ package org.apache.fop.area.inline;
*/
public class Anchor extends InlineArea {
+ private static final long serialVersionUID = 5227798744787823499L;
+
// has a keep with adjacent area
// has reference to associated footnote or float out-of-line area
diff --git a/src/java/org/apache/fop/area/inline/Container.java b/src/java/org/apache/fop/area/inline/Container.java
index 98c0aaef0..f6dbf3a15 100644
--- a/src/java/org/apache/fop/area/inline/Container.java
+++ b/src/java/org/apache/fop/area/inline/Container.java
@@ -32,6 +32,9 @@ import java.util.ArrayList;
* This allows an inline area to have blocks as children.
*/
public class Container extends Area {
+
+ private static final long serialVersionUID = 5256423939348189260L;
+
/**
* The list of block areas stacked inside this container
*/
diff --git a/src/java/org/apache/fop/area/inline/FilledArea.java b/src/java/org/apache/fop/area/inline/FilledArea.java
index 7df62e79b..06d0d3aa3 100644
--- a/src/java/org/apache/fop/area/inline/FilledArea.java
+++ b/src/java/org/apache/fop/area/inline/FilledArea.java
@@ -34,6 +34,9 @@ import java.util.Iterator;
* this as a normal inline parent.
*/
public class FilledArea extends InlineParent {
+
+ private static final long serialVersionUID = 8586584705587017474L;
+
private int unitWidth;
/**
diff --git a/src/java/org/apache/fop/area/inline/Image.java b/src/java/org/apache/fop/area/inline/Image.java
index 7d802db49..e6e355254 100644
--- a/src/java/org/apache/fop/area/inline/Image.java
+++ b/src/java/org/apache/fop/area/inline/Image.java
@@ -27,8 +27,11 @@ import org.apache.fop.area.Area;
* The url of the image is used as a key to reference the image cache.
*/
public class Image extends Area {
+
+ private static final long serialVersionUID = 4800834714349695386L;
+
private String url;
-
+
/**
* Create a new image with the given url.
*
diff --git a/src/java/org/apache/fop/area/inline/InlineArea.java b/src/java/org/apache/fop/area/inline/InlineArea.java
index 5106fd5bc..3450b99be 100644
--- a/src/java/org/apache/fop/area/inline/InlineArea.java
+++ b/src/java/org/apache/fop/area/inline/InlineArea.java
@@ -32,12 +32,17 @@ import org.apache.fop.area.Trait;
*/
public class InlineArea extends Area {
+ private static final long serialVersionUID = -8940066479810170980L;
+
/**
* this class stores information about potential adjustments
* that can be used in order to re-compute adjustments when a
* page-number or a page-number-citation is resolved
*/
protected class InlineAdjustingInfo implements Serializable {
+
+ private static final long serialVersionUID = -5601387735459712149L;
+
/** stretch of the inline area */
protected int availableStretch;
/** shrink of the inline area */
@@ -218,7 +223,16 @@ public class InlineArea extends Area {
return false;
}
+ /**
+ * Apply IPD variation.
+ * @param ipdVariation the variation
+ */
public void handleIPDVariation(int ipdVariation) {
+ if (log.isTraceEnabled()) {
+ log.trace("Handling IPD variation for " + getClass().getSimpleName()
+ + ": increase by " + ipdVariation + " mpt.");
+ }
+
increaseIPD(ipdVariation);
notifyIPDVariation(ipdVariation);
}
diff --git a/src/java/org/apache/fop/area/inline/InlineBlockParent.java b/src/java/org/apache/fop/area/inline/InlineBlockParent.java
index e580b1667..fe024ac0f 100644
--- a/src/java/org/apache/fop/area/inline/InlineBlockParent.java
+++ b/src/java/org/apache/fop/area/inline/InlineBlockParent.java
@@ -29,6 +29,9 @@ import org.apache.fop.area.Block;
*/
public class InlineBlockParent extends InlineArea {
+
+ private static final long serialVersionUID = -3661746143321407377L;
+
/**
* The list of inline areas added to this inline parent.
*/
diff --git a/src/java/org/apache/fop/area/inline/InlineParent.java b/src/java/org/apache/fop/area/inline/InlineParent.java
index cbc5b578c..db8f2f056 100644
--- a/src/java/org/apache/fop/area/inline/InlineParent.java
+++ b/src/java/org/apache/fop/area/inline/InlineParent.java
@@ -19,20 +19,22 @@
package org.apache.fop.area.inline;
-import org.apache.fop.area.Area;
-
import java.util.List;
-import java.util.ArrayList;
+
+import org.apache.fop.area.Area;
/**
* Inline parent area.
* This is an inline area that can have other inlines as children.
*/
public class InlineParent extends InlineArea {
+
+ private static final long serialVersionUID = -3047168298770354813L;
+
/**
* The list of inline areas added to this inline parent.
*/
- protected List inlines = new ArrayList();
+ protected List<InlineArea> inlines = new java.util.ArrayList<InlineArea>();
/** Controls whether the IPD is automatically adjusted based on the area's children. */
protected transient boolean autoSize;
@@ -48,13 +50,14 @@ public class InlineParent extends InlineArea {
*
* @param childArea the child area to add
*/
+ @Override
public void addChildArea(Area childArea) {
if (inlines.size() == 0) {
autoSize = (getIPD() == 0);
}
if (childArea instanceof InlineArea) {
InlineArea inlineChildArea = (InlineArea) childArea;
- inlines.add(childArea);
+ inlines.add(inlineChildArea);
// set the parent area for the child area
inlineChildArea.setParentArea(this);
if (autoSize) {
@@ -68,7 +71,7 @@ public class InlineParent extends InlineArea {
*
* @return the list of child areas
*/
- public List getChildAreas() {
+ public List<InlineArea> getChildAreas() {
return inlines;
}
@@ -79,15 +82,21 @@ public class InlineParent extends InlineArea {
* @param lineShrink the total shrink of the line
* @return true if there is an UnresolvedArea descendant
*/
+ @Override
public boolean applyVariationFactor(double variationFactor,
int lineStretch, int lineShrink) {
- boolean bUnresolvedAreasPresent = false;
+ boolean hasUnresolvedAreas = false;
+ int cumulativeIPD = 0;
// recursively apply variation factor to descendant areas
for (int i = 0, len = inlines.size(); i < len; i++) {
- bUnresolvedAreasPresent |= ((InlineArea)inlines.get(i))
- .applyVariationFactor(variationFactor, lineStretch, lineShrink);
+ InlineArea inline = inlines.get(i);
+ hasUnresolvedAreas |= inline.applyVariationFactor(
+ variationFactor, lineStretch, lineShrink);
+ cumulativeIPD += inline.getIPD(); //Update this area's IPD based on changes to children
}
- return bUnresolvedAreasPresent;
+ setIPD(cumulativeIPD);
+
+ return hasUnresolvedAreas;
}
}
diff --git a/src/java/org/apache/fop/area/inline/Leader.java b/src/java/org/apache/fop/area/inline/Leader.java
index cd7b2e9f3..ff8ba12b0 100644
--- a/src/java/org/apache/fop/area/inline/Leader.java
+++ b/src/java/org/apache/fop/area/inline/Leader.java
@@ -32,6 +32,9 @@ public class Leader extends InlineArea {
// if space replaced with a space
// otherwise this is a holder for a line
+
+ private static final long serialVersionUID = -8011373048313956301L;
+
private int ruleStyle = Constants.EN_SOLID;
private int ruleThickness = 1000;
diff --git a/src/java/org/apache/fop/area/inline/Space.java b/src/java/org/apache/fop/area/inline/Space.java
index 9a24de0d3..bf683bb22 100644
--- a/src/java/org/apache/fop/area/inline/Space.java
+++ b/src/java/org/apache/fop/area/inline/Space.java
@@ -25,4 +25,6 @@ package org.apache.fop.area.inline;
*/
public class Space extends InlineArea {
+ private static final long serialVersionUID = -8748265505356839796L;
+
}
diff --git a/src/java/org/apache/fop/area/inline/SpaceArea.java b/src/java/org/apache/fop/area/inline/SpaceArea.java
index 287f09dfc..9c698b305 100644
--- a/src/java/org/apache/fop/area/inline/SpaceArea.java
+++ b/src/java/org/apache/fop/area/inline/SpaceArea.java
@@ -16,6 +16,7 @@
*/
/* $Id$ */
+
package org.apache.fop.area.inline;
/**
@@ -23,10 +24,12 @@ package org.apache.fop.area.inline;
*/
public class SpaceArea extends InlineArea {
+ private static final long serialVersionUID = 2218803009825411416L;
+
/**
* The space for this space area
*/
- protected String space;
+ protected char space;
/**
* Is this space adjustable?
@@ -40,7 +43,7 @@ public class SpaceArea extends InlineArea {
* @param a is this space adjustable?
*/
public SpaceArea(char s, int o, boolean a) {
- space = new String() + s;
+ space = s;
offset = o;
isAdjustable = a;
}
@@ -49,7 +52,7 @@ public class SpaceArea extends InlineArea {
* @return Returns the space.
*/
public String getSpace() {
- return new String(space);
+ return String.valueOf(space);
}
/** @return true if the space is adjustable (WRT word-space processing) */
diff --git a/src/java/org/apache/fop/area/inline/TextArea.java b/src/java/org/apache/fop/area/inline/TextArea.java
index f736b894c..8fb9455ad 100644
--- a/src/java/org/apache/fop/area/inline/TextArea.java
+++ b/src/java/org/apache/fop/area/inline/TextArea.java
@@ -24,6 +24,8 @@ package org.apache.fop.area.inline;
*/
public class TextArea extends AbstractTextArea {
+ private static final long serialVersionUID = 7315900267242540809L;
+
/**
* Create a text inline area
*/
diff --git a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
index 43a995670..3457ad698 100644
--- a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
+++ b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
@@ -32,6 +32,9 @@ import java.util.List;
*/
public class UnresolvedPageNumber extends TextArea implements Resolvable {
+
+ private static final long serialVersionUID = -1758090835371647980L;
+
private boolean resolved = false;
private String pageIDRef;
private String text;
diff --git a/src/java/org/apache/fop/area/inline/Viewport.java b/src/java/org/apache/fop/area/inline/Viewport.java
index 489f5afda..206a965e2 100644
--- a/src/java/org/apache/fop/area/inline/Viewport.java
+++ b/src/java/org/apache/fop/area/inline/Viewport.java
@@ -32,6 +32,9 @@ import java.util.HashMap;
* holds the area and positions it.
*/
public class Viewport extends InlineArea {
+
+ private static final long serialVersionUID = 813338534627918689L;
+
// contents could be container, foreign object or image
private Area content;
// clipping for the viewport
diff --git a/src/java/org/apache/fop/area/inline/WordArea.java b/src/java/org/apache/fop/area/inline/WordArea.java
index 70d10ef9b..8bb6888ce 100644
--- a/src/java/org/apache/fop/area/inline/WordArea.java
+++ b/src/java/org/apache/fop/area/inline/WordArea.java
@@ -16,6 +16,7 @@
*/
/* $Id$ */
+
package org.apache.fop.area.inline;
/**
@@ -23,6 +24,8 @@ package org.apache.fop.area.inline;
*/
public class WordArea extends InlineArea {
+ private static final long serialVersionUID = 6444644662158970942L;
+
/** The text for this word area */
protected String word;
diff --git a/src/java/org/apache/fop/cli/CommandLineOptions.java b/src/java/org/apache/fop/cli/CommandLineOptions.java
index 011e84008..2a5c0d272 100644
--- a/src/java/org/apache/fop/cli/CommandLineOptions.java
+++ b/src/java/org/apache/fop/cli/CommandLineOptions.java
@@ -41,6 +41,7 @@ import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.fonts.FontManager;
import org.apache.fop.pdf.PDFAMode;
import org.apache.fop.pdf.PDFEncryptionManager;
import org.apache.fop.pdf.PDFEncryptionParams;
@@ -50,7 +51,7 @@ import org.apache.fop.render.awt.AWTRenderer;
import org.apache.fop.render.intermediate.IFContext;
import org.apache.fop.render.intermediate.IFDocumentHandler;
import org.apache.fop.render.intermediate.IFSerializer;
-import org.apache.fop.render.pdf.PDFRenderer;
+import org.apache.fop.render.pdf.PDFConfigurationConstants;
import org.apache.fop.render.print.PagesMode;
import org.apache.fop.render.print.PrintRenderer;
import org.apache.fop.render.xml.XMLRenderer;
@@ -109,7 +110,7 @@ public class CommandLineOptions {
private boolean useStdIn = false;
/* true if System.out (stdout) should be used for the output file */
private boolean useStdOut = false;
- /* true if a catalog resolver should be used for entity and uri resolution */
+ /* true if a catalog resolver should be used for entity and uri resolution */
private boolean useCatalogResolver = false;
/* rendering options (for the user agent) */
private Map renderingOptions = new java.util.HashMap();
@@ -129,6 +130,8 @@ public class CommandLineOptions {
private String mimicRenderer = null;
+ private boolean flushCache = false;
+
/**
* Construct a command line option object.
*/
@@ -166,7 +169,9 @@ public class CommandLineOptions {
}
checkSettings();
setUserConfig();
-
+ if (flushCache) {
+ flushCache();
+ }
//Factory config is set up, now we can create the user agent
foUserAgent = factory.newFOUserAgent();
foUserAgent.getRendererOptions().putAll(renderingOptions);
@@ -284,6 +289,10 @@ public class CommandLineOptions {
factory.setStrictValidation(false);
} else if (args[i].equals("-conserve")) {
conserveMemoryPolicy = true;
+ } else if (args[i].equals("-flush")) {
+ flushCache = true;
+ } else if (args[i].equals("-cache")) {
+ parseCacheOption(args, i);
} else if (args[i].equals("-dpi")) {
i = i + parseResolution(args, i);
} else if (args[i].equals("-q") || args[i].equals("--quiet")) {
@@ -385,6 +394,17 @@ public class CommandLineOptions {
return true;
} // end parseOptions
+ private int parseCacheOption(String[] args, int i) throws FOPException {
+ if ((i + 1 == args.length)
+ || (isOption(args[i + 1]))) {
+ throw new FOPException("if you use '-cache', you must specify "
+ + "the name of the font cache file");
+ } else {
+ factory.getFontManager().setCacheFile(new File(args[i + 1]));
+ return 1;
+ }
+ }
+
private int parseConfigurationOption(String[] args, int i) throws FOPException {
if ((i + 1 == args.length)
|| (isOption(args[i + 1]))) {
@@ -785,14 +805,14 @@ public class CommandLineOptions {
private PDFEncryptionParams getPDFEncryptionParams() throws FOPException {
PDFEncryptionParams params = (PDFEncryptionParams)renderingOptions.get(
- PDFRenderer.ENCRYPTION_PARAMS);
+ PDFConfigurationConstants.ENCRYPTION_PARAMS);
if (params == null) {
if (!PDFEncryptionManager.checkAvailableAlgorithms()) {
throw new FOPException("PDF encryption requested but it is not available."
+ " Please make sure MD5 and RC4 algorithms are available.");
}
params = new PDFEncryptionParams();
- renderingOptions.put(PDFRenderer.ENCRYPTION_PARAMS, params);
+ renderingOptions.put(PDFConfigurationConstants.ENCRYPTION_PARAMS, params);
}
return params;
}
@@ -961,10 +981,12 @@ public class CommandLineOptions {
"FO output mode is only available if you use -xml and -xsl");
} else if (outputmode.equals(MimeConstants.MIME_FOP_AREA_TREE)) {
throw new FOPException(
- "Area Tree Output is not available if Intermediate Format is used as input!");
+ "Area Tree Output is not available if Intermediate Format"
+ + " is used as input!");
} else if (outputmode.equals(MimeConstants.MIME_FOP_IF)) {
throw new FOPException(
- "Intermediate Output is not available if Intermediate Format is used as input!");
+ "Intermediate Output is not available if Intermediate Format"
+ + " is used as input!");
}
if (iffile != null && !iffile.exists()) {
throw new FileNotFoundException("Error: intermediate format file "
@@ -1151,7 +1173,8 @@ public class CommandLineOptions {
+ " -r relaxed/less strict validation (where available)\n"
+ " -dpi xxx target resolution in dots per inch (dpi) where xxx is a number\n"
+ " -s for area tree XML, down to block areas only\n"
- + " -v run in verbose mode (currently simply print FOP version and continue)\n\n"
+ + " -v run in verbose mode (currently simply print FOP version"
+ + " and continue)\n\n"
+ " -o [password] PDF file will be encrypted with option owner password\n"
+ " -u [password] PDF file will be encrypted with option user password\n"
+ " -noprint PDF file will be encrypted without printing permission\n"
@@ -1161,8 +1184,15 @@ public class CommandLineOptions {
+ " -a enables accessibility features (Tagged PDF etc., default off)\n"
+ " -pdfprofile prof PDF file will be generated with the specified profile\n"
+ " (Examples for prof: PDF/A-1b or PDF/X-3:2003)\n\n"
- + " -conserve Enable memory-conservation policy (trades memory-consumption for disk I/O)\n"
- + " (Note: currently only influences whether the area tree is serialized.)\n\n"
+ + " -conserve enable memory-conservation policy (trades memory-consumption"
+ + " for disk I/O)\n"
+ + " (Note: currently only influences whether the area tree is"
+ + " serialized.)\n\n"
+
+ + " -cache specifies a file/directory path location"
+ + " for the font cache file\n"
+ + " -flush flushes the current font cache file\n\n"
+
+ " [INPUT] \n"
+ " infile xsl:fo input file (the same as the next) \n"
+ " (use '-' for infile to pipe input from stdin)\n"
@@ -1192,14 +1222,16 @@ public class CommandLineOptions {
+ " -at [mime] out representation of area tree as XML (outfile req'd) \n"
+ " specify optional mime output to allow the AT to be converted\n"
+ " to final format later\n"
- + " -if [mime] out representation of document in intermediate format XML (outfile req'd)\n"
+ + " -if [mime] out representation of document in intermediate format XML"
+ + " (outfile req'd)\n"
+ " specify optional mime output to allow the IF to be converted\n"
+ " to final format later\n"
+ " -print input file will be rendered and sent to the printer \n"
+ " see options with \"-print help\" \n"
+ " -out mime outfile input will be rendered using the given MIME type\n"
+ " (outfile req'd) Example: \"-out application/pdf D:\\out.pdf\"\n"
- + " (Tip: \"-out list\" prints the list of supported MIME types)\n"
+ + " (Tip: \"-out list\" prints the list of supported MIME types"
+ + " and exits)\n"
//+ " -mif outfile input will be rendered as MIF (FrameMaker) (outfile req'd)\n"
//+ " Experimental feature - requires additional fop-sandbox.jar.\n"
+ " -svg outfile input will be rendered as an SVG slides file (outfile req'd) \n"
@@ -1333,5 +1365,14 @@ public class CommandLineOptions {
}
}
+ private void flushCache() throws FOPException {
+ FontManager fontManager = factory.getFontManager();
+ File cacheFile = fontManager.getCacheFile();
+ if (!fontManager.deleteCache()) {
+ System.err.println("Failed to flush the font cache file '"
+ + cacheFile + "'.");
+ System.exit(1);
+ }
+ }
}
diff --git a/src/java/org/apache/fop/cli/InputHandler.java b/src/java/org/apache/fop/cli/InputHandler.java
index e7109fcfa..f6389a25f 100644
--- a/src/java/org/apache/fop/cli/InputHandler.java
+++ b/src/java/org/apache/fop/cli/InputHandler.java
@@ -196,13 +196,14 @@ public class InputHandler implements ErrorListener, Renderable {
* Creates a catalog resolver and uses it for XML parsing and XSLT URI resolution.
* Tries the Apache Commons Resolver, and if unsuccessful,
* tries the same built into Java 6.
+ * @param userAgent the user agent instance
*/
public void createCatalogResolver(FOUserAgent userAgent) {
String[] classNames = new String[] {
"org.apache.xml.resolver.tools.CatalogResolver",
"com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver"};
- ResourceEventProducer eventProducer =
- ResourceEventProducer.Provider.get(userAgent.getEventBroadcaster());
+ ResourceEventProducer eventProducer
+ = ResourceEventProducer.Provider.get(userAgent.getEventBroadcaster());
Class resolverClass = null;
for (int i = 0; i < classNames.length && resolverClass == null; ++i) {
try {
diff --git a/src/java/org/apache/fop/cli/Main.java b/src/java/org/apache/fop/cli/Main.java
index c4393bb03..6ae81ea21 100644
--- a/src/java/org/apache/fop/cli/Main.java
+++ b/src/java/org/apache/fop/cli/Main.java
@@ -35,7 +35,10 @@ import org.apache.fop.apps.MimeConstants;
/**
* Main command-line class for Apache FOP.
*/
-public class Main {
+public final class Main {
+
+ private Main() {
+ }
/**
* @return the list of URLs to all libraries.
diff --git a/src/java/org/apache/fop/datatypes/FODimension.java b/src/java/org/apache/fop/datatypes/FODimension.java
index cf8acdbb5..e1a94d087 100644
--- a/src/java/org/apache/fop/datatypes/FODimension.java
+++ b/src/java/org/apache/fop/datatypes/FODimension.java
@@ -27,9 +27,9 @@ package org.apache.fop.datatypes;
public class FODimension {
/** distance (in millipoints) on the inline-progression-direction */
- public int ipd;
+ public int ipd; // CSOK: VisibilityModifier
/** distance (in millipoints) on the block-progression-direction */
- public int bpd;
+ public int bpd; // CSOK: VisibilityModifier
/**
* Constructor
@@ -41,6 +41,17 @@ public class FODimension {
this.bpd = bpd;
}
+ /** @return ipd */
+ public int getIPD() {
+ return ipd;
+ }
+
+ /** @return bpd */
+ public int getBPD() {
+ return bpd;
+ }
+
+ /** {@inheritDoc} */
public String toString() {
StringBuffer sb = new StringBuffer(super.toString());
sb.append(" {ipd=").append(Integer.toString(ipd));
diff --git a/src/java/org/apache/fop/datatypes/LengthBase.java b/src/java/org/apache/fop/datatypes/LengthBase.java
index 137ca94fa..00eaee8c8 100644
--- a/src/java/org/apache/fop/datatypes/LengthBase.java
+++ b/src/java/org/apache/fop/datatypes/LengthBase.java
@@ -62,7 +62,7 @@ public class LengthBase implements PercentBase {
/**
* logging instance
*/
- protected static Log log = LogFactory.getLog(LengthBase.class);
+ protected static final Log log = LogFactory.getLog(LengthBase.class);
/**
* The FO for which this property is to be calculated.
diff --git a/src/java/org/apache/fop/datatypes/Numeric.java b/src/java/org/apache/fop/datatypes/Numeric.java
index 32ae78921..2004c6721 100644
--- a/src/java/org/apache/fop/datatypes/Numeric.java
+++ b/src/java/org/apache/fop/datatypes/Numeric.java
@@ -29,15 +29,15 @@ import org.apache.fop.fo.expr.PropertyException;
* Numerics can be either absolute or relative. Relative numerics
* must be resolved against base value before the value can be used.
* <p>
- * To support relative numerics internally in the expresion parser and
- * during evaulation one additional methods exists: isAbsolute() which
+ * To support relative numerics internally in the expression parser and
+ * during evaluation one additional methods exists: isAbsolute() which
* return true for absolute numerics and false for relative numerics.
*/
public interface Numeric {
/**
* Return the value of this Numeric
* @return the computed value.
- * @throws PropertyException
+ * @throws PropertyException if a property exception occurs
*/
double getNumericValue() throws PropertyException;
@@ -45,7 +45,7 @@ public interface Numeric {
* Return the value of this Numeric
* @param context The context for the length calculation (for percentage based lengths)
* @return the computed value.
- * @throws PropertyException
+ * @throws PropertyException if a property exception occurs
*/
double getNumericValue(PercentBaseContext context) throws PropertyException;
@@ -68,19 +68,19 @@ public interface Numeric {
* Returns the value of this numeric as an int.
* @return the value as an integer.
*/
- public int getValue();
+ int getValue();
/**
* Returns the value of this numeric as an int.
* @param context the context for the length calculation (for percentage based lengths)
* @return the value as an integer.
*/
- public int getValue(PercentBaseContext context);
+ int getValue(PercentBaseContext context);
/**
- * Return the resolved value. This method will becalled during evaluation
+ * Return the resolved value. This method will be called during evaluation
* of the expression tree and relative numerics can then return a
- * resolved absolute Numeric. Absolute numerics can just return themself.
+ * resolved absolute Numeric. Absolute numerics can just return themselves.
*
* @return A resolved value.
* @throws PropertyException
@@ -89,6 +89,7 @@ public interface Numeric {
/**
* Return the enum value that is stored in this numeric.
+ * @return the enum value
*/
- public int getEnum();
+ int getEnum();
}
diff --git a/src/java/org/apache/fop/datatypes/PercentBaseContext.java b/src/java/org/apache/fop/datatypes/PercentBaseContext.java
index 9744f417e..b04f774cf 100644
--- a/src/java/org/apache/fop/datatypes/PercentBaseContext.java
+++ b/src/java/org/apache/fop/datatypes/PercentBaseContext.java
@@ -36,6 +36,6 @@ public interface PercentBaseContext {
* @param fobj The FO object against which the percentage should be evaluated
* @return The base length value of the given kind
*/
- public int getBaseLength(int lengthBase, FObj fobj);
+ int getBaseLength(int lengthBase, FObj fobj);
}
diff --git a/src/java/org/apache/fop/datatypes/URISpecification.java b/src/java/org/apache/fop/datatypes/URISpecification.java
index 9311851ea..b1a1d84d4 100644
--- a/src/java/org/apache/fop/datatypes/URISpecification.java
+++ b/src/java/org/apache/fop/datatypes/URISpecification.java
@@ -25,7 +25,10 @@ import java.io.UnsupportedEncodingException;
/**
* This class contains method to deal with the <uri-specification> datatype from XSL-FO.
*/
-public class URISpecification {
+public final class URISpecification {
+
+ private URISpecification() {
+ }
/**
* Get the URL string from a wrapped URL.
@@ -94,7 +97,7 @@ public class URISpecification {
return false;
}
- private final static char[] HEX_DIGITS = {
+ private static final char[] HEX_DIGITS = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
};
diff --git a/src/java/org/apache/fop/events/Event.java b/src/java/org/apache/fop/events/Event.java
index c48530c1c..ffec9473e 100644
--- a/src/java/org/apache/fop/events/Event.java
+++ b/src/java/org/apache/fop/events/Event.java
@@ -38,7 +38,7 @@ public class Event extends EventObject {
private String eventKey;
private EventSeverity severity;
- private Map params;
+ private Map<String, Object> params;
/**
* Creates a new Event.
@@ -47,7 +47,8 @@ public class Event extends EventObject {
* @param severity the severity level
* @param params the event parameters (a map of name/value pairs)
*/
- public Event(Object source, String eventID, EventSeverity severity, Map params) {
+ public Event(Object source, String eventID, EventSeverity severity, Map<String, Object> params)
+ {
super(source);
int pos = eventID.lastIndexOf('.');
if (pos < 0 || pos == eventID.length() - 1) {
@@ -122,7 +123,7 @@ public class Event extends EventObject {
* Returns an unmodifiable {@link java.util.Map} with all event parameters.
* @return the parameter map
*/
- public Map getParams() {
+ public Map<String, Object> getParams() {
return Collections.unmodifiableMap(this.params);
}
@@ -138,7 +139,7 @@ public class Event extends EventObject {
* This class is a fluent builder class for building up the parameter map.
*/
public static class ParamsBuilder {
- private Map params;
+ private Map<String, Object> params;
/**
* Adds a new parameter (a name/value pair).
@@ -148,7 +149,7 @@ public class Event extends EventObject {
*/
public ParamsBuilder param(String name, Object value) {
if (this.params == null) {
- this.params = new java.util.HashMap();
+ this.params = new java.util.HashMap<String, Object>();
}
this.params.put(name, value);
return this;
@@ -158,7 +159,7 @@ public class Event extends EventObject {
* Returns the accumulated parameter map.
* @return the accumulated parameter map
*/
- public Map build() {
+ public Map<String, Object> build() {
return this.params;
}
}
diff --git a/src/java/org/apache/fop/events/EventExceptionManager.java b/src/java/org/apache/fop/events/EventExceptionManager.java
index 1072600c9..3494dc560 100644
--- a/src/java/org/apache/fop/events/EventExceptionManager.java
+++ b/src/java/org/apache/fop/events/EventExceptionManager.java
@@ -27,13 +27,17 @@ import org.apache.xmlgraphics.util.Service;
/**
* This class is responsible for converting events into exceptions.
*/
-public class EventExceptionManager {
+public final class EventExceptionManager {
- private static final Map EXCEPTION_FACTORIES = new java.util.HashMap();
+ private EventExceptionManager() {
+ }
+
+ private static final Map<String, ExceptionFactory> EXCEPTION_FACTORIES
+ = new java.util.HashMap<String, ExceptionFactory>();
static {
- Iterator iter;
- iter = Service.providers(ExceptionFactory.class, true);
+ Iterator<Object> iter;
+ iter = Service.providers(ExceptionFactory.class);
while (iter.hasNext()) {
ExceptionFactory factory = (ExceptionFactory)iter.next();
EXCEPTION_FACTORIES.put(factory.getExceptionClass().getName(), factory);
@@ -60,7 +64,7 @@ public class EventExceptionManager {
String msg = EventFormatter.format(event);
//Get original exception as cause if it is given as one of the parameters
Throwable t = null;
- Iterator iter = event.getParams().values().iterator();
+ Iterator<Object> iter = event.getParams().values().iterator();
while (iter.hasNext()) {
Object o = iter.next();
if (o instanceof Throwable) {
@@ -93,6 +97,6 @@ public class EventExceptionManager {
* Returns the {@link Exception} class created by this factory.
* @return the exception class
*/
- Class getExceptionClass();
+ Class<? extends Exception> getExceptionClass();
}
}
diff --git a/src/java/org/apache/fop/events/PropertyExceptionFactory.java b/src/java/org/apache/fop/events/PropertyExceptionFactory.java
index 753019b31..d8c7f39fb 100644
--- a/src/java/org/apache/fop/events/PropertyExceptionFactory.java
+++ b/src/java/org/apache/fop/events/PropertyExceptionFactory.java
@@ -40,7 +40,7 @@ public class PropertyExceptionFactory implements ExceptionFactory {
}
/** {@inheritDoc} */
- public Class getExceptionClass() {
+ public Class<PropertyException> getExceptionClass() {
return PropertyException.class;
}
diff --git a/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java b/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java
index 7ec9d19b2..570fcbd64 100644
--- a/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java
+++ b/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java
@@ -36,7 +36,7 @@ public class UnsupportedOperationExceptionFactory implements ExceptionFactory {
}
/** {@inheritDoc} */
- public Class getExceptionClass() {
+ public Class<UnsupportedOperationException> getExceptionClass() {
return UnsupportedOperationException.class;
}
diff --git a/src/java/org/apache/fop/events/ValidationExceptionFactory.java b/src/java/org/apache/fop/events/ValidationExceptionFactory.java
index 760c4ec58..2c7c69ce9 100644
--- a/src/java/org/apache/fop/events/ValidationExceptionFactory.java
+++ b/src/java/org/apache/fop/events/ValidationExceptionFactory.java
@@ -43,7 +43,7 @@ public class ValidationExceptionFactory implements ExceptionFactory {
}
/** {@inheritDoc} */
- public Class getExceptionClass() {
+ public Class<ValidationException> getExceptionClass() {
return ValidationException.class;
}
diff --git a/src/java/org/apache/fop/events/model/EventModelParser.java b/src/java/org/apache/fop/events/model/EventModelParser.java
index ddb1bf663..5441d1c4f 100644
--- a/src/java/org/apache/fop/events/model/EventModelParser.java
+++ b/src/java/org/apache/fop/events/model/EventModelParser.java
@@ -40,10 +40,13 @@ import org.apache.fop.util.DefaultErrorListener;
/**
* This is a parser for the event model XML.
*/
-public class EventModelParser {
+public final class EventModelParser {
+
+ private EventModelParser() {
+ }
/** Logger instance */
- protected static Log log = LogFactory.getLog(EventModelParser.class);
+ private static final Log LOG = LogFactory.getLog(EventModelParser.class);
private static SAXTransformerFactory tFactory
= (SAXTransformerFactory)SAXTransformerFactory.newInstance();
@@ -57,7 +60,7 @@ public class EventModelParser {
public static EventModel parse(Source src)
throws TransformerException {
Transformer transformer = tFactory.newTransformer();
- transformer.setErrorListener(new DefaultErrorListener(log));
+ transformer.setErrorListener(new DefaultErrorListener(LOG));
EventModel model = new EventModel();
SAXResult res = new SAXResult(getContentHandler(model));
diff --git a/src/java/org/apache/fop/fo/ElementMapping.java b/src/java/org/apache/fop/fo/ElementMapping.java
index 1651f23a6..befb65eff 100644
--- a/src/java/org/apache/fop/fo/ElementMapping.java
+++ b/src/java/org/apache/fop/fo/ElementMapping.java
@@ -30,7 +30,7 @@ import org.apache.xmlgraphics.util.QName;
/**
* Abstract base class for Element Mappings (including FO Element Mappings)
- * which provide the framework of valid elements and attibutes for a given
+ * which provide the framework of valid elements and attributes for a given
* namespace.
*/
public abstract class ElementMapping {
@@ -38,7 +38,7 @@ public abstract class ElementMapping {
public static final String DEFAULT = "<default>";
/** The HashMap table of formatting objects defined by the ElementMapping */
- protected HashMap foObjs = null;
+ protected HashMap<String, Maker> foObjs = null;
//Please don't change that to java.util.Map as that can break extensions.
/** The namespace for the ElementMapping */
@@ -49,7 +49,7 @@ public abstract class ElementMapping {
*
* @return Table of Maker objects for this ElementMapping
*/
- public HashMap getTable() {
+ public HashMap<String, Maker> getTable() {
if (foObjs == null) {
initialize();
}
diff --git a/src/java/org/apache/fop/fo/ElementMappingRegistry.java b/src/java/org/apache/fop/fo/ElementMappingRegistry.java
index 4a6904f73..cf14fa281 100644
--- a/src/java/org/apache/fop/fo/ElementMappingRegistry.java
+++ b/src/java/org/apache/fop/fo/ElementMappingRegistry.java
@@ -48,12 +48,14 @@ public class ElementMappingRegistry {
* Table mapping element names to the makers of objects
* representing formatting objects.
*/
- protected Map fobjTable = new java.util.HashMap();
+ protected Map<String, Map<String, Maker>> fobjTable
+ = new java.util.HashMap<String, Map<String, Maker>>();
/**
* Map of mapped namespaces and their associated ElementMapping instances.
*/
- protected Map namespaces = new java.util.HashMap();
+ protected Map<String, ElementMapping> namespaces
+ = new java.util.HashMap<String, ElementMapping>();
/**
* Main constructor. Adds all default element mapping as well as detects ElementMapping
@@ -70,10 +72,10 @@ public class ElementMappingRegistry {
*/
private void setupDefaultMappings() {
// add mappings from available services
- Iterator providers = Service.providers(ElementMapping.class, false);
+ Iterator<String> providers = Service.providerNames(ElementMapping.class);
if (providers != null) {
while (providers.hasNext()) {
- String mapping = (String)providers.next();
+ String mapping = providers.next();
try {
addElementMapping(mapping);
} catch (IllegalArgumentException e) {
@@ -129,13 +131,13 @@ public class ElementMappingRegistry {
*/
public Maker findFOMaker(String namespaceURI, String localName, Locator locator)
throws FOPException {
- Map table = (Map)fobjTable.get(namespaceURI);
+ Map<String, Maker> table = fobjTable.get(namespaceURI);
Maker fobjMaker = null;
if (table != null) {
- fobjMaker = (Maker)table.get(localName);
+ fobjMaker = table.get(localName);
// try default
if (fobjMaker == null) {
- fobjMaker = (Maker)table.get(ElementMapping.DEFAULT);
+ fobjMaker = table.get(ElementMapping.DEFAULT);
}
}
diff --git a/src/java/org/apache/fop/fo/FOElementMapping.java b/src/java/org/apache/fop/fo/FOElementMapping.java
index 0a7e40955..8069880c6 100644
--- a/src/java/org/apache/fop/fo/FOElementMapping.java
+++ b/src/java/org/apache/fop/fo/FOElementMapping.java
@@ -44,7 +44,7 @@ public class FOElementMapping extends ElementMapping {
*/
protected void initialize() {
if (foObjs == null) {
- foObjs = new HashMap();
+ foObjs = new HashMap<String, Maker>();
// Declarations and Pagination and Layout Formatting Objects
foObjs.put("root", new RootMaker());
diff --git a/src/java/org/apache/fop/fo/FOEventHandler.java b/src/java/org/apache/fop/fo/FOEventHandler.java
index 238a4ced6..e280af2d7 100644
--- a/src/java/org/apache/fop/fo/FOEventHandler.java
+++ b/src/java/org/apache/fop/fo/FOEventHandler.java
@@ -40,11 +40,10 @@ import org.apache.fop.fo.flow.PageNumberCitation;
import org.apache.fop.fo.flow.PageNumberCitationLast;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableBody;
-import org.apache.fop.fo.flow.table.TableFooter;
-import org.apache.fop.fo.flow.table.TableHeader;
-import org.apache.fop.fo.flow.table.TablePart;
import org.apache.fop.fo.flow.table.TableCell;
import org.apache.fop.fo.flow.table.TableColumn;
+import org.apache.fop.fo.flow.table.TableFooter;
+import org.apache.fop.fo.flow.table.TableHeader;
import org.apache.fop.fo.flow.table.TableRow;
import org.apache.fop.fo.pagination.Flow;
import org.apache.fop.fo.pagination.PageSequence;
diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java
index bbe3ce3a3..c9c04aa4e 100644
--- a/src/java/org/apache/fop/fo/FONode.java
+++ b/src/java/org/apache/fop/fo/FONode.java
@@ -69,7 +69,7 @@ public abstract class FONode implements Cloneable {
protected Locator locator;
/** Logger for fo-tree related messages **/
- protected static Log log = LogFactory.getLog(FONode.class);
+ protected static final Log log = LogFactory.getLog(FONode.class);
/**
* Base constructor
@@ -633,8 +633,9 @@ public abstract class FONode implements Cloneable {
* this method only in exceptional conditions because this method may perform quite extensive
* information gathering inside the FO tree.
* @return a String containing context information
- * @deprecated Not localized! Should rename getContextInfoAlt() to getContextInfo() when done!
*/
+ // [GA] remove deprecation - no alternative specified
+ // @deprecated Not localized! Should rename getContextInfoAlt() to getContextInfo() when done!
public String getContextInfo() {
StringBuffer sb = new StringBuffer();
if (getLocalName() != null) {
@@ -797,8 +798,9 @@ public abstract class FONode implements Cloneable {
/**
* This method is overridden by extension elements and allows the extension element to return
- * a {@link ContentHandlerFactory}. This factory can create ContentHandler implementations that handle
- * foreign XML content by either building up a specific DOM, a Java object or something else.
+ * a {@link ContentHandlerFactory}. This factory can create ContentHandler implementations that
+ * handle foreign XML content by either building up a specific DOM, a Java object or something
+ * else.
*
* @return the <code>ContentHandlerFactory</code> or <code>null</code> if not applicable
*/
diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java
index 07fb20fd8..c711a76c0 100644
--- a/src/java/org/apache/fop/fo/FOPropertyMapping.java
+++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java
@@ -72,16 +72,20 @@ import org.apache.fop.fo.properties.XMLLangShorthandParser;
* This class creates and returns an array of Property.Maker instances
* indexed by the PR_* propId from Constants.java.
*
- * @todo Check multi-threading safety of the statics below
+ * TODO Check multi-threading safety of the statics below
*/
public final class FOPropertyMapping implements Constants {
- private static Map s_htPropNames = new HashMap();
- private static Map s_htSubPropNames = new HashMap();
- private static Map s_htPropIds = new HashMap();
- private static PropertyMaker[] s_generics = null;
+ private FOPropertyMapping() {
+ }
+
+ private static Map propNames = new HashMap(); // CSOK: VisibilityModifier
+ private static Map subPropNames = new HashMap(); // CSOK: VisibilityModifier
+ private static Map propIds = new HashMap(); // CSOK: VisibilityModifier
+
+ private static PropertyMaker[] generics = null; // CSOK: VisibilityModifier
- // The rest is only used during the building of the s_generics array.
+ // The rest is only used during the building of the generics array.
private Property[] enums = null;
private PropertyMaker genericColor = null;
@@ -154,7 +158,7 @@ public final class FOPropertyMapping implements Constants {
genericPadding.setInherited(false);
genericPadding.setDefault("0pt");
genericPadding.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
- genericPadding.addShorthand(s_generics[PR_PADDING]);
+ genericPadding.addShorthand(generics[PR_PADDING]);
// GenericCondBorderWidth
genericCondBorderWidth = new CondLengthProperty.Maker(0);
@@ -235,15 +239,15 @@ public final class FOPropertyMapping implements Constants {
/**
* Add a property maker to the generics array.
- * Also creates the name <-> id mapping in s_htPropNames and s_htPropIds.
+ * Also creates the name <-> id mapping in propNames and propIds.
*
* @param name the name of the property maker.
* @param maker the maker.
*/
private static void addPropertyMaker(String name, PropertyMaker maker) {
- s_generics[maker.getPropId()] = maker;
- s_htPropNames.put(name, new Integer(maker.getPropId()));
- s_htPropIds.put(new Integer(maker.getPropId()), name);
+ generics[maker.getPropId()] = maker;
+ propNames.put(name, new Integer(maker.getPropId()));
+ propIds.put(new Integer(maker.getPropId()), name);
}
/**
@@ -252,8 +256,8 @@ public final class FOPropertyMapping implements Constants {
* @param id Id for the subproperty from CP_* in Constants.java.
*/
private static void addSubpropMakerName(String name, int id) {
- s_htSubPropNames.put(name, new Integer(id));
- s_htPropIds.put(new Integer(id), name);
+ subPropNames.put(name, new Integer(id));
+ propIds.put(new Integer(id), name);
}
/**
@@ -278,9 +282,9 @@ public final class FOPropertyMapping implements Constants {
*/
public static PropertyMaker[] getGenericMappings() {
- if (s_generics == null) {
+ if (generics == null) {
/* this method was never called before */
- s_generics = new PropertyMaker[PROPERTY_COUNT + 1];
+ generics = new PropertyMaker[PROPERTY_COUNT + 1];
FOPropertyMapping gp = new FOPropertyMapping();
/* Create the shorthand first. They are
@@ -328,7 +332,7 @@ public final class FOPropertyMapping implements Constants {
addSubpropMakerName("precedence", CP_PRECEDENCE);
}
- return s_generics;
+ return generics;
}
/**
@@ -338,7 +342,7 @@ public final class FOPropertyMapping implements Constants {
*/
public static int getPropertyId(String name) {
if (name != null) {
- Integer i = (Integer) s_htPropNames.get(name);
+ Integer i = (Integer) propNames.get(name);
if (i != null) {
return i.intValue();
}
@@ -353,7 +357,7 @@ public final class FOPropertyMapping implements Constants {
*/
public static int getSubPropertyId(String name) {
if (name != null) {
- Integer i = (Integer) s_htSubPropNames.get(name);
+ Integer i = (Integer) subPropNames.get(name);
if (i != null) {
return i.intValue();
}
@@ -369,10 +373,10 @@ public final class FOPropertyMapping implements Constants {
public static String getPropertyName(int id) {
if (((id & Constants.COMPOUND_MASK) == 0)
|| ((id & Constants.PROPERTY_MASK) == 0)) {
- return (String) s_htPropIds.get(new Integer(id));
+ return (String) propIds.get(new Integer(id));
} else {
- return s_htPropIds.get(new Integer(id & Constants.PROPERTY_MASK))
- + "." + s_htPropIds.get(new Integer(id & Constants.COMPOUND_MASK));
+ return propIds.get(new Integer(id & Constants.PROPERTY_MASK))
+ + "." + propIds.get(new Integer(id & Constants.COMPOUND_MASK));
}
}
@@ -403,7 +407,7 @@ public final class FOPropertyMapping implements Constants {
m.addEnum("fixed", getEnumProperty(EN_FIXED, "FIXED"));
m.addEnum("absolute", getEnumProperty(EN_ABSOLUTE, "ABSOLUTE"));
m.setDefault("auto");
- m.addShorthand(s_generics[PR_POSITION]);
+ m.addShorthand(generics[PR_POSITION]);
addPropertyMaker("absolute-position", m);
// top
@@ -551,7 +555,7 @@ public final class FOPropertyMapping implements Constants {
addPropertyMaker("volume", m);
}
- private void createBorderPaddingBackgroundProperties() {
+ private void createBorderPaddingBackgroundProperties() { // CSOK: MethodLength
PropertyMaker m;
BorderWidthPropertyMaker bwm;
CorrespondingPropertyMaker corr;
@@ -606,7 +610,7 @@ public final class FOPropertyMapping implements Constants {
m.addKeyword("center", "50%");
m.addKeyword("right", "100%");
m.setPercentBase(LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL);
- m.addShorthand(s_generics[PR_BACKGROUND_POSITION]);
+ m.addShorthand(generics[PR_BACKGROUND_POSITION]);
addPropertyMaker("background-position-horizontal", m);
// background-position-vertical
@@ -617,7 +621,7 @@ public final class FOPropertyMapping implements Constants {
m.addKeyword("center", "50%");
m.addKeyword("bottom", "100%");
m.setPercentBase(LengthBase.IMAGE_BACKGROUND_POSITION_VERTICAL);
- m.addShorthand(s_generics[PR_BACKGROUND_POSITION]);
+ m.addShorthand(generics[PR_BACKGROUND_POSITION]);
addPropertyMaker("background-position-vertical", m);
// border-before-color
@@ -745,9 +749,9 @@ public final class FOPropertyMapping implements Constants {
m.useGeneric(genericColor);
m.setInherited(false);
m.setDefault("black");
- m.addShorthand(s_generics[PR_BORDER_TOP]);
- m.addShorthand(s_generics[PR_BORDER_COLOR]);
- m.addShorthand(s_generics[PR_BORDER]);
+ m.addShorthand(generics[PR_BORDER_TOP]);
+ m.addShorthand(generics[PR_BORDER_COLOR]);
+ m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_BEFORE_COLOR, PR_BORDER_BEFORE_COLOR,
PR_BORDER_START_COLOR);
@@ -756,9 +760,9 @@ public final class FOPropertyMapping implements Constants {
// border-top-style
m = new EnumProperty.Maker(PR_BORDER_TOP_STYLE);
m.useGeneric(genericBorderStyle);
- m.addShorthand(s_generics[PR_BORDER_TOP]);
- m.addShorthand(s_generics[PR_BORDER_STYLE]);
- m.addShorthand(s_generics[PR_BORDER]);
+ m.addShorthand(generics[PR_BORDER_TOP]);
+ m.addShorthand(generics[PR_BORDER_STYLE]);
+ m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_BEFORE_STYLE, PR_BORDER_BEFORE_STYLE,
PR_BORDER_START_STYLE);
@@ -768,9 +772,9 @@ public final class FOPropertyMapping implements Constants {
bwm = new BorderWidthPropertyMaker(PR_BORDER_TOP_WIDTH);
bwm.useGeneric(genericBorderWidth);
bwm.setBorderStyleId(PR_BORDER_TOP_STYLE);
- bwm.addShorthand(s_generics[PR_BORDER_TOP]);
- bwm.addShorthand(s_generics[PR_BORDER_WIDTH]);
- bwm.addShorthand(s_generics[PR_BORDER]);
+ bwm.addShorthand(generics[PR_BORDER_TOP]);
+ bwm.addShorthand(generics[PR_BORDER_WIDTH]);
+ bwm.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(bwm);
corr.setCorresponding(PR_BORDER_BEFORE_WIDTH, PR_BORDER_BEFORE_WIDTH,
PR_BORDER_START_WIDTH);
@@ -781,9 +785,9 @@ public final class FOPropertyMapping implements Constants {
m.useGeneric(genericColor);
m.setInherited(false);
m.setDefault("black");
- m.addShorthand(s_generics[PR_BORDER_BOTTOM]);
- m.addShorthand(s_generics[PR_BORDER_COLOR]);
- m.addShorthand(s_generics[PR_BORDER]);
+ m.addShorthand(generics[PR_BORDER_BOTTOM]);
+ m.addShorthand(generics[PR_BORDER_COLOR]);
+ m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_AFTER_COLOR, PR_BORDER_AFTER_COLOR,
PR_BORDER_END_COLOR);
@@ -792,9 +796,9 @@ public final class FOPropertyMapping implements Constants {
// border-bottom-style
m = new EnumProperty.Maker(PR_BORDER_BOTTOM_STYLE);
m.useGeneric(genericBorderStyle);
- m.addShorthand(s_generics[PR_BORDER_BOTTOM]);
- m.addShorthand(s_generics[PR_BORDER_STYLE]);
- m.addShorthand(s_generics[PR_BORDER]);
+ m.addShorthand(generics[PR_BORDER_BOTTOM]);
+ m.addShorthand(generics[PR_BORDER_STYLE]);
+ m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_AFTER_STYLE, PR_BORDER_AFTER_STYLE,
PR_BORDER_END_STYLE);
@@ -804,9 +808,9 @@ public final class FOPropertyMapping implements Constants {
bwm = new BorderWidthPropertyMaker(PR_BORDER_BOTTOM_WIDTH);
bwm.useGeneric(genericBorderWidth);
bwm.setBorderStyleId(PR_BORDER_BOTTOM_STYLE);
- bwm.addShorthand(s_generics[PR_BORDER_BOTTOM]);
- bwm.addShorthand(s_generics[PR_BORDER_WIDTH]);
- bwm.addShorthand(s_generics[PR_BORDER]);
+ bwm.addShorthand(generics[PR_BORDER_BOTTOM]);
+ bwm.addShorthand(generics[PR_BORDER_WIDTH]);
+ bwm.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(bwm);
corr.setCorresponding(PR_BORDER_AFTER_WIDTH, PR_BORDER_AFTER_WIDTH,
PR_BORDER_END_WIDTH);
@@ -817,9 +821,9 @@ public final class FOPropertyMapping implements Constants {
m.useGeneric(genericColor);
m.setInherited(false);
m.setDefault("black");
- m.addShorthand(s_generics[PR_BORDER_LEFT]);
- m.addShorthand(s_generics[PR_BORDER_COLOR]);
- m.addShorthand(s_generics[PR_BORDER]);
+ m.addShorthand(generics[PR_BORDER_LEFT]);
+ m.addShorthand(generics[PR_BORDER_COLOR]);
+ m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_START_COLOR, PR_BORDER_END_COLOR,
PR_BORDER_AFTER_COLOR);
@@ -828,9 +832,9 @@ public final class FOPropertyMapping implements Constants {
// border-left-style
m = new EnumProperty.Maker(PR_BORDER_LEFT_STYLE);
m.useGeneric(genericBorderStyle);
- m.addShorthand(s_generics[PR_BORDER_LEFT]);
- m.addShorthand(s_generics[PR_BORDER_STYLE]);
- m.addShorthand(s_generics[PR_BORDER]);
+ m.addShorthand(generics[PR_BORDER_LEFT]);
+ m.addShorthand(generics[PR_BORDER_STYLE]);
+ m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_START_STYLE, PR_BORDER_END_STYLE,
PR_BORDER_AFTER_STYLE);
@@ -840,9 +844,9 @@ public final class FOPropertyMapping implements Constants {
bwm = new BorderWidthPropertyMaker(PR_BORDER_LEFT_WIDTH);
bwm.useGeneric(genericBorderWidth);
bwm.setBorderStyleId(PR_BORDER_LEFT_STYLE);
- bwm.addShorthand(s_generics[PR_BORDER_LEFT]);
- bwm.addShorthand(s_generics[PR_BORDER_WIDTH]);
- bwm.addShorthand(s_generics[PR_BORDER]);
+ bwm.addShorthand(generics[PR_BORDER_LEFT]);
+ bwm.addShorthand(generics[PR_BORDER_WIDTH]);
+ bwm.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(bwm);
corr.setCorresponding(PR_BORDER_START_WIDTH, PR_BORDER_END_WIDTH,
PR_BORDER_AFTER_WIDTH);
@@ -853,9 +857,9 @@ public final class FOPropertyMapping implements Constants {
m.useGeneric(genericColor);
m.setInherited(false);
m.setDefault("black");
- m.addShorthand(s_generics[PR_BORDER_RIGHT]);
- m.addShorthand(s_generics[PR_BORDER_COLOR]);
- m.addShorthand(s_generics[PR_BORDER]);
+ m.addShorthand(generics[PR_BORDER_RIGHT]);
+ m.addShorthand(generics[PR_BORDER_COLOR]);
+ m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_END_COLOR, PR_BORDER_START_COLOR,
PR_BORDER_BEFORE_COLOR);
@@ -864,9 +868,9 @@ public final class FOPropertyMapping implements Constants {
// border-right-style
m = new EnumProperty.Maker(PR_BORDER_RIGHT_STYLE);
m.useGeneric(genericBorderStyle);
- m.addShorthand(s_generics[PR_BORDER_RIGHT]);
- m.addShorthand(s_generics[PR_BORDER_STYLE]);
- m.addShorthand(s_generics[PR_BORDER]);
+ m.addShorthand(generics[PR_BORDER_RIGHT]);
+ m.addShorthand(generics[PR_BORDER_STYLE]);
+ m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_END_STYLE, PR_BORDER_START_STYLE,
PR_BORDER_BEFORE_STYLE);
@@ -876,9 +880,9 @@ public final class FOPropertyMapping implements Constants {
bwm = new BorderWidthPropertyMaker(PR_BORDER_RIGHT_WIDTH);
bwm.useGeneric(genericBorderWidth);
bwm.setBorderStyleId(PR_BORDER_RIGHT_STYLE);
- bwm.addShorthand(s_generics[PR_BORDER_RIGHT]);
- bwm.addShorthand(s_generics[PR_BORDER_WIDTH]);
- bwm.addShorthand(s_generics[PR_BORDER]);
+ bwm.addShorthand(generics[PR_BORDER_RIGHT]);
+ bwm.addShorthand(generics[PR_BORDER_WIDTH]);
+ bwm.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(bwm);
corr.setCorresponding(PR_BORDER_END_WIDTH, PR_BORDER_START_WIDTH,
PR_BORDER_BEFORE_WIDTH);
@@ -964,7 +968,7 @@ public final class FOPropertyMapping implements Constants {
m = new FontFamilyProperty.Maker(PR_FONT_FAMILY);
m.setInherited(true);
m.setDefault("sans-serif,Symbol,ZapfDingbats");
- m.addShorthand(s_generics[PR_FONT]);
+ m.addShorthand(generics[PR_FONT]);
addPropertyMaker("font-family", m);
// font-selection-strategy
@@ -990,7 +994,7 @@ public final class FOPropertyMapping implements Constants {
m.addEnum("larger", getEnumProperty(EN_LARGER, "LARGER"));
m.addEnum("smaller", getEnumProperty(EN_SMALLER, "SMALLER"));
m.setPercentBase(LengthBase.INH_FONTSIZE);
- m.addShorthand(s_generics[PR_FONT]);
+ m.addShorthand(generics[PR_FONT]);
addPropertyMaker("font-size", m);
// font-stretch
@@ -1024,7 +1028,7 @@ public final class FOPropertyMapping implements Constants {
m.addEnum("oblique", getEnumProperty(EN_OBLIQUE, "OBLIQUE"));
m.addEnum("backslant", getEnumProperty(EN_BACKSLANT, "BACKSLANT"));
m.setDefault("normal");
- m.addShorthand(s_generics[PR_FONT]);
+ m.addShorthand(generics[PR_FONT]);
addPropertyMaker("font-style", m);
// font-variant
@@ -1033,7 +1037,7 @@ public final class FOPropertyMapping implements Constants {
m.addEnum("normal", getEnumProperty(EN_NORMAL, "NORMAL"));
m.addEnum("small-caps", getEnumProperty(EN_SMALL_CAPS, "SMALL_CAPS"));
m.setDefault("normal");
- m.addShorthand(s_generics[PR_FONT]);
+ m.addShorthand(generics[PR_FONT]);
addPropertyMaker("font-variant", m);
// font-weight
@@ -1053,7 +1057,7 @@ public final class FOPropertyMapping implements Constants {
m.addEnum("800", getEnumProperty(EN_800, "800"));
m.addEnum("900", getEnumProperty(EN_900, "900"));
m.setDefault("400");
- m.addShorthand(s_generics[PR_FONT]);
+ m.addShorthand(generics[PR_FONT]);
addPropertyMaker("font-weight", m);
}
@@ -1064,14 +1068,14 @@ public final class FOPropertyMapping implements Constants {
m = new StringProperty.Maker(PR_COUNTRY);
m.setInherited(true);
m.setDefault("none");
- m.addShorthand(s_generics[PR_XML_LANG]);
+ m.addShorthand(generics[PR_XML_LANG]);
addPropertyMaker("country", m);
// language
m = new StringProperty.Maker(PR_LANGUAGE);
m.setInherited(true);
m.setDefault("none");
- m.addShorthand(s_generics[PR_XML_LANG]);
+ m.addShorthand(generics[PR_XML_LANG]);
addPropertyMaker("language", m);
// script
@@ -1114,7 +1118,7 @@ public final class FOPropertyMapping implements Constants {
m = new LengthProperty.Maker(PR_MARGIN_TOP);
m.setInherited(false);
m.setDefault("0pt");
- m.addShorthand(s_generics[PR_MARGIN]);
+ m.addShorthand(generics[PR_MARGIN]);
m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
addPropertyMaker("margin-top", m);
@@ -1122,7 +1126,7 @@ public final class FOPropertyMapping implements Constants {
m = new LengthProperty.Maker(PR_MARGIN_BOTTOM);
m.setInherited(false);
m.setDefault("0pt");
- m.addShorthand(s_generics[PR_MARGIN]);
+ m.addShorthand(generics[PR_MARGIN]);
m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
addPropertyMaker("margin-bottom", m);
@@ -1130,7 +1134,7 @@ public final class FOPropertyMapping implements Constants {
m = new LengthProperty.Maker(PR_MARGIN_LEFT);
m.setInherited(false);
m.setDefault("0pt");
- m.addShorthand(s_generics[PR_MARGIN]);
+ m.addShorthand(generics[PR_MARGIN]);
m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
addPropertyMaker("margin-left", m);
@@ -1138,7 +1142,7 @@ public final class FOPropertyMapping implements Constants {
m = new LengthProperty.Maker(PR_MARGIN_RIGHT);
m.setInherited(false);
m.setDefault("0pt");
- m.addShorthand(s_generics[PR_MARGIN]);
+ m.addShorthand(generics[PR_MARGIN]);
m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH);
addPropertyMaker("margin-right", m);
@@ -1218,7 +1222,7 @@ public final class FOPropertyMapping implements Constants {
m.addEnum("static", getEnumProperty(EN_STATIC, "STATIC"));
m.addEnum("relative", getEnumProperty(EN_RELATIVE, "RELATIVE"));
m.setDefault("static");
- m.addShorthand(s_generics[PR_POSITION]);
+ m.addShorthand(generics[PR_POSITION]);
addPropertyMaker("relative-position", m);
}
@@ -1242,7 +1246,7 @@ public final class FOPropertyMapping implements Constants {
m.addEnum("mathematical", getEnumProperty(EN_MATHEMATICAL, "MATHEMATICAL"));
m.setDefault("auto");
m.setPercentBase(LengthBase.ALIGNMENT_ADJUST);
- m.addShorthand(s_generics[PR_VERTICAL_ALIGN]);
+ m.addShorthand(generics[PR_VERTICAL_ALIGN]);
addPropertyMaker("alignment-adjust", m);
// alignment-baseline
@@ -1261,7 +1265,7 @@ public final class FOPropertyMapping implements Constants {
m.addEnum("hanging", getEnumProperty(EN_HANGING, "HANGING"));
m.addEnum("mathematical", getEnumProperty(EN_MATHEMATICAL, "MATHEMATICAL"));
m.setDefault("auto");
- m.addShorthand(s_generics[PR_VERTICAL_ALIGN]);
+ m.addShorthand(generics[PR_VERTICAL_ALIGN]);
addPropertyMaker("alignment-baseline", m);
// baseline-shift
@@ -1271,7 +1275,7 @@ public final class FOPropertyMapping implements Constants {
m.addEnum("sub", getEnumProperty(EN_SUB, "SUB"));
m.addEnum("super", getEnumProperty(EN_SUPER, "SUPER"));
m.setDefault("baseline");
- m.addShorthand(s_generics[PR_VERTICAL_ALIGN]);
+ m.addShorthand(generics[PR_VERTICAL_ALIGN]);
m.setPercentBase(LengthBase.CUSTOM_BASE);
addPropertyMaker("baseline-shift", m);
@@ -1303,7 +1307,7 @@ public final class FOPropertyMapping implements Constants {
m.addEnum("text-after-edge", getEnumProperty(EN_TEXT_AFTER_EDGE, "TEXT_AFTER_EDGE"));
m.addEnum("text-before-edge", getEnumProperty(EN_TEXT_BEFORE_EDGE, "TEXT_BEFORE_EDGE"));
m.setDefault("auto");
- m.addShorthand(s_generics[PR_VERTICAL_ALIGN]);
+ m.addShorthand(generics[PR_VERTICAL_ALIGN]);
addPropertyMaker("dominant-baseline", m);
// relative-align
@@ -1315,7 +1319,7 @@ public final class FOPropertyMapping implements Constants {
addPropertyMaker("relative-align", m);
}
- private void createAreaDimensionProperties() {
+ private void createAreaDimensionProperties() { // CSOK: MethodLength
PropertyMaker m;
LengthProperty.Maker l;
DimensionPropertyMaker pdim;
@@ -1464,8 +1468,10 @@ public final class FOPropertyMapping implements Constants {
m = new EnumProperty.Maker(PR_SCALING_METHOD);
m.setInherited(false);
m.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
- m.addEnum("integer-pixels", getEnumProperty(EN_INTEGER_PIXELS, "INTEGER_PIXELS"));
- m.addEnum("resample-any-method", getEnumProperty(EN_RESAMPLE_ANY_METHOD, "RESAMPLE_ANY_METHOD"));
+ m.addEnum("integer-pixels",
+ getEnumProperty(EN_INTEGER_PIXELS, "INTEGER_PIXELS"));
+ m.addEnum("resample-any-method",
+ getEnumProperty(EN_RESAMPLE_ANY_METHOD, "RESAMPLE_ANY_METHOD"));
m.setDefault("auto");
addPropertyMaker("scaling-method", m);
@@ -1484,7 +1490,7 @@ public final class FOPropertyMapping implements Constants {
addPropertyMaker("fox:block-progression-unit", l);
}
- private void createBlockAndLineProperties() {
+ private void createBlockAndLineProperties() { // CSOK: MethodLength
PropertyMaker m;
// hyphenation-keep
@@ -1517,7 +1523,7 @@ public final class FOPropertyMapping implements Constants {
m.addKeyword("normal", "1.2");
m.setPercentBase(LengthBase.FONTSIZE);
m.setDefault("normal", true);
- m.addShorthand(s_generics[PR_FONT]);
+ m.addShorthand(generics[PR_FONT]);
addPropertyMaker("line-height", m);
// line-height-shift-adjustment
@@ -1543,9 +1549,11 @@ public final class FOPropertyMapping implements Constants {
m.addEnum("ignore", getEnumProperty(EN_IGNORE, "IGNORE"));
m.addEnum("preserve", getEnumProperty(EN_PRESERVE, "PRESERVE"));
m.addEnum("treat-as-space", getEnumProperty(EN_TREAT_AS_SPACE, "TREAT_AS_SPACE"));
- m.addEnum("treat-as-zero-width-space", getEnumProperty(EN_TREAT_AS_ZERO_WIDTH_SPACE, "TREAT_AS_ZERO_WIDTH_SPACE"));
+ m.addEnum("treat-as-zero-width-space",
+ getEnumProperty(EN_TREAT_AS_ZERO_WIDTH_SPACE,
+ "TREAT_AS_ZERO_WIDTH_SPACE"));
m.setDefault("treat-as-space");
- m.addShorthand(s_generics[PR_WHITE_SPACE]);
+ m.addShorthand(generics[PR_WHITE_SPACE]);
addPropertyMaker("linefeed-treatment", m);
// white-space-treatment
@@ -1553,11 +1561,17 @@ public final class FOPropertyMapping implements Constants {
m.setInherited(true);
m.addEnum("ignore", getEnumProperty(EN_IGNORE, "IGNORE"));
m.addEnum("preserve", getEnumProperty(EN_PRESERVE, "PRESERVE"));
- m.addEnum("ignore-if-before-linefeed", getEnumProperty(EN_IGNORE_IF_BEFORE_LINEFEED, "IGNORE_IF_BEFORE_LINEFEED"));
- m.addEnum("ignore-if-after-linefeed", getEnumProperty(EN_IGNORE_IF_AFTER_LINEFEED, "IGNORE_IF_AFTER_LINEFEED"));
- m.addEnum("ignore-if-surrounding-linefeed", getEnumProperty(EN_IGNORE_IF_SURROUNDING_LINEFEED, "IGNORE_IF_SURROUNDING_LINEFEED"));
+ m.addEnum("ignore-if-before-linefeed",
+ getEnumProperty(EN_IGNORE_IF_BEFORE_LINEFEED,
+ "IGNORE_IF_BEFORE_LINEFEED"));
+ m.addEnum("ignore-if-after-linefeed",
+ getEnumProperty(EN_IGNORE_IF_AFTER_LINEFEED,
+ "IGNORE_IF_AFTER_LINEFEED"));
+ m.addEnum("ignore-if-surrounding-linefeed",
+ getEnumProperty(EN_IGNORE_IF_SURROUNDING_LINEFEED,
+ "IGNORE_IF_SURROUNDING_LINEFEED"));
m.setDefault("ignore-if-surrounding-linefeed");
- m.addShorthand(s_generics[PR_WHITE_SPACE]);
+ m.addShorthand(generics[PR_WHITE_SPACE]);
addPropertyMaker("white-space-treatment", m);
// text-align TODO: make it a StringProperty with enums.
@@ -1637,7 +1651,7 @@ public final class FOPropertyMapping implements Constants {
m.useGeneric(genericBoolean);
m.setInherited(true);
m.setDefault("true");
- m.addShorthand(s_generics[PR_WHITE_SPACE]);
+ m.addShorthand(generics[PR_WHITE_SPACE]);
addPropertyMaker("white-space-collapse", m);
// wrap-option
@@ -1646,7 +1660,7 @@ public final class FOPropertyMapping implements Constants {
m.addEnum("wrap", getEnumProperty(EN_WRAP, "WRAP"));
m.addEnum("no-wrap", getEnumProperty(EN_NO_WRAP, "NO_WRAP"));
m.setDefault("wrap");
- m.addShorthand(s_generics[PR_WHITE_SPACE]);
+ m.addShorthand(generics[PR_WHITE_SPACE]);
addPropertyMaker("wrap-option", m);
}
@@ -1750,9 +1764,11 @@ public final class FOPropertyMapping implements Constants {
m.setInherited(false);
m.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
m.addEnum("perceptual", getEnumProperty(EN_PERCEPTUAL, "PERCEPTUAL"));
- m.addEnum("relative-colorimetric", getEnumProperty(EN_RELATIVE_COLOMETRIC, "RELATIVE_COLOMETRIC"));
+ m.addEnum("relative-colorimetric", getEnumProperty(EN_RELATIVE_COLOMETRIC,
+ "RELATIVE_COLOMETRIC"));
m.addEnum("saturation", getEnumProperty(EN_SATURATION, "SATURATION"));
- m.addEnum("absolute-colorimetric", getEnumProperty(EN_ABSOLUTE_COLORMETRIC, "ABSOLUTE_COLORMETRIC"));
+ m.addEnum("absolute-colorimetric", getEnumProperty(EN_ABSOLUTE_COLORMETRIC,
+ "ABSOLUTE_COLORMETRIC"));
m.setDefault("auto");
addPropertyMaker("rendering-intent", m);
}
@@ -1804,13 +1820,13 @@ public final class FOPropertyMapping implements Constants {
// break-after
m = new EnumProperty.Maker(PR_BREAK_AFTER);
m.useGeneric(genericBreak);
- m.addShorthand(s_generics[PR_PAGE_BREAK_AFTER]);
+ m.addShorthand(generics[PR_PAGE_BREAK_AFTER]);
addPropertyMaker("break-after", m);
// break-before
m = new EnumProperty.Maker(PR_BREAK_BEFORE);
m.useGeneric(genericBreak);
- m.addShorthand(s_generics[PR_PAGE_BREAK_BEFORE]);
+ m.addShorthand(generics[PR_PAGE_BREAK_BEFORE]);
addPropertyMaker("break-before", m);
// keep-together
@@ -1818,7 +1834,7 @@ public final class FOPropertyMapping implements Constants {
m.useGeneric(genericKeep);
m.setInherited(true);
m.setDefault("auto");
- m.addShorthand(s_generics[PR_PAGE_BREAK_INSIDE]);
+ m.addShorthand(generics[PR_PAGE_BREAK_INSIDE]);
addPropertyMaker("keep-together", m);
// keep-with-next
@@ -1826,7 +1842,7 @@ public final class FOPropertyMapping implements Constants {
m.useGeneric(genericKeep);
m.setInherited(false);
m.setDefault("auto");
- m.addShorthand(s_generics[PR_PAGE_BREAK_AFTER]);
+ m.addShorthand(generics[PR_PAGE_BREAK_AFTER]);
addPropertyMaker("keep-with-next", m);
// keep-with-previous
@@ -1834,7 +1850,7 @@ public final class FOPropertyMapping implements Constants {
m.useGeneric(genericKeep);
m.setInherited(false);
m.setDefault("auto");
- m.addShorthand(s_generics[PR_PAGE_BREAK_BEFORE]);
+ m.addShorthand(generics[PR_PAGE_BREAK_BEFORE]);
addPropertyMaker("keep-with-previous", m);
// orphans
@@ -2240,7 +2256,8 @@ public final class FOPropertyMapping implements Constants {
m.setInherited(false);
m.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
m.addEnum("paginate", getEnumProperty(EN_PAGINATE, "PAGINATE"));
- m.addEnum("bounded-in-one-dimension", getEnumProperty(EN_BOUNDED_IN_ONE_DIMENSION, "BOUNDED_IN_ONE_DIMENSION"));
+ m.addEnum("bounded-in-one-dimension", getEnumProperty(EN_BOUNDED_IN_ONE_DIMENSION,
+ "BOUNDED_IN_ONE_DIMENSION"));
m.addEnum("unbounded", getEnumProperty(EN_UNBOUNDED, "UNBOUNDED"));
m.setDefault("auto");
addPropertyMaker("media-usage", m);
@@ -2330,7 +2347,7 @@ public final class FOPropertyMapping implements Constants {
// border-separation
m = new LengthPairProperty.Maker(PR_BORDER_SEPARATION);
m.setInherited(true);
- m.addShorthand(s_generics[PR_BORDER_SPACING]);
+ m.addShorthand(generics[PR_BORDER_SPACING]);
sub = new LengthProperty.Maker(CP_BLOCK_PROGRESSION_DIRECTION);
sub.setDefault("0pt");
@@ -2577,7 +2594,7 @@ public final class FOPropertyMapping implements Constants {
addPropertyMaker("z-index", m);
}
- private void createShorthandProperties() {
+ private void createShorthandProperties() { // CSOK: MethodLength
PropertyMaker m;
// background
diff --git a/src/java/org/apache/fop/fo/FOText.java b/src/java/org/apache/fop/fo/FOText.java
index 08ffa40a3..5db11f731 100644
--- a/src/java/org/apache/fop/fo/FOText.java
+++ b/src/java/org/apache/fop/fo/FOText.java
@@ -489,10 +489,10 @@ public class FOText extends FONode implements CharSequence {
private class TextCharIterator extends CharIterator {
- int currentPosition = 0;
+ private int currentPosition = 0;
- boolean canRemove = false;
- boolean canReplace = false;
+ private boolean canRemove = false;
+ private boolean canReplace = false;
/** {@inheritDoc} */
public boolean hasNext() {
diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java
index c848eb4f1..451481eb8 100644
--- a/src/java/org/apache/fop/fo/FOTreeBuilder.java
+++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java
@@ -398,7 +398,9 @@ public class FOTreeBuilder extends DefaultHandler {
FOValidationEventProducer eventProducer
= FOValidationEventProducer.Provider.get(
userAgent.getEventBroadcaster());
- eventProducer.unknownFormattingObject(this, currentFObj.getName(),
+ String name = (currentFObj != null ? currentFObj.getName()
+ : "{" + namespaceURI + "}" + localName);
+ eventProducer.unknownFormattingObject(this, name,
new QName(namespaceURI, localName),
getEffectiveLocator());
}
diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java
index 133d932bc..34e29a58a 100644
--- a/src/java/org/apache/fop/fo/FObj.java
+++ b/src/java/org/apache/fop/fo/FObj.java
@@ -44,7 +44,7 @@ import org.apache.fop.fo.properties.PropertyMaker;
public abstract class FObj extends FONode implements Constants {
/** the list of property makers */
- private static final PropertyMaker[] propertyListTable
+ private static final PropertyMaker[] PROPERTY_LIST_TABLE
= FOPropertyMapping.getGenericMappings();
/**
@@ -108,7 +108,7 @@ public abstract class FObj extends FONode implements Constants {
* @return the requested Property Maker
*/
public static PropertyMaker getPropertyMakerFor(int propId) {
- return propertyListTable[propId];
+ return PROPERTY_LIST_TABLE[propId];
}
/** {@inheritDoc} */
@@ -255,7 +255,7 @@ public abstract class FObj extends FONode implements Constants {
/**
* Check if this formatting object generates reference areas.
* @return true if generates reference areas
- * @todo see if needed
+ * TODO see if needed
*/
public boolean generatesReferenceAreas() {
return false;
@@ -610,7 +610,7 @@ public abstract class FObj extends FONode implements Constants {
return (super.toString() + "[@id=" + this.id + "]");
}
- /** Basic {@link FONodeIterator} implementation */
+ /** Basic {@link FONode.FONodeIterator} implementation */
public class FObjIterator implements FONodeIterator {
private static final int F_NONE_ALLOWED = 0;
diff --git a/src/java/org/apache/fop/fo/InlineCharIterator.java b/src/java/org/apache/fop/fo/InlineCharIterator.java
deleted file mode 100644
index f71753dde..000000000
--- a/src/java/org/apache/fop/fo/InlineCharIterator.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.fo;
-
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.util.CharUtilities;
-import java.util.NoSuchElementException;
-
-/**
- * A recursive char iterator that indicates boundaries by returning
- * an EOT char.
- */
-public class InlineCharIterator extends RecursiveCharIterator {
- private boolean startBoundary = false;
- private boolean endBoundary = false;
-
- /**
- * @param fobj the object for whose character contents and for whose
- * descendant's character contents should be iterated
- * @param bpb the CommonBorderPaddingBackground properties to be applied
- */
- public InlineCharIterator(FObj fobj, CommonBorderPaddingBackground bpb) {
- super(fobj);
- checkBoundaries(bpb);
- }
-
-
- private void checkBoundaries(CommonBorderPaddingBackground bpb) {
- /* Current understanding is that an <fo:inline> is always a boundary for
- * whitespace collapse if it has a border or not
- startBoundary = (bpb.getBorderStartWidth(false) > 0
- || bpb.getPaddingStart(false, null) > 0); // TODO do we need context here?
- endBoundary = (bpb.getBorderEndWidth(false) > 0
- || bpb.getPaddingEnd(false, null) > 0); // TODO do we need context here?
- */
- startBoundary = true;
- endBoundary = true;
- }
-
- /**
- * @return true if there are more characters
- */
- public boolean hasNext() {
- if (startBoundary) {
- return true;
- }
- return (super.hasNext() || endBoundary);
- /* If super.hasNext() returns false,
- * we return true if we are going to return a "boundary" signal
- * else false.
- */
- }
-
- /**
- * @return the next character
- * @throws NoSuchElementException if there are no more characters
- */
- public char nextChar() throws NoSuchElementException {
- if (startBoundary) {
- startBoundary = false;
- return CharUtilities.CODE_EOT;
- }
- try {
- return super.nextChar();
- } catch (NoSuchElementException e) {
- // Underlying has nothing more to return
- // Check end boundary char
- if (endBoundary) {
- endBoundary = false;
- return CharUtilities.CODE_EOT;
- } else {
- throw e;
- }
- }
- }
-}
-
diff --git a/src/java/org/apache/fop/fo/NullCharIterator.java b/src/java/org/apache/fop/fo/NullCharIterator.java
index 2b2a2a9a0..db872caec 100644
--- a/src/java/org/apache/fop/fo/NullCharIterator.java
+++ b/src/java/org/apache/fop/fo/NullCharIterator.java
@@ -28,6 +28,10 @@ public class NullCharIterator extends CharIterator {
private static CharIterator instance;
+ /**
+ * Obtain the singleton instance of the null character iterator.
+ * @return the char iterator
+ */
public static CharIterator getInstance() {
if (instance == null) {
instance = new NullCharIterator();
diff --git a/src/java/org/apache/fop/fo/PropertyListMaker.java b/src/java/org/apache/fop/fo/PropertyListMaker.java
index e48541af5..ef8978b0c 100644
--- a/src/java/org/apache/fop/fo/PropertyListMaker.java
+++ b/src/java/org/apache/fop/fo/PropertyListMaker.java
@@ -23,6 +23,13 @@ package org.apache.fop.fo;
* A PropertyListMaker is a factory that creates PropertyLists.
*/
public interface PropertyListMaker {
+
+ /**
+ * Make a property list.
+ * @param fobj the FO from which the new property list is associated
+ * @param parentPropertyList the parent property list
+ * @return the new property list
+ */
PropertyList make(FObj fobj, PropertyList parentPropertyList);
}
diff --git a/src/java/org/apache/fop/fo/StaticPropertyList.java b/src/java/org/apache/fop/fo/StaticPropertyList.java
index 5e6559e84..c3ab95b91 100644
--- a/src/java/org/apache/fop/fo/StaticPropertyList.java
+++ b/src/java/org/apache/fop/fo/StaticPropertyList.java
@@ -14,6 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+/* $Id$ */
+
package org.apache.fop.fo;
import org.apache.fop.fo.expr.PropertyException;
@@ -62,14 +65,14 @@ public class StaticPropertyList extends PropertyList {
/**
* Override PropertyList.get() and provides fast caching of previously
* retrieved property values.
- * @param propId The property ID
+ * {@inheritDoc}
*/
public Property get(int propId, boolean bTryInherit, boolean bTryDefault)
- throws PropertyException
- {
+ throws PropertyException {
Property p = values[propId];
if (p == null) {
- p = values[propId] = super.get(propId, bTryInherit, bTryDefault);
+ p = super.get(propId, bTryInherit, bTryDefault);
+ values[propId] = p;
}
return p;
}
diff --git a/src/java/org/apache/fop/fo/ValidationException.java b/src/java/org/apache/fop/fo/ValidationException.java
index 103c5fcc8..2285fbd19 100644
--- a/src/java/org/apache/fop/fo/ValidationException.java
+++ b/src/java/org/apache/fop/fo/ValidationException.java
@@ -26,10 +26,20 @@ import org.xml.sax.Locator;
* Exception thrown during FO tree validation.
*/
public class ValidationException extends FOPException {
+
+ /**
+ * Construct a validation exception instance.
+ * @param message a message
+ */
public ValidationException(String message) {
super(message);
}
+ /**
+ * Construct a validation exception instance.
+ * @param message a message
+ * @param locator a locator
+ */
public ValidationException(String message, Locator locator) {
super(message, locator);
}
diff --git a/src/java/org/apache/fop/fo/expr/BodyStartFunction.java b/src/java/org/apache/fop/fo/expr/BodyStartFunction.java
index eb68b2a23..5307e75b0 100644
--- a/src/java/org/apache/fop/fo/expr/BodyStartFunction.java
+++ b/src/java/org/apache/fop/fo/expr/BodyStartFunction.java
@@ -47,8 +47,9 @@ public class BodyStartFunction extends FunctionBase {
*/
public Property eval(Property[] args,
PropertyInfo pInfo) throws PropertyException {
- Numeric distance =
- pInfo.getPropertyList().get(Constants.PR_PROVISIONAL_DISTANCE_BETWEEN_STARTS).getNumeric();
+ Numeric distance
+ = pInfo.getPropertyList()
+ .get(Constants.PR_PROVISIONAL_DISTANCE_BETWEEN_STARTS).getNumeric();
PropertyList pList = pInfo.getPropertyList();
while (pList != null && !(pList.getFObj() instanceof ListItem)) {
diff --git a/src/java/org/apache/fop/fo/expr/NumericOp.java b/src/java/org/apache/fop/fo/expr/NumericOp.java
index 9fe35d96d..a2b203330 100644
--- a/src/java/org/apache/fop/fo/expr/NumericOp.java
+++ b/src/java/org/apache/fop/fo/expr/NumericOp.java
@@ -19,8 +19,8 @@
package org.apache.fop.fo.expr;
-import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.datatypes.Numeric;
+import org.apache.fop.datatypes.PercentBaseContext;
/**
* This class contains static methods to evaluate operations on Numeric
@@ -30,7 +30,11 @@ import org.apache.fop.datatypes.Numeric;
* The evaluation of the operation can then occur when getNumericValue() is
* called.
*/
-public class NumericOp {
+public final class NumericOp {
+
+ private NumericOp() {
+ }
+
/**
* Add the two operands and return a new Numeric representing the result.
* @param op1 The first operand.
@@ -47,11 +51,23 @@ public class NumericOp {
}
}
- public static Numeric addition2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException {
+ /**
+ * Add the two operands with a percentage context
+ * and return a new Numeric representing the result.
+ * @param op1 The first operand.
+ * @param op2 The second operand.
+ * @param context a percent base context
+ * @return A Numeric representing the result.
+ * @throws PropertyException If the dimension of the operand is different
+ * from the dimension of this Numeric.
+ */
+ public static Numeric addition2(Numeric op1, Numeric op2, PercentBaseContext context)
+ throws PropertyException {
if (op1.getDimension() != op2.getDimension()) {
throw new PropertyException("Can't subtract Numerics of different dimensions");
}
- return numeric(op1.getNumericValue(context) + op2.getNumericValue(context), op1.getDimension());
+ return numeric(op1.getNumericValue(context)
+ + op2.getNumericValue(context), op1.getDimension());
}
/**
@@ -71,11 +87,23 @@ public class NumericOp {
}
}
- public static Numeric subtraction2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException {
+ /**
+ * Subtract the two operands with a percentage context
+ * and return a new Numeric representing the result.
+ * @param op1 The first operand.
+ * @param op2 The second operand.
+ * @param context a percent base context
+ * @return A Numeric representing the result.
+ * @throws PropertyException If the dimension of the operand is different
+ * from the dimension of this Numeric.
+ */
+ public static Numeric subtraction2(Numeric op1, Numeric op2, PercentBaseContext context)
+ throws PropertyException {
if (op1.getDimension() != op2.getDimension()) {
throw new PropertyException("Can't subtract Numerics of different dimensions");
}
- return numeric(op1.getNumericValue(context) - op2.getNumericValue(context), op1.getDimension());
+ return numeric(op1.getNumericValue(context)
+ - op2.getNumericValue(context), op1.getDimension());
}
/**
@@ -95,7 +123,18 @@ public class NumericOp {
}
}
- public static Numeric multiply2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException {
+ /**
+ * Multiply the two operands with a percentage context
+ * and return a new Numeric representing the result.
+ * @param op1 The first operand.
+ * @param op2 The second operand.
+ * @param context a percent base context
+ * @return A Numeric representing the result.
+ * @throws PropertyException If the dimension of the operand is different
+ * from the dimension of this Numeric.
+ */
+ public static Numeric multiply2(Numeric op1, Numeric op2, PercentBaseContext context)
+ throws PropertyException {
return numeric(op1.getNumericValue(context) * op2.getNumericValue(context),
op1.getDimension() + op2.getDimension());
}
@@ -118,7 +157,18 @@ public class NumericOp {
}
}
- public static Numeric divide2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException {
+ /**
+ * Divide the two operands with a percentage context
+ * and return a new Numeric representing the result.
+ * @param op1 The first operand.
+ * @param op2 The second operand.
+ * @param context a percent base context
+ * @return A Numeric representing the result.
+ * @throws PropertyException If the dimension of the operand is different
+ * from the dimension of this Numeric.
+ */
+ public static Numeric divide2(Numeric op1, Numeric op2, PercentBaseContext context)
+ throws PropertyException {
return numeric(op1.getNumericValue(context) / op2.getNumericValue(context),
op1.getDimension() - op2.getDimension());
}
@@ -128,6 +178,7 @@ public class NumericOp {
* @param op1 The first operand.
* @param op2 The second operand.
* @return A new Numeric object representing the absolute value.
+ * @throws PropertyException if a property exception occurs
*/
public static Numeric modulo(Numeric op1, Numeric op2) throws PropertyException {
if (op1.isAbsolute() && op2.isAbsolute()) {
@@ -137,14 +188,26 @@ public class NumericOp {
}
}
- public static Numeric modulo2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException {
- return numeric(op1.getNumericValue(context) % op2.getNumericValue(context), op1.getDimension());
+ /**
+ * Return the remainder of a division of the two operand Numeric.
+ * @param op1 The first operand.
+ * @param op2 The second operand.
+ * @param context a percent base context
+ * @return A Numeric representing the result.
+ * @throws PropertyException If the dimension of the operand is different
+ * from the dimension of this Numeric.
+ */
+ public static Numeric modulo2(Numeric op1, Numeric op2, PercentBaseContext context)
+ throws PropertyException {
+ return numeric(op1.getNumericValue(context)
+ % op2.getNumericValue(context), op1.getDimension());
}
/**
* Return the absolute value of a Numeric.
* @param op the operand.
* @return a new Numeric object representing the absolute value of the operand.
+ * @throws PropertyException if a property exception occurs
*/
public static Numeric abs(Numeric op) throws PropertyException {
if (op.isAbsolute()) {
@@ -154,6 +217,14 @@ public class NumericOp {
}
}
+ /**
+ * Return the absolute value of a Numeric.
+ * @param op the operand.
+ * @param context a percent base context
+ * @return A Numeric representing the result.
+ * @throws PropertyException If the dimension of the operand is different
+ * from the dimension of this Numeric.
+ */
public static Numeric abs2(Numeric op, PercentBaseContext context) throws PropertyException {
return numeric(Math.abs(op.getNumericValue(context)), op.getDimension());
}
@@ -162,6 +233,7 @@ public class NumericOp {
* Return the negation of a Numeric.
* @param op the operand.
* @return a new Numeric object representing the negation of the operand.
+ * @throws PropertyException if a property exception occurs
*/
public static Numeric negate(Numeric op) throws PropertyException {
if (op.isAbsolute()) {
@@ -171,8 +243,17 @@ public class NumericOp {
}
}
+
+ /**
+ * Return the negation of a Numeric.
+ * @param op the operand.
+ * @param context a percent base context
+ * @return A Numeric representing the result.
+ * @throws PropertyException If the dimension of the operand is different
+ * from the dimension of this Numeric.
+ */
public static Numeric negate2(Numeric op, PercentBaseContext context) throws PropertyException {
- return numeric(- op.getNumericValue(context), op.getDimension());
+ return numeric(-op.getNumericValue(context), op.getDimension());
}
/**
@@ -190,7 +271,17 @@ public class NumericOp {
}
}
- public static Numeric max2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException {
+ /**
+ * Return the larger of the two Numerics.
+ * @param op1 The first operand.
+ * @param op2 The second operand.
+ * @param context a percent base context
+ * @return A Numeric representing the result.
+ * @throws PropertyException If the dimension of the operand is different
+ * from the dimension of this Numeric.
+ */
+ public static Numeric max2(Numeric op1, Numeric op2, PercentBaseContext context)
+ throws PropertyException {
if (op1.getDimension() != op2.getDimension()) {
throw new PropertyException("Arguments to max() must have same dimensions");
}
@@ -212,7 +303,17 @@ public class NumericOp {
}
}
- public static Numeric min2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException {
+ /**
+ * Return the smaller of the two Numerics.
+ * @param op1 The first operand.
+ * @param op2 The second operand.
+ * @param context a percent base context
+ * @return A Numeric representing the result.
+ * @throws PropertyException If the dimension of the operand is different
+ * from the dimension of this Numeric.
+ */
+ public static Numeric min2(Numeric op1, Numeric op2, PercentBaseContext context)
+ throws PropertyException {
if (op1.getDimension() != op2.getDimension()) {
throw new PropertyException("Arguments to min() must have same dimensions");
}
@@ -221,8 +322,8 @@ public class NumericOp {
/**
* Create a new absolute numeric with the specified value and dimension.
- * @param value
- * @param dimension
+ * @param value of numeric
+ * @param dimension of numeric
* @return a new absolute numeric.
*/
private static Numeric numeric(double value, int dimension) {
diff --git a/src/java/org/apache/fop/fo/expr/PropertyInfo.java b/src/java/org/apache/fop/fo/expr/PropertyInfo.java
index 2bce0793f..0463e2e1d 100644
--- a/src/java/org/apache/fop/fo/expr/PropertyInfo.java
+++ b/src/java/org/apache/fop/fo/expr/PropertyInfo.java
@@ -58,6 +58,7 @@ public class PropertyInfo {
* a percent specification.
* Propagates to the Maker.
* @return The PercentBase object or null if percentLengthOK()=false.
+ * @throws PropertyException if a property exception occurs
*/
public PercentBase getPercentBase() throws PropertyException {
PercentBase pcbase = getFunctionPercentBase();
@@ -66,6 +67,7 @@ public class PropertyInfo {
/**
* @return the current font-size value as base units (milli-points).
+ * @throws PropertyException if a property exception occurs
*/
public Length currentFontSize() throws PropertyException {
return plist.get(Constants.PR_FONT_SIZE).getLength();
diff --git a/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java b/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java
index 7d846eefc..89a387753 100644
--- a/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java
+++ b/src/java/org/apache/fop/fo/expr/PropertyTokenizer.java
@@ -82,7 +82,7 @@ class PropertyTokenizer {
currentTokenStartIndex = exprIndex;
boolean bSawDecimal;
recognizeOperator = true;
- for (;;) {
+ while ( true ) {
if (exprIndex >= exprLength) {
currentToken = TOK_EOF;
return;
@@ -272,8 +272,11 @@ class PropertyTokenizer {
}
private void scanRestOfName() {
- while (++exprIndex < exprLength
- && isNameChar(expr.charAt(exprIndex))) { }
+ while ( ++exprIndex < exprLength ) {
+ if ( !isNameChar ( expr.charAt ( exprIndex ) ) ) {
+ break;
+ }
+ }
}
/**
@@ -330,7 +333,7 @@ class PropertyTokenizer {
* decimal digit (0-9).
* @param c The character to check
*/
- private static final boolean isDigit(char c) {
+ private static boolean isDigit(char c) {
return DIGITS.indexOf(c) >= 0;
}
@@ -339,7 +342,7 @@ class PropertyTokenizer {
* hexadecimal digit (0-9, A-F, a-f).
* @param c The character to check
*/
- private static final boolean isHexDigit(char c) {
+ private static boolean isHexDigit(char c) {
return HEX_CHARS.indexOf(c) >= 0;
}
@@ -348,15 +351,16 @@ class PropertyTokenizer {
* as defined by XSL (space, newline, CR, tab).
* @param c The character to check
*/
- private static final boolean isSpace(char c) {
+ private static boolean isSpace(char c) {
switch (c) {
case ' ':
case '\r':
case '\n':
case '\t':
return true;
+ default:
+ return false;
}
- return false;
}
/**
@@ -364,7 +368,7 @@ class PropertyTokenizer {
* start character, ie. can start a NAME as defined by XSL.
* @param c The character to check
*/
- private static final boolean isNameStartChar(char c) {
+ private static boolean isNameStartChar(char c) {
return NAME_START_CHARS.indexOf(c) >= 0 || c >= 0x80;
}
@@ -373,7 +377,7 @@ class PropertyTokenizer {
* character, ie. can occur in a NAME as defined by XSL.
* @param c The character to check
*/
- private static final boolean isNameChar(char c) {
+ private static boolean isNameChar(char c) {
return NAME_START_CHARS.indexOf(c) >= 0 || NAME_CHARS.indexOf(c) >= 0
|| c >= 0x80;
}
diff --git a/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java b/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java
index a4e257546..883070056 100644
--- a/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java
+++ b/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java
@@ -33,14 +33,23 @@ import org.apache.fop.fo.properties.TableColLength;
* or getValue() is called.
*/
public class RelativeNumericProperty extends Property implements Length {
+ /** ADDITION */
public static final int ADDITION = 1;
+ /** SUBTRACTION */
public static final int SUBTRACTION = 2;
+ /** MULTIPLY */
public static final int MULTIPLY = 3;
+ /** DIVIDE */
public static final int DIVIDE = 4;
+ /** MODULO */
public static final int MODULO = 5;
+ /** NEGATE */
public static final int NEGATE = 6;
+ /** ABS */
public static final int ABS = 7;
+ /** MAX */
public static final int MAX = 8;
+ /** MIN */
public static final int MIN = 9;
// Used in the toString() method, indexed by operation id.
@@ -145,6 +154,7 @@ public class RelativeNumericProperty extends Property implements Length {
/**
* Return the dimension of the expression
+ * @return numeric value as dimension
*/
public int getDimension() {
return dimension;
@@ -153,6 +163,7 @@ public class RelativeNumericProperty extends Property implements Length {
/**
* Return false since an expression is only created when there is relative
* numerics involved.
+ * @return true if expression is absolute
*/
public boolean isAbsolute() {
return false;
@@ -160,6 +171,7 @@ public class RelativeNumericProperty extends Property implements Length {
/**
* Cast this numeric as a Length.
+ * @return numeric value as length
*/
public Length getLength() {
if (dimension == 1) {
@@ -169,6 +181,7 @@ public class RelativeNumericProperty extends Property implements Length {
return null;
}
+ /** @return numeric value */
public Numeric getNumeric() {
return this;
}
@@ -272,7 +285,8 @@ public class RelativeNumericProperty extends Property implements Length {
return "min(" + op1 + ", " + op2 + ")";
case ABS:
return "abs(" + op1 + ")";
+ default:
+ return "unknown operation " + operation;
}
- return "unknown operation " + operation;
}
}
diff --git a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
index f9a556167..80a569c90 100644
--- a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
+++ b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java
@@ -37,17 +37,18 @@ public class ExtensionElementMapping extends ElementMapping {
/** The FOP extension namespace URI */
public static final String URI = "http://xmlgraphics.apache.org/fop/extensions";
- private static final Set propertyAttributes = new java.util.HashSet();
+ private static final Set<String> PROPERTY_ATTRIBUTES
+ = new java.util.HashSet<String>();
static {
//These are FOP's standard extension properties (fox:*)
- propertyAttributes.add("block-progression-unit");
- propertyAttributes.add("widow-content-limit");
- propertyAttributes.add("orphan-content-limit");
- propertyAttributes.add("internal-destination");
- propertyAttributes.add("disable-column-balancing");
+ PROPERTY_ATTRIBUTES.add("block-progression-unit");
+ PROPERTY_ATTRIBUTES.add("widow-content-limit");
+ PROPERTY_ATTRIBUTES.add("orphan-content-limit");
+ PROPERTY_ATTRIBUTES.add("internal-destination");
+ PROPERTY_ATTRIBUTES.add("disable-column-balancing");
//These are FOP's extension properties for accessibility
- propertyAttributes.add("alt-text");
+ PROPERTY_ATTRIBUTES.add("alt-text");
}
/**
@@ -62,7 +63,7 @@ public class ExtensionElementMapping extends ElementMapping {
*/
protected void initialize() {
if (foObjs == null) {
- foObjs = new HashMap();
+ foObjs = new HashMap<String, Maker>();
foObjs.put("outline", new UnknownXMLObj.Maker(URI));
foObjs.put("label", new UnknownXMLObj.Maker(URI));
foObjs.put("destination", new DestinationMaker());
@@ -92,7 +93,7 @@ public class ExtensionElementMapping extends ElementMapping {
if (!URI.equals(attributeName.getNamespaceURI())) {
throw new IllegalArgumentException("The namespace URIs don't match");
}
- return propertyAttributes.contains(attributeName.getLocalName());
+ return PROPERTY_ATTRIBUTES.contains(attributeName.getLocalName());
}
}
diff --git a/src/java/org/apache/fop/fo/extensions/ExtensionObj.java b/src/java/org/apache/fop/fo/extensions/ExtensionObj.java
index da732f421..4329f1a7e 100644
--- a/src/java/org/apache/fop/fo/extensions/ExtensionObj.java
+++ b/src/java/org/apache/fop/fo/extensions/ExtensionObj.java
@@ -47,13 +47,15 @@ public abstract class ExtensionObj extends FObj {
*/
public void processNode(String elementName, Locator locator,
Attributes attlist, PropertyList pList)
- throws FOPException
- {
- // Empty
+ throws FOPException {
}
/**
* Create a default property list for this element.
+ * @param parent the parent property list
+ * @param foEventHandler an event handler
+ * @return property list
+ * @throws FOPException in case of exception
*/
protected PropertyList createPropertyList(PropertyList parent,
FOEventHandler foEventHandler) throws FOPException {
diff --git a/src/java/org/apache/fop/fo/extensions/ExternalDocument.java b/src/java/org/apache/fop/fo/extensions/ExternalDocument.java
index 233714bd7..a6f5e7680 100644
--- a/src/java/org/apache/fop/fo/extensions/ExternalDocument.java
+++ b/src/java/org/apache/fop/fo/extensions/ExternalDocument.java
@@ -82,13 +82,18 @@ public class ExternalDocument extends AbstractPageSequence implements GraphicsPr
}
}
+ /**
+ * @throws FOPException in case of processing exception
+ * @see org.apache.fop.fo.FONode#startOfNode()
+ */
protected void startOfNode() throws FOPException {
super.startOfNode();
getFOEventHandler().startExternalDocument(this);
}
/**
- * @see org.apache.fop.fo.FONode#endOfNode
+ * @throws FOPException in case of processing exception
+ * @see org.apache.fop.fo.FONode#endOfNode()
*/
protected void endOfNode() throws FOPException {
getFOEventHandler().endExternalDocument(this);
@@ -96,8 +101,11 @@ public class ExternalDocument extends AbstractPageSequence implements GraphicsPr
}
/**
+ * @param loc a locator
+ * @param nsURI a namespace uri or null
+ * @param localName a local name
+ * @throws ValidationException if invalid child
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
- XSL/FOP: empty
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws ValidationException {
@@ -162,17 +170,26 @@ public class ExternalDocument extends AbstractPageSequence implements GraphicsPr
return textAlign;
}
- /** @see org.apache.fop.fo.FONode#getNamespaceURI() */
+ /**
+ * @return namespace uri
+ * @see org.apache.fop.fo.FONode#getNamespaceURI()
+ */
public String getNamespaceURI() {
return ExtensionElementMapping.URI;
}
- /** @see org.apache.fop.fo.FONode#getNormalNamespacePrefix() */
+ /**
+ * @return namespace prefix
+ * @see org.apache.fop.fo.FONode#getNormalNamespacePrefix()
+ */
public String getNormalNamespacePrefix() {
return "fox";
}
- /** @see org.apache.fop.fo.FONode#getLocalName() */
+ /**
+ * @return local name
+ * @see org.apache.fop.fo.FONode#getLocalName()
+ */
public String getLocalName() {
return "external-document";
}
diff --git a/src/java/org/apache/fop/fo/extensions/InternalElementMapping.java b/src/java/org/apache/fop/fo/extensions/InternalElementMapping.java
index 7704c8de7..4798f5500 100644
--- a/src/java/org/apache/fop/fo/extensions/InternalElementMapping.java
+++ b/src/java/org/apache/fop/fo/extensions/InternalElementMapping.java
@@ -34,7 +34,7 @@ public class InternalElementMapping extends ElementMapping {
/** The FOP extension namespace URI */
public static final String URI = "http://xmlgraphics.apache.org/fop/internal";
- private static final Set PROPERTY_ATTRIBUTES = new java.util.HashSet();
+ private static final Set<String> PROPERTY_ATTRIBUTES = new java.util.HashSet<String>();
static {
//These are FOP's extension properties for accessibility
@@ -53,7 +53,7 @@ public class InternalElementMapping extends ElementMapping {
*/
protected void initialize() {
if (foObjs == null) {
- foObjs = new HashMap();
+ foObjs = new HashMap<String, Maker>();
}
}
diff --git a/src/java/org/apache/fop/fo/extensions/OldExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/OldExtensionElementMapping.java
index e5ab93c35..d1c671dbe 100644
--- a/src/java/org/apache/fop/fo/extensions/OldExtensionElementMapping.java
+++ b/src/java/org/apache/fop/fo/extensions/OldExtensionElementMapping.java
@@ -44,7 +44,7 @@ public class OldExtensionElementMapping extends ElementMapping {
*/
protected void initialize() {
if (foObjs == null) {
- foObjs = new HashMap();
+ foObjs = new HashMap<String, Maker>();
foObjs.put("outline", new UnknownXMLObj.Maker(URI));
foObjs.put("label", new UnknownXMLObj.Maker(URI));
}
diff --git a/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java
index 2cc451b64..6103345cf 100644
--- a/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java
+++ b/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java
@@ -53,7 +53,7 @@ public class BatikExtensionElementMapping extends ElementMapping {
* Batik classes that apparently need it (error messages, perhaps)
* @return an XML parser classname
*/
- private final String getAParserClassName() {
+ private String getAParserClassName() {
try {
//TODO Remove when Batik uses JAXP instead of SAX directly.
SAXParserFactory factory = SAXParserFactory.newInstance();
@@ -63,6 +63,7 @@ public class BatikExtensionElementMapping extends ElementMapping {
}
}
+ /** initialize mapping */
protected void initialize() {
if (foObjs == null && batikAvail) {
// this sets the parser that will be used
@@ -72,7 +73,7 @@ public class BatikExtensionElementMapping extends ElementMapping {
XMLResourceDescriptor.setXMLParserClassName(
getAParserClassName());
- foObjs = new HashMap();
+ foObjs = new HashMap<String, Maker>();
foObjs.put("batik", new SE());
foObjs.put(DEFAULT, new SVGMaker());
} catch (Throwable t) {
diff --git a/src/java/org/apache/fop/fo/extensions/svg/SVGDOMContentHandlerFactory.java b/src/java/org/apache/fop/fo/extensions/svg/SVGDOMContentHandlerFactory.java
index 6556c7251..67f6567c9 100644
--- a/src/java/org/apache/fop/fo/extensions/svg/SVGDOMContentHandlerFactory.java
+++ b/src/java/org/apache/fop/fo/extensions/svg/SVGDOMContentHandlerFactory.java
@@ -105,7 +105,7 @@ public class SVGDOMContentHandlerFactory implements ContentHandlerFactory {
Class clazz = Class.forName(
"org.apache.batik.dom.svg12.SVG12DOMImplementation");
return (DOMImplementation)clazz.getMethod(
- "getDOMImplementation", null).invoke(null, null);
+ "getDOMImplementation", (Class[])null).invoke(null, (Object[])null);
} catch (Exception e) {
return SVGDOMImplementation.getDOMImplementation();
}
diff --git a/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java b/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java
index 167baf723..7120dbb59 100644
--- a/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java
+++ b/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java
@@ -80,7 +80,7 @@ public class SVGElementMapping extends ElementMapping {
XMLResourceDescriptor.setXMLParserClassName(
getAParserClassName());
- foObjs = new HashMap();
+ foObjs = new HashMap<String, Maker>();
foObjs.put("svg", new SE());
foObjs.put(DEFAULT, new SVGMaker());
} catch (Throwable t) {
diff --git a/src/java/org/apache/fop/fo/extensions/xmp/RDFElementMapping.java b/src/java/org/apache/fop/fo/extensions/xmp/RDFElementMapping.java
index ff84ee11f..a6befd710 100644
--- a/src/java/org/apache/fop/fo/extensions/xmp/RDFElementMapping.java
+++ b/src/java/org/apache/fop/fo/extensions/xmp/RDFElementMapping.java
@@ -45,7 +45,7 @@ public class RDFElementMapping extends ElementMapping {
/** {@inheritDoc} */
protected void initialize() {
if (foObjs == null) {
- foObjs = new HashMap();
+ foObjs = new HashMap<String, Maker>();
foObjs.put("RDF", new RDFElementMaker());
}
}
diff --git a/src/java/org/apache/fop/fo/extensions/xmp/XMPElementMapping.java b/src/java/org/apache/fop/fo/extensions/xmp/XMPElementMapping.java
index b2b3570f2..d934dc2b1 100644
--- a/src/java/org/apache/fop/fo/extensions/xmp/XMPElementMapping.java
+++ b/src/java/org/apache/fop/fo/extensions/xmp/XMPElementMapping.java
@@ -45,7 +45,7 @@ public class XMPElementMapping extends ElementMapping {
/** {@inheritDoc} */
protected void initialize() {
if (foObjs == null) {
- foObjs = new HashMap();
+ foObjs = new HashMap<String, Maker>();
foObjs.put("xmpmeta", new XMPMetaElementMaker());
}
}
diff --git a/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java b/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java
index 224741294..6dcc31385 100644
--- a/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java
+++ b/src/java/org/apache/fop/fo/extensions/xmp/XMPMetadata.java
@@ -33,6 +33,8 @@ import org.xml.sax.SAXException;
*/
public class XMPMetadata implements ExtensionAttachment, Serializable, XMLizable {
+ private static final long serialVersionUID = 591347206217931578L;
+
/** The category URI for this extension attachment. */
public static final String CATEGORY = XMPConstants.XMP_NAMESPACE;
diff --git a/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java
index 0f4575c5b..7bc0ff00c 100644
--- a/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java
+++ b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java
@@ -109,7 +109,9 @@ public abstract class AbstractPageNumberCitation extends FObj
}
/** {@inheritDoc} */
- public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList pList) throws FOPException {
+ public void processNode
+ (String elementName, Locator locator, Attributes attlist, PropertyList pList)
+ throws FOPException {
super.processNode(elementName, locator, attlist, pList);
if (!inMarker() && (refId == null || "".equals(refId))) {
missingPropertyError("ref-id");
diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java
index e3176464d..66e06db83 100644
--- a/src/java/org/apache/fop/fo/flow/Block.java
+++ b/src/java/org/apache/fop/fo/flow/Block.java
@@ -330,7 +330,8 @@ public class Block extends FObjMixed implements BreakPropertySet, StructurePoint
/**
* @return the "fox:disable-column-balancing" property, one of
- * {@link Constants#EN_TRUE}, {@link Constants#EN_FALSE}
+ * {@link org.apache.fop.fo.Constants#EN_TRUE},
+ * {@link org.apache.fop.fo.Constants#EN_FALSE}
*/
public int getDisableColumnBalancing() {
return disableColumnBalancing;
diff --git a/src/java/org/apache/fop/fo/flow/BlockContainer.java b/src/java/org/apache/fop/fo/flow/BlockContainer.java
index 2a8d73002..57cb6e5c6 100644
--- a/src/java/org/apache/fop/fo/flow/BlockContainer.java
+++ b/src/java/org/apache/fop/fo/flow/BlockContainer.java
@@ -219,7 +219,8 @@ public class BlockContainer extends FObj implements BreakPropertySet {
/**
* @return the "fox:disable-column-balancing" property, one of
- * {@link Constants#EN_TRUE}, {@link Constants#EN_FALSE}
+ * {@link org.apache.fop.fo.Constants#EN_TRUE},
+ * {@link org.apache.fop.fo.Constants#EN_FALSE}
*/
public int getDisableColumnBalancing() {
return disableColumnBalancing;
diff --git a/src/java/org/apache/fop/fo/flow/Float.java b/src/java/org/apache/fop/fo/flow/Float.java
index 815b30393..5d8fcdc2c 100644
--- a/src/java/org/apache/fop/fo/flow/Float.java
+++ b/src/java/org/apache/fop/fo/flow/Float.java
@@ -38,7 +38,7 @@ public class Float extends FObj {
// private int clear;
// End of property values
- static boolean notImplementedWarningGiven = false;
+ private static boolean notImplementedWarningGiven = false;
/**
* Base constructor
diff --git a/src/java/org/apache/fop/fo/flow/Footnote.java b/src/java/org/apache/fop/fo/flow/Footnote.java
index e73701c3b..51d2581cd 100644
--- a/src/java/org/apache/fop/fo/flow/Footnote.java
+++ b/src/java/org/apache/fop/fo/flow/Footnote.java
@@ -76,9 +76,9 @@ public class Footnote extends FObj {
/**
* {@inheritDoc}
* <br>XSL Content Model: (inline,footnote-body)
- * @todo implement additional constraint: A fo:footnote is not permitted
+ * TODO implement additional constraint: A fo:footnote is not permitted
* to have a fo:float, fo:footnote, or fo:marker as a descendant.
- * @todo implement additional constraint: A fo:footnote is not
+ * TODO implement additional constraint: A fo:footnote is not
* permitted to have as a descendant a fo:block-container that
* generates an absolutely positioned area.
*/
diff --git a/src/java/org/apache/fop/fo/flow/Inline.java b/src/java/org/apache/fop/fo/flow/Inline.java
index e6e8e9c01..d9ae63ec8 100644
--- a/src/java/org/apache/fop/fo/flow/Inline.java
+++ b/src/java/org/apache/fop/fo/flow/Inline.java
@@ -120,7 +120,8 @@ public class Inline extends InlineLevel implements StructurePointerPropertySet {
} else if (!isBlockOrInlineItem(nsURI, localName)) {
invalidChildError(loc, nsURI, localName);
} else if (!canHaveBlockLevelChildren && isBlockItem(nsURI, localName)) {
- invalidChildError(loc, getParent().getName(), nsURI, getName(), "rule.inlineContent");
+ invalidChildError(loc, getParent().getName(), nsURI, getName(),
+ "rule.inlineContent");
} else {
blockOrInlineItemFound = true;
}
diff --git a/src/java/org/apache/fop/fo/flow/Leader.java b/src/java/org/apache/fop/fo/flow/Leader.java
index c25fc8cab..54027514c 100644
--- a/src/java/org/apache/fop/fo/flow/Leader.java
+++ b/src/java/org/apache/fop/fo/flow/Leader.java
@@ -30,7 +30,7 @@ import org.apache.fop.fo.properties.LengthRangeProperty;
* <code>fo:leader</code></a> object.
* The main property of <code>fo:leader</code> is leader-pattern.
* The following patterns are treated: rule, space, dots and use-content.
- * @todo implement validateChildNode()
+ * TODO implement validateChildNode()
*/
public class Leader extends InlineLevel {
// The value of properties relevant for fo:leader.
diff --git a/src/java/org/apache/fop/fo/flow/ListItem.java b/src/java/org/apache/fop/fo/flow/ListItem.java
index f748bc15a..c4a2aa64b 100644
--- a/src/java/org/apache/fop/fo/flow/ListItem.java
+++ b/src/java/org/apache/fop/fo/flow/ListItem.java
@@ -119,7 +119,7 @@ public class ListItem extends FObj implements BreakPropertySet {
/**
* {@inheritDoc}
- * @todo see if can/should rely on base class for this
+ * TODO see if can/should rely on base class for this
* (i.e., add to childNodes instead)
*/
public void addChildNode(FONode child) {
diff --git a/src/java/org/apache/fop/fo/flow/Marker.java b/src/java/org/apache/fop/fo/flow/Marker.java
index 01863c0c7..4588a9df3 100644
--- a/src/java/org/apache/fop/fo/flow/Marker.java
+++ b/src/java/org/apache/fop/fo/flow/Marker.java
@@ -19,7 +19,6 @@
package org.apache.fop.fo.flow;
-import java.util.Collections;
import java.util.Map;
import org.xml.sax.Attributes;
@@ -111,7 +110,7 @@ public class Marker extends FObjMixed {
* <br><i>Additionally: "An fo:marker may contain any formatting objects that
* are permitted as a replacement of any fo:retrieve-marker that retrieves
* the fo:marker's children."</i>
- * @todo implement "additional" constraint, possibly within fo:retrieve-marker
+ * TODO implement "additional" constraint, possibly within fo:retrieve-marker
*/
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws ValidationException {
@@ -199,17 +198,25 @@ public class Marker extends FObjMixed {
name = attributes.getLocalName(i);
value = attributes.getValue(i);
- this.attribs[i] =
- MarkerAttribute.getInstance(namespace, qname, name, value);
+ this.attribs[i]
+ = MarkerAttribute.getInstance(namespace, qname, name, value);
}
}
- /** Null implementation; not used by this type of {@link PropertyList} */
+ /**
+ * Null implementation; not used by this type of {@link PropertyList}.
+ * @param propId the propert id
+ * @param value the property value
+ */
public void putExplicit(int propId, Property value) {
//nop
}
- /** Null implementation; not used by this type of {@link PropertyList} */
+ /**
+ * Null implementation; not used by this type of {@link PropertyList}.
+ * @param propId the propert id
+ * @return the property id
+ */
public Property getExplicit(int propId) {
return null;
}
@@ -259,7 +266,11 @@ public class Marker extends FObjMixed {
}
}
- /** Default implementation; not used */
+ /**
+ * Default implementation; not used.
+ * @param index a type index
+ * @return type string
+ */
public String getType(int index) {
return "CDATA";
}
@@ -305,12 +316,21 @@ public class Marker extends FObjMixed {
return index;
}
- /** Default implementation; not used */
+ /**
+ * Default implementation; not used
+ * @param name a type name
+ * @param namespace a type namespace
+ * @return type string
+ */
public String getType(String name, String namespace) {
return "CDATA";
}
- /** Default implementation; not used */
+ /**
+ * Default implementation; not used
+ * @param qname a type name
+ * @return type string
+ */
public String getType(String qname) {
return "CDATA";
}
@@ -337,12 +357,16 @@ public class Marker extends FObjMixed {
/** Convenience inner class */
public static final class MarkerAttribute {
- private static PropertyCache attributeCache =
- new PropertyCache(MarkerAttribute.class);
+ private static PropertyCache attributeCache
+ = new PropertyCache(MarkerAttribute.class);
+ /** namespace */
protected String namespace;
+ /** qualfied name */
protected String qname;
+ /** local name */
protected String name;
+ /** value */
protected String value;
/**
diff --git a/src/java/org/apache/fop/fo/flow/MultiCase.java b/src/java/org/apache/fop/fo/flow/MultiCase.java
index b2d630ba7..ac965dffb 100644
--- a/src/java/org/apache/fop/fo/flow/MultiCase.java
+++ b/src/java/org/apache/fop/fo/flow/MultiCase.java
@@ -27,7 +27,7 @@ import org.apache.fop.fo.PropertyList;
/**
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_multi-case">
* <code>fo:multi-case</code></a> object.
- * @todo implement validateChildNode()
+ * TODO implement validateChildNode()
*/
public class MultiCase extends FObj {
// The value of properties relevant for fo:multi-case.
@@ -38,7 +38,7 @@ public class MultiCase extends FObj {
// private CommonAccessibility commonAccessibility;
// End of property values
- static boolean notImplementedWarningGiven = false;
+ private static boolean notImplementedWarningGiven = false;
/**
* Base constructor
diff --git a/src/java/org/apache/fop/fo/flow/MultiProperties.java b/src/java/org/apache/fop/fo/flow/MultiProperties.java
index 091934203..3e2e57d97 100644
--- a/src/java/org/apache/fop/fo/flow/MultiProperties.java
+++ b/src/java/org/apache/fop/fo/flow/MultiProperties.java
@@ -37,11 +37,11 @@ public class MultiProperties extends FObj {
// private CommonAccessibility commonAccessibility;
// End of property values
- static boolean notImplementedWarningGiven = false;
+ private static boolean notImplementedWarningGiven = false;
// used for input FO validation
- boolean hasMultiPropertySet = false;
- boolean hasWrapper = false;
+ private boolean hasMultiPropertySet = false;
+ private boolean hasWrapper = false;
/**
* Base constructor
diff --git a/src/java/org/apache/fop/fo/flow/MultiPropertySet.java b/src/java/org/apache/fop/fo/flow/MultiPropertySet.java
index 96e73ec97..6e7c6a3e0 100644
--- a/src/java/org/apache/fop/fo/flow/MultiPropertySet.java
+++ b/src/java/org/apache/fop/fo/flow/MultiPropertySet.java
@@ -37,7 +37,7 @@ public class MultiPropertySet extends FObj {
// private ToBeImplementedProperty activeState;
// End of property values
- static boolean notImplementedWarningGiven = false;
+ private static boolean notImplementedWarningGiven = false;
/**
* Base constructor
diff --git a/src/java/org/apache/fop/fo/flow/MultiSwitch.java b/src/java/org/apache/fop/fo/flow/MultiSwitch.java
index 1db72159e..aa18d6cdf 100644
--- a/src/java/org/apache/fop/fo/flow/MultiSwitch.java
+++ b/src/java/org/apache/fop/fo/flow/MultiSwitch.java
@@ -39,7 +39,7 @@ public class MultiSwitch extends FObj {
// private CommonAccessibility commonAccessibility;
// End of property values
- static boolean notImplementedWarningGiven = false;
+ private static boolean notImplementedWarningGiven = false;
/**
* Base constructor
diff --git a/src/java/org/apache/fop/fo/flow/MultiToggle.java b/src/java/org/apache/fop/fo/flow/MultiToggle.java
index aacfda8eb..10766680e 100644
--- a/src/java/org/apache/fop/fo/flow/MultiToggle.java
+++ b/src/java/org/apache/fop/fo/flow/MultiToggle.java
@@ -39,7 +39,7 @@ public class MultiToggle extends FObj {
// public ToBeImplementedProperty prSwitchTo;
// End of property values
- static boolean notImplementedWarningGiven = false;
+ private static boolean notImplementedWarningGiven = false;
/**
* Base constructor
diff --git a/src/java/org/apache/fop/fo/flow/RetrieveTableMarker.java b/src/java/org/apache/fop/fo/flow/RetrieveTableMarker.java
index c58ecc628..3fe977b21 100644
--- a/src/java/org/apache/fop/fo/flow/RetrieveTableMarker.java
+++ b/src/java/org/apache/fop/fo/flow/RetrieveTableMarker.java
@@ -16,6 +16,7 @@
*/
/* $Id$ */
+
package org.apache.fop.fo.flow;
import org.apache.fop.fo.FONode;
@@ -50,7 +51,9 @@ public class RetrieveTableMarker extends AbstractRetrieveMarker {
* <i>NOTE: An <code>fo:retrieve-table-marker</code> is only permitted as a descendant
* of an <code>fo:table-header</code> or an <code>fo:table-footer</code>.</i>
*/
- public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList pList) throws FOPException {
+ public void processNode
+ (String elementName, Locator locator, Attributes attlist, PropertyList pList)
+ throws FOPException {
if (findAncestor(FO_TABLE_HEADER) < 0
&& findAncestor(FO_TABLE_FOOTER) < 0) {
invalidChildError(locator, getParent().getName(), FO_URI, getName(),
diff --git a/src/java/org/apache/fop/fo/flow/Wrapper.java b/src/java/org/apache/fop/fo/flow/Wrapper.java
index 74072da87..7fb412521 100644
--- a/src/java/org/apache/fop/fo/flow/Wrapper.java
+++ b/src/java/org/apache/fop/fo/flow/Wrapper.java
@@ -76,7 +76,8 @@ public class Wrapper extends FObjMixed {
try {
FONode.validateChildNode(this.parent, loc, nsURI, localName);
} catch (ValidationException vex) {
- invalidChildError(loc, getName(), FO_URI, localName, "rule.wrapperInvalidChildForParent");
+ invalidChildError(loc, getName(), FO_URI, localName,
+ "rule.wrapperInvalidChildForParent");
}
blockOrInlineItemFound = true;
} else {
diff --git a/src/java/org/apache/fop/fo/flow/table/ColumnNumberManager.java b/src/java/org/apache/fop/fo/flow/table/ColumnNumberManager.java
index 1f73f5f10..9f3ed195d 100644
--- a/src/java/org/apache/fop/fo/flow/table/ColumnNumberManager.java
+++ b/src/java/org/apache/fop/fo/flow/table/ColumnNumberManager.java
@@ -77,8 +77,7 @@ public class ColumnNumberManager {
for (int i = 0; i < pendingSpans.size(); i++) {
pSpan = (PendingSpan) pendingSpans.get(i);
if (pSpan != null) {
- pSpan.rowsLeft--;
- if (pSpan.rowsLeft == 0) {
+ if ( pSpan.decrRowsLeft() == 0 ) {
pendingSpans.set(i, null);
} else {
usedColumnIndices.set(i);
diff --git a/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java b/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java
index 5ff01b7fa..b5cd56d47 100644
--- a/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java
+++ b/src/java/org/apache/fop/fo/flow/table/ConditionalBorder.java
@@ -36,20 +36,23 @@ import org.apache.fop.layoutmgr.table.CollapsingBorderModel;
*/
public class ConditionalBorder {
+ /** normal border */
public static final int NORMAL = 0;
+ /** leading and trailing border */
public static final int LEADING_TRAILING = 1;
+ /** all the rest */
public static final int REST = 2;
/** Normal case, no break. */
- BorderSpecification normal;
+ BorderSpecification normal; // CSOK: VisibilityModifier
/** Special case: the cell is at the top or the bottom of the page. */
- BorderSpecification leadingTrailing;
+ BorderSpecification leadingTrailing; // CSOK: VisibilityModifier
/** Special case: break inside the cell. */
- BorderSpecification rest;
+ BorderSpecification rest; // CSOK: VisibilityModifier
/** The model used to resolve borders. */
private CollapsingBorderModel collapsingBorderModel;
diff --git a/src/java/org/apache/fop/fo/flow/table/GridUnit.java b/src/java/org/apache/fop/fo/flow/table/GridUnit.java
index 229a7177f..37f3df37c 100644
--- a/src/java/org/apache/fop/fo/flow/table/GridUnit.java
+++ b/src/java/org/apache/fop/fo/flow/table/GridUnit.java
@@ -65,13 +65,13 @@ public class GridUnit {
private byte flags = 0;
/** the border-before specification */
- ConditionalBorder borderBefore;
+ ConditionalBorder borderBefore; // CSOK: VisibilityModifier
/** the border-after specification */
- ConditionalBorder borderAfter;
+ ConditionalBorder borderAfter; // CSOK: VisibilityModifier
/** the border-start specification */
- BorderSpecification borderStart;
+ BorderSpecification borderStart; // CSOK: VisibilityModifier
/** the border-end specification */
- BorderSpecification borderEnd;
+ BorderSpecification borderEnd; // CSOK: VisibilityModifier
/** The border model helper associated with the table */
protected CollapsingBorderModel collapsingBorderModel;
diff --git a/src/java/org/apache/fop/fo/flow/table/PendingSpan.java b/src/java/org/apache/fop/fo/flow/table/PendingSpan.java
index 321684fae..0a5a2b41a 100644
--- a/src/java/org/apache/fop/fo/flow/table/PendingSpan.java
+++ b/src/java/org/apache/fop/fo/flow/table/PendingSpan.java
@@ -27,7 +27,7 @@ class PendingSpan {
/**
* member variable holding the number of rows left
*/
- int rowsLeft;
+ private int rowsLeft;
/**
* Constructor
@@ -37,4 +37,22 @@ class PendingSpan {
public PendingSpan(int rows) {
rowsLeft = rows;
}
+
+ /** @return number of rows spanned */
+ public int getRowsLeft() {
+ return rowsLeft;
+ }
+
+ /**
+ * Decrement rows spanned.
+ * @return number of rows spanned after decrementing
+ */
+ public int decrRowsLeft() {
+ if ( rowsLeft > 0 ) {
+ return --rowsLeft;
+ } else {
+ return 0;
+ }
+ }
+
} \ No newline at end of file
diff --git a/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java b/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
index 9326d6cd4..529a6acc2 100644
--- a/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
+++ b/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
@@ -85,6 +85,10 @@ public class PrimaryGridUnit extends GridUnit {
return (TablePart) node;
}
+ /**
+ * Get cell's layout manager.
+ * @return the cell's layout manager
+ */
public TableCellLayoutManager getCellLM() {
assert cellLM != null;
return cellLM;
@@ -109,6 +113,10 @@ public class PrimaryGridUnit extends GridUnit {
this.elements = elements;
}
+ /**
+ * Obtain the Knuth elements.
+ * @return a list of Knuth elements
+ */
public List getElements() {
return this.elements;
}
@@ -247,6 +255,10 @@ public class PrimaryGridUnit extends GridUnit {
return this.rows;
}
+ /**
+ * Add a row.
+ * @param row the row to be added
+ */
public void addRow(GridUnit[] row) {
if (rows == null) {
rows = new java.util.ArrayList();
diff --git a/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java b/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java
index 919e73bfb..634460ec4 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java
@@ -30,7 +30,7 @@ import org.apache.fop.fo.ValidationException;
/**
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table-and-caption">
* <code>fo:table-and-caption</code></a> property.
- * @todo needs implementation
+ * TODO needs implementation
*/
public class TableAndCaption extends FObj /*implements BreakPropertySet*/ {
// The value of properties relevant for fo:table-and-caption.
@@ -50,7 +50,7 @@ public class TableAndCaption extends FObj /*implements BreakPropertySet*/ {
// private int textAlign;
// End of property values
- static boolean notImplementedWarningGiven = false;
+ private static boolean notImplementedWarningGiven = false;
/** used for FO validation */
private boolean tableCaptionFound = false;
diff --git a/src/java/org/apache/fop/fo/flow/table/TableCaption.java b/src/java/org/apache/fop/fo/flow/table/TableCaption.java
index bbc9b52bc..fc5d3d5b7 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableCaption.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableCaption.java
@@ -49,7 +49,7 @@ public class TableCaption extends FObj {
/** used for FO validation */
private boolean blockItemFound = false;
- static boolean notImplementedWarningGiven = false;
+ private static boolean notImplementedWarningGiven = false;
/**
* Create a TableCaption instance with the given {@link FONode}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableCellContainer.java b/src/java/org/apache/fop/fo/flow/table/TableCellContainer.java
index 9b4fe755f..41eab578f 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableCellContainer.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableCellContainer.java
@@ -30,14 +30,26 @@ import org.apache.fop.fo.FONode;
*/
public abstract class TableCellContainer extends TableFObj implements ColumnNumberManagerHolder {
+ /** list of pending spans */
protected List pendingSpans;
+ /** column number manager */
protected ColumnNumberManager columnNumberManager;
+ /**
+ * Construct table cell container.
+ * @param parent the parent node of the cell container
+ */
public TableCellContainer(FONode parent) {
super(parent);
}
+ /**
+ * Add cell to current row.
+ * @param cell a table cell to add
+ * @param firstRow true is first row
+ * @throws FOPException if exception occurs
+ */
protected void addTableCellChild(TableCell cell, boolean firstRow) throws FOPException {
int colNumber = cell.getColumnNumber();
int colSpan = cell.getNumberColumnsSpanned();
diff --git a/src/java/org/apache/fop/fo/flow/table/TableEventProducer.java b/src/java/org/apache/fop/fo/flow/table/TableEventProducer.java
index d6abf609e..792151360 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableEventProducer.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableEventProducer.java
@@ -32,7 +32,10 @@ import org.apache.fop.fo.expr.PropertyException;
public interface TableEventProducer extends EventProducer {
/** Provider class for the event producer. */
- class Provider {
+ static final class Provider {
+
+ private Provider() {
+ }
/**
* Returns an event producer.
diff --git a/src/java/org/apache/fop/fo/flow/table/TableFObj.java b/src/java/org/apache/fop/fo/flow/table/TableFObj.java
index ab8676cb3..fce82dcff 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableFObj.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableFObj.java
@@ -50,12 +50,12 @@ public abstract class TableFObj extends FObj implements StructurePointerProperty
private Numeric borderStartPrecedence;
private String ptr;
- ConditionalBorder borderBefore;
- ConditionalBorder borderAfter;
- BorderSpecification borderStart;
- BorderSpecification borderEnd;
+ ConditionalBorder borderBefore; // CSOK: VisibilityModifier
+ ConditionalBorder borderAfter; // CSOK: VisibilityModifier
+ BorderSpecification borderStart; // CSOK: VisibilityModifier
+ BorderSpecification borderEnd; // CSOK: VisibilityModifier
- CollapsingBorderModel collapsingBorderModel;
+ CollapsingBorderModel collapsingBorderModel; // CSOK: VisibilityModifier
/**
* Create a TableFObj instance that is a child
@@ -205,9 +205,10 @@ public abstract class TableFObj extends FObj implements StructurePointerProperty
int foId = propertyList.getFObj().getNameId();
if (i <= 0) {
if (foId == FO_TABLE_CELL || foId == FO_TABLE_COLUMN) {
- ColumnNumberManagerHolder parent =
- (ColumnNumberManagerHolder) propertyList.getParentFObj();
- ColumnNumberManager columnIndexManager = parent.getColumnNumberManager();
+ ColumnNumberManagerHolder parent
+ = (ColumnNumberManagerHolder) propertyList.getParentFObj();
+ ColumnNumberManager columnIndexManager
+ = parent.getColumnNumberManager();
i = columnIndexManager.getCurrentColumnNumber();
} else {
/* very exceptional case:
@@ -216,10 +217,10 @@ public abstract class TableFObj extends FObj implements StructurePointerProperty
*/
i = 1;
}
- TableEventProducer eventProducer =
- TableEventProducer.Provider.get(fo.getUserAgent().getEventBroadcaster());
+ TableEventProducer eventProducer = TableEventProducer.Provider.get(
+ fo.getUserAgent().getEventBroadcaster());
eventProducer.forceNextColumnNumber(this, propertyList.getFObj().getName(),
- val, i, propertyList.getFObj().getLocator());
+ val, i, propertyList.getFObj().getLocator());
}
return NumberProperty.getInstance(i);
}
@@ -229,7 +230,8 @@ public abstract class TableFObj extends FObj implements StructurePointerProperty
}
/** {@inheritDoc} */
- public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList pList) throws FOPException {
+ public void processNode(String elementName, Locator locator, Attributes attlist,
+ PropertyList pList) throws FOPException {
super.processNode(elementName, locator, attlist, pList);
Table table = getTable();
if (!inMarker() && !table.isSeparateBorderModel()) {
diff --git a/src/java/org/apache/fop/fo/flow/table/TablePart.java b/src/java/org/apache/fop/fo/flow/table/TablePart.java
index 5b04cddc7..3ab92cc94 100644
--- a/src/java/org/apache/fop/fo/flow/table/TablePart.java
+++ b/src/java/org/apache/fop/fo/flow/table/TablePart.java
@@ -46,10 +46,9 @@ public abstract class TablePart extends TableCellContainer {
// private int visibility;
// End of property values
- /**
- * used for validation
- */
+ /** table rows found */
protected boolean tableRowsFound = false;
+ /** table cells found */
protected boolean tableCellsFound = false;
private boolean firstRow = true;
@@ -124,6 +123,10 @@ public abstract class TablePart extends TableCellContainer {
return this;
}
+ /**
+ * Finish last row group.
+ * @throws ValidationException if content validation exception
+ */
protected void finishLastRowGroup() throws ValidationException {
if (!inMarker()) {
RowGroupBuilder rowGroupBuilder = getTable().getRowGroupBuilder();
@@ -214,6 +217,7 @@ public abstract class TablePart extends TableCellContainer {
rowGroups.add(rowGroup);
}
+ /** @return list of row groups */
public List getRowGroups() {
return rowGroups;
}
diff --git a/src/java/org/apache/fop/fo/flow/table/TableRow.java b/src/java/org/apache/fop/fo/flow/table/TableRow.java
index 2feb45d86..dd9f7c6d4 100644
--- a/src/java/org/apache/fop/fo/flow/table/TableRow.java
+++ b/src/java/org/apache/fop/fo/flow/table/TableRow.java
@@ -144,7 +144,6 @@ public class TableRow extends TableCellContainer implements BreakPropertySet {
return (TablePart) parent;
}
- /** {@inheritDoc} */
boolean isTableRow() {
return true;
}
diff --git a/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java b/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
index dce36f95c..51b24b314 100644
--- a/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
+++ b/src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
@@ -34,7 +34,9 @@ import org.apache.fop.fo.PropertyList;
public abstract class AbstractPageSequence extends FObj {
// The value of properties relevant for fo:page-sequence.
+ /** initial page number */
protected Numeric initialPageNumber;
+ /** forced page count */
protected int forcePageCount;
private String format;
private int letterValue;
@@ -45,6 +47,7 @@ public abstract class AbstractPageSequence extends FObj {
private PageNumberGenerator pageNumberGenerator;
+ /** starting page number */
protected int startingPageNumber = 0;
/**
diff --git a/src/java/org/apache/fop/fo/pagination/Declarations.java b/src/java/org/apache/fop/fo/pagination/Declarations.java
index 1385bccc9..9c68043ff 100644
--- a/src/java/org/apache/fop/fo/pagination/Declarations.java
+++ b/src/java/org/apache/fop/fo/pagination/Declarations.java
@@ -41,7 +41,7 @@ import org.apache.fop.fo.ValidationException;
*/
public class Declarations extends FObj {
- private Map colorProfiles = null;
+ private Map<String, ColorProfile> colorProfiles = null;
/**
* @param parent FONode that is the parent of this object
@@ -98,7 +98,7 @@ public class Declarations extends FObj {
private void addColorProfile(ColorProfile cp) {
if (colorProfiles == null) {
- colorProfiles = new java.util.HashMap();
+ colorProfiles = new java.util.HashMap<String, ColorProfile>();
}
if (colorProfiles.get(cp.getColorProfileName()) != null) {
// duplicate names
@@ -132,7 +132,7 @@ public class Declarations extends FObj {
public ColorProfile getColorProfile(String cpName) {
ColorProfile profile = null;
if (this.colorProfiles != null) {
- profile = (ColorProfile)this.colorProfiles.get(cpName);
+ profile = this.colorProfiles.get(cpName);
}
return profile;
}
diff --git a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
index 482ec83c4..c4189d0c4 100644
--- a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
+++ b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java
@@ -44,8 +44,8 @@ import org.apache.fop.fo.ValidationException;
*/
public class LayoutMasterSet extends FObj {
- private Map simplePageMasters;
- private Map pageSequenceMasters;
+ private Map<String, SimplePageMaster> simplePageMasters;
+ private Map<String, PageSequenceMaster> pageSequenceMasters;
/**
* Create a LayoutMasterSet instance that is a child of the given
@@ -65,8 +65,8 @@ public class LayoutMasterSet extends FObj {
/** {@inheritDoc} */
protected void startOfNode() throws FOPException {
getRoot().setLayoutMasterSet(this);
- simplePageMasters = new java.util.HashMap();
- pageSequenceMasters = new java.util.HashMap();
+ simplePageMasters = new java.util.HashMap<String, SimplePageMaster>();
+ pageSequenceMasters = new java.util.HashMap<String, PageSequenceMaster>();
}
/** {@inheritDoc} */
@@ -98,18 +98,13 @@ public class LayoutMasterSet extends FObj {
*/
private void checkRegionNames() throws ValidationException {
// (user-entered) region-name to default region map.
- Map allRegions = new java.util.HashMap();
- for (Iterator spm = simplePageMasters.values().iterator();
- spm.hasNext();) {
- SimplePageMaster simplePageMaster
- = (SimplePageMaster)spm.next();
- Map spmRegions = simplePageMaster.getRegions();
- for (Iterator e = spmRegions.values().iterator();
- e.hasNext();) {
- Region region = (Region) e.next();
+ Map<String, String> allRegions = new java.util.HashMap<String, String>();
+ for (SimplePageMaster simplePageMaster : simplePageMasters.values()) {
+ Map<String, Region> spmRegions = simplePageMaster.getRegions();
+ for (Region region : spmRegions.values()) {
if (allRegions.containsKey(region.getRegionName())) {
String defaultRegionName
- = (String) allRegions.get(region.getRegionName());
+ = allRegions.get(region.getRegionName());
if (!defaultRegionName.equals(region.getDefaultRegionName())) {
getFOValidationEventProducer().regionNameMappedToMultipleRegionClasses(this,
region.getRegionName(),
@@ -118,7 +113,7 @@ public class LayoutMasterSet extends FObj {
}
}
allRegions.put(region.getRegionName(),
- region.getDefaultRegionName());
+ region.getDefaultRegionName());
}
}
}
@@ -155,7 +150,7 @@ public class LayoutMasterSet extends FObj {
* @return the requested simple-page-master
*/
public SimplePageMaster getSimplePageMaster(String masterName) {
- return (SimplePageMaster)this.simplePageMasters.get(masterName);
+ return this.simplePageMasters.get(masterName);
}
/**
@@ -185,7 +180,7 @@ public class LayoutMasterSet extends FObj {
* @return the requested PageSequenceMaster instance
*/
public PageSequenceMaster getPageSequenceMaster(String masterName) {
- return (PageSequenceMaster)this.pageSequenceMasters.get(masterName);
+ return this.pageSequenceMasters.get(masterName);
}
/**
@@ -194,9 +189,8 @@ public class LayoutMasterSet extends FObj {
* @return true when the region name specified has a region in this LayoutMasterSet
*/
public boolean regionNameExists(String regionName) {
- for (Iterator e = simplePageMasters.values().iterator();
- e.hasNext();) {
- if (((SimplePageMaster)e.next()).regionNameExists(regionName)) {
+ for (SimplePageMaster spm : simplePageMasters.values()) {
+ if (spm.regionNameExists(regionName)) {
return true;
}
}
diff --git a/src/java/org/apache/fop/fo/pagination/PageProductionException.java b/src/java/org/apache/fop/fo/pagination/PageProductionException.java
index bb09db6f4..39060f3d4 100644
--- a/src/java/org/apache/fop/fo/pagination/PageProductionException.java
+++ b/src/java/org/apache/fop/fo/pagination/PageProductionException.java
@@ -98,7 +98,7 @@ public class PageProductionException extends RuntimeException {
}
/** {@inheritDoc} */
- public Class getExceptionClass() {
+ public Class<PageProductionException> getExceptionClass() {
return PageProductionException.class;
}
diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java
index 26812166d..ee78bb8ba 100644
--- a/src/java/org/apache/fop/fo/pagination/PageSequence.java
+++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java
@@ -48,7 +48,7 @@ public class PageSequence extends AbstractPageSequence {
// the set of flows includes StaticContent flows also
/** Map of flows to their flow name (flow-name, Flow) */
- private Map/*<String, Flow>*/ flowMap;
+ private Map<String, Flow> flowMap;
/**
* The currentSimplePageMaster is either the page master for the
@@ -96,7 +96,7 @@ public class PageSequence extends AbstractPageSequence {
/** {@inheritDoc} */
protected void startOfNode() throws FOPException {
super.startOfNode();
- flowMap = new java.util.HashMap/*<String, Flow>*/();
+ flowMap = new java.util.HashMap<String, Flow>();
this.simplePageMaster
= getRoot().getLayoutMasterSet().getSimplePageMaster(masterReference);
@@ -151,7 +151,7 @@ public class PageSequence extends AbstractPageSequence {
/**
* {@inheritDoc}
- * @todo see if addChildNode() should also be called for fo's other than
+ * TODO see if addChildNode() should also be called for fo's other than
* fo:flow.
*/
public void addChildNode(FONode child) throws FOPException {
@@ -167,7 +167,7 @@ public class PageSequence extends AbstractPageSequence {
break;
case FO_STATIC_CONTENT:
addFlow((StaticContent)child);
- flowMap.put(((StaticContent)child).getFlowName(), child);
+ flowMap.put(((Flow)child).getFlowName(), (Flow)child);
break;
default:
super.addChildNode(child);
@@ -239,7 +239,7 @@ public class PageSequence extends AbstractPageSequence {
}
/** @return the flow map for this page-sequence */
- public Map getFlowMap() {
+ public Map<String, Flow> getFlowMap() {
return this.flowMap;
}
@@ -254,10 +254,9 @@ public class PageSequence extends AbstractPageSequence {
* @return the SimplePageMaster to use for this page
* @throws PageProductionException if there's a problem determining the page master
*/
- public SimplePageMaster getNextSimplePageMaster(int page,
- boolean isFirstPage,
- boolean isLastPage,
- boolean isBlank) throws PageProductionException {
+ public SimplePageMaster getNextSimplePageMaster
+ (int page, boolean isFirstPage, boolean isLastPage, boolean isBlank)
+ throws PageProductionException {
if (pageSequenceMaster == null) {
return simplePageMaster;
diff --git a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
index 705b955e9..5b71525d3 100644
--- a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
+++ b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
@@ -44,7 +44,7 @@ public class PageSequenceMaster extends FObj {
// End of property values
private LayoutMasterSet layoutMasterSet;
- private List subSequenceSpecifiers;
+ private List<SubSequenceSpecifier> subSequenceSpecifiers;
private SubSequenceSpecifier currentSubSequence;
private int currentSubSequenceNumber = -1;
@@ -76,7 +76,7 @@ public class PageSequenceMaster extends FObj {
/** {@inheritDoc} */
protected void startOfNode() throws FOPException {
- subSequenceSpecifiers = new java.util.ArrayList();
+ subSequenceSpecifiers = new java.util.ArrayList<SubSequenceSpecifier>();
layoutMasterSet = parent.getRoot().getLayoutMasterSet();
layoutMasterSet.addPageSequenceMaster(masterName, this);
}
@@ -121,8 +121,7 @@ public class PageSequenceMaster extends FObj {
currentSubSequenceNumber++;
if (currentSubSequenceNumber >= 0
&& currentSubSequenceNumber < subSequenceSpecifiers.size()) {
- return (SubSequenceSpecifier)subSequenceSpecifiers
- .get(currentSubSequenceNumber);
+ return subSequenceSpecifiers.get(currentSubSequenceNumber);
}
return null;
}
@@ -134,8 +133,8 @@ public class PageSequenceMaster extends FObj {
currentSubSequenceNumber = -1;
currentSubSequence = null;
if (subSequenceSpecifiers != null) {
- for (int i = 0; i < subSequenceSpecifiers.size(); i++) {
- ((SubSequenceSpecifier)subSequenceSpecifiers.get(i)).reset();
+ for (SubSequenceSpecifier subSequenceSpecifier : subSequenceSpecifiers) {
+ subSequenceSpecifier.reset();
}
}
}
@@ -150,7 +149,7 @@ public class PageSequenceMaster extends FObj {
if (!success) {
if (currentSubSequenceNumber > 0) {
currentSubSequenceNumber--;
- currentSubSequence = (SubSequenceSpecifier)subSequenceSpecifiers
+ currentSubSequence = subSequenceSpecifiers
.get(currentSubSequenceNumber);
} else {
currentSubSequence = null;
diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java
index 6f94418be..a3c259aa7 100644
--- a/src/java/org/apache/fop/fo/pagination/Region.java
+++ b/src/java/org/apache/fop/fo/pagination/Region.java
@@ -31,7 +31,6 @@ import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.ValidationException;
-import org.apache.fop.fo.expr.PropertyException;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
/**
@@ -48,7 +47,8 @@ public abstract class Region extends FObj {
private int writingMode;
// End of property values
- private SimplePageMaster layoutMaster;
+ /** the parent {@link SimplePageMaster} */
+ protected final SimplePageMaster layoutMaster;
/**
* Base constructor
@@ -103,11 +103,9 @@ public abstract class Region extends FObj {
/**
* @param pageRefRect reference dimension of the page area.
- * @param spm the simple page master this region belongs to.
* @return the rectangle for the viewport area
*/
- public abstract Rectangle getViewportRectangle(FODimension pageRefRect
- , SimplePageMaster spm);
+ public abstract Rectangle getViewportRectangle(FODimension pageRefRect);
/**
* Returns the default region name (xsl-region-before, xsl-region-start,
diff --git a/src/java/org/apache/fop/fo/pagination/RegionAfter.java b/src/java/org/apache/fop/fo/pagination/RegionAfter.java
index 841bff0d6..bab5d46b8 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionAfter.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionAfter.java
@@ -44,7 +44,7 @@ public class RegionAfter extends RegionBA {
}
/** {@inheritDoc} */
- public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
+ public Rectangle getViewportRectangle (FODimension reldims) {
/* Special rules apply to resolving extent as values are resolved relative
* to the page size and reference orientation.
*/
@@ -52,7 +52,8 @@ public class RegionAfter extends RegionBA {
PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE);
PercentBaseContext neighbourContext;
Rectangle vpRect;
- if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
+ if (layoutMaster.getWritingMode() == EN_LR_TB
+ || layoutMaster.getWritingMode() == EN_RL_TB) {
neighbourContext = pageWidthContext;
vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageHeightContext)
, reldims.ipd, getExtent().getValue(pageHeightContext));
@@ -62,7 +63,7 @@ public class RegionAfter extends RegionBA {
, getExtent().getValue(pageWidthContext), reldims.ipd);
}
if (getPrecedence() == EN_FALSE) {
- adjustIPD(vpRect, spm.getWritingMode(), neighbourContext);
+ adjustIPD(vpRect, layoutMaster.getWritingMode(), neighbourContext);
}
return vpRect;
}
diff --git a/src/java/org/apache/fop/fo/pagination/RegionBefore.java b/src/java/org/apache/fop/fo/pagination/RegionBefore.java
index 71ea26818..4aa29ec90 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionBefore.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionBefore.java
@@ -25,7 +25,7 @@ import java.awt.Rectangle;
// FOP
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.datatypes.LengthBase;
-import org.apache.fop.datatypes.SimplePercentBaseContext;
+import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.fo.FONode;
/**
@@ -49,31 +49,16 @@ public class RegionBefore extends RegionBA {
}
/** {@inheritDoc} */
- public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
+ public Rectangle getViewportRectangle (FODimension reldims) {
/* Special rules apply to resolving extent as values are resolved relative
* to the page size and reference orientation.
*/
- SimplePercentBaseContext pageWidthContext;
- SimplePercentBaseContext pageHeightContext;
- if (spm.getReferenceOrientation() % 180 == 0) {
- pageWidthContext = new SimplePercentBaseContext(null,
- LengthBase.CUSTOM_BASE,
- spm.getPageWidth().getValue());
- pageHeightContext = new SimplePercentBaseContext(null,
- LengthBase.CUSTOM_BASE,
- spm.getPageHeight().getValue());
- } else {
- // invert width and height since top left are rotated by 90 (cl or ccl)
- pageWidthContext = new SimplePercentBaseContext(null,
- LengthBase.CUSTOM_BASE,
- spm.getPageHeight().getValue());
- pageHeightContext = new SimplePercentBaseContext(null,
- LengthBase.CUSTOM_BASE,
- spm.getPageWidth().getValue());
- }
- SimplePercentBaseContext neighbourContext;
+ PercentBaseContext pageWidthContext = getPageWidthContext(LengthBase.CUSTOM_BASE);
+ PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE);
+ PercentBaseContext neighbourContext;
Rectangle vpRect;
- if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
+ if (layoutMaster.getWritingMode() == EN_LR_TB
+ || layoutMaster.getWritingMode() == EN_RL_TB) {
neighbourContext = pageWidthContext;
vpRect = new Rectangle(0, 0, reldims.ipd, getExtent().getValue(pageHeightContext));
} else {
@@ -81,7 +66,7 @@ public class RegionBefore extends RegionBA {
vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.ipd);
}
if (getPrecedence() == EN_FALSE) {
- adjustIPD(vpRect, spm.getWritingMode(), neighbourContext);
+ adjustIPD(vpRect, layoutMaster.getWritingMode(), neighbourContext);
}
return vpRect;
}
diff --git a/src/java/org/apache/fop/fo/pagination/RegionBody.java b/src/java/org/apache/fop/fo/pagination/RegionBody.java
index 165bb4734..5eed36061 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionBody.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionBody.java
@@ -96,7 +96,7 @@ public class RegionBody extends Region {
}
/** {@inheritDoc} */
- public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
+ public Rectangle getViewportRectangle (FODimension reldims) {
/* Special rules apply to resolving margins in the page context.
* Contrary to normal margins in this case top and bottom margin
* are resolved relative to the height. In the property subsystem
@@ -106,12 +106,14 @@ public class RegionBody extends Region {
* Also the values are resolved relative to the page size
* and reference orientation.
*/
- PercentBaseContext pageWidthContext = getPageWidthContext(LengthBase.CONTAINING_BLOCK_WIDTH);
- PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CONTAINING_BLOCK_WIDTH);
+ PercentBaseContext pageWidthContext
+ = getPageWidthContext(LengthBase.CONTAINING_BLOCK_WIDTH);
+ PercentBaseContext pageHeightContext
+ = getPageHeightContext(LengthBase.CONTAINING_BLOCK_WIDTH);
int start;
int end;
- if (spm.getWritingMode() == EN_LR_TB) { // Left-to-right
+ if (layoutMaster.getWritingMode() == EN_LR_TB) { // Left-to-right
start = commonMarginBlock.marginLeft.getValue(pageWidthContext);
end = commonMarginBlock.marginRight.getValue(pageWidthContext);
} else { // all other supported modes are right-to-left
diff --git a/src/java/org/apache/fop/fo/pagination/RegionEnd.java b/src/java/org/apache/fop/fo/pagination/RegionEnd.java
index 8b348ed5d..2533763a5 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionEnd.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionEnd.java
@@ -44,7 +44,7 @@ public class RegionEnd extends RegionSE {
}
/** {@inheritDoc} */
- public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
+ public Rectangle getViewportRectangle (FODimension reldims) {
/* Special rules apply to resolving extent as values are resolved relative
* to the page size and reference orientation.
*/
@@ -52,7 +52,8 @@ public class RegionEnd extends RegionSE {
PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE);
PercentBaseContext neighbourContext;
Rectangle vpRect;
- if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
+ if (layoutMaster.getWritingMode() == EN_LR_TB
+ || layoutMaster.getWritingMode() == EN_RL_TB) {
neighbourContext = pageHeightContext;
vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageWidthContext), 0,
getExtent().getValue(pageWidthContext), reldims.bpd);
@@ -62,7 +63,7 @@ public class RegionEnd extends RegionSE {
vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageHeightContext), 0,
reldims.bpd, getExtent().getValue(pageHeightContext));
}
- adjustIPD(vpRect, spm.getWritingMode(), neighbourContext);
+ adjustIPD(vpRect, layoutMaster.getWritingMode(), neighbourContext);
return vpRect;
}
diff --git a/src/java/org/apache/fop/fo/pagination/RegionStart.java b/src/java/org/apache/fop/fo/pagination/RegionStart.java
index afe9ddfe1..fdb423c51 100644
--- a/src/java/org/apache/fop/fo/pagination/RegionStart.java
+++ b/src/java/org/apache/fop/fo/pagination/RegionStart.java
@@ -44,7 +44,7 @@ public class RegionStart extends RegionSE {
}
/** {@inheritDoc} */
- public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) {
+ public Rectangle getViewportRectangle (FODimension reldims) {
/* Special rules apply to resolving extent as values are resolved relative
* to the page size and reference orientation.
*/
@@ -52,14 +52,15 @@ public class RegionStart extends RegionSE {
PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE);
PercentBaseContext neighbourContext;
Rectangle vpRect;
- if (spm.getWritingMode() == EN_LR_TB || spm.getWritingMode() == EN_RL_TB) {
+ if (layoutMaster.getWritingMode() == EN_LR_TB
+ || layoutMaster.getWritingMode() == EN_RL_TB) {
neighbourContext = pageHeightContext;
vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.bpd);
} else {
neighbourContext = pageWidthContext;
vpRect = new Rectangle(0, 0, reldims.bpd, getExtent().getValue(pageHeightContext));
}
- adjustIPD(vpRect, spm.getWritingMode(), neighbourContext);
+ adjustIPD(vpRect, layoutMaster.getWritingMode(), neighbourContext);
return vpRect;
}
diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
index 9b4c6544f..629d7d59d 100644
--- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
+++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
@@ -48,7 +48,7 @@ public class RepeatablePageMasterAlternatives extends FObj
private int numberConsumed = 0;
- private List conditionalPageMasterRefs;
+ private List<ConditionalPageMasterReference> conditionalPageMasterRefs;
private boolean hasPagePositionLast = false;
private boolean hasPagePositionOnly = false;
@@ -68,7 +68,7 @@ public class RepeatablePageMasterAlternatives extends FObj
/** {@inheritDoc} */
protected void startOfNode() throws FOPException {
- conditionalPageMasterRefs = new java.util.ArrayList();
+ conditionalPageMasterRefs = new java.util.ArrayList<ConditionalPageMasterReference>();
assert parent.getName().equals("fo:page-sequence-master"); //Validation by the parent
PageSequenceMaster pageSequenceMaster = (PageSequenceMaster)parent;
@@ -128,9 +128,7 @@ public class RepeatablePageMasterAlternatives extends FObj
numberConsumed++;
}
- for (int i = 0; i < conditionalPageMasterRefs.size(); i++) {
- ConditionalPageMasterReference cpmr
- = (ConditionalPageMasterReference)conditionalPageMasterRefs.get(i);
+ for (ConditionalPageMasterReference cpmr : conditionalPageMasterRefs) {
if (cpmr.isValid(isOddPage, isFirstPage, isLastPage, isBlankPage)) {
return cpmr.getMasterReference();
}
diff --git a/src/java/org/apache/fop/fo/pagination/Root.java b/src/java/org/apache/fop/fo/pagination/Root.java
index fcbb54abd..fb69dc2f1 100644
--- a/src/java/org/apache/fop/fo/pagination/Root.java
+++ b/src/java/org/apache/fop/fo/pagination/Root.java
@@ -47,8 +47,8 @@ public class Root extends FObj {
private LayoutMasterSet layoutMasterSet;
private Declarations declarations;
private BookmarkTree bookmarkTree = null;
- private List destinationList;
- private List pageSequences;
+ private List<Destination> destinationList;
+ private List<PageSequence> pageSequences;
// temporary until above list populated
private boolean pageSequenceFound = false;
@@ -77,11 +77,12 @@ public class Root extends FObj {
*/
public Root(FONode parent) {
super(parent);
- pageSequences = new java.util.ArrayList();
+ pageSequences = new java.util.ArrayList<PageSequence>();
}
/** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
+ super.bind(pList);
mediaUsage = pList.get(PR_MEDIA_USAGE).getEnum();
}
@@ -144,7 +145,11 @@ public class Root extends FObj {
}
- /** @inheritDoc */
+ /**
+ * @param loc location in the source file
+ * @param child the {@link FONode} to validate against
+ * @throws ValidationException if the incoming node is not a valid child for the given FO
+ */
protected void validateChildNode(Locator loc, FONode child) throws ValidationException {
if (child instanceof AbstractPageSequence) {
pageSequenceFound = true;
@@ -207,7 +212,8 @@ public class Root extends FObj {
* @param additionalPages the total pages generated by the sequence (for statistics)
* @throws IllegalArgumentException for negative additional page counts
*/
- public void notifyPageSequenceFinished(int lastPageNumber, int additionalPages) {
+ public void notifyPageSequenceFinished(int lastPageNumber, int additionalPages)
+ throws IllegalArgumentException {
if (additionalPages >= 0) {
totalPagesGenerated += additionalPages;
@@ -238,7 +244,7 @@ public class Root extends FObj {
return null;
}
if (currentIndex < (pageSequences.size() - 1)) {
- return (PageSequence)pageSequences.get(currentIndex + 1);
+ return pageSequences.get(currentIndex + 1);
} else {
return null;
}
@@ -290,7 +296,7 @@ public class Root extends FObj {
*/
public void addDestination(Destination destination) {
if (destinationList == null) {
- destinationList = new java.util.ArrayList();
+ destinationList = new java.util.ArrayList<Destination>();
}
destinationList.add(destination);
}
diff --git a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
index 8c95e1b8a..bd186db78 100644
--- a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
+++ b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java
@@ -56,7 +56,7 @@ public class SimplePageMaster extends FObj {
/**
* Page regions (regionClass, Region)
*/
- private Map regions;
+ private Map<String, Region> regions;
// used for node validation
private boolean hasRegionBody = false;
@@ -99,7 +99,7 @@ public class SimplePageMaster extends FObj {
}
//Well, there are only 5 regions so we can save a bit of memory here
- regions = new HashMap(5);
+ regions = new HashMap<String, Region>(5);
}
/** {@inheritDoc} */
@@ -135,7 +135,7 @@ public class SimplePageMaster extends FObj {
} else if (hasRegionEnd) {
nodesOutOfOrderError(loc, "fo:region-before", "fo:region-end");
} else {
- hasRegionBody = true;
+ hasRegionBefore = true;
}
} else if (localName.equals("region-after")) {
if (!hasRegionBody) {
@@ -192,8 +192,7 @@ public class SimplePageMaster extends FObj {
* @param region region to add
*/
protected void addRegion(Region region) {
- String key = String.valueOf(region.getNameId());
- regions.put(key, region);
+ regions.put(String.valueOf(region.getNameId()), region);
}
/**
@@ -240,14 +239,14 @@ public class SimplePageMaster extends FObj {
* @return the region, null if it doesn't exist
*/
public Region getRegion(int regionId) {
- return (Region) regions.get(String.valueOf(regionId));
+ return regions.get(String.valueOf(regionId));
}
/**
* Returns a Map of regions associated with this simple-page-master
* @return the regions
*/
- public Map getRegions() {
+ public Map<String, Region> getRegions() {
return regions;
}
@@ -258,9 +257,7 @@ public class SimplePageMaster extends FObj {
* @return True if a region with this name exists
*/
protected boolean regionNameExists(String regionName) {
- for (Iterator regenum = regions.values().iterator();
- regenum.hasNext();) {
- Region r = (Region) regenum.next();
+ for (Region r : regions.values()) {
if (r.getRegionName().equals(regionName)) {
return true;
}
diff --git a/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java b/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java
index aa2c2bb8b..2bb891cd9 100644
--- a/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java
+++ b/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java
@@ -28,6 +28,7 @@ public interface SubSequenceSpecifier {
/**
* Returns the name of the next page master.
+ *
* @param isOddPage True if the next page number is odd
* @param isFirstPage True if the next page is the first
* @param isLastPage True if the next page is the last
diff --git a/src/java/org/apache/fop/fo/properties/BackgroundPositionShorthand.java b/src/java/org/apache/fop/fo/properties/BackgroundPositionShorthand.java
index 709fdf7f2..3c0118181 100644
--- a/src/java/org/apache/fop/fo/properties/BackgroundPositionShorthand.java
+++ b/src/java/org/apache/fop/fo/properties/BackgroundPositionShorthand.java
@@ -57,7 +57,8 @@ public class BackgroundPositionShorthand extends ListProperty {
* specified, <code>background-position-vertical</code> is set
* to "50%".
*/
- public Property make(PropertyList propertyList, String value, FObj fo) throws PropertyException {
+ public Property make(PropertyList propertyList, String value, FObj fo)
+ throws PropertyException {
Property p = super.make(propertyList, value, fo);
if (p.getList().size() == 1) {
/* only background-position-horizontal specified
diff --git a/src/java/org/apache/fop/fo/properties/BorderSpacingShorthandParser.java b/src/java/org/apache/fop/fo/properties/BorderSpacingShorthandParser.java
index 37cb2119c..7822db3f8 100644
--- a/src/java/org/apache/fop/fo/properties/BorderSpacingShorthandParser.java
+++ b/src/java/org/apache/fop/fo/properties/BorderSpacingShorthandParser.java
@@ -29,6 +29,7 @@ import org.apache.fop.fo.expr.PropertyException;
*/
public class BorderSpacingShorthandParser extends GenericShorthandParser {
+ /** {@inheritDoc} */
protected Property convertValueForProperty(int propId, Property property,
PropertyMaker maker, PropertyList propertyList)
throws PropertyException {
diff --git a/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java b/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java
index 7c2854759..d2bab22ab 100644
--- a/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java
+++ b/src/java/org/apache/fop/fo/properties/BorderWidthPropertyMaker.java
@@ -28,7 +28,8 @@ import org.apache.fop.fo.expr.PropertyException;
* border width described in 7.7.20.
*/
public class BorderWidthPropertyMaker extends LengthProperty.Maker {
- int borderStyleId = 0;
+
+ private int borderStyleId = 0;
/**
* Create a length property which check the value of the border-*-style
@@ -41,7 +42,7 @@ public class BorderWidthPropertyMaker extends LengthProperty.Maker {
/**
* Set the propId of the style property for the same side.
- * @param borderStyleId
+ * @param borderStyleId the border style id
*/
public void setBorderStyleId(int borderStyleId) {
this.borderStyleId = borderStyleId;
@@ -53,10 +54,8 @@ public class BorderWidthPropertyMaker extends LengthProperty.Maker {
* {@inheritDoc}
*/
- public Property get(int subpropId, PropertyList propertyList,
- boolean bTryInherit, boolean bTryDefault)
- throws PropertyException
- {
+ public Property get(int subpropId, PropertyList propertyList, boolean bTryInherit,
+ boolean bTryDefault) throws PropertyException {
Property p = super.get(subpropId, propertyList,
bTryInherit, bTryDefault);
diff --git a/src/java/org/apache/fop/fo/properties/BreakPropertySet.java b/src/java/org/apache/fop/fo/properties/BreakPropertySet.java
index 2babe0f19..c70bc9fb2 100644
--- a/src/java/org/apache/fop/fo/properties/BreakPropertySet.java
+++ b/src/java/org/apache/fop/fo/properties/BreakPropertySet.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,5 +29,5 @@ public interface BreakPropertySet {
/** @return the "break-before" property. */
int getBreakBefore();
-
+
}
diff --git a/src/java/org/apache/fop/fo/properties/CharacterProperty.java b/src/java/org/apache/fop/fo/properties/CharacterProperty.java
index c078da0c7..ebded4b50 100644
--- a/src/java/org/apache/fop/fo/properties/CharacterProperty.java
+++ b/src/java/org/apache/fop/fo/properties/CharacterProperty.java
@@ -24,6 +24,8 @@ import org.apache.fop.fo.PropertyList;
/**
* Superclass for properties that wrap a character value
+ * TODO convert character value to int in order to denote unicode scalar value
+ * instead of a single UTF-16 code element
*/
public final class CharacterProperty extends Property {
@@ -39,6 +41,7 @@ public final class CharacterProperty extends Property {
super(propId);
}
+ /** {@inheritDoc} */
public Property make(PropertyList propertyList, String value,
FObj fo) {
char c = value.charAt(0);
@@ -48,7 +51,8 @@ public final class CharacterProperty extends Property {
}
/** cache containing all canonical CharacterProperty instances */
- private static final PropertyCache cache = new PropertyCache(CharacterProperty.class);
+ private static final PropertyCache CACHE
+ = new PropertyCache(CharacterProperty.class);
private final char character;
@@ -59,8 +63,13 @@ public final class CharacterProperty extends Property {
this.character = character;
}
+ /**
+ * Get character property instance for character.
+ * @param character the character
+ * @return the character property instance
+ */
public static CharacterProperty getInstance(char character) {
- return (CharacterProperty) cache.fetch(
+ return (CharacterProperty) CACHE.fetch(
new CharacterProperty(character));
}
diff --git a/src/java/org/apache/fop/fo/properties/ColorProperty.java b/src/java/org/apache/fop/fo/properties/ColorProperty.java
index 4bbf94b74..0550ce684 100644
--- a/src/java/org/apache/fop/fo/properties/ColorProperty.java
+++ b/src/java/org/apache/fop/fo/properties/ColorProperty.java
@@ -33,7 +33,8 @@ import org.apache.fop.util.ColorUtil;
public final class ColorProperty extends Property {
/** cache holding canonical ColorProperty instances */
- private static final PropertyCache cache = new PropertyCache(ColorProperty.class);
+ private static final PropertyCache CACHE
+ = new PropertyCache(ColorProperty.class);
/**
* The color represented by this property.
@@ -98,11 +99,12 @@ public final class ColorProperty extends Property {
* @throws PropertyException if the value can't be parsed
* @see ColorUtil#parseColorString(FOUserAgent, String)
*/
- public static ColorProperty getInstance(FOUserAgent foUserAgent, String value) throws PropertyException {
+ public static ColorProperty getInstance(FOUserAgent foUserAgent, String value)
+ throws PropertyException {
ColorProperty instance = new ColorProperty(
ColorUtil.parseColorString(
foUserAgent, value));
- return (ColorProperty)cache.fetch(instance);
+ return (ColorProperty)CACHE.fetch(instance);
}
/**
diff --git a/src/java/org/apache/fop/fo/properties/CommonAbsolutePosition.java b/src/java/org/apache/fop/fo/properties/CommonAbsolutePosition.java
index e32e9dbd9..f803439b9 100644
--- a/src/java/org/apache/fop/fo/properties/CommonAbsolutePosition.java
+++ b/src/java/org/apache/fop/fo/properties/CommonAbsolutePosition.java
@@ -33,31 +33,32 @@ public class CommonAbsolutePosition {
/**
* The "absolute-position" property.
*/
- public int absolutePosition;
+ public int absolutePosition; // CSOK: VisibilityModifier
/**
* The "top" property.
*/
- public Length top;
+ public Length top; // CSOK: VisibilityModifier
/**
* The "right" property.
*/
- public Length right;
+ public Length right; // CSOK: VisibilityModifier
/**
* The "bottom" property.
*/
- public Length bottom;
+ public Length bottom; // CSOK: VisibilityModifier
/**
* The "left" property.
*/
- public Length left;
+ public Length left; // CSOK: VisibilityModifier
/**
* Create a CommonAbsolutePosition object.
* @param pList The PropertyList with propery values.
+ * @throws PropertyException if a property exception is raised
*/
public CommonAbsolutePosition(PropertyList pList) throws PropertyException {
absolutePosition = pList.get(Constants.PR_ABSOLUTE_POSITION).getEnum();
@@ -67,6 +68,7 @@ public class CommonAbsolutePosition {
right = pList.get(Constants.PR_RIGHT).getLength();
}
+ /** {@inheritDoc} */
public String toString() {
StringBuffer sb = new StringBuffer("CommonAbsolutePosition{");
sb.append(" absPos=");
diff --git a/src/java/org/apache/fop/fo/properties/CommonAccessibility.java b/src/java/org/apache/fop/fo/properties/CommonAccessibility.java
index 74edf046b..dc17228d2 100644
--- a/src/java/org/apache/fop/fo/properties/CommonAccessibility.java
+++ b/src/java/org/apache/fop/fo/properties/CommonAccessibility.java
@@ -32,16 +32,17 @@ public class CommonAccessibility {
/**
* The "source-doc" property.
*/
- public String sourceDoc = null;
+ public String sourceDoc = null; // CSOK: VisibilityModifier
/**
* The "role" property.
*/
- public String role = null;
+ public String role = null; // CSOK: VisibilityModifier
/**
* Create a <code>CommonAccessibility</code> object.
* @param pList The PropertyList with propery values.
+ * @throws PropertyException if a property exception is raised
*/
public CommonAccessibility(PropertyList pList) throws PropertyException {
sourceDoc = pList.get(Constants.PR_SOURCE_DOCUMENT).getString();
diff --git a/src/java/org/apache/fop/fo/properties/CommonAural.java b/src/java/org/apache/fop/fo/properties/CommonAural.java
index a47f183f1..c805ab4fe 100644
--- a/src/java/org/apache/fop/fo/properties/CommonAural.java
+++ b/src/java/org/apache/fop/fo/properties/CommonAural.java
@@ -30,92 +30,92 @@ public class CommonAural {
/**
* The "azimuth" property.
*/
- public int azimuth;
+ public int azimuth; // CSOK: VisibilityModifier
/**
* The "cueAfter" property.
*/
- public String cueAfter;
+ public String cueAfter; // CSOK: VisibilityModifier
/**
* The "cueBefore" property.
*/
- public String cueBefore;
+ public String cueBefore; // CSOK: VisibilityModifier
/**
* The "elevation" property.
*/
- public int elevation;
+ public int elevation; // CSOK: VisibilityModifier
/**
* The "pauseAfter" property.
*/
- public int pauseAfter;
+ public int pauseAfter; // CSOK: VisibilityModifier
/**
* The "pauseBefore" property.
*/
- public int pauseBefore;
+ public int pauseBefore; // CSOK: VisibilityModifier
/**
* The "pitch" property.
*/
- public int pitch;
+ public int pitch; // CSOK: VisibilityModifier
/**
* The "pitch-range" property.
*/
- public int pitchRange;
+ public int pitchRange; // CSOK: VisibilityModifier
/**
* The "playDuring" property.
*/
- public int playDuring;
+ public int playDuring; // CSOK: VisibilityModifier
/**
* The "richness" property.
*/
- public int richness;
+ public int richness; // CSOK: VisibilityModifier
/**
* The "speak" property.
*/
- public int speak;
+ public int speak; // CSOK: VisibilityModifier
/**
* The "speak-header" property.
*/
- public int speakHeader;
+ public int speakHeader; // CSOK: VisibilityModifier
/**
* The "speak-numeral" property.
*/
- public int speakNumeral;
+ public int speakNumeral; // CSOK: VisibilityModifier
/**
* The "speak-punctuation" property.
*/
- public int speakPunctuation;
+ public int speakPunctuation; // CSOK: VisibilityModifier
/**
* The "speech-rate" property.
*/
- public int speechRate;
+ public int speechRate; // CSOK: VisibilityModifier
/**
* The "stress" property.
*/
- public int stress;
+ public int stress; // CSOK: VisibilityModifier
/**
* The "voice-family" property.
*/
- public int voiceFamily;
+ public int voiceFamily; // CSOK: VisibilityModifier
/**
* The "volume" property.
*/
- public int volume;
+ public int volume; // CSOK: VisibilityModifier
/**
* Create a CommonAbsolutePosition object.
diff --git a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
index 7e68bbcea..d39dc24f0 100644
--- a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
+++ b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java
@@ -42,45 +42,46 @@ import org.apache.fop.fo.expr.PropertyException;
* Stores all common border and padding properties.
* See Sec. 7.7 of the XSL-FO Standard.
*/
-public class CommonBorderPaddingBackground {
+public class CommonBorderPaddingBackground { // CSOK: FinalClassCheck
/**
* cache holding all canonical instances
* (w/ absolute background-position-* and padding-*)
*/
- private static final PropertyCache cache = new PropertyCache(CommonBorderPaddingBackground.class);
+ private static final PropertyCache CACHE
+ = new PropertyCache(CommonBorderPaddingBackground.class);
private int hash = -1;
/**
* The "background-attachment" property.
*/
- public final int backgroundAttachment;
+ public final int backgroundAttachment; // CSOK: VisibilityModifier
/**
* The "background-color" property.
*/
- public final Color backgroundColor;
+ public final Color backgroundColor; // CSOK: VisibilityModifier
/**
* The "background-image" property.
*/
- public final String backgroundImage;
+ public final String backgroundImage; // CSOK: VisibilityModifier
/**
* The "background-repeat" property.
*/
- public final int backgroundRepeat;
+ public final int backgroundRepeat; // CSOK: VisibilityModifier
/**
* The "background-position-horizontal" property.
*/
- public final Length backgroundPositionHorizontal;
+ public final Length backgroundPositionHorizontal; // CSOK: VisibilityModifier
/**
* The "background-position-vertical" property.
*/
- public final Length backgroundPositionVertical;
+ public final Length backgroundPositionVertical; // CSOK: VisibilityModifier
private ImageInfo backgroundImageInfo;
@@ -96,12 +97,13 @@ public class CommonBorderPaddingBackground {
public static final int END = 3;
/**
- *
+ * Utility class to express border info.
*/
- public static class BorderInfo {
+ public static final class BorderInfo {
/** cache holding all canonical instances */
- private static final PropertyCache cache = new PropertyCache(BorderInfo.class);
+ private static final PropertyCache CACHE
+ = new PropertyCache(BorderInfo.class);
private int mStyle; // Enum for border style
private Color mColor; // Border color
@@ -127,7 +129,7 @@ public class CommonBorderPaddingBackground {
* @return a cached BorderInfo instance
*/
public static BorderInfo getInstance(int style, CondLengthProperty width, Color color) {
- return cache.fetch(new BorderInfo(style, width, color));
+ return CACHE.fetch(new BorderInfo(style, width, color));
}
/**
@@ -212,7 +214,7 @@ public class CommonBorderPaddingBackground {
* A border info with style "none". Used as a singleton, in the collapsing-border model,
* for elements which don't specify any border on some of their sides.
*/
- private static final BorderInfo defaultBorderInfo
+ private static final BorderInfo DEFAULT_BORDER_INFO
= BorderInfo.getInstance(Constants.EN_NONE, new ConditionalNullLength(), null);
/**
@@ -274,7 +276,7 @@ public class CommonBorderPaddingBackground {
* @return a BorderInfo instance with style set to {@link Constants#EN_NONE}
*/
public static BorderInfo getDefaultBorderInfo() {
- return defaultBorderInfo;
+ return DEFAULT_BORDER_INFO;
}
private BorderInfo[] borderInfo = new BorderInfo[4];
@@ -352,13 +354,19 @@ public class CommonBorderPaddingBackground {
CommonBorderPaddingBackground cachedInstance = null;
/* if padding-* and background-position-* resolve to absolute lengths
* the whole instance can be cached */
- if ((newInstance.padding[BEFORE] == null || newInstance.padding[BEFORE].getLength().isAbsolute())
- && (newInstance.padding[AFTER] == null || newInstance.padding[AFTER].getLength().isAbsolute())
- && (newInstance.padding[START] == null || newInstance.padding[START].getLength().isAbsolute())
- && (newInstance.padding[END] == null || newInstance.padding[END].getLength().isAbsolute())
- && (newInstance.backgroundPositionHorizontal == null || newInstance.backgroundPositionHorizontal.isAbsolute())
- && (newInstance.backgroundPositionVertical == null || newInstance.backgroundPositionVertical.isAbsolute())) {
- cachedInstance = cache.fetch(newInstance);
+ if ((newInstance.padding[BEFORE] == null
+ || newInstance.padding[BEFORE].getLength().isAbsolute())
+ && (newInstance.padding[AFTER] == null
+ || newInstance.padding[AFTER].getLength().isAbsolute())
+ && (newInstance.padding[START] == null
+ || newInstance.padding[START].getLength().isAbsolute())
+ && (newInstance.padding[END] == null
+ || newInstance.padding[END].getLength().isAbsolute())
+ && (newInstance.backgroundPositionHorizontal == null
+ || newInstance.backgroundPositionHorizontal.isAbsolute())
+ && (newInstance.backgroundPositionVertical == null
+ || newInstance.backgroundPositionVertical.isAbsolute())) {
+ cachedInstance = CACHE.fetch(newInstance);
}
/* for non-cached, or not-yet-cached instances, preload the image */
@@ -515,6 +523,7 @@ public class CommonBorderPaddingBackground {
}
/**
+ * @param side the side to retrieve
* @param discard indicates whether the .conditionality component should be
* considered (end of a reference-area)
* @return the width of the start-border, taking into account the specified conditionality
@@ -755,8 +764,12 @@ public class CommonBorderPaddingBackground {
hash = 37 * hash + backgroundAttachment;
hash = 37 * hash + (backgroundColor == null ? 0 : backgroundColor.hashCode());
hash = 37 * hash + (backgroundImage == null ? 0 : backgroundImage.hashCode());
- hash = 37 * hash + (backgroundPositionHorizontal == null ? 0 : backgroundPositionHorizontal.hashCode());
- hash = 37 * hash + (backgroundPositionVertical == null ? 0 : backgroundPositionVertical.hashCode());
+ hash = 37 * hash
+ + (backgroundPositionHorizontal == null
+ ? 0 : backgroundPositionHorizontal.hashCode());
+ hash = 37 * hash
+ + (backgroundPositionVertical == null
+ ? 0 : backgroundPositionVertical.hashCode());
hash = 37 * hash + backgroundRepeat;
hash = 37 * hash + (borderInfo[BEFORE] == null ? 0 : borderInfo[BEFORE].hashCode());
hash = 37 * hash + (borderInfo[AFTER] == null ? 0 : borderInfo[AFTER].hashCode());
diff --git a/src/java/org/apache/fop/fo/properties/CommonFont.java b/src/java/org/apache/fop/fo/properties/CommonFont.java
index 55a2393fa..b12f84ad2 100644
--- a/src/java/org/apache/fop/fo/properties/CommonFont.java
+++ b/src/java/org/apache/fop/fo/properties/CommonFont.java
@@ -37,7 +37,8 @@ public final class CommonFont {
/** cache holding canonical CommonFont instances (only those with
* absolute font-size and font-size-adjust) */
- private static final PropertyCache cache = new PropertyCache(CommonFont.class);
+ private static final PropertyCache CACHE
+ = new PropertyCache(CommonFont.class);
/** hashcode of this instance */
private int hash = 0;
@@ -61,10 +62,10 @@ public final class CommonFont {
private final EnumProperty fontWeight;
/** The "font-size" property. */
- public final Length fontSize;
+ public final Length fontSize; // CSOK: VisibilityModifier
/** The "font-size-adjust" property. */
- public final Numeric fontSizeAdjust;
+ public final Numeric fontSizeAdjust; // CSOK: VisibilityModifier
/**
@@ -79,7 +80,7 @@ public final class CommonFont {
* @param fontSize the font-size (possibly non-cached)
* @param fontSizeAdjust the font-size-adjust (possibly non-cached)
*/
- private CommonFont(FontFamilyProperty fontFamily,
+ private CommonFont(FontFamilyProperty fontFamily, // CSOK: ParameterNumber
EnumProperty fontSelectionStrategy,
EnumProperty fontStretch,
EnumProperty fontStyle,
@@ -110,7 +111,8 @@ public final class CommonFont {
*/
public static CommonFont getInstance(PropertyList pList) throws PropertyException {
FontFamilyProperty fontFamily = (FontFamilyProperty) pList.get(Constants.PR_FONT_FAMILY);
- EnumProperty fontSelectionStrategy = (EnumProperty) pList.get(Constants.PR_FONT_SELECTION_STRATEGY);
+ EnumProperty fontSelectionStrategy
+ = (EnumProperty) pList.get(Constants.PR_FONT_SELECTION_STRATEGY);
EnumProperty fontStretch = (EnumProperty) pList.get(Constants.PR_FONT_STRETCH);
EnumProperty fontStyle = (EnumProperty) pList.get(Constants.PR_FONT_STYLE);
EnumProperty fontVariant = (EnumProperty) pList.get(Constants.PR_FONT_VARIANT);
@@ -127,7 +129,7 @@ public final class CommonFont {
fontSize,
fontSizeAdjust);
- return cache.fetch(commonFont);
+ return CACHE.fetch(commonFont);
}
/** @return an array with the font-family names */
@@ -183,23 +185,22 @@ public final class CommonFont {
/**
* Create and return an array of <code>FontTriplets</code> based on
* the properties stored in the instance variables.
- *
- * @param fontInfo
- * @return a Font object.
+ * @param fontInfo a font info object
+ * @return a font triplet
*/
public FontTriplet[] getFontState(FontInfo fontInfo) {
- int font_weight;
+ int fw;
switch (fontWeight.getEnum()) {
- case Constants.EN_100: font_weight = 100; break;
- case Constants.EN_200: font_weight = 200; break;
- case Constants.EN_300: font_weight = 300; break;
- case Constants.EN_400: font_weight = 400; break;
- case Constants.EN_500: font_weight = 500; break;
- case Constants.EN_600: font_weight = 600; break;
- case Constants.EN_700: font_weight = 700; break;
- case Constants.EN_800: font_weight = 800; break;
- case Constants.EN_900: font_weight = 900; break;
- default: font_weight = 400;
+ case Constants.EN_100: fw = 100; break;
+ case Constants.EN_200: fw = 200; break;
+ case Constants.EN_300: fw = 300; break;
+ case Constants.EN_400: fw = 400; break;
+ case Constants.EN_500: fw = 500; break;
+ case Constants.EN_600: fw = 600; break;
+ case Constants.EN_700: fw = 700; break;
+ case Constants.EN_800: fw = 800; break;
+ case Constants.EN_900: fw = 900; break;
+ default: fw = 400;
}
String style;
@@ -221,7 +222,7 @@ public final class CommonFont {
//int fontVariant = propertyList.get("font-variant").getEnum();
FontTriplet[] triplets = fontInfo.fontLookup(
getFontFamily(),
- style, font_weight);
+ style, fw);
return triplets;
}
@@ -259,7 +260,8 @@ public final class CommonFont {
hash = 37 * hash + (fontSize == null ? 0 : fontSize.hashCode());
hash = 37 * hash + (fontSizeAdjust == null ? 0 : fontSizeAdjust.hashCode());
hash = 37 * hash + (fontFamily == null ? 0 : fontFamily.hashCode());
- hash = 37 * hash + (fontSelectionStrategy == null ? 0 : fontSelectionStrategy.hashCode());
+ hash = 37 * hash + (fontSelectionStrategy == null
+ ? 0 : fontSelectionStrategy.hashCode());
hash = 37 * hash + (fontStretch == null ? 0 : fontStretch.hashCode());
hash = 37 * hash + (fontStyle == null ? 0 : fontStyle.hashCode());
hash = 37 * hash + (fontVariant == null ? 0 : fontVariant.hashCode());
diff --git a/src/java/org/apache/fop/fo/properties/CommonHyphenation.java b/src/java/org/apache/fop/fo/properties/CommonHyphenation.java
index 0e32f250a..7b9b5bc82 100644
--- a/src/java/org/apache/fop/fo/properties/CommonHyphenation.java
+++ b/src/java/org/apache/fop/fo/properties/CommonHyphenation.java
@@ -36,32 +36,32 @@ import org.apache.fop.fonts.Typeface;
public final class CommonHyphenation {
/** Logger */
- protected static Log log = LogFactory.getLog(CommonHyphenation.class);
+ private static final Log LOG = LogFactory.getLog(CommonHyphenation.class);
- private static final PropertyCache cache = new PropertyCache(CommonHyphenation.class);
+ private static final PropertyCache CACHE = new PropertyCache(CommonHyphenation.class);
private int hash = 0;
/** The "language" property */
- public final StringProperty language;
+ public final StringProperty language; // CSOK: VisibilityModifier
/** The "country" property */
- public final StringProperty country;
+ public final StringProperty country; // CSOK: VisibilityModifier
/** The "script" property */
- public final StringProperty script;
+ public final StringProperty script; // CSOK: VisibilityModifier
/** The "hyphenate" property */
- public final EnumProperty hyphenate;
+ public final EnumProperty hyphenate; // CSOK: VisibilityModifier
/** The "hyphenation-character" property */
- public final CharacterProperty hyphenationCharacter;
+ public final CharacterProperty hyphenationCharacter; // CSOK: VisibilityModifier
/** The "hyphenation-push-character-count" property */
- public final NumberProperty hyphenationPushCharacterCount;
+ public final NumberProperty hyphenationPushCharacterCount; // CSOK: VisibilityModifier
/** The "hyphenation-remain-character-count" property*/
- public final NumberProperty hyphenationRemainCharacterCount;
+ public final NumberProperty hyphenationRemainCharacterCount; // CSOK: VisibilityModifier
/**
* Construct a CommonHyphenation object holding the given properties
@@ -87,24 +87,26 @@ public final class CommonHyphenation {
* Gets the canonical <code>CommonHyphenation</code> instance corresponding
* to the values of the related properties present on the given
* <code>PropertyList</code>
- *
* @param propertyList the <code>PropertyList</code>
+ * @return a common hyphenation instance
+ * @throws PropertyException if a a property exception occurs
*/
- public static CommonHyphenation getInstance(PropertyList propertyList) throws PropertyException {
- StringProperty language =
- (StringProperty) propertyList.get(Constants.PR_LANGUAGE);
- StringProperty country =
- (StringProperty) propertyList.get(Constants.PR_COUNTRY);
- StringProperty script =
- (StringProperty) propertyList.get(Constants.PR_SCRIPT);
- EnumProperty hyphenate =
- (EnumProperty) propertyList.get(Constants.PR_HYPHENATE);
- CharacterProperty hyphenationCharacter =
- (CharacterProperty) propertyList.get(Constants.PR_HYPHENATION_CHARACTER);
- NumberProperty hyphenationPushCharacterCount =
- (NumberProperty) propertyList.get(Constants.PR_HYPHENATION_PUSH_CHARACTER_COUNT);
- NumberProperty hyphenationRemainCharacterCount =
- (NumberProperty) propertyList.get(Constants.PR_HYPHENATION_REMAIN_CHARACTER_COUNT);
+ public static CommonHyphenation getInstance(PropertyList propertyList)
+ throws PropertyException {
+ StringProperty language
+ = (StringProperty) propertyList.get(Constants.PR_LANGUAGE);
+ StringProperty country
+ = (StringProperty) propertyList.get(Constants.PR_COUNTRY);
+ StringProperty script
+ = (StringProperty) propertyList.get(Constants.PR_SCRIPT);
+ EnumProperty hyphenate
+ = (EnumProperty) propertyList.get(Constants.PR_HYPHENATE);
+ CharacterProperty hyphenationCharacter
+ = (CharacterProperty) propertyList.get(Constants.PR_HYPHENATION_CHARACTER);
+ NumberProperty hyphenationPushCharacterCount
+ = (NumberProperty) propertyList.get(Constants.PR_HYPHENATION_PUSH_CHARACTER_COUNT);
+ NumberProperty hyphenationRemainCharacterCount
+ = (NumberProperty) propertyList.get(Constants.PR_HYPHENATION_REMAIN_CHARACTER_COUNT);
CommonHyphenation instance = new CommonHyphenation(
language,
@@ -115,7 +117,7 @@ public final class CommonHyphenation {
hyphenationPushCharacterCount,
hyphenationRemainCharacterCount);
- return cache.fetch(instance);
+ return CACHE.fetch(instance);
}
@@ -164,7 +166,7 @@ public final class CommonHyphenation {
}
}
if (warn) {
- log.warn("Substituted specified hyphenation character (0x"
+ LOG.warn("Substituted specified hyphenation character (0x"
+ Integer.toHexString(hyphChar)
+ ") with 0x" + Integer.toHexString(effHyphChar)
+ " because the font doesn't have the specified hyphenation character: "
@@ -209,12 +211,15 @@ public final class CommonHyphenation {
hash = 37 * hash + (script == null ? 0 : script.hashCode());
hash = 37 * hash + (country == null ? 0 : country.hashCode());
hash = 37 * hash + (hyphenate == null ? 0 : hyphenate.hashCode());
- hash = 37 * hash +
- (hyphenationCharacter == null ? 0 : hyphenationCharacter.hashCode());
- hash = 37 * hash +
- (hyphenationPushCharacterCount == null ? 0 : hyphenationPushCharacterCount.hashCode());
- hash = 37 * hash +
- (hyphenationRemainCharacterCount == null ? 0 : hyphenationRemainCharacterCount.hashCode());
+ hash = 37 * hash
+ + (hyphenationCharacter == null
+ ? 0 : hyphenationCharacter.hashCode());
+ hash = 37 * hash
+ + (hyphenationPushCharacterCount == null
+ ? 0 : hyphenationPushCharacterCount.hashCode());
+ hash = 37 * hash
+ + (hyphenationRemainCharacterCount == null
+ ? 0 : hyphenationRemainCharacterCount.hashCode());
this.hash = hash;
}
return this.hash;
diff --git a/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java b/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java
index 8d63b3d22..a45c09672 100644
--- a/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java
+++ b/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java
@@ -33,46 +33,47 @@ public class CommonMarginBlock {
/**
* The "margin-top" property.
*/
- public Length marginTop;
+ public Length marginTop; // CSOK: VisibilityModifier
/**
* The "margin-bottom" property.
*/
- public Length marginBottom;
+ public Length marginBottom; // CSOK: VisibilityModifier
/**
* The "margin-left" property.
*/
- public Length marginLeft;
+ public Length marginLeft; // CSOK: VisibilityModifier
/**
* The "margin-right" property.
*/
- public Length marginRight;
+ public Length marginRight; // CSOK: VisibilityModifier
/**
* The "space-before" property.
*/
- public SpaceProperty spaceBefore;
+ public SpaceProperty spaceBefore; // CSOK: VisibilityModifier
/**
* The "space-after" property.
*/
- public SpaceProperty spaceAfter;
+ public SpaceProperty spaceAfter; // CSOK: VisibilityModifier
/**
* The "start-indent" property.
*/
- public Length startIndent;
+ public Length startIndent; // CSOK: VisibilityModifier
/**
* The "end-indent" property.
*/
- public Length endIndent;
+ public Length endIndent; // CSOK: VisibilityModifier
/**
* Create a CommonMarginBlock object.
* @param pList The PropertyList with propery values.
+ * @throws PropertyException if a property exception occurs
*/
public CommonMarginBlock(PropertyList pList) throws PropertyException {
marginTop = pList.get(Constants.PR_MARGIN_TOP).getLength();
diff --git a/src/java/org/apache/fop/fo/properties/CommonMarginInline.java b/src/java/org/apache/fop/fo/properties/CommonMarginInline.java
index c578e58b8..3b1d886ea 100644
--- a/src/java/org/apache/fop/fo/properties/CommonMarginInline.java
+++ b/src/java/org/apache/fop/fo/properties/CommonMarginInline.java
@@ -34,36 +34,37 @@ public class CommonMarginInline {
/**
* The "margin-top" property.
*/
- public Length marginTop;
+ public Length marginTop; // CSOK: VisibilityModifier
/**
* The "margin-bottom" property.
*/
- public Length marginBottom;
+ public Length marginBottom; // CSOK: VisibilityModifier
/**
* The "margin-left" property.
*/
- public Length marginLeft;
+ public Length marginLeft; // CSOK: VisibilityModifier
/**
* The "margin-right" property.
*/
- public Length marginRight;
+ public Length marginRight; // CSOK: VisibilityModifier
/**
* The "space-start" property.
*/
- public SpaceProperty spaceStart;
+ public SpaceProperty spaceStart; // CSOK: VisibilityModifier
/**
* The "space-end" property.
*/
- public SpaceProperty spaceEnd;
+ public SpaceProperty spaceEnd; // CSOK: VisibilityModifier
/**
* Create a CommonMarginInline object.
* @param pList The PropertyList with propery values.
+ * @throws PropertyException if a property exception occurs
*/
public CommonMarginInline(PropertyList pList) throws PropertyException {
marginTop = pList.get(Constants.PR_MARGIN_TOP).getLength();
diff --git a/src/java/org/apache/fop/fo/properties/CommonRelativePosition.java b/src/java/org/apache/fop/fo/properties/CommonRelativePosition.java
index f28a3edb3..32d21133b 100644
--- a/src/java/org/apache/fop/fo/properties/CommonRelativePosition.java
+++ b/src/java/org/apache/fop/fo/properties/CommonRelativePosition.java
@@ -33,31 +33,32 @@ public class CommonRelativePosition {
/**
* The "relative-position" property.
*/
- public int relativePosition;
+ public int relativePosition; // CSOK: VisibilityModifier
/**
* The "top" property.
*/
- public Length top;
+ public Length top; // CSOK: VisibilityModifier
/**
* The "right" property.
*/
- public Length right;
+ public Length right; // CSOK: VisibilityModifier
/**
* The "bottom" property.
*/
- public Length bottom;
+ public Length bottom; // CSOK: VisibilityModifier
/**
* The "left" property.
*/
- public Length left;
+ public Length left; // CSOK: VisibilityModifier
/**
* Create a CommonRelativePosition object.
* @param pList The PropertyList with propery values.
+ * @throws PropertyException if a property exception occurs
*/
public CommonRelativePosition(PropertyList pList) throws PropertyException {
relativePosition = pList.get(Constants.PR_RELATIVE_POSITION).getEnum();
diff --git a/src/java/org/apache/fop/fo/properties/CompoundPropertyMaker.java b/src/java/org/apache/fop/fo/properties/CompoundPropertyMaker.java
index 45f6b2e9f..cbd34c9b3 100644
--- a/src/java/org/apache/fop/fo/properties/CompoundPropertyMaker.java
+++ b/src/java/org/apache/fop/fo/properties/CompoundPropertyMaker.java
@@ -32,8 +32,8 @@ public class CompoundPropertyMaker extends PropertyMaker {
/**
* The list of subproperty makers supported by this compound maker.
*/
- private PropertyMaker[] subproperties =
- new PropertyMaker[Constants.COMPOUND_COUNT];
+ private PropertyMaker[] subproperties
+ = new PropertyMaker[Constants.COMPOUND_COUNT];
/**
* The first subproperty maker which has a setByShorthand of true.
@@ -66,7 +66,7 @@ public class CompoundPropertyMaker extends PropertyMaker {
/**
* Add a subproperty to this maker.
- * @param subproperty
+ * @param subproperty the sub property
*/
public void addSubpropMaker(PropertyMaker subproperty) {
// Place the base propId in the propId of the subproperty.
@@ -101,12 +101,11 @@ public class CompoundPropertyMaker extends PropertyMaker {
* Calculate the real value of a subproperty by unmasking and shifting
* the value into the range [0 - (COMPOUND_COUNT-1)].
* The value is used as index into the subproperties array.
- * @param propId the property id of the sub property.
+ * @param subpropertyId the property id of the sub property.
* @return the array index.
*/
private int getSubpropIndex(int subpropertyId) {
- return ((subpropertyId & Constants.COMPOUND_MASK) >>
- Constants.COMPOUND_SHIFT)-1;
+ return ((subpropertyId & Constants.COMPOUND_MASK) >> Constants.COMPOUND_SHIFT) - 1;
}
/**
@@ -137,11 +136,11 @@ public class CompoundPropertyMaker extends PropertyMaker {
* @param propertyList The PropertyList object being built for this FO.
* @param tryInherit true if inherited properties should be examined.
* @param tryDefault true if the default value should be returned.
+ * @return the property
+ * @throws PropertyException if a property exception occurs
*/
- public Property get(int subpropertyId, PropertyList propertyList,
- boolean tryInherit, boolean tryDefault)
- throws PropertyException
- {
+ public Property get(int subpropertyId, PropertyList propertyList, boolean tryInherit,
+ boolean tryDefault) throws PropertyException {
Property p = super.get(subpropertyId, propertyList, tryInherit, tryDefault);
if (subpropertyId != 0 && p != null) {
p = getSubprop(p, subpropertyId);
@@ -254,14 +253,15 @@ public class CompoundPropertyMaker extends PropertyMaker {
* @throws PropertyException ...
*/
protected Property makeCompound(PropertyList propertyList, FObj parentFO)
- throws PropertyException {
+ throws PropertyException {
Property p = makeNewProperty();
CompoundDatatype data = (CompoundDatatype) p.getObject();
for (int i = 0; i < Constants.COMPOUND_COUNT; i++) {
PropertyMaker subpropertyMaker = subproperties[i];
if (subpropertyMaker != null) {
Property subproperty = subpropertyMaker.make(propertyList);
- data.setComponent(subpropertyMaker.getPropId() & Constants.COMPOUND_MASK, subproperty, true);
+ data.setComponent(subpropertyMaker.getPropId()
+ & Constants.COMPOUND_MASK, subproperty, true);
}
}
return p;
diff --git a/src/java/org/apache/fop/fo/properties/CondLengthProperty.java b/src/java/org/apache/fop/fo/properties/CondLengthProperty.java
index aa913d969..1ab7ec3ad 100644
--- a/src/java/org/apache/fop/fo/properties/CondLengthProperty.java
+++ b/src/java/org/apache/fop/fo/properties/CondLengthProperty.java
@@ -33,7 +33,8 @@ import org.apache.fop.fo.expr.PropertyException;
public class CondLengthProperty extends Property implements CompoundDatatype {
/** cache holding canonical instances (for absolute conditional lengths) */
- private static final PropertyCache cache = new PropertyCache(CondLengthProperty.class);
+ private static final PropertyCache CACHE
+ = new PropertyCache(CondLengthProperty.class);
/** components */
private Property length;
@@ -158,7 +159,7 @@ public class CondLengthProperty extends Property implements CompoundDatatype {
*/
public CondLengthProperty getCondLength() {
if (this.length.getLength().isAbsolute()) {
- CondLengthProperty clp = (CondLengthProperty) cache.fetch(this);
+ CondLengthProperty clp = (CondLengthProperty) CACHE.fetch(this);
if (clp == this) {
isCached = true;
}
diff --git a/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java b/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java
index 60237c53a..6183b9e56 100644
--- a/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java
+++ b/src/java/org/apache/fop/fo/properties/CorrespondingPropertyMaker.java
@@ -19,31 +19,46 @@
package org.apache.fop.fo.properties;
-import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.expr.PropertyException;
/**
+ * Maker class for handling corresponding properties.
*/
public class CorrespondingPropertyMaker {
+ /** base property maker */
protected PropertyMaker baseMaker;
- protected int lr_tb;
- protected int rl_tb;
- protected int tb_rl;
+ /** corresponding property for lr-tb writing mode */
+ protected int lrtb;
+ /** corresponding property for rl-tb writing mode */
+ protected int rltb;
+ /** corresponding property for tb-rl writing mode */
+ protected int tbrl;
+ /** user parent property list */
protected boolean useParent;
private boolean relative;
+ /**
+ * Construct a corresponding property maker.
+ * @param baseMaker the base property maker
+ */
public CorrespondingPropertyMaker(PropertyMaker baseMaker) {
this.baseMaker = baseMaker;
baseMaker.setCorresponding(this);
}
- public void setCorresponding(int lr_tb, int rl_tb, int tb_rl) {
- this.lr_tb = lr_tb;
- this.rl_tb = rl_tb;
- this.tb_rl = tb_rl;
+ /**
+ * Set corresponding property identifiers.
+ * @param lrtb the property that corresponds with lr-tb writing mode
+ * @param rltb the property that corresponds with rl-tb writing mode
+ * @param tbrl the property that corresponds with tb-lr writing mode
+ */
+ public void setCorresponding(int lrtb, int rltb, int tbrl) {
+ this.lrtb = lrtb;
+ this.rltb = rltb;
+ this.tbrl = tbrl;
}
/**
@@ -55,6 +70,10 @@ public class CorrespondingPropertyMaker {
this.useParent = useParent;
}
+ /**
+ * Set relative flag.
+ * @param relative true if relative direction
+ */
public void setRelative(boolean relative) {
this.relative = relative;
}
@@ -83,7 +102,7 @@ public class CorrespondingPropertyMaker {
PropertyList pList = getWMPropertyList(propertyList);
if (pList != null) {
- int correspondingId = pList.getWritingMode(lr_tb, rl_tb, tb_rl);
+ int correspondingId = pList.getWritingMode(lrtb, rltb, tbrl);
if (pList.getExplicit(correspondingId) != null) {
return true;
@@ -100,14 +119,14 @@ public class CorrespondingPropertyMaker {
* @param propertyList The PropertyList for the FO.
* @return Property A computed Property value or null if no rules
* are specified (in foproperties.xml) to compute the value.
- * @throws FOPException for invalid or inconsistent FO input
+ * @throws PropertyException if a property exception occurs
*/
public Property compute(PropertyList propertyList) throws PropertyException {
PropertyList pList = getWMPropertyList(propertyList);
if (pList == null) {
return null;
}
- int correspondingId = pList.getWritingMode(lr_tb, rl_tb, tb_rl);
+ int correspondingId = pList.getWritingMode(lrtb, rltb, tbrl);
Property p = propertyList.getExplicitOrShorthand(correspondingId);
if (p != null) {
@@ -120,6 +139,8 @@ public class CorrespondingPropertyMaker {
/**
* Return the property list to use for fetching writing mode depending property
* ids.
+ * @param pList a property list
+ * @return the property list to use
*/
protected PropertyList getWMPropertyList(PropertyList pList) {
if (useParent) {
diff --git a/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java b/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java
index 29715fe66..0bef5e916 100644
--- a/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java
+++ b/src/java/org/apache/fop/fo/properties/DimensionPropertyMaker.java
@@ -30,27 +30,44 @@ import org.apache.fop.fo.expr.PropertyException;
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class DimensionPropertyMaker extends CorrespondingPropertyMaker {
- int[][] extraCorresponding = null;
+ private int[][] extraCorresponding = null;
+
+ /**
+ * Construct a dimension property maker.
+ * @param baseMaker the base property maker
+ */
public DimensionPropertyMaker(PropertyMaker baseMaker) {
super(baseMaker);
}
+ /**
+ * Set extra correspondences.
+ * @param extraCorresponding the extra correspondences
+ */
public void setExtraCorresponding(int[][] extraCorresponding) {
this.extraCorresponding = extraCorresponding;
}
+ /**
+ * Determine if corresponding property is forced.
+ * @param propertyList the property list to use
+ * @return true if it is forced
+ */
public boolean isCorrespondingForced(PropertyList propertyList) {
- if (super.isCorrespondingForced(propertyList))
+ if (super.isCorrespondingForced(propertyList)) {
return true;
+ }
for (int i = 0; i < extraCorresponding.length; i++) {
int wmcorr = extraCorresponding[i][0]; //propertyList.getWritingMode()];
- if (propertyList.getExplicit(wmcorr) != null)
+ if (propertyList.getExplicit(wmcorr) != null) {
return true;
+ }
}
return false;
}
+ /** {@inheritDoc} */
public Property compute(PropertyList propertyList) throws PropertyException {
// Based on [width|height]
Property p = super.compute(propertyList);
diff --git a/src/java/org/apache/fop/fo/properties/EnumLength.java b/src/java/org/apache/fop/fo/properties/EnumLength.java
index 76fd0e5b7..d2480beb2 100644
--- a/src/java/org/apache/fop/fo/properties/EnumLength.java
+++ b/src/java/org/apache/fop/fo/properties/EnumLength.java
@@ -27,6 +27,10 @@ import org.apache.fop.datatypes.PercentBaseContext;
public class EnumLength extends LengthProperty {
private Property enumProperty;
+ /**
+ * Construct an enumerated length from an enum property.
+ * @param enumProperty the enumeration property
+ */
public EnumLength(Property enumProperty) {
this.enumProperty = enumProperty;
}
@@ -38,6 +42,7 @@ public class EnumLength extends LengthProperty {
return enumProperty.getEnum();
}
+ /** @return true if absolute */
public boolean isAbsolute() {
return false;
}
diff --git a/src/java/org/apache/fop/fo/properties/EnumNumber.java b/src/java/org/apache/fop/fo/properties/EnumNumber.java
index fdc359a06..153a716df 100644
--- a/src/java/org/apache/fop/fo/properties/EnumNumber.java
+++ b/src/java/org/apache/fop/fo/properties/EnumNumber.java
@@ -29,7 +29,8 @@ import org.apache.fop.fo.expr.PropertyException;
public final class EnumNumber extends Property implements Numeric {
/** cache holding all canonical EnumNumber instances */
- private static final PropertyCache cache = new PropertyCache(EnumNumber.class);
+ private static final PropertyCache CACHE
+ = new PropertyCache(EnumNumber.class);
private final EnumProperty enumProperty;
@@ -49,7 +50,7 @@ public final class EnumNumber extends Property implements Numeric {
* @return the canonical instance
*/
public static EnumNumber getInstance(Property enumProperty) {
- return (EnumNumber)cache.fetch(
+ return (EnumNumber)CACHE.fetch(
new EnumNumber((EnumProperty) enumProperty));
}
diff --git a/src/java/org/apache/fop/fo/properties/EnumProperty.java b/src/java/org/apache/fop/fo/properties/EnumProperty.java
index 07cfaadcc..ae704f1c9 100644
--- a/src/java/org/apache/fop/fo/properties/EnumProperty.java
+++ b/src/java/org/apache/fop/fo/properties/EnumProperty.java
@@ -29,7 +29,8 @@ import org.apache.fop.fo.expr.PropertyException;
public final class EnumProperty extends Property {
/** cache holding all canonical EnumProperty instances */
- private static final PropertyCache cache = new PropertyCache(EnumProperty.class);
+ private static final PropertyCache CACHE
+ = new PropertyCache(EnumProperty.class);
/**
* Inner class for creating EnumProperty instances
@@ -54,6 +55,14 @@ public final class EnumProperty extends Property {
return super.checkEnumValues(value);
}
+ /**
+ * Convert a property.
+ * @param p the property to convert
+ * @param propertyList the property list to use in conversion
+ * @param fo the FO to use in conversion
+ * @return the converted property
+ * @throws PropertyException if a property conversion exception occurs
+ */
public Property convertProperty(Property p,
PropertyList propertyList,
FObj fo) throws PropertyException {
@@ -77,8 +86,14 @@ public final class EnumProperty extends Property {
this.text = text;
}
+ /**
+ * Construct an enumeration property.
+ * @param explicitValue the value
+ * @param text the text
+ * @return an enumeration property
+ */
public static EnumProperty getInstance(int explicitValue, String text) {
- return (EnumProperty) cache.fetch(
+ return (EnumProperty) CACHE.fetch(
new EnumProperty(explicitValue, text));
}
diff --git a/src/java/org/apache/fop/fo/properties/FixedLength.java b/src/java/org/apache/fop/fo/properties/FixedLength.java
index 84d159edf..c35c6f6c9 100644
--- a/src/java/org/apache/fop/fo/properties/FixedLength.java
+++ b/src/java/org/apache/fop/fo/properties/FixedLength.java
@@ -45,7 +45,8 @@ public final class FixedLength extends LengthProperty {
public static final String MPT = "mpt";
/** cache holding all canonical FixedLength instances */
- private static final PropertyCache cache = new PropertyCache(FixedLength.class);
+ private static final PropertyCache CACHE
+ = new PropertyCache(FixedLength.class);
/** canonical zero-length instance */
public static final FixedLength ZERO_FIXED_LENGTH = new FixedLength(0, FixedLength.MPT, 1.0f);
@@ -81,7 +82,7 @@ public final class FixedLength extends LengthProperty {
if (numUnits == 0.0) {
return ZERO_FIXED_LENGTH;
} else {
- return (FixedLength)cache.fetch(
+ return (FixedLength)CACHE.fetch(
new FixedLength(numUnits, units, sourceResolution));
}
diff --git a/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java b/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java
index 34a6b58d8..f6fa806c9 100644
--- a/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java
+++ b/src/java/org/apache/fop/fo/properties/FontFamilyProperty.java
@@ -31,7 +31,8 @@ import org.apache.fop.fo.expr.PropertyException;
public final class FontFamilyProperty extends ListProperty {
/** cache holding all canonical FontFamilyProperty instances */
- private static final PropertyCache cache = new PropertyCache(FontFamilyProperty.class);
+ private static final PropertyCache CACHE
+ = new PropertyCache(FontFamilyProperty.class);
private int hash = 0;
@@ -50,7 +51,8 @@ public final class FontFamilyProperty extends ListProperty {
/**
* {@inheritDoc}
*/
- public Property make(PropertyList propertyList, String value, FObj fo) throws PropertyException {
+ public Property make(PropertyList propertyList, String value, FObj fo)
+ throws PropertyException {
if ("inherit".equals(value)) {
return super.make(propertyList, value, fo);
} else {
@@ -93,7 +95,7 @@ public final class FontFamilyProperty extends ListProperty {
prop.addProperty(StringProperty.getInstance(tmpVal));
}
}
- return cache.fetch(prop);
+ return CACHE.fetch(prop);
}
}
diff --git a/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java b/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java
index 5096d6160..72884a177 100644
--- a/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java
+++ b/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java
@@ -50,7 +50,8 @@ public class FontSizePropertyMaker
* here already: if the property evaluates to a {@link PercentLength},
* it is immediately replaced by the resolved {@link FixedLength}.
*/
- public Property make(PropertyList propertyList, String value, FObj fo) throws PropertyException {
+ public Property make(PropertyList propertyList, String value, FObj fo)
+ throws PropertyException {
Property p = super.make(propertyList, value, fo);
if (p instanceof PercentLength) {
Property pp = propertyList.getFromParent(this.propId);
diff --git a/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java b/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java
index 278fec862..6397813e6 100644
--- a/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java
+++ b/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java
@@ -13,7 +13,8 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ */
+
/* $Id$ */
package org.apache.fop.fo.properties;
@@ -25,6 +26,9 @@ import org.apache.fop.fo.expr.PropertyException;
import org.apache.fop.fo.expr.PropertyInfo;
import org.apache.fop.fo.expr.PropertyParser;
+/**
+ * Font weight property maker.
+ */
public class FontWeightPropertyMaker extends EnumProperty.Maker {
/**
@@ -45,10 +49,8 @@ public class FontWeightPropertyMaker extends EnumProperty.Maker {
} else {
String pValue = checkValueKeywords(value);
Property newProp = checkEnumValues(pValue);
- int enumValue = -1;
- if (newProp != null
- && ((enumValue = newProp.getEnum()) == Constants.EN_BOLDER
- || enumValue == Constants.EN_LIGHTER)) {
+ int enumValue = ( newProp != null ) ? newProp.getEnum() : -1;
+ if (enumValue == Constants.EN_BOLDER || enumValue == Constants.EN_LIGHTER) {
/* check for relative enum values, compute in relation to parent */
Property parentProp = pList.getInherited(Constants.PR_FONT_WEIGHT);
if (enumValue == Constants.EN_BOLDER) {
diff --git a/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java b/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java
index d976fc6ea..19c4675ed 100644
--- a/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java
+++ b/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java
@@ -68,6 +68,9 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker {
/**
* Calculate the corresponding value for start-indent and end-indent.
+ * @param propertyList the property list to use in the computation
+ * @return the computed indent property
+ * @throws PropertyException if a property exception occurs
* @see CorrespondingPropertyMaker#compute(PropertyList)
*/
public Property compute(PropertyList propertyList) throws PropertyException {
@@ -81,6 +84,9 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker {
/**
* Calculate the corresponding value for start-indent and end-indent.
+ * @param propertyList the property list to use in the computation
+ * @return the computed indent property
+ * @throws PropertyException if a property exception occurs
* @see CorrespondingPropertyMaker#compute(PropertyList)
*/
public Property computeConforming(PropertyList propertyList) throws PropertyException {
@@ -93,7 +99,7 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker {
Numeric padding = getCorresponding(paddingCorresponding, propertyList).getNumeric();
Numeric border = getCorresponding(borderWidthCorresponding, propertyList).getNumeric();
- int marginProp = pList.getWritingMode(lr_tb, rl_tb, tb_rl);
+ int marginProp = pList.getWritingMode(lrtb, rltb, tbrl);
// Calculate the absolute margin.
if (propertyList.getExplicitOrShorthand(marginProp) == null) {
Property indent = propertyList.getExplicit(baseMaker.propId);
@@ -136,6 +142,9 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker {
* This method calculates indent following an alternative rule set that
* tries to mimic many commercial solutions that chose to violate the
* XSL specification.
+ * @param propertyList the property list to use in the computation
+ * @return the computed indent property
+ * @throws PropertyException if a property exception occurs
* @see CorrespondingPropertyMaker#compute(PropertyList)
*/
public Property computeAlternativeRuleset(PropertyList propertyList) throws PropertyException {
@@ -149,7 +158,7 @@ public class IndentPropertyMaker extends CorrespondingPropertyMaker {
Numeric padding = getCorresponding(paddingCorresponding, propertyList).getNumeric();
Numeric border = getCorresponding(borderWidthCorresponding, propertyList).getNumeric();
- int marginProp = pList.getWritingMode(lr_tb, rl_tb, tb_rl);
+ int marginProp = pList.getWritingMode(lrtb, rltb, tbrl);
//Determine whether the nearest anscestor indent was specified through
//start-indent|end-indent or through a margin property.
diff --git a/src/java/org/apache/fop/fo/properties/KeepProperty.java b/src/java/org/apache/fop/fo/properties/KeepProperty.java
index d2e2c70a7..9d04ce780 100644
--- a/src/java/org/apache/fop/fo/properties/KeepProperty.java
+++ b/src/java/org/apache/fop/fo/properties/KeepProperty.java
@@ -30,7 +30,8 @@ import org.apache.fop.fo.expr.PropertyException;
public final class KeepProperty extends Property implements CompoundDatatype {
/** class holding all canonical KeepProperty instances*/
- private static final PropertyCache cache = new PropertyCache(KeepProperty.class);
+ private static final PropertyCache CACHE
+ = new PropertyCache(KeepProperty.class);
private boolean isCachedValue = false;
private Property withinLine;
@@ -61,8 +62,7 @@ public final class KeepProperty extends Property implements CompoundDatatype {
* {@inheritDoc}
*/
public Property convertProperty(Property p, PropertyList propertyList, FObj fo)
- throws PropertyException
- {
+ throws PropertyException {
if (p instanceof KeepProperty) {
return p;
}
@@ -154,10 +154,10 @@ public final class KeepProperty extends Property implements CompoundDatatype {
* @return String representation
*/
public String toString() {
- return "Keep[" +
- "withinLine:" + getWithinLine().getObject() +
- ", withinColumn:" + getWithinColumn().getObject() +
- ", withinPage:" + getWithinPage().getObject() + "]";
+ return "Keep["
+ + "withinLine:" + getWithinLine().getObject()
+ + ", withinColumn:" + getWithinColumn().getObject()
+ + ", withinPage:" + getWithinPage().getObject() + "]";
}
/**
@@ -165,7 +165,7 @@ public final class KeepProperty extends Property implements CompoundDatatype {
* this property
*/
public KeepProperty getKeep() {
- KeepProperty keep = (KeepProperty) cache.fetch(this);
+ KeepProperty keep = (KeepProperty) CACHE.fetch(this);
/* make sure setComponent() can never alter cached values */
keep.isCachedValue = true;
return keep;
diff --git a/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java b/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java
index 4b408e83b..1d79bb7af 100644
--- a/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java
+++ b/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java
@@ -64,6 +64,7 @@ public class LineHeightPropertyMaker extends SpaceProperty.Maker {
/**
* Recalculate the line-height value based on the nearest specified
* value.
+ * {@inheritDoc}
*/
protected Property compute(PropertyList propertyList) throws PropertyException {
// recalculate based on last specified value
diff --git a/src/java/org/apache/fop/fo/properties/NumberProperty.java b/src/java/org/apache/fop/fo/properties/NumberProperty.java
index 4d7c3b97b..97844d723 100644
--- a/src/java/org/apache/fop/fo/properties/NumberProperty.java
+++ b/src/java/org/apache/fop/fo/properties/NumberProperty.java
@@ -68,6 +68,9 @@ public final class NumberProperty extends Property implements Numeric {
}
+ /**
+ * A positive integer property maker.
+ */
public static class PositiveIntegerMaker extends PropertyMaker {
/**
@@ -103,7 +106,8 @@ public final class NumberProperty extends Property implements Numeric {
}
/** cache holding all canonical NumberProperty instances */
- private static final PropertyCache cache = new PropertyCache(NumberProperty.class);
+ private static final PropertyCache CACHE
+ = new PropertyCache(NumberProperty.class);
private final Number number;
@@ -140,7 +144,7 @@ public final class NumberProperty extends Property implements Numeric {
* @return the canonical NumberProperty
*/
public static NumberProperty getInstance(Double num) {
- return (NumberProperty)cache.fetch(
+ return (NumberProperty)CACHE.fetch(
new NumberProperty(num.doubleValue()));
}
@@ -151,7 +155,7 @@ public final class NumberProperty extends Property implements Numeric {
* @return the canonical NumberProperty
*/
public static NumberProperty getInstance(Integer num) {
- return (NumberProperty)cache.fetch(
+ return (NumberProperty)CACHE.fetch(
new NumberProperty(num.intValue()));
}
@@ -162,7 +166,7 @@ public final class NumberProperty extends Property implements Numeric {
* @return the canonical NumberProperty
*/
public static NumberProperty getInstance(double num) {
- return (NumberProperty)cache.fetch(
+ return (NumberProperty)CACHE.fetch(
new NumberProperty(num));
}
@@ -173,7 +177,7 @@ public final class NumberProperty extends Property implements Numeric {
* @return the canonical NumberProperty
*/
public static NumberProperty getInstance(int num) {
- return (NumberProperty)cache.fetch(
+ return (NumberProperty)CACHE.fetch(
new NumberProperty(num));
}
diff --git a/src/java/org/apache/fop/fo/properties/PageDimensionMaker.java b/src/java/org/apache/fop/fo/properties/PageDimensionMaker.java
index 53a9c1286..c0c6a2ed7 100644
--- a/src/java/org/apache/fop/fo/properties/PageDimensionMaker.java
+++ b/src/java/org/apache/fop/fo/properties/PageDimensionMaker.java
@@ -43,7 +43,13 @@ public class PageDimensionMaker extends LengthProperty.Maker {
* Check the value of the page-width / page-height property.
* Return the default or user-defined fallback in case the value
* was specified as "auto"
- *
+ * @param subpropId The subproperty id of the property being retrieved.
+ * Is 0 when retrieving a base property.
+ * @param propertyList The PropertyList object being built for this FO.
+ * @param tryInherit true if inherited properties should be examined.
+ * @param tryDefault true if the default value should be returned.
+ * @return the property
+ * @throws PropertyException if a property exception occurs
* @see PropertyMaker#get(int, PropertyList, boolean, boolean)
*/
public Property get(int subpropId, PropertyList propertyList,
diff --git a/src/java/org/apache/fop/fo/properties/PercentLength.java b/src/java/org/apache/fop/fo/properties/PercentLength.java
index f89007f34..66f1f175c 100644
--- a/src/java/org/apache/fop/fo/properties/PercentLength.java
+++ b/src/java/org/apache/fop/fo/properties/PercentLength.java
@@ -118,8 +118,7 @@ public class PercentLength extends LengthProperty {
* @return the String equivalent of this
*/
public String toString() {
- StringBuffer sb =
- new StringBuffer(PercentLength.class.getName())
+ StringBuffer sb = new StringBuffer(PercentLength.class.getName())
.append("[factor=").append(factor)
.append(",lbase=").append(lbase).append("]");
return sb.toString();
diff --git a/src/java/org/apache/fop/fo/properties/Property.java b/src/java/org/apache/fop/fo/properties/Property.java
index 29e8faac5..a04f96a3c 100644
--- a/src/java/org/apache/fop/fo/properties/Property.java
+++ b/src/java/org/apache/fop/fo/properties/Property.java
@@ -36,7 +36,7 @@ import org.apache.fop.fo.Constants;
public class Property {
/** Logger for all property classes */
- protected static Log log = LogFactory.getLog(PropertyMaker.class);
+ protected static final Log log = LogFactory.getLog(PropertyMaker.class);
/**
* The original specified value for properties which inherit
@@ -197,6 +197,6 @@ public class Property {
if (obj != this) {
return obj.toString();
}
- return null;
+ return "";
}
}
diff --git a/src/java/org/apache/fop/fo/properties/PropertyCache.java b/src/java/org/apache/fop/fo/properties/PropertyCache.java
index dc9abb023..920125796 100644
--- a/src/java/org/apache/fop/fo/properties/PropertyCache.java
+++ b/src/java/org/apache/fop/fo/properties/PropertyCache.java
@@ -98,8 +98,13 @@ public final class PropertyCache {
}
/* Wrapper objects to synchronize on */
- private static class CacheSegment {
+ private static final class CacheSegment {
+ CacheSegment() {
+ }
private int count = 0;
+ int getCount() {
+ return count;
+ }
}
private void cleanSegment(int segmentIndex) {
@@ -209,10 +214,11 @@ public final class PropertyCache {
/* try non-synched first */
for (CacheEntry e = entry; e != null; e = e.nextEntry) {
- if (e.hash == hash
- && (q = e.get()) != null
- && eq(q, o)) {
- return q;
+ if ( e.hash == hash ) {
+ q = e.get();
+ if ( ( q != null ) && eq ( q, o ) ) {
+ return q;
+ }
}
}
@@ -223,10 +229,11 @@ public final class PropertyCache {
synchronized (segment) {
entry = table[index];
for (CacheEntry e = entry; e != null; e = e.nextEntry) {
- if (e.hash == hash
- && (q = e.get()) != null
- && eq(q, o)) {
- return q;
+ if ( e.hash == hash ) {
+ q = e.get();
+ if ( ( q != null ) && eq ( q, o ) ) {
+ return q;
+ }
}
}
}
@@ -261,7 +268,8 @@ public final class PropertyCache {
newLength--;
for (int i = table.length; --i >= 0;) {
for (CacheEntry c = table[i]; c != null; c = c.nextEntry) {
- if ((o = c.get()) != null) {
+ o = c.get();
+ if (o != null) {
hash = c.hash;
idx = hash & newLength;
newTable[idx] = new CacheEntry(o, newTable[idx]);
@@ -384,7 +392,7 @@ public final class PropertyCache {
}
/**
- * Checks if the given {@link Marker.MarkerAttribute} is present
+ * Checks if the given {@link org.apache.fop.fo.flow.Marker.MarkerAttribute} is present
* in the cache - if so, returns a reference to the cached instance.
* Otherwise the given object is added to the cache and returned.
*
diff --git a/src/java/org/apache/fop/fo/properties/ShorthandParser.java b/src/java/org/apache/fop/fo/properties/ShorthandParser.java
index f0ec0e6e9..f03c377fd 100644
--- a/src/java/org/apache/fop/fo/properties/ShorthandParser.java
+++ b/src/java/org/apache/fop/fo/properties/ShorthandParser.java
@@ -30,9 +30,11 @@ public interface ShorthandParser {
/**
* @param propId the property ID in the Constants interface
+ * @param property from which value is obtained
* @param maker Maker object for the Property
* @param propertyList list of properties
* @return Property object corresponding to propName
+ * @throws PropertyException in case a property exception occurs
*/
Property getValueForProperty(int propId,
Property property,
diff --git a/src/java/org/apache/fop/fo/properties/SpaceProperty.java b/src/java/org/apache/fop/fo/properties/SpaceProperty.java
index 49f76f874..641ec3baf 100644
--- a/src/java/org/apache/fop/fo/properties/SpaceProperty.java
+++ b/src/java/org/apache/fop/fo/properties/SpaceProperty.java
@@ -136,13 +136,14 @@ public class SpaceProperty extends LengthRangeProperty {
return this.conditionality.getEnum() == Constants.EN_DISCARD;
}
+ /** {@inheritDoc} */
public String toString() {
- return "Space[" +
- "min:" + getMinimum(null).getObject() +
- ", max:" + getMaximum(null).getObject() +
- ", opt:" + getOptimum(null).getObject() +
- ", precedence:" + precedence.getObject() +
- ", conditionality:" + conditionality.getObject() + "]";
+ return "Space["
+ + "min:" + getMinimum(null).getObject()
+ + ", max:" + getMaximum(null).getObject()
+ + ", opt:" + getOptimum(null).getObject()
+ + ", precedence:" + precedence.getObject()
+ + ", conditionality:" + conditionality.getObject() + "]";
}
/**
diff --git a/src/java/org/apache/fop/fo/properties/SpacingPropertyMaker.java b/src/java/org/apache/fop/fo/properties/SpacingPropertyMaker.java
index 19fa7baa7..3c51dd44a 100644
--- a/src/java/org/apache/fop/fo/properties/SpacingPropertyMaker.java
+++ b/src/java/org/apache/fop/fo/properties/SpacingPropertyMaker.java
@@ -41,6 +41,11 @@ public class SpacingPropertyMaker extends SpaceProperty.Maker {
/**
* Support for the 'normal' value.
+ * @param p the property to convert
+ * @param propertyList the property list to use in conversion
+ * @param fo the FO to use in conversion
+ * @return the converted property
+ * @throws PropertyException if a property conversion exception occurs
*/
public Property convertProperty(Property p,
PropertyList propertyList,
diff --git a/src/java/org/apache/fop/fo/properties/StringProperty.java b/src/java/org/apache/fop/fo/properties/StringProperty.java
index ec7e1f841..9bbe33070 100644
--- a/src/java/org/apache/fop/fo/properties/StringProperty.java
+++ b/src/java/org/apache/fop/fo/properties/StringProperty.java
@@ -21,11 +21,6 @@ package org.apache.fop.fo.properties;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
-import org.apache.fop.fo.FOValidationEventProducer;
-import org.apache.fop.fo.ValidationException;
-import org.apache.fop.fo.expr.PropertyException;
-
-import java.util.Set;
/**
* Exists primarily as a container for its Maker inner class, which is
@@ -83,7 +78,8 @@ public final class StringProperty extends Property {
}
/** cache containing all canonical StringProperty instances */
- private static final PropertyCache cache = new PropertyCache(StringProperty.class);
+ private static final PropertyCache CACHE
+ = new PropertyCache(StringProperty.class);
/** canonical instance for empty strings */
public static final StringProperty EMPTY_STRING_PROPERTY = new StringProperty("");
@@ -108,7 +104,7 @@ public final class StringProperty extends Property {
if ("".equals(str) || str == null) {
return EMPTY_STRING_PROPERTY;
} else {
- return (StringProperty)cache.fetch(
+ return (StringProperty)CACHE.fetch(
new StringProperty(str));
}
}
diff --git a/src/java/org/apache/fop/fo/properties/TableBorderPrecedence.java b/src/java/org/apache/fop/fo/properties/TableBorderPrecedence.java
index 4a2fc92f4..b01ee22a0 100644
--- a/src/java/org/apache/fop/fo/properties/TableBorderPrecedence.java
+++ b/src/java/org/apache/fop/fo/properties/TableBorderPrecedence.java
@@ -24,7 +24,11 @@ import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.expr.PropertyException;
-public class TableBorderPrecedence extends NumberProperty.Maker{
+/**
+ * A table border preference property maker.
+ */
+public class TableBorderPrecedence extends NumberProperty.Maker {
+
private static Property num0 = NumberProperty.getInstance(0);
private static Property num1 = NumberProperty.getInstance(1);
private static Property num2 = NumberProperty.getInstance(2);
@@ -33,6 +37,10 @@ public class TableBorderPrecedence extends NumberProperty.Maker{
private static Property num5 = NumberProperty.getInstance(5);
private static Property num6 = NumberProperty.getInstance(6);
+ /**
+ * Construct a table border preference property maker.
+ * @param propId the border's property id
+ */
public TableBorderPrecedence(int propId) {
super(propId);
}
@@ -59,7 +67,8 @@ public class TableBorderPrecedence extends NumberProperty.Maker{
return num1;
case Constants.FO_TABLE_FOOTER:
return num0;
+ default:
+ return null;
}
- return null;
}
}
diff --git a/src/java/org/apache/fop/fo/properties/TextDecorationProperty.java b/src/java/org/apache/fop/fo/properties/TextDecorationProperty.java
index 3cbe56f00..bcd41fb20 100644
--- a/src/java/org/apache/fop/fo/properties/TextDecorationProperty.java
+++ b/src/java/org/apache/fop/fo/properties/TextDecorationProperty.java
@@ -14,6 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+/* $Id$ */
+
package org.apache.fop.fo.properties;
import java.util.Iterator;
@@ -72,11 +75,11 @@ public class TextDecorationProperty extends ListProperty {
if (prop instanceof EnumProperty) {
//skip
} else if (prop instanceof NCnameProperty) {
- Property prop_enum = checkEnumValues(((NCnameProperty)prop).getString());
- if (prop_enum == null) {
+ Property propEnum = checkEnumValues(((NCnameProperty)prop).getString());
+ if (propEnum == null) {
throw new PropertyException("Illegal enum value: " + prop.getString());
}
- l.set(i, prop_enum);
+ l.set(i, propEnum);
} else {
throw new PropertyException("Invalid content for text-decoration "
+ "property: " + prop);
@@ -113,7 +116,8 @@ public class TextDecorationProperty extends ListProperty {
case Constants.EN_UNDERLINE:
case Constants.EN_NO_UNDERLINE:
if (none) {
- throw new PropertyException("'none' specified, no additional values allowed");
+ throw new PropertyException
+ ("'none' specified, no additional values allowed");
}
if (under) {
throw new PropertyException("Invalid combination of values");
@@ -123,7 +127,8 @@ public class TextDecorationProperty extends ListProperty {
case Constants.EN_OVERLINE:
case Constants.EN_NO_OVERLINE:
if (none) {
- throw new PropertyException("'none' specified, no additional values allowed");
+ throw new PropertyException
+ ("'none' specified, no additional values allowed");
}
if (over) {
throw new PropertyException("Invalid combination of values");
@@ -133,7 +138,8 @@ public class TextDecorationProperty extends ListProperty {
case Constants.EN_LINE_THROUGH:
case Constants.EN_NO_LINE_THROUGH:
if (none) {
- throw new PropertyException("'none' specified, no additional values allowed");
+ throw new PropertyException
+ ("'none' specified, no additional values allowed");
}
if (through) {
throw new PropertyException("Invalid combination of values");
@@ -143,7 +149,8 @@ public class TextDecorationProperty extends ListProperty {
case Constants.EN_BLINK:
case Constants.EN_NO_BLINK:
if (none) {
- throw new PropertyException("'none' specified, no additional values allowed");
+ throw new PropertyException
+ ("'none' specified, no additional values allowed");
}
if (blink) {
throw new PropertyException("Invalid combination of values");
diff --git a/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java b/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java
index c04b1a892..59a6cafef 100644
--- a/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java
+++ b/src/java/org/apache/fop/fo/properties/ToBeImplementedProperty.java
@@ -22,22 +22,33 @@ package org.apache.fop.fo.properties;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
+/**
+ * A special property for representing an as yet unimplemented property.
+ */
public class ToBeImplementedProperty extends Property {
+ /**
+ * A to be implemented property maker instance.
+ */
public static class Maker extends PropertyMaker {
+ /**
+ * Instantiate a to be implemented property maker instance.
+ * @param propId a property id
+ */
public Maker(int propId) {
super(propId);
}
+ /** {@inheritDoc} */
public Property convertProperty(Property p,
PropertyList propertyList, FObj fo) {
if (p instanceof ToBeImplementedProperty) {
return p;
}
- ToBeImplementedProperty val =
- new ToBeImplementedProperty(getPropId());
+ ToBeImplementedProperty val
+ = new ToBeImplementedProperty(getPropId());
return val;
}
}
diff --git a/src/java/org/apache/fop/fo/properties/VerticalAlignShorthandParser.java b/src/java/org/apache/fop/fo/properties/VerticalAlignShorthandParser.java
index c0950a794..8c0cec744 100644
--- a/src/java/org/apache/fop/fo/properties/VerticalAlignShorthandParser.java
+++ b/src/java/org/apache/fop/fo/properties/VerticalAlignShorthandParser.java
@@ -18,6 +18,7 @@
/* $Id$ */
package org.apache.fop.fo.properties;
+
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.PropertyList;
@@ -47,6 +48,8 @@ public class VerticalAlignShorthandParser implements ShorthandParser, Constants
return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
case PR_DOMINANT_BASELINE:
return EnumProperty.getInstance(EN_AUTO, "AUTO");
+ default:
+ break;
}
case EN_TOP:
switch (propId) {
@@ -58,6 +61,8 @@ public class VerticalAlignShorthandParser implements ShorthandParser, Constants
return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
case PR_DOMINANT_BASELINE:
return EnumProperty.getInstance(EN_AUTO, "AUTO");
+ default:
+ break;
}
case EN_TEXT_TOP:
switch (propId) {
@@ -69,6 +74,8 @@ public class VerticalAlignShorthandParser implements ShorthandParser, Constants
return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
case PR_DOMINANT_BASELINE:
return EnumProperty.getInstance(EN_AUTO, "AUTO");
+ default:
+ break;
}
case EN_MIDDLE:
switch (propId) {
@@ -80,6 +87,8 @@ public class VerticalAlignShorthandParser implements ShorthandParser, Constants
return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
case PR_DOMINANT_BASELINE:
return EnumProperty.getInstance(EN_AUTO, "AUTO");
+ default:
+ break;
}
case EN_BOTTOM:
switch (propId) {
@@ -91,6 +100,8 @@ public class VerticalAlignShorthandParser implements ShorthandParser, Constants
return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
case PR_DOMINANT_BASELINE:
return EnumProperty.getInstance(EN_AUTO, "AUTO");
+ default:
+ break;
}
case EN_TEXT_BOTTOM:
switch (propId) {
@@ -102,6 +113,8 @@ public class VerticalAlignShorthandParser implements ShorthandParser, Constants
return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
case PR_DOMINANT_BASELINE:
return EnumProperty.getInstance(EN_AUTO, "AUTO");
+ default:
+ break;
}
case EN_SUB:
switch (propId) {
@@ -113,6 +126,8 @@ public class VerticalAlignShorthandParser implements ShorthandParser, Constants
return new EnumLength(EnumProperty.getInstance(EN_SUB, "SUB"));
case PR_DOMINANT_BASELINE:
return EnumProperty.getInstance(EN_AUTO, "AUTO");
+ default:
+ break;
}
case EN_SUPER:
switch (propId) {
@@ -124,6 +139,8 @@ public class VerticalAlignShorthandParser implements ShorthandParser, Constants
return new EnumLength(EnumProperty.getInstance(EN_SUPER, "SUPER"));
case PR_DOMINANT_BASELINE:
return EnumProperty.getInstance(EN_AUTO, "AUTO");
+ default:
+ break;
}
default:
switch (propId) {
@@ -135,6 +152,8 @@ public class VerticalAlignShorthandParser implements ShorthandParser, Constants
return new EnumLength(EnumProperty.getInstance(EN_BASELINE, "BASELINE"));
case PR_DOMINANT_BASELINE:
return EnumProperty.getInstance(EN_AUTO, "AUTO");
+ default:
+ break;
}
}
return null;
diff --git a/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java b/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java
index efadd8957..d8b8dac27 100644
--- a/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java
+++ b/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java
@@ -13,7 +13,8 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ */
+
/* $Id$ */
package org.apache.fop.fo.properties;
@@ -22,6 +23,9 @@ import org.apache.fop.fo.Constants;
import org.apache.fop.fo.PropertyList;
import org.apache.fop.fo.expr.PropertyException;
+/**
+ * A parser for the xml:lang property.
+ */
public class XMLLangShorthandParser extends GenericShorthandParser {
private static final char HYPHEN_MINUS = '-';
diff --git a/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java b/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java
index f03d4beab..71415faa3 100644
--- a/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java
+++ b/src/java/org/apache/fop/fonts/AbstractCodePointMapping.java
@@ -20,24 +20,25 @@
package org.apache.fop.fonts;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.Map;
-import org.apache.xmlgraphics.fonts.Glyphs;
-
import org.apache.fop.util.CharUtilities;
+import org.apache.xmlgraphics.fonts.Glyphs;
/**
* Abstract base class for code point mapping classes (1-byte character encodings).
*/
public class AbstractCodePointMapping implements SingleByteEncoding {
- private String name;
+ private final String name;
private char[] latin1Map;
private char[] characters;
private char[] codepoints;
private char[] unicodeMap; //code point to Unicode char
private String[] charNameMap; //all character names in the encoding
- private Map fallbackMap; //Here we accumulate all mappings we have found through substitution
+ //Here we accumulate all mappings we have found through substitution
+ private Map<Character, Character> fallbackMap;
/**
* Main constructor.
@@ -144,7 +145,7 @@ public class AbstractCodePointMapping implements SingleByteEncoding {
//Fallback: using cache
synchronized (this) {
if (fallbackMap != null) {
- Character fallback = (Character)fallbackMap.get(new Character(c));
+ Character fallback = fallbackMap.get(new Character(c));
if (fallback != null) {
return fallback.charValue();
}
@@ -172,7 +173,7 @@ public class AbstractCodePointMapping implements SingleByteEncoding {
private void putFallbackCharacter(char c, char mapTo) {
synchronized (this) {
if (this.fallbackMap == null) {
- this.fallbackMap = new java.util.HashMap();
+ this.fallbackMap = new HashMap<Character, Character>();
}
this.fallbackMap.put(new Character(c), new Character(mapTo));
}
@@ -239,6 +240,7 @@ public class AbstractCodePointMapping implements SingleByteEncoding {
}
/** {@inheritDoc} */
+ @Override
public String toString() {
return getName();
}
diff --git a/src/java/org/apache/fop/fonts/CIDFontType.java b/src/java/org/apache/fop/fonts/CIDFontType.java
index 24132ffc2..ce01fa629 100644
--- a/src/java/org/apache/fop/fonts/CIDFontType.java
+++ b/src/java/org/apache/fop/fonts/CIDFontType.java
@@ -38,6 +38,9 @@ public class CIDFontType extends ValuedEnum {
/**
+ * Construct a CID font type.
+ * @param name a type name
+ * @param value a type value
* @see org.apache.avalon.framework.Enum#Enum(String)
*/
protected CIDFontType(String name, int value) {
diff --git a/src/java/org/apache/fop/fonts/CIDSubset.java b/src/java/org/apache/fop/fonts/CIDSubset.java
index 6be4007ea..b152ad38e 100644
--- a/src/java/org/apache/fop/fonts/CIDSubset.java
+++ b/src/java/org/apache/fop/fonts/CIDSubset.java
@@ -21,7 +21,7 @@ package org.apache.fop.fonts;
import java.util.BitSet;
import java.util.Collections;
-import java.util.Iterator;
+import java.util.HashMap;
import java.util.Map;
import org.apache.fop.util.CharUtilities;
@@ -42,19 +42,22 @@ public class CIDSubset {
/**
* usedGlyphs contains orginal, new glyph index (glyph index -> char selector)
*/
- private Map/*<Integer, Integer>*/ usedGlyphs = new java.util.HashMap();
+ private Map<Integer, Integer> usedGlyphs = new HashMap<Integer, Integer>();
/**
* usedGlyphsIndex contains new glyph, original index (char selector -> glyph index)
*/
- private Map/*<Integer, Integer>*/ usedGlyphsIndex = new java.util.HashMap();
+ private Map<Integer, Integer> usedGlyphsIndex = new HashMap<Integer, Integer>();
private int usedGlyphsCount = 0;
/**
* usedCharsIndex contains new glyph, original char (char selector -> Unicode)
*/
- private Map/*<Integer, Character>*/ usedCharsIndex = new java.util.HashMap();
+ private Map<Integer, Character> usedCharsIndex = new HashMap<Integer, Character>();
+ /**
+ * Default constructor.
+ */
public CIDSubset() {
}
@@ -81,7 +84,7 @@ public class CIDSubset {
* @return the original index (or -1 if no glyph index is available for the subset index)
*/
public int getGlyphIndexForSubsetIndex(int subsetIndex) {
- Integer glyphIndex = (Integer)usedGlyphsIndex.get(new Integer(subsetIndex));
+ Integer glyphIndex = usedGlyphsIndex.get(new Integer(subsetIndex));
if (glyphIndex != null) {
return glyphIndex.intValue();
} else {
@@ -96,7 +99,7 @@ public class CIDSubset {
* @return the Unicode value or "NOT A CHARACTER" (0xFFFF)
*/
public char getUnicodeForSubsetIndex(int subsetIndex) {
- Character mapValue = (Character)usedCharsIndex.get(new Integer(subsetIndex));
+ Character mapValue = usedCharsIndex.get(new Integer(subsetIndex));
if (mapValue != null) {
return mapValue.charValue();
} else {
@@ -115,7 +118,7 @@ public class CIDSubset {
public int mapSubsetChar(int glyphIndex, char unicode) {
// Reencode to a new subset font or get the reencoded value
// IOW, accumulate the accessed characters and build a character map for them
- Integer subsetCharSelector = (Integer)usedGlyphs.get(new Integer(glyphIndex));
+ Integer subsetCharSelector = usedGlyphs.get(new Integer(glyphIndex));
if (subsetCharSelector == null) {
int selector = usedGlyphsCount;
usedGlyphs.put(new Integer(glyphIndex),
@@ -136,7 +139,7 @@ public class CIDSubset {
* character selector (i.e. the subset index in this case).
* @return Map Map&lt;Integer, Integer&gt; of the font subset
*/
- public Map/*<Integer, Integer>*/ getSubsetGlyphs() {
+ public Map<Integer, Integer> getSubsetGlyphs() {
return Collections.unmodifiableMap(this.usedGlyphs);
}
@@ -166,9 +169,7 @@ public class CIDSubset {
*/
public BitSet getGlyphIndexBitSet() {
BitSet bitset = new BitSet();
- Iterator iter = usedGlyphsIndex.keySet().iterator();
- while (iter.hasNext()) {
- Integer cid = (Integer)iter.next();
+ for (Integer cid : usedGlyphs.keySet()) {
bitset.set(cid.intValue());
}
return bitset;
diff --git a/src/java/org/apache/fop/fonts/CustomFont.java b/src/java/org/apache/fop/fonts/CustomFont.java
index 4cf24ae16..4432fccef 100644
--- a/src/java/org/apache/fop/fonts/CustomFont.java
+++ b/src/java/org/apache/fop/fonts/CustomFont.java
@@ -21,6 +21,8 @@ package org.apache.fop.fonts;
import java.io.IOException;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -35,7 +37,7 @@ public abstract class CustomFont extends Typeface
private String fontName = null;
private String fullName = null;
- private Set familyNames = null; //Set<String>
+ private Set<String> familyNames = null;
private String fontSubName = null;
private String embedFileName = null;
private String embedResourceName = null;
@@ -55,7 +57,7 @@ public abstract class CustomFont extends Typeface
private int firstChar = 0;
private int lastChar = 255;
- private Map kerning;
+ private Map<Integer, Map<Integer, Integer>> kerning;
private boolean useKerning = true;
@@ -78,7 +80,7 @@ public abstract class CustomFont extends Typeface
* Returns the font family names.
* @return the font family names (a Set of Strings)
*/
- public Set getFamilyNames() {
+ public Set<String> getFamilyNames() {
return Collections.unmodifiableSet(this.familyNames);
}
@@ -275,11 +277,11 @@ public abstract class CustomFont extends Typeface
/**
* {@inheritDoc}
*/
- public final Map getKerningInfo() {
+ public final Map<Integer, Map<Integer, Integer>> getKerningInfo() {
if (hasKerningInfo()) {
return kerning;
} else {
- return java.util.Collections.EMPTY_MAP;
+ return Collections.emptyMap();
}
}
@@ -296,8 +298,8 @@ public abstract class CustomFont extends Typeface
}
/** {@inheritDoc} */
- public void setFamilyNames(Set names) {
- this.familyNames = new java.util.HashSet(names);
+ public void setFamilyNames(Set<String> names) {
+ this.familyNames = new HashSet<String>(names);
}
/**
@@ -434,9 +436,9 @@ public abstract class CustomFont extends Typeface
}
/** {@inheritDoc} */
- public void putKerningEntry(Integer key, Map value) {
+ public void putKerningEntry(Integer key, Map<Integer, Integer> value) {
if (kerning == null) {
- kerning = new java.util.HashMap();
+ kerning = new HashMap<Integer, Map<Integer, Integer>>();
}
this.kerning.put(key, value);
}
@@ -446,9 +448,9 @@ public abstract class CustomFont extends Typeface
* @param kerningMap the kerning map (Map<Integer, Map<Integer, Integer>, the integers are
* character codes)
*/
- public void replaceKerningMap(Map kerningMap) {
+ public void replaceKerningMap(Map<Integer, Map<Integer, Integer>> kerningMap) {
if (kerningMap == null) {
- this.kerning = Collections.EMPTY_MAP;
+ this.kerning = Collections.emptyMap();
} else {
this.kerning = kerningMap;
}
diff --git a/src/java/org/apache/fop/fonts/CustomFontCollection.java b/src/java/org/apache/fop/fonts/CustomFontCollection.java
index 5a0bba782..9f98814a3 100644
--- a/src/java/org/apache/fop/fonts/CustomFontCollection.java
+++ b/src/java/org/apache/fop/fonts/CustomFontCollection.java
@@ -27,7 +27,7 @@ import java.util.List;
public class CustomFontCollection implements FontCollection {
private FontResolver fontResolver;
- private List/*<EmbedFontInfo>*/ embedFontInfoList;
+ private final List<EmbedFontInfo> embedFontInfoList;
/**
* Main constructor.
@@ -35,7 +35,7 @@ public class CustomFontCollection implements FontCollection {
* @param customFonts the list of custom fonts
*/
public CustomFontCollection(FontResolver fontResolver,
- List/*<EmbedFontInfo>*/ customFonts) {
+ List<EmbedFontInfo> customFonts) {
this.fontResolver = fontResolver;
if (this.fontResolver == null) {
//Ensure that we have minimal font resolution capabilities
@@ -54,7 +54,7 @@ public class CustomFontCollection implements FontCollection {
//FontReader reader = null;
for (int i = 0; i < embedFontInfoList.size(); i++) {
- EmbedFontInfo embedFontInfo = (EmbedFontInfo)embedFontInfoList.get(i);
+ EmbedFontInfo embedFontInfo = embedFontInfoList.get(i);
//String metricsFile = configFontInfo.getMetricsFile();
internalName = "F" + num;
@@ -69,7 +69,7 @@ public class CustomFontCollection implements FontCollection {
LazyFont font = new LazyFont(embedFontInfo, this.fontResolver);
fontInfo.addMetrics(internalName, font);
- List triplets = embedFontInfo.getFontTriplets();
+ List<FontTriplet> triplets = embedFontInfo.getFontTriplets();
for (int tripletIndex = 0; tripletIndex < triplets.size(); tripletIndex++) {
FontTriplet triplet = (FontTriplet) triplets.get(tripletIndex);
fontInfo.addFontProperties(internalName, triplet);
diff --git a/src/java/org/apache/fop/fonts/EmbedFontInfo.java b/src/java/org/apache/fop/fonts/EmbedFontInfo.java
index aa464c21d..b53cdfdd6 100644
--- a/src/java/org/apache/fop/fonts/EmbedFontInfo.java
+++ b/src/java/org/apache/fop/fonts/EmbedFontInfo.java
@@ -46,7 +46,7 @@ public class EmbedFontInfo implements Serializable {
protected String subFontName = null;
/** the list of associated font triplets */
- private List/*<FontTriplet>*/ fontTriplets = null;
+ private List<FontTriplet> fontTriplets = null;
private transient boolean embedded = true;
@@ -59,7 +59,7 @@ public class EmbedFontInfo implements Serializable {
* @param subFontName the sub-fontname used for TrueType Collections (null otherwise)
*/
public EmbedFontInfo(String metricsFile, boolean kerning,
- List/*<FontTriplet>*/ fontTriplets, String embedFile, String subFontName) {
+ List<FontTriplet> fontTriplets, String embedFile, String subFontName) {
this.metricsFile = metricsFile;
this.embedFile = embedFile;
this.kerning = kerning;
@@ -120,7 +120,7 @@ public class EmbedFontInfo implements Serializable {
* Returns the list of font triplets associated with this font.
* @return List of font triplets
*/
- public List/*<FontTriplet>*/ getFontTriplets() {
+ public List<FontTriplet> getFontTriplets() {
return fontTriplets;
}
diff --git a/src/java/org/apache/fop/fonts/EncodingMode.java b/src/java/org/apache/fop/fonts/EncodingMode.java
index 734292c54..8a40d6593 100644
--- a/src/java/org/apache/fop/fonts/EncodingMode.java
+++ b/src/java/org/apache/fop/fonts/EncodingMode.java
@@ -19,25 +19,19 @@
package org.apache.fop.fonts;
-import java.io.ObjectStreamException;
-import java.io.Serializable;
-
-
/**
* This class enumerates all supported encoding modes for fonts: auto, single-byte and CID.
*/
-public final class EncodingMode implements Serializable {
-
- private static final long serialVersionUID = 8311486102457779529L;
+public enum EncodingMode {
/** Automatic selection of encoding mode. */
- public static final EncodingMode AUTO = new EncodingMode("auto");
+ AUTO("auto"),
/** Single-byte encoding */
- public static final EncodingMode SINGLE_BYTE = new EncodingMode("single-byte");
+ SINGLE_BYTE("single-byte"),
/** CID encoding */
- public static final EncodingMode CID = new EncodingMode("cid");
+ CID("cid");
private String name;
@@ -58,25 +52,18 @@ public final class EncodingMode implements Serializable {
* @param name the name of the encoding mode to look up
* @return the encoding mode constant
*/
- public static EncodingMode valueOf(String name) {
- if (name.equalsIgnoreCase(EncodingMode.AUTO.getName())) {
- return EncodingMode.AUTO;
- } else if (name.equalsIgnoreCase(EncodingMode.SINGLE_BYTE.getName())) {
- return EncodingMode.SINGLE_BYTE;
- } else if (name.equalsIgnoreCase(EncodingMode.CID.getName())) {
- return EncodingMode.CID;
- } else {
- throw new IllegalArgumentException("Invalid encoding mode: " + name);
+ public static EncodingMode getEncodingMode(String name) {
+ for (EncodingMode em : EncodingMode.values()) {
+ if (name.equalsIgnoreCase(em.getName())) {
+ return em;
+ }
}
- }
-
- private Object readResolve() throws ObjectStreamException {
- return valueOf(getName());
+ throw new IllegalArgumentException("Invalid encoding mode: " + name);
}
/** {@inheritDoc} */
public String toString() {
- return "EncodingMode:" + getName();
+ return "EncodingMode: " + getName();
}
}
diff --git a/src/java/org/apache/fop/fonts/Font.java b/src/java/org/apache/fop/fonts/Font.java
index d0a87efbf..8ca802234 100644
--- a/src/java/org/apache/fop/fonts/Font.java
+++ b/src/java/org/apache/fop/fonts/Font.java
@@ -19,11 +19,11 @@
package org.apache.fop.fonts;
+import java.util.Collections;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.fonts.CodePointMapping;
/**
* This class holds font state information and provides access to the font
@@ -160,11 +160,11 @@ public class Font {
* Returns the font's kerning table
* @return the kerning table
*/
- public Map getKerning() {
+ public Map<Integer, Map<Integer, Integer>> getKerning() {
if (metric.hasKerningInfo()) {
return metric.getKerningInfo();
} else {
- return java.util.Collections.EMPTY_MAP;
+ return Collections.emptyMap();
}
}
@@ -178,9 +178,9 @@ public class Font {
* @return the distance to adjust for kerning, 0 if there's no kerning
*/
public int getKernValue(char ch1, char ch2) {
- Map kernPair = (Map)getKerning().get(new Integer(ch1));
+ Map<Integer, Integer> kernPair = getKerning().get((int) ch1);
if (kernPair != null) {
- Integer width = (Integer)kernPair.get(new Integer(ch2));
+ Integer width = kernPair.get((int) ch2);
if (width != null) {
return width.intValue() * getFontSize() / 1000;
}
@@ -239,6 +239,7 @@ public class Font {
/**
* {@inheritDoc}
*/
+ @Override
public String toString() {
StringBuffer sbuf = new StringBuffer();
sbuf.append('(');
diff --git a/src/java/org/apache/fop/fonts/FontAdder.java b/src/java/org/apache/fop/fonts/FontAdder.java
index f0e511c42..c5e2b8b9f 100644
--- a/src/java/org/apache/fop/fonts/FontAdder.java
+++ b/src/java/org/apache/fop/fonts/FontAdder.java
@@ -20,18 +20,17 @@
package org.apache.fop.fonts;
import java.net.URL;
-import java.util.Iterator;
import java.util.List;
import org.apache.fop.fonts.autodetect.FontInfoFinder;
/**
- * Adds a list of fonts to a given font info list
+ * Adds a list of fonts to a given font info list
*/
public class FontAdder {
- private FontEventListener listener;
- private FontResolver resolver;
- private FontManager manager;
+ private final FontEventListener listener;
+ private final FontResolver resolver;
+ private final FontManager manager;
/**
* Main constructor
@@ -44,20 +43,19 @@ public class FontAdder {
this.resolver = resolver;
this.listener = listener;
}
-
+
/**
* Iterates over font url list adding to font info list
* @param fontURLList font file list
* @param fontInfoList a configured font info list
*/
- public void add(List/*<URL>*/ fontURLList, List/*<EmbedFontInfo>*/ fontInfoList) {
+ public void add(List<URL> fontURLList, List<EmbedFontInfo> fontInfoList) {
FontCache cache = manager.getFontCache();
FontInfoFinder finder = new FontInfoFinder();
finder.setEventListener(listener);
- for (Iterator iter = fontURLList.iterator(); iter.hasNext();) {
- URL fontUrl = (URL)iter.next();
- EmbedFontInfo[] embedFontInfos = finder.find(fontUrl, resolver, cache);
+ for (URL fontURL : fontURLList) {
+ EmbedFontInfo[] embedFontInfos = finder.find(fontURL, resolver, cache);
if (embedFontInfos == null) {
continue;
}
diff --git a/src/java/org/apache/fop/fonts/FontCache.java b/src/java/org/apache/fop/fonts/FontCache.java
index 9d5eff010..87298a707 100644
--- a/src/java/org/apache/fop/fonts/FontCache.java
+++ b/src/java/org/apache/fop/fonts/FontCache.java
@@ -19,7 +19,9 @@
package org.apache.fop.fonts;
+import java.io.BufferedInputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
@@ -29,6 +31,7 @@ import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
+import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.FileUtils;
@@ -45,8 +48,8 @@ import org.apache.fop.util.LogUtil;
public final class FontCache implements Serializable {
/**
- * Serialization Version UID. Change this value if you want to make sure the user's cache
- * file is purged after an update.
+ * Serialization Version UID. Change this value if you want to make sure the
+ * user's cache file is purged after an update.
*/
private static final long serialVersionUID = 605232520271754719L;
@@ -59,19 +62,23 @@ public final class FontCache implements Serializable {
/** font cache file path */
private static final String DEFAULT_CACHE_FILENAME = "fop-fonts.cache";
-
/** has this cache been changed since it was last read? */
private transient boolean changed = false;
/** change lock */
private final boolean[] changeLock = new boolean[1];
- /** master mapping of font url -> font info. This needs to be
- * a list, since a TTC file may contain more than 1 font. */
- private Map/*<String, CachedFontFile>*/ fontfileMap = null;
+ /**
+ * master mapping of font url -> font info. This needs to be a list, since a
+ * TTC file may contain more than 1 font.
+ */
+ private Map<String, CachedFontFile> fontfileMap = null;
- /** mapping of font url -> file modified date (for all fonts that have failed to load) */
- private Map failedFontMap/*<String, Long>*/ = null;
+ /**
+ * mapping of font url -> file modified date (for all fonts that have failed
+ * to load)
+ */
+ private Map<String, Long> failedFontMap = null;
/**
* Default constructor
@@ -100,7 +107,9 @@ public final class FontCache implements Serializable {
/**
* Returns the default font cache file.
- * @param forWriting true if the user directory should be created
+ *
+ * @param forWriting
+ * true if the user directory should be created
* @return the default font cache file
*/
public static File getDefaultCacheFile(boolean forWriting) {
@@ -125,8 +134,9 @@ public final class FontCache implements Serializable {
/**
* Reads the default font cache file and returns its contents.
- * @return the font cache deserialized from the file (or null if no cache file exists or if
- * it could not be read)
+ *
+ * @return the font cache deserialized from the file (or null if no cache
+ * file exists or if it could not be read)
*/
public static FontCache load() {
return loadFrom(getDefaultCacheFile(false));
@@ -134,36 +144,41 @@ public final class FontCache implements Serializable {
/**
* Reads a font cache file and returns its contents.
- * @param cacheFile the cache file
- * @return the font cache deserialized from the file (or null if no cache file exists or if
- * it could not be read)
+ *
+ * @param cacheFile
+ * the cache file
+ * @return the font cache deserialized from the file (or null if no cache
+ * file exists or if it could not be read)
*/
public static FontCache loadFrom(File cacheFile) {
if (cacheFile.exists()) {
try {
if (log.isTraceEnabled()) {
- log.trace("Loading font cache from " + cacheFile.getCanonicalPath());
+ log.trace("Loading font cache from "
+ + cacheFile.getCanonicalPath());
}
- InputStream in = new java.io.FileInputStream(cacheFile);
- in = new java.io.BufferedInputStream(in);
+ InputStream in = new BufferedInputStream(new FileInputStream(cacheFile));
ObjectInputStream oin = new ObjectInputStream(in);
try {
- return (FontCache)oin.readObject();
+ return (FontCache) oin.readObject();
} finally {
IOUtils.closeQuietly(oin);
}
} catch (ClassNotFoundException e) {
- //We don't really care about the exception since it's just a cache file
+ // We don't really care about the exception since it's just a
+ // cache file
log.warn("Could not read font cache. Discarding font cache file. Reason: "
+ e.getMessage());
} catch (IOException ioe) {
- //We don't really care about the exception since it's just a cache file
- log.warn("I/O exception while reading font cache (" + ioe.getMessage()
- + "). Discarding font cache file.");
+ // We don't really care about the exception since it's just a
+ // cache file
+ log.warn("I/O exception while reading font cache ("
+ + ioe.getMessage() + "). Discarding font cache file.");
try {
cacheFile.delete();
} catch (SecurityException ex) {
- log.warn("Failed to delete font cache file: " + cacheFile.getAbsolutePath());
+ log.warn("Failed to delete font cache file: "
+ + cacheFile.getAbsolutePath());
}
}
}
@@ -172,7 +187,9 @@ public final class FontCache implements Serializable {
/**
* Writes the font cache to disk.
- * @throws FOPException fop exception
+ *
+ * @throws FOPException
+ * fop exception
*/
public void save() throws FOPException {
saveTo(getDefaultCacheFile(true));
@@ -180,16 +197,17 @@ public final class FontCache implements Serializable {
/**
* Writes the font cache to disk.
- * @param cacheFile the file to write to
- * @throws FOPException fop exception
+ *
+ * @param cacheFile
+ * the file to write to
+ * @throws FOPException
+ * fop exception
*/
public void saveTo(File cacheFile) throws FOPException {
synchronized (changeLock) {
if (changed) {
try {
- if (log.isTraceEnabled()) {
- log.trace("Writing font cache to " + cacheFile.getCanonicalPath());
- }
+ log.trace("Writing font cache to " + cacheFile.getCanonicalPath());
OutputStream out = new java.io.FileOutputStream(cacheFile);
out = new java.io.BufferedOutputStream(out);
ObjectOutputStream oout = new ObjectOutputStream(out);
@@ -209,7 +227,9 @@ public final class FontCache implements Serializable {
/**
* creates a key given a font info for the font mapping
- * @param fontInfo font info
+ *
+ * @param fontInfo
+ * font info
* @return font cache key
*/
protected static String getCacheKey(EmbedFontInfo fontInfo) {
@@ -223,6 +243,7 @@ public final class FontCache implements Serializable {
/**
* cache has been updated since it was read
+ *
* @return if this cache has changed
*/
public boolean hasChanged() {
@@ -231,28 +252,33 @@ public final class FontCache implements Serializable {
/**
* is this font in the cache?
- * @param embedUrl font info
+ *
+ * @param embedUrl
+ * font info
* @return boolean
*/
public boolean containsFont(String embedUrl) {
- return (embedUrl != null
- && getFontFileMap().containsKey(embedUrl));
+ return (embedUrl != null && getFontFileMap().containsKey(embedUrl));
}
/**
* is this font info in the cache?
- * @param fontInfo font info
+ *
+ * @param fontInfo
+ * font info
* @return font
*/
public boolean containsFont(EmbedFontInfo fontInfo) {
- return (fontInfo != null
- && getFontFileMap().containsKey(getCacheKey(fontInfo)));
+ return (fontInfo != null && getFontFileMap().containsKey(
+ getCacheKey(fontInfo)));
}
/**
- * Tries to identify a File instance from an array of URLs. If there's no file URL in the
- * array, the method returns null.
- * @param urls array of possible font urls
+ * Tries to identify a File instance from an array of URLs. If there's no
+ * file URL in the array, the method returns null.
+ *
+ * @param urls
+ * array of possible font urls
* @return file font file
*/
public static File getFileFromUrls(String[] urls) {
@@ -279,31 +305,34 @@ public final class FontCache implements Serializable {
return null;
}
- private Map/*<String, CachedFontFile>*/ getFontFileMap() {
+ private Map<String, CachedFontFile> getFontFileMap() {
if (fontfileMap == null) {
- fontfileMap = new java.util.HashMap/*<String, CachedFontFile>*/();
+ fontfileMap = new HashMap<String, CachedFontFile>();
}
return fontfileMap;
}
/**
* Adds a font info to cache
- * @param fontInfo font info
+ *
+ * @param fontInfo
+ * font info
*/
public void addFont(EmbedFontInfo fontInfo) {
String cacheKey = getCacheKey(fontInfo);
synchronized (changeLock) {
CachedFontFile cachedFontFile;
if (containsFont(cacheKey)) {
- cachedFontFile = (CachedFontFile)getFontFileMap().get(cacheKey);
+ cachedFontFile = getFontFileMap().get(cacheKey);
if (!cachedFontFile.containsFont(fontInfo)) {
cachedFontFile.put(fontInfo);
}
} else {
// try and determine modified date
- File fontFile = getFileFromUrls(new String[]
- {fontInfo.getEmbedFile(), fontInfo.getMetricsFile()});
- long lastModified = (fontFile != null ? fontFile.lastModified() : -1);
+ File fontFile = getFileFromUrls(new String[] {
+ fontInfo.getEmbedFile(), fontInfo.getMetricsFile() });
+ long lastModified = (fontFile != null ? fontFile.lastModified()
+ : -1);
cachedFontFile = new CachedFontFile(lastModified);
if (log.isTraceEnabled()) {
log.trace("Font added to cache: " + cacheKey);
@@ -317,19 +346,26 @@ public final class FontCache implements Serializable {
/**
* Returns a font from the cache.
- * @param embedUrl font info
+ *
+ * @param embedUrl
+ * font info
* @return CachedFontFile object
*/
public CachedFontFile getFontFile(String embedUrl) {
- return containsFont(embedUrl) ? (CachedFontFile) getFontFileMap().get(embedUrl) : null;
+ return containsFont(embedUrl) ? getFontFileMap().get(embedUrl) : null;
}
/**
- * Returns the EmbedFontInfo instances belonging to a font file. If the font file was
- * modified since it was cached the entry is removed and null is returned.
- * @param embedUrl the font URL
- * @param lastModified the last modified date/time of the font file
- * @return the EmbedFontInfo instances or null if there's no cached entry or if it is outdated
+ * Returns the EmbedFontInfo instances belonging to a font file. If the font
+ * file was modified since it was cached the entry is removed and null is
+ * returned.
+ *
+ * @param embedUrl
+ * the font URL
+ * @param lastModified
+ * the last modified date/time of the font file
+ * @return the EmbedFontInfo instances or null if there's no cached entry or
+ * if it is outdated
*/
public EmbedFontInfo[] getFontInfos(String embedUrl, long lastModified) {
CachedFontFile cff = getFontFile(embedUrl);
@@ -343,7 +379,9 @@ public final class FontCache implements Serializable {
/**
* removes font from cache
- * @param embedUrl embed url
+ *
+ * @param embedUrl
+ * embed url
*/
public void removeFont(String embedUrl) {
synchronized (changeLock) {
@@ -359,14 +397,18 @@ public final class FontCache implements Serializable {
/**
* has this font previously failed to load?
- * @param embedUrl embed url
- * @param lastModified last modified
+ *
+ * @param embedUrl
+ * embed url
+ * @param lastModified
+ * last modified
* @return whether this is a failed font
*/
public boolean isFailedFont(String embedUrl, long lastModified) {
synchronized (changeLock) {
if (getFailedFontMap().containsKey(embedUrl)) {
- long failedLastModified = ((Long)getFailedFontMap().get(embedUrl)).longValue();
+ long failedLastModified = getFailedFontMap().get(
+ embedUrl).longValue();
if (lastModified != failedLastModified) {
// this font has been changed so lets remove it
// from failed font map for now
@@ -382,8 +424,11 @@ public final class FontCache implements Serializable {
/**
* Registers a failed font with the cache
- * @param embedUrl embed url
- * @param lastModified time last modified
+ *
+ * @param embedUrl
+ * embed url
+ * @param lastModified
+ * time last modified
*/
public void registerFailedFont(String embedUrl, long lastModified) {
synchronized (changeLock) {
@@ -394,9 +439,9 @@ public final class FontCache implements Serializable {
}
}
- private Map/*<String, Long>*/ getFailedFontMap() {
+ private Map<String, Long> getFailedFontMap() {
if (failedFontMap == null) {
- failedFontMap = new java.util.HashMap/*<String, Long>*/();
+ failedFontMap = new HashMap<String, Long>();
}
return failedFontMap;
}
@@ -417,7 +462,9 @@ public final class FontCache implements Serializable {
/**
* Retrieve the last modified date/time of a URL.
- * @param url the URL
+ *
+ * @param url
+ * the URL
* @return the last modified date/time
*/
public static long getLastModified(URL url) {
@@ -426,7 +473,8 @@ public final class FontCache implements Serializable {
try {
return conn.getLastModified();
} finally {
- //An InputStream is created even if it's not accessed, but we need to close it.
+ // An InputStream is created even if it's not accessed, but we
+ // need to close it.
IOUtils.closeQuietly(conn.getInputStream());
}
} catch (IOException e) {
@@ -442,15 +490,15 @@ public final class FontCache implements Serializable {
/** file modify date (if available) */
private long lastModified = -1;
- private Map/*<String, EmbedFontInfo>*/ filefontsMap = null;
+ private Map<String, EmbedFontInfo> filefontsMap = null;
public CachedFontFile(long lastModified) {
setLastModified(lastModified);
}
- private Map/*<String, EmbedFontInfo>*/ getFileFontsMap() {
+ private Map<String, EmbedFontInfo> getFileFontsMap() {
if (filefontsMap == null) {
- filefontsMap = new java.util.HashMap/*<String, EmbedFontInfo>*/();
+ filefontsMap = new HashMap<String, EmbedFontInfo>();
}
return filefontsMap;
}
@@ -465,12 +513,13 @@ public final class FontCache implements Serializable {
}
public EmbedFontInfo[] getEmbedFontInfos() {
- return (EmbedFontInfo[])getFileFontsMap().values().toArray(
+ return getFileFontsMap().values().toArray(
new EmbedFontInfo[getFileFontsMap().size()]);
}
/**
* Gets the modified timestamp for font file (not always available)
+ *
* @return modified timestamp
*/
public long lastModified() {
@@ -478,17 +527,18 @@ public final class FontCache implements Serializable {
}
/**
- * Gets the modified timestamp for font file
- * (used for the purposes of font info caching)
- * @param lastModified modified font file timestamp
+ * Gets the modified timestamp for font file (used for the purposes of
+ * font info caching)
+ *
+ * @param lastModified
+ * modified font file timestamp
*/
public void setLastModified(long lastModified) {
this.lastModified = lastModified;
}
/**
- * @return string representation of this object
- * {@inheritDoc}
+ * @return string representation of this object {@inheritDoc}
*/
public String toString() {
return super.toString() + ", lastModified=" + lastModified;
diff --git a/src/java/org/apache/fop/fonts/FontDetector.java b/src/java/org/apache/fop/fonts/FontDetector.java
index 828cad2b5..88e4c6e69 100644
--- a/src/java/org/apache/fop/fonts/FontDetector.java
+++ b/src/java/org/apache/fop/fonts/FontDetector.java
@@ -41,10 +41,10 @@ public class FontDetector {
private static final String[] FONT_MIMETYPES = {
"application/x-font", "application/x-font-truetype"
};
-
- private FontManager fontManager;
- private FontAdder fontAdder;
- private boolean strict;
+
+ private final FontManager fontManager;
+ private final FontAdder fontAdder;
+ private final boolean strict;
/**
* Main constructor
@@ -63,7 +63,7 @@ public class FontDetector {
* @param fontInfoList a list of fontinfo to populate
* @throws FOPException thrown if a problem occurred during detection
*/
- public void detect(List/*<EmbedFontInfo>*/ fontInfoList) throws FOPException {
+ public void detect(List<EmbedFontInfo> fontInfoList) throws FOPException {
// search in font base if it is defined and
// is a directory but don't recurse
FontFileFinder fontFileFinder = new FontFileFinder();
@@ -72,10 +72,9 @@ public class FontDetector {
try {
File fontBase = FileUtils.toFile(new URL(fontBaseURL));
if (fontBase != null) {
- List/*<URL>*/ fontURLList = fontFileFinder.find(
- fontBase.getAbsolutePath());
+ List<URL> fontURLList = fontFileFinder.find(fontBase.getAbsolutePath());
fontAdder.add(fontURLList, fontInfoList);
-
+
//Can only use the font base URL if it's a file URL
}
} catch (IOException e) {
@@ -84,7 +83,7 @@ public class FontDetector {
}
// native o/s font directory finding
- List/*<URL>*/ systemFontList;
+ List<URL> systemFontList;
try {
systemFontList = fontFileFinder.find();
fontAdder.add(systemFontList, fontInfoList);
diff --git a/src/java/org/apache/fop/fonts/FontInfo.java b/src/java/org/apache/fop/fonts/FontInfo.java
index a7b840fcc..c0bf8db8d 100644
--- a/src/java/org/apache/fop/fonts/FontInfo.java
+++ b/src/java/org/apache/fop/fonts/FontInfo.java
@@ -19,12 +19,15 @@
package org.apache.fop.fonts;
-import java.util.Collection;
+import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -41,29 +44,29 @@ import org.apache.commons.logging.LogFactory;
public class FontInfo {
/** logging instance */
- protected static Log log = LogFactory.getLog(FontInfo.class);
+ protected static final Log log = LogFactory.getLog(FontInfo.class);
/** Map containing fonts that have been used */
- private Map/*<String,FontMetrics>*/ usedFonts = null; //(String = font key)
+ private Map<String, Typeface> usedFonts = null; //(String = font key)
/** look up a font-triplet to find a font-name */
- private Map/*<FontTriplet,String>*/ triplets = null; //(String = font key)
+ private Map<FontTriplet, String> triplets = null; //(String = font key)
/** look up a font-triplet to find its priority
* (only used inside addFontProperties()) */
- private Map/*<FontTriplet,Integer>*/ tripletPriorities = null; //Map<FontTriplet,Integer>
+ private Map<FontTriplet, Integer> tripletPriorities = null; //Map<FontTriplet,Integer>
/** look up a font-name to get a font (that implements FontMetrics at least) */
- private Map/*<String,FontMetrics>*/ fonts = null; //(String = font key)
+ private Map<String, Typeface> fonts = null; //(String = font key)
/**
* a collection of missing fonts; used to make sure the user gets
* a warning for a missing font only once (not every time the font is used)
*/
- private Set/*<FontTriplet>*/ loggedFontKeys = null;
+ private Set<FontTriplet> loggedFontKeys = null;
/** Cache for Font instances. */
- private Map/*<FontTriplet, Map>*/ fontInstanceCache = null;
+ private Map<FontTriplet, Map<Integer, Font>> fontInstanceCache = null;
/** Event listener for font events */
private FontEventListener eventListener = null;
@@ -72,10 +75,10 @@ public class FontInfo {
* Main constructor
*/
public FontInfo() {
- this.triplets = new java.util.HashMap/*<FontTriplet, String>*/();
- this.tripletPriorities = new java.util.HashMap/*<FontTriplet, Integer>*/();
- this.fonts = new java.util.HashMap/*<String, FontMetrics>*/();
- this.usedFonts = new java.util.HashMap/*<String,FontMetrics>*/();
+ this.triplets = new HashMap<FontTriplet, String>();
+ this.tripletPriorities = new HashMap<FontTriplet, Integer>();
+ this.fonts = new HashMap<String, Typeface>();
+ this.usedFonts = new HashMap<String, Typeface>();
}
/**
@@ -135,10 +138,10 @@ public class FontInfo {
if (log.isDebugEnabled()) {
log.debug("Registering: " + triplet + " under " + internalFontKey);
}
- String oldName = (String)triplets.get(triplet);
+ String oldName = triplets.get(triplet);
int newPriority = triplet.getPriority();
if (oldName != null) {
- int oldPriority = ((Integer)tripletPriorities.get(triplet)).intValue();
+ int oldPriority = tripletPriorities.get(triplet).intValue();
if (oldPriority < newPriority) {
logDuplicateFont(triplet, false, oldName, oldPriority,
internalFontKey, newPriority);
@@ -168,9 +171,9 @@ public class FontInfo {
if (log.isDebugEnabled()) {
log.debug(triplet
+ (replacing ? ": Replacing " : ": Not replacing ")
- + ((FontMetrics)fonts.get(triplets.get(triplet))).getFullName()
+ + fonts.get(triplets.get(triplet)).getFullName()
+ " (priority=" + oldPriority + ") by "
- + ((FontMetrics)fonts.get(newKey)).getFullName()
+ + fonts.get(newKey).getFullName()
+ " (priority=" + newPriority + ")");
}
}
@@ -186,7 +189,7 @@ public class FontInfo {
if (metrics instanceof Typeface) {
((Typeface)metrics).setEventListener(this.eventListener);
}
- this.fonts.put(internalFontKey, metrics);
+ this.fonts.put(internalFontKey, (Typeface)metrics);
}
/**
@@ -292,9 +295,9 @@ public class FontInfo {
usedFonts.put(internalName, fonts.get(internalName));
}
- private Map/*<FontTriplet,Map<Integer,Font>>*/ getFontInstanceCache() {
+ private Map<FontTriplet, Map<Integer, Font>> getFontInstanceCache() {
if (fontInstanceCache == null) {
- fontInstanceCache = new java.util.HashMap/*<FontTriplet, Map<Integer,Font>>*/();
+ fontInstanceCache = new HashMap<FontTriplet, Map<Integer, Font>>();
}
return fontInstanceCache;
}
@@ -307,14 +310,14 @@ public class FontInfo {
* @return the requested Font instance
*/
public Font getFontInstance(FontTriplet triplet, int fontSize) {
- Map/*<Integer,Font>*/ sizes
- = (Map/*<Integer,Font>*/)getFontInstanceCache().get(triplet);
+ Map<Integer, Font> sizes
+ = getFontInstanceCache().get(triplet);
if (sizes == null) {
- sizes = new java.util.HashMap/*<Integer,Font>*/();
+ sizes = new HashMap<Integer, Font>();
getFontInstanceCache().put(triplet, sizes);
}
Integer size = new Integer(fontSize);
- Font font = (Font)sizes.get(size);
+ Font font = sizes.get(size);
if (font == null) {
String fontKey = getInternalFontKey(triplet);
useFont(fontKey);
@@ -325,11 +328,9 @@ public class FontInfo {
return font;
}
- private List/*<FontTriplet>*/ getTripletsForName(String fontName) {
- List/*<FontTriplet>*/ matchedTriplets = new java.util.ArrayList/*<FontTriplet>*/();
- Iterator it = triplets.keySet().iterator();
- while (it.hasNext()) {
- FontTriplet triplet = (FontTriplet)it.next();
+ private List<FontTriplet> getTripletsForName(String fontName) {
+ List<FontTriplet> matchedTriplets = new ArrayList<FontTriplet>();
+ for (FontTriplet triplet : triplets.keySet()) {
String tripletName = triplet.getName();
if (tripletName.toLowerCase().equals(fontName.toLowerCase())) {
matchedTriplets.add(triplet);
@@ -351,11 +352,9 @@ public class FontInfo {
int awtFontWeight = awtFont.isBold() ? Font.WEIGHT_BOLD : Font.WEIGHT_NORMAL;
FontTriplet matchedTriplet = null;
- List/*<FontTriplet>*/ triplets = getTripletsForName(awtFontName);
+ List<FontTriplet> triplets = getTripletsForName(awtFontName);
if (!triplets.isEmpty()) {
- Iterator it = triplets.iterator();
- while (it.hasNext()) {
- FontTriplet triplet = (FontTriplet)it.next();
+ for (FontTriplet triplet : triplets) {
boolean styleMatched = triplet.getStyle().equals(awtFontStyle);
boolean weightMatched = triplet.getWeight() == awtFontWeight;
if (styleMatched && weightMatched) {
@@ -393,9 +392,9 @@ public class FontInfo {
return fontLookup(family, style, weight, true);
}
- private List/*<FontTriplet>*/ fontLookup(String[] families, String style,
+ private List<FontTriplet> fontLookup(String[] families, String style,
int weight, boolean substitutable) {
- List/*<FontTriplet>*/ matchingTriplets = new java.util.ArrayList/*<FontTriplet>*/();
+ List<FontTriplet> matchingTriplets = new ArrayList<FontTriplet>();
FontTriplet triplet = null;
for (int i = 0; i < families.length; i++) {
triplet = fontLookup(families[i], style, weight, substitutable);
@@ -426,7 +425,7 @@ public class FontInfo {
}
// try matching without substitutions
- List/*<FontTriplet>*/ matchedTriplets = fontLookup(families, style, weight, false);
+ List<FontTriplet> matchedTriplets = fontLookup(families, style, weight, false);
// if there are no matching font triplets found try with substitutions
if (matchedTriplets.size() == 0) {
@@ -454,9 +453,9 @@ public class FontInfo {
return fontTriplets;
}
- private Set/*<FontTriplet>*/ getLoggedFontKeys() {
+ private Set<FontTriplet> getLoggedFontKeys() {
if (loggedFontKeys == null) {
- loggedFontKeys = new java.util.HashSet/*<FontTriplet>*/();
+ loggedFontKeys = new HashSet<FontTriplet>();
}
return loggedFontKeys;
}
@@ -544,7 +543,7 @@ public class FontInfo {
* @return the associated internal key or null, if not found
*/
public String getInternalFontKey(FontTriplet triplet) {
- return (String)triplets.get(triplet);
+ return triplets.get(triplet);
}
/**
@@ -563,15 +562,15 @@ public class FontInfo {
* Gets a Map of all registered fonts.
* @return a read-only Map with font key/FontMetrics pairs
*/
- public Map/*<String,FontMetrics>*/ getFonts() {
- return java.util.Collections.unmodifiableMap(this.fonts);
+ public Map<String, Typeface> getFonts() {
+ return Collections.unmodifiableMap(this.fonts);
}
/**
* Gets a Map of all registered font triplets.
* @return a Map with FontTriplet/font key pairs
*/
- public Map/*<FontTriplet,String>*/ getFontTriplets() {
+ public Map<FontTriplet, String> getFontTriplets() {
return this.triplets;
}
@@ -581,7 +580,7 @@ public class FontInfo {
* This is for embedded font or creating a list of used fonts.
* @return a read-only Map with font key/FontMetrics pairs
*/
- public Map/*<String,FontMetrics>*/ getUsedFonts() {
+ public Map<String, Typeface> getUsedFonts() {
return this.usedFonts;
}
@@ -591,7 +590,7 @@ public class FontInfo {
* @return font metrics
*/
public FontMetrics getMetricsFor(String fontName) {
- FontMetrics metrics = (FontMetrics)fonts.get(fontName);
+ Typeface metrics = fonts.get(fontName);
usedFonts.put(fontName, metrics);
return metrics;
}
@@ -601,10 +600,9 @@ public class FontInfo {
* @param fontName The font name we are looking for
* @return A list of matching font triplets
*/
- public List/*<FontTriplet>*/ getTripletsFor(String fontName) {
- List/*<FontTriplet>*/ foundTriplets = new java.util.ArrayList();
- for (Iterator iter = triplets.entrySet().iterator(); iter.hasNext();) {
- Map.Entry tripletEntry = (Map.Entry) iter.next();
+ public List<FontTriplet> getTripletsFor(String fontName) {
+ List<FontTriplet> foundTriplets = new ArrayList<FontTriplet> ();
+ for (Map.Entry<FontTriplet, String> tripletEntry : triplets.entrySet()) {
if (fontName.equals((tripletEntry.getValue()))) {
foundTriplets.add(tripletEntry.getKey());
}
@@ -620,10 +618,10 @@ public class FontInfo {
* @return The first triplet for the given font name
*/
public FontTriplet getTripletFor(String fontName) {
- List/*<FontTriplet>*/ foundTriplets = getTripletsFor(fontName);
+ List<FontTriplet> foundTriplets = getTripletsFor(fontName);
if (foundTriplets.size() > 0) {
Collections.sort(foundTriplets);
- return (FontTriplet)foundTriplets.get(0);
+ return foundTriplets.get(0);
}
return null;
}
@@ -672,18 +670,17 @@ public class FontInfo {
/**
* {@inheritDoc}
*/
+ @Override
public String toString() {
- Collection entries = new java.util.TreeSet();
- Iterator iter = this.triplets.keySet().iterator();
- while (iter.hasNext()) {
- FontTriplet triplet = (FontTriplet)iter.next();
+ SortedSet<String> entries = new TreeSet<String>();
+ for (FontTriplet triplet : this.triplets.keySet()) {
String key = getInternalFontKey(triplet);
FontMetrics metrics = getMetricsFor(key);
entries.add(triplet.toString() + " -> " + key + " -> " + metrics.getFontName() + "\n");
}
StringBuffer stringBuffer = new StringBuffer();
- for (iter = entries.iterator(); iter.hasNext();) {
- stringBuffer.append(iter.next());
+ for (String str : entries) {
+ stringBuffer.append(str);
}
return stringBuffer.toString();
}
diff --git a/src/java/org/apache/fop/fonts/FontInfoConfigurator.java b/src/java/org/apache/fop/fonts/FontInfoConfigurator.java
index e0d52ad43..67bb2e295 100644
--- a/src/java/org/apache/fop/fonts/FontInfoConfigurator.java
+++ b/src/java/org/apache/fop/fonts/FontInfoConfigurator.java
@@ -33,7 +33,6 @@ import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.apache.fop.apps.FOPException;
import org.apache.fop.fonts.autodetect.FontFileFinder;
import org.apache.fop.fonts.autodetect.FontInfoFinder;
@@ -44,13 +43,13 @@ import org.apache.fop.util.LogUtil;
*/
public class FontInfoConfigurator {
/** logger instance */
- protected static Log log = LogFactory.getLog(FontInfoConfigurator.class);
+ protected static final Log log = LogFactory.getLog(FontInfoConfigurator.class);
- private Configuration cfg;
- private FontManager fontManager;
- private FontResolver fontResolver;
- private FontEventListener listener;
- private boolean strict;
+ private final Configuration cfg;
+ private final FontManager fontManager;
+ private final FontResolver fontResolver;
+ private final FontEventListener listener;
+ private final boolean strict;
/**
* Main constructor
@@ -74,9 +73,10 @@ public class FontInfoConfigurator {
* @param fontInfoList a font info list
* @throws FOPException if an exception occurs while processing the configuration
*/
- public void configure(List/*<EmbedFontInfo>*/ fontInfoList) throws FOPException {
- Configuration fonts = cfg.getChild("fonts", false);
- if (fonts != null) {
+ public void configure(List<EmbedFontInfo> fontInfoList)
+ throws FOPException {
+ Configuration fontsCfg = cfg.getChild("fonts", false);
+ if (fontsCfg != null) {
long start = 0;
if (log.isDebugEnabled()) {
log.debug("Starting font configuration...");
@@ -86,24 +86,23 @@ public class FontInfoConfigurator {
FontAdder fontAdder = new FontAdder(fontManager, fontResolver, listener);
// native o/s search (autodetect) configuration
- boolean autodetectFonts = (fonts.getChild("auto-detect", false) != null);
+ boolean autodetectFonts = (fontsCfg.getChild("auto-detect", false) != null);
if (autodetectFonts) {
FontDetector fontDetector = new FontDetector(fontManager, fontAdder, strict);
fontDetector.detect(fontInfoList);
}
- // Add configured directories to FontInfo
- addDirectories(fonts, fontAdder, fontInfoList);
+ // Add configured directories to FontInfo list
+ addDirectories(fontsCfg, fontAdder, fontInfoList);
- // Add configured fonts to FontInfo
- FontCache fontCache = fontManager.getFontCache();
- addFonts(fonts, fontCache, fontInfoList);
+ // Add fonts from configuration to FontInfo list
+ addFonts(fontsCfg, fontManager.getFontCache(), fontInfoList);
// Update referenced fonts (fonts which are not to be embedded)
fontManager.updateReferencedFonts(fontInfoList);
// Renderer-specific referenced fonts
- Configuration referencedFontsCfg = fonts.getChild("referenced-fonts", false);
+ Configuration referencedFontsCfg = fontsCfg.getChild("referenced-fonts", false);
if (referencedFontsCfg != null) {
FontTriplet.Matcher matcher = FontManagerConfigurator.createFontsMatcher(
referencedFontsCfg, strict);
@@ -111,9 +110,7 @@ public class FontInfoConfigurator {
}
// Update font cache if it has changed
- if (fontCache != null && fontCache.hasChanged()) {
- fontCache.save();
- }
+ fontManager.saveCache();
if (log.isDebugEnabled()) {
log.debug("Finished font configuration in "
@@ -123,7 +120,7 @@ public class FontInfoConfigurator {
}
private void addDirectories(Configuration fontsCfg,
- FontAdder fontAdder, List/*<URL>*/ fontInfoList) throws FOPException {
+ FontAdder fontAdder, List<EmbedFontInfo> fontInfoList) throws FOPException {
// directory (multiple font) configuration
Configuration[] directories = fontsCfg.getChildren("directory");
for (int i = 0; i < directories.length; i++) {
@@ -143,7 +140,7 @@ public class FontInfoConfigurator {
// add fonts found in directory
FontFileFinder fontFileFinder = new FontFileFinder(recursive ? -1 : 1);
- List/*<URL>*/ fontURLList;
+ List<URL> fontURLList;
try {
fontURLList = fontFileFinder.find(directory);
fontAdder.add(fontURLList, fontInfoList);
@@ -161,7 +158,7 @@ public class FontInfoConfigurator {
* @throws FOPException if an exception occurs while processing the configuration
*/
protected void addFonts(Configuration fontsCfg, FontCache fontCache,
- List/*<EmbedFontInfo>*/ fontInfoList) throws FOPException {
+ List<EmbedFontInfo> fontInfoList) throws FOPException {
// font file (singular) configuration
Configuration[] font = fontsCfg.getChildren("font");
for (int i = 0; i < font.length; i++) {
@@ -189,9 +186,8 @@ public class FontInfoConfigurator {
* @return the embedded font info
* @throws FOPException if something's wrong with the config data
*/
- protected EmbedFontInfo getFontInfo(
- Configuration fontCfg, FontCache fontCache)
- throws FOPException {
+ protected EmbedFontInfo getFontInfo(Configuration fontCfg, FontCache fontCache)
+ throws FOPException {
String metricsUrl = fontCfg.getAttribute("metrics-url", null);
String embedUrl = fontCfg.getAttribute("embed-url", null);
String subFont = fontCfg.getAttribute("sub-font", null);
@@ -232,32 +228,30 @@ public class FontInfoConfigurator {
LogUtil.handleError(log, "font without font-triplet", strict);
File fontFile = FontCache.getFileFromUrls(new String[] {embedUrl, metricsUrl});
- URL fontUrl;
+ URL fontURL = null;
try {
- fontUrl = fontFile.toURI().toURL();
+ fontURL = fontFile.toURI().toURL();
} catch (MalformedURLException e) {
- // Should never happen
- log.debug("Malformed Url: " + e.getMessage());
- return null;
+ LogUtil.handleException(log, e, strict);
}
if (fontFile != null) {
FontInfoFinder finder = new FontInfoFinder();
finder.setEventListener(listener);
- EmbedFontInfo[] infos = finder.find(fontUrl, fontResolver, fontCache);
+ EmbedFontInfo[] infos = finder.find(fontURL, fontResolver, fontCache);
return infos[0]; //When subFont is set, only one font is returned
} else {
return null;
}
}
- List/*<FontTriplet>*/ tripletList = new java.util.ArrayList/*<FontTriplet>*/();
+ List<FontTriplet> tripletList = new java.util.ArrayList<FontTriplet>();
for (int j = 0; j < tripletCfg.length; j++) {
FontTriplet fontTriplet = getFontTriplet(tripletCfg[j]);
tripletList.add(fontTriplet);
}
boolean useKerning = fontCfg.getAttributeAsBoolean("kerning", true);
- EncodingMode encodingMode = EncodingMode.valueOf(
+ EncodingMode encodingMode = EncodingMode.getEncodingMode(
fontCfg.getAttribute("encoding-mode", EncodingMode.AUTO.getName()));
EmbedFontInfo embedFontInfo
= new EmbedFontInfo(metricsUrl, useKerning, tripletList, embedUrl, subFont);
@@ -273,7 +267,7 @@ public class FontInfoConfigurator {
log.debug("Adding font " + (embedFile != null ? embedFile + ", " : "")
+ "metric file " + embedFontInfo.getMetricsFile());
for (int j = 0; j < tripletList.size(); ++j) {
- FontTriplet triplet = (FontTriplet) tripletList.get(j);
+ FontTriplet triplet = tripletList.get(j);
log.debug(" Font triplet "
+ triplet.getName() + ", "
+ triplet.getStyle() + ", "
diff --git a/src/java/org/apache/fop/fonts/FontLoader.java b/src/java/org/apache/fop/fonts/FontLoader.java
index 93d4ae03f..02c09a1a1 100644
--- a/src/java/org/apache/fop/fonts/FontLoader.java
+++ b/src/java/org/apache/fop/fonts/FontLoader.java
@@ -40,7 +40,7 @@ import org.apache.fop.fonts.type1.Type1FontLoader;
public abstract class FontLoader {
/** logging instance */
- protected static Log log = LogFactory.getLog(FontLoader.class);
+ protected static final Log log = LogFactory.getLog(FontLoader.class);
/** URI representing the font file */
protected String fontFileURI = null;
diff --git a/src/java/org/apache/fop/fonts/FontManager.java b/src/java/org/apache/fop/fonts/FontManager.java
index cfce0fd69..51516e231 100644
--- a/src/java/org/apache/fop/fonts/FontManager.java
+++ b/src/java/org/apache/fop/fonts/FontManager.java
@@ -19,19 +19,19 @@
package org.apache.fop.fonts;
+import java.io.File;
import java.net.MalformedURLException;
-import java.util.Iterator;
import java.util.List;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
+import org.apache.fop.apps.FOPException;
import org.apache.fop.fonts.FontTriplet.Matcher;
import org.apache.fop.fonts.substitute.FontSubstitutions;
// TODO: Refactor fonts package so major font activities (autodetection etc)
-// are all centrally managed and delegated from this class, also remove dependency on FopFactory
-// and start using POJO config/properties type classes
+// are all centrally managed and delegated from this class
/**
* The manager of fonts. The class holds a reference to the font cache and information about
@@ -56,11 +56,16 @@ public class FontManager {
/** FontTriplet matcher for fonts that shall be referenced rather than embedded. */
private FontTriplet.Matcher referencedFontsMatcher;
+ /** Enables/disables the use of font caching */
+ private boolean useCache = DEFAULT_USE_CACHE;
+
+ /** Provides a font cache file path **/
+ private File cacheFile;
+
/**
* Main constructor
*/
public FontManager() {
- setUseCache(DEFAULT_USE_CACHE);
}
/**
@@ -113,16 +118,31 @@ public class FontManager {
}
/**
+ * Sets the font cache file
+ * @param cacheFile the font cache file
+ */
+ public void setCacheFile(File cacheFile) {
+ this.cacheFile = cacheFile;
+ }
+
+ /**
+ * Returns the font cache file
+ * @return the font cache file
+ */
+ public File getCacheFile() {
+ if (cacheFile != null) {
+ return this.cacheFile;
+ }
+ return FontCache.getDefaultCacheFile(false);
+ }
+
+ /**
* Whether or not to cache results of font triplet detection/auto-config
* @param useCache use cache or not
*/
public void setUseCache(boolean useCache) {
- if (useCache) {
- this.fontCache = FontCache.load();
- if (this.fontCache == null) {
- this.fontCache = new FontCache();
- }
- } else {
+ this.useCache = useCache;
+ if (!useCache) {
this.fontCache = null;
}
}
@@ -132,7 +152,7 @@ public class FontManager {
* @return true if this font manager uses the cache
*/
public boolean useCache() {
- return (this.fontCache != null);
+ return useCache;
}
/**
@@ -140,7 +160,52 @@ public class FontManager {
* @return the font cache
*/
public FontCache getFontCache() {
- return this.fontCache;
+ if (fontCache == null) {
+ if (useCache) {
+ if (cacheFile != null) {
+ fontCache = FontCache.loadFrom(cacheFile);
+ } else {
+ fontCache = FontCache.load();
+ }
+ if (fontCache == null) {
+ fontCache = new FontCache();
+ }
+ }
+ }
+ return fontCache;
+ }
+
+ /**
+ * Saves the FontCache as necessary
+ *
+ * @throws FOPException fop exception
+ */
+ public void saveCache() throws FOPException {
+ if (useCache) {
+ if (fontCache != null && fontCache.hasChanged()) {
+ if (cacheFile != null) {
+ fontCache.saveTo(cacheFile);
+ } else {
+ fontCache.save();
+ }
+ }
+ }
+ }
+
+ /**
+ * Deletes the current FontCache file
+ * @return Returns true if the font cache file was successfully deleted.
+ */
+ public boolean deleteCache() {
+ boolean deleted = false;
+ if (useCache) {
+ if (cacheFile != null) {
+ deleted = cacheFile.delete();
+ } else {
+ deleted = FontCache.getDefaultCacheFile(true).delete();
+ }
+ }
+ return deleted;
}
/**
@@ -194,7 +259,7 @@ public class FontManager {
* ({@link #getReferencedFontsMatcher()}).
* @param fontInfoList a font info list
*/
- public void updateReferencedFonts(List fontInfoList) {
+ public void updateReferencedFonts(List<EmbedFontInfo> fontInfoList) {
Matcher matcher = getReferencedFontsMatcher();
updateReferencedFonts(fontInfoList, matcher);
}
@@ -204,16 +269,12 @@ public class FontManager {
* @param fontInfoList a font info list
* @param matcher the font triplet matcher to use
*/
- public void updateReferencedFonts(List fontInfoList, Matcher matcher) {
+ public void updateReferencedFonts(List<EmbedFontInfo> fontInfoList, Matcher matcher) {
if (matcher == null) {
return; //No referenced fonts
}
- Iterator iter = fontInfoList.iterator();
- while (iter.hasNext()) {
- EmbedFontInfo fontInfo = (EmbedFontInfo)iter.next();
- Iterator triplets = fontInfo.getFontTriplets().iterator();
- while (triplets.hasNext()) {
- FontTriplet triplet = (FontTriplet)triplets.next();
+ for (EmbedFontInfo fontInfo : fontInfoList) {
+ for (FontTriplet triplet : fontInfo.getFontTriplets()) {
if (matcher.matches(triplet)) {
fontInfo.setEmbedded(false);
break;
diff --git a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java b/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
index 68dd869f5..6935df7e3 100644
--- a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
+++ b/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
@@ -19,7 +19,9 @@
package org.apache.fop.fonts;
+import java.io.File;
import java.net.MalformedURLException;
+import java.net.URI;
import java.util.List;
import java.util.regex.Pattern;
@@ -27,7 +29,6 @@ import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.apache.fop.apps.FOPException;
import org.apache.fop.fonts.substitute.FontSubstitutions;
import org.apache.fop.fonts.substitute.FontSubstitutionsConfigurator;
@@ -41,7 +42,9 @@ public class FontManagerConfigurator {
/** logger instance */
private static Log log = LogFactory.getLog(FontManagerConfigurator.class);
- private Configuration cfg;
+ private final Configuration cfg;
+
+ private URI baseURI = null;
/**
* Main constructor
@@ -52,26 +55,44 @@ public class FontManagerConfigurator {
}
/**
+ * Main constructor
+ * @param cfg the font manager configuration object
+ * @param baseURI the base URI of the configuration
+ */
+ public FontManagerConfigurator(Configuration cfg, URI baseURI) {
+ this.cfg = cfg;
+ this.baseURI = baseURI;
+ }
+
+ /**
* Initializes font settings from the user configuration
* @param fontManager a font manager
* @param strict true if strict checking of the configuration is enabled
* @throws FOPException if an exception occurs while processing the configuration
*/
public void configure(FontManager fontManager, boolean strict) throws FOPException {
-
// caching (fonts)
if (cfg.getChild("use-cache", false) != null) {
try {
- fontManager.setUseCache(
- cfg.getChild("use-cache").getValueAsBoolean());
- } catch (ConfigurationException mfue) {
- LogUtil.handleException(log, mfue, true);
+ fontManager.setUseCache(cfg.getChild("use-cache").getValueAsBoolean());
+ } catch (ConfigurationException e) {
+ LogUtil.handleException(log, e, true);
+ }
+ }
+ if (cfg.getChild("cache-file", false) != null) {
+ try {
+ fontManager.setCacheFile(new File(cfg.getChild("cache-file").getValue()));
+ } catch (ConfigurationException e) {
+ LogUtil.handleException(log, e, true);
}
}
if (cfg.getChild("font-base", false) != null) {
+ String path = cfg.getChild("font-base").getValue(null);
+ if (baseURI != null) {
+ path = baseURI.resolve(path).normalize().toString();
+ }
try {
- fontManager.setFontBaseURL(
- cfg.getChild("font-base").getValue(null));
+ fontManager.setFontBaseURL(path);
} catch (MalformedURLException mfue) {
LogUtil.handleException(log, mfue, true);
}
@@ -80,13 +101,12 @@ public class FontManagerConfigurator {
// global font configuration
Configuration fontsCfg = cfg.getChild("fonts", false);
if (fontsCfg != null) {
+
// font substitution
Configuration substitutionsCfg = fontsCfg.getChild("substitutions", false);
if (substitutionsCfg != null) {
- FontSubstitutionsConfigurator fontSubstitutionsConfigurator
- = new FontSubstitutionsConfigurator(substitutionsCfg);
FontSubstitutions substitutions = new FontSubstitutions();
- fontSubstitutionsConfigurator.configure(substitutions);
+ new FontSubstitutionsConfigurator(substitutionsCfg).configure(substitutions);
fontManager.setFontSubstitutions(substitutions);
}
@@ -110,7 +130,7 @@ public class FontManagerConfigurator {
*/
public static FontTriplet.Matcher createFontsMatcher(
Configuration cfg, boolean strict) throws FOPException {
- List matcherList = new java.util.ArrayList();
+ List<FontTriplet.Matcher> matcherList = new java.util.ArrayList<FontTriplet.Matcher>();
Configuration[] matches = cfg.getChildren("match");
for (int i = 0; i < matches.length; i++) {
try {
@@ -122,14 +142,13 @@ public class FontManagerConfigurator {
}
}
FontTriplet.Matcher orMatcher = new OrFontTripletMatcher(
- (FontTriplet.Matcher[])matcherList.toArray(
- new FontTriplet.Matcher[matcherList.size()]));
+ matcherList.toArray(new FontTriplet.Matcher[matcherList.size()]));
return orMatcher;
}
private static class OrFontTripletMatcher implements FontTriplet.Matcher {
- private FontTriplet.Matcher[] matchers;
+ private final FontTriplet.Matcher[] matchers;
public OrFontTripletMatcher(FontTriplet.Matcher[] matchers) {
this.matchers = matchers;
@@ -149,7 +168,7 @@ public class FontManagerConfigurator {
private static class FontFamilyRegExFontTripletMatcher implements FontTriplet.Matcher {
- private Pattern regex;
+ private final Pattern regex;
public FontFamilyRegExFontTripletMatcher(String regex) {
this.regex = Pattern.compile(regex);
diff --git a/src/java/org/apache/fop/fonts/FontMetrics.java b/src/java/org/apache/fop/fonts/FontMetrics.java
index 29ade1ef3..ff32d7305 100644
--- a/src/java/org/apache/fop/fonts/FontMetrics.java
+++ b/src/java/org/apache/fop/fonts/FontMetrics.java
@@ -45,7 +45,7 @@ public interface FontMetrics {
* Returns the font's family names as a Set of Strings (Example: "Helvetica").
* @return the font's family names (a Set of Strings)
*/
- Set getFamilyNames();
+ Set<String> getFamilyNames();
/**
* Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").
@@ -129,6 +129,6 @@ public interface FontMetrics {
* Returns the kerning map for the font.
* @return the kerning map
*/
- Map getKerningInfo();
+ Map<Integer, Map<Integer, Integer>> getKerningInfo();
}
diff --git a/src/java/org/apache/fop/fonts/FontReader.java b/src/java/org/apache/fop/fonts/FontReader.java
index 16da99baa..e9b88ec16 100644
--- a/src/java/org/apache/fop/fonts/FontReader.java
+++ b/src/java/org/apache/fop/fonts/FontReader.java
@@ -21,6 +21,9 @@ package org.apache.fop.fonts;
//Java
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -56,12 +59,12 @@ public class FontReader extends DefaultHandler {
private SingleByteFont singleFont = null;
private StringBuffer text = new StringBuffer();
- private List cidWidths = null;
+ private List<Integer> cidWidths = null;
private int cidWidthIndex = 0;
- private Map currentKerning = null;
+ private Map<Integer, Integer> currentKerning = null;
- private List bfranges = null;
+ private List<BFEntry> bfranges = null;
private void createFont(InputSource source) throws FOPException {
XMLReader parser = null;
@@ -181,13 +184,13 @@ public class FontReader extends DefaultHandler {
returnFont.setEmbedResourceName(attributes.getValue("class"));
} else if ("cid-widths".equals(localName)) {
cidWidthIndex = getInt(attributes.getValue("start-index"));
- cidWidths = new java.util.ArrayList();
+ cidWidths = new ArrayList<Integer>();
} else if ("kerning".equals(localName)) {
- currentKerning = new java.util.HashMap();
+ currentKerning = new HashMap<Integer, Integer>();
returnFont.putKerningEntry(new Integer(attributes.getValue("kpx1")),
currentKerning);
} else if ("bfranges".equals(localName)) {
- bfranges = new java.util.ArrayList();
+ bfranges = new ArrayList<BFEntry>();
} else if ("bf".equals(localName)) {
BFEntry entry = new BFEntry(getInt(attributes.getValue("us")),
getInt(attributes.getValue("ue")),
@@ -231,7 +234,7 @@ public class FontReader extends DefaultHandler {
} else if ("full-name".equals(localName)) {
returnFont.setFullName(content);
} else if ("family-name".equals(localName)) {
- Set s = new java.util.HashSet();
+ Set<String> s = new HashSet<String>();
s.add(content);
returnFont.setFamilyNames(s);
} else if ("ttc-name".equals(localName) && isCID) {
@@ -284,15 +287,14 @@ public class FontReader extends DefaultHandler {
int[] wds = new int[cidWidths.size()];
int j = 0;
for (int count = 0; count < cidWidths.size(); count++) {
- Integer i = (Integer)cidWidths.get(count);
- wds[j++] = i.intValue();
+ wds[j++] = cidWidths.get(count).intValue();
}
//multiFont.addCIDWidthEntry(cidWidthIndex, wds);
multiFont.setWidthArray(wds);
} else if ("bfranges".equals(localName)) {
- multiFont.setBFEntries((BFEntry[])bfranges.toArray(new BFEntry[0]));
+ multiFont.setBFEntries(bfranges.toArray(new BFEntry[0]));
}
text.setLength(0); //Reset text buffer (see characters())
}
diff --git a/src/java/org/apache/fop/fonts/FontSetup.java b/src/java/org/apache/fop/fonts/FontSetup.java
index f7ad6fc65..935f695b1 100644
--- a/src/java/org/apache/fop/fonts/FontSetup.java
+++ b/src/java/org/apache/fop/fonts/FontSetup.java
@@ -25,8 +25,6 @@ import java.util.List;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.fop.fonts.base14.Courier;
import org.apache.fop.fonts.base14.CourierBold;
import org.apache.fop.fonts.base14.CourierBoldOblique;
@@ -51,12 +49,10 @@ import org.apache.fop.fonts.base14.ZapfDingbats;
* Assigns the font (with metrics) to internal names like "F1" and
* assigns family-style-weight triplets to the fonts
*/
-public class FontSetup {
+public final class FontSetup {
- /**
- * logging instance
- */
- protected static Log log = LogFactory.getLog(FontSetup.class);
+ private FontSetup() {
+ }
/**
* Sets up a font info
@@ -76,7 +72,8 @@ public class FontSetup {
* @param embedFontInfoList a list of EmbedFontInfo objects
* @param resolver the font resolver
*/
- public static void setup(FontInfo fontInfo, List embedFontInfoList, FontResolver resolver) {
+ public static void setup(FontInfo fontInfo, List<EmbedFontInfo> embedFontInfoList,
+ FontResolver resolver) {
final boolean base14Kerning = false;
fontInfo.addMetrics("F1", new Helvetica(base14Kerning));
fontInfo.addMetrics("F2", new HelveticaOblique(base14Kerning));
@@ -194,7 +191,7 @@ public class FontSetup {
* @param resolver the font resolver
*/
private static void addConfiguredFonts(FontInfo fontInfo,
- List/*<EmbedFontInfo>*/ embedFontInfoList, int num, FontResolver resolver) {
+ List<EmbedFontInfo> embedFontInfoList, int num, FontResolver resolver) {
if (embedFontInfoList == null) {
return; //No fonts to process
}
@@ -206,18 +203,16 @@ public class FontSetup {
String internalName = null;
- for (int i = 0; i < embedFontInfoList.size(); i++) {
- EmbedFontInfo embedFontInfo = (EmbedFontInfo)embedFontInfoList.get(i);
-
+ for (EmbedFontInfo embedFontInfo : embedFontInfoList) {
internalName = "F" + num;
num++;
LazyFont font = new LazyFont(embedFontInfo, resolver);
fontInfo.addMetrics(internalName, font);
- List triplets = embedFontInfo.getFontTriplets();
+ List<FontTriplet> triplets = embedFontInfo.getFontTriplets();
for (int tripletIndex = 0; tripletIndex < triplets.size(); tripletIndex++) {
- FontTriplet triplet = (FontTriplet) triplets.get(tripletIndex);
+ FontTriplet triplet = triplets.get(tripletIndex);
fontInfo.addFontProperties(internalName, triplet);
}
}
diff --git a/src/java/org/apache/fop/fonts/FontTriplet.java b/src/java/org/apache/fop/fonts/FontTriplet.java
index f5cfe442a..c14634460 100644
--- a/src/java/org/apache/fop/fonts/FontTriplet.java
+++ b/src/java/org/apache/fop/fonts/FontTriplet.java
@@ -25,7 +25,7 @@ import java.io.Serializable;
/**
* FontTriplet contains information on name, style and weight of one font
*/
-public class FontTriplet implements Comparable, Serializable {
+public class FontTriplet implements Comparable<FontTriplet>, Serializable {
/** serial version UID */
private static final long serialVersionUID = 1168991106658033508L;
@@ -99,8 +99,8 @@ public class FontTriplet implements Comparable, Serializable {
}
/** {@inheritDoc} */
- public int compareTo(Object o) {
- return getKey().compareTo(((FontTriplet)o).getKey());
+ public int compareTo(FontTriplet o) {
+ return getKey().compareTo(o.getKey());
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/fonts/FontType.java b/src/java/org/apache/fop/fonts/FontType.java
index 95b594ca4..56039b519 100644
--- a/src/java/org/apache/fop/fonts/FontType.java
+++ b/src/java/org/apache/fop/fonts/FontType.java
@@ -54,6 +54,9 @@ public class FontType {
/**
+ * Construct a font type.
+ * @param name a font type name
+ * @param value a font type value
* @see org.apache.avalon.framework.Enum#Enum(String)
*/
protected FontType(String name, int value) {
diff --git a/src/java/org/apache/fop/fonts/FontUtil.java b/src/java/org/apache/fop/fonts/FontUtil.java
index 49f23c12f..b97e3a407 100644
--- a/src/java/org/apache/fop/fonts/FontUtil.java
+++ b/src/java/org/apache/fop/fonts/FontUtil.java
@@ -23,7 +23,10 @@ package org.apache.fop.fonts;
/**
* Font utilities.
*/
-public class FontUtil {
+public final class FontUtil {
+
+ private FontUtil() {
+ }
/**
* Parses an CSS2 (SVG and XSL-FO) font weight (normal, bold, 100-900) to
diff --git a/src/java/org/apache/fop/fonts/Glyphs.java b/src/java/org/apache/fop/fonts/Glyphs.java
index 4da95d575..dfc44675b 100644
--- a/src/java/org/apache/fop/fonts/Glyphs.java
+++ b/src/java/org/apache/fop/fonts/Glyphs.java
@@ -23,7 +23,10 @@ package org.apache.fop.fonts;
* This class provides a number of constants for glyph management.
* @deprecated Use the Glyphs class from XML Graphics Commons instead!
*/
-public class Glyphs {
+public final class Glyphs {
+
+ private Glyphs() {
+ }
/**
* Glyph name for the "notdef" glyph
@@ -33,7 +36,7 @@ public class Glyphs {
/**
* Glyph names for Mac encoding
*/
- public static final String MAC_GLYPH_NAMES[] = {
+ public static final String[] MAC_GLYPH_NAMES = {
/* 0x00 */
NOTDEF, ".null", "CR", "space", "exclam", "quotedbl", "numbersign",
"dollar", "percent", "ampersand", "quotesingle", "parenleft",
@@ -1273,7 +1276,7 @@ public class Glyphs {
* @param ch glyph to evaluate
* @return the name of the glyph
*/
- public static final String charToGlyphName(char ch) {
+ public static String charToGlyphName(char ch) {
return stringToGlyph(new Character(ch).toString());
}
@@ -1286,7 +1289,7 @@ public class Glyphs {
* TODO: javadocs for glyphToString and stringToGlyph are confused
* TODO: Improve method names
*/
- public static final String glyphToString(String name) {
+ public static String glyphToString(String name) {
for (int i = 0; i < UNICODE_GLYPHS.length; i += 2) {
if (UNICODE_GLYPHS[i + 1].equals(name)) {
return UNICODE_GLYPHS[i];
diff --git a/src/java/org/apache/fop/fonts/LazyFont.java b/src/java/org/apache/fop/fonts/LazyFont.java
index e5d111d38..a8fd447c4 100644
--- a/src/java/org/apache/fop/fonts/LazyFont.java
+++ b/src/java/org/apache/fop/fonts/LazyFont.java
@@ -221,7 +221,7 @@ public class LazyFont extends Typeface implements FontDescriptor {
}
/** {@inheritDoc} */
- public Set getFamilyNames() {
+ public Set<String> getFamilyNames() {
load(true);
return realFont.getFamilyNames();
}
@@ -293,7 +293,7 @@ public class LazyFont extends Typeface implements FontDescriptor {
/**
* {@inheritDoc}
*/
- public Map getKerningInfo() {
+ public Map<Integer, Map<Integer, Integer>> getKerningInfo() {
load(true);
return realFont.getKerningInfo();
}
diff --git a/src/java/org/apache/fop/fonts/MultiByteFont.java b/src/java/org/apache/fop/fonts/MultiByteFont.java
index 1e6bd4f84..afac21c1b 100644
--- a/src/java/org/apache/fop/fonts/MultiByteFont.java
+++ b/src/java/org/apache/fop/fonts/MultiByteFont.java
@@ -237,11 +237,11 @@ public class MultiByteFont extends CIDFont {
* Returns a Map of used Glyphs.
* @return Map Map of used Glyphs
*/
- public Map getUsedGlyphs() {
+ public Map<Integer, Integer> getUsedGlyphs() {
return subset.getSubsetGlyphs();
}
- /** {@inheritDoc} */
+ /** @return an array of the chars used */
public char[] getCharsUsed() {
if (!isEmbeddable()) {
return null;
diff --git a/src/java/org/apache/fop/fonts/MutableFont.java b/src/java/org/apache/fop/fonts/MutableFont.java
index a5acf51b3..bcbcadbdc 100644
--- a/src/java/org/apache/fop/fonts/MutableFont.java
+++ b/src/java/org/apache/fop/fonts/MutableFont.java
@@ -46,7 +46,7 @@ public interface MutableFont {
* Sets the font's family names (Example: "Helvetica").
* @param names the font's family names (a Set of Strings)
*/
- void setFamilyNames(Set names);
+ void setFamilyNames(Set<String> names);
/**
* Sets the path to the embeddable font file.
@@ -137,6 +137,6 @@ public interface MutableFont {
* @param key Kerning key
* @param value Kerning value
*/
- void putKerningEntry(Integer key, Map value);
+ void putKerningEntry(Integer key, Map<Integer, Integer> value);
}
diff --git a/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java b/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java
index d55529d58..cec39bfb9 100644
--- a/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java
+++ b/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java
@@ -19,13 +19,14 @@
package org.apache.fop.fonts;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.xmlgraphics.fonts.Glyphs;
-
import org.apache.fop.util.CharUtilities;
+import org.apache.xmlgraphics.fonts.Glyphs;
/**
* A simple implementation of the OneByteEncoding mostly used for encodings that are constructed
@@ -33,11 +34,9 @@ import org.apache.fop.util.CharUtilities;
*/
public class SimpleSingleByteEncoding implements SingleByteEncoding {
- private String name;
- private List mapping = new java.util.ArrayList();
- //List<NamedCharacter>
- private Map charMap = new java.util.HashMap();
- //Map<Character(Unicode), Character(code point)>
+ private final String name;
+ private final List<NamedCharacter> mapping = new ArrayList<NamedCharacter>();
+ private final Map<Character, Character> charMap = new HashMap<Character, Character>();
/**
* Main constructor.
@@ -54,7 +53,7 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding {
/** {@inheritDoc} */
public char mapChar(char c) {
- Character nc = (Character)charMap.get(new Character(c));
+ Character nc = charMap.get(new Character(c));
if (nc != null) {
return nc.charValue();
}
@@ -66,7 +65,7 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding {
String[] map = new String[getSize()];
Arrays.fill(map, Glyphs.NOTDEF);
for (int i = getFirstChar(); i <= getLastChar(); i++) {
- NamedCharacter ch = (NamedCharacter)this.mapping.get(i - 1);
+ NamedCharacter ch = this.mapping.get(i - 1);
map[i] = ch.getName();
}
return map;
@@ -133,7 +132,7 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding {
throw new IllegalArgumentException("codePoint must be between 0 and 255");
}
if (codePoint <= getLastChar()) {
- return (NamedCharacter)this.mapping.get(codePoint - 1);
+ return this.mapping.get(codePoint - 1);
} else {
return null;
}
@@ -152,6 +151,7 @@ public class SimpleSingleByteEncoding implements SingleByteEncoding {
}
/** {@inheritDoc} */
+ @Override
public String toString() {
return getName() + " (" + getSize() + " chars)";
}
diff --git a/src/java/org/apache/fop/fonts/SingleByteFont.java b/src/java/org/apache/fop/fonts/SingleByteFont.java
index fb4725bd4..d798db1bb 100644
--- a/src/java/org/apache/fop/fonts/SingleByteFont.java
+++ b/src/java/org/apache/fop/fonts/SingleByteFont.java
@@ -19,10 +19,12 @@
package org.apache.fop.fonts;
-import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.TreeSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -40,9 +42,8 @@ public class SingleByteFont extends CustomFont {
private int[] width = null;
- private Map unencodedCharacters;
- //Map<Character, UnencodedCharacter>
- private List additionalEncodings;
+ private Map<Character, UnencodedCharacter> unencodedCharacters;
+ private List<SimpleSingleByteEncoding> additionalEncodings;
/**
@@ -59,6 +60,7 @@ public class SingleByteFont extends CustomFont {
}
/** {@inheritDoc} */
+ @Override
public String getEncodingName() {
return this.mapping.getName();
}
@@ -84,8 +86,7 @@ public class SingleByteFont extends CustomFont {
int codePoint = i % 256;
NamedCharacter nc = encoding.getCharacterForIndex(codePoint);
UnencodedCharacter uc
- = (UnencodedCharacter)this.unencodedCharacters.get(
- new Character(nc.getSingleUnicodeValue()));
+ = this.unencodedCharacters.get(new Character(nc.getSingleUnicodeValue()));
return size * uc.getWidth();
}
return 0;
@@ -99,6 +100,7 @@ public class SingleByteFont extends CustomFont {
}
/** {@inheritDoc} */
+ @Override
public char mapChar(char c) {
notifyMapOperation();
char d = mapping.mapChar(c);
@@ -117,11 +119,10 @@ public class SingleByteFont extends CustomFont {
private char mapUnencodedChar(char ch) {
if (this.unencodedCharacters != null) {
- UnencodedCharacter unencoded
- = (UnencodedCharacter)this.unencodedCharacters.get(new Character(ch));
+ UnencodedCharacter unencoded = this.unencodedCharacters.get(new Character(ch));
if (unencoded != null) {
if (this.additionalEncodings == null) {
- this.additionalEncodings = new java.util.ArrayList();
+ this.additionalEncodings = new ArrayList<SimpleSingleByteEncoding>();
}
SimpleSingleByteEncoding encoding = null;
char mappedStart = 0;
@@ -150,6 +151,7 @@ public class SingleByteFont extends CustomFont {
}
/** {@inheritDoc} */
+ @Override
public boolean hasChar(char c) {
char d = mapping.mapChar(c);
if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) {
@@ -230,7 +232,7 @@ public class SingleByteFont extends CustomFont {
*/
public void addUnencodedCharacter(NamedCharacter ch, int width) {
if (this.unencodedCharacters == null) {
- this.unencodedCharacters = new java.util.HashMap();
+ this.unencodedCharacters = new HashMap<Character, UnencodedCharacter>();
}
if (ch.hasSingleUnicodeValue()) {
UnencodedCharacter uc = new UnencodedCharacter(ch, width);
@@ -248,10 +250,8 @@ public class SingleByteFont extends CustomFont {
*/
public void encodeAllUnencodedCharacters() {
if (this.unencodedCharacters != null) {
- Set sortedKeys = new java.util.TreeSet(this.unencodedCharacters.keySet());
- Iterator iter = sortedKeys.iterator();
- while (iter.hasNext()) {
- Character ch = (Character)iter.next();
+ Set<Character> sortedKeys = new TreeSet<Character>(this.unencodedCharacters.keySet());
+ for (Character ch : sortedKeys) {
char mapped = mapChar(ch.charValue());
assert mapped != Typeface.NOT_FOUND;
}
@@ -287,7 +287,7 @@ public class SingleByteFont extends CustomFont {
public SimpleSingleByteEncoding getAdditionalEncoding(int index)
throws IndexOutOfBoundsException {
if (hasAdditionalEncodings()) {
- return (SimpleSingleByteEncoding)this.additionalEncodings.get(index);
+ return this.additionalEncodings.get(index);
} else {
throw new IndexOutOfBoundsException("No additional encodings available");
}
@@ -303,7 +303,7 @@ public class SingleByteFont extends CustomFont {
int[] arr = new int[enc.getLastChar() - enc.getFirstChar() + 1];
for (int i = 0, c = arr.length; i < c; i++) {
NamedCharacter nc = enc.getCharacterForIndex(enc.getFirstChar() + i);
- UnencodedCharacter uc = (UnencodedCharacter)this.unencodedCharacters.get(
+ UnencodedCharacter uc = this.unencodedCharacters.get(
new Character(nc.getSingleUnicodeValue()));
arr[i] = uc.getWidth();
}
@@ -312,8 +312,8 @@ public class SingleByteFont extends CustomFont {
private static final class UnencodedCharacter {
- private NamedCharacter character;
- private int width;
+ private final NamedCharacter character;
+ private final int width;
public UnencodedCharacter(NamedCharacter character, int width) {
this.character = character;
@@ -329,6 +329,7 @@ public class SingleByteFont extends CustomFont {
}
/** {@inheritDoc} */
+ @Override
public String toString() {
return getCharacter().toString();
}
diff --git a/src/java/org/apache/fop/fonts/Typeface.java b/src/java/org/apache/fop/fonts/Typeface.java
index f4e317de3..a0c1d99ec 100644
--- a/src/java/org/apache/fop/fonts/Typeface.java
+++ b/src/java/org/apache/fop/fonts/Typeface.java
@@ -19,6 +19,7 @@
package org.apache.fop.fonts;
+import java.util.HashSet;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -49,7 +50,7 @@ public abstract class Typeface implements FontMetrics {
/** An optional event listener that receives events such as missing glyphs etc. */
protected FontEventListener eventListener;
- private Set warnedChars;
+ private Set<Character> warnedChars;
/**
* Get the encoding of the font.
@@ -120,7 +121,7 @@ public abstract class Typeface implements FontMetrics {
// Give up, character is not available
Character ch = new Character(c);
if (warnedChars == null) {
- warnedChars = new java.util.HashSet();
+ warnedChars = new HashSet<Character>();
}
if (warnedChars.size() < 8 && !warnedChars.contains(ch)) {
warnedChars.add(ch);
@@ -139,9 +140,9 @@ public abstract class Typeface implements FontMetrics {
}
}
}
-
+
/** {@inheritDoc} */
public String toString() {
return getFullName();
- }
+ }
}
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java b/src/java/org/apache/fop/fonts/autodetect/FontDirFinder.java
index 1d4c733a3..383c5283d 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java
+++ b/src/java/org/apache/fop/fonts/autodetect/FontDirFinder.java
@@ -17,20 +17,25 @@
/* $Id$ */
-package org.apache.fop.render.pdf;
+package org.apache.fop.fonts.autodetect;
-import org.apache.fop.render.AbstractImageHandlerRegistry;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
/**
- * This class holds references to various image handlers used by the PDF renderer. It also
- * supports automatic discovery of additional handlers available through
- * the class path.
+ * Implementers provide find method for searching native operating system
+ * for available fonts.
*/
-public class PDFImageHandlerRegistry extends AbstractImageHandlerRegistry {
+public interface FontDirFinder {
- /** {@inheritDoc} */
- public Class getHandlerClass() {
- return PDFImageHandler.class;
- }
+ /**
+ * Finds a list of font files.
+ *
+ * @return list of font files.
+ * @throws IOException
+ * In case of an I/O problem
+ */
+ List<File> find() throws IOException;
}
diff --git a/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java b/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java
index bd0f1ee14..9a0a73e2f 100644
--- a/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java
+++ b/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java
@@ -22,8 +22,8 @@ package org.apache.fop.fonts.autodetect;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
+import java.net.URL;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import org.apache.commons.io.DirectoryWalker;
@@ -91,6 +91,7 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder {
* @return whether directory should be handled
* {@inheritDoc}
*/
+ @Override
protected boolean handleDirectory(File directory, int depth, Collection results) {
return true;
}
@@ -101,6 +102,7 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder {
* @param results collection
* {@inheritDoc}
*/
+ @Override
protected void handleFile(File file, int depth, Collection results) {
try {
// Looks Strange, but is actually recommended over just .URL()
@@ -116,6 +118,7 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder {
* @param results the collection of results objects
* {@inheritDoc}
*/
+ @Override
protected void handleDirectoryEnd(File directory, int depth, Collection results) {
if (log.isDebugEnabled()) {
log.debug(directory + ": found " + results.size() + " font"
@@ -130,8 +133,8 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder {
* @throws IOException io exception
* {@inheritDoc}
*/
- public List/*<URL>*/ find() throws IOException {
- final FontFinder fontDirFinder;
+ public List<URL> find() throws IOException {
+ final FontDirFinder fontDirFinder;
final String osName = System.getProperty("os.name");
if (osName.startsWith("Windows")) {
fontDirFinder = new WindowsFontDirFinder();
@@ -142,10 +145,9 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder {
fontDirFinder = new UnixFontDirFinder();
}
}
- List/*<URL>*/ fontDirs = fontDirFinder.find();
- List/*<URL>*/ results = new java.util.ArrayList/*<URL>*/();
- for (Iterator iter = fontDirs.iterator(); iter.hasNext();) {
- final File dir = (File)iter.next();
+ List<File> fontDirs = fontDirFinder.find();
+ List<URL> results = new java.util.ArrayList<URL>();
+ for (File dir : fontDirs) {
super.walk(dir, results);
}
return results;
@@ -158,8 +160,8 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder {
* @return list of font files
* @throws IOException thrown if an I/O exception of some sort has occurred
*/
- public List find(String dir) throws IOException {
- List results = new java.util.ArrayList();
+ public List<URL> find(String dir) throws IOException {
+ List<URL> results = new java.util.ArrayList<URL>();
super.walk(new File(dir), results);
return results;
}
diff --git a/src/java/org/apache/fop/fonts/autodetect/FontFinder.java b/src/java/org/apache/fop/fonts/autodetect/FontFinder.java
index 0ab71daec..51e79443a 100644
--- a/src/java/org/apache/fop/fonts/autodetect/FontFinder.java
+++ b/src/java/org/apache/fop/fonts/autodetect/FontFinder.java
@@ -20,6 +20,7 @@
package org.apache.fop.fonts.autodetect;
import java.io.IOException;
+import java.net.URL;
import java.util.List;
/**
@@ -31,12 +32,10 @@ public interface FontFinder {
/**
* Finds a list of font files.
*
- * @return list of font files. List&lt;URL&gt; in the case of the
- * FontFinder, and List&lt;File&gt; in the case of the
- * FonrDirFinders.
+ * @return list of font files.
* @throws IOException
* In case of an I/O problem
*/
- List/*<URL>*/ find() throws IOException;
+ List<URL> find() throws IOException;
}
diff --git a/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java b/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
index e2858e2f7..714af0e57 100644
--- a/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
+++ b/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
@@ -22,7 +22,6 @@ package org.apache.fop.fonts.autodetect;
import java.io.InputStream;
import java.net.URL;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
@@ -30,7 +29,6 @@ import java.util.regex.Pattern;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.apache.fop.fonts.CustomFont;
import org.apache.fop.fonts.EmbedFontInfo;
import org.apache.fop.fonts.EncodingMode;
@@ -52,7 +50,7 @@ import org.apache.fop.fonts.truetype.TTFFontLoader;
public class FontInfoFinder {
/** logging instance */
- private Log log = LogFactory.getLog(FontInfoFinder.class);
+ private final Log log = LogFactory.getLog(FontInfoFinder.class);
private FontEventListener eventListener;
@@ -70,9 +68,9 @@ public class FontInfoFinder {
* It seems to be fairly accurate but will probably require some tweaking over time
*
* @param customFont CustomFont
- * @param triplet Collection that will take the generated triplets
+ * @param triplets Collection that will take the generated triplets
*/
- private void generateTripletsFromFont(CustomFont customFont, Collection triplets) {
+ private void generateTripletsFromFont(CustomFont customFont, Collection<FontTriplet> triplets) {
if (log.isTraceEnabled()) {
log.trace("Font: " + customFont.getFullName()
+ ", family: " + customFont.getFamilyNames()
@@ -99,10 +97,9 @@ public class FontInfoFinder {
if (!fullName.equals(strippedName)) {
triplets.add(new FontTriplet(strippedName, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL));
}
- Set familyNames = customFont.getFamilyNames();
- Iterator iter = familyNames.iterator();
- while (iter.hasNext()) {
- String familyName = stripQuotes((String)iter.next());
+ Set<String> familyNames = customFont.getFamilyNames();
+ for (String familyName : familyNames) {
+ familyName = stripQuotes(familyName);
if (!fullName.equals(familyName)) {
/* Heuristic:
* The more similar the family name to the full font name,
@@ -135,17 +132,17 @@ public class FontInfoFinder {
/**
* Attempts to determine FontInfo from a given custom font
- * @param fontUrl the font URL
+ * @param fontURL the font URL
* @param customFont the custom font
* @param fontCache font cache (may be null)
- * @return
+ * @return FontInfo from the given custom font
*/
private EmbedFontInfo getFontInfoFromCustomFont(
- URL fontUrl, CustomFont customFont, FontCache fontCache) {
- List fontTripletList = new java.util.ArrayList();
+ URL fontURL, CustomFont customFont, FontCache fontCache) {
+ List<FontTriplet> fontTripletList = new java.util.ArrayList<FontTriplet>();
generateTripletsFromFont(customFont, fontTripletList);
String embedUrl;
- embedUrl = fontUrl.toExternalForm();
+ embedUrl = fontURL.toExternalForm();
String subFontName = null;
if (customFont instanceof MultiByteFont) {
subFontName = ((MultiByteFont)customFont).getTTCName();
@@ -162,29 +159,29 @@ public class FontInfoFinder {
/**
* Attempts to determine EmbedFontInfo from a given font file.
*
- * @param fontUrl font URL. Assumed to be local.
+ * @param fontURL font URL. Assumed to be local.
* @param resolver font resolver used to resolve font
* @param fontCache font cache (may be null)
* @return an array of newly created embed font info. Generally, this array
* will have only one entry, unless the fontUrl is a TrueType Collection
*/
- public EmbedFontInfo[] find(URL fontUrl, FontResolver resolver, FontCache fontCache) {
- String embedUrl = null;
- embedUrl = fontUrl.toExternalForm();
+ public EmbedFontInfo[] find(URL fontURL, FontResolver resolver, FontCache fontCache) {
+ String embedURL = null;
+ embedURL = fontURL.toExternalForm();
long fileLastModified = -1;
if (fontCache != null) {
- fileLastModified = FontCache.getLastModified(fontUrl);
+ fileLastModified = FontCache.getLastModified(fontURL);
// firstly try and fetch it from cache before loading/parsing the font file
- if (fontCache.containsFont(embedUrl)) {
- EmbedFontInfo[] fontInfos = fontCache.getFontInfos(embedUrl, fileLastModified);
+ if (fontCache.containsFont(embedURL)) {
+ EmbedFontInfo[] fontInfos = fontCache.getFontInfos(embedURL, fileLastModified);
if (fontInfos != null) {
return fontInfos;
}
// is this a previously failed parsed font?
- } else if (fontCache.isFailedFont(embedUrl, fileLastModified)) {
+ } else if (fontCache.isFailedFont(embedURL, fileLastModified)) {
if (log.isDebugEnabled()) {
- log.debug("Skipping font file that failed to load previously: " + embedUrl);
+ log.debug("Skipping font file that failed to load previously: " + embedURL);
}
return null;
}
@@ -193,77 +190,72 @@ public class FontInfoFinder {
// try to determine triplet information from font file
CustomFont customFont = null;
- if (fontUrl.toExternalForm().endsWith(".ttc")) {
+ if (fontURL.toExternalForm().endsWith(".ttc")) {
// Get a list of the TTC Font names
- List ttcNames = null; //List<String>
- String fontFileURI = fontUrl.toExternalForm().trim();
+ List<String> ttcNames = null;
+ String fontFileURL = fontURL.toExternalForm().trim();
InputStream in = null;
try {
- in = FontLoader.openFontUri(resolver, fontFileURI);
+ in = FontLoader.openFontUri(resolver, fontFileURL);
TTFFile ttf = new TTFFile();
FontFileReader reader = new FontFileReader(in);
ttcNames = ttf.getTTCnames(reader);
} catch (Exception e) {
if (this.eventListener != null) {
- this.eventListener.fontLoadingErrorAtAutoDetection(this, fontFileURI, e);
+ this.eventListener.fontLoadingErrorAtAutoDetection(this, fontFileURL, e);
}
return null;
} finally {
IOUtils.closeQuietly(in);
}
- List/*<EmbedFontInfo>*/ embedFontInfoList
- = new java.util.ArrayList/*<EmbedFontInfo>*/();
+ List<EmbedFontInfo> embedFontInfoList = new java.util.ArrayList<EmbedFontInfo>();
// For each font name ...
- //for (String fontName : ttcNames) {
- Iterator ttcNamesIterator = ttcNames.iterator();
- while (ttcNamesIterator.hasNext()) {
- String fontName = (String)ttcNamesIterator.next();
-
+ for (String fontName : ttcNames) {
if (log.isDebugEnabled()) {
log.debug("Loading " + fontName);
}
try {
TTFFontLoader ttfLoader = new TTFFontLoader(
- fontFileURI, fontName, true, EncodingMode.AUTO, true, resolver);
+ fontFileURL, fontName, true, EncodingMode.AUTO, true, resolver);
customFont = ttfLoader.getFont();
if (this.eventListener != null) {
customFont.setEventListener(this.eventListener);
}
} catch (Exception e) {
if (fontCache != null) {
- fontCache.registerFailedFont(embedUrl, fileLastModified);
+ fontCache.registerFailedFont(embedURL, fileLastModified);
}
if (this.eventListener != null) {
- this.eventListener.fontLoadingErrorAtAutoDetection(this, embedUrl, e);
+ this.eventListener.fontLoadingErrorAtAutoDetection(this, embedURL, e);
}
continue;
}
- EmbedFontInfo fi = getFontInfoFromCustomFont(fontUrl, customFont, fontCache);
+ EmbedFontInfo fi = getFontInfoFromCustomFont(fontURL, customFont, fontCache);
if (fi != null) {
embedFontInfoList.add(fi);
}
}
- return (EmbedFontInfo[])embedFontInfoList.toArray(
+ return embedFontInfoList.toArray(
new EmbedFontInfo[embedFontInfoList.size()]);
} else {
// The normal case
try {
- customFont = FontLoader.loadFont(fontUrl, null, true, EncodingMode.AUTO, resolver);
+ customFont = FontLoader.loadFont(fontURL, null, true, EncodingMode.AUTO, resolver);
if (this.eventListener != null) {
customFont.setEventListener(this.eventListener);
}
} catch (Exception e) {
if (fontCache != null) {
- fontCache.registerFailedFont(embedUrl, fileLastModified);
+ fontCache.registerFailedFont(embedURL, fileLastModified);
}
if (this.eventListener != null) {
- this.eventListener.fontLoadingErrorAtAutoDetection(this, embedUrl, e);
+ this.eventListener.fontLoadingErrorAtAutoDetection(this, embedURL, e);
}
return null;
}
- EmbedFontInfo fi = getFontInfoFromCustomFont(fontUrl, customFont, fontCache);
+ EmbedFontInfo fi = getFontInfoFromCustomFont(fontURL, customFont, fontCache);
if (fi != null) {
return new EmbedFontInfo[] {fi};
} else {
diff --git a/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java b/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java
index 4072257b4..9f723a308 100644
--- a/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java
+++ b/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java
@@ -25,15 +25,15 @@ import java.util.List;
/**
* Native font finder base class
*/
-public abstract class NativeFontDirFinder implements FontFinder {
+public abstract class NativeFontDirFinder implements FontDirFinder {
/**
* Generic method used by Mac and Unix font finders.
* @return list of natively existing font directories
* {@inheritDoc}
*/
- public List find() {
- List fontDirList = new java.util.ArrayList();
+ public List<File> find() {
+ List<File> fontDirList = new java.util.ArrayList<File>();
String[] searchableDirectories = getSearchableDirectories();
if (searchableDirectories != null) {
for (int i = 0; i < searchableDirectories.length; i++) {
diff --git a/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java b/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java
index 2e07229f6..d9773a026 100644
--- a/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java
+++ b/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java
@@ -28,7 +28,7 @@ import java.util.List;
/**
* FontFinder for native Windows platforms
*/
-public class WindowsFontDirFinder implements FontFinder {
+public class WindowsFontDirFinder implements FontDirFinder {
/**
* Attempts to read windir environment variable on windows
@@ -51,8 +51,8 @@ public class WindowsFontDirFinder implements FontFinder {
* {@inheritDoc}
* @return a list of detected font files
*/
- public List find() {
- List fontDirList = new java.util.ArrayList();
+ public List<File> find() {
+ List<File> fontDirList = new java.util.ArrayList<File>();
String windir = null;
try {
windir = System.getProperty("env.windir");
diff --git a/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java b/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java
index 313ad04a8..e018bb2c2 100644
--- a/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java
+++ b/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java
@@ -35,7 +35,7 @@ public class FontSubstitutions extends java.util.ArrayList/*<Substitutions>*/ {
private static final long serialVersionUID = -9173104935431899722L;
/** logging instance */
- protected static Log log = LogFactory.getLog(FontSubstitutions.class);
+ protected static final Log log = LogFactory.getLog(FontSubstitutions.class);
/**
* Adjusts a given fontInfo using this font substitution catalog
diff --git a/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java b/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java
index 29ae0556d..34e04eb67 100644
--- a/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java
+++ b/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java
@@ -30,7 +30,7 @@ import org.apache.commons.logging.LogFactory;
public class FontWeightRange {
/** logging instance */
- protected static Log log = LogFactory.getLog("org.apache.fop.render.fonts");
+ protected static final Log log = LogFactory.getLog("org.apache.fop.render.fonts");
/**
* Returns an <code>FontWeightRange</code> object holding the
diff --git a/src/java/org/apache/fop/fonts/truetype/FontFileReader.java b/src/java/org/apache/fop/fonts/truetype/FontFileReader.java
index d12b19654..a6db7b6d0 100644
--- a/src/java/org/apache/fop/fonts/truetype/FontFileReader.java
+++ b/src/java/org/apache/fop/fonts/truetype/FontFileReader.java
@@ -317,6 +317,7 @@ public class FontFileReader {
* Read an ISO-8859-1 string of len bytes.
*
* @param len The length of the string to read
+ * @param encodingID the string encoding id (presently ignored; always uses UTF-16BE)
* @return A String
* @throws IOException If EOF is reached
*/
diff --git a/src/java/org/apache/fop/fonts/truetype/TTFCmapEntry.java b/src/java/org/apache/fop/fonts/truetype/TTFCmapEntry.java
index 171f71a76..897d5e2de 100644
--- a/src/java/org/apache/fop/fonts/truetype/TTFCmapEntry.java
+++ b/src/java/org/apache/fop/fonts/truetype/TTFCmapEntry.java
@@ -44,6 +44,17 @@ public class TTFCmapEntry {
/**
* {@inheritDoc}
*/
+ public int hashCode() {
+ int hc = super.hashCode();
+ hc ^= ( hc * 11 ) + unicodeStart;
+ hc ^= ( hc * 19 ) + unicodeEnd;
+ hc ^= ( hc * 23 ) + glyphStartIndex;
+ return hc;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public boolean equals(Object o) {
if (o instanceof TTFCmapEntry) {
TTFCmapEntry ce = (TTFCmapEntry)o;
diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFile.java b/src/java/org/apache/fop/fonts/truetype/TTFFile.java
index 9fd6adbce..f4806d95e 100644
--- a/src/java/org/apache/fop/fonts/truetype/TTFFile.java
+++ b/src/java/org/apache/fop/fonts/truetype/TTFFile.java
@@ -28,10 +28,8 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
-import org.apache.xmlgraphics.fonts.Glyphs;
-
import org.apache.fop.fonts.FontUtil;
+import org.apache.xmlgraphics.fonts.Glyphs;
/**
* Reads a TrueType file or a TrueType Collection.
@@ -48,17 +46,17 @@ public class TTFFile {
/** Set to true to get even more debug output than with level DEBUG */
public static final boolean TRACE_ENABLED = false;
- private String encoding = "WinAnsiEncoding"; // Default encoding
+ private final String encoding = "WinAnsiEncoding"; // Default encoding
- private short firstChar = 0;
+ private final short firstChar = 0;
private boolean isEmbeddable = true;
private boolean hasSerifs = true;
/**
* Table directory
*/
protected Map dirTabs;
- private Map kerningTab; // for CIDs
- private Map ansiKerningTab; // For winAnsiEncoding
+ private Map<Integer, Map<Integer, Integer>> kerningTab; // for CIDs
+ private Map<Integer, Map<Integer, Integer>> ansiKerningTab; // For winAnsiEncoding
private List cmaps;
private List unicodeMapping;
@@ -77,12 +75,12 @@ public class TTFFile {
* Contains glyph data
*/
protected TTFMtxEntry[] mtxTab; // Contains glyph data
- private int[] mtxEncoded = null;
+ private final int[] mtxEncoded = null;
private String postScriptName = "";
private String fullName = "";
private String notice = "";
- private Set familyNames = new java.util.HashSet(); //Set<String>
+ private final Set familyNames = new java.util.HashSet(); //Set<String>
private String subFamilyName = "";
private long italicAngle = 0;
@@ -115,8 +113,8 @@ public class TTFFile {
// internal mapping of glyph indexes to unicode indexes
// used for quick mappings in this class
- private Map glyphToUnicodeMap = new java.util.HashMap();
- private Map unicodeToGlyphMap = new java.util.HashMap();
+ private final Map glyphToUnicodeMap = new java.util.HashMap();
+ private final Map unicodeToGlyphMap = new java.util.HashMap();
private TTFDirTabEntry currentDirTab;
@@ -132,8 +130,8 @@ public class TTFFile {
*/
class UnicodeMapping {
- private int unicodeIndex;
- private int glyphIndex;
+ private final int unicodeIndex;
+ private final int glyphIndex;
UnicodeMapping(int glyphIndex, int unicodeIndex) {
this.unicodeIndex = unicodeIndex;
@@ -245,7 +243,8 @@ public class TTFFile {
}
}
- private boolean readUnicodeCmap(FontFileReader in, long cmapUniOffset, int encodingID)
+ private boolean readUnicodeCmap // CSOK: MethodLength
+ (FontFileReader in, long cmapUniOffset, int encodingID)
throws IOException {
//Read CMAP table and correct mtxTab.index
int mtxPtr = 0;
@@ -491,7 +490,7 @@ public class TTFFile {
ansiIndex = new java.util.HashMap();
for (int i = 32; i < Glyphs.WINANSI_ENCODING.length; i++) {
Integer ansi = new Integer(i);
- Integer uni = new Integer((int)Glyphs.WINANSI_ENCODING[i]);
+ Integer uni = new Integer(Glyphs.WINANSI_ENCODING[i]);
List v = (List)ansiIndex.get(uni);
if (v == null) {
@@ -640,7 +639,7 @@ public class TTFFile {
* @return int The CapHeight
*/
public int getCapHeight() {
- return (int)convertTTFUnit2PDFUnit(capHeight);
+ return convertTTFUnit2PDFUnit(capHeight);
}
/**
@@ -648,7 +647,7 @@ public class TTFFile {
* @return int The XHeight
*/
public int getXHeight() {
- return (int)convertTTFUnit2PDFUnit(xHeight);
+ return convertTTFUnit2PDFUnit(xHeight);
}
/**
@@ -707,10 +706,10 @@ public class TTFFile {
*/
public int[] getFontBBox() {
final int[] fbb = new int[4];
- fbb[0] = (int)convertTTFUnit2PDFUnit(fontBBox1);
- fbb[1] = (int)convertTTFUnit2PDFUnit(fontBBox2);
- fbb[2] = (int)convertTTFUnit2PDFUnit(fontBBox3);
- fbb[3] = (int)convertTTFUnit2PDFUnit(fontBBox4);
+ fbb[0] = convertTTFUnit2PDFUnit(fontBBox1);
+ fbb[1] = convertTTFUnit2PDFUnit(fontBBox2);
+ fbb[2] = convertTTFUnit2PDFUnit(fontBBox3);
+ fbb[3] = convertTTFUnit2PDFUnit(fontBBox4);
return fbb;
}
@@ -720,7 +719,7 @@ public class TTFFile {
* @return int The LowerCaseAscent
*/
public int getLowerCaseAscent() {
- return (int)convertTTFUnit2PDFUnit(ascender);
+ return convertTTFUnit2PDFUnit(ascender);
}
/**
@@ -728,7 +727,7 @@ public class TTFFile {
* @return int The LowerCaseDescent
*/
public int getLowerCaseDescent() {
- return (int)convertTTFUnit2PDFUnit(descender);
+ return convertTTFUnit2PDFUnit(descender);
}
/**
@@ -755,7 +754,7 @@ public class TTFFile {
public int[] getWidths() {
int[] wx = new int[mtxTab.length];
for (int i = 0; i < wx.length; i++) {
- wx[i] = (int)convertTTFUnit2PDFUnit(mtxTab[i].getWx());
+ wx[i] = convertTTFUnit2PDFUnit(mtxTab[i].getWx());
}
return wx;
@@ -767,14 +766,14 @@ public class TTFFile {
* @return int Standard width
*/
public int getCharWidth(int idx) {
- return (int)convertTTFUnit2PDFUnit(ansiWidth[idx]);
+ return convertTTFUnit2PDFUnit(ansiWidth[idx]);
}
/**
* Returns the kerning table.
* @return Map The kerning table
*/
- public Map getKerning() {
+ public Map<Integer, Map<Integer, Integer>> getKerning() {
return kerningTab;
}
@@ -782,7 +781,7 @@ public class TTFFile {
* Returns the ANSI kerning table.
* @return Map The ANSI kerning table
*/
- public Map getAnsiKerning() {
+ public Map<Integer, Map<Integer, Integer>> getAnsiKerning() {
return ansiKerningTab;
}
@@ -961,7 +960,7 @@ public class TTFFile {
* Read the "post" table
* containing the PostScript names of the glyphs.
*/
- private final void readPostScript(FontFileReader in) throws IOException {
+ private void readPostScript(FontFileReader in) throws IOException {
seekTab(in, "post", 0);
postFormat = in.readTTFLong();
italicAngle = in.readTTFULong();
@@ -1133,7 +1132,7 @@ public class TTFFile {
* @param in FontFileReader to read from
* @throws IOException In case of a I/O problem
*/
- private final void readGlyf(FontFileReader in) throws IOException {
+ private void readGlyf(FontFileReader in) throws IOException {
TTFDirTabEntry dirTab = (TTFDirTabEntry)dirTabs.get("glyf");
if (dirTab == null) {
throw new IOException("glyf table not found, cannot continue");
@@ -1188,7 +1187,7 @@ public class TTFFile {
* @param in FontFileReader to read from
* @throws IOException In case of a I/O problem
*/
- private final void readName(FontFileReader in) throws IOException {
+ private void readName(FontFileReader in) throws IOException {
seekTab(in, "name", 2);
int i = in.getCurrentPos();
int n = in.readTTFUShort();
@@ -1259,7 +1258,7 @@ public class TTFFile {
* @param in FontFileReader to read from
* @throws IOException In case of a I/O problem
*/
- private final boolean readPCLT(FontFileReader in) throws IOException {
+ private boolean readPCLT(FontFileReader in) throws IOException {
TTFDirTabEntry dirTab = (TTFDirTabEntry)dirTabs.get("PCLT");
if (dirTab != null) {
in.seekSet(dirTab.getOffset() + 4 + 4 + 2);
@@ -1403,7 +1402,7 @@ public class TTFFile {
* @param in FontFileReader to read from
* @throws IOException In case of a I/O problem
*/
- private final void readKerning(FontFileReader in) throws IOException {
+ private void readKerning(FontFileReader in) throws IOException {
// Read kerning
kerningTab = new java.util.HashMap();
ansiKerningTab = new java.util.HashMap();
@@ -1439,11 +1438,11 @@ public class TTFFile {
log.debug("Ignoring kerning pair because Unicode index was"
+ " found for the second glyph " + i);
} else {
- Map adjTab = (Map)kerningTab.get(iObj);
+ Map adjTab = kerningTab.get(iObj);
if (adjTab == null) {
adjTab = new java.util.HashMap();
}
- adjTab.put(u2, new Integer((int)convertTTFUnit2PDFUnit(kpx)));
+ adjTab.put(u2, new Integer(convertTTFUnit2PDFUnit(kpx)));
kerningTab.put(iObj, adjTab);
}
}
@@ -1457,8 +1456,8 @@ public class TTFFile {
while (ae.hasNext()) {
Integer unicodeKey1 = (Integer)ae.next();
Integer cidKey1 = unicodeToGlyph(unicodeKey1.intValue());
- Map akpx = new java.util.HashMap();
- Map ckpx = (Map)kerningTab.get(unicodeKey1);
+ Map<Integer, Integer> akpx = new java.util.HashMap();
+ Map ckpx = kerningTab.get(unicodeKey1);
Iterator aee = ckpx.keySet().iterator();
while (aee.hasNext()) {
@@ -1569,8 +1568,8 @@ public class TTFFile {
* @return True if not collection or font name present, false otherwise
* @throws IOException In case of an I/O problem
*/
- public final List getTTCnames(FontFileReader in) throws IOException {
- List fontNames = new java.util.ArrayList();
+ public final List<String> getTTCnames(FontFileReader in) throws IOException {
+ List<String> fontNames = new java.util.ArrayList<String>();
String tag = in.readTTFString(4);
@@ -1639,8 +1638,8 @@ public class TTFFile {
System.out.println("Family name: " + familyNames);
System.out.println("Subfamily name: " + subFamilyName);
System.out.println("Notice: " + notice);
- System.out.println("xHeight: " + (int)convertTTFUnit2PDFUnit(xHeight));
- System.out.println("capheight: " + (int)convertTTFUnit2PDFUnit(capHeight));
+ System.out.println("xHeight: " + convertTTFUnit2PDFUnit(xHeight));
+ System.out.println("capheight: " + convertTTFUnit2PDFUnit(capHeight));
int italic = (int)(italicAngle >> 16);
System.out.println("Italic: " + italic);
@@ -1653,10 +1652,10 @@ public class TTFFile {
System.out.println();
System.out.println("Ascender: " + convertTTFUnit2PDFUnit(ascender));
System.out.println("Descender: " + convertTTFUnit2PDFUnit(descender));
- System.out.println("FontBBox: [" + (int)convertTTFUnit2PDFUnit(fontBBox1)
- + " " + (int)convertTTFUnit2PDFUnit(fontBBox2) + " "
- + (int)convertTTFUnit2PDFUnit(fontBBox3) + " "
- + (int)convertTTFUnit2PDFUnit(fontBBox4) + "]");
+ System.out.println("FontBBox: [" + convertTTFUnit2PDFUnit(fontBBox1)
+ + " " + convertTTFUnit2PDFUnit(fontBBox2) + " "
+ + convertTTFUnit2PDFUnit(fontBBox3) + " "
+ + convertTTFUnit2PDFUnit(fontBBox4) + "]");
}
private String formatUnitsForDebug(int units) {
diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
index 405a25f9e..8ee36ec1f 100644
--- a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
+++ b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
@@ -24,11 +24,9 @@ import java.io.InputStream;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.commons.io.IOUtils;
-
-import org.apache.xmlgraphics.fonts.Glyphs;
-
import org.apache.fop.fonts.BFEntry;
import org.apache.fop.fonts.CIDFontType;
import org.apache.fop.fonts.EncodingMode;
@@ -38,6 +36,7 @@ import org.apache.fop.fonts.FontType;
import org.apache.fop.fonts.MultiByteFont;
import org.apache.fop.fonts.NamedCharacter;
import org.apache.fop.fonts.SingleByteFont;
+import org.apache.xmlgraphics.fonts.Glyphs;
/**
* Loads a TrueType font into memory directly from the original font file.
@@ -46,7 +45,7 @@ public class TTFFontLoader extends FontLoader {
private MultiByteFont multiFont;
private SingleByteFont singleFont;
- private String subFontName;
+ private final String subFontName;
private EncodingMode encodingMode;
/**
@@ -80,6 +79,7 @@ public class TTFFontLoader extends FontLoader {
}
/** {@inheritDoc} */
+ @Override
protected void read() throws IOException {
read(this.subFontName);
}
@@ -205,21 +205,20 @@ public class TTFFontLoader extends FontLoader {
private void copyKerning(TTFFile ttf, boolean isCid) {
// Get kerning
- Iterator iter;
+ Set<Integer> kerningSet;
if (isCid) {
- iter = ttf.getKerning().keySet().iterator();
+ kerningSet = ttf.getKerning().keySet();
} else {
- iter = ttf.getAnsiKerning().keySet().iterator();
+ kerningSet = ttf.getAnsiKerning().keySet();
}
- while (iter.hasNext()) {
- Integer kpx1 = (Integer)iter.next();
+ for (Integer kpx1 : kerningSet) {
- Map h2;
+ Map<Integer, Integer> h2;
if (isCid) {
- h2 = (Map)ttf.getKerning().get(kpx1);
+ h2 = ttf.getKerning().get(kpx1);
} else {
- h2 = (Map)ttf.getAnsiKerning().get(kpx1);
+ h2 = ttf.getAnsiKerning().get(kpx1);
}
returnFont.putKerningEntry(kpx1, h2);
}
diff --git a/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java b/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java
index 37e24836e..ee89d9303 100644
--- a/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java
+++ b/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java
@@ -645,7 +645,7 @@ public class TTFSubSetFile extends TTFFile {
* @throws IOException in case of an I/O problem
*/
public byte[] readFont(FontFileReader in, String name,
- Map glyphs) throws IOException {
+ Map<Integer, Integer> glyphs) throws IOException {
//Check if TrueType collection, and that the name exists in the collection
if (!checkTTC(in, name)) {
@@ -653,7 +653,7 @@ public class TTFSubSetFile extends TTFFile {
}
//Copy the Map as we're going to modify it
- Map subsetGlyphs = new java.util.HashMap(glyphs);
+ Map<Integer, Integer> subsetGlyphs = new java.util.HashMap<Integer, Integer>(glyphs);
output = new byte[in.getFileSize()];
diff --git a/src/java/org/apache/fop/fonts/type1/PFBParser.java b/src/java/org/apache/fop/fonts/type1/PFBParser.java
index bd12c2c77..8cb90b146 100644
--- a/src/java/org/apache/fop/fonts/type1/PFBParser.java
+++ b/src/java/org/apache/fop/fonts/type1/PFBParser.java
@@ -161,7 +161,7 @@ public class PFBParser {
}
- private static final boolean byteCmp(byte[] src, int srcOffset, byte[] cmp) {
+ private static boolean byteCmp(byte[] src, int srcOffset, byte[] cmp) {
for (int i = 0; i < cmp.length; i++) {
// System.out.println("Compare: " + src[srcOffset + i] + " " + cmp[i]);
if (src[srcOffset + i] != cmp[i]) {
diff --git a/src/java/org/apache/fop/hyphenation/ByteVector.java b/src/java/org/apache/fop/hyphenation/ByteVector.java
index 5a81a51ec..0df1bd925 100644
--- a/src/java/org/apache/fop/hyphenation/ByteVector.java
+++ b/src/java/org/apache/fop/hyphenation/ByteVector.java
@@ -29,6 +29,8 @@ import java.io.Serializable;
*/
public class ByteVector implements Serializable {
+ private static final long serialVersionUID = 1554572867863466772L;
+
/**
* Capacity increment size
*/
@@ -45,10 +47,17 @@ public class ByteVector implements Serializable {
*/
private int n;
+ /**
+ * Construct byte vector instance with default block size.
+ */
public ByteVector() {
this(DEFAULT_BLOCK_SIZE);
}
+ /**
+ * Construct byte vector instance.
+ * @param capacity initial block size
+ */
public ByteVector(int capacity) {
if (capacity > 0) {
blockSize = capacity;
@@ -59,12 +68,25 @@ public class ByteVector implements Serializable {
n = 0;
}
+ /**
+ * Construct byte vector instance.
+ * @param a byte array to use
+ * TODO should n should be initialized to a.length to be consistent with
+ * CharVector behavior? [GA]
+ */
public ByteVector(byte[] a) {
blockSize = DEFAULT_BLOCK_SIZE;
array = a;
n = 0;
}
+ /**
+ * Construct byte vector instance.
+ * @param a byte array to use
+ * @param capacity initial block size
+ * TODO should n should be initialized to a.length to be consistent with
+ * CharVector behavior? [GA]
+ */
public ByteVector(byte[] a, int capacity) {
if (capacity > 0) {
blockSize = capacity;
@@ -75,34 +97,52 @@ public class ByteVector implements Serializable {
n = 0;
}
+ /**
+ * Obtain byte vector array.
+ * @return byte array
+ */
public byte[] getArray() {
return array;
}
/**
- * return number of items in array
+ * Obtain number of items in array.
+ * @return number of items
*/
public int length() {
return n;
}
/**
- * returns current capacity of array
+ * Obtain capacity of array.
+ * @return current capacity of array
*/
public int capacity() {
return array.length;
}
+ /**
+ * Pet byte at index.
+ * @param index the index
+ * @param val a byte
+ */
public void put(int index, byte val) {
array[index] = val;
}
+ /**
+ * Get byte at index.
+ * @param index the index
+ * @return a byte
+ */
public byte get(int index) {
return array[index];
}
/**
* This is to implement memory allocation in the array. Like malloc().
+ * @param size to allocate
+ * @return previous length
*/
public int alloc(int size) {
int index = n;
@@ -116,6 +156,9 @@ public class ByteVector implements Serializable {
return index;
}
+ /**
+ * Trim byte vector to current length.
+ */
public void trimToSize() {
if (n < array.length) {
byte[] aux = new byte[n];
diff --git a/src/java/org/apache/fop/hyphenation/CharVector.java b/src/java/org/apache/fop/hyphenation/CharVector.java
index ad8280f12..97a63392e 100644
--- a/src/java/org/apache/fop/hyphenation/CharVector.java
+++ b/src/java/org/apache/fop/hyphenation/CharVector.java
@@ -29,6 +29,8 @@ import java.io.Serializable;
*/
public class CharVector implements Cloneable, Serializable {
+ private static final long serialVersionUID = 4263472982169004048L;
+
/**
* Capacity increment size
*/
@@ -45,10 +47,17 @@ public class CharVector implements Cloneable, Serializable {
*/
private int n;
+ /**
+ * Construct char vector instance with default block size.
+ */
public CharVector() {
this(DEFAULT_BLOCK_SIZE);
}
+ /**
+ * Construct char vector instance.
+ * @param capacity initial block size
+ */
public CharVector(int capacity) {
if (capacity > 0) {
blockSize = capacity;
@@ -59,12 +68,21 @@ public class CharVector implements Cloneable, Serializable {
n = 0;
}
+ /**
+ * Construct char vector instance.
+ * @param a char array to use
+ */
public CharVector(char[] a) {
blockSize = DEFAULT_BLOCK_SIZE;
array = a;
n = a.length;
}
+ /**
+ * Construct char vector instance.
+ * @param a char array to use
+ * @param capacity initial block size
+ */
public CharVector(char[] a, int capacity) {
if (capacity > 0) {
blockSize = capacity;
@@ -76,44 +94,66 @@ public class CharVector implements Cloneable, Serializable {
}
/**
- * Reset Vector but don't resize or clear elements
+ * Reset length of vector, but don't clear contents.
*/
public void clear() {
n = 0;
}
+ /** {@inheritDoc} */
public Object clone() {
CharVector cv = new CharVector((char[])array.clone(), blockSize);
cv.n = this.n;
return cv;
}
+ /**
+ * Obtain char vector array.
+ * @return char array
+ */
public char[] getArray() {
return array;
}
/**
- * return number of items in array
+ * Obtain number of items in array.
+ * @return number of items
*/
public int length() {
return n;
}
/**
- * returns current capacity of array
+ * Obtain capacity of array.
+ * @return current capacity of array
*/
public int capacity() {
return array.length;
}
+ /**
+ * Pet char at index.
+ * @param index the index
+ * @param val a char
+ */
public void put(int index, char val) {
array[index] = val;
}
+ /**
+ * Get char at index.
+ * @param index the index
+ * @return a char
+ */
public char get(int index) {
return array[index];
}
+ /**
+ * This is to implement memory allocation in the array. Like malloc().
+ * @param size to allocate
+ * @return previous length
+ */
public int alloc(int size) {
int index = n;
int len = array.length;
@@ -126,6 +166,9 @@ public class CharVector implements Cloneable, Serializable {
return index;
}
+ /**
+ * Trim char vector to current length.
+ */
public void trimToSize() {
if (n < array.length) {
char[] aux = new char[n];
diff --git a/src/java/org/apache/fop/hyphenation/Hyphen.java b/src/java/org/apache/fop/hyphenation/Hyphen.java
index 268e3861d..ae33ec616 100644
--- a/src/java/org/apache/fop/hyphenation/Hyphen.java
+++ b/src/java/org/apache/fop/hyphenation/Hyphen.java
@@ -34,23 +34,45 @@ import java.io.Serializable;
* @author Carlos Villegas <cav@uniscope.co.jp>
*/
+/**
+ * Represents a hyphen.
+ */
public class Hyphen implements Serializable {
- public String preBreak;
- public String noBreak;
- public String postBreak;
+ private static final long serialVersionUID = 8989909741110279085L;
+
+ /** pre break string */
+ public String preBreak; // CSOK: VisibilityModifier
+
+ /** no break string */
+ public String noBreak; // CSOK: VisibilityModifier
+
+ /** post break string */
+ public String postBreak; // CSOK: VisibilityModifier
+
+ /**
+ * Construct a hyphen.
+ * @param pre break string
+ * @param no break string
+ * @param post break string
+ */
Hyphen(String pre, String no, String post) {
preBreak = pre;
noBreak = no;
postBreak = post;
}
+ /**
+ * Construct a hyphen.
+ * @param pre break string
+ */
Hyphen(String pre) {
preBreak = pre;
noBreak = null;
postBreak = null;
}
+ /** {@inheritDoc} */
public String toString() {
if (noBreak == null
&& postBreak == null
diff --git a/src/java/org/apache/fop/hyphenation/Hyphenation.java b/src/java/org/apache/fop/hyphenation/Hyphenation.java
index fe4d6ba0c..b1e2f1cde 100644
--- a/src/java/org/apache/fop/hyphenation/Hyphenation.java
+++ b/src/java/org/apache/fop/hyphenation/Hyphenation.java
@@ -52,6 +52,7 @@ public class Hyphenation {
}
/**
+ * @param index an index position
* @return the pre-break text, not including the hyphen character
*/
public String getPreHyphenText(int index) {
@@ -59,6 +60,7 @@ public class Hyphenation {
}
/**
+ * @param index an index position
* @return the post-break text
*/
public String getPostHyphenText(int index) {
@@ -72,6 +74,7 @@ public class Hyphenation {
return hyphenPoints;
}
+ /** {@inheritDoc} */
public String toString() {
StringBuffer str = new StringBuffer();
int start = 0;
diff --git a/src/java/org/apache/fop/hyphenation/HyphenationException.java b/src/java/org/apache/fop/hyphenation/HyphenationException.java
index 0a4e737c6..484d01cbd 100644
--- a/src/java/org/apache/fop/hyphenation/HyphenationException.java
+++ b/src/java/org/apache/fop/hyphenation/HyphenationException.java
@@ -20,12 +20,15 @@
package org.apache.fop.hyphenation;
/**
+ * An hyphenation exception.
* @author Carlos Villegas <cav@uniscope.co.jp>
- * (todo) Derive from FOPException
+ * TODO Derive from FOPException
*/
public class HyphenationException extends Exception {
/**
+ * Construct a hyphenation exception.
+ * @param msg a message string
* @see java.lang.Throwable#Throwable(String)
*/
public HyphenationException(String msg) {
diff --git a/src/java/org/apache/fop/hyphenation/HyphenationTree.java b/src/java/org/apache/fop/hyphenation/HyphenationTree.java
index 41d4cc63c..fa7d218d9 100644
--- a/src/java/org/apache/fop/hyphenation/HyphenationTree.java
+++ b/src/java/org/apache/fop/hyphenation/HyphenationTree.java
@@ -66,6 +66,7 @@ public class HyphenationTree extends TernaryTree
*/
private transient TernaryTree ivalues;
+ /** Default constructor. */
public HyphenationTree() {
stoplist = new HashMap(23); // usually a small table
classmap = new TernaryTree();
@@ -100,6 +101,11 @@ public class HyphenationTree extends TernaryTree
return offset;
}
+ /**
+ * Unpack values.
+ * @param k an integer
+ * @return a string
+ */
protected String unpackValues(int k) {
StringBuffer buf = new StringBuffer();
byte v = vspace.get(k++);
@@ -154,6 +160,11 @@ public class HyphenationTree extends TernaryTree
ivalues = null;
}
+ /**
+ * Find pattern.
+ * @param pat a pattern
+ * @return a string
+ */
public String findPattern(String pat) {
int k = super.find(pat);
if (k >= 0) {
@@ -164,7 +175,12 @@ public class HyphenationTree extends TernaryTree
/**
* String compare, returns 0 if equal or
- * t is a substring of s
+ * t is a substring of s.
+ * @param s first character array
+ * @param si starting index into first array
+ * @param t second character array
+ * @param ti starting index into second array
+ * @return an integer
*/
protected int hstrcmp(char[] s, int si, char[] t, int ti) {
for (; s[si] == t[ti]; si++, ti++) {
@@ -178,6 +194,11 @@ public class HyphenationTree extends TernaryTree
return s[si] - t[ti];
}
+ /**
+ * Get values.
+ * @param k an integer
+ * @return a byte array
+ */
protected byte[] getValues(int k) {
StringBuffer buf = new StringBuffer();
byte v = vspace.get(k++);
@@ -352,12 +373,12 @@ public class HyphenationTree extends TernaryTree
if (nc < 0) { // found a non-letter character ...
if (i == (1 + iIgnoreAtBeginning)) {
// ... before any letter character
- iIgnoreAtBeginning ++;
+ iIgnoreAtBeginning++;
} else {
// ... after a letter character
bEndOfLetters = true;
}
- iLength --;
+ iLength--;
} else {
if (!bEndOfLetters) {
word[i - iIgnoreAtBeginning] = (char)nc;
@@ -435,6 +456,7 @@ public class HyphenationTree extends TernaryTree
* files use only lower case characters, in this case a class
* for letter 'a', for example, should be defined as "aA", the first
* character being the normalization char.
+ * @param chargroup a character class (group)
*/
public void addClass(String chargroup) {
if (chargroup.length() > 0) {
@@ -479,6 +501,9 @@ public class HyphenationTree extends TernaryTree
insert(pattern, (char)k);
}
+ /**
+ * Print statistics.
+ */
public void printStats() {
System.out.println("Value space size = "
+ Integer.toString(vspace.length()));
@@ -486,11 +511,16 @@ public class HyphenationTree extends TernaryTree
}
+ /**
+ * Main entry point for this hyphenation utility application.
+ * @param argv array of command linee arguments
+ * @throws Exception in case an exception is raised but not caught
+ */
public static void main(String[] argv) throws Exception {
HyphenationTree ht = null;
int minCharCount = 2;
- BufferedReader in =
- new BufferedReader(new java.io.InputStreamReader(System.in));
+ BufferedReader in
+ = new BufferedReader(new java.io.InputStreamReader(System.in));
while (true) {
System.out.print("l:\tload patterns from XML\n"
+ "L:\tload patterns from serialized object\n"
@@ -572,8 +602,8 @@ public class HyphenationTree extends TernaryTree
long starttime = 0;
int counter = 0;
try {
- BufferedReader reader =
- new BufferedReader(new FileReader(token));
+ BufferedReader reader
+ = new BufferedReader(new FileReader(token));
String line;
starttime = System.currentTimeMillis();
diff --git a/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java b/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java
index 5831e2b98..00a622be5 100644
--- a/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java
+++ b/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java
@@ -20,6 +20,7 @@
package org.apache.fop.hyphenation;
import java.util.Hashtable;
+import java.util.Map;
import java.util.Set;
/**
@@ -39,7 +40,7 @@ public class HyphenationTreeCache {
* @return the HyhenationTree instance or null if it's not in the cache
*/
public HyphenationTree getHyphenationTree(String lang, String country) {
- String key = constructKey(lang, country);
+ String key = constructLlccKey(lang, country);
// first try to find it in the cache
if (hyphenTrees.containsKey(key)) {
@@ -57,7 +58,7 @@ public class HyphenationTreeCache {
* @param country the country (may be null or "none")
* @return the resulting key
*/
- public static String constructKey(String lang, String country) {
+ public static String constructLlccKey(String lang, String country) {
String key = lang;
// check whether the country code has been used
if (country != null && !country.equals("none")) {
@@ -67,6 +68,24 @@ public class HyphenationTreeCache {
}
/**
+ * If the user configured a hyphenation pattern file name
+ * for this (lang,country) value, return it. If not, return null.
+ * @param lang the language
+ * @param country the country (may be null or "none")
+ * @param hyphPatNames the map of user-configured hyphenation pattern file names
+ * @return the hyphenation pattern file name or null
+ */
+ public static String constructUserKey(String lang, String country, Map hyphPatNames) {
+ String userKey = null;
+ if (hyphPatNames != null) {
+ String key = constructLlccKey(lang, country);
+ key.replace('_', '-');
+ userKey = (String) hyphPatNames.get(key);
+ }
+ return userKey;
+ }
+
+ /**
* Cache a hyphenation tree under its key.
* @param key the key (ex. "de_CH" or "en")
* @param hTree the hyphenation tree
diff --git a/src/java/org/apache/fop/hyphenation/Hyphenator.java b/src/java/org/apache/fop/hyphenation/Hyphenator.java
index 401cc6e3b..455520b09 100644
--- a/src/java/org/apache/fop/hyphenation/Hyphenator.java
+++ b/src/java/org/apache/fop/hyphenation/Hyphenator.java
@@ -24,6 +24,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
+import java.util.Map;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
@@ -39,32 +40,20 @@ import org.xml.sax.InputSource;
*
* @author Carlos Villegas <cav@uniscope.co.jp>
*/
-public class Hyphenator {
+public final class Hyphenator {
/** logging instance */
- protected static Log log = LogFactory.getLog(Hyphenator.class);
+ protected static final Log log = LogFactory.getLog(Hyphenator.class);
private static HyphenationTreeCache hTreeCache = null;
- private HyphenationTree hyphenTree = null;
- private int remainCharCount = 2;
- private int pushCharCount = 2;
/** Enables a dump of statistics. Note: If activated content is sent to System.out! */
private static boolean statisticsDump = false;
/**
* Creates a new hyphenator.
- * @param lang the language
- * @param country the country (may be null or "none")
- * @param leftMin the minimum number of characters before the hyphenation point
- * @param rightMin the minimum number of characters after the hyphenation point
*/
- public Hyphenator(String lang, String country, int leftMin,
- int rightMin) {
- hyphenTree = getHyphenationTree(lang, country);
- remainCharCount = leftMin;
- pushCharCount = rightMin;
- }
+ private Hyphenator() { }
/** @return the default (static) hyphenation tree cache */
public static synchronized HyphenationTreeCache getHyphenationTreeCache() {
@@ -75,35 +64,76 @@ public class Hyphenator {
}
/**
- * Returns a hyphenation tree for a given language and country. The hyphenation trees are
- * cached.
+ * Returns a hyphenation tree for a given language and country,
+ * with fallback from (lang,country) to (lang).
+ * The hyphenation trees are cached.
* @param lang the language
* @param country the country (may be null or "none")
+ * @param resolver resolver to find the hyphenation files
+ * @param hyphPatNames the map with user-configured hyphenation pattern file names
* @return the hyphenation tree
*/
public static HyphenationTree getHyphenationTree(String lang,
- String country) {
- return getHyphenationTree(lang, country, null);
+ String country, HyphenationTreeResolver resolver, Map hyphPatNames) {
+ String llccKey = HyphenationTreeCache.constructLlccKey(lang, country);
+ HyphenationTreeCache cache = getHyphenationTreeCache();
+
+ // If this hyphenation tree has been registered as missing, return immediately
+ if (cache.isMissing(llccKey)) {
+ return null;
+ }
+
+ HyphenationTree hTree = getHyphenationTree2(lang, country, resolver, hyphPatNames);
+
+ // fallback to lang only
+ if (hTree == null && country != null && !country.equals("none")) {
+ String llKey = HyphenationTreeCache.constructLlccKey(lang, null);
+ if (!cache.isMissing(llKey)) {
+ hTree = getHyphenationTree2(lang, null, resolver, hyphPatNames);
+ if (hTree != null && log.isDebugEnabled()) {
+ log.debug("Couldn't find hyphenation pattern "
+ + "for lang=\"" + lang + "\",country=\"" + country + "\"."
+ + " Using general language pattern "
+ + "for lang=\"" + lang + "\" instead.");
+ }
+ if (hTree == null) {
+ // no fallback; register as missing
+ cache.noteMissing(llKey);
+ } else {
+ // also register for (lang,country)
+ cache.cache(llccKey, hTree);
+ }
+ }
+ }
+
+ if (hTree == null) {
+ // (lang,country) and (lang) tried; register as missing
+ cache.noteMissing(llccKey);
+ log.error("Couldn't find hyphenation pattern "
+ + "for lang=\"" + lang + "\""
+ + (country != null && !country.equals("none")
+ ? ",country=\"" + country + "\""
+ : "")
+ + ".");
+ }
+
+ return hTree;
}
/**
- * Returns a hyphenation tree for a given language and country. The hyphenation trees are
- * cached.
+ * Returns a hyphenation tree for a given language and country
+ * The hyphenation trees are cached.
* @param lang the language
* @param country the country (may be null or "none")
* @param resolver resolver to find the hyphenation files
+ * @param hyphPatNames the map with user-configured hyphenation pattern file names
* @return the hyphenation tree
*/
- public static HyphenationTree getHyphenationTree(String lang,
- String country, HyphenationTreeResolver resolver) {
- String key = HyphenationTreeCache.constructKey(lang, country);
+ private static HyphenationTree getHyphenationTree2(String lang,
+ String country, HyphenationTreeResolver resolver, Map hyphPatNames) {
+ String llccKey = HyphenationTreeCache.constructLlccKey(lang, country);
HyphenationTreeCache cache = getHyphenationTreeCache();
- // See if there was an error finding this hyphenation tree before
- if (cache.isMissing(key)) {
- return null;
- }
-
HyphenationTree hTree;
// first try to find it in the cache
hTree = getHyphenationTreeCache().getHyphenationTree(lang, country);
@@ -111,6 +141,11 @@ public class Hyphenator {
return hTree;
}
+ String key = HyphenationTreeCache.constructUserKey(lang, country, hyphPatNames);
+ if (key == null) {
+ key = llccKey;
+ }
+
if (resolver != null) {
hTree = getUserHyphenationTree(key, resolver);
}
@@ -120,11 +155,9 @@ public class Hyphenator {
// put it into the pattern cache
if (hTree != null) {
- cache.cache(key, hTree);
- } else {
- log.error("Couldn't find hyphenation pattern " + key);
- cache.noteMissing(key);
+ cache.cache(llccKey, hTree);
}
+
return hTree;
}
@@ -179,31 +212,11 @@ public class Hyphenator {
try {
is = getResourceStream(key);
if (is == null) {
- if (key.length() == 5) {
- String lang = key.substring(0, 2);
- is = getResourceStream(lang);
- if (is != null) {
- if (log.isDebugEnabled()) {
- log.debug("Couldn't find hyphenation pattern '"
- + key
- + "'. Using general language pattern '"
- + lang
- + "' instead.");
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Couldn't find precompiled hyphenation pattern "
- + lang + " in resources.");
- }
- return null;
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Couldn't find precompiled hyphenation pattern "
- + key + " in resources");
- }
- return null;
+ if (log.isDebugEnabled()) {
+ log.debug("Couldn't find precompiled hyphenation pattern "
+ + key + " in resources");
}
+ return null;
}
hTree = readHyphenationTree(is);
} finally {
@@ -259,7 +272,8 @@ public class Hyphenator {
if (source.getSystemId() != null) {
in = new java.net.URL(source.getSystemId()).openStream();
} else {
- throw new UnsupportedOperationException("Cannot load hyphenation pattern file"
+ throw new UnsupportedOperationException
+ ("Cannot load hyphenation pattern file"
+ " with the supplied Source object: " + source);
}
}
@@ -334,6 +348,7 @@ public class Hyphenator {
* @param lang the language
* @param country the optional country code (may be null or "none")
* @param resolver resolver to find the hyphenation files
+ * @param hyphPatNames the map with user-configured hyphenation pattern file names
* @param word the word to hyphenate
* @param leftMin the minimum number of characters before the hyphenation point
* @param rightMin the minimum number of characters after the hyphenation point
@@ -341,120 +356,14 @@ public class Hyphenator {
*/
public static Hyphenation hyphenate(String lang, String country,
HyphenationTreeResolver resolver,
+ Map hyphPatNames,
String word,
int leftMin, int rightMin) {
- HyphenationTree hTree = getHyphenationTree(lang, country, resolver);
+ HyphenationTree hTree = getHyphenationTree(lang, country, resolver, hyphPatNames);
if (hTree == null) {
return null;
}
return hTree.hyphenate(word, leftMin, rightMin);
}
- /**
- * Hyphenates a word.
- * @param lang the language
- * @param country the optional country code (may be null or "none")
- * @param word the word to hyphenate
- * @param leftMin the minimum number of characters before the hyphenation point
- * @param rightMin the minimum number of characters after the hyphenation point
- * @return the hyphenation result
- */
- public static Hyphenation hyphenate(String lang, String country,
- String word,
- int leftMin, int rightMin) {
- return hyphenate(lang, country, null, word, leftMin, rightMin);
- }
-
- /**
- * Hyphenates a word.
- * @param lang the language
- * @param country the optional country code (may be null or "none")
- * @param resolver resolver to find the hyphenation files
- * @param word the word to hyphenate
- * @param offset the offset of the first character in the "word" character array
- * @param len the length of the word
- * @param leftMin the minimum number of characters before the hyphenation point
- * @param rightMin the minimum number of characters after the hyphenation point
- * @return the hyphenation result
- */
- public static Hyphenation hyphenate(String lang, String country,
- HyphenationTreeResolver resolver,
- char[] word, int offset, int len,
- int leftMin, int rightMin) {
- HyphenationTree hTree = getHyphenationTree(lang, country, resolver);
- if (hTree == null) {
- return null;
- }
- return hTree.hyphenate(word, offset, len, leftMin, rightMin);
- }
-
- /**
- * Hyphenates a word.
- * @param lang the language
- * @param country the optional country code (may be null or "none")
- * @param word the word to hyphenate
- * @param offset the offset of the first character in the "word" character array
- * @param len the length of the word
- * @param leftMin the minimum number of characters before the hyphenation point
- * @param rightMin the minimum number of characters after the hyphenation point
- * @return the hyphenation result
- */
- public static Hyphenation hyphenate(String lang, String country,
- char[] word, int offset, int len,
- int leftMin, int rightMin) {
- return hyphenate(lang, country, null, word, offset, len, leftMin, rightMin);
- }
-
- /**
- * Sets the minimum number of characters before the hyphenation point
- * @param min the number of characters
- */
- public void setMinRemainCharCount(int min) {
- remainCharCount = min;
- }
-
- /**
- * Sets the minimum number of characters after the hyphenation point
- * @param min the number of characters
- */
- public void setMinPushCharCount(int min) {
- pushCharCount = min;
- }
-
- /**
- * Sets the language and country for the hyphenation process.
- * @param lang the language
- * @param country the country (may be null or "none")
- */
- public void setLanguage(String lang, String country) {
- hyphenTree = getHyphenationTree(lang, country);
- }
-
- /**
- * Hyphenates a word.
- * @param word the word to hyphenate
- * @param offset the offset of the first character in the "word" character array
- * @param len the length of the word
- * @return the hyphenation result
- */
- public Hyphenation hyphenate(char[] word, int offset, int len) {
- if (hyphenTree == null) {
- return null;
- }
- return hyphenTree.hyphenate(word, offset, len, remainCharCount,
- pushCharCount);
- }
-
- /**
- * Hyphenates a word.
- * @param word the word to hyphenate
- * @return the hyphenation result
- */
- public Hyphenation hyphenate(String word) {
- if (hyphenTree == null) {
- return null;
- }
- return hyphenTree.hyphenate(word, remainCharCount, pushCharCount);
- }
-
}
diff --git a/src/java/org/apache/fop/hyphenation/PatternConsumer.java b/src/java/org/apache/fop/hyphenation/PatternConsumer.java
index 6263b5534..5fb80dcaa 100644
--- a/src/java/org/apache/fop/hyphenation/PatternConsumer.java
+++ b/src/java/org/apache/fop/hyphenation/PatternConsumer.java
@@ -44,6 +44,8 @@ public interface PatternConsumer {
* fails or the user wants to provide his own hyphenation.
* A hyphenatedword is a vector of alternating String's and
* {@link Hyphen Hyphen} instances
+ * @param word word to add as an exception
+ * @param hyphenatedword pre-hyphenated word
*/
void addException(String word, ArrayList hyphenatedword);
diff --git a/src/java/org/apache/fop/hyphenation/PatternParser.java b/src/java/org/apache/fop/hyphenation/PatternParser.java
index b34ab7ec8..404f10c7f 100644
--- a/src/java/org/apache/fop/hyphenation/PatternParser.java
+++ b/src/java/org/apache/fop/hyphenation/PatternParser.java
@@ -61,6 +61,10 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
static final int ELEM_PATTERNS = 3;
static final int ELEM_HYPHEN = 4;
+ /**
+ * Construct a pattern parser.
+ * @throws HyphenationException if a hyphenation exception is raised
+ */
public PatternParser() throws HyphenationException {
this.consumer = this;
token = new StringBuffer();
@@ -70,6 +74,11 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
hyphenChar = '-'; // default
}
+ /**
+ * Construct a pattern parser.
+ * @param consumer a pattern consumer
+ * @throws HyphenationException if a hyphenation exception is raised
+ */
public PatternParser(PatternConsumer consumer) throws HyphenationException {
this();
this.consumer = consumer;
@@ -130,7 +139,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
}
}
- protected String readToken(StringBuffer chars) {
+ private String readToken(StringBuffer chars) {
String word;
boolean space = false;
int i;
@@ -175,7 +184,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
return null;
}
- protected static String getPattern(String word) {
+ private static String getPattern(String word) {
StringBuffer pat = new StringBuffer();
int len = word.length();
for (int i = 0; i < len; i++) {
@@ -186,7 +195,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
return pat.toString();
}
- protected ArrayList normalizeException(ArrayList ex) {
+ private ArrayList normalizeException(ArrayList ex) {
ArrayList res = new ArrayList();
for (int i = 0; i < ex.size(); i++) {
Object item = ex.get(i);
@@ -217,7 +226,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
return res;
}
- protected String getExceptionWord(ArrayList ex) {
+ private String getExceptionWord(ArrayList ex) {
StringBuffer res = new StringBuffer();
for (int i = 0; i < ex.size(); i++) {
Object item = ex.get(i);
@@ -232,7 +241,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
return res.toString();
}
- protected static String getInterletterValues(String pat) {
+ private static String getInterletterValues(String pat) {
StringBuffer il = new StringBuffer();
String word = pat + "a"; // add dummy letter to serve as sentinel
int len = word.length();
@@ -248,6 +257,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
return il.toString();
}
+ /** @throws SAXException if not caught */
protected void getExternalClasses() throws SAXException {
XMLReader mainParser = parser;
parser = createParser();
@@ -263,14 +273,14 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
parser = mainParser;
}
}
-
+
//
// ContentHandler methods
//
/**
* {@inheritDoc}
- * @throws SAXException
+ * @throws SAXException
*/
public void startElement(String uri, String local, String raw,
Attributes attrs) throws SAXException {
@@ -328,6 +338,8 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
case ELEM_HYPHEN:
// nothing to do
break;
+ default:
+ break;
}
if (currElement != ELEM_HYPHEN) {
token.setLength(0);
@@ -347,7 +359,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
/**
* {@inheritDoc}
*/
- public void characters(char ch[], int start, int length) {
+ public void characters(char[] ch, int start, int length) {
StringBuffer chars = new StringBuffer(length);
chars.append(ch, start, length);
String word = readToken(chars);
@@ -368,6 +380,8 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
consumer.addPattern(getPattern(word),
getInterletterValues(word));
break;
+ default:
+ break;
}
word = readToken(chars);
}
@@ -426,33 +440,53 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
} // getLocationString(SAXParseException):String
- // PatternConsumer implementation for testing purposes
+ /**
+ * For testing purposes only.
+ * {@inheritDoc}
+ */
public void addClass(String c) {
testOut.println("class: " + c);
}
+ /**
+ * For testing purposes only.
+ * {@inheritDoc}
+ */
public void addException(String w, ArrayList e) {
testOut.println("exception: " + w + " : " + e.toString());
}
+ /**
+ * For testing purposes only.
+ * {@inheritDoc}
+ */
public void addPattern(String p, String v) {
testOut.println("pattern: " + p + " : " + v);
}
-
+
private PrintStream testOut = System.out;
-
+
/**
+ * Set test out stream.
* @param testOut the testOut to set
*/
public void setTestOut(PrintStream testOut) {
this.testOut = testOut;
}
-
+
+ /**
+ * Close test out file.
+ */
public void closeTestOut() {
testOut.flush();
testOut.close();
}
+ /**
+ * Main entry point when used as an application.
+ * @param args array of command line arguments
+ * @throws Exception in case of uncaught exception
+ */
public static void main(String[] args) throws Exception {
if (args.length > 0) {
PatternParser pp = new PatternParser();
@@ -469,5 +503,5 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
}
}
-
+
}
diff --git a/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java b/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java
index d2a259db0..067e2009e 100644
--- a/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java
+++ b/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java
@@ -27,10 +27,10 @@ import java.io.ObjectOutputStream;
/**
* Serialize hyphenation patterns
* For all xml files in the source directory a pattern file is built in the target directory
- * This class may be called from the ant build file in a java task
+ * This class may be called from the ant build file in a java task
*/
public class SerializeHyphPattern {
-
+
private boolean errorDump = false;
/**
diff --git a/src/java/org/apache/fop/hyphenation/TernaryTree.java b/src/java/org/apache/fop/hyphenation/TernaryTree.java
index 0824632a3..206b81f3f 100644
--- a/src/java/org/apache/fop/hyphenation/TernaryTree.java
+++ b/src/java/org/apache/fop/hyphenation/TernaryTree.java
@@ -75,6 +75,8 @@ public class TernaryTree implements Cloneable, Serializable {
* if it ain't broken, don't fix it.
*/
+ private static final long serialVersionUID = 3175412271203716160L;
+
/**
* Pointer to low branch and to rest of the key when it is
* stored directly in this node, we don't have unions in java!
@@ -107,16 +109,22 @@ public class TernaryTree implements Cloneable, Serializable {
*/
protected CharVector kv;
+ /** root */
protected char root;
+ /** free node */
protected char freenode;
- protected int length; // number of items in tree
+ /** number of items in tree */
+ protected int length;
- protected static final int BLOCK_SIZE = 2048; // allocation size for arrays
+ /** allocation size for arrays */
+ protected static final int BLOCK_SIZE = 2048;
+ /** default constructor */
TernaryTree() {
init();
}
+ /** initialize */
protected void init() {
root = 0;
freenode = 1;
@@ -135,6 +143,8 @@ public class TernaryTree implements Cloneable, Serializable {
* another key with same prefix
* is inserted. This saves a lot of space,
* specially for long keys.
+ * @param key the key
+ * @param val a value
*/
public void insert(String key, char val) {
// make sure we have enough room in the arrays
@@ -143,12 +153,18 @@ public class TernaryTree implements Cloneable, Serializable {
if (freenode + len > eq.length) {
redimNodeArrays(eq.length + BLOCK_SIZE);
}
- char strkey[] = new char[len--];
+ char[] strkey = new char[len--];
key.getChars(0, len, strkey, 0);
strkey[len] = 0;
root = insert(root, strkey, 0, val);
}
+ /**
+ * Insert key.
+ * @param key the key
+ * @param start offset into key array
+ * @param val a value
+ */
public void insert(char[] key, int start, char val) {
int len = strlen(key) + 1;
if (freenode + len > eq.length) {
@@ -232,6 +248,11 @@ public class TernaryTree implements Cloneable, Serializable {
/**
* Compares 2 null terminated char arrays
+ * @param a a character array
+ * @param startA an index into character array
+ * @param b a character array
+ * @param startB an index into character array
+ * @return an integer
*/
public static int strcmp(char[] a, int startA, char[] b, int startB) {
for (; a[startA] == b[startB]; startA++, startB++) {
@@ -244,6 +265,10 @@ public class TernaryTree implements Cloneable, Serializable {
/**
* Compares a string with null terminated char array
+ * @param str a string
+ * @param a a character array
+ * @param start an index into character array
+ * @return an integer
*/
public static int strcmp(String str, char[] a, int start) {
int i, d, len = str.length();
@@ -263,6 +288,12 @@ public class TernaryTree implements Cloneable, Serializable {
}
+ /**
+ * @param dst a character array
+ * @param di an index into character array
+ * @param src a character array
+ * @param si an index into character array
+ */
public static void strcpy(char[] dst, int di, char[] src, int si) {
while (src[si] != 0) {
dst[di++] = src[si++];
@@ -270,6 +301,11 @@ public class TernaryTree implements Cloneable, Serializable {
dst[di] = 0;
}
+ /**
+ * @param a a character array
+ * @param start an index into character array
+ * @return an integer
+ */
public static int strlen(char[] a, int start) {
int len = 0;
for (int i = start; i < a.length && a[i] != 0; i++) {
@@ -278,19 +314,34 @@ public class TernaryTree implements Cloneable, Serializable {
return len;
}
+ /**
+ * @param a a character array
+ * @return an integer
+ */
public static int strlen(char[] a) {
return strlen(a, 0);
}
+ /**
+ * Find key.
+ * @param key the key
+ * @return result
+ */
public int find(String key) {
int len = key.length();
- char strkey[] = new char[len + 1];
+ char[] strkey = new char[len + 1];
key.getChars(0, len, strkey, 0);
strkey[len] = 0;
return find(strkey, 0);
}
+ /**
+ * Find key.
+ * @param key the key
+ * @param start offset into key array
+ * @return result
+ */
public int find(char[] key, int start) {
int d;
char p = root;
@@ -322,6 +373,10 @@ public class TernaryTree implements Cloneable, Serializable {
return -1;
}
+ /**
+ * @param key a key
+ * @return trye if key present
+ */
public boolean knows(String key) {
return (find(key) >= 0);
}
@@ -343,10 +398,12 @@ public class TernaryTree implements Cloneable, Serializable {
sc = na;
}
+ /** @return length */
public int size() {
return length;
}
+ /** {@inheritDoc} */
public Object clone() {
TernaryTree t = new TernaryTree();
t.lo = (char[])this.lo.clone();
@@ -366,6 +423,10 @@ public class TernaryTree implements Cloneable, Serializable {
* lower and upper halves, and so on in order to get a balanced
* tree. The array of keys is assumed to be sorted in ascending
* order.
+ * @param k array of keys
+ * @param v array of values
+ * @param offset where to insert
+ * @param n count to insert
*/
protected void insertBalanced(String[] k, char[] v, int offset, int n) {
int m;
@@ -453,37 +514,47 @@ public class TernaryTree implements Cloneable, Serializable {
}
}
-
+ /** @return the keys */
public Enumeration keys() {
return new Iterator();
}
+ /** an iterator */
public class Iterator implements Enumeration {
/**
* current node index
*/
- int cur;
+ int cur; // CSOK: VisibilityModifier
/**
* current key
*/
- String curkey;
+ String curkey; // CSOK: VisibilityModifier
private class Item implements Cloneable {
- char parent;
- char child;
+ /** parent */
+ char parent; // CSOK: VisibilityModifier
+ /** child */
+ char child; // CSOK: VisibilityModifier
+ /** default constructor */
public Item() {
parent = 0;
child = 0;
}
+ /**
+ * Construct item.
+ * @param p a char
+ * @param c a char
+ */
public Item(char p, char c) {
parent = p;
child = c;
}
+ /** {@inheritDoc} */
public Object clone() {
return new Item(parent, child);
}
@@ -493,13 +564,14 @@ public class TernaryTree implements Cloneable, Serializable {
/**
* Node stack
*/
- Stack ns;
+ Stack ns; // CSOK: VisibilityModifier
/**
* key stack implemented with a StringBuffer
*/
- StringBuffer ks;
+ StringBuffer ks; // CSOK: VisibilityModifier
+ /** default constructor */
public Iterator() {
cur = -1;
ns = new Stack();
@@ -507,6 +579,7 @@ public class TernaryTree implements Cloneable, Serializable {
rewind();
}
+ /** rewind iterator */
public void rewind() {
ns.removeAllElements();
ks.setLength(0);
@@ -514,6 +587,7 @@ public class TernaryTree implements Cloneable, Serializable {
run();
}
+ /** @return next element */
public Object nextElement() {
String res = new String(curkey);
cur = up();
@@ -521,6 +595,7 @@ public class TernaryTree implements Cloneable, Serializable {
return res;
}
+ /** @return value */
public char getValue() {
if (cur >= 0) {
return eq[cur];
@@ -528,6 +603,7 @@ public class TernaryTree implements Cloneable, Serializable {
return 0;
}
+ /** @return true if more elements */
public boolean hasMoreElements() {
return (cur != -1);
}
@@ -633,6 +709,9 @@ public class TernaryTree implements Cloneable, Serializable {
}
+ /**
+ * Print stats (for testing).
+ */
public void printStats() {
System.out.println("Number of keys = " + Integer.toString(length));
System.out.println("Node count = " + Integer.toString(freenode));
@@ -653,6 +732,11 @@ public class TernaryTree implements Cloneable, Serializable {
}
+ /**
+ * Main entry point for testing.
+ * @param args not used
+ * @throws Exception if not caught
+ */
public static void main(String[] args) throws Exception {
TernaryTree tt = new TernaryTree();
tt.insert("Carlos", 'C');
diff --git a/src/java/org/apache/fop/image/loader/batik/BatikUtil.java b/src/java/org/apache/fop/image/loader/batik/BatikUtil.java
index 20a7bf767..c5b6264b4 100644
--- a/src/java/org/apache/fop/image/loader/batik/BatikUtil.java
+++ b/src/java/org/apache/fop/image/loader/batik/BatikUtil.java
@@ -27,7 +27,10 @@ import org.apache.batik.dom.util.DOMUtilities;
/**
* Helper utilities for Apache Batik.
*/
-public class BatikUtil {
+public final class BatikUtil {
+
+ private BatikUtil() {
+ }
/**
* Checks whether Apache Batik is available in the classpath.
diff --git a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
index 9efc2aaf0..0b7989fb2 100644
--- a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
+++ b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
@@ -33,6 +33,7 @@ import org.apache.batik.gvt.GraphicsNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.image.GraphicsConstants;
import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageException;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
@@ -72,7 +73,7 @@ public class ImageConverterSVG2G2D extends AbstractImageConverter {
}
//Prepare
- float pxToMillimeter = UnitConv.IN2MM / 72; //default: 72dpi
+ float pxToMillimeter = UnitConv.IN2MM / GraphicsConstants.DEFAULT_DPI;
Number ptm = (Number)hints.get(ImageProcessingHints.SOURCE_RESOLUTION);
if (ptm != null) {
pxToMillimeter = (float)(UnitConv.IN2MM / ptm.doubleValue());
diff --git a/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java b/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java
index 5e4e37345..c675e3cfc 100644
--- a/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java
+++ b/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java
@@ -102,7 +102,11 @@ public class PreloaderSVG extends AbstractImagePreloader {
* attempt to load Batik related classes when constructing the SVGPreloader
* class.
*/
- class Loader {
+ private final class Loader {
+
+ private Loader() {
+ }
+
private ImageInfo getImage(String uri, Source src,
ImageContext context) {
// parse document and get the size attributes of the svg element
diff --git a/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java b/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java
index 4e78f8193..8bda04903 100644
--- a/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java
+++ b/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java
@@ -78,7 +78,11 @@ public class PreloaderWMF extends AbstractImagePreloader {
* attempt to load Batik related classes when constructing the WMFPreloader
* class.
*/
- class Loader {
+ private final class Loader {
+
+ private Loader() {
+ }
+
private ImageInfo getImage(String uri, Source src,
ImageContext context) {
// parse document and get the size attributes of the svg element
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
index 07c2a3d36..402161a92 100644
--- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
+++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
@@ -40,17 +40,21 @@ import org.apache.fop.util.ListUtil;
public abstract class AbstractBreaker {
/** logging instance */
- protected static Log log = LogFactory.getLog(AbstractBreaker.class);
+ protected static final Log log = LogFactory.getLog(AbstractBreaker.class);
+ /**
+ * A page break position.
+ */
public static class PageBreakPosition extends LeafPosition {
- double bpdAdjust; // Percentage to adjust (stretch or shrink)
- int difference;
- int footnoteFirstListIndex;
- int footnoteFirstElementIndex;
- int footnoteLastListIndex;
- int footnoteLastElementIndex;
-
- PageBreakPosition(LayoutManager lm, int breakIndex,
+ // Percentage to adjust (stretch or shrink)
+ double bpdAdjust; // CSOK: VisibilityModifier
+ int difference; // CSOK: VisibilityModifier
+ int footnoteFirstListIndex; // CSOK: VisibilityModifier
+ int footnoteFirstElementIndex; // CSOK: VisibilityModifier
+ int footnoteLastListIndex; // CSOK: VisibilityModifier
+ int footnoteLastElementIndex; // CSOK: VisibilityModifier
+
+ PageBreakPosition(LayoutManager lm, int breakIndex, // CSOK: ParameterNumber
int ffli, int ffei, int flli, int flei,
double bpdA, int diff) {
super(lm, breakIndex);
@@ -89,10 +93,12 @@ public abstract class AbstractBreaker {
*/
public class BlockSequence extends BlockKnuthSequence {
+ private static final long serialVersionUID = -5348831120146774118L;
+
/** Number of elements to ignore at the beginning of the list. */
- public int ignoreAtStart = 0;
+ int ignoreAtStart = 0; // CSOK: VisibilityModifier
/** Number of elements to ignore at the end of the list. */
- public int ignoreAtEnd = 0;
+ int ignoreAtEnd = 0; // CSOK: VisibilityModifier
/**
* startOn represents where on the page/which page layout
@@ -193,20 +199,39 @@ public abstract class AbstractBreaker {
}
- /** blockListIndex of the current BlockSequence in blockLists */
- private int blockListIndex = 0;
+ // used by doLayout and getNextBlockList*
+ private List<BlockSequence> blockLists;
- private List blockLists = null;
+ private boolean empty = true;
+ /** desired text alignment */
protected int alignment;
+
private int alignmentLast;
+ /** footnote separator length */
protected MinOptMax footnoteSeparatorLength = MinOptMax.ZERO;
+ /** @return current display alignment */
protected abstract int getCurrentDisplayAlign();
+
+ /** @return true if content not exhausted */
protected abstract boolean hasMoreContent();
+
+ /**
+ * Tell the layout manager to add all the child areas implied
+ * by Position objects which will be returned by the
+ * Iterator.
+ *
+ * @param posIter the position iterator
+ * @param context the context
+ */
protected abstract void addAreas(PositionIterator posIter, LayoutContext context);
+
+ /** @return top level layout manager */
protected abstract LayoutManager getTopLevelLM();
+
+ /** @return current child layout manager */
protected abstract LayoutManager getCurrentChildLM();
/**
@@ -244,23 +269,43 @@ public abstract class AbstractBreaker {
return null;
}
- /*
- * This method is to contain the logic to determine the LM's
- * getNextKnuthElements() implementation(s) that are to be called.
- * @return LinkedList of Knuth elements.
+ /**
+ * Get a sequence of KnuthElements representing the content
+ * of the node assigned to the LM
+ *
+ * @param context the LayoutContext used to store layout information
+ * @param alignment the desired text alignment
+ * @return the list of KnuthElements
*/
- protected abstract List getNextKnuthElements(LayoutContext context, int alignment);
+ protected abstract List<KnuthElement> getNextKnuthElements(LayoutContext context,
+ int alignment);
- protected List getNextKnuthElements(LayoutContext context, int alignment,
+ /**
+ * Get a sequence of KnuthElements representing the content
+ * of the node assigned to the LM
+ *
+ * @param context the LayoutContext used to store layout information
+ * @param alignment the desired text alignment
+ * @param positionAtIPDChange last element on the part before an IPD change
+ * @param restartAtLM the layout manager from which to restart, if IPD
+ * change occurs between two LMs
+ * @return the list of KnuthElements
+ */
+ protected List<KnuthElement> getNextKnuthElements(LayoutContext context, int alignment,
Position positionAtIPDChange, LayoutManager restartAtLM) {
throw new UnsupportedOperationException("TODO: implement acceptable fallback");
}
/** @return true if there's no content that could be handled. */
public boolean isEmpty() {
- return (this.blockLists.isEmpty());
+ return empty;
}
+ /**
+ * Start part.
+ * @param list a block sequence
+ * @param breakClass a break class
+ */
protected void startPart(BlockSequence list, int breakClass) {
//nop
}
@@ -272,6 +317,11 @@ public abstract class AbstractBreaker {
//nop
}
+ /**
+ * Finish part.
+ * @param alg a page breaking algorithm
+ * @param pbp a page break posittion
+ */
protected abstract void finishPart(PageBreakingAlgorithm alg, PageBreakPosition pbp);
/**
@@ -325,21 +375,22 @@ public abstract class AbstractBreaker {
childLC.setBPAlignment(alignment);
BlockSequence blockList;
- this.blockLists = new java.util.ArrayList();
+ blockLists = new java.util.ArrayList<BlockSequence>();
log.debug("PLM> flow BPD =" + flowBPD);
- //*** Phase 1: Get Knuth elements ***
int nextSequenceStartsOn = Constants.EN_ANY;
while (hasMoreContent()) {
blockLists.clear();
+ //*** Phase 1: Get Knuth elements ***
nextSequenceStartsOn = getNextBlockList(childLC, nextSequenceStartsOn);
+ empty = empty && blockLists.size() == 0;
- //*** Phase 2: Alignment and breaking ***
+ //*** Phases 2 and 3 ***
log.debug("PLM> blockLists.size() = " + blockLists.size());
- for (blockListIndex = 0; blockListIndex < blockLists.size(); blockListIndex++) {
- blockList = (BlockSequence) blockLists.get(blockListIndex);
+ for (int blockListIndex = 0; blockListIndex < blockLists.size(); blockListIndex++) {
+ blockList = blockLists.get(blockListIndex);
//debug code start
if (log.isDebugEnabled()) {
@@ -349,12 +400,13 @@ public abstract class AbstractBreaker {
observeElementList(blockList);
//debug code end
+ //*** Phase 2: Alignment and breaking ***
log.debug("PLM> start of algorithm (" + this.getClass().getName()
+ "), flow BPD =" + flowBPD);
PageBreakingAlgorithm alg = new PageBreakingAlgorithm(getTopLevelLM(),
- getPageProvider(), createLayoutListener(),
- alignment, alignmentLast, footnoteSeparatorLength,
- isPartOverflowRecoveryActivated(), autoHeight, isSinglePartFavored());
+ getPageProvider(), createLayoutListener(),
+ alignment, alignmentLast, footnoteSeparatorLength,
+ isPartOverflowRecoveryActivated(), autoHeight, isSinglePartFavored());
BlockSequence effectiveList;
if (getCurrentDisplayAlign() == Constants.EN_X_FILL) {
@@ -369,89 +421,25 @@ public abstract class AbstractBreaker {
int optimalPageCount = alg.findBreakingPoints(effectiveList, 1, true,
BreakingAlgorithm.ALL_BREAKS);
if (alg.getIPDdifference() != 0) {
- KnuthNode optimalBreak = alg.getBestNodeBeforeIPDChange();
- int positionIndex = optimalBreak.position;
- KnuthElement elementAtBreak = alg.getElement(positionIndex);
- Position positionAtBreak = elementAtBreak.getPosition();
- if (!(positionAtBreak instanceof SpaceResolver.SpaceHandlingBreakPosition)) {
- throw new UnsupportedOperationException(
- "Don't know how to restart at position" + positionAtBreak);
- }
- /* Retrieve the original position wrapped into this space position */
- positionAtBreak = positionAtBreak.getPosition();
- LayoutManager restartAtLM = null;
- List firstElements = Collections.EMPTY_LIST;
- if (containsNonRestartableLM(positionAtBreak)) {
- if (alg.getIPDdifference() > 0) {
- EventBroadcaster eventBroadcaster = getCurrentChildLM().getFObj()
- .getUserAgent().getEventBroadcaster();
- BlockLevelEventProducer eventProducer
- = BlockLevelEventProducer.Provider.get(eventBroadcaster);
- eventProducer.nonRestartableContentFlowingToNarrowerPage(this);
- }
- firstElements = new LinkedList();
- boolean boxFound = false;
- Iterator iter = effectiveList.listIterator(positionIndex + 1);
- Position position = null;
- while (iter.hasNext()
- && (position == null || containsNonRestartableLM(position))) {
- positionIndex++;
- KnuthElement element = (KnuthElement) iter.next();
- position = element.getPosition();
- if (element.isBox()) {
- boxFound = true;
- firstElements.add(element);
- } else if (boxFound) {
- firstElements.add(element);
- }
- }
- if (position instanceof SpaceResolver.SpaceHandlingBreakPosition) {
- /* Retrieve the original position wrapped into this space position */
- positionAtBreak = position.getPosition();
- } else {
- positionAtBreak = null;
- }
- }
- if (positionAtBreak != null && positionAtBreak.getIndex() == -1) {
- /*
- * This is an indication that we are between two blocks
- * (possibly surrounded by another block), not inside a
- * paragraph.
- */
- Position position;
- Iterator iter = effectiveList.listIterator(positionIndex + 1);
- do {
- KnuthElement nextElement = (KnuthElement) iter.next();
- position = nextElement.getPosition();
- } while (position == null
- || position instanceof SpaceResolver.SpaceHandlingPosition
- || position instanceof SpaceResolver.SpaceHandlingBreakPosition
- && position.getPosition().getIndex() == -1);
- LayoutManager surroundingLM = positionAtBreak.getLM();
- while (position.getLM() != surroundingLM) {
- position = position.getPosition();
- }
- restartAtLM = position.getPosition().getLM();
- }
- log.trace("IPD changes after page " + optimalPageCount + " at index "
- + optimalBreak.position);
addAreas(alg, optimalPageCount, blockList, effectiveList);
-
+ // *** redo Phase 1 ***
+ log.trace("IPD changes after page " + optimalPageCount);
blockLists.clear();
+ nextSequenceStartsOn = getNextBlockListChangedIPD(childLC, alg,
+ effectiveList);
blockListIndex = -1;
- nextSequenceStartsOn = getNextBlockList(childLC, Constants.EN_COLUMN,
- positionAtBreak, restartAtLM, firstElements);
} else {
log.debug("PLM> iOptPageCount= " + optimalPageCount
+ " pageBreaks.size()= " + alg.getPageBreaks().size());
-
//*** Phase 3: Add areas ***
doPhase3(alg, optimalPageCount, blockList, effectiveList);
}
}
}
+ // done
+ blockLists = null;
}
/**
@@ -509,7 +497,6 @@ public abstract class AbstractBreaker {
BlockSequence originalList, BlockSequence effectiveList) {
LayoutContext childLC;
// add areas
- ListIterator effectiveListIterator = effectiveList.listIterator();
int startElementIndex = 0;
int endElementIndex = 0;
int lastBreak = -1;
@@ -567,11 +554,10 @@ public abstract class AbstractBreaker {
// ignore KnuthGlue and KnuthPenalty objects
// at the beginning of the line
- effectiveListIterator = effectiveList
- .listIterator(startElementIndex);
+ ListIterator<KnuthElement> effectiveListIterator
+ = effectiveList.listIterator(startElementIndex);
while (effectiveListIterator.hasNext()
- && !((KnuthElement) effectiveListIterator.next())
- .isBox()) {
+ && !(effectiveListIterator.next()).isBox()) {
startElementIndex++;
}
@@ -594,10 +580,9 @@ public abstract class AbstractBreaker {
&& p < (partCount - 1)) {
// count the boxes whose width is not 0
int boxCount = 0;
- effectiveListIterator = effectiveList
- .listIterator(startElementIndex);
+ effectiveListIterator = effectiveList.listIterator(startElementIndex);
while (effectiveListIterator.nextIndex() <= endElementIndex) {
- KnuthElement tempEl = (KnuthElement)effectiveListIterator.next();
+ KnuthElement tempEl = effectiveListIterator.next();
if (tempEl.isBox() && tempEl.getWidth() > 0) {
boxCount++;
}
@@ -661,8 +646,7 @@ public abstract class AbstractBreaker {
* @param nextSequenceStartsOn indicates on what page the next sequence should start
* @return the page on which the next content should appear after a hard break
*/
- protected int getNextBlockList(LayoutContext childLC,
- int nextSequenceStartsOn) {
+ protected int getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn) {
return getNextBlockList(childLC, nextSequenceStartsOn, null, null, null);
}
@@ -681,13 +665,14 @@ public abstract class AbstractBreaker {
* break
*/
protected int getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn,
- Position positionAtIPDChange, LayoutManager restartAtLM, List firstElements) {
+ Position positionAtIPDChange, LayoutManager restartAtLM,
+ List<KnuthElement> firstElements) {
updateLayoutContext(childLC);
//Make sure the span change signal is reset
childLC.signalSpanChange(Constants.NOT_SET);
BlockSequence blockList;
- List returnedList;
+ List<KnuthElement> returnedList;
if (firstElements == null) {
returnedList = getNextKnuthElements(childLC, alignment);
} else if (positionAtIPDChange == null) {
@@ -749,13 +734,93 @@ public abstract class AbstractBreaker {
BlockSequence seq;
seq = blockList.endBlockSequence(breakPosition);
if (seq != null) {
- this.blockLists.add(seq);
+ blockLists.add(seq);
}
}
return nextSequenceStartsOn;
}
/**
+ * @param childLC LayoutContext to use
+ * @param alg the pagebreaking algorithm
+ * @param effectiveList the list of Knuth elements to be reused
+ * @return the page on which the next content should appear after a hard break
+ */
+ private int getNextBlockListChangedIPD(LayoutContext childLC, PageBreakingAlgorithm alg,
+ BlockSequence effectiveList) {
+ int nextSequenceStartsOn;
+ KnuthNode optimalBreak = alg.getBestNodeBeforeIPDChange();
+ int positionIndex = optimalBreak.position;
+ log.trace("IPD changes at index " + positionIndex);
+ KnuthElement elementAtBreak = alg.getElement(positionIndex);
+ Position positionAtBreak = elementAtBreak.getPosition();
+ if (!(positionAtBreak instanceof SpaceResolver.SpaceHandlingBreakPosition)) {
+ throw new UnsupportedOperationException(
+ "Don't know how to restart at position" + positionAtBreak);
+ }
+ /* Retrieve the original position wrapped into this space position */
+ positionAtBreak = positionAtBreak.getPosition();
+ LayoutManager restartAtLM = null;
+ List<KnuthElement> firstElements = Collections.EMPTY_LIST;
+ if (containsNonRestartableLM(positionAtBreak)) {
+ if (alg.getIPDdifference() > 0) {
+ EventBroadcaster eventBroadcaster = getCurrentChildLM().getFObj()
+ .getUserAgent().getEventBroadcaster();
+ BlockLevelEventProducer eventProducer
+ = BlockLevelEventProducer.Provider.get(eventBroadcaster);
+ eventProducer.nonRestartableContentFlowingToNarrowerPage(this);
+ }
+ firstElements = new LinkedList<KnuthElement>();
+ boolean boxFound = false;
+ Iterator<KnuthElement> iter = effectiveList.listIterator(positionIndex + 1);
+ Position position = null;
+ while (iter.hasNext()
+ && (position == null || containsNonRestartableLM(position))) {
+ positionIndex++;
+ KnuthElement element = iter.next();
+ position = element.getPosition();
+ if (element.isBox()) {
+ boxFound = true;
+ firstElements.add(element);
+ } else if (boxFound) {
+ firstElements.add(element);
+ }
+ }
+ if (position instanceof SpaceResolver.SpaceHandlingBreakPosition) {
+ /* Retrieve the original position wrapped into this space position */
+ positionAtBreak = position.getPosition();
+ } else {
+ positionAtBreak = null;
+ }
+ }
+ if (positionAtBreak != null && positionAtBreak.getIndex() == -1) {
+ /*
+ * This is an indication that we are between two blocks
+ * (possibly surrounded by another block), not inside a
+ * paragraph.
+ */
+ Position position;
+ Iterator<KnuthElement> iter = effectiveList.listIterator(positionIndex + 1);
+ do {
+ KnuthElement nextElement = iter.next();
+ position = nextElement.getPosition();
+ } while (position == null
+ || position instanceof SpaceResolver.SpaceHandlingPosition
+ || position instanceof SpaceResolver.SpaceHandlingBreakPosition
+ && position.getPosition().getIndex() == -1);
+ LayoutManager surroundingLM = positionAtBreak.getLM();
+ while (position.getLM() != surroundingLM) {
+ position = position.getPosition();
+ }
+ restartAtLM = position.getPosition().getLM();
+ }
+
+ nextSequenceStartsOn = getNextBlockList(childLC, Constants.EN_COLUMN,
+ positionAtBreak, restartAtLM, firstElements);
+ return nextSequenceStartsOn;
+ }
+
+ /**
* Returns the average width of all the lines in the given range.
* @param effectiveList effective block list to work on
* @param startElementIndex index of the element starting the range
@@ -764,15 +829,14 @@ public abstract class AbstractBreaker {
*/
private int optimizeLineLength(KnuthSequence effectiveList, int startElementIndex,
int endElementIndex) {
- ListIterator effectiveListIterator;
+ ListIterator<KnuthElement> effectiveListIterator;
// optimize line length
int boxCount = 0;
int accumulatedLineLength = 0;
int greatestMinimumLength = 0;
- effectiveListIterator = effectiveList
- .listIterator(startElementIndex);
+ effectiveListIterator = effectiveList.listIterator(startElementIndex);
while (effectiveListIterator.nextIndex() <= endElementIndex) {
- KnuthElement tempEl = (KnuthElement) effectiveListIterator
+ KnuthElement tempEl = effectiveListIterator
.next();
if (tempEl instanceof KnuthBlockBox) {
KnuthBlockBox blockBox = (KnuthBlockBox) tempEl;
@@ -809,8 +873,8 @@ public abstract class AbstractBreaker {
* @param availableBPD the available BPD
* @return the effective list
*/
- private BlockSequence justifyBoxes(BlockSequence blockList, PageBreakingAlgorithm alg,
- int availableBPD) {
+ private BlockSequence justifyBoxes // CSOK: MethodLength
+ (BlockSequence blockList, PageBreakingAlgorithm alg, int availableBPD) {
int iOptPageNumber;
alg.setConstantLineWidth(availableBPD);
iOptPageNumber = alg.findBreakingPoints(blockList, /*availableBPD,*/
@@ -818,23 +882,20 @@ public abstract class AbstractBreaker {
log.debug("PLM> iOptPageNumber= " + iOptPageNumber);
//
- ListIterator sequenceIterator = blockList.listIterator();
- ListIterator breakIterator = alg.getPageBreaks().listIterator();
+ ListIterator<KnuthElement> sequenceIterator = blockList.listIterator();
+ ListIterator<PageBreakPosition> breakIterator = alg.getPageBreaks().listIterator();
KnuthElement thisElement = null;
PageBreakPosition thisBreak;
- int accumulatedS; // accumulated stretch or shrink
int adjustedDiff; // difference already adjusted
- int firstElementIndex;
while (breakIterator.hasNext()) {
- thisBreak = (PageBreakPosition) breakIterator.next();
+ thisBreak = breakIterator.next();
if (log.isDebugEnabled()) {
log.debug("| first page: break= "
+ thisBreak.getLeafPos() + " difference= "
+ thisBreak.difference + " ratio= "
+ thisBreak.bpdAdjust);
}
- accumulatedS = 0;
adjustedDiff = 0;
// glue and penalty items at the beginning of the page must
@@ -843,52 +904,53 @@ public abstract class AbstractBreaker {
// inside the
// while loop must be a box
KnuthElement firstElement;
- while (!(firstElement = (KnuthElement) sequenceIterator
- .next()).isBox()) {
- //
- log.debug("PLM> ignoring glue or penalty element "
- + "at the beginning of the sequence");
- if (firstElement.isGlue()) {
- ((BlockLevelLayoutManager) firstElement
- .getLayoutManager())
+ while ( sequenceIterator.hasNext() ) {
+ firstElement = sequenceIterator.next();
+ if ( !firstElement.isBox() ) {
+ log.debug("PLM> ignoring glue or penalty element "
+ + "at the beginning of the sequence");
+ if (firstElement.isGlue()) {
+ ((BlockLevelLayoutManager) firstElement
+ .getLayoutManager())
.discardSpace((KnuthGlue) firstElement);
+ }
+ } else {
+ break;
}
}
- firstElementIndex = sequenceIterator.previousIndex();
sequenceIterator.previous();
// scan the sub-sequence representing a page,
// collecting information about potential adjustments
MinOptMax lineNumberMaxAdjustment = MinOptMax.ZERO;
MinOptMax spaceMaxAdjustment = MinOptMax.ZERO;
- double spaceAdjustmentRatio = 0.0;
- LinkedList blockSpacesList = new LinkedList();
- LinkedList unconfirmedList = new LinkedList();
- LinkedList adjustableLinesList = new LinkedList();
+ LinkedList<KnuthGlue> blockSpacesList = new LinkedList<KnuthGlue>();
+ LinkedList<KnuthGlue> unconfirmedList = new LinkedList<KnuthGlue>();
+ LinkedList<KnuthGlue> adjustableLinesList = new LinkedList<KnuthGlue>();
boolean bBoxSeen = false;
while (sequenceIterator.hasNext()
- && sequenceIterator.nextIndex() <= thisBreak
- .getLeafPos()) {
- thisElement = (KnuthElement) sequenceIterator.next();
+ && sequenceIterator.nextIndex() <= thisBreak.getLeafPos()) {
+ thisElement = sequenceIterator.next();
if (thisElement.isGlue()) {
// glue elements are used to represent adjustable
// lines
// and adjustable spaces between blocks
- Adjustment adjustment = ((KnuthGlue) thisElement).getAdjustmentClass();
+ KnuthGlue thisGlue = (KnuthGlue) thisElement;
+ Adjustment adjustment = thisGlue.getAdjustmentClass();
if (adjustment.equals(Adjustment.SPACE_BEFORE_ADJUSTMENT)
|| adjustment.equals(Adjustment.SPACE_AFTER_ADJUSTMENT)) {
// potential space adjustment
// glue items before the first box or after the
// last one
// must be ignored
- unconfirmedList.add(thisElement);
+ unconfirmedList.add(thisGlue);
} else if (adjustment.equals(Adjustment.LINE_NUMBER_ADJUSTMENT)) {
// potential line number adjustment
lineNumberMaxAdjustment
= lineNumberMaxAdjustment.plusMax(thisElement.getStretch());
lineNumberMaxAdjustment
= lineNumberMaxAdjustment.minusMin(thisElement.getShrink());
- adjustableLinesList.add(thisElement);
+ adjustableLinesList.add(thisGlue);
} else if (adjustment.equals(Adjustment.LINE_HEIGHT_ADJUSTMENT)) {
// potential line height adjustment
}
@@ -902,10 +964,11 @@ public abstract class AbstractBreaker {
// the last box
// in this page; they must be added to
// blockSpaceList
- KnuthGlue blockSpace = (KnuthGlue) unconfirmedList
- .removeFirst();
- spaceMaxAdjustment = spaceMaxAdjustment.plusMax(blockSpace.getStretch());
- spaceMaxAdjustment = spaceMaxAdjustment.minusMin(blockSpace.getShrink());
+ KnuthGlue blockSpace = unconfirmedList.removeFirst();
+ spaceMaxAdjustment
+ = spaceMaxAdjustment.plusMax(blockSpace.getStretch());
+ spaceMaxAdjustment
+ = spaceMaxAdjustment.minusMin(blockSpace.getShrink());
blockSpacesList.add(blockSpace);
}
}
@@ -929,9 +992,6 @@ public abstract class AbstractBreaker {
|| (thisBreak.difference < 0 && thisBreak.difference >= spaceMaxAdjustment
.getMin())) {
// modify only the spaces between blocks
- spaceAdjustmentRatio = ((double) thisBreak.difference / (thisBreak.difference > 0
- ? spaceMaxAdjustment.getMax()
- : spaceMaxAdjustment.getMin()));
adjustedDiff += adjustBlockSpaces(
blockSpacesList,
thisBreak.difference,
@@ -978,16 +1038,16 @@ public abstract class AbstractBreaker {
return effectiveList;
}
- private int adjustBlockSpaces(LinkedList spaceList, int difference, int total) {
+ private int adjustBlockSpaces(LinkedList<KnuthGlue> spaceList, int difference, int total) {
if (log.isDebugEnabled()) {
log.debug("AdjustBlockSpaces: difference " + difference + " / " + total
+ " on " + spaceList.size() + " spaces in block");
}
- ListIterator spaceListIterator = spaceList.listIterator();
+ ListIterator<KnuthGlue> spaceListIterator = spaceList.listIterator();
int adjustedDiff = 0;
int partial = 0;
while (spaceListIterator.hasNext()) {
- KnuthGlue blockSpace = (KnuthGlue)spaceListIterator.next();
+ KnuthGlue blockSpace = spaceListIterator.next();
partial += (difference > 0 ? blockSpace.getStretch() : blockSpace.getShrink());
if (log.isDebugEnabled()) {
log.debug("available = " + partial + " / " + total);
@@ -995,24 +1055,34 @@ public abstract class AbstractBreaker {
+ (((int)((float) partial * difference / total)) - adjustedDiff)
+ " / " + difference);
}
- int newAdjust = ((BlockLevelLayoutManager) blockSpace.getLayoutManager()).negotiateBPDAdjustment(((int) ((float) partial * difference / total)) - adjustedDiff, blockSpace);
+ int newAdjust = ((BlockLevelLayoutManager) blockSpace.getLayoutManager())
+ .negotiateBPDAdjustment
+ (((int) ((float) partial * difference / total)) - adjustedDiff, blockSpace);
adjustedDiff += newAdjust;
}
return adjustedDiff;
}
- private int adjustLineNumbers(LinkedList lineList, int difference, int total) {
+ private int adjustLineNumbers(LinkedList<KnuthGlue> lineList, int difference, int total) {
if (log.isDebugEnabled()) {
- log.debug("AdjustLineNumbers: difference " + difference + " / " + total + " on " + lineList.size() + " elements");
+ log.debug("AdjustLineNumbers: difference "
+ + difference
+ + " / "
+ + total
+ + " on "
+ + lineList.size()
+ + " elements");
}
- ListIterator lineListIterator = lineList.listIterator();
+ ListIterator<KnuthGlue> lineListIterator = lineList.listIterator();
int adjustedDiff = 0;
int partial = 0;
while (lineListIterator.hasNext()) {
- KnuthGlue line = (KnuthGlue)lineListIterator.next();
+ KnuthGlue line = lineListIterator.next();
partial += (difference > 0 ? line.getStretch() : line.getShrink());
- int newAdjust = ((BlockLevelLayoutManager) line.getLayoutManager()).negotiateBPDAdjustment(((int) ((float) partial * difference / total)) - adjustedDiff, line);
+ int newAdjust = ((BlockLevelLayoutManager) line.getLayoutManager())
+ .negotiateBPDAdjustment
+ (((int) ((float) partial * difference / total)) - adjustedDiff, line);
adjustedDiff += newAdjust;
}
return adjustedDiff;
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
index 1f91cef1a..ae230e261 100644
--- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
@@ -123,6 +123,10 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager
return null;
}
+ /**
+ * Set currently active child layout manager.
+ * @param childLM the child layout manager
+ */
protected void setCurrentChildLM(LayoutManager childLM) {
curChildLM = childLM;
childLMiter = new LMiter(this);
diff --git a/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java
index 0fa046aee..fba571df3 100644
--- a/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java
@@ -275,8 +275,8 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa
/**
* Makes a new page
*
- * @param bIsBlank whether this page is blank or not
- * @param bIsLast whether this page is the last page or not
+ * @param isBlank whether this page is blank or not
+ * @param isLast whether this page is the last page or not
* @return a new page
*/
protected Page makeNewPage(boolean isBlank, boolean isLast) {
@@ -293,6 +293,7 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa
+ (isBlank ? "*" : "") + "]");
}
+ addIDToPage(pageSeq.getRoot().getId());
addIDToPage(pageSeq.getId());
return curPage;
}
diff --git a/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java b/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
index 14183c52e..755be91d1 100644
--- a/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
+++ b/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
@@ -27,7 +27,10 @@ import org.apache.fop.layoutmgr.SpaceResolver.SpaceHandlingBreakPosition;
/**
* Utility class which provides common code for the addAreas stage.
*/
-public class AreaAdditionUtil {
+public final class AreaAdditionUtil {
+
+ private AreaAdditionUtil() {
+ }
private static class StackingIter extends PositionIterator {
StackingIter(Iterator parentIter) {
diff --git a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java
index 2bb499a36..0eae6fa9c 100644
--- a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java
+++ b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java
@@ -21,6 +21,8 @@ package org.apache.fop.layoutmgr;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.fo.Constants;
import org.apache.fop.traits.MinOptMax;
/**
@@ -29,13 +31,32 @@ import org.apache.fop.traits.MinOptMax;
*/
public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm {
- private Log log = LogFactory.getLog(BalancingColumnBreakingAlgorithm.class);
+ private static final Log LOG = LogFactory.getLog(BalancingColumnBreakingAlgorithm.class);
private int columnCount;
private int fullLen;
private int idealPartLen;
- public BalancingColumnBreakingAlgorithm(LayoutManager topLevelLM,
+ /**
+ * Construct a balancing column breaking algorithm.
+ * @param topLevelLM the top level layout manager
+ * @param pageProvider the page provider
+ * @param layoutListener the layout listener
+ * @param alignment alignment of the paragraph/page. One of {@link Constants#EN_START},
+ * {@link Constants#EN_JUSTIFY}, {@link Constants#EN_CENTER},
+ * {@link Constants#EN_END}.
+ * For pages, {@link Constants#EN_BEFORE} and {@link Constants#EN_AFTER}
+ * are mapped to the corresponding inline properties,
+ * {@link Constants#EN_START} and {@link Constants#EN_END}.
+ * @param alignmentLast alignment of the paragraph's last line
+ * @param footnoteSeparatorLength length of footnote separator
+ * @param partOverflowRecovery {@code true} if too long elements should be moved to
+ * the next line/part
+ * @param columnCount number of columns
+ * @see PageBreakingAlgorithm
+ */
+ public BalancingColumnBreakingAlgorithm( // CSOK: ParameterNumber
+ LayoutManager topLevelLM,
PageProvider pageProvider,
PageBreakingLayoutListener layoutListener,
int alignment, int alignmentLast,
@@ -53,8 +74,8 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm {
protected double computeDemerits(KnuthNode activeNode,
KnuthElement element, int fitnessClass, double r) {
double dem = super.computeDemerits(activeNode, element, fitnessClass, r);
- if (log.isTraceEnabled()) {
- log.trace("original demerit=" + dem + " " + totalWidth
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("original demerit=" + dem + " " + totalWidth
+ " line=" + activeNode.line + "/" + columnCount
+ " pos=" + activeNode.position + "/" + (par.size() - 1));
}
@@ -70,13 +91,13 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm {
if (remParts > 0) {
avgRestLen = restLen / remParts;
}
- if (log.isTraceEnabled()) {
- log.trace("remaining parts: " + remParts + " rest len: " + restLen
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("remaining parts: " + remParts + " rest len: " + restLen
+ " avg=" + avgRestLen);
}
double balance = (idealPartLen - partLen) / 1000f;
- if (log.isTraceEnabled()) {
- log.trace("balance=" + balance);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("balance=" + balance);
}
double absBalance = Math.abs(balance);
dem = absBalance;
@@ -99,8 +120,8 @@ public class BalancingColumnBreakingAlgorithm extends PageBreakingAlgorithm {
//We don't want more columns than available
dem = Double.MAX_VALUE;
}
- if (log.isTraceEnabled()) {
- log.trace("effective dem=" + dem + " " + totalWidth);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("effective dem=" + dem + " " + totalWidth);
}
return dem;
}
diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
index 5ca2b567f..877da13dd 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
@@ -187,7 +187,8 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
}
/** {@inheritDoc} */
- public List getNextKnuthElements(LayoutContext context, int alignment) {
+ public List getNextKnuthElements // CSOK: MethodLength
+ (LayoutContext context, int alignment) {
resetSpaces();
if (isAbsoluteOrFixed()) {
return getNextKnuthElementsAbsolute(context, alignment);
@@ -322,7 +323,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
}
if (ElementListUtils.endsWithForcedBreak(returnedList)) {
// a descendant of this block has break-after
- if (curLM.isFinished()) {
+ if (curLM.isFinished() && !hasNextChildLM()) {
// there is no other content in this block;
// it's useless to add space after before a page break
setFinished(true);
@@ -404,8 +405,9 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
}
/** {@inheritDoc} */
- public List getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack,
- Position restartPosition, LayoutManager restartAtLM) {
+ public List getNextKnuthElements // CSOK: MethodLength
+ (LayoutContext context, int alignment, Stack lmStack,
+ Position restartPosition, LayoutManager restartAtLM) {
resetSpaces();
if (isAbsoluteOrFixed()) {
return getNextKnuthElementsAbsolute(context, alignment);
@@ -990,8 +992,8 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
}
/** {@inheritDoc} */
- public void addAreas(PositionIterator parentIter,
- LayoutContext layoutContext) {
+ public void addAreas // CSOK: MethodLength
+ (PositionIterator parentIter, LayoutContext layoutContext) {
getParentArea(null);
// if this will create the first block area in a page
diff --git a/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java b/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java
index fac5bf075..0be0c9437 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockKnuthSequence.java
@@ -27,6 +27,8 @@ import java.util.List;
*/
public class BlockKnuthSequence extends KnuthSequence {
+ private static final long serialVersionUID = 1648962416582509095L;
+
private boolean isClosed = false;
/**
diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
index 69e07a404..62e89bdb0 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
@@ -234,8 +234,8 @@ public class BlockLayoutManager extends BlockStackingLayoutManager
}
/** {@inheritDoc} */
- public void addAreas(PositionIterator parentIter,
- LayoutContext layoutContext) {
+ public void addAreas // CSOK: MethodLength
+ (PositionIterator parentIter, LayoutContext layoutContext) {
getParentArea(null);
// if this will create the first block area in a page
diff --git a/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java
index a1d43dd6f..8f2a4b214 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockLevelLayoutManager.java
@@ -26,8 +26,18 @@ import org.apache.fop.fo.properties.KeepProperty;
*/
public interface BlockLevelLayoutManager extends LayoutManager {
+ /**
+ * Negotiate BPD adjustment.
+ * @param adj amount to adjust
+ * @param lastElement the last knuth element
+ * @return the resulting adjusted BPD
+ */
int negotiateBPDAdjustment(int adj, KnuthElement lastElement);
+ /**
+ * Discard space.
+ * @param spaceGlue the space
+ */
void discardSpace(KnuthGlue spaceGlue);
/**
diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
index 4636cb15a..fd9f2a822 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
@@ -55,6 +55,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
*/
private static Log log = LogFactory.getLog(BlockStackingLayoutManager.class);
+ /** parent area */
protected BlockParent parentArea;
/** Value of the block-progression-unit (non-standard property) */
@@ -360,7 +361,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
}
/** {@inheritDoc} */
- public List getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack,
+ public List getNextKnuthElements // CSOK: MethodLength
+ (LayoutContext context, int alignment, Stack lmStack,
Position restartPosition, LayoutManager restartAtLM) {
referenceIPD = context.getRefIPD();
updateContentAreaIPDwithOverconstrainedAdjust();
@@ -582,8 +584,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
/**
* Adds a break element to the content list between individual child elements.
- * @param contentList
- * @param parentLC
+ * @param contentList the content list
+ * @param parentLC the parent layout context
* @param childLC the currently active child layout context
*/
protected void addInBetweenBreak(List contentList, LayoutContext parentLC,
@@ -758,7 +760,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
/**
* {@inheritDoc}
*/
- public List getChangedKnuthElements(List oldList, int alignment) {
+ public List getChangedKnuthElements(List oldList, int alignment) { // CSOK: MethodLength
/*LF*/ //log.debug("");
/*LF*/ //log.debug(" BLM.getChangedKnuthElements> inizio: oldList.size() = "
// + oldList.size());
@@ -1377,7 +1379,12 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
}*/
}
- protected List createUnitElements(List oldList) {
+ /**
+ * Create unit elements.
+ * @param oldList the old list
+ * @return the new list
+ */
+ protected List createUnitElements(List oldList) { // CSOK: MethodLength
//log.debug("Start conversion: " + oldList.size()
// + " elements, space-before.min=" + layoutProps.spaceBefore.getSpace().min
// + " space-after.min=" + layoutProps.spaceAfter.getSpace().min);
@@ -1640,7 +1647,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
// insert the correct elements
newList.addFirst(new KnuthBox(wrongBox.getWidth() - decreasedLength,
wrongBox.getPosition(), false));
- newList.addFirst(new KnuthGlue(decreasedLength, 0, 0, Adjustment.SPACE_BEFORE_ADJUSTMENT,
+ newList.addFirst(new KnuthGlue(decreasedLength, 0, 0,
+ Adjustment.SPACE_BEFORE_ADJUSTMENT,
wrongBox.getPosition(), false));
//log.debug(" rimosso box " + neededUnits(wrongBox.getWidth()));
//log.debug(" aggiunto glue " + neededUnits(decreasedLength) + " 0 0");
@@ -1692,34 +1700,58 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
return newList;
}
+ /** A stack iterator. */
protected static class StackingIter extends PositionIterator {
+
+ /**
+ * Construct a stacking iterator.
+ * @param parentIter the parent iterator
+ */
StackingIter(Iterator parentIter) {
super(parentIter);
}
+ /**
+ * @param nextObj the next position
+ * @return the layout manager of the next position
+ */
protected LayoutManager getLM(Object nextObj) {
return ((Position) nextObj).getLM();
}
+ /**
+ * @param nextObj the next position
+ * @return the next position
+ */
protected Position getPos(Object nextObj) {
return ((Position) nextObj);
}
}
+ /** A mapping position. */
protected static class MappingPosition extends Position {
+
private int iFirstIndex;
private int iLastIndex;
+ /**
+ * Construct mapping position.
+ * @param lm layout manager
+ * @param first position
+ * @param last position
+ */
public MappingPosition(LayoutManager lm, int first, int last) {
super(lm);
iFirstIndex = first;
iLastIndex = last;
}
+ /** @return first index */
public int getFirstIndex() {
return iFirstIndex;
}
+ /** @return last index */
public int getLastIndex() {
return iLastIndex;
}
diff --git a/src/java/org/apache/fop/layoutmgr/BreakElement.java b/src/java/org/apache/fop/layoutmgr/BreakElement.java
index 3eb96e9cd..7208a585f 100644
--- a/src/java/org/apache/fop/layoutmgr/BreakElement.java
+++ b/src/java/org/apache/fop/layoutmgr/BreakElement.java
@@ -55,7 +55,8 @@ public class BreakElement extends UnresolvedListElement {
* @param breakClass the break class
* @param context the {@link LayoutContext}
*/
- public BreakElement(Position position, int penaltyValue, int breakClass, LayoutContext context) {
+ public BreakElement(Position position, int penaltyValue, int breakClass,
+ LayoutContext context) {
this(position, 0, penaltyValue, breakClass, context);
}
diff --git a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
index 4516c8d97..edea3aa79 100644
--- a/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
+++ b/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
@@ -42,7 +42,7 @@ import org.apache.fop.fo.Constants;
public abstract class BreakingAlgorithm {
/** the logger for the class */
- protected static Log log = LogFactory.getLog(BreakingAlgorithm.class);
+ protected static final Log log = LogFactory.getLog(BreakingAlgorithm.class);
/** Maximum adjustment ration */
protected static final int INFINITE_RATIO = 1000;
@@ -59,12 +59,18 @@ public abstract class BreakingAlgorithm {
/** Holder for symbolic literals for the fitness classes */
static final class FitnessClasses {
+
+ private FitnessClasses() {
+ }
+
static final int VERY_TIGHT = 0;
static final int TIGHT = 1;
static final int LOOSE = 2;
static final int VERY_LOOSE = 3;
- static final String[] NAMES = { "VERY TIGHT", "TIGHT", "LOOSE", "VERY LOOSE" };
+ static final String[] NAMES = {
+ "VERY TIGHT", "TIGHT", "LOOSE", "VERY LOOSE"
+ };
/**
* Figure out the fitness class of this line (tight, loose,
@@ -178,6 +184,9 @@ public abstract class BreakingAlgorithm {
*/
protected int totalShrink = 0;
+ /**
+ * Best records.
+ */
protected BestRecords best;
private boolean partOverflowRecoveryActivated = true;
@@ -217,54 +226,70 @@ public abstract class BreakingAlgorithm {
*/
public class KnuthNode {
/** index of the breakpoint represented by this node */
- public final int position;
+ public final int position; // CSOK: VisibilityModifier
/** number of the line ending at this breakpoint */
- public final int line;
+ public final int line; // CSOK: VisibilityModifier
/** fitness class of the line ending at this breakpoint. One of 0, 1, 2, 3. */
- public final int fitness;
+ public final int fitness; // CSOK: VisibilityModifier
/** accumulated width of the KnuthElements up to after this breakpoint. */
- public final int totalWidth;
+ public final int totalWidth; // CSOK: VisibilityModifier
/** accumulated stretchability of the KnuthElements up to after this breakpoint. */
- public final int totalStretch;
+ public final int totalStretch; // CSOK: VisibilityModifier
/** accumulated shrinkability of the KnuthElements up to after this breakpoint. */
- public final int totalShrink;
+ public final int totalShrink; // CSOK: VisibilityModifier
/** adjustment ratio if the line ends at this breakpoint */
- public final double adjustRatio;
+ public final double adjustRatio; // CSOK: VisibilityModifier
/** available stretch of the line ending at this breakpoint */
- public final int availableShrink;
+ public final int availableShrink; // CSOK: VisibilityModifier
/** available shrink of the line ending at this breakpoint */
- public final int availableStretch;
+ public final int availableStretch; // CSOK: VisibilityModifier
/** difference between target and actual line width */
- public final int difference;
+ public final int difference; // CSOK: VisibilityModifier
/** minimum total demerits up to this breakpoint */
- public double totalDemerits;
+ public double totalDemerits; // CSOK: VisibilityModifier
/** best node for the preceding breakpoint */
- public KnuthNode previous;
+ public KnuthNode previous; // CSOK: VisibilityModifier
/** next possible node in the same line */
- public KnuthNode next;
+ public KnuthNode next; // CSOK: VisibilityModifier
/**
* Holds the number of subsequent recovery attempty that are made to get content fit
* into a line.
*/
- public int fitRecoveryCounter = 0;
+ public int fitRecoveryCounter = 0; // CSOK: VisibilityModifier
- public KnuthNode(int position, int line, int fitness,
- int totalWidth, int totalStretch, int totalShrink,
- double adjustRatio, int availableShrink, int availableStretch,
- int difference, double totalDemerits, KnuthNode previous) {
+ /**
+ * Construct node.
+ * @param position an integer
+ * @param line an integer
+ * @param fitness an integer
+ * @param totalWidth an integer
+ * @param totalStretch an integer
+ * @param totalShrink an integer
+ * @param adjustRatio a real number
+ * @param availableShrink an integer
+ * @param availableStretch an integer
+ * @param difference an integer
+ * @param totalDemerits a real number
+ * @param previous a node
+ */
+ public KnuthNode( // CSOK: ParameterNumber
+ int position, int line, int fitness,
+ int totalWidth, int totalStretch, int totalShrink,
+ double adjustRatio, int availableShrink, int availableStretch,
+ int difference, double totalDemerits, KnuthNode previous) {
this.position = position;
this.line = line;
this.fitness = fitness;
@@ -279,6 +304,7 @@ public abstract class BreakingAlgorithm {
this.previous = previous;
}
+ /** {@inheritDoc} */
public String toString() {
return "<KnuthNode at " + position + " "
+ totalWidth + "+" + totalStretch + "-" + totalShrink
@@ -303,6 +329,7 @@ public abstract class BreakingAlgorithm {
/** Points to the fitness class which currently leads to the best demerits. */
private int bestIndex = -1;
+ /** default constructor */
public BestRecords() {
reset();
}
@@ -334,6 +361,7 @@ public abstract class BreakingAlgorithm {
}
}
+ /** @return true if has records (best index not -1) */
public boolean hasRecords() {
return (bestIndex != -1);
}
@@ -347,30 +375,55 @@ public abstract class BreakingAlgorithm {
return (bestDemerits[fitness] != INFINITE_DEMERITS);
}
+ /**
+ * @param fitness to use
+ * @return best demerits
+ */
public double getDemerits(int fitness) {
return bestDemerits[fitness];
}
+ /**
+ * @param fitness to use
+ * @return best node
+ */
public KnuthNode getNode(int fitness) {
return bestNode[fitness];
}
+ /**
+ * @param fitness to use
+ * @return adjustment
+ */
public double getAdjust(int fitness) {
return bestAdjust[fitness];
}
+ /**
+ * @param fitness to use
+ * @return available shrink
+ */
public int getAvailableShrink(int fitness) {
return bestAvailableShrink[fitness];
}
+ /**
+ * @param fitness to use
+ * @return available stretch
+ */
public int getAvailableStretch(int fitness) {
return bestAvailableStretch[fitness];
}
+ /**
+ * @param fitness to use
+ * @return difference
+ */
public int getDifference(int fitness) {
return bestDifference[fitness];
}
+ /** @return minimum demerits */
public double getMinDemerits() {
if (bestIndex != -1) {
return getDemerits(bestIndex);
@@ -427,11 +480,22 @@ public abstract class BreakingAlgorithm {
KnuthSequence sequence,
int total);
+ /** @param lineWidth the line width */
public void setConstantLineWidth(int lineWidth) {
this.lineWidth = lineWidth;
}
- /** @see #findBreakingPoints(KnuthSequence, int, double, boolean, int) */
+ /**
+ * @param par the paragraph to break
+ * @param threshold upper bound of the adjustment ratio
+ * @param force {@code true} if a set of breakpoints must be found, even
+ * if there are no feasible ones
+ * @param allowedBreaks the type(s) of breaks allowed. One of {@link #ONLY_FORCED_BREAKS},
+ * {@link #NO_FLAGGED_PENALTIES} or {@link #ALL_BREAKS}.
+ *
+ * @return the number of effective breaks
+ * @see #findBreakingPoints(KnuthSequence, int, double, boolean, int)
+ */
public int findBreakingPoints(KnuthSequence par,
double threshold,
boolean force,
@@ -538,10 +602,18 @@ public abstract class BreakingAlgorithm {
return line;
}
+ /**
+ * obtain ipd difference
+ * @return an integer
+ */
protected int getIPDdifference() {
return 0;
}
+ /**
+ * handle ipd change
+ * @return an integer
+ */
protected int handleIpdChange() {
throw new IllegalStateException();
}
@@ -572,8 +644,10 @@ public abstract class BreakingAlgorithm {
this.totalWidth = 0;
this.totalStretch = 0;
this.totalShrink = 0;
- this.lastTooShort = this.lastTooLong = null;
- this.startLine = this.endLine = 0;
+ this.lastTooShort = null;
+ this.lastTooLong = null;
+ this.startLine = 0;
+ this.endLine = 0;
this.activeLines = new KnuthNode[20];
}
@@ -597,10 +671,11 @@ public abstract class BreakingAlgorithm {
* @param previous active node for the preceding breakpoint
* @return a new node
*/
- protected KnuthNode createNode(int position, int line, int fitness,
- int totalWidth, int totalStretch, int totalShrink,
- double adjustRatio, int availableShrink, int availableStretch,
- int difference, double totalDemerits, KnuthNode previous) {
+ protected KnuthNode createNode( // CSOK: ParameterNumber
+ int position, int line, int fitness,
+ int totalWidth, int totalStretch, int totalShrink,
+ double adjustRatio, int availableShrink, int availableStretch,
+ int difference, double totalDemerits, KnuthNode previous) {
return new KnuthNode(position, line, fitness,
totalWidth, totalStretch, totalShrink,
adjustRatio, availableShrink, availableStretch,
@@ -609,7 +684,17 @@ public abstract class BreakingAlgorithm {
/** Creates a new active node for a break from the best active node of the given
* fitness class to the element at the given position.
- * @see #createNode(int, int, int, int, int, int, double, int, int, int, double, org.apache.fop.layoutmgr.BreakingAlgorithm.KnuthNode)
+ * @param position index of the element in the Knuth sequence
+ * @param line number of the line ending at the breakpoint
+ * @param fitness fitness class of the line ending at the breakpoint. One of 0, 1, 2, 3.
+ * @param totalWidth accumulated width of the KnuthElements up to after the breakpoint
+ * @param totalStretch accumulated stretchability of the KnuthElements up to after the
+ * breakpoint
+ * @param totalShrink accumulated shrinkability of the KnuthElements up to after the
+ * breakpoint
+ * @return a new node
+ * @see #createNode(int, int, int, int, int, int, double, int, int, int, double,
+ * org.apache.fop.layoutmgr.BreakingAlgorithm.KnuthNode)
* @see BreakingAlgorithm.BestRecords
*/
protected KnuthNode createNode(int position, int line, int fitness,
@@ -655,7 +740,7 @@ public abstract class BreakingAlgorithm {
handleBox((KnuthBox) element);
} else if (element.isGlue()) {
handleGlueAt((KnuthGlue) element, position, previousIsBox, allowedBreaks);
- } else if (element.isPenalty()){
+ } else if (element.isPenalty()) {
handlePenaltyAt((KnuthPenalty) element, position, allowedBreaks);
} else {
throw new IllegalArgumentException(
@@ -875,7 +960,7 @@ public abstract class BreakingAlgorithm {
* number.
* @param element the element
* @param line the line number
- * @param difference
+ * @param difference an integer
* @return {@code true} if the element can end the line
*/
protected boolean elementCanEndLine(KnuthElement element, int line, int difference) {
@@ -896,7 +981,7 @@ public abstract class BreakingAlgorithm {
* @param availableShrink the available amount of shrink
* @param availableStretch tha available amount of stretch
*/
- protected void forceNode(KnuthNode node,
+ protected void forceNode(KnuthNode node, // CSOK: ParameterNumber
int line,
int elementIdx,
int difference,
@@ -1320,6 +1405,10 @@ public abstract class BreakingAlgorithm {
return sb.toString();
}
+ /**
+ * Filter active nodes.
+ * @return an integer
+ */
protected abstract int filterActiveNodes();
/**
diff --git a/src/java/org/apache/fop/layoutmgr/ElementListObserver.java b/src/java/org/apache/fop/layoutmgr/ElementListObserver.java
index 73a6d5be4..d5c6f5527 100644
--- a/src/java/org/apache/fop/layoutmgr/ElementListObserver.java
+++ b/src/java/org/apache/fop/layoutmgr/ElementListObserver.java
@@ -27,7 +27,10 @@ import java.util.List;
* is mainly used for the purpose of automated testing. This implementation here does nothing.
* Please see the subclass within the test code.
*/
-public class ElementListObserver {
+public final class ElementListObserver {
+
+ private ElementListObserver() {
+ }
private static List activeObservers = null;
diff --git a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
index 6a843ac63..2bd6f429a 100644
--- a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
+++ b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java
@@ -55,43 +55,7 @@ public final class ElementListUtils {
* @return true if the constraint is bigger than the list contents
*/
public static boolean removeLegalBreaks(List elements, int constraint) {
- int len = 0;
- ListIterator iter = elements.listIterator();
- while (iter.hasNext()) {
- ListElement el = (ListElement)iter.next();
- if (el.isPenalty()) {
- KnuthPenalty penalty = (KnuthPenalty)el;
- //Convert all penalties to break inhibitors
- if (penalty.getPenalty() < KnuthPenalty.INFINITE) {
- iter.set(new KnuthPenalty(penalty.getWidth(), KnuthPenalty.INFINITE,
- penalty.isPenaltyFlagged(), penalty.getPosition(),
- penalty.isAuxiliary()));
- }
- } else if (el.isGlue()) {
- KnuthGlue glue = (KnuthGlue)el;
- len += glue.getWidth();
- iter.previous();
- el = (ListElement)iter.previous();
- iter.next();
- if (el.isBox()) {
- iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
- null, false));
- }
- iter.next();
- } else if (el instanceof BreakElement) {
- BreakElement breakEl = (BreakElement)el;
- if (breakEl.getPenaltyValue() < KnuthPenalty.INFINITE) {
- breakEl.setPenaltyValue(KnuthPenalty.INFINITE);
- }
- } else {
- KnuthElement kel = (KnuthElement)el;
- len += kel.getWidth();
- }
- if (len >= constraint) {
- return false;
- }
- }
- return true;
+ return removeLegalBreaks(elements, constraint, false);
}
/**
@@ -103,27 +67,48 @@ public final class ElementListUtils {
* @return true if the constraint is bigger than the list contents
*/
public static boolean removeLegalBreaksFromEnd(List elements, int constraint) {
+ return removeLegalBreaks(elements, constraint, true);
+ }
+
+ private static boolean removeLegalBreaks(List elements, int constraint, boolean fromEnd) {
+
int len = 0;
- ListIterator i = elements.listIterator(elements.size());
- while (i.hasPrevious()) {
- ListElement el = (ListElement)i.previous();
+ ListElement el;
+
+ for (ListIterator iter = elements.listIterator(fromEnd ? elements.size() : 0);
+ (fromEnd ? iter.hasPrevious() : iter.hasNext());) {
+
+ if (fromEnd) {
+ el = (ListElement) iter.previous();
+ } else {
+ el = (ListElement) iter.next();
+ }
+
if (el.isPenalty()) {
KnuthPenalty penalty = (KnuthPenalty)el;
- //Convert all penalties to break inhibitors
+ //Convert penalty to break inhibitor
if (penalty.getPenalty() < KnuthPenalty.INFINITE) {
- i.set(new KnuthPenalty(penalty.getWidth(), KnuthPenalty.INFINITE,
+ iter.set(new KnuthPenalty(penalty.getWidth(), KnuthPenalty.INFINITE,
penalty.isPenaltyFlagged(), penalty.getPosition(),
penalty.isAuxiliary()));
}
} else if (el.isGlue()) {
KnuthGlue glue = (KnuthGlue)el;
len += glue.getWidth();
- el = (ListElement)i.previous();
- i.next();
+ //check if previous is a box
+ if (!fromEnd) {
+ iter.previous();
+ }
+ el = (ListElement)iter.previous();
+ iter.next();
if (el.isBox()) {
- i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
+ //add break inhibitor
+ iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false,
null, false));
}
+ if (!fromEnd) {
+ iter.next();
+ }
} else if (el.isUnresolvedElement()) {
if (el instanceof BreakElement) {
BreakElement breakEl = (BreakElement)el;
@@ -138,10 +123,12 @@ public final class ElementListUtils {
KnuthElement kel = (KnuthElement)el;
len += kel.getWidth();
}
+
if (len >= constraint) {
return false;
}
}
+
return true;
}
@@ -191,8 +178,7 @@ public final class ElementListUtils {
* @return true if the list ends with a forced break
*/
public static boolean endsWithForcedBreak(List elems) {
- ListElement last = (ListElement) ListUtil.getLast(elems);
- return last.isForcedBreak();
+ return ((ListElement) ListUtil.getLast(elems)).isForcedBreak();
}
/**
diff --git a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
index 67b9b4254..a29398b93 100644
--- a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
@@ -36,7 +36,7 @@ import org.apache.fop.fo.pagination.Flow;
* Its parent LM is the PageSequenceLayoutManager.
* This LM is responsible for getting columns of the appropriate size
* and filling them with block-level areas generated by its children.
- * @todo Reintroduce emergency counter (generate error to avoid endless loop)
+ * TODO Reintroduce emergency counter (generate error to avoid endless loop)
*/
public class FlowLayoutManager extends BlockStackingLayoutManager
implements BlockLevelLayoutManager {
@@ -79,7 +79,16 @@ public class FlowLayoutManager extends BlockStackingLayoutManager
return elements;
}
- /** {@inheritDoc} */
+ /**
+ * Get a sequence of KnuthElements representing the content
+ * of the node assigned to the LM.
+ * @param context the LayoutContext used to store layout information
+ * @param alignment the desired text alignment
+ * @param positionAtIPDChange position at ipd change
+ * @param restartAtLM restart at this layout manager
+ * @return the list of KnuthElements
+ * @see LayoutManager#getNextKnuthElements(LayoutContext,int)
+ */
public List getNextKnuthElements(LayoutContext context, int alignment,
Position positionAtIPDChange, LayoutManager restartAtLM) {
diff --git a/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java b/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java
index 0d00b710a..81df3c992 100644
--- a/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java
+++ b/src/java/org/apache/fop/layoutmgr/InlineKnuthSequence.java
@@ -32,6 +32,8 @@ import org.apache.fop.layoutmgr.inline.KnuthInlineBox;
*/
public class InlineKnuthSequence extends KnuthSequence {
+ private static final long serialVersionUID = 1354774188859946549L;
+
private boolean isClosed = false;
/**
@@ -95,6 +97,9 @@ public class InlineKnuthSequence extends KnuthSequence {
return this;
}
+ /**
+ * Add letter space.
+ */
public void addALetterSpace() {
KnuthBox prevBox = (KnuthBox) getLast();
if (prevBox.isAuxiliary()
diff --git a/src/java/org/apache/fop/layoutmgr/Keep.java b/src/java/org/apache/fop/layoutmgr/Keep.java
index 444448ae4..c53c5e41a 100644
--- a/src/java/org/apache/fop/layoutmgr/Keep.java
+++ b/src/java/org/apache/fop/layoutmgr/Keep.java
@@ -1,16 +1,18 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file to You under the Apache
- * License, Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
/* $Id$ */
@@ -25,7 +27,7 @@ import org.apache.fop.fo.properties.Property;
* Object representing a keep constraint, corresponding
* to the XSL-FO <a href="http://www.w3.org/TR/xsl/#d0e26492">keep properties</a>.
*/
-public class Keep {
+public final class Keep {
/** The integer value for "auto" keep strength. */
private static final int STRENGTH_AUTO = Integer.MIN_VALUE;
@@ -33,8 +35,10 @@ public class Keep {
/** The integer value for "always" keep strength. */
private static final int STRENGTH_ALWAYS = Integer.MAX_VALUE;
+ /** keep auto */
public static final Keep KEEP_AUTO = new Keep(STRENGTH_AUTO, Constants.EN_AUTO);
+ /** keep always */
public static final Keep KEEP_ALWAYS = new Keep(STRENGTH_ALWAYS, Constants.EN_LINE);
private int strength;
diff --git a/src/java/org/apache/fop/layoutmgr/KnuthGlue.java b/src/java/org/apache/fop/layoutmgr/KnuthGlue.java
index 2efea0e61..2b89c10d4 100644
--- a/src/java/org/apache/fop/layoutmgr/KnuthGlue.java
+++ b/src/java/org/apache/fop/layoutmgr/KnuthGlue.java
@@ -87,6 +87,16 @@ public class KnuthGlue extends KnuthElement {
this.adjustmentClass = Adjustment.NO_ADJUSTMENT;
}
+ /**
+ * Creates a new <code>KnuthGlue</code>.
+ *
+ * @param width the width of this glue
+ * @param stretch the stretchability of this glue
+ * @param shrink the shrinkability of this glue
+ * @param adjustmentClass the adjsutment class
+ * @param pos the Position stored in this glue
+ * @param auxiliary is this glue auxiliary?
+ */
public KnuthGlue(int width, int stretch, int shrink, Adjustment adjustmentClass,
Position pos, boolean auxiliary) {
super(width, pos, auxiliary);
diff --git a/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java b/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java
index e7397babb..e69b991b3 100644
--- a/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java
+++ b/src/java/org/apache/fop/layoutmgr/KnuthPossPosIter.java
@@ -21,6 +21,9 @@ package org.apache.fop.layoutmgr;
import java.util.List;
+/**
+ * A Knuth element position iterator.
+ */
public class KnuthPossPosIter extends PositionIterator {
private int iterCount;
@@ -46,9 +49,7 @@ public class KnuthPossPosIter extends PositionIterator {
// Check position < endPos
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected boolean checkNext() {
if (iterCount > 0) {
return super.checkNext();
@@ -58,22 +59,26 @@ public class KnuthPossPosIter extends PositionIterator {
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public Object next() {
--iterCount;
return super.next();
}
+ /**
+ * Peek at next, returning as ListElement.
+ * @return peek at next as ListElement
+ */
public ListElement getKE() {
return (ListElement) peekNext();
}
+ /** {@inheritDoc} */
protected LayoutManager getLM(Object nextObj) {
return ((ListElement) nextObj).getLayoutManager();
}
+ /** {@inheritDoc} */
protected Position getPos(Object nextObj) {
return ((ListElement) nextObj).getPosition();
}
diff --git a/src/java/org/apache/fop/layoutmgr/KnuthSequence.java b/src/java/org/apache/fop/layoutmgr/KnuthSequence.java
index 7c712040a..1a9bb6534 100644
--- a/src/java/org/apache/fop/layoutmgr/KnuthSequence.java
+++ b/src/java/org/apache/fop/layoutmgr/KnuthSequence.java
@@ -182,13 +182,20 @@ public abstract class KnuthSequence extends ArrayList {
ListElement element = null;
int posIndex = startIndex;
int lastIndex = size();
- while (posIndex < lastIndex
- && !(element = getElement(posIndex)).isBox()) {
- posIndex++;
+ while ( posIndex < lastIndex ) {
+ element = getElement(posIndex);
+ if ( !element.isBox() ) {
+ posIndex++;
+ } else {
+ break;
+ }
}
- if (posIndex != startIndex
- && element.isBox()) {
- return posIndex - 1;
+ if ( posIndex != startIndex ) {
+ if ( ( element != null ) && element.isBox() ) {
+ return posIndex - 1;
+ } else {
+ return startIndex;
+ }
} else {
return startIndex;
}
diff --git a/src/java/org/apache/fop/layoutmgr/LMiter.java b/src/java/org/apache/fop/layoutmgr/LMiter.java
index 4fa5590dc..9f437df6a 100644
--- a/src/java/org/apache/fop/layoutmgr/LMiter.java
+++ b/src/java/org/apache/fop/layoutmgr/LMiter.java
@@ -23,27 +23,36 @@ import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;
+/** An iterator for layout managers. */
public class LMiter implements ListIterator {
-
+ /** list of layout managers */
protected List listLMs;
+ /** current position in iteration */
protected int curPos = 0;
/** The LayoutManager to which this LMiter is attached **/
private LayoutManager lp;
+ /**
+ * Construct a layout manager iterator.
+ * @param lp the associated layout manager (parent)
+ */
public LMiter(LayoutManager lp) {
this.lp = lp;
listLMs = lp.getChildLMs();
}
+ /** {@inheritDoc} */
public boolean hasNext() {
return (curPos < listLMs.size()) ? true : lp.createNextChildLMs(curPos);
}
+ /** {@inheritDoc} */
public boolean hasPrevious() {
return (curPos > 0);
}
+ /** {@inheritDoc} */
public Object previous() throws NoSuchElementException {
if (curPos > 0) {
return listLMs.get(--curPos);
@@ -52,6 +61,7 @@ public class LMiter implements ListIterator {
}
}
+ /** {@inheritDoc} */
public Object next() throws NoSuchElementException {
if (curPos < listLMs.size()) {
return listLMs.get(curPos++);
@@ -60,7 +70,8 @@ public class LMiter implements ListIterator {
}
}
- public void remove() throws NoSuchElementException {
+ /** {@inheritDoc} */
+ public void remove() throws NoSuchElementException {
if (curPos > 0) {
listLMs.remove(--curPos);
// Note: doesn't actually remove it from the base!
@@ -70,18 +81,22 @@ public class LMiter implements ListIterator {
}
- public void add(Object o) throws UnsupportedOperationException {
+ /** {@inheritDoc} */
+ public void add(Object o) throws UnsupportedOperationException {
throw new UnsupportedOperationException("LMiter doesn't support add");
}
+ /** {@inheritDoc} */
public void set(Object o) throws UnsupportedOperationException {
throw new UnsupportedOperationException("LMiter doesn't support set");
}
+ /** {@inheritDoc} */
public int nextIndex() {
return curPos;
}
+ /** {@inheritDoc} */
public int previousIndex() {
return curPos - 1;
}
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutContext.java b/src/java/org/apache/fop/layoutmgr/LayoutContext.java
index 752ffd628..18059c5ca 100644
--- a/src/java/org/apache/fop/layoutmgr/LayoutContext.java
+++ b/src/java/org/apache/fop/layoutmgr/LayoutContext.java
@@ -33,12 +33,12 @@ import org.apache.fop.traits.MinOptMax;
* method. It is set up by higher level LM and used by lower level LM.
*/
public class LayoutContext {
- /**
- * Values for flags.
- */
+
+ /** linebreak at line feed only flag */
public static final int LINEBREAK_AT_LF_ONLY = 0x01;
/** Generated break possibility is first in a new area */
public static final int NEW_AREA = 0x02;
+ /** ipd unknown flag */
public static final int IPD_UNKNOWN = 0x04;
/** Signal to a Line LM that a higher level LM may provoke a change
* in the reference area, thus ref area IPD. The LineLM should return
@@ -51,10 +51,13 @@ public class LayoutContext {
* not cause a mandatory break as this break was already handled by a parent layout manager.
*/
public static final int SUPPRESS_BREAK_BEFORE = 0x10;
+ /** first area flag */
public static final int FIRST_AREA = 0x20;
+ /** try hypenate flag */
public static final int TRY_HYPHENATE = 0x40;
+ /** last area flag */
public static final int LAST_AREA = 0x80;
-
+ /** resolve leading space flag */
public static final int RESOLVE_LEADING_SPACE = 0x100;
/**
@@ -178,6 +181,7 @@ public class LayoutContext {
trailingSpace = null;
}
+ /** @param source from which pending marks are copied */
public void copyPendingMarksFrom(LayoutContext source) {
if (source.pendingAfterMarks != null) {
this.pendingAfterMarks = new java.util.ArrayList(source.pendingAfterMarks);
@@ -187,10 +191,15 @@ public class LayoutContext {
}
}
+ /** @param flags to set */
public void setFlags(int flags) {
setFlags(flags, true);
}
+ /**
+ * @param flags to set or clear
+ * @param bSet true to set, false to clear
+ */
public void setFlags(int flags, boolean bSet) {
if (bSet) {
this.flags |= flags;
@@ -199,26 +208,32 @@ public class LayoutContext {
}
}
+ /** @param flags to clear */
public void unsetFlags(int flags) {
setFlags(flags, false);
}
+ /** @return true if new area is set */
public boolean isStart() {
return ((this.flags & NEW_AREA) != 0);
}
+ /** @return true if new area is set and leading space is non-null */
public boolean startsNewArea() {
return ((this.flags & NEW_AREA) != 0 && leadingSpace != null);
}
+ /** @return true if first area is set */
public boolean isFirstArea() {
return ((this.flags & FIRST_AREA) != 0);
}
+ /** @return true if last area is set */
public boolean isLastArea() {
return ((this.flags & LAST_AREA) != 0);
}
+ /** @return true if suppress break before is set */
public boolean suppressBreakBefore() {
return ((this.flags & SUPPRESS_BREAK_BEFORE) != 0);
}
@@ -293,22 +308,27 @@ public class LayoutContext {
return !getKeepWithPreviousPending().isAuto();
}
+ /** @param space leading space */
public void setLeadingSpace(SpaceSpecifier space) {
leadingSpace = space;
}
+ /** @return leading space */
public SpaceSpecifier getLeadingSpace() {
return leadingSpace;
}
+ /** @return true if resolve leading space is set */
public boolean resolveLeadingSpace() {
return ((this.flags & RESOLVE_LEADING_SPACE) != 0);
}
+ /** @param space trailing space */
public void setTrailingSpace(SpaceSpecifier space) {
trailingSpace = space;
}
+ /** @return trailing space */
public SpaceSpecifier getTrailingSpace() {
return trailingSpace;
}
@@ -389,6 +409,7 @@ public class LayoutContext {
/**
* Sets the inline-progression-dimension of the nearest ancestor reference area.
+ * @param ipd of nearest ancestor reference area
*/
public void setRefIPD(int ipd) {
refIPD = ipd;
@@ -403,14 +424,17 @@ public class LayoutContext {
return refIPD;
}
+ /** @param hyph a hyphenation context */
public void setHyphContext(HyphContext hyph) {
hyphContext = hyph;
}
+ /** @return hyphenation context */
public HyphContext getHyphContext() {
return hyphContext;
}
+ /** @return true if try hyphenate is set */
public boolean tryHyphenate() {
return ((this.flags & TRY_HYPHENATE) != 0);
}
@@ -428,30 +452,39 @@ public class LayoutContext {
return this.bpAlignment;
}
+ /** @param adjust space adjustment */
public void setSpaceAdjust(double adjust) {
dSpaceAdjust = adjust;
}
+ /** @return space adjustment */
public double getSpaceAdjust() {
return dSpaceAdjust;
}
+ /** @param ipdA ipd adjustment */
public void setIPDAdjust(double ipdA) {
ipdAdjust = ipdA;
}
+ /** @return ipd adjustment */
public double getIPDAdjust() {
return ipdAdjust;
}
+ /** @param alignmentContext alignment context */
public void setAlignmentContext(AlignmentContext alignmentContext) {
this.alignmentContext = alignmentContext;
}
+ /** @return alignment context */
public AlignmentContext getAlignmentContext() {
return this.alignmentContext;
}
+ /**
+ * Reset alignment context.
+ */
public void resetAlignmentContext() {
if (this.alignmentContext != null) {
this.alignmentContext = this.alignmentContext.getParentAlignmentContext();
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutException.java b/src/java/org/apache/fop/layoutmgr/LayoutException.java
index 822607020..f22d34bd8 100644
--- a/src/java/org/apache/fop/layoutmgr/LayoutException.java
+++ b/src/java/org/apache/fop/layoutmgr/LayoutException.java
@@ -29,7 +29,7 @@ import org.apache.fop.events.EventExceptionManager.ExceptionFactory;
* Exception thrown by FOP if an unrecoverable layout error occurs. An example: An area overflows
* a viewport that has overflow="error-if-overflow".
*
- * @todo Discuss if this should become a checked exception.
+ * TODO Discuss if this should become a checked exception.
*/
public class LayoutException extends RuntimeException {
@@ -97,7 +97,7 @@ public class LayoutException extends RuntimeException {
}
/** {@inheritDoc} */
- public Class getExceptionClass() {
+ public Class<LayoutException> getExceptionClass() {
return LayoutException.class;
}
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManager.java b/src/java/org/apache/fop/layoutmgr/LayoutManager.java
index 454b8b366..985131bf1 100644
--- a/src/java/org/apache/fop/layoutmgr/LayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/LayoutManager.java
@@ -132,7 +132,7 @@ public interface LayoutManager extends PercentBaseContext {
/**
* Get a sequence of KnuthElements representing the content
- * of the node assigned to the LM
+ * of the node assigned to the LM.
*
* @param context the LayoutContext used to store layout information
* @param alignment the desired text alignment
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java
index 8efe5ce65..e9e3fb6a7 100644
--- a/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java
+++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java
@@ -16,6 +16,7 @@
*/
/* $Id$ */
+
package org.apache.fop.layoutmgr;
import java.util.List;
@@ -40,7 +41,7 @@ public interface LayoutManagerMaker {
* @param node the FO node for which the LayoutManagers are made
* @param lms the list to which the LayoutManagers are added
*/
- public void makeLayoutManagers(FONode node, List lms);
+ void makeLayoutManagers(FONode node, List lms);
/**
* Make a specific LayoutManager for the node.
@@ -48,10 +49,8 @@ public interface LayoutManagerMaker {
* an IllegalStateException is thrown.
* @param node the FO node for which the LayoutManagers are made
* @return The created LayoutManager
- * @throws IllegalStateException if not exactly one
- * LayoutManager is available for the requested node
*/
- public LayoutManager makeLayoutManager(FONode node);
+ LayoutManager makeLayoutManager(FONode node);
/**
* Make a PageSequenceLayoutManager object.
@@ -59,7 +58,7 @@ public interface LayoutManagerMaker {
* @param ps the fo:page-sequence object this PSLM will process
* @return The created PageSequenceLayoutManager object
*/
- public PageSequenceLayoutManager makePageSequenceLayoutManager(
+ PageSequenceLayoutManager makePageSequenceLayoutManager(
AreaTreeHandler ath, PageSequence ps);
/**
@@ -68,7 +67,7 @@ public interface LayoutManagerMaker {
* @param ed the fox:external-document object to be processed
* @return The created ExternalDocumentLayoutManager object
*/
- public ExternalDocumentLayoutManager makeExternalDocumentLayoutManager(
+ ExternalDocumentLayoutManager makeExternalDocumentLayoutManager(
AreaTreeHandler ath, ExternalDocument ed);
/**
@@ -77,7 +76,7 @@ public interface LayoutManagerMaker {
* @param flow the fo:flow object this FLM will process
* @return The created FlowLayoutManager object
*/
- public FlowLayoutManager makeFlowLayoutManager(
+ FlowLayoutManager makeFlowLayoutManager(
PageSequenceLayoutManager pslm, Flow flow);
/**
@@ -86,7 +85,7 @@ public interface LayoutManagerMaker {
* @param title the fo:title object this CLM will process
* @return The created ContentLayoutManager object
*/
- public ContentLayoutManager makeContentLayoutManager(
+ ContentLayoutManager makeContentLayoutManager(
PageSequenceLayoutManager pslm, Title title);
/**
@@ -97,7 +96,7 @@ public interface LayoutManagerMaker {
* needs to be processed.
* @return The created StaticContentLayoutManager object
*/
- public StaticContentLayoutManager makeStaticContentLayoutManager(
+ StaticContentLayoutManager makeStaticContentLayoutManager(
PageSequenceLayoutManager pslm, StaticContent sc, SideRegion reg);
/**
@@ -107,7 +106,7 @@ public interface LayoutManagerMaker {
* @param block the Block area this SCLM must add its areas to
* @return The created StaticContentLayoutManager object
*/
- public StaticContentLayoutManager makeStaticContentLayoutManager(
+ StaticContentLayoutManager makeStaticContentLayoutManager(
PageSequenceLayoutManager pslm, StaticContent sc, Block block);
}
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
index cab2dd0ba..2acf67c1f 100644
--- a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
+++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
@@ -67,14 +67,12 @@ import org.apache.fop.fo.pagination.SideRegion;
import org.apache.fop.fo.pagination.StaticContent;
import org.apache.fop.fo.pagination.Title;
import org.apache.fop.layoutmgr.inline.BasicLinkLayoutManager;
-import org.apache.fop.layoutmgr.inline.BidiLayoutManager;
import org.apache.fop.layoutmgr.inline.CharacterLayoutManager;
import org.apache.fop.layoutmgr.inline.ContentLayoutManager;
import org.apache.fop.layoutmgr.inline.ExternalGraphicLayoutManager;
import org.apache.fop.layoutmgr.inline.FootnoteLayoutManager;
import org.apache.fop.layoutmgr.inline.ICLayoutManager;
import org.apache.fop.layoutmgr.inline.InlineLayoutManager;
-import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager;
import org.apache.fop.layoutmgr.inline.InstreamForeignObjectLM;
import org.apache.fop.layoutmgr.inline.LeaderLayoutManager;
import org.apache.fop.layoutmgr.inline.PageNumberCitationLastLayoutManager;
@@ -93,11 +91,12 @@ import org.apache.fop.util.CharUtilities;
public class LayoutManagerMapping implements LayoutManagerMaker {
/** logging instance */
- protected static Log log = LogFactory.getLog(LayoutManagerMapping.class);
+ private static final Log LOG = LogFactory.getLog(LayoutManagerMapping.class);
/** The map of LayoutManagerMakers */
private Map makers = new HashMap();
+ /** default constructor */
public LayoutManagerMapping() {
initialize();
}
@@ -152,17 +151,15 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
makers.put(clazz, maker);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void makeLayoutManagers(FONode node, List lms) {
Maker maker = (Maker) makers.get(node.getClass());
if (maker == null) {
if (FOElementMapping.URI.equals(node.getNamespaceURI())) {
- log.error("No LayoutManager maker for class " + node.getClass());
+ LOG.error("No LayoutManager maker for class " + node.getClass());
} else {
- if (log.isDebugEnabled()) {
- log.debug("Skipping the creation of a layout manager for " + node.getClass());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Skipping the creation of a layout manager for " + node.getClass());
}
}
} else {
@@ -170,9 +167,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public LayoutManager makeLayoutManager(FONode node) {
List lms = new ArrayList();
makeLayoutManagers(node, lms);
@@ -188,30 +183,31 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
return (LayoutManager) lms.get(0);
}
+ /** {@inheritDoc} */
public PageSequenceLayoutManager makePageSequenceLayoutManager(
AreaTreeHandler ath, PageSequence ps) {
return new PageSequenceLayoutManager(ath, ps);
}
- /*
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
+ public ExternalDocumentLayoutManager makeExternalDocumentLayoutManager(
+ AreaTreeHandler ath, ExternalDocument ed) {
+ return new ExternalDocumentLayoutManager(ath, ed);
+ }
+
+ /** {@inheritDoc} */
public FlowLayoutManager makeFlowLayoutManager(
PageSequenceLayoutManager pslm, Flow flow) {
return new FlowLayoutManager(pslm, flow);
}
- /*
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public ContentLayoutManager makeContentLayoutManager(PageSequenceLayoutManager pslm,
Title title) {
return new ContentLayoutManager(pslm, title);
}
- /*
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public StaticContentLayoutManager makeStaticContentLayoutManager(
PageSequenceLayoutManager pslm, StaticContent sc, SideRegion reg) {
return new StaticContentLayoutManager(pslm, sc, reg);
@@ -223,13 +219,21 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
return new StaticContentLayoutManager(pslm, sc, block);
}
+ /** a layout manager maker base class */
public static class Maker {
+ /**
+ * Create a layout manager.
+ * @param node the associated FO node
+ * @param lms a list of layout managers to which new manager is to be added
+ */
public void make(FONode node, List lms) {
// no layout manager
}
}
+ /** a layout manager maker */
public static class FOTextLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
FOText foText = (FOText) node;
if (foText.length() > 0) {
@@ -238,9 +242,11 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
}
}
+ /** a layout manager maker */
public static class BidiOverrideLayoutManagerMaker extends Maker {
- // public static class BidiOverrideLayoutManagerMaker extends FObjMixedLayoutManagerMaker {
- public void make(BidiOverride node, List lms) {
+ /** {@inheritDoc} */
+ public void make(FONode node, List lms) {
+ /* [GA] remove broken code
if (false) {
// this is broken; it does nothing
// it should make something like an InlineStackingLM
@@ -254,29 +260,36 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
LayoutManager lm = (LayoutManager) childList.get(count);
if (lm instanceof InlineLevelLayoutManager) {
LayoutManager blm = new BidiLayoutManager
- (node, (InlineLayoutManager) lm);
+ ((BidiOverride) node, (InlineLayoutManager) lm);
lms.add(blm);
} else {
lms.add(lm);
}
}
}
+ */
}
}
+ /** a layout manager maker */
public static class InlineLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
lms.add(new InlineLayoutManager((InlineLevel) node));
}
}
+ /** a layout manager maker */
public static class FootnodeLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
lms.add(new FootnoteLayoutManager((Footnote) node));
}
}
+ /** a layout manager maker */
public static class InlineContainerLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
ArrayList childList = new ArrayList();
super.make(node, childList);
@@ -284,25 +297,33 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
}
}
+ /** a layout manager maker */
public static class BasicLinkLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
lms.add(new BasicLinkLayoutManager((BasicLink) node));
}
}
+ /** a layout manager maker */
public static class BlockLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
lms.add(new BlockLayoutManager((Block) node));
}
}
+ /** a layout manager maker */
public static class LeaderLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
lms.add(new LeaderLayoutManager((Leader) node));
}
}
+ /** a layout manager maker */
public static class CharacterLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
Character foCharacter = (Character) node;
if (foCharacter.getCharacter() != CharUtilities.CODE_EOT) {
@@ -311,7 +332,9 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
}
}
+ /** a layout manager maker */
public static class ExternalGraphicLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
ExternalGraphic eg = (ExternalGraphic) node;
if (!eg.getSrc().equals("")) {
@@ -320,49 +343,65 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
}
}
+ /** a layout manager maker */
public static class BlockContainerLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
lms.add(new BlockContainerLayoutManager((BlockContainer) node));
}
}
+ /** a layout manager maker */
public static class ListItemLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
lms.add(new ListItemLayoutManager((ListItem) node));
}
}
+ /** a layout manager maker */
public static class ListBlockLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
lms.add(new ListBlockLayoutManager((ListBlock) node));
}
}
+ /** a layout manager maker */
public static class InstreamForeignObjectLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
lms.add(new InstreamForeignObjectLM((InstreamForeignObject) node));
}
}
+ /** a layout manager maker */
public static class PageNumberLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
lms.add(new PageNumberLayoutManager((PageNumber) node));
}
}
+ /** a layout manager maker */
public static class PageNumberCitationLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
lms.add(new PageNumberCitationLayoutManager((PageNumberCitation) node));
}
}
+ /** a layout manager maker */
public static class PageNumberCitationLastLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
lms.add(new PageNumberCitationLastLayoutManager((PageNumberCitationLast) node));
}
}
+ /** a layout manager maker */
public static class TableLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
Table table = (Table) node;
TableLayoutManager tlm = new TableLayoutManager(table);
@@ -370,7 +409,9 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
}
}
+ /** a layout manager maker */
public class RetrieveMarkerLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
Iterator baseIter;
baseIter = node.getChildNodes();
@@ -384,7 +425,9 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
}
}
+ /** a layout manager maker */
public class WrapperLayoutManagerMaker extends Maker {
+ /** {@inheritDoc} */
public void make(FONode node, List lms) {
//We insert the wrapper LM before it's children so an ID
//on the node can be registered on a page.
@@ -401,9 +444,4 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
}
}
- public ExternalDocumentLayoutManager makeExternalDocumentLayoutManager(
- AreaTreeHandler ath, ExternalDocument ed) {
- return new ExternalDocumentLayoutManager(ath, ed);
- }
-
}
diff --git a/src/java/org/apache/fop/layoutmgr/LeafPosition.java b/src/java/org/apache/fop/layoutmgr/LeafPosition.java
index e1d5b2aaa..61ebfc5e7 100644
--- a/src/java/org/apache/fop/layoutmgr/LeafPosition.java
+++ b/src/java/org/apache/fop/layoutmgr/LeafPosition.java
@@ -19,24 +19,38 @@
package org.apache.fop.layoutmgr;
+/** A leaf position. */
public class LeafPosition extends Position {
private int leafPos;
+ /**
+ * Construct a leaf position.
+ * @param layoutManager the associated layout manager
+ * @param pos the leaf position
+ */
public LeafPosition(LayoutManager layoutManager, int pos) {
super(layoutManager);
leafPos = pos;
}
+ /**
+ * Construct a leaf position.
+ * @param layoutManager the associated layout manager
+ * @param pos the leaf position
+ * @param index the index
+ */
public LeafPosition(LayoutManager layoutManager, int pos, int index) {
super(layoutManager, index);
leafPos = pos;
}
+ /** @return leaf position */
public int getLeafPos() {
return leafPos;
}
+ /** {@inheritDoc} */
public boolean generatesAreas() {
return getLM() != null;
}
diff --git a/src/java/org/apache/fop/layoutmgr/NonLeafPosition.java b/src/java/org/apache/fop/layoutmgr/NonLeafPosition.java
index 7089dabda..42908262f 100644
--- a/src/java/org/apache/fop/layoutmgr/NonLeafPosition.java
+++ b/src/java/org/apache/fop/layoutmgr/NonLeafPosition.java
@@ -19,19 +19,27 @@
package org.apache.fop.layoutmgr;
+/** A non-leaf position. */
public class NonLeafPosition extends Position {
private Position subPos;
+ /**
+ * Construct a leaf position.
+ * @param lm the associated layout manager
+ * @param sub the position
+ */
public NonLeafPosition(LayoutManager lm, Position sub) {
super(lm);
subPos = sub;
}
+ /** @return the sub position */
public Position getPosition() {
return subPos;
}
+ /** {@inheritDoc} */
public boolean generatesAreas() {
return (subPos != null ? subPos.generatesAreas() : false);
}
diff --git a/src/java/org/apache/fop/layoutmgr/Page.java b/src/java/org/apache/fop/layoutmgr/Page.java
index b183efa01..d8ec66e82 100644
--- a/src/java/org/apache/fop/layoutmgr/Page.java
+++ b/src/java/org/apache/fop/layoutmgr/Page.java
@@ -41,10 +41,12 @@ public class Page {
* @param pageNumber the page number (as an int)
* @param pageNumberStr the page number (as a String)
* @param blank true if this is a blank page
+ * @param spanAll true if the first span area spans all columns
*/
- public Page(SimplePageMaster spm, int pageNumber, String pageNumberStr, boolean blank) {
+ public Page(SimplePageMaster spm, int pageNumber, String pageNumberStr,
+ boolean blank, boolean spanAll) {
this.spm = spm;
- this.pageViewport = new PageViewport(spm, pageNumber, pageNumberStr, blank);
+ this.pageViewport = new PageViewport(spm, pageNumber, pageNumberStr, blank, spanAll);
}
/**
diff --git a/src/java/org/apache/fop/layoutmgr/PageBreaker.java b/src/java/org/apache/fop/layoutmgr/PageBreaker.java
index 25ecd5a75..3a41eb191 100644
--- a/src/java/org/apache/fop/layoutmgr/PageBreaker.java
+++ b/src/java/org/apache/fop/layoutmgr/PageBreaker.java
@@ -45,6 +45,7 @@ public class PageBreaker extends AbstractBreaker {
private boolean needColumnBalancing;
private PageProvider pageProvider;
private Block separatorArea;
+ private boolean spanAllActive;
/**
* The FlowLayoutManager object, which processes
@@ -54,6 +55,10 @@ public class PageBreaker extends AbstractBreaker {
private StaticContentLayoutManager footnoteSeparatorLM = null;
+ /**
+ * Construct page breaker.
+ * @param pslm the page sequence layout manager
+ */
public PageBreaker(PageSequenceLayoutManager pslm) {
this.pslm = pslm;
this.pageProvider = pslm.getPageProvider();
@@ -144,8 +149,9 @@ public class PageBreaker extends AbstractBreaker {
}
firstPart = false;
pageBreakHandled = true;
+
pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(),
- pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex());
+ pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex(), this.spanAllActive);
return super.getNextBlockList(childLC, nextSequenceStartsOn, positionAtIPDChange,
restartLM, firstElements);
}
@@ -338,8 +344,9 @@ public class PageBreaker extends AbstractBreaker {
pageBreakHandled = true;
//Update so the available BPD is reported correctly
int currentPageNum = pslm.getCurrentPageNum();
+
pageProvider.setStartOfNextElementList(currentPageNum,
- pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex());
+ pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex(), this.spanAllActive);
//Make sure we only add the areas we haven't added already
effectiveList.ignoreAtStart = newStartPos;
@@ -382,7 +389,8 @@ public class PageBreaker extends AbstractBreaker {
+ " pageBreaks.size()= " + algRestart.getPageBreaks().size());
boolean fitsOnePage
- = optimalPageCount <= pslm.getCurrentPV().getBodyRegion().getMainReference().getCurrentSpan().getColumnCount();
+ = optimalPageCount <= pslm.getCurrentPV()
+ .getBodyRegion().getMainReference().getCurrentSpan().getColumnCount();
if (needColumnBalancing) {
if (!fitsOnePage) {
@@ -411,6 +419,7 @@ public class PageBreaker extends AbstractBreaker {
addAreas(algRestart, optimalPageCount, originalList, effectiveList);
}
+ /** {@inheritDoc} */
protected void startPart(BlockSequence list, int breakClass) {
AbstractBreaker.log.debug("startPart() breakClass=" + getBreakClassName(breakClass));
if (pslm.getCurrentPage() == null) {
@@ -429,7 +438,8 @@ public class PageBreaker extends AbstractBreaker {
handleBreakTrait(breakClass);
}
pageProvider.setStartOfNextElementList(pslm.getCurrentPageNum(),
- pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex());
+ pslm.getCurrentPV().getCurrentSpan().getCurrentFlowIndex(),
+ this.spanAllActive);
}
pageBreakHandled = false;
// add static areas and resolve any new id areas
@@ -442,6 +452,7 @@ public class PageBreaker extends AbstractBreaker {
pslm.getCurrentPV().getPage().fakeNonEmpty();
}
+ /** {@inheritDoc} */
protected void finishPart(PageBreakingAlgorithm alg, PageBreakPosition pbp) {
// add footnote areas
if (pbp.footnoteFirstListIndex < pbp.footnoteLastListIndex
@@ -473,7 +484,7 @@ public class PageBreaker extends AbstractBreaker {
pslm.getCurrentPV().getCurrentSpan().notifyFlowsFinished();
}
- /** @return the current child flow layout manager */
+ /** {@inheritDoc} */
protected LayoutManager getCurrentChildLM() {
return childFLM;
}
@@ -496,9 +507,11 @@ public class PageBreaker extends AbstractBreaker {
case Constants.EN_ALL:
//break due to span change in multi-column layout
curPage.getPageViewport().createSpan(true);
+ this.spanAllActive = true;
return;
case Constants.EN_NONE:
curPage.getPageViewport().createSpan(false);
+ this.spanAllActive = false;
return;
case Constants.EN_COLUMN:
case Constants.EN_AUTO:
@@ -546,7 +559,8 @@ public class PageBreaker extends AbstractBreaker {
* @param breakVal - value of break-before or break-after trait.
*/
private boolean needBlankPageBeforeNew(int breakVal) {
- if (breakVal == Constants.EN_PAGE || (pslm.getCurrentPage().getPageViewport().getPage().isEmpty())) {
+ if (breakVal == Constants.EN_PAGE
+ || (pslm.getCurrentPage().getPageViewport().getPage().isEmpty())) {
// any page is OK or we already have an empty page
return false;
} else {
diff --git a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
index 8f60e51b7..7e54cbe43 100644
--- a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
+++ b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
@@ -103,8 +103,26 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
private int currentKeepContext = Constants.EN_AUTO;
private KnuthNode lastBeforeKeepContextSwitch;
-
- public PageBreakingAlgorithm(LayoutManager topLevelLM,
+ /**
+ * Construct a page breaking algorithm.
+ * @param topLevelLM the top level layout manager
+ * @param pageProvider the page provider
+ * @param layoutListener the layout listener
+ * @param alignment alignment of the paragraph/page. One of {@link Constants#EN_START},
+ * {@link Constants#EN_JUSTIFY}, {@link Constants#EN_CENTER},
+ * {@link Constants#EN_END}.
+ * For pages, {@link Constants#EN_BEFORE} and {@link Constants#EN_AFTER}
+ * are mapped to the corresponding inline properties,
+ * {@link Constants#EN_START} and {@link Constants#EN_END}.
+ * @param alignmentLast alignment of the paragraph's last line
+ * @param footnoteSeparatorLength length of footnote separator
+ * @param partOverflowRecovery {@code true} if too long elements should be moved to
+ * the next line/part
+ * @param autoHeight true if auto height
+ * @param favorSinglePart true if favoring single part
+ * @see BreakingAlgorithm
+ */
+ public PageBreakingAlgorithm(LayoutManager topLevelLM, // CSOK: ParameterNumber
PageProvider pageProvider,
PageBreakingLayoutListener layoutListener,
int alignment, int alignmentLast,
@@ -128,15 +146,16 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
protected class KnuthPageNode extends KnuthNode {
/** Additional length due to footnotes. */
- public int totalFootnotes;
+ public int totalFootnotes; // CSOK: VisibilityModifier
/** Index of the last inserted footnote. */
- public int footnoteListIndex;
+ public int footnoteListIndex; // CSOK: VisibilityModifier
/** Index of the last inserted element of the last inserted footnote. */
- public int footnoteElementIndex;
+ public int footnoteElementIndex; // CSOK: VisibilityModifier
- public KnuthPageNode(int position, int line, int fitness,
+ public KnuthPageNode(int position, // CSOK: ParameterNumber
+ int line, int fitness,
int totalWidth, int totalStretch, int totalShrink,
int totalFootnotes, int footnoteListIndex, int footnoteElementIndex,
double adjustRatio, int availableShrink, int availableStretch,
@@ -206,7 +225,8 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
log.debug("Recovering from too long: " + lastTooLong);
log.debug("\tlastTooShort = " + getLastTooShort());
log.debug("\tlastBeforeKeepContextSwitch = " + lastBeforeKeepContextSwitch);
- log.debug("\tcurrentKeepContext = " + AbstractBreaker.getBreakClassName(currentKeepContext));
+ log.debug("\tcurrentKeepContext = "
+ + AbstractBreaker.getBreakClassName(currentKeepContext));
}
if (lastBeforeKeepContextSwitch == null
@@ -261,7 +281,8 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
}
/** {@inheritDoc} */
- protected KnuthNode createNode(int position, int line, int fitness,
+ protected KnuthNode createNode(int position, // CSOK: ParameterNumber
+ int line, int fitness,
int totalWidth, int totalStretch, int totalShrink,
double adjustRatio, int availableShrink, int availableStretch,
int difference, double totalDemerits, KnuthNode previous) {
@@ -473,7 +494,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
KnuthPageNode pageNode = (KnuthPageNode) activeNode;
int actualWidth = totalWidth - pageNode.totalWidth;
int footnoteSplit = 0;
- boolean canDeferOldFootnotes;
+ boolean canDeferOldFN;
if (element.isPenalty()) {
actualWidth += element.getWidth();
}
@@ -492,11 +513,12 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
footnoteListIndex = footnotesList.size() - 1;
footnoteElementIndex
= getFootnoteList(footnoteListIndex).size() - 1;
- } else if (((canDeferOldFootnotes
- = checkCanDeferOldFootnotes(pageNode, elementIndex))
+ } else if (((canDeferOldFN = canDeferOldFootnotes // CSOK: InnerAssignment
+ (pageNode, elementIndex))
|| newFootnotes)
- && (footnoteSplit = getFootnoteSplit(pageNode,
- getLineWidth(activeNode.line) - actualWidth, canDeferOldFootnotes)) > 0) {
+ && (footnoteSplit = getFootnoteSplit // CSOK: InnerAssignment
+ (pageNode, getLineWidth(activeNode.line) - actualWidth,
+ canDeferOldFN)) > 0) {
// it is allowed to break or even defer footnotes if either:
// - there are new footnotes in the last piece of content, and
// there is space to add at least a piece of the first one
@@ -541,7 +563,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
* @param contentElementIndex index of the Knuth element considered for the
* current page break
*/
- private boolean checkCanDeferOldFootnotes(KnuthPageNode node, int contentElementIndex) {
+ private boolean canDeferOldFootnotes(KnuthPageNode node, int contentElementIndex) {
return (noBreakBetween(node.position, contentElementIndex)
&& deferredFootnotes(node.footnoteListIndex,
node.footnoteElementIndex, node.totalFootnotes));
@@ -584,7 +606,8 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
index++) {
if (par.getElement(index).isGlue() && par.getElement(index - 1).isBox()
|| par.getElement(index).isPenalty()
- && ((KnuthElement) par.getElement(index)).getPenalty() < KnuthElement.INFINITE) {
+ && ((KnuthElement) par
+ .getElement(index)).getPenalty() < KnuthElement.INFINITE) {
// break found
break;
}
@@ -865,8 +888,9 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
insertedFootnotesLength = tmpLength;
footnoteElementIndex
= getFootnoteList(footnoteListIndex).size() - 1;
- } else if ((split = getFootnoteSplit(footnoteListIndex, footnoteElementIndex,
- insertedFootnotesLength, availableBPD, true)) > 0) {
+ } else if ((split = getFootnoteSplit // CSOK: InnerAssignment
+ (footnoteListIndex, footnoteElementIndex,
+ insertedFootnotesLength, availableBPD, true)) > 0) {
// add a piece of a footnote
availableBPD -= split;
insertedFootnotesLength += split;
@@ -1101,7 +1125,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm {
*/
protected void addNode(int line, KnuthNode node) {
if (node.position < par.size() - 1 && line > 0
- && (ipdDifference = compareIPDs(line - 1)) != 0) {
+ && (ipdDifference = compareIPDs(line - 1)) != 0) { // CSOK: InnerAssignment
log.trace("IPD changes at page " + line);
if (bestNodeForIPDChange == null
|| node.totalDemerits < bestNodeForIPDChange.totalDemerits) {
diff --git a/src/java/org/apache/fop/layoutmgr/PageProvider.java b/src/java/org/apache/fop/layoutmgr/PageProvider.java
index 2e531a8d8..8caafa72b 100644
--- a/src/java/org/apache/fop/layoutmgr/PageProvider.java
+++ b/src/java/org/apache/fop/layoutmgr/PageProvider.java
@@ -51,6 +51,7 @@ public class PageProvider implements Constants {
private int startPageOfPageSequence;
private int startPageOfCurrentElementList;
private int startColumnOfCurrentElementList;
+ private boolean spanAllForCurrentElementList;
private List cachedPages = new java.util.ArrayList();
private int lastPageIndex = -1;
@@ -88,12 +89,17 @@ public class PageProvider implements Constants {
* on so it can later retrieve PageViewports relative to this first page.
* @param startPage the number of the first page for the element list.
* @param startColumn the starting column number for the element list.
+ * @param spanAll true if the current element list is for a column-spanning section
*/
- public void setStartOfNextElementList(int startPage, int startColumn) {
- log.debug("start of the next element list is:"
- + " page=" + startPage + " col=" + startColumn);
+ public void setStartOfNextElementList(int startPage, int startColumn, boolean spanAll) {
+ if (log.isDebugEnabled()) {
+ log.debug("start of the next element list is:"
+ + " page=" + startPage + " col=" + startColumn
+ + (spanAll ? ", column-spanning" : ""));
+ }
this.startPageOfCurrentElementList = startPage - startPageOfPageSequence + 1;
this.startColumnOfCurrentElementList = startColumn;
+ this.spanAllForCurrentElementList = spanAll;
//Reset Cache
this.lastRequestedIndex = -1;
this.lastReportedBPD = -1;
@@ -290,7 +296,7 @@ public class PageProvider implements Constants {
if (log.isTraceEnabled()) {
log.trace("Caching " + index);
}
- cacheNextPage(index, isBlank, isLastPage);
+ cacheNextPage(index, isBlank, isLastPage, this.spanAllForCurrentElementList);
}
Page page = (Page)cachedPages.get(intIndex);
boolean replace = false;
@@ -306,7 +312,7 @@ public class PageProvider implements Constants {
}
if (replace) {
discardCacheStartingWith(intIndex);
- page = cacheNextPage(index, isBlank, isLastPage);
+ page = cacheNextPage(index, isBlank, isLastPage, this.spanAllForCurrentElementList);
}
return page;
}
@@ -320,7 +326,7 @@ public class PageProvider implements Constants {
}
}
- private Page cacheNextPage(int index, boolean isBlank, boolean isLastPage) {
+ private Page cacheNextPage(int index, boolean isBlank, boolean isLastPage, boolean spanAll) {
String pageNumberString = pageSeq.makeFormattedPageNumber(index);
boolean isFirstPage = (startPageOfPageSequence == index);
SimplePageMaster spm = pageSeq.getNextSimplePageMaster(
@@ -335,7 +341,7 @@ public class PageProvider implements Constants {
eventProducer.flowNotMappingToRegionBody(this,
pageSeq.getMainFlow().getFlowName(), spm.getMasterName(), spm.getLocator());
}
- Page page = new Page(spm, index, pageNumberString, isBlank);
+ Page page = new Page(spm, index, pageNumberString, isBlank, spanAll);
//Set unique key obtained from the AreaTreeHandler
page.getPageViewport().setKey(areaTreeHandler.generatePageViewportKey());
page.getPageViewport().setForeignAttributes(spm.getForeignAttributes());
diff --git a/src/java/org/apache/fop/layoutmgr/Position.java b/src/java/org/apache/fop/layoutmgr/Position.java
index 10ad5878e..8230e64f0 100644
--- a/src/java/org/apache/fop/layoutmgr/Position.java
+++ b/src/java/org/apache/fop/layoutmgr/Position.java
@@ -19,32 +19,69 @@
package org.apache.fop.layoutmgr;
+/** A position. */
public class Position {
private LayoutManager layoutManager;
private int index = -1;
+ /**
+ * Construct a position.
+ * @param lm the associated layout manager
+ */
public Position(LayoutManager lm) {
layoutManager = lm;
}
+ /**
+ * Construct a position.
+ * @param lm the associated layout manager
+ * @param index the index
+ */
public Position(LayoutManager lm, int index) {
this(lm);
setIndex(index);
}
-
+ /** @return associated layout manager */
public LayoutManager getLM() {
return layoutManager;
}
/**
- * Overridden by NonLeafPosition to return the Position of its
- * child LM.
+ * @param depth the depth at which the LM in this position is found
+ * @return associated layout manager
+ */
+ public LayoutManager getLM(int depth) {
+ Position subPos = getPosition(depth);
+ if (subPos == null) {
+ return null;
+ } else {
+ return subPos.getLM();
+ }
+ }
+
+ /**
+ * Overridden by NonLeafPosition to return the Position of its child LM.
+ * @return a position or null
*/
public Position getPosition() {
return null;
}
+ /**
+ * Overridden by NonLeafPosition to return the Position of its child LM.
+ * @param depth the depth at which the position in this position is found
+ * @return a position or null
+ */
+ public Position getPosition(int depth) {
+ Position subPos = this;
+ for (int i = 0; i < depth && subPos != null; ++i, subPos = subPos.getPosition()) {
+ // no-op
+ }
+ return subPos;
+ }
+
+ /** @return true if generates areas */
public boolean generatesAreas() {
return false;
}
@@ -67,12 +104,13 @@ public class Position {
return this.index;
}
- public String getShortLMName() {
+ /** @return short name of associated layout manager */
+ protected String getShortLMName() {
if (getLM() != null) {
String lm = getLM().toString();
int idx = lm.lastIndexOf('.');
if (idx >= 0 && lm.indexOf('@') > 0) {
- return(lm.substring(idx + 1));
+ return lm.substring(idx + 1);
} else {
return lm;
}
diff --git a/src/java/org/apache/fop/layoutmgr/PositionIterator.java b/src/java/org/apache/fop/layoutmgr/PositionIterator.java
index b50035313..63ff8461a 100644
--- a/src/java/org/apache/fop/layoutmgr/PositionIterator.java
+++ b/src/java/org/apache/fop/layoutmgr/PositionIterator.java
@@ -22,6 +22,7 @@ package org.apache.fop.layoutmgr;
import java.util.Iterator;
import java.util.NoSuchElementException;
+/** A position iterator. */
public abstract class PositionIterator implements Iterator {
private Iterator parentIter;
@@ -29,12 +30,17 @@ public abstract class PositionIterator implements Iterator {
private LayoutManager childLM;
private boolean bHasNext;
+ /**
+ * Construct position iterator.
+ * @param pIter an iterator to use as parent
+ */
protected PositionIterator(Iterator pIter) {
parentIter = pIter;
lookAhead();
//checkNext();
}
+ /** @return layout manager of next child layout manager or null */
public LayoutManager getNextChildLM() {
// Move to next "segment" of iterator, ie: new childLM
if (childLM == null && nextObj != null) {
@@ -44,8 +50,16 @@ public abstract class PositionIterator implements Iterator {
return childLM;
}
+ /**
+ * @param nextObj next object from which to obtain position
+ * @return layout manager
+ */
protected abstract LayoutManager getLM(Object nextObj);
+ /**
+ * @param nextObj next object from which to obtain position
+ * @return position of next object
+ */
protected abstract Position getPos(Object nextObj);
private void lookAhead() {
@@ -57,6 +71,7 @@ public abstract class PositionIterator implements Iterator {
}
}
+ /** @return true if not at end of sub-sequence with same child layout manager */
protected boolean checkNext() {
LayoutManager lm = getLM(nextObj);
if (childLM == null) {
@@ -70,17 +85,20 @@ public abstract class PositionIterator implements Iterator {
return true;
}
+ /** end (reset) iterator */
protected void endIter() {
bHasNext = false;
nextObj = null;
childLM = null;
}
+ /** {@inheritDoc} */
public boolean hasNext() {
return (bHasNext && checkNext());
}
+ /** {@inheritDoc} */
public Object next() throws NoSuchElementException {
if (bHasNext) {
Object retObj = getPos(nextObj);
@@ -91,10 +109,12 @@ public abstract class PositionIterator implements Iterator {
}
}
+ /** @return peek at next object */
public Object peekNext() {
return nextObj;
}
+ /** {@inheritDoc} */
public void remove() throws UnsupportedOperationException {
throw new UnsupportedOperationException("PositionIterator doesn't support remove");
}
diff --git a/src/java/org/apache/fop/layoutmgr/SpaceResolver.java b/src/java/org/apache/fop/layoutmgr/SpaceResolver.java
index 6dbf107f3..6890d4ebc 100644
--- a/src/java/org/apache/fop/layoutmgr/SpaceResolver.java
+++ b/src/java/org/apache/fop/layoutmgr/SpaceResolver.java
@@ -32,10 +32,10 @@ import org.apache.fop.traits.MinOptMax;
* UnresolvedListElements descendants by the right combination of KnuthElements on an element
* list.
*/
-public class SpaceResolver {
+public final class SpaceResolver {
/** Logger instance */
- protected static Log log = LogFactory.getLog(SpaceResolver.class);
+ private static final Log LOG = LogFactory.getLog(SpaceResolver.class);
private UnresolvedListElementWithLength[] firstPart;
private BreakElement breakPoss;
@@ -93,25 +93,25 @@ public class SpaceResolver {
//Add pending elements from higher level FOs
if (breakPoss != null) {
if (breakPoss.getPendingAfterMarks() != null) {
- if (log.isTraceEnabled()) {
- log.trace(" adding pending before break: "
+ if (LOG.isTraceEnabled()) {
+ LOG.trace(" adding pending before break: "
+ breakPoss.getPendingAfterMarks());
}
first.addAll(0, breakPoss.getPendingAfterMarks());
}
if (breakPoss.getPendingBeforeMarks() != null) {
- if (log.isTraceEnabled()) {
- log.trace(" adding pending after break: "
+ if (LOG.isTraceEnabled()) {
+ LOG.trace(" adding pending after break: "
+ breakPoss.getPendingBeforeMarks());
}
second.addAll(0, breakPoss.getPendingBeforeMarks());
}
}
- if (log.isTraceEnabled()) {
- log.trace("before: " + first);
- log.trace(" break: " + breakPoss);
- log.trace("after: " + second);
- log.trace("NO-BREAK: " + toString(noBreak, noBreakLengths));
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("before: " + first);
+ LOG.trace(" break: " + breakPoss);
+ LOG.trace("after: " + second);
+ LOG.trace("NO-BREAK: " + toString(noBreak, noBreakLengths));
}
if (first != null) {
@@ -163,15 +163,15 @@ public class SpaceResolver {
if (elems[effIndex] instanceof BorderOrPaddingElement) {
BorderOrPaddingElement bop = (BorderOrPaddingElement)elems[effIndex];
if (bop.isConditional() && !(bop.isFirst() || bop.isLast())) {
- if (log.isDebugEnabled()) {
- log.debug("Nulling conditional element: " + bop);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Nulling conditional element: " + bop);
}
lengths[effIndex] = null;
}
}
}
- if (log.isTraceEnabled() && elems.length > 0) {
- log.trace("-->Resulting list: " + toString(elems, lengths));
+ if (LOG.isTraceEnabled() && elems.length > 0) {
+ LOG.trace("-->Resulting list: " + toString(elems, lengths));
}
}
@@ -193,20 +193,20 @@ public class SpaceResolver {
} else if (!elems[effIndex].isConditional()) {
break;
}
- if (log.isDebugEnabled()) {
- log.debug("Nulling conditional element using 4.3.1, rule 1: " + elems[effIndex]);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Nulling conditional element using 4.3.1, rule 1: " + elems[effIndex]);
}
lengths[effIndex] = null;
}
- if (log.isTraceEnabled() && elems.length > 0) {
- log.trace("-->Resulting list: " + toString(elems, lengths));
+ if (LOG.isTraceEnabled() && elems.length > 0) {
+ LOG.trace("-->Resulting list: " + toString(elems, lengths));
}
}
private void performSpaceResolutionRules2to3(UnresolvedListElement[] elems,
MinOptMax[] lengths, int start, int end) {
- if (log.isTraceEnabled()) {
- log.trace("rule 2-3: " + start + "-" + end);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("rule 2-3: " + start + "-" + end);
}
SpaceElement space;
int remaining;
@@ -235,8 +235,8 @@ public class SpaceResolver {
}
space = (SpaceElement)elems[i];
if (!space.isForcing()) {
- if (log.isDebugEnabled()) {
- log.debug("Nulling non-forcing space-specifier using 4.3.1, rule 2: "
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Nulling non-forcing space-specifier using 4.3.1, rule 2: "
+ elems[i]);
}
lengths[i] = null;
@@ -255,8 +255,8 @@ public class SpaceResolver {
space = (SpaceElement)elems[i];
highestPrecedence = Math.max(highestPrecedence, space.getPrecedence());
}
- if (highestPrecedence != 0 && log.isDebugEnabled()) {
- log.debug("Highest precedence is " + highestPrecedence);
+ if (highestPrecedence != 0 && LOG.isDebugEnabled()) {
+ LOG.debug("Highest precedence is " + highestPrecedence);
}
//Suppress space-specifiers with lower precedence
remaining = 0;
@@ -267,8 +267,8 @@ public class SpaceResolver {
}
space = (SpaceElement)elems[i];
if (space.getPrecedence() != highestPrecedence) {
- if (log.isDebugEnabled()) {
- log.debug("Nulling space-specifier with precedence "
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Nulling space-specifier with precedence "
+ space.getPrecedence() + " using 4.3.1, rule 3: "
+ elems[i]);
}
@@ -278,8 +278,8 @@ public class SpaceResolver {
remaining++;
}
}
- if (log.isDebugEnabled()) {
- log.debug("Greatest optimum: " + greatestOptimum);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Greatest optimum: " + greatestOptimum);
}
if (remaining <= 1) {
return;
@@ -292,8 +292,8 @@ public class SpaceResolver {
}
space = (SpaceElement)elems[i];
if (space.getLength().getOpt() < greatestOptimum) {
- if (log.isDebugEnabled()) {
- log.debug("Nulling space-specifier with smaller optimum length "
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Nulling space-specifier with smaller optimum length "
+ "using 4.3.1, rule 3: "
+ elems[i]);
}
@@ -316,8 +316,8 @@ public class SpaceResolver {
min = Math.max(min, space.getLength().getMin());
max = Math.min(max, space.getLength().getMax());
if (remaining > 1) {
- if (log.isDebugEnabled()) {
- log.debug("Nulling non-last space-specifier using 4.3.1, rule 3, second part: "
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Nulling non-last space-specifier using 4.3.1, rule 3, second part: "
+ elems[i]);
}
lengths[i] = null;
@@ -327,9 +327,9 @@ public class SpaceResolver {
}
}
- if (log.isTraceEnabled() && elems.length > 0) {
- log.trace("Remaining spaces: " + remaining);
- log.trace("-->Resulting list: " + toString(elems, lengths));
+ if (LOG.isTraceEnabled() && elems.length > 0) {
+ LOG.trace("Remaining spaces: " + remaining);
+ LOG.trace("-->Resulting list: " + toString(elems, lengths));
}
}
@@ -389,7 +389,7 @@ public class SpaceResolver {
if (hasFirstPart()) {
//Now that we've handled isFirst/isLast conditions, we need to look at the
//active part in its normal order so swap it back.
- log.trace("Swapping first and second parts.");
+ LOG.trace("Swapping first and second parts.");
UnresolvedListElementWithLength[] tempList;
MinOptMax[] tempLengths;
tempList = secondPart;
@@ -439,7 +439,8 @@ public class SpaceResolver {
}
// No break
- // TODO: We can't use a MinOptMax for glue2, because min <= opt <= max is not always true - why?
+ // TODO: We can't use a MinOptMax for glue2,
+ // because min <= opt <= max is not always true - why?
MinOptMax noBreakLength = sum(noBreakLengths);
MinOptMax spaceSum = spaceBeforeBreak.plus(spaceAfterBreak);
int glue2width = noBreakLength.getOpt() - spaceSum.getOpt();
@@ -543,6 +544,7 @@ public class SpaceResolver {
return this.originalPosition;
}
+ /** {@inheritDoc} */
public Position getPosition() {
return originalPosition;
}
@@ -595,8 +597,8 @@ public class SpaceResolver {
* @param elems the element list
*/
public static void resolveElementList(List elems) {
- if (log.isTraceEnabled()) {
- log.trace(elems);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace(elems);
}
boolean first = true;
boolean last = false;
@@ -608,8 +610,8 @@ public class SpaceResolver {
while (iter.hasNext()) {
ListElement el = (ListElement)iter.next();
if (el.isUnresolvedElement()) {
- if (log.isTraceEnabled()) {
- log.trace("unresolved found: " + el + " " + first + "/" + last);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("unresolved found: " + el + " " + first + "/" + last);
}
BreakElement breakPoss = null;
//Clear temp lists
@@ -646,7 +648,7 @@ public class SpaceResolver {
}
//last = !iter.hasNext();
if (breakPoss == null && unresolvedSecond.size() == 0 && !last) {
- log.trace("Swap first and second parts in no-break condition,"
+ LOG.trace("Swap first and second parts in no-break condition,"
+ " second part is empty.");
//The first list is reversed, so swap if this shouldn't happen
List swapList = unresolvedSecond;
@@ -654,7 +656,7 @@ public class SpaceResolver {
unresolvedFirst = swapList;
}
- log.debug("----start space resolution (first=" + first + ", last=" + last + ")...");
+ LOG.debug("----start space resolution (first=" + first + ", last=" + last + ")...");
SpaceResolver resolver = new SpaceResolver(
unresolvedFirst, breakPoss, unresolvedSecond, first, last);
if (!last) {
@@ -664,7 +666,7 @@ public class SpaceResolver {
if (!last && skipNextElement) {
iter.next();
}
- log.debug("----end space resolution.");
+ LOG.debug("----end space resolution.");
}
first = false;
}
diff --git a/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java b/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java
index 140d90bb8..83a67b101 100644
--- a/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java
+++ b/src/java/org/apache/fop/layoutmgr/SpaceSpecifier.java
@@ -155,6 +155,7 @@ public class SpaceSpecifier implements Cloneable {
return resolvedSpace;
}
+ /** {@inheritDoc} */
public String toString() {
return "Space Specifier (resolved at begin/end of ref. area:):\n"
+ resolve(false) + "\n" + resolve(true);
diff --git a/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java b/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java
index 72fddf199..2091484a4 100644
--- a/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java
@@ -33,18 +33,18 @@ public interface TopLevelLayoutManager {
* page sequence will be created and sent to the AreaTreeModel
* for rendering.
*/
- public void activateLayout();
+ void activateLayout();
/**
* Act upon the force-page-count trait,
* in relation to the initial-page-number trait of the following page-sequence.
* @param nextPageSeqInitialPageNumber initial-page-number trait of next page-sequence
*/
- public void doForcePageCount(Numeric nextPageSeqInitialPageNumber);
+ void doForcePageCount(Numeric nextPageSeqInitialPageNumber);
/**
* Finished the page-sequence and notifies everyone about it.
*/
- public void finishPageSequence();
+ void finishPageSequence();
} \ No newline at end of file
diff --git a/src/java/org/apache/fop/layoutmgr/TraitSetter.java b/src/java/org/apache/fop/layoutmgr/TraitSetter.java
index 911b6dcc6..6039ad941 100644
--- a/src/java/org/apache/fop/layoutmgr/TraitSetter.java
+++ b/src/java/org/apache/fop/layoutmgr/TraitSetter.java
@@ -39,10 +39,13 @@ import org.apache.fop.traits.MinOptMax;
/**
* This is a helper class used for setting common traits on areas.
*/
-public class TraitSetter {
+public final class TraitSetter {
+
+ private TraitSetter() {
+ }
/** logger */
- protected static Log log = LogFactory.getLog(TraitSetter.class);
+ private static final Log LOG = LogFactory.getLog(TraitSetter.class);
/**
* Sets border and padding traits on areas.
@@ -339,7 +342,7 @@ public class TraitSetter {
+ backProps.backgroundPositionHorizontal.getValue(refContext));
} else {
// TODO Area IPD has to be set for this to work
- log.warn("Horizontal background image positioning ignored"
+ LOG.warn("Horizontal background image positioning ignored"
+ " because the IPD was not set on the area."
+ " (Yes, it's a bug in FOP)");
}
@@ -356,7 +359,7 @@ public class TraitSetter {
+ backProps.backgroundPositionVertical.getValue(refContext));
} else {
// TODO Area BPD has to be set for this to work
- log.warn("Vertical background image positioning ignored"
+ LOG.warn("Vertical background image positioning ignored"
+ " because the BPD was not set on the area."
+ " (Yes, it's a bug in FOP)");
}
@@ -407,7 +410,7 @@ public class TraitSetter {
back.setHoriz(horizontal);
} else {
//TODO Area IPD has to be set for this to work
- log.warn("Horizontal background image positioning ignored"
+ LOG.warn("Horizontal background image positioning ignored"
+ " because the IPD was not set on the area."
+ " (Yes, it's a bug in FOP)");
}
@@ -431,7 +434,7 @@ public class TraitSetter {
back.setVertical(vertical);
} else {
//TODO Area BPD has to be set for this to work
- log.warn("Vertical background image positioning ignored"
+ LOG.warn("Vertical background image positioning ignored"
+ " because the BPD was not set on the area."
+ " (Yes, it's a bug in FOP)");
}
diff --git a/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java b/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java
index d1b16a523..0667b9355 100644
--- a/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java
+++ b/src/java/org/apache/fop/layoutmgr/UnresolvedListElementWithLength.java
@@ -30,7 +30,7 @@ import org.apache.fop.traits.MinOptMax;
public abstract class UnresolvedListElementWithLength extends UnresolvedListElement {
/** Logger instance */
- protected static Log log = LogFactory.getLog(UnresolvedListElementWithLength.class);
+ protected static final Log log = LogFactory.getLog(UnresolvedListElementWithLength.class);
private MinOptMax length;
private boolean conditional;
diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java
index a74fac743..e090fbae6 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java
@@ -30,7 +30,6 @@ import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontTriplet;
import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.TraitSetter;
@@ -99,10 +98,9 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa
}
/**
- * If id can be resolved then simply return a word, otherwise
+ * If id can be resolved then simply return a text area, otherwise
* return a resolvable area
*
- * @param parentLM the parent LayoutManager
* @return a corresponding InlineArea
*/
private InlineArea getPageNumberCitationInlineArea() {
diff --git a/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java b/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java
index 4eb0abd64..2e8a3aca7 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java
@@ -237,6 +237,8 @@ public class AlignmentContext implements Constants {
case EN_MATHEMATICAL:
this.alignmentBaselineIdentifier = alignmentBaseline;
break;
+ default:
+ break;
}
}
@@ -307,7 +309,6 @@ public class AlignmentContext implements Constants {
* Calculates the baseline shift value based on the baseline-shift
* property value.
* @param baselineShift the baseline shift property value
- * @return the computed baseline shift value
*/
private void setBaselineShift(Length baselineShift) {
baselineShiftValue = 0;
@@ -331,6 +332,9 @@ public class AlignmentContext implements Constants {
, LengthBase.CUSTOM_BASE
, parentAlignmentContext.getLineHeight()));
break;
+ default:
+ break;
+
}
}
@@ -354,10 +358,12 @@ public class AlignmentContext implements Constants {
return parentAlignmentContext.getScaledBaselineTable()
.getBaseline(alignmentBaselineIdentifier)
- scaledBaselineTable
- .deriveScaledBaselineTable(parentAlignmentContext.getDominantBaselineIdentifier())
+ .deriveScaledBaselineTable(parentAlignmentContext
+ .getDominantBaselineIdentifier())
.getBaseline(alignmentBaselineIdentifier)
- scaledBaselineTable
- .getBaseline(parentAlignmentContext.getDominantBaselineIdentifier())
+ .getBaseline(parentAlignmentContext
+ .getDominantBaselineIdentifier())
+ baselineShiftValue;
}
@@ -514,11 +520,11 @@ public class AlignmentContext implements Constants {
/** {@inheritDoc} */
public String toString() {
StringBuffer sb = new StringBuffer(64);
- sb.append("ah=" + areaHeight);
- sb.append(" lp=" + lineHeight);
- sb.append(" ap=" + alignmentPoint);
- sb.append(" ab=" + alignmentBaselineIdentifier);
- sb.append(" bs=" + baselineShiftValue);
+ sb.append("areaHeight=" + areaHeight);
+ sb.append(" lineHeight=" + lineHeight);
+ sb.append(" alignmentPoint=" + alignmentPoint);
+ sb.append(" alignmentBaselineID=" + alignmentBaselineIdentifier);
+ sb.append(" baselineShift=" + baselineShiftValue);
return sb.toString();
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.java b/src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.java
index 73f414bf7..467f2e154 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/BasicScaledBaselineTable.java
@@ -21,9 +21,7 @@ package org.apache.fop.layoutmgr.inline;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.datatypes.Length;
-import org.apache.fop.datatypes.LengthBase;
-import org.apache.fop.datatypes.SimplePercentBaseContext;
+
import org.apache.fop.fo.Constants;
@@ -96,39 +94,44 @@ public class BasicScaledBaselineTable implements ScaledBaselineTable, Constants
* @return the baseline offset
*/
public int getBaseline(int baselineIdentifier) {
- int offset = 0;
+ int offset;
if (!isHorizontalWritingMode()) {
switch (baselineIdentifier) {
+ default:
case EN_TOP:
case EN_TEXT_TOP:
case EN_TEXT_BOTTOM:
case EN_BOTTOM:
log.warn("The given baseline is only supported for horizontal"
+ " writing modes");
- return 0;
+ offset = 0;
+ }
+ } else {
+ switch (baselineIdentifier) {
+ case EN_TOP: // fall through
+ case EN_BEFORE_EDGE:
+ offset = beforeEdgeOffset;
+ break;
+ case EN_TEXT_TOP:
+ case EN_TEXT_BEFORE_EDGE:
+ case EN_HANGING:
+ case EN_CENTRAL:
+ case EN_MIDDLE:
+ case EN_MATHEMATICAL:
+ case EN_ALPHABETIC:
+ case EN_IDEOGRAPHIC:
+ case EN_TEXT_BOTTOM:
+ case EN_TEXT_AFTER_EDGE:
+ offset = getBaselineDefaultOffset(baselineIdentifier) - dominantBaselineOffset;
+ break;
+ case EN_BOTTOM: // fall through
+ case EN_AFTER_EDGE:
+ offset = afterEdgeOffset;
+ break;
+ default:
+ offset = 0;
+ break;
}
- }
- switch (baselineIdentifier) {
- case EN_TOP: // fall through
- case EN_BEFORE_EDGE:
- offset = beforeEdgeOffset;
- break;
- case EN_TEXT_TOP:
- case EN_TEXT_BEFORE_EDGE:
- case EN_HANGING:
- case EN_CENTRAL:
- case EN_MIDDLE:
- case EN_MATHEMATICAL:
- case EN_ALPHABETIC:
- case EN_IDEOGRAPHIC:
- case EN_TEXT_BOTTOM:
- case EN_TEXT_AFTER_EDGE:
- offset = getBaselineDefaultOffset(baselineIdentifier) - dominantBaselineOffset;
- break;
- case EN_BOTTOM: // fall through
- case EN_AFTER_EDGE:
- offset = afterEdgeOffset;
- break;
}
return offset;
}
@@ -168,6 +171,8 @@ public class BasicScaledBaselineTable implements ScaledBaselineTable, Constants
case EN_TEXT_AFTER_EDGE:
offset = depth;
break;
+ default:
+ break;
}
return offset;
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java
index d5b2e5803..f342399fc 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java
@@ -35,6 +35,11 @@ public class BidiLayoutManager extends LeafNodeLayoutManager {
private List children;
+ /**
+ * Construct bidi layout manager.
+ * @param node bidi override FO
+ * @param cLM parent layout manager
+ */
public BidiLayoutManager(BidiOverride node, InlineLayoutManager cLM) {
super(node);
setParent(cLM);
@@ -53,10 +58,15 @@ public class BidiLayoutManager extends LeafNodeLayoutManager {
*/
}
+ /** @return number of children */
public int size() {
return children.size();
}
+ /**
+ * @param index of child inline area
+ * @return a child inline area
+ */
public InlineArea get(int index) {
return (InlineArea) children.get(index);
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
index a19680f51..66e162692 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
@@ -194,9 +194,8 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager {
areaInfo.alignmentContext,
notifyPos(new LeafPosition(this, 0)), false));
if (areaInfo.bHyphenated) {
- returnList.add
- (new KnuthPenalty(hyphIPD, KnuthPenalty.FLAGGED_PENALTY, true,
- new LeafPosition(this, -1), false));
+ returnList.add(new KnuthPenalty(hyphIPD, KnuthPenalty.FLAGGED_PENALTY, true,
+ new LeafPosition(this, -1), false));
}
} else {
// adjustable letter space
@@ -207,7 +206,8 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager {
new LeafPosition(this, -1), true));
returnList.add(new KnuthGlue(letterSpaceIPD.mult(areaInfo.iLScount),
new LeafPosition(this, -1), true));
- returnList.add(new KnuthInlineBox(0, null, notifyPos(new LeafPosition(this, -1)), true));
+ returnList.add (
+ new KnuthInlineBox(0, null, notifyPos(new LeafPosition(this, -1)), true));
if (areaInfo.bHyphenated) {
returnList.add(new KnuthPenalty(hyphIPD, KnuthPenalty.FLAGGED_PENALTY, true,
new LeafPosition(this, -1), false));
diff --git a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
index d0dcc2bb8..c7eaa1820 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
@@ -67,6 +67,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
* Constructs a new ContentLayoutManager
*
* @param area The parent area
+ * @param parentLM the parent layout manager
*/
public ContentLayoutManager(Area area, LayoutManager parentLM) {
holder = area;
@@ -100,11 +101,12 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
}
}
+ /** {@inheritDoc} */
public void initialize() {
// Empty
}
- public void fillArea(LayoutManager curLM) {
+ private void fillArea(LayoutManager curLM) {
int ipd = 1000000;
@@ -150,6 +152,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
curLM.addAreas(contentPosIter, lc);
}
+ /** {@inheritDoc} */
public void addAreas(PositionIterator posIter, LayoutContext context) {
// add the content areas
// the area width has already been adjusted, and it must remain unchanged
@@ -163,6 +166,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
((InlineArea)holder).setIPD(savedIPD);
}
+ /** @return stack size */
public int getStackingSize() {
return stackSize;
}
@@ -248,6 +252,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
}
}
+ /** {@inheritDoc} */
public List getNextKnuthElements(LayoutContext context, int alignment) {
List contentList = new LinkedList();
List returnedList;
@@ -264,7 +269,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
Object obj = returnedList.remove(0);
if (obj instanceof KnuthSequence) {
KnuthSequence ks = (KnuthSequence)obj;
- for (Iterator it = ks.iterator(); it.hasNext(); ) {
+ for (Iterator it = ks.iterator(); it.hasNext();) {
contentElement = (KnuthElement)it.next();
stackSize += contentElement.getWidth();
contentList.add(contentElement);
@@ -282,37 +287,46 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
return contentList;
}
+ /** {@inheritDoc} */
public List addALetterSpaceTo(List oldList) {
return oldList;
}
- /**
- * Remove the word space represented by the given elements
- *
- * @param oldList the elements representing the word space
- */
- public void removeWordSpace(List oldList) {
- // do nothing
- log.warn(this.getClass().getName() + " should not receive a call to removeWordSpace(list)");
+ /** {@inheritDoc} */
+ public List addALetterSpaceTo(List oldList, int depth) {
+ return addALetterSpaceTo(oldList);
}
+ /** {@inheritDoc} */
public String getWordChars(Position pos) {
return "";
}
+ /** {@inheritDoc} */
public void hyphenate(Position pos, HyphContext hc) {
}
+ /** {@inheritDoc} */
public boolean applyChanges(List oldList) {
return false;
}
- public List getChangedKnuthElements(List oldList,
- /*int flaggedPenalty,*/
- int alignment) {
+ /** {@inheritDoc} */
+ public boolean applyChanges(List oldList, int depth) {
+ return applyChanges(oldList);
+ }
+
+ /** {@inheritDoc} */
+ public List getChangedKnuthElements(List oldList, int alignment) {
return null;
}
+ /** {@inheritDoc} */
+ public List getChangedKnuthElements(List oldList, int alignment, int depth) {
+ return getChangedKnuthElements(oldList, alignment);
+ }
+
+ /** {@inheritDoc} */
public PageSequenceLayoutManager getPSLM() {
return parentLM.getPSLM();
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java
index 2cdc7a6fc..efa6f880a 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java
@@ -122,9 +122,8 @@ public class FootnoteLayoutManager extends InlineStackingLayoutManager {
/**
* {@inheritDoc}
*/
- public List getChangedKnuthElements(List oldList,
- int alignment) {
- List returnedList = super.getChangedKnuthElements(oldList, alignment);
+ public List getChangedKnuthElements(List oldList, int alignment, int depth) {
+ List returnedList = super.getChangedKnuthElements(oldList, alignment, depth);
addAnchor(returnedList);
return returnedList;
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/HyphContext.java b/src/java/org/apache/fop/layoutmgr/inline/HyphContext.java
index 881608e08..ffc57fa16 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/HyphContext.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/HyphContext.java
@@ -32,10 +32,14 @@ public class HyphContext {
private int currentOffset = 0;
private int currentIndex = 0;
+ /**
+ * @param hyphPoints number of hyphenation points
+ */
public HyphContext(int[] hyphPoints) {
this.hyphPoints = hyphPoints;
}
+ /** @return next hyphenation point */
public int getNextHyphPoint() {
for (; currentIndex < hyphPoints.length; currentIndex++) {
if (hyphPoints[currentIndex] > currentOffset) {
@@ -45,6 +49,7 @@ public class HyphContext {
return -1; // AT END!
}
+ /** @return true if more hyphenation points */
public boolean hasMoreHyphPoints() {
for (; currentIndex < hyphPoints.length; currentIndex++) {
if (hyphPoints[currentIndex] > currentOffset) {
@@ -54,6 +59,7 @@ public class HyphContext {
return false;
}
+ /** @param iCharsProcessed amount to extend offset */
public void updateOffset(int iCharsProcessed) {
currentOffset += iCharsProcessed;
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java
index c47a7e682..7fe90f63c 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java
@@ -33,11 +33,20 @@ import org.apache.fop.fo.flow.InlineContainer;
public class ICLayoutManager extends LeafNodeLayoutManager {
private List childrenLM;
+ /**
+ * Construct inline container layout manager.
+ * @param node inline container FO node
+ * @param childLM child layout manager
+ */
public ICLayoutManager(InlineContainer node, List childLM) {
super(node);
childrenLM = childLM;
}
+ /**
+ * @param index an integer
+ * @return an inline area or null
+ */
public InlineArea get(int index) {
return null;
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java b/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
index 338a58d9c..73235d2d1 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
@@ -37,7 +37,7 @@ import org.apache.fop.fo.properties.LengthRangeProperty;
public class ImageLayout implements Constants {
/** logging instance */
- protected static Log log = LogFactory.getLog(ImageLayout.class);
+ protected static final Log log = LogFactory.getLog(ImageLayout.class);
//Input
private GraphicsProperties props;
diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
index 26f8e3b97..1d3233112 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
@@ -239,7 +239,8 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
}
/** {@inheritDoc} */
- public List getNextKnuthElements(LayoutContext context, int alignment) {
+ public List getNextKnuthElements // CSOK: MethodLength
+ (LayoutContext context, int alignment) {
LayoutManager curLM;
// the list returned by child LM
@@ -434,7 +435,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
// layout context given to the other LMs.
List positionList = new LinkedList();
NonLeafPosition pos;
- LayoutManager lastLM = null;// last child LM in this iterator
+ LayoutManager lastLM = null; // last child LM in this iterator
Position lastPos = null;
while (parentIter.hasNext()) {
pos = (NonLeafPosition) parentIter.next();
@@ -531,10 +532,10 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
}
/** {@inheritDoc} */
- public List getChangedKnuthElements(List oldList, int alignment) {
+ public List getChangedKnuthElements(List oldList, int alignment, int depth) {
List returnedList = new LinkedList();
addKnuthElementsForBorderPaddingStart(returnedList);
- returnedList.addAll(super.getChangedKnuthElements(oldList, alignment));
+ returnedList.addAll(super.getChangedKnuthElements(oldList, alignment, depth));
addKnuthElementsForBorderPaddingEnd(returnedList);
return returnedList;
}
@@ -553,13 +554,13 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
if (returnList instanceof BlockKnuthSequence) {
return;
}
- CommonBorderPaddingBackground borderAndPadding =
- ((InlineLevel)fobj).getCommonBorderPaddingBackground();
+ CommonBorderPaddingBackground borderAndPadding
+ = ((InlineLevel)fobj).getCommonBorderPaddingBackground();
if (borderAndPadding != null) {
int ipStart = borderAndPadding.getBorderStartWidth(false)
+ borderAndPadding.getPaddingStart(false, this);
if (ipStart > 0) {
- returnList.add(0,new KnuthBox(ipStart, getAuxiliaryPosition(), true));
+ returnList.add(0, new KnuthBox(ipStart, getAuxiliaryPosition(), true));
}
}
}
@@ -578,8 +579,8 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
if (returnList instanceof BlockKnuthSequence) {
return;
}
- CommonBorderPaddingBackground borderAndPadding =
- ((InlineLevel)fobj).getCommonBorderPaddingBackground();
+ CommonBorderPaddingBackground borderAndPadding
+ = ((InlineLevel)fobj).getCommonBorderPaddingBackground();
if (borderAndPadding != null) {
int ipEnd = borderAndPadding.getBorderEndWidth(false)
+ borderAndPadding.getPaddingEnd(false, this);
diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java
index c9c65e769..f286fbf6c 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLevelEventProducer.java
@@ -32,7 +32,10 @@ public interface InlineLevelEventProducer extends EventProducer {
/**
* Provider class for the event producer.
*/
- class Provider {
+ final class Provider {
+
+ private Provider() {
+ }
/**
* Returns an event producer.
diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java
index 525f0407d..ac829a2fc 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java
@@ -40,17 +40,21 @@ public interface InlineLevelLayoutManager extends LayoutManager {
List addALetterSpaceTo(List oldList);
/**
- * Tell the LM to modify its data, removing the word space
- * represented by the given elements
+ * Tell the LM to modify its data, adding a letter space
+ * to the word fragment represented by the given elements,
+ * and returning the corrected elements
*
- * @param oldList the elements representing the word space
+ * @param oldList the elements which must be given one more letter space
+ * @param depth the depth at which the Positions for this LM in oldList are found
+ * @return the new elements replacing the old ones
*/
- void removeWordSpace(List oldList);
+List addALetterSpaceTo(List oldList, int depth);
/**
* Get the word chars corresponding to the given position.
*
* @param pos the position referring to the needed word chars.
+ * @return the word chars
*/
String getWordChars(Position pos);
@@ -70,4 +74,23 @@ public interface InlineLevelLayoutManager extends LayoutManager {
*/
boolean applyChanges(List oldList);
+ /**
+ * Tell the LM to apply the changes due to hyphenation
+ *
+ * @param oldList the list of the old elements the changes refer to
+ * @param depth the depth at which the Positions for this LM in oldList are found
+ * @return true if the LM had to change its data, false otherwise
+ */
+ boolean applyChanges(List oldList, int depth);
+
+ /**
+ * Get a sequence of KnuthElements representing the content
+ * of the node assigned to the LM, after changes have been applied
+ * @param oldList the elements to replace
+ * @param alignment the desired text alignment
+ * @param depth the depth at which the Positions for this LM in oldList are found
+ * @return the updated list of KnuthElements
+ **/
+ List getChangedKnuthElements(List oldList, int alignment, int depth);
+
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
index 375afb82f..d8c4966d0 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
@@ -46,16 +46,27 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
implements InlineLevelLayoutManager {
+ /**
+ * A stacking iterator.
+ */
protected static class StackingIter extends PositionIterator {
StackingIter(Iterator parentIter) {
super(parentIter);
}
+ /**
+ * @param nextObj the next object
+ * @return layout manager of next object
+ */
protected LayoutManager getLM(Object nextObj) {
return ((Position) nextObj).getLM();
}
+ /**
+ * @param nextObj the next object
+ * @return position of next object
+ */
protected Position getPos(Object nextObj) {
return ((Position) nextObj);
}
@@ -206,54 +217,48 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
/** {@inheritDoc} */
public List addALetterSpaceTo(List oldList) {
+ return addALetterSpaceTo(oldList, 0);
+ }
+
+ /** {@inheritDoc} */
+ public List addALetterSpaceTo(List oldList, int thisDepth) {
// old list contains only a box, or the sequence: box penalty glue box
- ListIterator oldListIterator = oldList.listIterator();
- KnuthElement element = null;
- // "unwrap" the Position stored in each element of oldList
- while (oldListIterator.hasNext()) {
- element = (KnuthElement) oldListIterator.next();
- element.setPosition(element.getPosition().getPosition());
- }
+ ListIterator oldListIterator = oldList.listIterator(oldList.size());
+ KnuthElement element = (KnuthElement) oldListIterator.previous();
+ int depth = thisDepth + 1;
// The last element may not have a layout manager (its position == null);
// this may happen if it is a padding box; see bug 39571.
- InlineLevelLayoutManager LM =
- (InlineLevelLayoutManager) element.getLayoutManager();
- if (LM != null) {
- oldList = LM.addALetterSpaceTo(oldList);
+ Position pos = element.getPosition();
+ InlineLevelLayoutManager lm = null;
+ if (pos != null) {
+ lm = (InlineLevelLayoutManager) pos.getLM(depth);
}
- // "wrap" again the Position stored in each element of oldList
+ if (lm == null) {
+ return oldList;
+ }
+ oldList = lm.addALetterSpaceTo(oldList, depth);
+ // "wrap" the Position stored in new elements of oldList
oldListIterator = oldList.listIterator();
while (oldListIterator.hasNext()) {
element = (KnuthElement) oldListIterator.next();
- element.setPosition(notifyPos(new NonLeafPosition(this, element.getPosition())));
+ pos = element.getPosition();
+ lm = null;
+ if (pos != null) {
+ lm = (InlineLevelLayoutManager) pos.getLM(thisDepth);
+ }
+ // in old elements the position at thisDepth is a position for this LM
+ // only wrap new elements
+ if (lm != this) {
+ // new element, wrap position
+ element.setPosition(notifyPos(new NonLeafPosition(this, element.getPosition())));
+ }
}
return oldList;
}
- /**
- * remove the AreaInfo object represented by the given elements,
- * so that it won't generate any element when getChangedKnuthElements
- * will be called
- *
- * @param oldList the elements representing the word space
- */
- public void removeWordSpace(List oldList) {
- ListIterator oldListIterator = oldList.listIterator();
- KnuthElement element = null;
- // "unwrap" the Position stored in each element of oldList
- while (oldListIterator.hasNext()) {
- element = (KnuthElement) oldListIterator.next();
- element.setPosition(element.getPosition().getPosition());
- }
-
- ((InlineLevelLayoutManager)
- element.getLayoutManager()).removeWordSpace(oldList);
-
- }
-
/** {@inheritDoc} */
public String getWordChars(Position pos) {
Position newPos = pos.getPosition();
@@ -269,16 +274,14 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
/** {@inheritDoc} */
public boolean applyChanges(List oldList) {
- // "unwrap" the Positions stored in the elements
+ return applyChanges(oldList, 0);
+ }
+
+ /** {@inheritDoc} */
+ public boolean applyChanges(List oldList, int depth) {
ListIterator oldListIterator = oldList.listIterator();
KnuthElement oldElement;
- while (oldListIterator.hasNext()) {
- oldElement = (KnuthElement) oldListIterator.next();
- oldElement.setPosition
- (oldElement.getPosition().getPosition());
- }
- // reset the iterator
- oldListIterator = oldList.listIterator();
+ depth += 1;
InlineLevelLayoutManager prevLM = null;
InlineLevelLayoutManager currLM;
@@ -287,7 +290,12 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
boolean bSomethingChanged = false;
while (oldListIterator.hasNext()) {
oldElement = (KnuthElement) oldListIterator.next();
- currLM = (InlineLevelLayoutManager) oldElement.getLayoutManager();
+ Position pos = oldElement.getPosition();
+ if (pos == null) {
+ currLM = null;
+ } else {
+ currLM = (InlineLevelLayoutManager) pos.getLM(depth);
+ }
// initialize prevLM
if (prevLM == null) {
prevLM = currLM;
@@ -298,38 +306,34 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
prevLM = currLM;
} else if (oldListIterator.hasNext()) {
bSomethingChanged
- = prevLM.applyChanges(oldList.subList(fromIndex
- , oldListIterator.previousIndex()))
+ = prevLM.applyChanges(oldList.subList(fromIndex,
+ oldListIterator.previousIndex()),
+ depth)
|| bSomethingChanged;
prevLM = currLM;
fromIndex = oldListIterator.previousIndex();
} else if (currLM == prevLM) {
bSomethingChanged
= (prevLM != null)
- && prevLM.applyChanges(oldList.subList(fromIndex, oldList.size()))
+ && prevLM.applyChanges(oldList.subList(fromIndex,
+ oldList.size()), depth)
|| bSomethingChanged;
} else {
bSomethingChanged
- = prevLM.applyChanges(oldList.subList(fromIndex
- , oldListIterator.previousIndex()))
+ = prevLM.applyChanges(oldList.subList(fromIndex,
+ oldListIterator.previousIndex()),
+ depth)
|| bSomethingChanged;
if (currLM != null) {
bSomethingChanged
- = currLM.applyChanges(oldList.subList(oldListIterator.previousIndex()
- , oldList.size()))
+ = currLM.applyChanges(oldList.subList(oldListIterator.previousIndex(),
+ oldList.size()), depth)
|| bSomethingChanged;
}
}
}
}
- // "wrap" again the Positions stored in the elements
- oldListIterator = oldList.listIterator();
- while (oldListIterator.hasNext()) {
- oldElement = (KnuthElement) oldListIterator.next();
- oldElement.setPosition
- (notifyPos(new NonLeafPosition(this, oldElement.getPosition())));
- }
return bSomethingChanged;
}
@@ -337,16 +341,15 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
* {@inheritDoc}
*/
public List getChangedKnuthElements(List oldList, int alignment) {
+ return getChangedKnuthElements(oldList, alignment, 0);
+ }
+
+ /** {@inheritDoc} */
+ public List getChangedKnuthElements(List oldList, int alignment, int depth) {
// "unwrap" the Positions stored in the elements
ListIterator oldListIterator = oldList.listIterator();
KnuthElement oldElement;
- while (oldListIterator.hasNext()) {
- oldElement = (KnuthElement) oldListIterator.next();
- oldElement.setPosition
- (oldElement.getPosition().getPosition());
- }
- // reset the iterator
- oldListIterator = oldList.listIterator();
+ depth += 1;
KnuthElement returnedElement;
LinkedList returnedList = new LinkedList();
@@ -357,7 +360,12 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
while (oldListIterator.hasNext()) {
oldElement = (KnuthElement) oldListIterator.next();
- currLM = (InlineLevelLayoutManager) oldElement.getLayoutManager();
+ Position pos = oldElement.getPosition();
+ if (pos == null) {
+ currLM = null;
+ } else {
+ currLM = (InlineLevelLayoutManager) pos.getLM(depth);
+ }
if (prevLM == null) {
prevLM = currLM;
}
@@ -366,33 +374,31 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
if (oldListIterator.hasNext()) {
returnedList.addAll
(prevLM.getChangedKnuthElements
- (oldList.subList(fromIndex,
- oldListIterator.previousIndex()),
- /*flaggedPenalty,*/ alignment));
+ (oldList.subList(fromIndex, oldListIterator.previousIndex()),
+ alignment, depth));
prevLM = currLM;
fromIndex = oldListIterator.previousIndex();
} else if (currLM == prevLM) {
returnedList.addAll
(prevLM.getChangedKnuthElements
(oldList.subList(fromIndex, oldList.size()),
- /*flaggedPenalty,*/ alignment));
+ alignment, depth));
} else {
returnedList.addAll
(prevLM.getChangedKnuthElements
- (oldList.subList(fromIndex,
- oldListIterator.previousIndex()),
- /*flaggedPenalty,*/ alignment));
+ (oldList.subList(fromIndex, oldListIterator.previousIndex()),
+ alignment, depth));
if (currLM != null) {
returnedList.addAll
(currLM.getChangedKnuthElements
- (oldList.subList(oldListIterator.previousIndex(),
- oldList.size()),
- /*flaggedPenalty,*/ alignment));
+ (oldList.subList(oldListIterator.previousIndex(), oldList.size()),
+ alignment, depth));
}
}
}
}
+ // this is a new list
// "wrap" the Position stored in each element of returnedList
ListIterator listIter = returnedList.listIterator();
while (listIter.hasNext()) {
@@ -401,6 +407,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
(notifyPos(new NonLeafPosition(this, returnedElement.getPosition())));
returnList.add(returnedElement);
}
+
return returnList;
}
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java b/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java
index 7b08a67db..312a58fc0 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java
@@ -23,6 +23,9 @@ import org.apache.fop.layoutmgr.FootnoteBodyLayoutManager;
import org.apache.fop.layoutmgr.KnuthBox;
import org.apache.fop.layoutmgr.Position;
+/**
+ * A knuth inline box.
+ */
public class KnuthInlineBox extends KnuthBox {
private FootnoteBodyLayoutManager footnoteBodyLM = null;
@@ -36,7 +39,8 @@ public class KnuthInlineBox extends KnuthBox {
* @param pos the Position stored in this box
* @param auxiliary is this box auxiliary?
*/
- public KnuthInlineBox(int width, AlignmentContext alignmentContext, Position pos, boolean auxiliary) {
+ public KnuthInlineBox
+ (int width, AlignmentContext alignmentContext, Position pos, boolean auxiliary) {
super(width, pos, auxiliary);
this.alignmentContext = alignmentContext;
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
index c5f38134b..2a58b2018 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
@@ -344,4 +344,10 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
this.contentAreaIPD = contentAreaIPD;
}
+ /** {@inheritDoc} */
+ public void reset() {
+ childLMs.clear();
+ super.reset();
+ }
+
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java
index e74b51d96..f3749f2ed 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java
@@ -48,6 +48,7 @@ import org.apache.fop.traits.MinOptMax;
* an exception to this rule.)
* This class can be extended to handle the creation and adding of the
* inline area.
+ * TODO [GA] replace use of hungarian notation with normalized java naming
*/
public abstract class LeafNodeLayoutManager extends AbstractLayoutManager
implements InlineLevelLayoutManager {
@@ -55,7 +56,7 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager
/**
* logging instance
*/
- protected static Log log = LogFactory.getLog(LeafNodeLayoutManager.class);
+ protected static final Log log = LogFactory.getLog(LeafNodeLayoutManager.class);
/**
* The inline area that this leafnode will add.
@@ -75,11 +76,22 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager
* Store information about the inline area
*/
protected class AreaInfo {
+ /** letter space count */
protected short iLScount;
+ /** ipd of area */
protected MinOptMax ipdArea;
+ /** true if hyphenated */
protected boolean bHyphenated;
+ /** alignment context */
protected AlignmentContext alignmentContext;
+ /**
+ * Construct an area information item.
+ * @param iLS letter space count
+ * @param ipd inline progression dimension
+ * @param bHyph true if hyphenated
+ * @param alignmentContext an alignment context
+ */
public AreaInfo(short iLS, MinOptMax ipd, boolean bHyph,
AlignmentContext alignmentContext) {
iLScount = iLS;
@@ -285,13 +297,11 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager
}
/**
- * Remove the word space represented by the given elements
- *
- * @param oldList the elements representing the word space
+ * {@inheritDoc}
+ * Only TextLM has a meaningful implementation of this method
*/
- public void removeWordSpace(List oldList) {
- // do nothing
- log.warn(this.getClass().getName() + " should not receive a call to removeWordSpace(list)");
+ public List addALetterSpaceTo(List oldList, int depth) {
+ return addALetterSpaceTo(oldList);
}
/** {@inheritDoc} */
@@ -309,9 +319,24 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager
return false;
}
+ /**
+ * {@inheritDoc}
+ * Only TextLM has a meaningful implementation of this method
+ */
+ public boolean applyChanges(List oldList, int depth) {
+ return applyChanges(oldList);
+ }
+
+ /**
+ * {@inheritDoc}
+ * No subclass has a meaningful implementation of this method
+ */
+ public List getChangedKnuthElements(List oldList, int alignment, int depth) {
+ return getChangedKnuthElements(oldList, alignment);
+ }
+
/** {@inheritDoc} */
- public List getChangedKnuthElements(List oldList,
- int alignment) {
+ public List getChangedKnuthElements(List oldList, int alignment) {
if (isFinished()) {
return null;
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
index 9e17a0368..2611a8cd5 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
@@ -27,7 +27,6 @@ import java.util.ListIterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.apache.fop.area.Area;
import org.apache.fop.area.LineArea;
import org.apache.fop.area.Trait;
@@ -82,60 +81,45 @@ public class LineLayoutManager extends InlineStackingLayoutManager
implements BlockLevelLayoutManager {
/**
+ * this constant is used to create elements when text-align is center:
+ * every TextLM descendant of LineLM must use the same value,
+ * otherwise the line breaking algorithm does not find the right
+ * break point
+ */
+ public static final int DEFAULT_SPACE_WIDTH = 3336;
+
+ /**
* logging instance
*/
private static Log log = LogFactory.getLog(LineLayoutManager.class);
- private Block fobj;
+ private final Block fobj;
private boolean isFirstInBlock;
- /** {@inheritDoc} */
- public void initialize() {
- textAlignment = fobj.getTextAlign();
- textAlignmentLast = fobj.getTextAlignLast();
- textIndent = fobj.getTextIndent();
- lastLineEndIndent = fobj.getLastLineEndIndent();
- hyphenationProperties = fobj.getCommonHyphenation();
- hyphenationLadderCount = fobj.getHyphenationLadderCount();
- wrapOption = fobj.getWrapOption();
- whiteSpaceTreament = fobj.getWhitespaceTreatment();
- //
- effectiveAlignment = getEffectiveAlignment(textAlignment, textAlignmentLast);
- isFirstInBlock = (this == getParent().getChildLMs().get(0));
- }
-
- private int getEffectiveAlignment(int alignment, int alignmentLast) {
- if (textAlignment != EN_JUSTIFY && textAlignmentLast == EN_JUSTIFY) {
- return 0;
- } else {
- return textAlignment;
- }
- }
-
/**
* Private class to store information about inline breaks.
* Each value holds the start and end indexes into a List of
* inline break positions.
*/
private static class LineBreakPosition extends LeafPosition {
- private int parIndex; // index of the Paragraph this Position refers to
- private int startIndex; //index of the first element this Position refers to
- private int availableShrink;
- private int availableStretch;
- private int difference;
- private double dAdjust; // Percentage to adjust (stretch or shrink)
- private double ipdAdjust; // Percentage to adjust (stretch or shrink)
- private int startIndent;
- private int lineHeight;
- private int lineWidth;
- private int spaceBefore;
- private int spaceAfter;
- private int baseline;
-
- LineBreakPosition(LayoutManager lm, int index, int startIndex, int breakIndex,
- int shrink, int stretch, int diff,
- double ipdA, double adjust, int ind,
- int lh, int lw, int sb, int sa, int bl) {
+ private final int parIndex; // index of the Paragraph this Position refers to
+ private final int startIndex; //index of the first element this Position refers to
+ private final int availableShrink;
+ private final int availableStretch;
+ private final int difference;
+ private final double dAdjust; // Percentage to adjust (stretch or shrink)
+ private final double ipdAdjust; // Percentage to adjust (stretch or shrink)
+ private final int startIndent;
+ private final int lineHeight;
+ private final int lineWidth;
+ private final int spaceBefore;
+ private final int spaceAfter;
+ private final int baseline;
+
+ LineBreakPosition( // CSOK: ParameterNumber
+ LayoutManager lm, int index, int startIndex, int breakIndex,
+ int shrink, int stretch, int diff, double ipdA, double adjust, int ind,
+ int lh, int lw, int sb, int sa, int bl) {
super(lm, breakIndex);
availableShrink = shrink;
availableStretch = stretch;
@@ -166,9 +150,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager
private int whiteSpaceTreament;
//private LayoutProps layoutProps;
- private Length lineHeight;
- private int lead;
- private int follow;
+ private final Length lineHeight;
+ private final int lead;
+ private final int follow;
private AlignmentContext alignmentContext;
private List knuthParagraphs;
@@ -183,24 +167,15 @@ public class LineLayoutManager extends InlineStackingLayoutManager
private boolean hyphenationPerformed;
/**
- * this constant is used to create elements when text-align is center:
- * every TextLM descendant of LineLM must use the same value,
- * otherwise the line breaking algorithm does not find the right
- * break point
- */
- public static final int DEFAULT_SPACE_WIDTH = 3336;
-
-
- /**
* This class is used to remember
* which was the first element in the paragraph
* returned by each LM.
*/
- private class Update {
- private InlineLevelLayoutManager inlineLM;
- private int firstIndex;
+ private final class Update {
+ private final InlineLevelLayoutManager inlineLM;
+ private final int firstIndex;
- public Update(InlineLevelLayoutManager lm, int index) {
+ private Update(InlineLevelLayoutManager lm, int index) {
inlineLM = lm;
firstIndex = index;
}
@@ -208,6 +183,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager
// this class represents a paragraph
private class Paragraph extends InlineKnuthSequence {
+
+ private static final long serialVersionUID = 5862072380375189105L;
+
/** Number of elements to ignore at the beginning of the list. */
private int ignoreAtStart = 0;
/** Number of elements to ignore at the end of the list. */
@@ -215,12 +193,12 @@ public class LineLayoutManager extends InlineStackingLayoutManager
// space at the end of the last line (in millipoints)
private MinOptMax lineFiller;
- private int textAlignment;
- private int textAlignmentLast;
- private int textIndent;
- private int lastLineEndIndent;
+ private final int textAlignment;
+ private final int textAlignmentLast;
+ private final int textIndent;
+ private final int lastLineEndIndent;
// the LM which created the paragraph
- private LineLayoutManager layoutManager;
+ private final LineLayoutManager layoutManager;
Paragraph(LineLayoutManager llm, int alignment, int alignmentLast,
int indent, int endIndent) {
@@ -232,6 +210,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
lastLineEndIndent = endIndent;
}
+ @Override
public void startSequence() {
// set the minimum amount of empty space at the end of the
// last line
@@ -266,6 +245,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
}
}
+ @Override
public KnuthSequence endSequence() {
if (this.size() > ignoreAtStart) {
if (textAlignment == EN_CENTER
@@ -315,21 +295,19 @@ public class LineLayoutManager extends InlineStackingLayoutManager
}
private class LineBreakingAlgorithm extends BreakingAlgorithm {
- private LineLayoutManager thisLLM;
- private int pageAlignment;
+ private final LineLayoutManager thisLLM;
+ private final int pageAlignment;
private int activePossibility;
private int addedPositions;
- private int textIndent;
- private int lineHeight;
- private int lead;
- private int follow;
+ private final int textIndent;
+ private final int lineHeight;
+ private final int lead;
+ private final int follow;
private static final double MAX_DEMERITS = 10e6;
- public LineBreakingAlgorithm (int pageAlign,
- int textAlign, int textAlignLast,
- int indent, int fillerWidth,
- int lh, int ld, int fl, boolean first,
- int maxFlagCount, LineLayoutManager llm) {
+ public LineBreakingAlgorithm( // CSOK: ParameterNumber
+ int pageAlign, int textAlign, int textAlignLast, int indent, int fillerWidth,
+ int lh, int ld, int fl, boolean first, int maxFlagCount, LineLayoutManager llm) {
super(textAlign, textAlignLast, first, false, maxFlagCount);
pageAlignment = pageAlign;
textIndent = indent;
@@ -340,6 +318,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
activePossibility = -1;
}
+ @Override
public void updateData1(int lineCount, double demerits) {
lineLayouts.addPossibility(lineCount, demerits);
if (log.isTraceEnabled()) {
@@ -347,6 +326,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
}
}
+ @Override
public void updateData2(KnuthNode bestActiveNode,
KnuthSequence par,
int total) {
@@ -357,7 +337,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager
int textAlign = (bestActiveNode.line < total) ? alignment : alignmentLast;
indent += (textAlign == Constants.EN_CENTER)
? difference / 2 : (textAlign == Constants.EN_END) ? difference : 0;
- indent += (bestActiveNode.line == 1 && indentFirstPart && isFirstInBlock) ? textIndent : 0;
+ indent += (bestActiveNode.line == 1 && indentFirstPart && isFirstInBlock)
+ ? textIndent : 0;
double ratio = (textAlign == Constants.EN_JUSTIFY
|| difference < 0 && -difference <= bestActiveNode.availableShrink)
? bestActiveNode.adjustRatio : 0;
@@ -405,14 +386,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager
activePossibility = -1;
}
- private LineBreakPosition makeLineBreakPosition(KnuthSequence par,
- int firstElementIndex,
- int lastElementIndex,
- int availableShrink,
- int availableStretch,
- int difference,
- double ratio,
- int indent) {
+ private LineBreakPosition makeLineBreakPosition( // CSOK: ParameterNumber
+ KnuthSequence par, int firstElementIndex, int lastElementIndex, int availableShrink,
+ int availableStretch, int difference, double ratio, int indent) {
// line height calculation - spaceBefore may differ from spaceAfter
// by 1mpt due to rounding
int spaceBefore = (lineHeight - lead - follow) / 2;
@@ -493,6 +469,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
}
}
+ @Override
protected int filterActiveNodes() {
KnuthNode bestActiveNode = null;
@@ -501,7 +478,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager
//log.debug("LBA.filterActiveNodes> " + activeNodeCount + " layouts");
for (int i = startLine; i < endLine; i++) {
for (KnuthNode node = getNode(i); node != null; node = node.next) {
- //log.debug(" + lines = " + node.line + " demerits = " + node.totalDemerits);
+ //log.debug(" + lines = "
+ //+ node.line + " demerits = " + node.totalDemerits);
bestActiveNode = compareNodes(bestActiveNode, node);
}
}
@@ -514,10 +492,12 @@ public class LineLayoutManager extends InlineStackingLayoutManager
//if (false) {
if (node.line != bestActiveNode.line
&& node.totalDemerits > MAX_DEMERITS) {
- //log.debug(" XXX lines = " + node.line + " demerits = " + node.totalDemerits);
+ //log.debug(" XXX lines = "
+ //+ node.line + " demerits = " + node.totalDemerits);
removeNode(i, node);
} else {
- //log.debug(" ok lines = " + node.line + " demerits = " + node.totalDemerits);
+ //log.debug(" ok lines = "
+ //+ node.line + " demerits = " + node.totalDemerits);
}
}
}
@@ -561,12 +541,39 @@ public class LineLayoutManager extends InlineStackingLayoutManager
}
/** {@inheritDoc} */
+ @Override
+ public void initialize() {
+ textAlignment = fobj.getTextAlign();
+ textAlignmentLast = fobj.getTextAlignLast();
+ textIndent = fobj.getTextIndent();
+ lastLineEndIndent = fobj.getLastLineEndIndent();
+ hyphenationProperties = fobj.getCommonHyphenation();
+ hyphenationLadderCount = fobj.getHyphenationLadderCount();
+ wrapOption = fobj.getWrapOption();
+ whiteSpaceTreament = fobj.getWhitespaceTreatment();
+ //
+ effectiveAlignment = getEffectiveAlignment(textAlignment, textAlignmentLast);
+ isFirstInBlock = (this == getParent().getChildLMs().get(0));
+ }
+
+ private int getEffectiveAlignment(int alignment, int alignmentLast) {
+ if (textAlignment != EN_JUSTIFY && textAlignmentLast == EN_JUSTIFY) {
+ return 0;
+ } else {
+ return textAlignment;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
public List getNextKnuthElements(LayoutContext context, int alignment) {
- FontInfo fi = fobj.getFOEventHandler().getFontInfo();
- FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi);
- Font fs = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this));
- alignmentContext = new AlignmentContext(fs, lineHeight.getValue(this),
- context.getWritingMode());
+ if (alignmentContext == null) {
+ FontInfo fi = fobj.getFOEventHandler().getFontInfo();
+ FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi);
+ Font fs = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this));
+ alignmentContext = new AlignmentContext(fs, lineHeight.getValue(this),
+ context.getWritingMode());
+ }
context.setAlignmentContext(alignmentContext);
ipd = context.getRefIPD();
@@ -592,6 +599,15 @@ public class LineLayoutManager extends InlineStackingLayoutManager
return createLineBreaks(context.getBPAlignment(), context);
}
+ /**
+ * Get a sequence of KnuthElements representing the content
+ * of the node assigned to the LM.
+ * @param context the LayoutContext used to store layout information
+ * @param alignment the desired text alignment
+ * @param restartPosition position at restart
+ * @return the list of KnuthElements
+ * @see LayoutManager#getNextKnuthElements(LayoutContext,int)
+ */
public List getNextKnuthElements(LayoutContext context, int alignment,
LeafPosition restartPosition) {
log.trace("Restarting line breaking from index " + restartPosition.getIndex());
@@ -705,7 +721,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager
// finish last paragraph if it was closed with a linefeed
if (lastElement.isPenalty()
- && ((KnuthPenalty) lastElement).getPenalty() == -KnuthPenalty.INFINITE) {
+ && ((KnuthPenalty) lastElement).getPenalty()
+ == -KnuthPenalty.INFINITE) {
// a penalty item whose value is -inf
// represents a preserved linefeed,
// which forces a line break
@@ -760,7 +777,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager
// we only need an entry in lineLayoutsList.
llPoss = new LineLayoutPossibilities();
} else {
- llPoss = findOptimalBreakingPoints(alignment, (Paragraph) seq);
+ llPoss = findOptimalBreakingPoints(alignment, (Paragraph) seq,
+ !paragraphsIterator.hasNext());
}
lineLayoutsList[i] = llPoss;
}
@@ -772,16 +790,17 @@ public class LineLayoutManager extends InlineStackingLayoutManager
}
/**
- * Fint the optimal linebreaks for a paragraph
+ * Find the optimal linebreaks for a paragraph
* @param alignment alignment of the paragraph
* @param currPar the Paragraph for which the linebreaks are found
+ * @param isLastPar flag indicating whether currPar is the last paragraph
* @return the line layout possibilities for the paragraph
*/
- private LineLayoutPossibilities findOptimalBreakingPoints(int alignment, Paragraph currPar) {
+ private LineLayoutPossibilities findOptimalBreakingPoints(int alignment, Paragraph currPar,
+ boolean isLastPar) {
// use the member lineLayouts, which is read by LineBreakingAlgorithm.updateData1 and 2
lineLayouts = new LineLayoutPossibilities();
double maxAdjustment = 1;
- int iBPcount = 0;
LineBreakingAlgorithm alg = new LineBreakingAlgorithm(alignment,
textAlignment, textAlignmentLast,
textIndent.getValue(this), currPar.lineFiller.getOpt(),
@@ -790,26 +809,26 @@ public class LineLayoutManager extends InlineStackingLayoutManager
hyphenationLadderCount.getEnum() == EN_NO_LIMIT
? 0 : hyphenationLadderCount.getValue(),
this);
-
- if (hyphenationProperties.hyphenate.getEnum() == EN_TRUE
- && fobj.getWrapOption() != EN_NO_WRAP && !hyphenationPerformed) {
- hyphenationPerformed = true;
+ alg.setConstantLineWidth(ipd);
+ boolean canWrap = (wrapOption != EN_NO_WRAP);
+ boolean canHyphenate = (canWrap && hyphenationProperties.hyphenate.getEnum() == EN_TRUE);
+
+ // find hyphenation points, if allowed and not yet done
+ if (canHyphenate && !hyphenationPerformed) {
+ // make sure findHyphenationPoints() is bypassed if
+ // the method is called twice (e.g. due to changing page-ipd)
+ hyphenationPerformed = isLastPar;
findHyphenationPoints(currPar);
}
- // first try
- int allowedBreaks;
- if (wrapOption == EN_NO_WRAP) {
- allowedBreaks = BreakingAlgorithm.ONLY_FORCED_BREAKS;
- } else {
- allowedBreaks = BreakingAlgorithm.NO_FLAGGED_PENALTIES;
- }
- alg.setConstantLineWidth(ipd);
- iBPcount = alg.findBreakingPoints(currPar,
- maxAdjustment, false, allowedBreaks);
- if (iBPcount == 0 || alignment == EN_JUSTIFY) {
+ // first try: do not consider hyphenation points as legal breaks
+ int allowedBreaks = (canWrap ? BreakingAlgorithm.NO_FLAGGED_PENALTIES
+ : BreakingAlgorithm.ONLY_FORCED_BREAKS);
+ int breakingPoints = alg.findBreakingPoints(currPar, maxAdjustment, false, allowedBreaks);
+
+ if (breakingPoints == 0 || alignment == EN_JUSTIFY) {
// if the first try found a set of breaking points, save them
- if (iBPcount > 0) {
+ if (breakingPoints > 0) {
alg.resetAlgorithm();
lineLayouts.savePossibilities(false);
} else {
@@ -818,9 +837,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager
}
// now try something different
- log.debug("Hyphenation possible? " + (hyphenationProperties.hyphenate.getEnum() == EN_TRUE));
- if (hyphenationProperties.hyphenate.getEnum() == EN_TRUE
- && !(allowedBreaks == BreakingAlgorithm.ONLY_FORCED_BREAKS)) {
+ log.debug("Hyphenation possible? " + canHyphenate);
+ // Note: if allowedBreaks is guaranteed to be unchanged by alg.findBreakingPoints(),
+ // the below check can be simplified to 'if (canHyphenate) ...'
+ if (canHyphenate && allowedBreaks != BreakingAlgorithm.ONLY_FORCED_BREAKS) {
// consider every hyphenation point as a legal break
allowedBreaks = BreakingAlgorithm.ALL_BREAKS;
} else {
@@ -828,63 +848,22 @@ public class LineLayoutManager extends InlineStackingLayoutManager
maxAdjustment = 5;
}
- if ((iBPcount
- = alg.findBreakingPoints(currPar,
- maxAdjustment, false, allowedBreaks)) == 0) {
+ breakingPoints = alg.findBreakingPoints(currPar, maxAdjustment, false, allowedBreaks);
+ if (breakingPoints == 0) {
// the second try failed too, try with a huge threshold
- // and force the algorithm to find
- // a set of breaking points
+ // and force the algorithm to find a set of breaking points
if (log.isDebugEnabled()) {
log.debug("No set of breaking points found with maxAdjustment = "
- + maxAdjustment
- + (hyphenationProperties.hyphenate.getEnum() == EN_TRUE
- ? " and hyphenation" : ""));
+ + maxAdjustment + (canHyphenate ? " and hyphenation" : ""));
}
maxAdjustment = 20;
- iBPcount
- = alg.findBreakingPoints(currPar,
- maxAdjustment, true, allowedBreaks);
+ alg.findBreakingPoints(currPar, maxAdjustment, true, allowedBreaks);
}
// use non-hyphenated breaks, when possible
lineLayouts.restorePossibilities();
-
- /* extension (not in the XSL FO recommendation): if vertical alignment
- is justify and the paragraph has only one layout, try using
- shorter or longer lines */
- //TODO This code snippet is disabled. Reenable?
- if (false && alignment == EN_JUSTIFY && textAlignment == EN_JUSTIFY) {
- //log.debug("LLM.getNextKnuthElements> layouts with more lines? " + lineLayouts.canUseMoreLines());
- //log.debug(" layouts with fewer lines? " + lineLayouts.canUseLessLines());
- if (!lineLayouts.canUseMoreLines()) {
- alg.resetAlgorithm();
- lineLayouts.savePossibilities(true);
- // try with shorter lines
- int savedLineWidth = ipd;
- ipd = (int) (ipd * 0.95);
- iBPcount = alg.findBreakingPoints(currPar,
- maxAdjustment, true, allowedBreaks);
- // use normal lines, when possible
- lineLayouts.restorePossibilities();
- ipd = savedLineWidth;
- }
- if (!lineLayouts.canUseLessLines()) {
- alg.resetAlgorithm();
- lineLayouts.savePossibilities(true);
- // try with longer lines
- int savedLineWidth = ipd;
- ipd = (int) (ipd * 1.05);
- alg.setConstantLineWidth(ipd);
- iBPcount = alg.findBreakingPoints(currPar,
- maxAdjustment, true, allowedBreaks);
- // use normal lines, when possible
- lineLayouts.restorePossibilities();
- ipd = savedLineWidth;
- }
- //log.debug("LLM.getNextKnuthElements> now, layouts with more lines? " + lineLayouts.canUseMoreLines());
- //log.debug(" now, layouts with fewer lines? " + lineLayouts.canUseLessLines());
- }
}
+
return lineLayouts;
}
@@ -1068,7 +1047,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager
//log.debug("first=" + firstLines + " inner=" + innerLines
// + " optional=" + optionalLines + " eliminable=" + eliminableLines
// + " last=" + lastLines
- // + " (condOpt=" + conditionalOptionalLines + " condEl=" + conditionalEliminableLines + ")");
+ // + " (condOpt=" + conditionalOptionalLines
+ // + " condEl=" + conditionalEliminableLines + ")");
// creation of the elements:
// first group of lines
@@ -1172,8 +1152,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager
//}
//int lineNumberDifference = (int)((double) totalAdj / constantLineHeight);
int lineNumberDifference = (int) Math.round((double) adj / constantLineHeight
- + (adj > 0 ? - 0.4 : 0.4));
- //log.debug(" LLM> variazione calcolata = " + ((double) totalAdj / constantLineHeight) + " variazione applicata = " + lineNumberDifference);
+ + (adj > 0 ? -0.4 : 0.4));
+ //log.debug(" LLM> variazione calcolata = " + ((double) totalAdj / constantLineHeight)
+ //+ " variazione applicata = " + lineNumberDifference);
LineLayoutPossibilities llPoss;
llPoss = lineLayoutsList[pos.getLeafPos()];
lineNumberDifference = llPoss.applyLineCountAdjustment(lineNumberDifference);
@@ -1185,6 +1166,12 @@ public class LineLayoutManager extends InlineStackingLayoutManager
}
/** {@inheritDoc} */
+ @Override
+ public List getChangedKnuthElements(List oldList, int alignment, int depth) {
+ return getChangedKnuthElements(oldList, alignment);
+ }
+
+ /** {@inheritDoc} */
public List getChangedKnuthElements(List oldList, int alignment) {
List returnList = new LinkedList();
for (int p = 0; p < knuthParagraphs.size(); p++) {
@@ -1198,10 +1185,12 @@ public class LineLayoutManager extends InlineStackingLayoutManager
returnList.add(new KnuthPenalty(0, 0, false, new Position(this), false));
}
LineBreakPosition lbp = (LineBreakPosition) llPoss.getChosenPosition(i);
- //log.debug("LLM.getChangedKnuthElements> lineWidth= " + lbp.lineWidth + " difference= " + lbp.difference);
- //log.debug(" shrink= " + lbp.availableShrink + " stretch= " + lbp.availableStretch);
-
- //log.debug("linewidth= " + lbp.lineWidth + " difference= " + lbp.difference + " indent= " + lbp.startIndent);
+ //log.debug("LLM.getChangedKnuthElements> lineWidth= "
+ // + lbp.lineWidth + " difference= " + lbp.difference);
+ //log.debug(" shrink= "
+ // + lbp.availableShrink + " stretch= " + lbp.availableStretch);
+ //log.debug("linewidth= " + lbp.lineWidth + " difference= "
+ //+ lbp.difference + " indent= " + lbp.startIndent);
MinOptMax contentIPD;
if (alignment == EN_JUSTIFY) {
contentIPD = MinOptMax.getInstance(
@@ -1213,7 +1202,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager
} else if (alignment == EN_END) {
contentIPD = MinOptMax.getInstance(lbp.lineWidth - lbp.startIndent);
} else {
- contentIPD = MinOptMax.getInstance(lbp.lineWidth - lbp.difference + lbp.startIndent);
+ contentIPD
+ = MinOptMax.getInstance(lbp.lineWidth - lbp.difference + lbp.startIndent);
}
returnList.add(new KnuthBlockBox(lbp.lineHeight, contentIPD, (lbp.ipdAdjust != 0
? lbp.lineWidth - lbp.difference : 0),
@@ -1256,8 +1246,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager
} else if (currLM == null) {
break;
}
- //TODO Something's not right here. See block_hyphenation_linefeed_preserve.xml
- //for more info: see also https://issues.apache.org/bugzilla/show_bug.cgi?id=38264
// collect word fragments, ignoring auxiliary elements;
// each word fragment was created by a different TextLM
@@ -1366,6 +1354,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
* @param isNotFirst ignored
* @return always true
*/
+ @Override
protected boolean hasLeadingFence(boolean isNotFirst) {
return true;
}
@@ -1375,6 +1364,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
* @param isNotLast ignored
* @return always true
*/
+ @Override
protected boolean hasTrailingFence(boolean isNotLast) {
return true;
}
@@ -1397,6 +1387,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
= Hyphenator.hyphenate(hyphenationProperties.language.getString(),
hyphenationProperties.country.getString(),
getFObj().getUserAgent().getFactory().getHyphenationTreeResolver(),
+ getFObj().getUserAgent().getFactory().getHyphPatNames(),
sbChars.toString(),
hyphenationProperties.hyphenationRemainCharacterCount.getValue(),
hyphenationProperties.hyphenationPushCharacterCount.getValue());
@@ -1421,6 +1412,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
* @param parentIter the iterator of break positions
* @param context the context for adding areas
*/
+ @Override
public void addAreas(PositionIterator parentIter,
LayoutContext context) {
while (parentIter.hasNext()) {
@@ -1449,8 +1441,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager
*/
private void addInlineArea(LayoutContext context, LineBreakPosition lbp,
boolean isLastPosition) {
- // the TLM which created the last KnuthElement in this line
- LayoutManager lastLM = null;
KnuthSequence seq = (KnuthSequence) knuthParagraphs.get(lbp.parIndex);
int startElementIndex = lbp.startIndex;
@@ -1482,15 +1472,16 @@ public class LineLayoutManager extends InlineStackingLayoutManager
}
}
- // Remove trailing spaces if allowed so
- if (whiteSpaceTreament == EN_IGNORE_IF_SURROUNDING_LINEFEED
- || whiteSpaceTreament == EN_IGNORE
- || whiteSpaceTreament == EN_IGNORE_IF_BEFORE_LINEFEED) {
- // ignore the last element in the line if it is a KnuthGlue object
- ListIterator seqIterator = seq.listIterator(endElementIndex);
- KnuthElement lastElement = (KnuthElement) seqIterator.next();
- lastLM = lastElement.getLayoutManager();
- if (lastElement.isGlue()) {
+ // ignore the last element in the line if it is a KnuthGlue object
+ ListIterator seqIterator = seq.listIterator(endElementIndex);
+ KnuthElement lastElement = (KnuthElement) seqIterator.next();
+ // the TLM which created the last KnuthElement in this line
+ LayoutManager lastLM = lastElement.getLayoutManager();
+ if (lastElement.isGlue()) {
+ // Remove trailing spaces if allowed so
+ if (whiteSpaceTreament == EN_IGNORE_IF_SURROUNDING_LINEFEED
+ || whiteSpaceTreament == EN_IGNORE
+ || whiteSpaceTreament == EN_IGNORE_IF_BEFORE_LINEFEED) {
endElementIndex--;
// this returns the same KnuthElement
seqIterator.previous();
@@ -1506,7 +1497,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
|| whiteSpaceTreament == EN_IGNORE_IF_AFTER_LINEFEED) {
// ignore KnuthGlue and KnuthPenalty objects
// at the beginning of the line
- ListIterator seqIterator = seq.listIterator(startElementIndex);
+ seqIterator = seq.listIterator(startElementIndex);
while (seqIterator.hasNext() && !((KnuthElement) seqIterator.next()).isBox()) {
startElementIndex++;
}
@@ -1523,36 +1514,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager
lc.setTrailingSpace(new SpaceSpecifier(false));
lc.setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true);
- /*
- * extension (not in the XSL FO recommendation): if the left and right margins
- * have been optimized, recompute indents and / or adjust ratio, according
- * to the paragraph horizontal alignment
- */
- if (false && textAlignment == EN_JUSTIFY) {
- // re-compute space adjust ratio
- int updatedDifference = context.getRefIPD()
- - lbp.lineWidth + lbp.difference;
- double updatedRatio = 0.0;
- if (updatedDifference > 0) {
- updatedRatio = (float) updatedDifference / lbp.availableStretch;
- } else if (updatedDifference < 0) {
- updatedRatio = (float) updatedDifference / lbp.availableShrink;
- }
- lc.setIPDAdjust(updatedRatio);
- //log.debug("LLM.addAreas> old difference = " + lbp.difference + " new difference = " + updatedDifference);
- //log.debug(" old ratio = " + lbp.ipdAdjust + " new ratio = " + updatedRatio);
- } else if (false && textAlignment == EN_CENTER) {
- // re-compute indent
- int updatedIndent = lbp.startIndent
- + (context.getRefIPD() - lbp.lineWidth) / 2;
- lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent));
- } else if (false && textAlignment == EN_END) {
- // re-compute indent
- int updatedIndent = lbp.startIndent
- + (context.getRefIPD() - lbp.lineWidth);
- lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent));
- }
-
setCurrentArea(lineArea);
setChildContext(lc);
LayoutManager childLM;
@@ -1622,6 +1583,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
}
/** {@inheritDoc} */
+ @Override
public void addChildArea(Area childArea) {
// Make sure childArea is inline area
if (childArea instanceof InlineArea) {
@@ -1637,19 +1599,21 @@ public class LineLayoutManager extends InlineStackingLayoutManager
// --------- Property Resolution related functions --------- //
/** {@inheritDoc} */
+ @Override
public boolean getGeneratesBlockArea() {
return true;
}
/** {@inheritDoc} */
+ @Override
public boolean getGeneratesLineArea() {
return true;
}
/** {@inheritDoc} */
+ @Override
public boolean isRestartable() {
return true;
}
}
-
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java
index c1b81c4ab..49c97b7b6 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java
@@ -23,14 +23,18 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.layoutmgr.Position;
+/**
+ * Line layout possibilities.
+ */
public class LineLayoutPossibilities {
/** logger instance */
- protected static Log log = LogFactory.getLog(LineLayoutPossibilities.class);
+ private static final Log LOG = LogFactory.getLog(LineLayoutPossibilities.class);
- private class Possibility {
+ private final class Possibility {
private int lineCount;
private double demerits;
private List breakPositions;
@@ -69,12 +73,18 @@ public class LineLayoutPossibilities {
private int chosenIndex;
private int savedOptLineCount;
+ /** default constructor */
public LineLayoutPossibilities() {
possibilitiesList = new java.util.ArrayList();
savedPossibilities = new java.util.ArrayList();
optimumIndex = -1;
}
+ /**
+ * Add possibility.
+ * @param ln line number
+ * @param dem demerits
+ */
public void addPossibility(int ln, double dem) {
possibilitiesList.add(new Possibility(ln, dem));
if (possibilitiesList.size() == 1) {
@@ -97,8 +107,10 @@ public class LineLayoutPossibilities {
}
}
- /* save in a different array the computed Possibilities,
- * so possibilitiesList is ready to store different Possibilities
+ /**
+ * Save in a different array the computed Possibilities,
+ * so possibilitiesList is ready to store different Possibilities.
+ * @param bSaveOptLineCount true if should save optimum line count
*/
public void savePossibilities(boolean bSaveOptLineCount) {
if (bSaveOptLineCount) {
@@ -110,8 +122,9 @@ public class LineLayoutPossibilities {
possibilitiesList = new java.util.ArrayList();
}
- /* replace the Possibilities stored in possibilitiesList with
- * the ones stored in savedPossibilities and having the same line number
+ /**
+ * Replace the Possibilities stored in possibilitiesList with
+ * the ones stored in savedPossibilities and having the same line number.
*/
public void restorePossibilities() {
int index = 0;
@@ -124,9 +137,9 @@ public class LineLayoutPossibilities {
// update minimumIndex
minimumIndex = 0;
// shift the other indexes;
- optimumIndex ++;
- maximumIndex ++;
- chosenIndex ++;
+ optimumIndex++;
+ maximumIndex++;
+ chosenIndex++;
} else if (restoredPossibility.getLineCount() > getMaxLineCount()) {
// if the line number of restoredPossibility is greater than the maximum one,
// add restoredPossibility at the end of the list
@@ -138,13 +151,13 @@ public class LineLayoutPossibilities {
// find the index of the Possibility that will be replaced
while (index < maximumIndex
&& getLineCount(index) < restoredPossibility.getLineCount()) {
- index ++;
+ index++;
}
if (getLineCount(index) == restoredPossibility.getLineCount()) {
possibilitiesList.set(index, restoredPossibility);
} else {
// this should not happen
- log.error("LineLayoutPossibilities restorePossibilities(),"
+ LOG.error("LineLayoutPossibilities restorePossibilities(),"
+ " min= " + getMinLineCount()
+ " max= " + getMaxLineCount()
+ " restored= " + restoredPossibility.getLineCount());
@@ -152,8 +165,10 @@ public class LineLayoutPossibilities {
}
}
// update optimumIndex and chosenIndex
- if (savedOptLineCount == 0 && getDemerits(optimumIndex) > restoredPossibility.getDemerits()
- || savedOptLineCount != 0 && restoredPossibility.getLineCount() == savedOptLineCount) {
+ if (savedOptLineCount == 0
+ && getDemerits(optimumIndex) > restoredPossibility.getDemerits()
+ || savedOptLineCount != 0
+ && restoredPossibility.getLineCount() == savedOptLineCount) {
optimumIndex = index;
chosenIndex = optimumIndex;
}
@@ -162,73 +177,102 @@ public class LineLayoutPossibilities {
// + " optLineCount = " + getOptLineCount() + " maxLineCount() = " + getMaxLineCount());
}
+ /**
+ * @param pos a position
+ * @param i an index into posibilities list
+ */
public void addBreakPosition(Position pos, int i) {
((Possibility)possibilitiesList.get(i)).addBreakPosition(pos);
}
+ /** @return true if can use more lines */
public boolean canUseMoreLines() {
return (getOptLineCount() < getMaxLineCount());
}
+ /** @return true if can use fewer lines */
public boolean canUseLessLines() {
return (getMinLineCount() < getOptLineCount());
}
+ /** @return the line count of the minimum index */
public int getMinLineCount() {
return getLineCount(minimumIndex);
}
+ /** @return the line count of the optimum index */
public int getOptLineCount() {
return getLineCount(optimumIndex);
}
+ /** @return the line count of the maximum index */
public int getMaxLineCount() {
return getLineCount(maximumIndex);
}
+ /** @return the line count of the chosen index */
public int getChosenLineCount() {
return getLineCount(chosenIndex);
}
+ /**
+ * @param i the posibilities list index
+ * @return the line count
+ */
public int getLineCount(int i) {
return ((Possibility)possibilitiesList.get(i)).getLineCount();
}
+ /** @return the demerits of the chosen index */
public double getChosenDemerits() {
return getDemerits(chosenIndex);
}
+ /**
+ * @param i the posibilities list index
+ * @return the demerits
+ */
public double getDemerits(int i) {
return ((Possibility)possibilitiesList.get(i)).getDemerits();
}
+ /** @return the possibilities count */
public int getPossibilitiesNumber() {
return possibilitiesList.size();
}
+ /**
+ * @param i the break position index
+ * @return the chosen position
+ */
public Position getChosenPosition(int i) {
return ((Possibility)possibilitiesList.get(chosenIndex)).getBreakPosition(i);
}
+ /**
+ * @param adj the adjustment
+ * @return the adjustment or zero
+ */
public int applyLineCountAdjustment(int adj) {
if (adj >= (getMinLineCount() - getChosenLineCount())
&& adj <= (getMaxLineCount() - getChosenLineCount())
&& getLineCount(chosenIndex + adj) == getChosenLineCount() + adj) {
chosenIndex += adj;
- log.debug("chosenLineCount= " + (getChosenLineCount() - adj) + " adjustment= " + adj
+ LOG.debug("chosenLineCount= " + (getChosenLineCount() - adj) + " adjustment= " + adj
+ " => chosenLineCount= " + getLineCount(chosenIndex));
return adj;
} else {
// this should not happen!
- log.warn("Cannot apply the desired line count adjustment.");
+ LOG.warn("Cannot apply the desired line count adjustment.");
return 0;
}
}
+ /** print all */
public void printAll() {
System.out.println("++++++++++");
System.out.println(" " + possibilitiesList.size() + " possibility':");
- for (int i = 0; i < possibilitiesList.size(); i ++) {
+ for (int i = 0; i < possibilitiesList.size(); i++) {
System.out.println(" " + ((Possibility)possibilitiesList.get(i)).getLineCount()
+ (i == optimumIndex ? " *" : "")
+ (i == minimumIndex ? " -" : "")
diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java
index a38e3e2d8..56bcdaa3b 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLastLayoutManager.java
@@ -37,7 +37,7 @@ public class PageNumberCitationLastLayoutManager extends AbstractPageNumberCitat
* Constructor
*
* @param node the formatting object that creates this area
- * @todo better retrieval of font info
+ * TODO better retrieval of font info
*/
public PageNumberCitationLastLayoutManager(PageNumberCitationLast node) {
super(node);
diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java
index 583f73d24..958a854ac 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java
@@ -25,7 +25,6 @@ import org.apache.fop.area.inline.TextArea;
import org.apache.fop.area.inline.UnresolvedPageNumber;
import org.apache.fop.fo.flow.PageNumberCitation;
import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.LayoutManager;
/**
* LayoutManager for the fo:page-number-citation formatting object
@@ -36,7 +35,7 @@ public class PageNumberCitationLayoutManager extends AbstractPageNumberCitationL
* Constructor
*
* @param node the formatting object that creates this area
- * @todo better retrieval of font info
+ * TODO better retrieval of font info
*/
public PageNumberCitationLayoutManager(PageNumberCitation node) {
super(node);
diff --git a/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java b/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java
index a2a1dce27..19a1a1f8a 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java
@@ -19,8 +19,6 @@
package org.apache.fop.layoutmgr.inline;
-import org.apache.fop.datatypes.Length;
-
/**
* The FOP specific incarnation of the XSL-FO scaled baseline table.
* All baseline tables are scaled to the font size of the font they
diff --git a/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java b/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java
index 1536552c4..0d48ccbfe 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java
@@ -28,7 +28,10 @@ import org.apache.fop.fonts.Font;
* Currently supports alignment contexts for basic fonts
* and graphic inlines.
*/
-public class ScaledBaselineTableFactory implements Constants {
+public final class ScaledBaselineTableFactory implements Constants {
+
+ private ScaledBaselineTableFactory() {
+ }
/**
* Creates a new instance of BasicScaledBaselineTable for the given
diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
index 43e8c5a31..81240dec0 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
@@ -81,15 +81,10 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
private boolean breakOppAfter;
private final Font font;
- AreaInfo(final int startIndex,
- final int breakIndex,
- final int wordSpaceCount,
- final int letterSpaceCount,
- final MinOptMax areaIPD,
- final boolean isHyphenated,
- final boolean isSpace,
- final boolean breakOppAfter,
- final Font font) {
+ AreaInfo( // CSOK: ParameterNumber
+ int startIndex, int breakIndex, int wordSpaceCount, int letterSpaceCount,
+ MinOptMax areaIPD, boolean isHyphenated, boolean isSpace, boolean breakOppAfter,
+ Font font) {
assert startIndex <= breakIndex;
this.startIndex = startIndex;
this.breakIndex = breakIndex;
@@ -170,7 +165,8 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
private int hyphIPD;
private boolean hasChanged = false;
- private int returnedIndex = 0;
+ private int[] returnedIndices = {0, 0};
+ private int changeOffset = 0;
private int thisStart = 0;
private int tempStart = 0;
private List changeList = new LinkedList();
@@ -709,7 +705,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
if (inWord) {
processWord(alignment, sequence, prevAreaInfo, ch, false, false);
} else if (inWhitespace) {
- processWhitespace(alignment, sequence, true);
+ processWhitespace(alignment, sequence, !keepTogether);
} else if (areaInfo != null) {
processLeftoverAreaInfo(alignment, sequence, areaInfo,
ch == CharUtilities.ZERO_WIDTH_SPACE);
@@ -774,10 +770,8 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
while (lastIndex > 0 && foText.charAt(lastIndex - 1) == CharUtilities.SOFT_HYPHEN) {
lastIndex--;
}
- final boolean endsWithHyphen = checkEndsWithHyphen
- && foText.charAt(lastIndex) == CharUtilities.SOFT_HYPHEN;
- Font font = FontSelector.selectFontForCharactersInText(foText, thisStart, lastIndex, foText, this);
- int wordLength = lastIndex - thisStart;
+ Font font = FontSelector
+ .selectFontForCharactersInText(foText, thisStart, lastIndex, foText, this);
boolean kerning = font.hasKerning();
MinOptMax wordIPD = MinOptMax.ZERO;
for (int i = thisStart; i < lastIndex; i++) {
@@ -793,7 +787,8 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
if (i > thisStart) {
char previousChar = foText.charAt(i - 1);
kern = font.getKernValue(previousChar, currentChar);
- } else if (prevAreaInfo != null && !prevAreaInfo.isSpace && prevAreaInfo.breakIndex > 0) {
+ } else if (prevAreaInfo != null
+ && !prevAreaInfo.isSpace && prevAreaInfo.breakIndex > 0) {
char previousChar = foText.charAt(prevAreaInfo.breakIndex - 1);
kern = font.getKernValue(previousChar, currentChar);
}
@@ -803,30 +798,38 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
}
}
}
+ boolean endsWithHyphen = checkEndsWithHyphen
+ && foText.charAt(lastIndex) == CharUtilities.SOFT_HYPHEN;
if (kerning
&& breakOpportunity
&& !TextLayoutManager.isSpace(ch)
&& lastIndex > 0
&& endsWithHyphen) {
- final int kern = font.getKernValue(foText.charAt(lastIndex - 1), ch);
+ int kern = font.getKernValue(foText.charAt(lastIndex - 1), ch);
if (kern != 0) {
addToLetterAdjust(lastIndex, kern);
//TODO: add kern to wordIPD?
}
}
- int iLetterSpaces = wordLength - 1;
- // if there is a break opportunity and the next one
- // is not a space, it could be used as a line end;
- // add one more letter space, in case other text follows
- if (breakOpportunity && !TextLayoutManager.isSpace(ch)) {
- iLetterSpaces++;
+ // shy+chars at start of word: wordLength == 0 && breakOpportunity
+ // shy only characters in word: wordLength == 0 && !breakOpportunity
+ int wordLength = lastIndex - thisStart;
+ int letterSpaces = 0;
+ if (wordLength != 0) {
+ letterSpaces = wordLength - 1;
+ // if there is a break opportunity and the next one
+ // is not a space, it could be used as a line end;
+ // add one more letter space, in case other text follows
+ if (breakOpportunity && !TextLayoutManager.isSpace(ch)) {
+ letterSpaces++;
+ }
}
- assert iLetterSpaces >= 0;
- wordIPD = wordIPD.plus(letterSpaceIPD.mult(iLetterSpaces));
+ assert letterSpaces >= 0;
+ wordIPD = wordIPD.plus(letterSpaceIPD.mult(letterSpaces));
// create the AreaInfo object
AreaInfo areaInfo = new AreaInfo(thisStart, lastIndex, 0,
- iLetterSpaces, wordIPD,
+ letterSpaces, wordIPD,
endsWithHyphen,
false, breakOpportunity, font);
prevAreaInfo = areaInfo;
@@ -841,14 +844,20 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
}
/** {@inheritDoc} */
- public List addALetterSpaceTo(final List oldList) {
+ public List addALetterSpaceTo(List oldList) {
+ return addALetterSpaceTo(oldList, 0);
+ }
+
+ /** {@inheritDoc} */
+ public List addALetterSpaceTo(final List oldList, int depth) {
// old list contains only a box, or the sequence: box penalty glue box;
// look at the Position stored in the first element in oldList
// which is always a box
ListIterator oldListIterator = oldList.listIterator();
KnuthElement knuthElement = (KnuthElement) oldListIterator.next();
- LeafPosition pos = (LeafPosition) ((KnuthBox) knuthElement).getPosition();
- int index = pos.getLeafPos();
+ Position pos = knuthElement.getPosition();
+ LeafPosition leafPos = (LeafPosition) pos.getPosition(depth);
+ int index = leafPos.getLeafPos();
//element could refer to '-1' position, for non-collapsed spaces (?)
if (index > -1) {
AreaInfo areaInfo = getAreaInfo(index);
@@ -863,6 +872,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
oldListIterator.add(new KnuthGlue(letterSpaceIPD, auxiliaryPosition, false));
} else if (letterSpaceIPD.isStiff()) {
// constant letter space: replace the box
+ // give it the unwrapped position of the replaced element
oldListIterator.set(new KnuthInlineBox(areaInfo.areaIPD.getOpt(),
alignmentContext, pos, false));
} else {
@@ -876,41 +886,9 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
return oldList;
}
- /**
- * Removes the <code>AreaInfo</code> object represented by the given elements, so that it won't
- * generate any element when <code>getChangedKnuthElements</code> is called.
- *
- * @param oldList the elements representing the word space
- */
- public void removeWordSpace(final List oldList) {
- // find the element storing the Position whose value
- // points to the AreaInfo object
- final ListIterator oldListIterator = oldList.listIterator();
- if (((KnuthElement) ((LinkedList) oldList).getFirst()).isPenalty()) {
- // non breaking space: oldList starts with a penalty
- oldListIterator.next();
- }
- if (oldList.size() > 2) {
- // alignment is either center, start or end:
- // the first two elements does not store the needed Position
- oldListIterator.next();
- oldListIterator.next();
- }
- KnuthElement knuthElement = (KnuthElement) oldListIterator.next();
- int leafValue = ((LeafPosition) knuthElement.getPosition()).getLeafPos();
- // only the last word space can be a trailing space!
- if (leafValue == areaInfos.size() - 1) {
- areaInfos.remove(leafValue);
- } else {
- TextLayoutManager.LOG.error("trying to remove a non-trailing word space");
- }
- }
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public void hyphenate(Position pos, HyphContext hyphContext) {
- AreaInfo areaInfo = getAreaInfo(((LeafPosition) pos).getLeafPos());
+ AreaInfo areaInfo = getAreaInfo(((LeafPosition) pos).getLeafPos() + changeOffset);
int startIndex = areaInfo.startIndex;
int stopIndex;
boolean nothingChanged = true;
@@ -953,7 +931,9 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
}
// add letter spaces
- boolean isWordEnd = stopIndex == areaInfo.breakIndex && areaInfo.letterSpaceCount < areaInfo.getCharLength();
+ boolean isWordEnd
+ = stopIndex == areaInfo.breakIndex
+ && areaInfo.letterSpaceCount < areaInfo.getCharLength();
int letterSpaceCount = isWordEnd ? stopIndex - startIndex - 1 : stopIndex - startIndex;
assert letterSpaceCount >= 0;
@@ -963,7 +943,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
// the new AreaInfo object is not equal to the old one
changeList.add(new PendingChange(new AreaInfo(startIndex, stopIndex, 0,
letterSpaceCount, newIPD, hyphenFollows, false, false, font),
- ((LeafPosition) pos).getLeafPos()));
+ ((LeafPosition) pos).getLeafPos() + changeOffset));
nothingChanged = false;
}
startIndex = stopIndex;
@@ -973,11 +953,48 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
/** {@inheritDoc} */
public boolean applyChanges(final List oldList) {
+ return applyChanges(oldList, 0);
+ }
+
+ /** {@inheritDoc} */
+ public boolean applyChanges(final List oldList, int depth) {
+
+ // make sure the LM appears unfinished in between this call
+ // and the next call to getChangedKnuthElements()
setFinished(false);
+ if (oldList.isEmpty()) {
+ return false;
+ }
+
+ // Find the first and last positions in oldList that point to an AreaInfo
+ // (i.e. getLeafPos() != -1)
+ LeafPosition startPos = null, endPos = null;
+ ListIterator oldListIter;
+ for (oldListIter = oldList.listIterator(); oldListIter.hasNext();) {
+ Position pos = ((KnuthElement) oldListIter.next()).getPosition();
+ startPos = (LeafPosition) pos.getPosition(depth);
+ if (startPos != null && startPos.getLeafPos() != -1) {
+ break;
+ }
+ }
+ for (oldListIter = oldList.listIterator(oldList.size()); oldListIter.hasPrevious();) {
+ Position pos = ((KnuthElement) oldListIter.previous()).getPosition();
+ endPos = (LeafPosition) pos.getPosition(depth);
+ if (endPos != null && endPos.getLeafPos() != -1) {
+ break;
+ }
+ }
+
+ // set start/end index, taking into account any offset due to
+ // changes applied to previous paragraphs
+ returnedIndices[0] = (startPos != null ? startPos.getLeafPos() : -1) + changeOffset;
+ returnedIndices[1] = (endPos != null ? endPos.getLeafPos() : -1) + changeOffset;
+
+ int areaInfosAdded = 0;
+ int areaInfosRemoved = 0;
+
if (!changeList.isEmpty()) {
- int areaInfosAdded = 0;
- int areaInfosRemoved = 0;
int oldIndex = -1, changeIndex;
PendingChange currChange;
ListIterator changeListIterator = changeList.listIterator();
@@ -998,7 +1015,11 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
changeList.clear();
}
- returnedIndex = 0;
+ // increase the end index for getChangedKnuthElements()
+ returnedIndices[1] += (areaInfosAdded - areaInfosRemoved);
+ // increase offset to use for subsequent paragraphs
+ changeOffset += (areaInfosAdded - areaInfosRemoved);
+
return hasChanged;
}
@@ -1010,27 +1031,24 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
final LinkedList returnList = new LinkedList();
- while (returnedIndex < areaInfos.size()) {
- AreaInfo areaInfo = getAreaInfo(returnedIndex);
+ for (; returnedIndices[0] <= returnedIndices[1]; returnedIndices[0]++) {
+ AreaInfo areaInfo = getAreaInfo(returnedIndices[0]);
if (areaInfo.wordSpaceCount == 0) {
// areaInfo refers either to a word or a word fragment
- addElementsForAWordFragment(returnList, alignment, areaInfo, returnedIndex);
+ addElementsForAWordFragment(returnList, alignment, areaInfo, returnedIndices[0]);
} else {
// areaInfo refers to a space
- addElementsForASpace(returnList, alignment, areaInfo, returnedIndex);
+ addElementsForASpace(returnList, alignment, areaInfo, returnedIndices[0]);
}
- returnedIndex++;
}
- setFinished(true);
+ setFinished(returnedIndices[0] == areaInfos.size() - 1);
//ElementListObserver.observe(returnList, "text-changed", null);
return returnList;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
public String getWordChars(Position pos) {
- int leafValue = ((LeafPosition) pos).getLeafPos();
+ int leafValue = ((LeafPosition) pos).getLeafPos() + changeOffset;
if (leafValue != -1) {
AreaInfo areaInfo = getAreaInfo(leafValue);
StringBuffer buffer = new StringBuffer(areaInfo.getCharLength());
@@ -1065,11 +1083,13 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
if (foText.charAt(areaInfo.startIndex) != CharUtilities.SPACE
|| foText.getWhitespaceTreatment() == Constants.EN_PRESERVE) {
// a breaking space that needs to be preserved
- baseList.addAll(getElementsForBreakingSpace(alignment, areaInfo, auxiliaryPosition, 0,
+ baseList
+ .addAll(getElementsForBreakingSpace(alignment, areaInfo, auxiliaryPosition, 0,
mainPosition, areaInfo.areaIPD.getOpt(), true));
} else {
// a (possible block) of breaking spaces
- baseList.addAll(getElementsForBreakingSpace(alignment, areaInfo, mainPosition,
+ baseList
+ .addAll(getElementsForBreakingSpace(alignment, areaInfo, mainPosition,
areaInfo.areaIPD.getOpt(), auxiliaryPosition, 0, false));
}
}
@@ -1103,17 +1123,31 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
// if the second element is chosen as a line break these elements
// add a constant amount of stretch at the end of a line, otherwise
// they don't add any stretch
+ KnuthGlue g;
if (skipZeroCheck || lineStartBAP != 0 || lineEndBAP != 0) {
- elements.add(new KnuthGlue(lineEndBAP, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, auxiliaryPosition, false));
+ g = new KnuthGlue
+ (lineEndBAP,
+ 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, auxiliaryPosition, false);
+ elements.add(g);
elements.add(makeZeroWidthPenalty(0));
- elements.add(new KnuthGlue(p2WidthOffset - (lineStartBAP + lineEndBAP), -3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, pos2, false));
+ g = new KnuthGlue
+ (p2WidthOffset - (lineStartBAP + lineEndBAP),
+ -3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, pos2, false);
+ elements.add(g);
elements.add(makeAuxiliaryZeroWidthBox());
elements.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
- elements.add(new KnuthGlue(lineStartBAP + p3WidthOffset, 0, 0, pos3, false));
+ g = new KnuthGlue(lineStartBAP + p3WidthOffset, 0, 0, pos3, false);
+ elements.add(g);
} else {
- elements.add(new KnuthGlue(0, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, auxiliaryPosition, false));
+ g = new KnuthGlue
+ (0,
+ 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, auxiliaryPosition, false);
+ elements.add(g);
elements.add(makeZeroWidthPenalty(0));
- elements.add(new KnuthGlue(areaInfo.areaIPD.getOpt(), -3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, pos2, false));
+ g = new KnuthGlue
+ (areaInfo.areaIPD.getOpt(),
+ -3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, pos2, false);
+ elements.add(g);
}
break;
@@ -1133,9 +1167,10 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
return elements;
}
- private List getElementsForJustifiedText(AreaInfo areaInfo, Position pos2, int p2WidthOffset,
- Position pos3, int p3WidthOffset, boolean skipZeroCheck,
- int shrinkability) {
+ private List getElementsForJustifiedText
+ (AreaInfo areaInfo, Position pos2, int p2WidthOffset,
+ Position pos3, int p3WidthOffset, boolean skipZeroCheck,
+ int shrinkability) {
int stretchability = areaInfo.areaIPD.getStretch();
diff --git a/src/java/org/apache/fop/layoutmgr/table/CellPart.java b/src/java/org/apache/fop/layoutmgr/table/CellPart.java
index 7dd2bc201..cde19e67b 100644
--- a/src/java/org/apache/fop/layoutmgr/table/CellPart.java
+++ b/src/java/org/apache/fop/layoutmgr/table/CellPart.java
@@ -61,7 +61,8 @@ class CellPart {
* @param bpAfterLast width of (possibly optional) border- and padding-after if this
* part will be the last one on the page
*/
- protected CellPart(PrimaryGridUnit pgu, int start, int end, boolean last,
+ protected CellPart( // CSOK: ParameterNumber
+ PrimaryGridUnit pgu, int start, int end, boolean last,
int condBeforeContentLength, int length, int condAfterContentLength,
int bpBeforeNormal, int bpBeforeFirst,
int bpAfterNormal, int bpAfterLast) {
diff --git a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java
index ede6210ca..7221d4fee 100644
--- a/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java
+++ b/src/java/org/apache/fop/layoutmgr/table/CollapsingBorderModel.java
@@ -196,7 +196,7 @@ public abstract class CollapsingBorderModel {
* @param border1 a border specification
* @param border2 another border specification
* @return the winning border, null if the two borders are equivalent
- * @see determineWinner
+ * @see #determineWinner(BorderSpecification,BorderSpecification,boolean)
*/
public abstract BorderSpecification determineWinner(BorderSpecification border1,
BorderSpecification border2);
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
index e28126c3e..fc35a8069 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java
@@ -33,7 +33,7 @@ import org.apache.fop.layoutmgr.PositionIterator;
* The caption contains blocks that are positioned next to the
* table on the caption side.
* The caption blocks have an implicit keep with the table.
- * @todo Implement getNextKnuthElements()
+ * TODO Implement getNextKnuthElements()
*/
public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager {
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
index c7d0d0da4..7ba0b5970 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java
@@ -31,7 +31,7 @@ import org.apache.fop.layoutmgr.PositionIterator;
* LayoutManager for a table-caption FO.
* The table caption contains blocks that are placed beside the
* table.
- * @todo Implement getNextKnuthElements()
+ * TODO Implement getNextKnuthElements()
*/
public class TableCaptionLayoutManager extends BlockStackingLayoutManager {
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
index 0599b430c..ded18384d 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
@@ -277,17 +277,10 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager
* this row is placed on a previous page). Used to calculate the placement of the
* row's background image if any
*/
- public void addAreas(PositionIterator parentIter,
- LayoutContext layoutContext,
- int[] spannedGridRowHeights,
- int startRow,
- int endRow,
- int borderBeforeWhich,
- int borderAfterWhich,
- boolean firstOnPage,
- boolean lastOnPage,
- RowPainter painter,
- int firstRowHeight) {
+ public void addAreas( // CSOK: ParameterNumber
+ PositionIterator parentIter, LayoutContext layoutContext, int[] spannedGridRowHeights,
+ int startRow, int endRow, int borderBeforeWhich, int borderAfterWhich,
+ boolean firstOnPage, boolean lastOnPage, RowPainter painter, int firstRowHeight) {
getParentArea(null);
addId();
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
index 40ebf9e0d..db5b4736c 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
@@ -55,7 +55,7 @@ import org.apache.fop.util.BreakUtil;
public class TableContentLayoutManager implements PercentBaseContext {
/** Logger **/
- private static Log log = LogFactory.getLog(TableContentLayoutManager.class);
+ private static final Log LOG = LogFactory.getLog(TableContentLayoutManager.class);
private TableLayoutManager tableLM;
private TableRowIterator bodyIter;
@@ -127,10 +127,18 @@ public class TableContentLayoutManager implements PercentBaseContext {
return this.footerList;
}
- /** {@inheritDoc} */
- public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
- if (log.isDebugEnabled()) {
- log.debug("==> Columns: " + getTableLM().getColumns());
+ /**
+ * Get a sequence of KnuthElements representing the content
+ * of the node assigned to the LM.
+ *
+ * @param context the LayoutContext used to store layout information
+ * @param alignment the desired text alignment
+ * @return the list of KnuthElements
+ * @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(LayoutContext, int)
+ */
+ public List getNextKnuthElements(LayoutContext context, int alignment) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("==> Columns: " + getTableLM().getColumns());
}
KnuthBox headerAsFirst = null;
KnuthBox headerAsSecondToLast = null;
@@ -140,8 +148,8 @@ public class TableContentLayoutManager implements PercentBaseContext {
headerIter, context, alignment, TableRowIterator.HEADER);
this.headerNetHeight
= ElementListUtils.calcContentLength(this.headerList);
- if (log.isDebugEnabled()) {
- log.debug("==> Header: "
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("==> Header: "
+ headerNetHeight + " - " + this.headerList);
}
TableHeaderFooterPosition pos = new TableHeaderFooterPosition(
@@ -160,8 +168,8 @@ public class TableContentLayoutManager implements PercentBaseContext {
footerIter, context, alignment, TableRowIterator.FOOTER);
this.footerNetHeight
= ElementListUtils.calcContentLength(this.footerList);
- if (log.isDebugEnabled()) {
- log.debug("==> Footer: "
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("==> Footer: "
+ footerNetHeight + " - " + this.footerList);
}
//We can simply add the table footer at the end of the whole list
@@ -369,14 +377,14 @@ public class TableContentLayoutManager implements PercentBaseContext {
} else if (pos instanceof TableContentPosition) {
tablePositions.add(pos);
} else {
- if (log.isDebugEnabled()) {
- log.debug("Ignoring position: " + pos);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Ignoring position: " + pos);
}
}
}
if (lastPos instanceof TableHFPenaltyPosition) {
TableHFPenaltyPosition penaltyPos = (TableHFPenaltyPosition)lastPos;
- log.debug("Break at penalty!");
+ LOG.debug("Break at penalty!");
if (penaltyPos.headerElements != null) {
//Header positions for the penalty position are in the last element and need to
//be handled first before all other TableContentPositions
@@ -402,7 +410,7 @@ public class TableContentLayoutManager implements PercentBaseContext {
if (tablePositions.isEmpty()) {
// TODO make sure this actually never happens
- log.error("tablePositions empty."
+ LOG.error("tablePositions empty."
+ " Please send your FO file to fop-users@xmlgraphics.apache.org");
} else {
// Here we are sure that posIter iterates only over TableContentPosition instances
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
index 7ccab7898..7e343697a 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
@@ -240,7 +240,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager
// Elements for the table-header/footer/body
- LinkedList contentKnuthElements;
+ List contentKnuthElements;
contentLM = new TableContentLayoutManager(this);
LayoutContext childLC = new LayoutContext(0);
/*
@@ -552,4 +552,11 @@ public class TableLayoutManager extends BlockStackingLayoutManager
}
}
+ /** {@inheritDoc} */
+ public void reset() {
+ super.reset();
+ curBlockArea = null;
+ tableUnit = 0.0;
+ }
+
}
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java b/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java
index 282cd0fd5..35cba6da6 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java
@@ -28,8 +28,6 @@ import org.apache.fop.fo.FONode.FONodeIterator;
import org.apache.fop.fo.flow.table.EffRow;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableBody;
-import org.apache.fop.fo.flow.table.TablePart;
-
/**
* Iterator that lets the table layout manager step over all the rows of a part of the
diff --git a/src/java/org/apache/fop/pdf/AbstractPDFStream.java b/src/java/org/apache/fop/pdf/AbstractPDFStream.java
index 4107c7e7a..91605b293 100644
--- a/src/java/org/apache/fop/pdf/AbstractPDFStream.java
+++ b/src/java/org/apache/fop/pdf/AbstractPDFStream.java
@@ -191,7 +191,7 @@ public abstract class AbstractPDFStream extends PDFDictionary {
StreamCache encodedStream = null;
PDFNumber refLength = null;
final Object lengthEntry;
- if (getDocument().isEncodingOnTheFly()) {
+ if (isEncodingOnTheFly()) {
refLength = new PDFNumber();
getDocumentSafely().registerObject(refLength);
lengthEntry = refLength;
@@ -218,6 +218,15 @@ public abstract class AbstractPDFStream extends PDFDictionary {
}
/**
+ * Indicates whether encoding may happen without buffering the encoded data. If this method
+ * returns true, the /Length entry will be an indirect object, a direct object otherwise.
+ * @return true if encoding should happen "on the fly"
+ */
+ protected boolean isEncodingOnTheFly() {
+ return getDocument().isEncodingOnTheFly();
+ }
+
+ /**
* Populates the dictionary with all necessary entries for the stream.
* Override this method if you need additional entries.
* @param lengthEntry value for the /Length entry
diff --git a/src/java/org/apache/fop/pdf/AlphaRasterImage.java b/src/java/org/apache/fop/pdf/AlphaRasterImage.java
index bd31148be..7272c5edd 100644
--- a/src/java/org/apache/fop/pdf/AlphaRasterImage.java
+++ b/src/java/org/apache/fop/pdf/AlphaRasterImage.java
@@ -116,7 +116,7 @@ public class AlphaRasterImage implements PDFImage {
return null;
}
- /** {@inheritDoc} */
+ /** @return null (unless overridden) */
public String getSoftMask() {
return null;
}
diff --git a/src/java/org/apache/fop/pdf/CMapBuilder.java b/src/java/org/apache/fop/pdf/CMapBuilder.java
index affb4fcad..84b3b2ce7 100644
--- a/src/java/org/apache/fop/pdf/CMapBuilder.java
+++ b/src/java/org/apache/fop/pdf/CMapBuilder.java
@@ -22,11 +22,19 @@ package org.apache.fop.pdf;
import java.io.IOException;
import java.io.Writer;
+/** A cmap builder. */
public class CMapBuilder {
+ /** name */
protected String name;
+ /** writer */
protected Writer writer;
+ /**
+ * Construct cmap builder.
+ * @param writer a writer
+ * @param name a name
+ */
public CMapBuilder(Writer writer, String name) {
this.writer = writer;
this.name = name;
@@ -52,12 +60,14 @@ public class CMapBuilder {
writeUseCMap();
}
+ /** @throws IOException if i/o exception */
protected void writePreStream() throws IOException {
// writer.write("/Type /CMap\n");
// writer.write(sysInfo.toPDFString());
// writer.write("/CMapName /" + name + EOL);
}
+ /** @throws IOException if i/o exception */
protected void writeStreamComments() throws IOException {
writer.write("%!PS-Adobe-3.0 Resource-CMap\n");
writer.write("%%DocumentNeededResources: ProcSet (CIDInit)\n");
@@ -66,12 +76,19 @@ public class CMapBuilder {
writer.write("%%EndComments\n");
}
+ /** @throws IOException if i/o exception */
protected void writeCIDInit() throws IOException {
writer.write("/CIDInit /ProcSet findresource begin\n");
writer.write("12 dict begin\n");
writer.write("begincmap\n");
}
+ /**
+ * @param registry string
+ * @param ordering string
+ * @param supplement string
+ * @throws IOException if i/o exception
+ */
protected void writeCIDSystemInfo(String registry, String ordering, int supplement)
throws IOException {
writer.write("/CIDSystemInfo 3 dict dup begin\n");
@@ -87,32 +104,50 @@ public class CMapBuilder {
writer.write("end def\n");
}
+ /** @throws IOException if i/o exception */
protected void writeCIDSystemInfo() throws IOException {
writeCIDSystemInfo("Adobe", "Identity", 0);
}
+ /**
+ * @param version a version
+ * @throws IOException if i/o exception
+ */
protected void writeVersion(String version) throws IOException {
writer.write("/CMapVersion ");
writer.write(version);
writer.write(" def\n");
}
+ /**
+ * @param type a type
+ * @throws IOException if i/o exception
+ */
protected void writeType(String type) throws IOException {
writer.write("/CMapType ");
writer.write(type);
writer.write(" def\n");
}
+ /**
+ * @param name a name
+ * @throws IOException if i/o exception
+ */
protected void writeName(String name) throws IOException {
writer.write("/CMapName /");
writer.write(name);
writer.write(" def\n");
}
+ /** @throws IOException if i/o exception */
protected void writeCodeSpaceRange() throws IOException {
writeCodeSpaceRange(false);
}
+ /**
+ * @param singleByte true if single byte range
+ * @throws IOException if i/o exception
+ */
protected void writeCodeSpaceRange(boolean singleByte) throws IOException {
writer.write("1 begincodespacerange\n");
if (singleByte) {
@@ -123,18 +158,21 @@ public class CMapBuilder {
writer.write("endcodespacerange\n");
}
+ /** @throws IOException if i/o exception */
protected void writeCIDRange() throws IOException {
writer.write("1 begincidrange\n");
writer.write("<0000> <FFFF> 0\n");
writer.write("endcidrange\n");
}
+ /** @throws IOException if i/o exception */
protected void writeBFEntries() throws IOException {
// writer.write("1 beginbfrange\n");
// writer.write("<0020> <0100> <0000>\n");
// writer.write("endbfrange\n");
}
+ /** @throws IOException if i/o exception */
protected void writeWrapUp() throws IOException {
writer.write("endcmap\n");
writer.write("CMapName currentdict /CMap defineresource pop\n");
@@ -142,11 +180,13 @@ public class CMapBuilder {
writer.write("end\n");
}
+ /** @throws IOException if i/o exception */
protected void writeStreamAfterComments() throws IOException {
writer.write("%%EndResource\n");
writer.write("%%EOF\n");
}
+ /** does nothing */
protected void writeUseCMap() {
/*
* writer.write(" /Type /CMap");
diff --git a/src/java/org/apache/fop/pdf/DestinationComparator.java b/src/java/org/apache/fop/pdf/DestinationComparator.java
index 87d6a00ff..0966853ea 100644
--- a/src/java/org/apache/fop/pdf/DestinationComparator.java
+++ b/src/java/org/apache/fop/pdf/DestinationComparator.java
@@ -30,6 +30,7 @@ public class DestinationComparator implements java.util.Comparator {
return dest1.getIDRef().compareTo(dest2.getIDRef());
}*/
+ /** {@inheritDoc} */
public int compare (Object obj1, Object obj2) {
if (obj1 instanceof PDFDestination && obj2 instanceof PDFDestination) {
PDFDestination dest1 = (PDFDestination)obj1;
diff --git a/src/java/org/apache/fop/pdf/PDFArray.java b/src/java/org/apache/fop/pdf/PDFArray.java
index a7dfc388e..a79e2704f 100644
--- a/src/java/org/apache/fop/pdf/PDFArray.java
+++ b/src/java/org/apache/fop/pdf/PDFArray.java
@@ -172,6 +172,13 @@ public class PDFArray extends PDFObject {
this.values.add(new Double(value));
}
+ /**
+ * Clears the PDF array.
+ */
+ public void clear() {
+ this.values.clear();
+ }
+
/** {@inheritDoc} */
protected int output(OutputStream stream) throws IOException {
CountingOutputStream cout = new CountingOutputStream(stream);
diff --git a/src/java/org/apache/fop/pdf/PDFCIDFont.java b/src/java/org/apache/fop/pdf/PDFCIDFont.java
index 3224eb567..459fe2584 100644
--- a/src/java/org/apache/fop/pdf/PDFCIDFont.java
+++ b/src/java/org/apache/fop/pdf/PDFCIDFont.java
@@ -56,9 +56,10 @@ public class PDFCIDFont extends PDFObject {
* @param supplement Supplement number
* @param descriptor CID font descriptor
*/
- public PDFCIDFont(String basefont, CIDFontType cidtype, int dw,
- int[] w, String registry, String ordering,
- int supplement, PDFCIDFontDescriptor descriptor) {
+ public PDFCIDFont( // CSOK: ParameterNumber
+ String basefont, CIDFontType cidtype, int dw,
+ int[] w, String registry, String ordering,
+ int supplement, PDFCIDFontDescriptor descriptor) {
this(basefont, cidtype, dw,
new PDFWArray(w),
diff --git a/src/java/org/apache/fop/pdf/PDFDocument.java b/src/java/org/apache/fop/pdf/PDFDocument.java
index 10834760e..9268ae921 100644
--- a/src/java/org/apache/fop/pdf/PDFDocument.java
+++ b/src/java/org/apache/fop/pdf/PDFDocument.java
@@ -91,7 +91,7 @@ public class PDFDocument {
private long xref;
/** the character position of each object */
- private List location = new ArrayList();
+ private List<Long> location = new ArrayList<Long>();
/** List of objects to write in the trailer */
private List trailerObjects = new ArrayList();
@@ -124,8 +124,8 @@ public class PDFDocument {
private PDFEncryption encryption;
/** the colorspace (0=RGB, 1=CMYK) */
- private PDFDeviceColorSpace colorspace =
- new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
+ private PDFDeviceColorSpace colorspace
+ = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
/** the counter for Pattern name numbering (e.g. 'Pattern1') */
private int patternCount = 0;
@@ -747,6 +747,7 @@ public class PDFDocument {
* @return the image or PDFXObject for the key if found
* @deprecated Use getXObject instead (so forms are treated in the same way)
*/
+ @Deprecated
public PDFImageXObject getImage(String key) {
return (PDFImageXObject)this.xObjectsMap.get(key);
}
@@ -915,7 +916,7 @@ public class PDFDocument {
while (this.location.size() <= objidx) {
this.location.add(LOCATION_PLACEHOLDER);
}
- this.location.set(objidx, new Long(position));
+ this.location.set(objidx, position);
}
/**
@@ -1017,9 +1018,7 @@ public class PDFDocument {
output(stream);
for (int count = 0; count < this.trailerObjects.size(); count++) {
PDFObject o = (PDFObject)this.trailerObjects.get(count);
- this.location.set(
- o.getObjectNumber() - 1,
- new Long(this.position));
+ setLocation(o.getObjectNumber() - 1, this.position);
this.position += o.output(stream);
}
/* output the xref table and increment the character position
diff --git a/src/java/org/apache/fop/pdf/PDFEmbeddedFile.java b/src/java/org/apache/fop/pdf/PDFEmbeddedFile.java
new file mode 100644
index 000000000..a5b44710a
--- /dev/null
+++ b/src/java/org/apache/fop/pdf/PDFEmbeddedFile.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.pdf;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * This class represents an embedded file stream.
+ */
+public class PDFEmbeddedFile extends PDFStream {
+
+ /**
+ * Creates a new embedded file stream.
+ */
+ public PDFEmbeddedFile() {
+ super();
+ put("Type", new PDFName("EmbeddedFile"));
+ PDFDictionary params = new PDFDictionary();
+ params.put("CreationDate", params.formatDateTime(new Date()));
+ put("Params", params);
+ }
+
+ /** {@inheritDoc} */
+ protected boolean isEncodingOnTheFly() {
+ //Acrobat doesn't like an indirect /Length object in this case,
+ //but only when the embedded file is a PDF file.
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ protected void populateStreamDict(Object lengthEntry) {
+ super.populateStreamDict(lengthEntry);
+ try {
+ PDFDictionary dict = (PDFDictionary)get("Params");
+ dict.put("Size", new Integer(data.getSize()));
+ } catch (IOException ioe) {
+ //ignore and just skip this entry as it's optional
+ }
+ }
+
+}
diff --git a/src/java/org/apache/fop/pdf/PDFEmbeddedFiles.java b/src/java/org/apache/fop/pdf/PDFEmbeddedFiles.java
new file mode 100644
index 000000000..8e89f5ada
--- /dev/null
+++ b/src/java/org/apache/fop/pdf/PDFEmbeddedFiles.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.pdf;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.SortedMap;
+
+/**
+ * Class representing an /EmbeddedFiles dictionary object (name tree).
+ */
+public class PDFEmbeddedFiles extends PDFNameTreeNode {
+
+ /**
+ * Create a /EmbeddedFiles dictionary.
+ */
+ public PDFEmbeddedFiles() {
+ super();
+ }
+
+ /** {@inheritDoc} */
+ protected void writeDictionary(OutputStream out, Writer writer) throws IOException {
+ sortNames(); //Sort the names before writing them out
+ super.writeDictionary(out, writer);
+ }
+
+ private void sortNames() {
+ PDFArray names = getNames();
+ SortedMap map = new java.util.TreeMap();
+ int i = 0;
+ int c = names.length();
+ while (i < c) {
+ Comparable key = (Comparable)names.get(i++); //Key must be a Comparable for sorting
+ Object value = names.get(i++);
+ map.put(key, value);
+ }
+ names.clear();
+ Iterator iter = map.entrySet().iterator();
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ names.add(entry.getKey());
+ names.add(entry.getValue());
+ }
+ }
+}
+
diff --git a/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java b/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java
index 43a323335..269f0639d 100644
--- a/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java
+++ b/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java
@@ -21,7 +21,6 @@ package org.apache.fop.pdf;
// Java
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
@@ -80,26 +79,6 @@ public class PDFEncryptionJCE extends PDFObject implements PDFEncryption {
}
/**
- * Encode the given data with the filter
- * @param data The data to be encrypted
- * @return The encrypted data
- */
- public byte[] encode(byte[] data) {
- return encryption.encryptData(data, number, generation);
- }
-
- /**
- * {@inheritDoc}
- */
- public void encode(InputStream in, OutputStream out, int length)
- throws IOException {
- byte[] buffer = new byte[length];
- in.read(buffer);
- buffer = encode(buffer);
- out.write(buffer);
- }
-
- /**
* {@inheritDoc}
*/
public OutputStream applyFilter(OutputStream out) throws IOException {
diff --git a/src/java/org/apache/fop/pdf/PDFEncryptionManager.java b/src/java/org/apache/fop/pdf/PDFEncryptionManager.java
index 5d5ea8586..3f5ae2a3d 100644
--- a/src/java/org/apache/fop/pdf/PDFEncryptionManager.java
+++ b/src/java/org/apache/fop/pdf/PDFEncryptionManager.java
@@ -31,10 +31,13 @@ import org.apache.commons.logging.LogFactory;
* This class acts as a factory for PDF encryption support. It enables the
* feature to be optional to FOP depending on the availability of JCE.
*/
-public class PDFEncryptionManager {
+public final class PDFEncryptionManager {
+
+ private PDFEncryptionManager() {
+ }
/** logging instance */
- protected static Log log = LogFactory.getLog(PDFEncryptionManager.class);
+ private static final Log LOG = LogFactory.getLog(PDFEncryptionManager.class);
/**
* Indicates whether JCE is available.
@@ -60,12 +63,12 @@ public class PDFEncryptionManager {
Provider[] providers;
providers = Security.getProviders("Cipher.RC4");
if (providers == null) {
- log.warn("Cipher provider for RC4 not available.");
+ LOG.warn("Cipher provider for RC4 not available.");
return false;
}
providers = Security.getProviders("MessageDigest.MD5");
if (providers == null) {
- log.warn("MessageDigest provider for MD5 not available.");
+ LOG.warn("MessageDigest provider for MD5 not available.");
return false;
}
return true;
@@ -88,13 +91,13 @@ public class PDFEncryptionManager {
if (params != null) {
if (!checkAvailableAlgorithms()) {
if (isJCEAvailable()) {
- log.warn("PDF encryption has been requested, JCE is "
+ LOG.warn("PDF encryption has been requested, JCE is "
+ "available but there's no "
+ "JCE provider available that provides the "
+ "necessary algorithms. The PDF won't be "
+ "encrypted.");
} else {
- log.warn("PDF encryption has been requested but JCE is "
+ LOG.warn("PDF encryption has been requested but JCE is "
+ "unavailable! The PDF won't be encrypted.");
}
}
@@ -119,19 +122,19 @@ public class PDFEncryptionManager {
return (PDFEncryption)obj;
} catch (ClassNotFoundException e) {
if (checkAvailableAlgorithms()) {
- log.warn("JCE and algorithms available, but the "
+ LOG.warn("JCE and algorithms available, but the "
+ "implementation class unavailable. Please do a full "
+ "rebuild.");
}
return null;
} catch (NoSuchMethodException e) {
- log.error(e);
+ LOG.error(e);
return null;
} catch (IllegalAccessException e) {
- log.error(e);
+ LOG.error(e);
return null;
} catch (InvocationTargetException e) {
- log.error(e);
+ LOG.error(e);
return null;
}
}
diff --git a/src/java/org/apache/fop/pdf/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java
index b7ce6618d..23542a49e 100644
--- a/src/java/org/apache/fop/pdf/PDFFactory.java
+++ b/src/java/org/apache/fop/pdf/PDFFactory.java
@@ -69,6 +69,9 @@ import org.apache.fop.fonts.type1.PFBParser;
*/
public class PDFFactory {
+ /** Resolution of the User Space coordinate system (72dpi). */
+ public static final int DEFAULT_PDF_RESOLUTION = 72;
+
private PDFDocument document;
private Log log = LogFactory.getLog(PDFFactory.class);
@@ -293,12 +296,13 @@ public class PDFFactory {
* It should be 0 as this is the constructor for sampled functions.
* @return the PDF function that was created
*/
- public PDFFunction makeFunction(int theFunctionType, List theDomain,
- List theRange, List theSize,
- int theBitsPerSample, int theOrder,
- List theEncode, List theDecode,
- StringBuffer theFunctionDataStream,
- List theFilter) {
+ public PDFFunction makeFunction( // CSOK: ParameterNumber
+ int theFunctionType, List theDomain,
+ List theRange, List theSize,
+ int theBitsPerSample, int theOrder,
+ List theEncode, List theDecode,
+ StringBuffer theFunctionDataStream,
+ List theFilter) {
// Type 0 function
PDFFunction function = new PDFFunction(theFunctionType, theDomain,
theRange, theSize,
@@ -466,12 +470,13 @@ public class PDFFactory {
* @param theFunction The PDF Function that maps an (x,y) location to a color
* @return the PDF shading that was created
*/
- public PDFShading makeShading(PDFResourceContext res, int theShadingType,
- PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias, List theDomain,
- List theMatrix,
- PDFFunction theFunction) {
+ public PDFShading makeShading( // CSOK: ParameterNumber
+ PDFResourceContext res, int theShadingType,
+ PDFDeviceColorSpace theColorSpace,
+ List theBackground, List theBBox,
+ boolean theAntiAlias, List theDomain,
+ List theMatrix,
+ PDFFunction theFunction) {
// make Shading of Type 1
PDFShading shading = new PDFShading(theShadingType,
theColorSpace, theBackground,
@@ -518,12 +523,13 @@ public class PDFFactory {
* The default is [false, false]
* @return the PDF shading that was created
*/
- public PDFShading makeShading(PDFResourceContext res, int theShadingType,
- PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias, List theCoords,
- List theDomain, PDFFunction theFunction,
- List theExtend) {
+ public PDFShading makeShading( // CSOK: ParameterNumber
+ PDFResourceContext res, int theShadingType,
+ PDFDeviceColorSpace theColorSpace,
+ List theBackground, List theBBox,
+ boolean theAntiAlias, List theCoords,
+ List theDomain, PDFFunction theFunction,
+ List theExtend) {
// make Shading of Type 2 or 3
PDFShading shading = new PDFShading(theShadingType,
theColorSpace, theBackground,
@@ -571,14 +577,15 @@ public class PDFFactory {
* @param theFunction the PDFFunction
* @return the PDF shading that was created
*/
- public PDFShading makeShading(PDFResourceContext res, int theShadingType,
- PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias,
- int theBitsPerCoordinate,
- int theBitsPerComponent,
- int theBitsPerFlag, List theDecode,
- PDFFunction theFunction) {
+ public PDFShading makeShading( // CSOK: ParameterNumber
+ PDFResourceContext res, int theShadingType,
+ PDFDeviceColorSpace theColorSpace,
+ List theBackground, List theBBox,
+ boolean theAntiAlias,
+ int theBitsPerCoordinate,
+ int theBitsPerComponent,
+ int theBitsPerFlag, List theDecode,
+ PDFFunction theFunction) {
// make Shading of type 4,6 or 7
PDFShading shading = new PDFShading(theShadingType,
theColorSpace, theBackground,
@@ -626,14 +633,15 @@ public class PDFFactory {
* @param theFunction The PDFFunction that's mapped on to this shape
* @return the PDF shading that was created
*/
- public PDFShading makeShading(PDFResourceContext res, int theShadingType,
- PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias,
- int theBitsPerCoordinate,
- int theBitsPerComponent, List theDecode,
- int theVerticesPerRow,
- PDFFunction theFunction) {
+ public PDFShading makeShading( // CSOK: ParameterNumber
+ PDFResourceContext res, int theShadingType,
+ PDFDeviceColorSpace theColorSpace,
+ List theBackground, List theBBox,
+ boolean theAntiAlias,
+ int theBitsPerCoordinate,
+ int theBitsPerComponent, List theDecode,
+ int theVerticesPerRow,
+ PDFFunction theFunction) {
// make shading of Type 5
PDFShading shading = new PDFShading(theShadingType,
theColorSpace, theBackground,
@@ -676,11 +684,12 @@ public class PDFFactory {
* @param thePatternDataStream The stream of pattern data to be tiled.
* @return the PDF pattern that was created
*/
- public PDFPattern makePattern(PDFResourceContext res, int thePatternType, // 1
- PDFResources theResources, int thePaintType, int theTilingType,
- List theBBox, double theXStep,
- double theYStep, List theMatrix,
- List theXUID, StringBuffer thePatternDataStream) {
+ public PDFPattern makePattern( // CSOK: ParameterNumber
+ PDFResourceContext res, int thePatternType, // 1
+ PDFResources theResources, int thePaintType, int theTilingType,
+ List theBBox, double theXStep,
+ double theYStep, List theMatrix,
+ List theXUID, StringBuffer thePatternDataStream) {
// PDFResources theResources
PDFPattern pattern = new PDFPattern(theResources, 1,
thePaintType, theTilingType,
@@ -884,7 +893,8 @@ public class PDFFactory {
*/
public PDFNames makeNames() {
PDFNames names = new PDFNames();
- getDocument().registerObject(names);
+ getDocument().assignObjectNumber(names);
+ getDocument().addTrailerObject(names);
return names;
}
@@ -1057,6 +1067,8 @@ public class PDFFactory {
return link;
}
+ private static final String EMBEDDED_FILE = "embedded-file:";
+
/**
* Create/find and return the appropriate external PDFAction according to the target
*
@@ -1069,32 +1081,88 @@ public class PDFFactory {
public PDFAction getExternalAction(String target, boolean newWindow) {
int index;
String targetLo = target.toLowerCase();
- // HTTP URL?
- if (targetLo.startsWith("http://")) {
+ if (target.startsWith(EMBEDDED_FILE)) {
+ // File Attachments (Embedded Files)
+ String filename = target.substring(EMBEDDED_FILE.length());
+ return getActionForEmbeddedFile(filename, newWindow);
+ } else if (targetLo.startsWith("http://")) {
+ // HTTP URL?
return new PDFUri(target);
- // Non PDF files. Try to /Launch them.
} else if (targetLo.startsWith("file://")) {
+ // Non PDF files. Try to /Launch them.
target = target.substring("file://".length());
return getLaunchAction(target);
- // Bare PDF file name?
} else if (targetLo.endsWith(".pdf")) {
+ // Bare PDF file name?
return getGoToPDFAction(target, null, -1, newWindow);
- // PDF file + page?
- } else if ((index = targetLo.indexOf(".pdf#page=")) > 0) {
+ } else if ((index = targetLo.indexOf(".pdf#page=")) > 0) { // CSOK: InnerAssignment
+ // PDF file + page?
String filename = target.substring(0, index + 4);
int page = Integer.parseInt(target.substring(index + 10));
return getGoToPDFAction(filename, null, page, newWindow);
- // PDF file + destination?
- } else if ((index = targetLo.indexOf(".pdf#dest=")) > 0) {
+ } else if ((index = targetLo.indexOf(".pdf#dest=")) > 0) { // CSOK: InnerAssignment
+ // PDF file + destination?
String filename = target.substring(0, index + 4);
String dest = target.substring(index + 10);
return getGoToPDFAction(filename, dest, -1, newWindow);
- // None of the above? Default to URI:
} else {
+ // None of the above? Default to URI:
return new PDFUri(target);
}
}
+ private PDFAction getActionForEmbeddedFile(String filename, boolean newWindow) {
+ PDFNames names = getDocument().getRoot().getNames();
+ if (names == null) {
+ throw new IllegalStateException(
+ "No Names dictionary present."
+ + " Cannot create Launch Action for embedded file: " + filename);
+ }
+ PDFNameTreeNode embeddedFiles = names.getEmbeddedFiles();
+ if (embeddedFiles == null) {
+ throw new IllegalStateException(
+ "No /EmbeddedFiles name tree present."
+ + " Cannot create Launch Action for embedded file: " + filename);
+ }
+
+ //Find filespec reference for the embedded file
+ filename = PDFText.toPDFString(filename, '_');
+ PDFArray files = embeddedFiles.getNames();
+ PDFReference embeddedFileRef = null;
+ int i = 0;
+ while (i < files.length()) {
+ String name = (String)files.get(i);
+ i++;
+ PDFReference ref = (PDFReference)files.get(i);
+ if (name.equals(filename)) {
+ embeddedFileRef = ref;
+ break;
+ }
+ i++;
+ }
+ if (embeddedFileRef == null) {
+ throw new IllegalStateException(
+ "No embedded file with name " + filename + " present.");
+ }
+
+ //Finally create the action
+ //PDFLaunch action = new PDFLaunch(embeddedFileRef);
+ //This works with Acrobat 8 but not with Acrobat 9
+
+ //The following two options didn't seem to have any effect.
+ //PDFGoToEmbedded action = new PDFGoToEmbedded(embeddedFileRef, 0, newWindow);
+ //PDFGoToRemote action = new PDFGoToRemote(embeddedFileRef, 0, newWindow);
+
+ //This finally seems to work:
+ StringBuffer scriptBuffer = new StringBuffer();
+ scriptBuffer.append("this.exportDataObject({cName:\"");
+ scriptBuffer.append(filename);
+ scriptBuffer.append("\", nLaunch:2});");
+
+ PDFJavaScriptLaunchAction action = new PDFJavaScriptLaunchAction(scriptBuffer.toString());
+ return action;
+ }
+
/**
* Create or find a PDF GoTo with the given page reference string and Y offset,
* and return its PDF object reference
diff --git a/src/java/org/apache/fop/pdf/PDFFileSpec.java b/src/java/org/apache/fop/pdf/PDFFileSpec.java
index 8de4164af..b9a46c8b8 100644
--- a/src/java/org/apache/fop/pdf/PDFFileSpec.java
+++ b/src/java/org/apache/fop/pdf/PDFFileSpec.java
@@ -20,15 +20,9 @@
package org.apache.fop.pdf;
/**
- * class representing a /FileSpec object.
- *
+ * Class representing a /FileSpec object.
*/
-public class PDFFileSpec extends PDFObject {
-
- /**
- * the filename
- */
- protected String filename;
+public class PDFFileSpec extends PDFDictionary {
/**
* create a /FileSpec object.
@@ -39,29 +33,30 @@ public class PDFFileSpec extends PDFObject {
/* generic creation of object */
super();
+ put("Type", new PDFName("Filespec"));
+ put("F", filename);
+ }
- this.filename = filename;
+ private String getFilename() {
+ return (String)get("F");
}
/**
- * {@inheritDoc}
+ * Associates an dictionary with pointers to embedded file streams with this file spec.
+ * @param embeddedFileDict the dictionary with pointers to embedded file streams
*/
- public String toPDFString() {
- return getObjectID()
- + "<<\n/Type /FileSpec\n"
- + "/F (" + this.filename + ")\n"
- + ">>\nendobj\n";
+ public void setEmbeddedFile(PDFDictionary embeddedFileDict) {
+ put("EF", embeddedFileDict);
}
- /*
- * example
- * 29 0 obj
- * <<
- * /Type /FileSpec
- * /F (table1.pdf)
- * >>
- * endobj
+ /**
+ * Sets a description for the file spec.
+ * @param description the description
+ * @since PDF 1.6
*/
+ public void setDescription(String description) {
+ put("Desc", description);
+ }
/** {@inheritDoc} */
protected boolean contentEquals(PDFObject obj) {
@@ -75,7 +70,7 @@ public class PDFFileSpec extends PDFObject {
PDFFileSpec spec = (PDFFileSpec)obj;
- if (!spec.filename.equals(filename)) {
+ if (!spec.getFilename().equals(getFilename())) {
return false;
}
diff --git a/src/java/org/apache/fop/pdf/PDFFontDescriptor.java b/src/java/org/apache/fop/pdf/PDFFontDescriptor.java
index d4b412e4c..9d255545f 100644
--- a/src/java/org/apache/fop/pdf/PDFFontDescriptor.java
+++ b/src/java/org/apache/fop/pdf/PDFFontDescriptor.java
@@ -40,10 +40,11 @@ public class PDFFontDescriptor extends PDFDictionary {
* @param italicAngle the angle of the vertical dominant strokes
* @param stemV the width of the dominant vertical stems of glyphs
*/
- public PDFFontDescriptor(String basefont, int ascent,
- int descent, int capHeight, int flags,
- PDFRectangle fontBBox, int italicAngle,
- int stemV) {
+ public PDFFontDescriptor( // CSOK: ParameterNumber
+ String basefont, int ascent,
+ int descent, int capHeight, int flags,
+ PDFRectangle fontBBox, int italicAngle,
+ int stemV) {
super();
put("Type", new PDFName("FontDescriptor"));
diff --git a/src/java/org/apache/fop/pdf/PDFFunction.java b/src/java/org/apache/fop/pdf/PDFFunction.java
index d57cabb50..9e93ebee8 100644
--- a/src/java/org/apache/fop/pdf/PDFFunction.java
+++ b/src/java/org/apache/fop/pdf/PDFFunction.java
@@ -211,10 +211,11 @@ public class PDFFunction extends PDFObject {
* @param theFunctionType This is the type of function (0,2,3, or 4).
* It should be 0 as this is the constructor for sampled functions.
*/
- public PDFFunction(int theFunctionType, List theDomain,
- List theRange, List theSize, int theBitsPerSample,
- int theOrder, List theEncode, List theDecode,
- StringBuffer theFunctionDataStream, List theFilter) {
+ public PDFFunction( // CSOK: ParameterNumber
+ int theFunctionType, List theDomain,
+ List theRange, List theSize, int theBitsPerSample,
+ int theOrder, List theEncode, List theDecode,
+ StringBuffer theFunctionDataStream, List theFilter) {
super();
this.functionType = 0; // dang well better be 0;
@@ -374,7 +375,7 @@ public class PDFFunction extends PDFObject {
*
* @return the PDF string.
*/
- public byte[] toPDF() {
+ public byte[] toPDF() { // CSOK: MethodLength
int vectorSize = 0;
int numberOfFunctions = 0;
int tempInt = 0;
diff --git a/src/java/org/apache/fop/pdf/PDFGoTo.java b/src/java/org/apache/fop/pdf/PDFGoTo.java
index ad04650c6..0626f0fcd 100644
--- a/src/java/org/apache/fop/pdf/PDFGoTo.java
+++ b/src/java/org/apache/fop/pdf/PDFGoTo.java
@@ -42,10 +42,8 @@ public class PDFGoTo extends PDFAction {
* @param pageReference the pageReference represented by this object
*/
public PDFGoTo(String pageReference) {
- /* generic creation of object */
super();
-
- this.pageReference = pageReference;
+ setPageReference(pageReference);
}
/**
@@ -56,9 +54,7 @@ public class PDFGoTo extends PDFAction {
*/
public PDFGoTo(String pageReference, Point2D position) {
/* generic creation of object */
- super();
-
- this.pageReference = pageReference;
+ this(pageReference);
setPosition(position);
}
diff --git a/src/java/org/apache/fop/pdf/PDFGoToRemote.java b/src/java/org/apache/fop/pdf/PDFGoToRemote.java
index ee7660875..93fbe47de 100644
--- a/src/java/org/apache/fop/pdf/PDFGoToRemote.java
+++ b/src/java/org/apache/fop/pdf/PDFGoToRemote.java
@@ -27,7 +27,7 @@ public class PDFGoToRemote extends PDFAction {
/**
* the file specification
*/
- private PDFFileSpec pdfFileSpec;
+ private PDFReference pdfFileSpec;
private int pageReference = 0;
private String destination = null;
private boolean newWindow = false;
@@ -43,12 +43,12 @@ public class PDFGoToRemote extends PDFAction {
/* generic creation of object */
super();
- this.pdfFileSpec = pdfFileSpec;
+ this.pdfFileSpec = pdfFileSpec.makeReference();
this.newWindow = newWindow;
}
/**
- * create an GoToR object.
+ * Create an GoToR object.
*
* @param pdfFileSpec the fileSpec associated with the action
* @param page a page reference within the remote document
@@ -56,7 +56,18 @@ public class PDFGoToRemote extends PDFAction {
* displayed in a new window
*/
public PDFGoToRemote(PDFFileSpec pdfFileSpec, int page, boolean newWindow) {
- /* generic creation of object */
+ this(pdfFileSpec.makeReference(), page, newWindow);
+ }
+
+ /**
+ * Create an GoToR object.
+ *
+ * @param pdfFileSpec the fileSpec associated with the action
+ * @param page a page reference within the remote document
+ * @param newWindow boolean indicating whether the target should be
+ * displayed in a new window
+ */
+ public PDFGoToRemote(PDFReference pdfFileSpec, int page, boolean newWindow) {
super();
this.pdfFileSpec = pdfFileSpec;
@@ -76,7 +87,7 @@ public class PDFGoToRemote extends PDFAction {
/* generic creation of object */
super();
- this.pdfFileSpec = pdfFileSpec;
+ this.pdfFileSpec = pdfFileSpec.makeReference();
this.destination = dest;
this.newWindow = newWindow;
}
@@ -97,7 +108,7 @@ public class PDFGoToRemote extends PDFAction {
StringBuffer sb = new StringBuffer(64);
sb.append(getObjectID());
sb.append("<<\n/S /GoToR\n/F ");
- sb.append(pdfFileSpec.referencePDF());
+ sb.append(pdfFileSpec.toString());
sb.append("\n");
if (destination != null) {
@@ -139,7 +150,7 @@ public class PDFGoToRemote extends PDFAction {
PDFGoToRemote remote = (PDFGoToRemote)obj;
- if (!remote.pdfFileSpec.referencePDF().equals(pdfFileSpec.referencePDF())) {
+ if (!remote.pdfFileSpec.toString().equals(pdfFileSpec.toString())) {
return false;
}
diff --git a/src/java/org/apache/fop/pdf/PDFJavaScriptLaunchAction.java b/src/java/org/apache/fop/pdf/PDFJavaScriptLaunchAction.java
new file mode 100644
index 000000000..dcd3c6fea
--- /dev/null
+++ b/src/java/org/apache/fop/pdf/PDFJavaScriptLaunchAction.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.pdf;
+
+/**
+ * PDF Action which executes some JavaScript code.
+ * @since PDF 1.3
+ */
+public class PDFJavaScriptLaunchAction extends PDFAction {
+
+ private String script;
+
+ /**
+ * Creates a new /Launch action.
+ * @param script the script to run when the launch action is triggered
+ */
+ public PDFJavaScriptLaunchAction(String script) {
+ this.script = script;
+ }
+
+ /** {@inheritDoc} */
+ public String getAction() {
+ return this.referencePDF();
+ }
+
+ /** {@inheritDoc} */
+ public String toPDFString() {
+ StringBuffer sb = new StringBuffer(64);
+ sb.append(getObjectID());
+ sb.append("<<\n/S /JavaScript\n/JS (");
+ sb.append(this.script);
+ sb.append(")\n>>\nendobj\n");
+ return sb.toString();
+ }
+
+ /** {@inheritDoc} */
+ protected boolean contentEquals(PDFObject obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null || !(obj instanceof PDFJavaScriptLaunchAction)) {
+ return false;
+ }
+
+ PDFJavaScriptLaunchAction launch = (PDFJavaScriptLaunchAction) obj;
+
+ if (!launch.script.toString().equals(script.toString())) {
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/src/java/org/apache/fop/pdf/PDFLaunch.java b/src/java/org/apache/fop/pdf/PDFLaunch.java
index 386a7a9a3..e62da5279 100644
--- a/src/java/org/apache/fop/pdf/PDFLaunch.java
+++ b/src/java/org/apache/fop/pdf/PDFLaunch.java
@@ -5,7 +5,7 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
-
+ *
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@@ -14,7 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
/* $Id$ */
+
package org.apache.fop.pdf;
/**
@@ -22,21 +24,39 @@ package org.apache.fop.pdf;
*/
public class PDFLaunch extends PDFAction {
- private PDFFileSpec externalFileSpec;
+ private PDFReference externalFileSpec;
+ /**
+ * Creates a new /Launch action.
+ * @param fileSpec the file specification to launch
+ */
public PDFLaunch(PDFFileSpec fileSpec) {
+ this(fileSpec.makeReference());
+ }
+
+ /**
+ * Creates a new /Launch action.
+ * @param fileSpec a reference to the file specification
+ */
+ public PDFLaunch(PDFReference fileSpec) {
+ PDFObject fs = fileSpec.getObject();
+ if (fs != null) {
+ assert fs instanceof PDFFileSpec;
+ }
this.externalFileSpec = fileSpec;
}
+ /** {@inheritDoc} */
public String getAction() {
return this.referencePDF();
}
+ /** {@inheritDoc} */
public String toPDFString() {
StringBuffer sb = new StringBuffer(64);
sb.append(getObjectID());
sb.append("<<\n/S /Launch\n/F ");
- sb.append(externalFileSpec.referencePDF());
+ sb.append(externalFileSpec.toString());
sb.append(" \n>>\nendobj\n");
return sb.toString();
@@ -54,7 +74,7 @@ public class PDFLaunch extends PDFAction {
PDFLaunch launch = (PDFLaunch) obj;
- if (!launch.externalFileSpec.referencePDF().equals(externalFileSpec.referencePDF())) {
+ if (!launch.externalFileSpec.toString().equals(externalFileSpec.toString())) {
return false;
}
diff --git a/src/java/org/apache/fop/pdf/PDFMetadata.java b/src/java/org/apache/fop/pdf/PDFMetadata.java
index 92796c0d1..b9612d11b 100644
--- a/src/java/org/apache/fop/pdf/PDFMetadata.java
+++ b/src/java/org/apache/fop/pdf/PDFMetadata.java
@@ -47,7 +47,11 @@ public class PDFMetadata extends PDFStream {
private Metadata xmpMetadata;
private boolean readOnly = true;
- /** @see org.apache.fop.pdf.PDFObject#PDFObject() */
+ /**
+ * @param xmp xmp metadata
+ * @param readOnly true if read only
+ * @see org.apache.fop.pdf.PDFObject#PDFObject()
+ */
public PDFMetadata(Metadata xmp, boolean readOnly) {
super();
if (xmp == null) {
@@ -147,6 +151,9 @@ public class PDFMetadata extends PDFStream {
}
dc.addDate(info.getCreationDate());
+ //Somewhat redundant but some PDF/A checkers issue a warning without this.
+ dc.setFormat("application/pdf");
+
//PDF/A identification
PDFAMode pdfaMode = pdfDoc.getProfile().getPDFAMode();
if (pdfaMode.isPDFA1LevelB()) {
diff --git a/src/java/org/apache/fop/pdf/PDFName.java b/src/java/org/apache/fop/pdf/PDFName.java
index 18b1745e7..e40a12f13 100644
--- a/src/java/org/apache/fop/pdf/PDFName.java
+++ b/src/java/org/apache/fop/pdf/PDFName.java
@@ -41,6 +41,7 @@ public class PDFName extends PDFObject {
this.name = escapeName(name);
}
+ private static final String ESCAPED_NAME_CHARS = "/()<>[]%#";
/**
* Escapes a PDF name. It adds the leading slash and escapes characters as necessary.
@@ -56,7 +57,8 @@ public class PDFName extends PDFObject {
}
for (int i = (skipFirst ? 1 : 0), c = name.length(); i < c; i++) {
char ch = name.charAt(i);
- if (ch < 33 || ch > 126 || ch == 0x2F) {
+
+ if (ch < 33 || ch > 126 || ESCAPED_NAME_CHARS.indexOf(ch) >= 0) {
sb.append('#');
toHex(ch, sb);
} else {
diff --git a/src/java/org/apache/fop/pdf/PDFNameTreeNode.java b/src/java/org/apache/fop/pdf/PDFNameTreeNode.java
index 4bc00ef9c..4e1f1b71b 100644
--- a/src/java/org/apache/fop/pdf/PDFNameTreeNode.java
+++ b/src/java/org/apache/fop/pdf/PDFNameTreeNode.java
@@ -19,6 +19,7 @@
package org.apache.fop.pdf;
+
/**
* Class representing a PDF name tree node.
*/
@@ -104,7 +105,6 @@ public class PDFNameTreeNode extends PDFDictionary {
return (String)limits.get(1);
}
-
private PDFArray prepareLimitsArray() {
PDFArray limits = (PDFArray)get(LIMITS);
if (limits == null) {
diff --git a/src/java/org/apache/fop/pdf/PDFNames.java b/src/java/org/apache/fop/pdf/PDFNames.java
index 4253dd6d1..fbea0d3f5 100644
--- a/src/java/org/apache/fop/pdf/PDFNames.java
+++ b/src/java/org/apache/fop/pdf/PDFNames.java
@@ -24,6 +24,9 @@ package org.apache.fop.pdf;
*/
public class PDFNames extends PDFDictionary {
+ private static final String DESTS = "Dests";
+ private static final String EMBEDDED_FILES = "EmbeddedFiles";
+
/**
* Create the Names object
*/
@@ -37,7 +40,7 @@ public class PDFNames extends PDFDictionary {
* @return the Dests object, or null if it's not used
*/
public PDFDests getDests() {
- return (PDFDests)get("Dests");
+ return (PDFDests)get(DESTS);
}
/**
@@ -45,7 +48,23 @@ public class PDFNames extends PDFDictionary {
* @param dests the Dests object
*/
public void setDests(PDFDests dests) {
- put("Dests", dests);
+ put(DESTS, dests);
+ }
+
+ /**
+ * Returns the EmbeddedFiles object
+ * @return the EmbeddedFiles object, or null if it's not used
+ */
+ public PDFEmbeddedFiles getEmbeddedFiles() {
+ return (PDFEmbeddedFiles)get(EMBEDDED_FILES);
+ }
+
+ /**
+ * Set the EmbeddedFiles object
+ * @param embeddedFiles the EmbeddedFiles object
+ */
+ public void setEmbeddedFiles(PDFEmbeddedFiles embeddedFiles) {
+ put(EMBEDDED_FILES, embeddedFiles);
}
}
diff --git a/src/java/org/apache/fop/pdf/PDFNull.java b/src/java/org/apache/fop/pdf/PDFNull.java
index 01ec7898c..7e11a1763 100644
--- a/src/java/org/apache/fop/pdf/PDFNull.java
+++ b/src/java/org/apache/fop/pdf/PDFNull.java
@@ -33,7 +33,6 @@ public final class PDFNull implements PDFWritable {
/**
* Creates a new PDF name object.
- * @param name the name value
*/
private PDFNull() {
}
diff --git a/src/java/org/apache/fop/pdf/PDFObject.java b/src/java/org/apache/fop/pdf/PDFObject.java
index 21ff82394..09b8673a8 100644
--- a/src/java/org/apache/fop/pdf/PDFObject.java
+++ b/src/java/org/apache/fop/pdf/PDFObject.java
@@ -42,7 +42,7 @@ import org.apache.commons.logging.LogFactory;
public abstract class PDFObject implements PDFWritable {
/** logger for all PDFObjects (and descendants) */
- protected static Log log = LogFactory.getLog(PDFObject.class.getName());
+ protected static final Log log = LogFactory.getLog(PDFObject.class.getName());
/**
* the object's number
@@ -401,7 +401,7 @@ public abstract class PDFObject implements PDFWritable {
* identical, this method is not required to check everything. In the case
* of PDFObjects, this means that the overriding function does not have to
* check for {@link #getObjectID()}.
- *
+ *
* @param o
* object to compare to.
* @return true if the other object has the same content.
diff --git a/src/java/org/apache/fop/pdf/PDFPattern.java b/src/java/org/apache/fop/pdf/PDFPattern.java
index 89ae1efcd..74f56377e 100644
--- a/src/java/org/apache/fop/pdf/PDFPattern.java
+++ b/src/java/org/apache/fop/pdf/PDFPattern.java
@@ -117,11 +117,12 @@ public class PDFPattern extends PDFPathPaint {
* @param theXUID Optional vector of Integers that uniquely identify the pattern
* @param thePatternDataStream The stream of pattern data to be tiled.
*/
- public PDFPattern(PDFResources theResources, int thePatternType, // 1
- int thePaintType, int theTilingType, List theBBox,
- double theXStep, double theYStep,
- List theMatrix, List theXUID,
- StringBuffer thePatternDataStream) {
+ public PDFPattern( // CSOK: ParameterNumber
+ PDFResources theResources, int thePatternType, // 1
+ int thePaintType, int theTilingType, List theBBox,
+ double theXStep, double theYStep,
+ List theMatrix, List theXUID,
+ StringBuffer thePatternDataStream) {
super();
this.resources = theResources;
// This next parameter is implicit to all constructors, and is
diff --git a/src/java/org/apache/fop/pdf/PDFProfile.java b/src/java/org/apache/fop/pdf/PDFProfile.java
index b645cb825..fb4575105 100644
--- a/src/java/org/apache/fop/pdf/PDFProfile.java
+++ b/src/java/org/apache/fop/pdf/PDFProfile.java
@@ -265,4 +265,16 @@ public class PDFProfile {
}
}
+ /** Checks if embedded files are allowed. */
+ public void verifyEmbeddedFilesAllowed() {
+ final String err = "{0} does not allow embedded files.";
+ if (isPDFAActive()) {
+ throw new PDFConformanceException(format(err, getPDFAMode()));
+ }
+ if (isPDFXActive()) {
+ //Implicit since file specs are forbidden
+ throw new PDFConformanceException(format(err, getPDFXMode()));
+ }
+ }
+
}
diff --git a/src/java/org/apache/fop/pdf/PDFResources.java b/src/java/org/apache/fop/pdf/PDFResources.java
index 6d994a73d..46462bbd7 100644
--- a/src/java/org/apache/fop/pdf/PDFResources.java
+++ b/src/java/org/apache/fop/pdf/PDFResources.java
@@ -100,11 +100,9 @@ public class PDFResources extends PDFDictionary {
* @param fontInfo font info object to get font information from
*/
public void addFonts(PDFDocument doc, FontInfo fontInfo) {
- Map usedFonts = fontInfo.getUsedFonts();
- Iterator e = usedFonts.keySet().iterator();
- while (e.hasNext()) {
- String f = (String)e.next();
- Typeface font = (Typeface)usedFonts.get(f);
+ Map<String, Typeface> usedFonts = fontInfo.getUsedFonts();
+ for (String f : usedFonts.keySet()) {
+ Typeface font = usedFonts.get(f);
//Check if the font actually had any mapping operations. If not, it is an indication
//that it has never actually been used and therefore doesn't have to be embedded.
diff --git a/src/java/org/apache/fop/pdf/PDFShading.java b/src/java/org/apache/fop/pdf/PDFShading.java
index fa4d454ed..2f955b850 100644
--- a/src/java/org/apache/fop/pdf/PDFShading.java
+++ b/src/java/org/apache/fop/pdf/PDFShading.java
@@ -164,10 +164,11 @@ public class PDFShading extends PDFObject {
* It's optional, the default is the identity matrix
* @param theFunction The PDF Function that maps an (x,y) location to a color
*/
- public PDFShading(int theShadingType, PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias, List theDomain,
- List theMatrix, PDFFunction theFunction) {
+ public PDFShading( // CSOK: ParameterNumber
+ int theShadingType, PDFDeviceColorSpace theColorSpace,
+ List theBackground, List theBBox,
+ boolean theAntiAlias, List theDomain,
+ List theMatrix, PDFFunction theFunction) {
super();
this.shadingType = theShadingType; // 1
this.colorSpace = theColorSpace;
@@ -202,11 +203,12 @@ public class PDFShading extends PDFObject {
* and end colors past the start and end points
* The default is [false, false]
*/
- public PDFShading(int theShadingType, PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias, List theCoords,
- List theDomain, PDFFunction theFunction,
- List theExtend) {
+ public PDFShading( // CSOK: ParameterNumber
+ int theShadingType, PDFDeviceColorSpace theColorSpace,
+ List theBackground, List theBBox,
+ boolean theAntiAlias, List theCoords,
+ List theDomain, PDFFunction theFunction,
+ List theExtend) {
super();
this.shadingType = theShadingType; // 2 or 3
this.colorSpace = theColorSpace;
@@ -242,11 +244,12 @@ public class PDFShading extends PDFObject {
* @param theDecode List of Doubles see PDF 1.3 spec pages 303 to 312.
* @param theFunction the PDFFunction
*/
- public PDFShading(int theShadingType, PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias, int theBitsPerCoordinate,
- int theBitsPerComponent, int theBitsPerFlag,
- List theDecode, PDFFunction theFunction) {
+ public PDFShading( // CSOK: ParameterNumber
+ int theShadingType, PDFDeviceColorSpace theColorSpace,
+ List theBackground, List theBBox,
+ boolean theAntiAlias, int theBitsPerCoordinate,
+ int theBitsPerComponent, int theBitsPerFlag,
+ List theDecode, PDFFunction theFunction) {
super();
this.shadingType = theShadingType; // 4,6 or 7
@@ -281,11 +284,12 @@ public class PDFShading extends PDFObject {
* @param theVerticesPerRow number of vertices in each "row" of the lattice.
* @param theFunction The PDFFunction that's mapped on to this shape
*/
- public PDFShading(int theShadingType, PDFDeviceColorSpace theColorSpace,
- List theBackground, List theBBox,
- boolean theAntiAlias, int theBitsPerCoordinate,
- int theBitsPerComponent, List theDecode,
- int theVerticesPerRow, PDFFunction theFunction) {
+ public PDFShading( // CSOK: ParameterNumber
+ int theShadingType, PDFDeviceColorSpace theColorSpace,
+ List theBackground, List theBBox,
+ boolean theAntiAlias, int theBitsPerCoordinate,
+ int theBitsPerComponent, List theDecode,
+ int theVerticesPerRow, PDFFunction theFunction) {
super();
this.shadingType = theShadingType; // 5
this.colorSpace = theColorSpace;
@@ -334,7 +338,7 @@ public class PDFShading extends PDFObject {
*
* @return the PDF string.
*/
- public String toPDFString() {
+ public String toPDFString() { // CSOK: MethodLength
int vectorSize;
int tempInt;
StringBuffer p = new StringBuffer(128);
diff --git a/src/java/org/apache/fop/pdf/PDFText.java b/src/java/org/apache/fop/pdf/PDFText.java
index 02f845266..9566f60da 100644
--- a/src/java/org/apache/fop/pdf/PDFText.java
+++ b/src/java/org/apache/fop/pdf/PDFText.java
@@ -320,5 +320,41 @@ public class PDFText extends PDFObject {
return bout.toByteArray();
}
+ /**
+ * Converts a text to PDF's "string" data type. Unsupported characters get converted to '?'
+ * characters (similar to what the Java "US-ASCII" encoding does).
+ * @see #toPDFString(CharSequence, char)
+ * @param text the text to convert
+ * @return the converted string
+ */
+ public static String toPDFString(CharSequence text) {
+ return toPDFString(text, '?');
+ }
+
+ /**
+ * Converts a text to PDF's "string" data type. Unsupported characters get converted to the
+ * given replacement character.
+ * <p>
+ * The PDF library currently doesn't properly distinguish between the PDF
+ * data types "string" and "text string", so we currently restrict "string" to US-ASCII, also
+ * because "string" seems somewhat under-specified concerning the upper 128 bytes.
+ * @param text the text to convert
+ * @param replacement the replacement character used when substituting a character
+ * @return the converted string
+ */
+ public static String toPDFString(CharSequence text, char replacement) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0, c = text.length(); i < c; i++) {
+ char ch = text.charAt(i);
+ if (ch > 127) {
+ //TODO Revisit the restriction to US-ASCII once "string" and "text string" are
+ //"disentangled".
+ sb.append(replacement);
+ } else {
+ sb.append(ch);
+ }
+ }
+ return sb.toString();
+ }
}
diff --git a/src/java/org/apache/fop/pdf/PDFToUnicodeCMap.java b/src/java/org/apache/fop/pdf/PDFToUnicodeCMap.java
index 95999b73f..56ca884f9 100644
--- a/src/java/org/apache/fop/pdf/PDFToUnicodeCMap.java
+++ b/src/java/org/apache/fop/pdf/PDFToUnicodeCMap.java
@@ -79,7 +79,6 @@ public class PDFToUnicodeCMap extends PDFCMap {
/**
* Writes the CMap to a Writer.
- * @param writer the writer
* @throws IOException if an I/O error occurs
*/
public void writeCMap() throws IOException {
@@ -94,7 +93,6 @@ public class PDFToUnicodeCMap extends PDFCMap {
/**
* Writes the character mappings for this font.
- * @param p StingBuffer to write to
*/
protected void writeBFEntries() throws IOException {
if (unicodeCharMap != null) {
@@ -106,7 +104,6 @@ public class PDFToUnicodeCMap extends PDFCMap {
/**
* Writes the entries for single characters of a base font (only characters which cannot be
* expressed as part of a character range).
- * @param p StringBuffer to write to
* @param charArray all the characters to map
* @throws IOException
*/
@@ -147,7 +144,6 @@ public class PDFToUnicodeCMap extends PDFCMap {
/**
* Writes the entries for character ranges for a base font.
- * @param p StringBuffer to write to
* @param charArray all the characters to map
* @throws IOException
*/
diff --git a/src/java/org/apache/fop/pdf/TransitionDictionary.java b/src/java/org/apache/fop/pdf/TransitionDictionary.java
index 6711c9508..079a6ce4e 100644
--- a/src/java/org/apache/fop/pdf/TransitionDictionary.java
+++ b/src/java/org/apache/fop/pdf/TransitionDictionary.java
@@ -28,8 +28,6 @@ public class TransitionDictionary extends PDFDictionary {
/**
* Create a Transition Dictionary
- *
- * @param values the dictionary values to output
*/
public TransitionDictionary() {
put("Type", new PDFName("Trans"));
diff --git a/src/java/org/apache/fop/render/AbstractConfigurator.java b/src/java/org/apache/fop/render/AbstractConfigurator.java
index 096007b98..4adc1451e 100644
--- a/src/java/org/apache/fop/render/AbstractConfigurator.java
+++ b/src/java/org/apache/fop/render/AbstractConfigurator.java
@@ -30,10 +30,10 @@ import org.apache.fop.apps.FOUserAgent;
*/
public abstract class AbstractConfigurator {
/** logger instance */
- protected static Log log = LogFactory.getLog(AbstractConfigurator.class);
+ protected static final Log log = LogFactory.getLog(AbstractConfigurator.class);
private static final String MIME = "mime";
-
+
/** fop factory configuration */
protected FOUserAgent userAgent = null;
diff --git a/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java
index ee18dff0d..913a72b0d 100644
--- a/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java
+++ b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java
@@ -34,9 +34,10 @@ import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.io.IOException;
-import org.apache.fop.render.RendererContext.RendererContextWrapper;
import org.apache.xmlgraphics.util.UnitConv;
+import org.apache.fop.render.RendererContext.RendererContextWrapper;
+
/**
* Abstract base class for Graphics2DAdapter implementations.
*/
@@ -147,10 +148,14 @@ public abstract class AbstractGraphics2DAdapter implements Graphics2DAdapter {
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ * @deprecated
+ */
public void paintImage(Graphics2DImagePainter painter,
RendererContext context,
int x, int y, int width, int height) throws IOException {
+ //TODO Deprecated method to be removed once Barcode4J 2.1 is released.
paintImage((org.apache.xmlgraphics.java2d.Graphics2DImagePainter)painter,
context, x, y, width, height);
}
diff --git a/src/java/org/apache/fop/render/AbstractImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/AbstractImageHandlerGraphics2D.java
index a79734d49..5bac4d88f 100644
--- a/src/java/org/apache/fop/render/AbstractImageHandlerGraphics2D.java
+++ b/src/java/org/apache/fop/render/AbstractImageHandlerGraphics2D.java
@@ -34,7 +34,7 @@ import java.awt.image.DataBuffer;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
-import org.apache.fop.util.UnitConv;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* Abstract base class for ImageHandler implementations that process Java2D images through
@@ -45,7 +45,6 @@ public abstract class AbstractImageHandlerGraphics2D implements ImageHandler {
/**
* Paints the image to a BufferedImage and returns that.
* @param painter the painter which will paint the actual image
- * @param context the renderer context for the current renderer
* @param targetDimension the target dimensions of the image to be converted to a bitmap
* @param resolution the requested bitmap resolution
* @param gray true if the generated image should be in grayscales
diff --git a/src/java/org/apache/fop/render/AbstractImageHandlerRegistry.java b/src/java/org/apache/fop/render/AbstractImageHandlerRegistry.java
deleted file mode 100644
index 4196a1b19..000000000
--- a/src/java/org/apache/fop/render/AbstractImageHandlerRegistry.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render;
-
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.xmlgraphics.image.loader.Image;
-import org.apache.xmlgraphics.image.loader.ImageFlavor;
-import org.apache.xmlgraphics.util.Service;
-
-/**
- * This class holds references to various image handlers used by the renderers. It also
- * supports automatic discovery of additional handlers available through
- * the class path.
- */
-public abstract class AbstractImageHandlerRegistry {
-
- /** the logger */
- private static Log log = LogFactory.getLog(AbstractImageHandlerRegistry.class);
-
- private static final Comparator HANDLER_COMPARATOR = new Comparator() {
- public int compare(Object o1, Object o2) {
- ImageHandlerBase h1 = (ImageHandlerBase)o1;
- ImageHandlerBase h2 = (ImageHandlerBase)o2;
- return h1.getPriority() - h2.getPriority();
- }
- };
-
- /** Map containing image handlers for various MIME types */
- private final Map/*<Class, ImageHandler>*/ handlers
- = new java.util.HashMap/*<Class, ImageHandler>*/();
-
- /** List containing the same handlers as above but ordered by priority */
- private final List/*<ImageHandler>*/ handlerList
- = new java.util.LinkedList/*<ImageHandler>*/();
-
- /** Sorted Set of registered handlers */
- private ImageFlavor[] supportedFlavors = new ImageFlavor[0];
-
- private int handlerRegistrations;
- private int lastSync;
-
- /**
- * Default constructor.
- */
- public AbstractImageHandlerRegistry() {
- discoverHandlers();
- }
-
- /**
- * Add an ImageHandler. The handler itself is inspected to find out what it supports.
- * @param classname the fully qualified class name
- */
- public void addHandler(String classname) {
- try {
- ImageHandlerBase handlerInstance
- = (ImageHandlerBase)Class.forName(classname).newInstance();
- addHandler(handlerInstance);
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException("Could not find "
- + classname);
- } catch (InstantiationException e) {
- throw new IllegalArgumentException("Could not instantiate "
- + classname);
- } catch (IllegalAccessException e) {
- throw new IllegalArgumentException("Could not access "
- + classname);
- } catch (ClassCastException e) {
- throw new IllegalArgumentException(classname
- + " is not an "
- + getHandlerClass().getName());
- }
- }
-
- /**
- * Add an image handler. The handler itself is inspected to find out what it supports.
- * @param handler the ImageHandler instance
- */
- public synchronized void addHandler(ImageHandlerBase handler) {
- this.handlers.put(handler.getSupportedImageClass(), handler);
-
- //Sorted insert
- ListIterator iter = this.handlerList.listIterator();
- while (iter.hasNext()) {
- ImageHandlerBase h = (ImageHandlerBase)iter.next();
- if (getHandlerComparator().compare(handler, h) < 0) {
- iter.previous();
- break;
- }
- }
- iter.add(handler);
- this.handlerRegistrations++;
- }
-
- /**
- * Returns an ImageHandler which handles an specific image type given the MIME type
- * of the image.
- * @param img the Image to be handled
- * @return the ImageHandler responsible for handling the image or null if none is available
- */
- public ImageHandlerBase getHandler(Image img) {
- return getHandler(img.getClass());
- }
-
- /**
- * Returns an ImageHandler which handles an specific image type given the MIME type
- * of the image.
- * @param imageClass the Image subclass for which to get a handler
- * @return the ImageHandler responsible for handling the image or null if none is available
- */
- public synchronized ImageHandlerBase getHandler(Class imageClass) {
- ImageHandlerBase handler = null;
- Class cl = imageClass;
- while (cl != null) {
- handler = (ImageHandlerBase)handlers.get(cl);
- if (handler != null) {
- break;
- }
- cl = cl.getSuperclass();
- }
- return handler;
- }
-
- /**
- * Returns the ordered array of supported image flavors.
- * @return the array of image flavors
- */
- public synchronized ImageFlavor[] getSupportedFlavors() {
- if (this.lastSync != this.handlerRegistrations) {
- //Extract all ImageFlavors into a single array
- List flavors = new java.util.ArrayList();
- Iterator iter = this.handlerList.iterator();
- while (iter.hasNext()) {
- ImageFlavor[] f = ((ImageHandlerBase)iter.next()).getSupportedImageFlavors();
- for (int i = 0; i < f.length; i++) {
- flavors.add(f[i]);
- }
- }
- this.supportedFlavors = (ImageFlavor[])flavors.toArray(new ImageFlavor[flavors.size()]);
- this.lastSync = this.handlerRegistrations;
- }
- return this.supportedFlavors;
- }
-
- /**
- * Discovers ImageHandler implementations through the classpath and dynamically
- * registers them.
- */
- private void discoverHandlers() {
- // add mappings from available services
- Class imageHandlerClass = getHandlerClass();
- Iterator providers = Service.providers(imageHandlerClass);
- if (providers != null) {
- while (providers.hasNext()) {
- ImageHandlerBase handler = (ImageHandlerBase)providers.next();
- try {
- if (log.isDebugEnabled()) {
- log.debug("Dynamically adding ImageHandler: "
- + handler.getClass().getName());
- }
- addHandler(handler);
- } catch (IllegalArgumentException e) {
- log.error("Error while adding ImageHandler", e);
- }
-
- }
- }
- }
-
- /**
- * Returns the ImageHandler comparator
- *
- * @return the ImageHandler comparator
- */
- public Comparator getHandlerComparator() {
- return HANDLER_COMPARATOR;
- }
-
- /**
- * Returns the ImageHandler implementing class
- *
- * @return the ImageHandler implementing class
- */
- public abstract Class getHandlerClass();
-}
diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
index 54f6170db..cfce3a875 100644
--- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
+++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
@@ -172,11 +172,10 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
* @param bpsStart the border-start traits
* @param bpsEnd the border-end traits
*/
- protected void drawBackground(float startx, float starty,
- float width, float height,
- Trait.Background back,
- BorderProps bpsBefore, BorderProps bpsAfter,
- BorderProps bpsStart, BorderProps bpsEnd) {
+ protected void drawBackground( // CSOK: ParameterNumber
+ float startx, float starty, float width, float height, Trait.Background back,
+ BorderProps bpsBefore, BorderProps bpsAfter,
+ BorderProps bpsStart, BorderProps bpsEnd) {
if (back != null) {
endTextObject();
@@ -262,10 +261,10 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
* @param bpsStart the border-start traits
* @param bpsEnd the border-end traits
*/
- protected void drawBorders(float startx, float starty,
- float width, float height,
- BorderProps bpsBefore, BorderProps bpsAfter,
- BorderProps bpsStart, BorderProps bpsEnd) {
+ protected void drawBorders( // CSOK: ParameterNumber
+ float startx, float starty, float width, float height,
+ BorderProps bpsBefore, BorderProps bpsAfter,
+ BorderProps bpsStart, BorderProps bpsEnd) {
Rectangle2D.Float borderRect = new Rectangle2D.Float(startx, starty, width, height);
drawBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd);
}
@@ -283,7 +282,8 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
* @param bpsStart the border specification on the start side
* @param bpsEnd the border specification on the end side
*/
- protected void drawBorders(Rectangle2D.Float borderRect,
+ protected void drawBorders( // CSOK: MethodLength
+ Rectangle2D.Float borderRect,
BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd) {
//TODO generalize each of the four conditions into using a parameterized drawBorder()
boolean[] border = new boolean[] {
@@ -858,8 +858,9 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
* @param style the border style (one of Constants.EN_DASHED etc.)
* @param col the color for the border segment
*/
- protected abstract void drawBorderLine(float x1, float y1, float x2, float y2,
- boolean horz, boolean startOrBefore, int style, Color col);
+ protected abstract void drawBorderLine( // CSOK: ParameterNumber
+ float x1, float y1, float x2, float y2, boolean horz,
+ boolean startOrBefore, int style, Color col);
/** {@inheritDoc} */
public void renderForeignObject(ForeignObject fo, Rectangle2D pos) {
@@ -872,8 +873,6 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
/**
* Establishes a new coordinate system with the given transformation matrix.
* The current graphics state is saved and the new coordinate system is concatenated.
- * @param block
- *
* @param at the transformation matrix
*/
protected void establishTransformationMatrix(AffineTransform at) {
diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java
index 8233e480a..273f0bc16 100644
--- a/src/java/org/apache/fop/render/AbstractRenderer.java
+++ b/src/java/org/apache/fop/render/AbstractRenderer.java
@@ -79,7 +79,7 @@ public abstract class AbstractRenderer
implements Renderer, Constants {
/** logging instance */
- protected static Log log = LogFactory.getLog("org.apache.fop.render");
+ protected static final Log log = LogFactory.getLog("org.apache.fop.render");
/**
* user agent
@@ -208,14 +208,17 @@ public abstract class AbstractRenderer
return sb.toString();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ * @deprecated
+ */
public void startPageSequence(LineArea seqTitle) {
//do nothing
}
/** {@inheritDoc} */
public void startPageSequence(PageSequence pageSequence) {
- startPageSequence(pageSequence.getTitle());
+ // do nothing
}
// normally this would be overriden to create a page in the
diff --git a/src/java/org/apache/fop/render/DummyPercentBaseContext.java b/src/java/org/apache/fop/render/DummyPercentBaseContext.java
index f9ecf63fe..c04c1d000 100644
--- a/src/java/org/apache/fop/render/DummyPercentBaseContext.java
+++ b/src/java/org/apache/fop/render/DummyPercentBaseContext.java
@@ -39,7 +39,7 @@ public final class DummyPercentBaseContext implements PercentBaseContext {
public static DummyPercentBaseContext getInstance() {
return singleton;
}
-
+
/** {@inheritDoc} */
public int getBaseLength(int lengthBase, FObj fo) {
return 0;
diff --git a/src/java/org/apache/fop/render/ImageHandlerRegistry.java b/src/java/org/apache/fop/render/ImageHandlerRegistry.java
index e878e0dfe..02a26265c 100644
--- a/src/java/org/apache/fop/render/ImageHandlerRegistry.java
+++ b/src/java/org/apache/fop/render/ImageHandlerRegistry.java
@@ -133,6 +133,7 @@ public class ImageHandlerRegistry {
/**
* Returns the ordered array of supported image flavors. The array needs to be ordered by
* priority so the image loader framework can return the preferred image type.
+ * @param context the rendering context
* @return the array of image flavors
*/
public synchronized ImageFlavor[] getSupportedFlavors(RenderingContext context) {
diff --git a/src/java/org/apache/fop/render/ImageHandlerUtil.java b/src/java/org/apache/fop/render/ImageHandlerUtil.java
index 41e0e1d45..5aa5f152b 100644
--- a/src/java/org/apache/fop/render/ImageHandlerUtil.java
+++ b/src/java/org/apache/fop/render/ImageHandlerUtil.java
@@ -28,7 +28,10 @@ import org.apache.fop.fo.extensions.ExtensionElementMapping;
/**
* Utility methods for image handling.
*/
-public class ImageHandlerUtil {
+public final class ImageHandlerUtil {
+
+ private ImageHandlerUtil() {
+ }
/** conversion-mode extension attribute */
public static final QName CONVERSION_MODE = new QName(
diff --git a/src/java/org/apache/fop/render/PrintRenderer.java b/src/java/org/apache/fop/render/PrintRenderer.java
index 6e501c199..be3ace016 100644
--- a/src/java/org/apache/fop/render/PrintRenderer.java
+++ b/src/java/org/apache/fop/render/PrintRenderer.java
@@ -30,6 +30,7 @@ import org.apache.fop.apps.FOPException;
import org.apache.fop.area.Area;
import org.apache.fop.area.Trait;
import org.apache.fop.fonts.CustomFontCollection;
+import org.apache.fop.fonts.EmbedFontInfo;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontCollection;
import org.apache.fop.fonts.FontInfo;
@@ -48,13 +49,13 @@ public abstract class PrintRenderer extends AbstractRenderer {
protected FontResolver fontResolver = null;
/** list of fonts */
- protected List/*<EmbedFontInfo>*/ embedFontInfoList = null;
+ protected List<EmbedFontInfo> embedFontInfoList = null;
/**
* Adds a font list to current list of fonts
* @param fontList a font info list
*/
- public void addFontList(List/*<EmbedFontInfo>*/ fontList) {
+ public void addFontList(List<EmbedFontInfo> fontList) {
if (embedFontInfoList == null) {
setFontList(fontList);
} else {
@@ -65,14 +66,14 @@ public abstract class PrintRenderer extends AbstractRenderer {
/**
* @param embedFontInfoList list of available fonts
*/
- public void setFontList(List/*<EmbedFontInfo>*/ embedFontInfoList) {
+ public void setFontList(List<EmbedFontInfo> embedFontInfoList) {
this.embedFontInfoList = embedFontInfoList;
}
/**
* @return list of available embedded fonts
*/
- public List/*<EmbedFontInfo>*/ getFontList() {
+ public List<EmbedFontInfo> getFontList() {
return this.embedFontInfoList;
}
diff --git a/src/java/org/apache/fop/render/PrintRendererConfigurator.java b/src/java/org/apache/fop/render/PrintRendererConfigurator.java
index dd7a05067..90305ae03 100644
--- a/src/java/org/apache/fop/render/PrintRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/PrintRendererConfigurator.java
@@ -19,6 +19,7 @@
package org.apache.fop.render;
+import java.util.ArrayList;
import java.util.List;
import org.apache.avalon.framework.configuration.Configuration;
@@ -48,7 +49,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator
implements RendererConfigurator, IFDocumentHandlerConfigurator {
/** logger instance */
- protected static Log log = LogFactory.getLog(PrintRendererConfigurator.class);
+ protected static final Log log = LogFactory.getLog(PrintRendererConfigurator.class);
/**
* Default constructor
@@ -76,7 +77,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator
FontEventListener listener = new FontEventAdapter(
renderer.getUserAgent().getEventBroadcaster());
- List/*<EmbedFontInfo>*/ embedFontInfoList = buildFontList(cfg, fontResolver, listener);
+ List<EmbedFontInfo> embedFontInfoList = buildFontList(cfg, fontResolver, listener);
printRenderer.addFontList(embedFontInfoList);
}
@@ -88,7 +89,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator
* @return the list of {@link EmbedFontInfo} objects
* @throws FOPException if an error occurs while processing the configuration
*/
- protected List/*<EmbedFontInfo>*/ buildFontList(Configuration cfg, FontResolver fontResolver,
+ protected List<EmbedFontInfo> buildFontList(Configuration cfg, FontResolver fontResolver,
FontEventListener listener) throws FOPException {
FopFactory factory = userAgent.getFactory();
FontManager fontManager = factory.getFontManager();
@@ -102,7 +103,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator
//Read font configuration
FontInfoConfigurator fontInfoConfigurator
= new FontInfoConfigurator(cfg, fontManager, fontResolver, listener, strict);
- List/*<EmbedFontInfo>*/ fontInfoList = new java.util.ArrayList/*<EmbedFontInfo>*/();
+ List<EmbedFontInfo> fontInfoList = new ArrayList<EmbedFontInfo>();
fontInfoConfigurator.configure(fontInfoList);
return fontInfoList;
}
@@ -118,7 +119,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator
public void setupFontInfo(IFDocumentHandler documentHandler, FontInfo fontInfo)
throws FOPException {
FontManager fontManager = userAgent.getFactory().getFontManager();
- List fontCollections = new java.util.ArrayList();
+ List<FontCollection> fontCollections = new ArrayList<FontCollection>();
fontCollections.add(new Base14FontCollection(fontManager.isBase14KerningEnabled()));
Configuration cfg = super.getRendererConfig(documentHandler.getMimeType());
@@ -126,7 +127,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator
FontResolver fontResolver = new DefaultFontResolver(userAgent);
FontEventListener listener = new FontEventAdapter(
userAgent.getEventBroadcaster());
- List fontList = buildFontList(cfg, fontResolver, listener);
+ List<EmbedFontInfo> fontList = buildFontList(cfg, fontResolver, listener);
fontCollections.add(new CustomFontCollection(fontResolver, fontList));
}
diff --git a/src/java/org/apache/fop/render/Renderer.java b/src/java/org/apache/fop/render/Renderer.java
index 5fa9ca5b2..76f245251 100644
--- a/src/java/org/apache/fop/render/Renderer.java
+++ b/src/java/org/apache/fop/render/Renderer.java
@@ -149,7 +149,7 @@ public interface Renderer {
* Tells the renderer that a new page sequence starts.
*
* @param seqTitle The title of the page sequence
- * @deprecated Use startPageSequence(PageSequence) instead
+ * @deprecated Use {@link #startPageSequence(PageSequence)} instead
*/
void startPageSequence(LineArea seqTitle);
@@ -162,7 +162,7 @@ public interface Renderer {
/**
* Tells the renderer to render a particular page. A renderer typically
- * reponds by packing up the current page and writing it immediately to the
+ * responds by packing up the current page and writing it immediately to the
* output device.
*
* @param page The page to be rendered
diff --git a/src/java/org/apache/fop/render/RendererEventProducer.java b/src/java/org/apache/fop/render/RendererEventProducer.java
index c61e4a8ee..87b01b1cc 100644
--- a/src/java/org/apache/fop/render/RendererEventProducer.java
+++ b/src/java/org/apache/fop/render/RendererEventProducer.java
@@ -30,7 +30,10 @@ import org.apache.fop.events.EventProducer;
public interface RendererEventProducer extends EventProducer {
/** Provider class for the event producer. */
- class Provider {
+ final class Provider {
+
+ private Provider() {
+ }
/**
* Returns an event producer.
diff --git a/src/java/org/apache/fop/render/XMLHandlerConfigurator.java b/src/java/org/apache/fop/render/XMLHandlerConfigurator.java
index fb2420572..b93d4003a 100644
--- a/src/java/org/apache/fop/render/XMLHandlerConfigurator.java
+++ b/src/java/org/apache/fop/render/XMLHandlerConfigurator.java
@@ -32,7 +32,7 @@ import org.apache.fop.apps.FOUserAgent;
public class XMLHandlerConfigurator extends AbstractRendererConfigurator {
/** logger instance */
- protected static Log log = LogFactory.getLog(XMLHandlerConfigurator.class);
+ protected static final Log log = LogFactory.getLog(XMLHandlerConfigurator.class);
/**
* Default constructor
diff --git a/src/java/org/apache/fop/render/XMLHandlerRegistry.java b/src/java/org/apache/fop/render/XMLHandlerRegistry.java
index 81d9fcc93..cad09bff9 100644
--- a/src/java/org/apache/fop/render/XMLHandlerRegistry.java
+++ b/src/java/org/apache/fop/render/XMLHandlerRegistry.java
@@ -39,7 +39,8 @@ public class XMLHandlerRegistry {
private static Log log = LogFactory.getLog(XMLHandlerRegistry.class);
/** Map containing XML handlers for various document types */
- private Map handlers = new java.util.HashMap();
+ private Map<String, List<XMLHandler>> handlers
+ = new java.util.HashMap<String, List<XMLHandler>>();
/**
* Default constructor.
@@ -98,11 +99,10 @@ public class XMLHandlerRegistry {
* @param ns Namespace URI
* @param handler XMLHandler to use
*/
- private void addXMLHandler(String ns,
- XMLHandler handler) {
- List lst = (List)handlers.get(ns);
+ private void addXMLHandler(String ns, XMLHandler handler) {
+ List<XMLHandler> lst = handlers.get(ns);
if (lst == null) {
- lst = new java.util.ArrayList();
+ lst = new java.util.ArrayList<XMLHandler>();
handlers.put(ns, lst);
}
lst.add(handler);
@@ -118,21 +118,21 @@ public class XMLHandlerRegistry {
public XMLHandler getXMLHandler(Renderer renderer, String ns) {
XMLHandler handler;
- List lst = (List)handlers.get(ns);
+ List<XMLHandler> lst = handlers.get(ns);
handler = getXMLHandler(renderer, lst);
if (handler == null) {
- lst = (List)handlers.get(XMLHandler.HANDLE_ALL);
+ lst = handlers.get(XMLHandler.HANDLE_ALL);
handler = getXMLHandler(renderer, lst);
}
return handler;
}
- private XMLHandler getXMLHandler(Renderer renderer, List lst) {
+ private XMLHandler getXMLHandler(Renderer renderer, List<XMLHandler> lst) {
XMLHandler handler;
if (lst != null) {
for (int i = 0, c = lst.size(); i < c; i++) {
//TODO Maybe add priorities later
- handler = (XMLHandler)lst.get(i);
+ handler = lst.get(i);
if (handler.supportsRenderer(renderer)) {
return handler;
}
@@ -147,7 +147,7 @@ public class XMLHandlerRegistry {
*/
private void discoverXMLHandlers() {
// add mappings from available services
- Iterator providers = Service.providers(XMLHandler.class);
+ Iterator<Object> providers = Service.providers(XMLHandler.class);
if (providers != null) {
while (providers.hasNext()) {
XMLHandler handler = (XMLHandler)providers.next();
diff --git a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
index 21d4faf56..c37e0c37c 100644
--- a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
+++ b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
@@ -47,6 +47,7 @@ import org.apache.fop.render.afp.extensions.AFPElementMapping;
import org.apache.fop.render.afp.extensions.AFPIncludeFormMap;
import org.apache.fop.render.afp.extensions.AFPInvokeMediumMap;
import org.apache.fop.render.afp.extensions.AFPPageOverlay;
+import org.apache.fop.render.afp.extensions.AFPPageSegmentElement;
import org.apache.fop.render.afp.extensions.AFPPageSetup;
import org.apache.fop.render.intermediate.AbstractBinaryWritingIFDocumentHandler;
import org.apache.fop.render.intermediate.IFDocumentHandler;
@@ -76,8 +77,8 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
private DataStream dataStream;
/** the map of page segments */
- private Map/*<String,String>*/pageSegmentMap
- = new java.util.HashMap/*<String,String>*/();
+ private Map/*<String,PageSegmentDescriptor>*/pageSegmentMap
+ = new java.util.HashMap/*<String,PageSegmentDescriptor>*/();
/** Medium Map referenced on previous page **/
private String lastMediumMap;
@@ -213,7 +214,6 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
throws IFException {
this.location = LOC_ELSEWHERE;
paintingState.clear();
- pageSegmentMap.clear();
AffineTransform baseTransform = getBaseTransform();
paintingState.concatenate(baseTransform);
@@ -288,9 +288,12 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
null);
}
if (AFPElementMapping.INCLUDE_PAGE_SEGMENT.equals(element)) {
- String name = aps.getName();
- String source = aps.getValue();
- pageSegmentMap.put(source, name);
+ AFPPageSegmentElement.AFPPageSegmentSetup apse
+ = (AFPPageSegmentElement.AFPPageSegmentSetup)aps;
+ String name = apse.getName();
+ String source = apse.getValue();
+ String uri = apse.getResourceSrc();
+ pageSegmentMap.put(source, new PageSegmentDescriptor(name, uri));
} else if (AFPElementMapping.NO_OPERATION.equals(element)) {
String content = aps.getContent();
if (content != null) {
@@ -392,13 +395,13 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
}
/**
- * Returns the page segment name for a given URI if it actually represents a page segment.
+ * Returns the page segment descriptor for a given URI if it actually represents a page segment.
* Otherwise, it just returns null.
* @param uri the URI that identifies the page segment
- * @return the page segment name or null if there's no page segment for the given URI
+ * @return the page segment descriptor or null if there's no page segment for the given URI
*/
- String getPageSegmentNameFor(String uri) {
- return (String)pageSegmentMap.get(uri);
+ PageSegmentDescriptor getPageSegmentNameFor(String uri) {
+ return (PageSegmentDescriptor)pageSegmentMap.get(uri);
}
}
diff --git a/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java b/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java
index 235218cfc..a03aaf816 100644
--- a/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java
+++ b/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java
@@ -35,7 +35,7 @@ import org.apache.fop.render.afp.extensions.AFPElementMapping;
* Parses any AFP foreign attributes
*/
public class AFPForeignAttributeReader {
- private static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp");
+ private static final Log LOG = LogFactory.getLog("org.apache.xmlgraphics.afp");
/** the resource-name attribute */
public static final QName RESOURCE_NAME = new QName(
@@ -94,7 +94,7 @@ public class AFPForeignAttributeReader {
= (String)foreignAttributes.get(RESOURCE_GROUP_FILE);
if (resourceGroupFile == null) {
String msg = RESOURCE_GROUP_FILE + " not specified";
- log.error(msg);
+ LOG.error(msg);
throw new UnsupportedOperationException(msg);
}
File resourceExternalGroupFile = new File(resourceGroupFile);
@@ -106,20 +106,20 @@ public class AFPForeignAttributeReader {
} catch (SecurityException ex) {
String msg = "unable to gain write access to external resource file: "
+ resourceGroupFile;
- log.error(msg);
+ LOG.error(msg);
}
try {
boolean exists = resourceExternalGroupFile.exists();
if (exists) {
- log.warn("overwriting external resource file: "
+ LOG.warn("overwriting external resource file: "
+ resourceGroupFile);
}
resourceLevel.setExternalFilePath(resourceGroupFile);
} catch (SecurityException ex) {
String msg = "unable to gain read access to external resource file: "
+ resourceGroupFile;
- log.error(msg);
+ LOG.error(msg);
}
}
}
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandler.java b/src/java/org/apache/fop/render/afp/AFPImageHandler.java
index 4a985db00..244263213 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandler.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandler.java
@@ -19,10 +19,7 @@
package org.apache.fop.render.afp;
-import java.awt.Point;
import java.awt.Rectangle;
-import java.awt.geom.Rectangle2D;
-import java.io.IOException;
import java.util.Map;
import org.apache.fop.afp.AFPDataObjectInfo;
@@ -44,44 +41,6 @@ public abstract class AFPImageHandler implements ImageHandlerBase {
= new AFPForeignAttributeReader();
/**
- * Generates an intermediate AFPDataObjectInfo that is later used to construct
- * the appropriate data object in the AFP DataStream.
- *
- * @param rendererImageInfo the renderer image info
- * @return a data object info object
- * @throws IOException thrown if an I/O exception of some sort has occurred.
- */
- public AFPDataObjectInfo generateDataObjectInfo(
- AFPRendererImageInfo rendererImageInfo) throws IOException {
- AFPDataObjectInfo dataObjectInfo = createDataObjectInfo();
-
- // set resource information
- setResourceInformation(dataObjectInfo,
- rendererImageInfo.getURI(),
- rendererImageInfo.getForeignAttributes());
-
-
- Point origin = rendererImageInfo.getOrigin();
- Rectangle2D position = rendererImageInfo.getPosition();
- int srcX = Math.round(origin.x + (float)position.getX());
- int srcY = Math.round(origin.y + (float)position.getY());
- Rectangle targetRect = new Rectangle(
- srcX,
- srcY,
- (int)Math.round(position.getWidth()),
- (int)Math.round(position.getHeight()));
-
- AFPRendererContext rendererContext
- = (AFPRendererContext)rendererImageInfo.getRendererContext();
- AFPInfo afpInfo = rendererContext.getInfo();
- AFPPaintingState paintingState = afpInfo.getPaintingState();
-
- dataObjectInfo.setObjectAreaInfo(createObjectAreaInfo(paintingState, targetRect));
-
- return dataObjectInfo;
- }
-
- /**
* Sets resource information on the data object info.
* @param dataObjectInfo the data object info instance
* @param uri the image's URI (or null if no URI is available)
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
index aaaecf2ea..07b712ceb 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
@@ -49,47 +49,6 @@ public class AFPImageHandlerGraphics2D extends AFPImageHandler implements ImageH
ImageFlavor.GRAPHICS2D
};
- /** {@inheritDoc} */
- public AFPDataObjectInfo generateDataObjectInfo(
- AFPRendererImageInfo rendererImageInfo) throws IOException {
-
- AFPRendererContext rendererContext
- = (AFPRendererContext)rendererImageInfo.getRendererContext();
- AFPInfo afpInfo = rendererContext.getInfo();
- ImageGraphics2D imageG2D = (ImageGraphics2D)rendererImageInfo.getImage();
- Graphics2DImagePainter painter = imageG2D.getGraphics2DImagePainter();
-
- if (afpInfo.paintAsBitmap()) {
- int x = afpInfo.getX();
- int y = afpInfo.getY();
- int width = afpInfo.getWidth();
- int height = afpInfo.getHeight();
- AFPPaintingState paintingState = afpInfo.getPaintingState();
- AFPGraphics2DAdapter g2dAdapter = new AFPGraphics2DAdapter(paintingState);
- g2dAdapter.paintImage(painter, rendererContext, x, y, width, height);
- return null;
- } else {
- AFPGraphicsObjectInfo graphicsObjectInfo
- = (AFPGraphicsObjectInfo)super.generateDataObjectInfo(rendererImageInfo);
-
- setDefaultResourceLevel(graphicsObjectInfo, afpInfo.getResourceManager());
-
- // set mime type (unsupported by MOD:CA registry)
- graphicsObjectInfo.setMimeType(MimeConstants.MIME_AFP_GOCA);
-
- // set g2d
- boolean textAsShapes = false;
- AFPGraphics2D g2d = afpInfo.createGraphics2D(textAsShapes);
-
- graphicsObjectInfo.setGraphics2D(g2d);
-
- // set painter
- graphicsObjectInfo.setPainter(painter);
-
- return graphicsObjectInfo;
- }
- }
-
private void setDefaultResourceLevel(AFPGraphicsObjectInfo graphicsObjectInfo,
AFPResourceManager resourceManager) {
AFPResourceInfo resourceInfo = graphicsObjectInfo.getResourceInfo();
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
index cb7b23da2..ca0544542 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
@@ -66,29 +66,10 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler implements Ima
ImageFlavor.RENDERED_IMAGE
};
- /** {@inheritDoc} */
- public AFPDataObjectInfo generateDataObjectInfo(
- AFPRendererImageInfo rendererImageInfo) throws IOException {
- AFPImageObjectInfo imageObjectInfo
- = (AFPImageObjectInfo)super.generateDataObjectInfo(rendererImageInfo);
-
- AFPRendererContext rendererContext
- = (AFPRendererContext)rendererImageInfo.getRendererContext();
- AFPInfo afpInfo = rendererContext.getInfo();
-
- setDefaultResourceLevel(imageObjectInfo, afpInfo.getResourceManager());
-
- AFPPaintingState paintingState = afpInfo.getPaintingState();
- ImageRendered imageRendered = (ImageRendered) rendererImageInfo.img;
- Dimension targetSize = new Dimension(afpInfo.getWidth(), afpInfo.getHeight());
-
- updateDataObjectInfo(imageObjectInfo, paintingState, imageRendered, targetSize);
- return imageObjectInfo;
- }
-
- private AFPDataObjectInfo updateDataObjectInfo(AFPImageObjectInfo imageObjectInfo,
- AFPPaintingState paintingState, ImageRendered imageRendered, Dimension targetSize)
- throws IOException {
+ private AFPDataObjectInfo updateDataObjectInfo // CSOK: MethodLength
+ (AFPImageObjectInfo imageObjectInfo,
+ AFPPaintingState paintingState, ImageRendered imageRendered, Dimension targetSize)
+ throws IOException {
long start = System.currentTimeMillis();
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java
index 67c19843b..4e4e1de31 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java
@@ -65,7 +65,7 @@ public class AFPImageHandlerSVG implements ImageHandler {
BatikImageFlavors.SVG_DOM
};
- /** {@inheritDoc} */
+ /** @return a new AFP data object info instance */
protected AFPDataObjectInfo createDataObjectInfo() {
return new AFPGraphicsObjectInfo();
}
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerXML.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerXML.java
deleted file mode 100644
index 7ea1a7a10..000000000
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerXML.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.afp;
-
-import java.awt.geom.Rectangle2D;
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.fop.afp.AFPDataObjectInfo;
-import org.apache.fop.render.RendererContext;
-import org.apache.fop.render.RendererContextConstants;
-import org.apache.xmlgraphics.image.loader.ImageFlavor;
-import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
-import org.w3c.dom.Document;
-
-/**
- * PDFImageHandler implementation which handles XML-based images.
- */
-public class AFPImageHandlerXML extends AFPImageHandler {
-
- private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
- ImageFlavor.XML_DOM,
- };
-
- /** {@inheritDoc} */
- public AFPDataObjectInfo generateDataObjectInfo(AFPRendererImageInfo rendererImageInfo)
- throws IOException {
- RendererContext rendererContext = rendererImageInfo.getRendererContext();
- AFPRenderer renderer = (AFPRenderer)rendererContext.getRenderer();
- ImageXMLDOM imgXML = (ImageXMLDOM)rendererImageInfo.getImage();
- Document doc = imgXML.getDocument();
- String ns = imgXML.getRootNamespace();
- Map foreignAttributes = (Map)rendererContext.getProperty(
- RendererContextConstants.FOREIGN_ATTRIBUTES);
- Rectangle2D pos = rendererImageInfo.getPosition();
- renderer.renderDocument(doc, ns, pos, foreignAttributes);
- return null;
- }
-
- /** {@inheritDoc} */
- public int getPriority() {
- return 400;
- }
-
- /** {@inheritDoc} */
- public Class getSupportedImageClass() {
- return ImageXMLDOM.class;
- }
-
- /** {@inheritDoc} */
- public ImageFlavor[] getSupportedImageFlavors() {
- return FLAVORS;
- }
-
- /** {@inheritDoc} */
- protected AFPDataObjectInfo createDataObjectInfo() {
- return null;
- }
-
-}
diff --git a/src/java/org/apache/fop/render/afp/AFPInfo.java b/src/java/org/apache/fop/render/afp/AFPInfo.java
index fb1ec87a8..53a1aa046 100644
--- a/src/java/org/apache/fop/render/afp/AFPInfo.java
+++ b/src/java/org/apache/fop/render/afp/AFPInfo.java
@@ -256,7 +256,8 @@ public final class AFPInfo {
public boolean strokeText() {
boolean strokeText = false;
if (handlerConfiguration != null) {
- strokeText = handlerConfiguration.getChild("stroke-text", true).getValueAsBoolean(strokeText);
+ strokeText
+ = handlerConfiguration.getChild("stroke-text", true).getValueAsBoolean(strokeText);
}
return strokeText;
}
@@ -286,8 +287,9 @@ public final class AFPInfo {
* @return a newly created AFPGraphics2D
*/
public AFPGraphics2D createGraphics2D(boolean textAsShapes) {
- AFPGraphics2D g2d = new AFPGraphics2D(
- textAsShapes, paintingState, resourceManager, resourceInfo, fontInfo);
+ AFPGraphics2D g2d
+ = new AFPGraphics2D
+ (textAsShapes, paintingState, resourceManager, resourceInfo, fontInfo);
g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
return g2d;
}
diff --git a/src/java/org/apache/fop/render/afp/AFPPainter.java b/src/java/org/apache/fop/render/afp/AFPPainter.java
index 22a5e0a58..28ca6c67f 100644
--- a/src/java/org/apache/fop/render/afp/AFPPainter.java
+++ b/src/java/org/apache/fop/render/afp/AFPPainter.java
@@ -26,13 +26,10 @@ import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Map;
-import org.w3c.dom.Document;
-
-import org.apache.xmlgraphics.image.loader.ImageProcessingHints;
-import org.apache.xmlgraphics.image.loader.ImageSessionContext;
-
import org.apache.fop.afp.AFPBorderPainter;
import org.apache.fop.afp.AFPPaintingState;
import org.apache.fop.afp.AFPUnitConverter;
@@ -48,9 +45,12 @@ import org.apache.fop.afp.modca.AbstractPageObject;
import org.apache.fop.afp.modca.PresentationTextObject;
import org.apache.fop.afp.ptoca.PtocaBuilder;
import org.apache.fop.afp.ptoca.PtocaProducer;
+import org.apache.fop.afp.util.DefaultFOPResourceAccessor;
+import org.apache.fop.afp.util.ResourceAccessor;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontTriplet;
+import org.apache.fop.fonts.Typeface;
import org.apache.fop.render.RenderingContext;
import org.apache.fop.render.intermediate.AbstractIFPainter;
import org.apache.fop.render.intermediate.BorderPainter;
@@ -60,6 +60,9 @@ import org.apache.fop.render.intermediate.IFState;
import org.apache.fop.traits.BorderProps;
import org.apache.fop.traits.RuleStyle;
import org.apache.fop.util.CharUtilities;
+import org.apache.xmlgraphics.image.loader.ImageProcessingHints;
+import org.apache.xmlgraphics.image.loader.ImageSessionContext;
+import org.w3c.dom.Document;
/**
* IFPainter implementation that produces AFP (MO:DCA).
@@ -72,12 +75,12 @@ public class AFPPainter extends AbstractIFPainter {
private static final int X = 0;
private static final int Y = 1;
- private AFPDocumentHandler documentHandler;
+ private final AFPDocumentHandler documentHandler;
/** the border painter */
- private AFPBorderPainterAdapter borderPainter;
+ private final AFPBorderPainterAdapter borderPainter;
/** the rectangle painter */
- private AbstractAFPPainter rectanglePainter;
+ private final AbstractAFPPainter rectanglePainter;
/** unit converter */
private final AFPUnitConverter unitConv;
@@ -97,6 +100,7 @@ public class AFPPainter extends AbstractIFPainter {
}
/** {@inheritDoc} */
+ @Override
protected IFContext getContext() {
return this.documentHandler.getContext();
}
@@ -161,6 +165,7 @@ public class AFPPainter extends AbstractIFPainter {
}
/** {@inheritDoc} */
+ @Override
protected Map createDefaultImageProcessingHints(ImageSessionContext sessionContext) {
Map hints = super.createDefaultImageProcessingHints(sessionContext);
@@ -171,6 +176,7 @@ public class AFPPainter extends AbstractIFPainter {
}
/** {@inheritDoc} */
+ @Override
protected RenderingContext createRenderingContext() {
AFPRenderingContext psContext = new AFPRenderingContext(
getUserAgent(),
@@ -183,14 +189,34 @@ public class AFPPainter extends AbstractIFPainter {
/** {@inheritDoc} */
public void drawImage(String uri, Rectangle rect) throws IFException {
- String name = documentHandler.getPageSegmentNameFor(uri);
- if (name != null) {
+ PageSegmentDescriptor pageSegment = documentHandler.getPageSegmentNameFor(uri);
+
+ if (pageSegment != null) {
float[] srcPts = {rect.x, rect.y};
int[] coords = unitConv.mpts2units(srcPts);
int width = Math.round(unitConv.mpt2units(rect.width));
int height = Math.round(unitConv.mpt2units(rect.height));
- getDataStream().createIncludePageSegment(name, coords[X], coords[Y], width, height);
+ getDataStream().createIncludePageSegment(pageSegment.getName(),
+ coords[X], coords[Y], width, height);
+
+ //Do we need to embed an external page segment?
+ if (pageSegment.getURI() != null) {
+ ResourceAccessor accessor = new DefaultFOPResourceAccessor (
+ documentHandler.getUserAgent(), null, null);
+ try {
+ URI resourceUri = new URI(pageSegment.getURI());
+ documentHandler.getResourceManager().createIncludedResourceFromExternal(
+ pageSegment.getName(), resourceUri, accessor);
+
+ } catch (URISyntaxException urie) {
+ throw new IFException("Could not handle resource url"
+ + pageSegment.getURI(), urie);
+ } catch (IOException ioe) {
+ throw new IFException("Could not handle resource" + pageSegment.getURI(), ioe);
+ }
+ }
+
} else {
drawImageUsingURI(uri, rect);
}
@@ -232,6 +258,7 @@ public class AFPPainter extends AbstractIFPainter {
}
/** {@inheritDoc} */
+ @Override
public void drawBorderRect(Rectangle rect, BorderProps before, BorderProps after,
BorderProps start, BorderProps end) throws IFException {
if (before != null || after != null || start != null || end != null) {
@@ -247,32 +274,38 @@ public class AFPPainter extends AbstractIFPainter {
//and this one. Not done for now to avoid a lot of re-implementation and code duplication.
private static class AFPBorderPainterAdapter extends BorderPainter {
- private AFPBorderPainter delegate;
+ private final AFPBorderPainter delegate;
public AFPBorderPainterAdapter(AFPBorderPainter borderPainter) {
this.delegate = borderPainter;
}
+ @Override
protected void clip() throws IOException {
//not supported by AFP
}
+ @Override
protected void closePath() throws IOException {
//used for clipping only, so not implemented
}
+ @Override
protected void moveTo(int x, int y) throws IOException {
//used for clipping only, so not implemented
}
+ @Override
protected void lineTo(int x, int y) throws IOException {
//used for clipping only, so not implemented
}
+ @Override
protected void saveGraphicsState() throws IOException {
//used for clipping only, so not implemented
}
+ @Override
protected void restoreGraphicsState() throws IOException {
//used for clipping only, so not implemented
}
@@ -281,7 +314,9 @@ public class AFPPainter extends AbstractIFPainter {
return mpt / 1000f;
}
- protected void drawBorderLine(int x1, int y1, int x2, int y2, boolean horz,
+ @Override
+ protected void drawBorderLine( // CSOK: ParameterNumber
+ int x1, int y1, int x2, int y2, boolean horz,
boolean startOrBefore, int style, Color color) throws IOException {
BorderPaintingInfo borderPaintInfo = new BorderPaintingInfo(
toPoints(x1), toPoints(y1), toPoints(x2), toPoints(y2),
@@ -289,6 +324,7 @@ public class AFPPainter extends AbstractIFPainter {
delegate.paint(borderPaintInfo);
}
+ @Override
public void drawLine(Point start, Point end, int width, Color color, RuleStyle style)
throws IOException {
if (start.y != end.y) {
@@ -306,6 +342,7 @@ public class AFPPainter extends AbstractIFPainter {
}
/** {@inheritDoc} */
+ @Override
public void drawLine(Point start, Point end, int width, Color color, RuleStyle style)
throws IFException {
try {
@@ -316,8 +353,8 @@ public class AFPPainter extends AbstractIFPainter {
}
/** {@inheritDoc} */
- public void drawText(int x, int y,
- final int letterSpacing, final int wordSpacing, final int[] dx,
+ public void drawText( // CSOK: MethodLength
+ int x, int y, final int letterSpacing, final int wordSpacing, final int[] dx,
final String text) throws IFException {
final int fontSize = this.state.getFontSize();
getPaintingState().setFontSize(fontSize);
@@ -332,7 +369,7 @@ public class AFPPainter extends AbstractIFPainter {
}
// register font as necessary
- Map/*<String,FontMetrics>*/ fontMetricMap = documentHandler.getFontInfo().getFonts();
+ Map<String, Typeface> fontMetricMap = documentHandler.getFontInfo().getFonts();
final AFPFont afpFont = (AFPFont)fontMetricMap.get(fontKey);
final Font font = getFontInfo().getFontInstance(triplet, fontSize);
AFPPageFonts pageFonts = getPaintingState().getPageFonts();
diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java
deleted file mode 100644
index 1f373023c..000000000
--- a/src/java/org/apache/fop/render/afp/AFPRenderer.java
+++ /dev/null
@@ -1,920 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.afp;
-
-import java.awt.Color;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.RenderedImage;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.xmlgraphics.image.loader.ImageException;
-import org.apache.xmlgraphics.image.loader.ImageFlavor;
-import org.apache.xmlgraphics.image.loader.ImageInfo;
-import org.apache.xmlgraphics.image.loader.ImageManager;
-import org.apache.xmlgraphics.image.loader.ImageSessionContext;
-import org.apache.xmlgraphics.image.loader.util.ImageUtil;
-import org.apache.xmlgraphics.ps.ImageEncodingHelper;
-
-import org.apache.fop.ResourceEventProducer;
-import org.apache.fop.afp.AFPBorderPainter;
-import org.apache.fop.afp.AFPDataObjectInfo;
-import org.apache.fop.afp.AFPDitheredRectanglePainter;
-import org.apache.fop.afp.AFPEventProducer;
-import org.apache.fop.afp.AFPPaintingState;
-import org.apache.fop.afp.AFPRectanglePainter;
-import org.apache.fop.afp.AFPResourceLevelDefaults;
-import org.apache.fop.afp.AFPResourceManager;
-import org.apache.fop.afp.AFPTextDataInfo;
-import org.apache.fop.afp.AFPUnitConverter;
-import org.apache.fop.afp.AbstractAFPPainter;
-import org.apache.fop.afp.BorderPaintingInfo;
-import org.apache.fop.afp.DataStream;
-import org.apache.fop.afp.RectanglePaintingInfo;
-import org.apache.fop.afp.fonts.AFPFont;
-import org.apache.fop.afp.fonts.AFPFontAttributes;
-import org.apache.fop.afp.fonts.AFPFontCollection;
-import org.apache.fop.afp.fonts.AFPPageFonts;
-import org.apache.fop.afp.fonts.CharacterSet;
-import org.apache.fop.afp.modca.PageObject;
-import org.apache.fop.afp.modca.ResourceObject;
-import org.apache.fop.afp.util.DefaultFOPResourceAccessor;
-import org.apache.fop.afp.util.ResourceAccessor;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.area.CTM;
-import org.apache.fop.area.OffDocumentExtensionAttachment;
-import org.apache.fop.area.OffDocumentItem;
-import org.apache.fop.area.PageSequence;
-import org.apache.fop.area.PageViewport;
-import org.apache.fop.area.Trait;
-import org.apache.fop.area.inline.Image;
-import org.apache.fop.area.inline.Leader;
-import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.datatypes.URISpecification;
-import org.apache.fop.fo.extensions.ExtensionAttachment;
-import org.apache.fop.fonts.Font;
-import org.apache.fop.fonts.FontCollection;
-import org.apache.fop.fonts.FontInfo;
-import org.apache.fop.fonts.FontManager;
-import org.apache.fop.render.AbstractPathOrientedRenderer;
-import org.apache.fop.render.Graphics2DAdapter;
-import org.apache.fop.render.RendererContext;
-import org.apache.fop.render.afp.extensions.AFPElementMapping;
-import org.apache.fop.render.afp.extensions.AFPExtensionAttachment;
-import org.apache.fop.render.afp.extensions.AFPIncludeFormMap;
-import org.apache.fop.render.afp.extensions.AFPInvokeMediumMap;
-import org.apache.fop.render.afp.extensions.AFPPageOverlay;
-import org.apache.fop.render.afp.extensions.AFPPageSetup;
-
-/**
- * This is an implementation of a FOP Renderer that renders areas to AFP.
- * <p>
- * A renderer is primarily designed to convert a given area tree into the output
- * document format. It should be able to produce pages and fill the pages with
- * the text and graphical content. Usually the output is sent to an output
- * stream. Some output formats may support extra information that is not
- * available from the area tree or depends on the destination of the document.
- * Each renderer is given an area tree to render to its output format. The area
- * tree is simply a representation of the pages and the placement of text and
- * graphical objects on those pages.
- * </p>
- * <p>
- * The renderer will be given each page as it is ready and an output stream to
- * write the data out. All pages are supplied in the order they appear in the
- * document. In order to save memory it is possible to render the pages out of
- * order. Any page that is not ready to be rendered is setup by the renderer
- * first so that it can reserve a space or reference for when the page is ready
- * to be rendered.The renderer is responsible for managing the output format and
- * associated data and flow.
- * </p>
- * <p>
- * Each renderer is totally responsible for its output format. Because font
- * metrics (and therefore layout) are obtained in two different ways depending
- * on the renderer, the renderer actually sets up the fonts being used. The font
- * metrics are used during the layout process to determine the size of
- * characters.
- * </p>
- * <p>
- * The render context is used by handlers. It contains information about the
- * current state of the renderer, such as the page, the position, and any other
- * miscellaneous objects that are required to draw into the page.
- * </p>
- * <p>
- * A renderer is created by implementing the Renderer interface. However, the
- * AbstractRenderer does most of what is needed, including iterating through the
- * tree parts, so it is this that is extended. This means that this object only
- * need to implement the basic functionality such as text, images, and lines.
- * AbstractRenderer's methods can easily be overridden to handle things in a
- * different way or do some extra processing.
- * </p>
- * <p>
- * The relevant AreaTree structures that will need to be rendered are Page,
- * Viewport, Region, Span, Block, Line, Inline. A renderer implementation
- * renders each individual page, clips and aligns child areas to a viewport,
- * handle all types of inline area, text, image etc and draws various lines and
- * rectangles.
- * </p>
- *
- * Note: There are specific extensions that have been added to the FO. They are
- * specific to their location within the FO and have to be processed accordingly
- * (ie. at the start or end of the page).
- *
- */
-public class AFPRenderer extends AbstractPathOrientedRenderer implements AFPCustomizable {
-
- private static final int X = 0;
- private static final int Y = 1;
-
- /** the resource manager */
- private AFPResourceManager resourceManager;
-
- /** the painting state */
- private final AFPPaintingState paintingState;
-
- /** unit converter */
- private final AFPUnitConverter unitConv;
-
- /** the line painter */
- private AFPBorderPainter borderPainter;
-
- /** the map of page segments */
- private final Map/*<String,String>*/pageSegmentMap
- = new java.util.HashMap/*<String,String>*/();
-
- /** the map of saved incomplete pages */
- private final Map pages = new java.util.HashMap/*<PageViewport,PageObject>*/();
-
- /** the AFP datastream */
- private DataStream dataStream;
-
- /** the image handler registry */
- private final AFPImageHandlerRegistry imageHandlerRegistry;
-
- private AbstractAFPPainter rectanglePainter;
-
- /** the shading mode for filled rectangles */
- private AFPShadingMode shadingMode = AFPShadingMode.COLOR;
-
- /** medium map referenced used on previous page **/
- private String lastMediumMap;
-
- /**
- * Constructor for AFPRenderer.
- */
- public AFPRenderer() {
- super();
- this.imageHandlerRegistry = new AFPImageHandlerRegistry();
- this.resourceManager = new AFPResourceManager();
- this.paintingState = new AFPPaintingState();
- this.unitConv = paintingState.getUnitConverter();
- }
-
- /** {@inheritDoc} */
- public void setupFontInfo(FontInfo inFontInfo) {
- this.fontInfo = inFontInfo;
- FontManager fontManager = userAgent.getFactory().getFontManager();
- FontCollection[] fontCollections = new FontCollection[] {
- new AFPFontCollection(userAgent.getEventBroadcaster(), getFontList())
- };
- fontManager.setup(getFontInfo(), fontCollections);
- }
-
- /** {@inheritDoc} */
- public void setUserAgent(FOUserAgent agent) {
- super.setUserAgent(agent);
- }
-
- /** {@inheritDoc} */
- public void startRenderer(OutputStream outputStream) throws IOException {
- paintingState.setColor(Color.WHITE);
-
- this.dataStream = resourceManager.createDataStream(paintingState, outputStream);
- this.borderPainter = new AFPBorderPainter(paintingState, dataStream);
- this.rectanglePainter = createRectanglePainter();
-
- dataStream.startDocument();
- }
-
- AbstractAFPPainter createRectanglePainter() {
- if (AFPShadingMode.DITHERED.equals(this.shadingMode)) {
- return new AFPDitheredRectanglePainter(
- this.paintingState, this.dataStream, this.resourceManager);
- } else {
- return new AFPRectanglePainter(
- this.paintingState, this.dataStream);
- }
- }
-
- /** {@inheritDoc} */
- public void stopRenderer() throws IOException {
- dataStream.endDocument();
- resourceManager.writeToStream();
- resourceManager = null;
- }
-
- /** {@inheritDoc} */
- public void startPageSequence(PageSequence pageSequence) {
- super.startPageSequence(pageSequence);
- try {
- dataStream.startPageGroup();
- } catch (IOException e) {
- log.error(e.getMessage());
- }
- if (pageSequence.hasExtensionAttachments()) {
- for (Iterator iter = pageSequence.getExtensionAttachments().iterator();
- iter.hasNext();) {
- ExtensionAttachment attachment = (ExtensionAttachment)iter.next();
- if (attachment instanceof AFPInvokeMediumMap) {
- AFPInvokeMediumMap imm = (AFPInvokeMediumMap)attachment;
- String mediumMap = imm.getName();
- if (mediumMap != null) {
- dataStream.createInvokeMediumMap(mediumMap);
- }
- } else if (attachment instanceof AFPPageSetup) {
- AFPPageSetup aps = (AFPPageSetup)attachment;
- String name = aps.getName();
- String value = aps.getValue();
- dataStream.createTagLogicalElement(name, value);
- }
- }
- }
- }
-
- /** {@inheritDoc} */
- public boolean supportsOutOfOrder() {
- return false;
- }
-
- /** {@inheritDoc} */
- public void preparePage(PageViewport page) {
- int pageRotation = paintingState.getPageRotation();
- int pageWidth = paintingState.getPageWidth();
- int pageHeight = paintingState.getPageHeight();
- int resolution = paintingState.getResolution();
- dataStream.startPage(pageWidth, pageHeight, pageRotation,
- resolution, resolution);
-
- renderPageObjectExtensions(page);
-
- PageObject currentPage = dataStream.savePage();
- pages.put(page, currentPage);
- }
-
- /** {@inheritDoc} */
- public void processOffDocumentItem(OffDocumentItem odi) {
- if (odi instanceof OffDocumentExtensionAttachment) {
- ExtensionAttachment attachment = ((OffDocumentExtensionAttachment)odi).getAttachment();
- if (attachment != null) {
- if (AFPExtensionAttachment.CATEGORY.equals(attachment.getCategory())) {
- if (attachment instanceof AFPIncludeFormMap) {
- handleIncludeFormMap((AFPIncludeFormMap)attachment);
- }
- }
- }
- }
- }
-
- private void handleIncludeFormMap(AFPIncludeFormMap formMap) {
- ResourceAccessor accessor = new DefaultFOPResourceAccessor(
- getUserAgent(), null, null);
- try {
- this.resourceManager.createIncludedResource(formMap.getName(),
- formMap.getSrc(), accessor,
- ResourceObject.TYPE_FORMDEF);
- } catch (IOException ioe) {
- AFPEventProducer eventProducer
- = AFPEventProducer.Provider.get(userAgent.getEventBroadcaster());
- eventProducer.resourceEmbeddingError(this, formMap.getName(), ioe);
- }
- }
-
- /** {@inheritDoc} */
- public Graphics2DAdapter getGraphics2DAdapter() {
- return new AFPGraphics2DAdapter(paintingState);
- }
-
- /** {@inheritDoc} */
- public void startVParea(CTM ctm, Rectangle2D clippingRect) {
- saveGraphicsState();
- if (ctm != null) {
- AffineTransform at = ctm.toAffineTransform();
- concatenateTransformationMatrix(at);
- }
- if (clippingRect != null) {
- clipRect((float)clippingRect.getX() / 1000f,
- (float)clippingRect.getY() / 1000f,
- (float)clippingRect.getWidth() / 1000f,
- (float)clippingRect.getHeight() / 1000f);
- }
- }
-
- /** {@inheritDoc} */
- public void endVParea() {
- restoreGraphicsState();
- }
-
- /** {@inheritDoc} */
- protected void concatenateTransformationMatrix(AffineTransform at) {
- if (!at.isIdentity()) {
- paintingState.concatenate(at);
- }
- }
-
- /**
- * Returns the base AFP transform
- *
- * @return the base AFP transform
- */
- private AffineTransform getBaseTransform() {
- AffineTransform baseTransform = new AffineTransform();
- double scale = unitConv.mpt2units(1);
- baseTransform.scale(scale, scale);
- return baseTransform;
- }
-
- /** {@inheritDoc} */
- public void renderPage(PageViewport pageViewport) throws IOException, FOPException {
- paintingState.clear();
-
- Rectangle2D bounds = pageViewport.getViewArea();
-
- AffineTransform baseTransform = getBaseTransform();
- paintingState.concatenate(baseTransform);
-
- if (pages.containsKey(pageViewport)) {
- dataStream.restorePage(
- (PageObject)pages.remove(pageViewport));
- } else {
- int pageWidth
- = Math.round(unitConv.mpt2units((float)bounds.getWidth()));
- paintingState.setPageWidth(pageWidth);
-
- int pageHeight
- = Math.round(unitConv.mpt2units((float)bounds.getHeight()));
- paintingState.setPageHeight(pageHeight);
-
- int pageRotation = paintingState.getPageRotation();
-
- int resolution = paintingState.getResolution();
-
- // IMM should occur before BPG
- renderInvokeMediumMap(pageViewport);
-
- dataStream.startPage(pageWidth, pageHeight, pageRotation,
- resolution, resolution);
-
- renderPageObjectExtensions(pageViewport);
- }
-
- super.renderPage(pageViewport);
-
- AFPPageFonts pageFonts = paintingState.getPageFonts();
- if (pageFonts != null && !pageFonts.isEmpty()) {
- dataStream.addFontsToCurrentPage(pageFonts);
- }
-
- dataStream.endPage();
- }
-
- /** {@inheritDoc} */
- public void drawBorderLine(float x1, float y1, float x2, float y2,
- boolean horz, boolean startOrBefore, int style, Color col) {
- BorderPaintingInfo borderPaintInfo = new BorderPaintingInfo(x1, y1, x2, y2, horz, style, col);
- borderPainter.paint(borderPaintInfo);
- }
-
- /** {@inheritDoc} */
- public void fillRect(float x, float y, float width, float height) {
- RectanglePaintingInfo rectanglePaintInfo = new RectanglePaintingInfo(x, y, width, height);
- try {
- rectanglePainter.paint(rectanglePaintInfo);
- } catch (IOException ioe) {
- //TODO not ideal, but the AFPRenderer is legacy
- throw new RuntimeException("I/O error while painting a filled rectangle", ioe);
- }
- }
-
- /** {@inheritDoc} */
- protected RendererContext instantiateRendererContext() {
- return new AFPRendererContext(this, getMimeType());
- }
-
- /** {@inheritDoc} */
- protected RendererContext createRendererContext(int x, int y, int width,
- int height, Map foreignAttributes) {
- RendererContext context;
- context = super.createRendererContext(x, y, width, height,
- foreignAttributes);
- context.setProperty(AFPRendererContextConstants.AFP_FONT_INFO,
- this.fontInfo);
- context.setProperty(AFPRendererContextConstants.AFP_RESOURCE_MANAGER,
- this.resourceManager);
- context.setProperty(AFPRendererContextConstants.AFP_PAINTING_STATE, paintingState);
- return context;
- }
-
- private static final ImageFlavor[] NATIVE_FLAVORS = new ImageFlavor[] {
- ImageFlavor.XML_DOM,
- /*ImageFlavor.RAW_PNG, */ // PNG not natively supported in AFP
- ImageFlavor.RAW_JPEG, ImageFlavor.RAW_CCITTFAX, ImageFlavor.RAW_EPS,
- ImageFlavor.RAW_TIFF,
- ImageFlavor.GRAPHICS2D, ImageFlavor.BUFFERED_IMAGE, ImageFlavor.RENDERED_IMAGE };
-
- private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
- ImageFlavor.XML_DOM,
- ImageFlavor.GRAPHICS2D, ImageFlavor.BUFFERED_IMAGE, ImageFlavor.RENDERED_IMAGE };
-
- /** {@inheritDoc} */
- public void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) {
- uri = URISpecification.getURL(uri);
- paintingState.setImageUri(uri);
-
- Point origin = new Point(currentIPPosition, currentBPPosition);
- Rectangle posInt = new Rectangle(
- (int)Math.round(pos.getX()),
- (int)Math.round(pos.getY()),
- (int)Math.round(pos.getWidth()),
- (int)Math.round(pos.getHeight())
- );
- int x = origin.x + posInt.x;
- int y = origin.y + posInt.y;
-
- String name = (String)pageSegmentMap.get(uri);
- if (name != null) {
- float[] srcPts = {x, y, posInt.width, posInt.height};
- int[] coords = unitConv.mpts2units(srcPts);
- int width = Math.round(unitConv.mpt2units(posInt.width));
- int height = Math.round(unitConv.mpt2units(posInt.height));
- dataStream.createIncludePageSegment(name, coords[X], coords[Y], width, height);
- } else {
- ImageManager manager = userAgent.getFactory().getImageManager();
- ImageInfo info = null;
- try {
- ImageSessionContext sessionContext = userAgent
- .getImageSessionContext();
- info = manager.getImageInfo(uri, sessionContext);
-
- // Only now fully load/prepare the image
- Map hints = ImageUtil.getDefaultHints(sessionContext);
-
- boolean nativeImagesSupported = paintingState.isNativeImagesSupported();
- ImageFlavor[] flavors = nativeImagesSupported ? NATIVE_FLAVORS : FLAVORS;
-
- // Load image
- org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
- info, flavors, hints, sessionContext);
-
- // Handle image
- AFPImageHandler imageHandler
- = (AFPImageHandler)imageHandlerRegistry.getHandler(img);
- if (imageHandler != null) {
- RendererContext rendererContext = createRendererContext(
- x, y, posInt.width, posInt.height, foreignAttributes);
- AFPRendererImageInfo rendererImageInfo = new AFPRendererImageInfo(
- uri, pos, origin, info, img, rendererContext, foreignAttributes);
- AFPDataObjectInfo dataObjectInfo = null;
- try {
- dataObjectInfo = imageHandler.generateDataObjectInfo(rendererImageInfo);
- // Create image
- if (dataObjectInfo != null) {
- resourceManager.createObject(dataObjectInfo);
- }
- } catch (IOException ioe) {
- ResourceEventProducer eventProducer
- = ResourceEventProducer.Provider.get(userAgent.getEventBroadcaster());
- eventProducer.imageWritingError(this, ioe);
- throw ioe;
- }
- } else {
- throw new UnsupportedOperationException(
- "No AFPImageHandler available for image: "
- + info + " (" + img.getClass().getName() + ")");
- }
-
- } catch (ImageException ie) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider
- .get(userAgent.getEventBroadcaster());
- eventProducer.imageError(this, (info != null ? info.toString()
- : uri), ie, null);
- } catch (FileNotFoundException fe) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider
- .get(userAgent.getEventBroadcaster());
- eventProducer.imageNotFound(this, (info != null ? info.toString()
- : uri), fe, null);
- } catch (IOException ioe) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider
- .get(userAgent.getEventBroadcaster());
- eventProducer.imageIOError(this, (info != null ? info.toString()
- : uri), ioe, null);
- }
- }
- }
-
- /**
- * Writes a RenderedImage to an OutputStream as raw sRGB bitmaps.
- *
- * @param image
- * the RenderedImage
- * @param out
- * the OutputStream
- * @throws IOException
- * In case of an I/O error.
- * @deprecated use ImageEncodingHelper.encodeRenderedImageAsRGB(image, out)
- * directly instead
- */
- public static void writeImage(RenderedImage image, OutputStream out)
- throws IOException {
- ImageEncodingHelper.encodeRenderedImageAsRGB(image, out);
- }
-
- /** {@inheritDoc} */
- public void updateColor(Color col, boolean fill) {
- if (fill) {
- paintingState.setColor(col);
- }
- }
-
- /** {@inheritDoc} */
- public void restoreStateStackAfterBreakOut(List breakOutList) {
- log.debug("Block.FIXED --> restoring context after break-out");
- paintingState.saveAll(breakOutList);
- }
-
- /** {@inheritDoc} */
- protected List breakOutOfStateStack() {
- log.debug("Block.FIXED --> break out");
- return paintingState.restoreAll();
- }
-
- /** {@inheritDoc} */
- public void saveGraphicsState() {
- paintingState.save();
- }
-
- /** {@inheritDoc} */
- public void restoreGraphicsState() {
- paintingState.restore();
- }
-
- /** {@inheritDoc} */
- public void renderImage(Image image, Rectangle2D pos) {
- drawImage(image.getURL(), pos, image.getForeignAttributes());
- }
-
- /** {@inheritDoc} */
- public void renderText(TextArea text) {
- renderInlineAreaBackAndBorders(text);
-
- // set font size
- int fontSize = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue();
- paintingState.setFontSize(fontSize);
-
- // register font as necessary
- String internalFontName = getInternalFontNameForArea(text);
- Map/*<String,FontMetrics>*/ fontMetricMap = fontInfo.getFonts();
- AFPFont font = (AFPFont)fontMetricMap.get(internalFontName);
- AFPPageFonts pageFonts = paintingState.getPageFonts();
- AFPFontAttributes fontAttributes = pageFonts.registerFont(internalFontName, font, fontSize);
- Font fnt = getFontFromArea(text);
-
- if (font.isEmbeddable()) {
- CharacterSet charSet = font.getCharacterSet(fontSize);
- try {
- this.resourceManager.embedFont(font, charSet);
- } catch (IOException ioe) {
- AFPEventProducer eventProducer
- = AFPEventProducer.Provider.get(userAgent.getEventBroadcaster());
- eventProducer.resourceEmbeddingError(this, charSet.getName(), ioe);
- }
- }
-
- // create text data info
- AFPTextDataInfo textDataInfo = new AFPTextDataInfo();
-
- int fontReference = fontAttributes.getFontReference();
- textDataInfo.setFontReference(fontReference);
-
- int x = (currentIPPosition + text.getBorderAndPaddingWidthStart());
- int y = (currentBPPosition + text.getOffset() + text.getBaselineOffset());
-
- int[] coords = unitConv.mpts2units(new float[] {x, y} );
- textDataInfo.setX(coords[X]);
- textDataInfo.setY(coords[Y]);
-
- Color color = (Color) text.getTrait(Trait.COLOR);
- textDataInfo.setColor(color);
-
- int textWordSpaceAdjust = text.getTextWordSpaceAdjust();
- int textLetterSpaceAdjust = text.getTextLetterSpaceAdjust();
- int textWidth = font.getWidth(' ', fontSize) / 1000;
- textWidth = 0; //JM, the above is strange
- int variableSpaceCharacterIncrement
- = textWidth + textWordSpaceAdjust + textLetterSpaceAdjust;
-
- variableSpaceCharacterIncrement
- = Math.round(unitConv.mpt2units(variableSpaceCharacterIncrement));
- textDataInfo.setVariableSpaceCharacterIncrement(variableSpaceCharacterIncrement);
-
- int interCharacterAdjustment
- = Math.round(unitConv.mpt2units(textLetterSpaceAdjust));
- textDataInfo.setInterCharacterAdjustment(interCharacterAdjustment);
-
- CharacterSet charSet = font.getCharacterSet(fontSize);
- String encoding = charSet.getEncoding();
- textDataInfo.setEncoding(encoding);
-
- String textString = text.getText();
- textDataInfo.setString(textString);
-
- try {
- dataStream.createText(textDataInfo, textLetterSpaceAdjust, textWordSpaceAdjust, fnt, charSet);
- } catch (UnsupportedEncodingException e) {
- AFPEventProducer eventProducer
- = AFPEventProducer.Provider.get(userAgent.getEventBroadcaster());
- eventProducer.characterSetEncodingError(this, charSet.getName(), encoding);
- }
- // word.getOffset() = only height of text itself
- // currentBlockIPPosition: 0 for beginning of line; nonzero
- // where previous line area failed to take up entire allocated space
-
- super.renderText(text);
-
- renderTextDecoration(font, fontSize, text, y, x);
- }
-
- /**
- * Render leader area. This renders a leader area which is an area with a
- * rule.
- *
- * @param area
- * the leader area to render
- */
- public void renderLeader(Leader area) {
- renderInlineAreaBackAndBorders(area);
-
- int style = area.getRuleStyle();
- float startx = (currentIPPosition + area
- .getBorderAndPaddingWidthStart()) / 1000f;
- float starty = (currentBPPosition + area.getOffset()) / 1000f;
- float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart() + area
- .getIPD()) / 1000f;
- float ruleThickness = area.getRuleThickness() / 1000f;
- Color col = (Color) area.getTrait(Trait.COLOR);
-
- switch (style) {
- case EN_SOLID:
- case EN_DASHED:
- case EN_DOUBLE:
- case EN_DOTTED:
- case EN_GROOVE:
- case EN_RIDGE:
- drawBorderLine(startx, starty, endx, starty + ruleThickness, true,
- true, style, col);
- break;
- default:
- throw new UnsupportedOperationException("rule style not supported");
- }
- super.renderLeader(area);
- }
-
- /**
- * Get the MIME type of the renderer.
- *
- * @return The MIME type of the renderer
- */
- public String getMimeType() {
- return MimeConstants.MIME_AFP;
- }
-
- /**
- * checks for IMM Extension and renders if found and different
- * from previous page
- *
- * @param pageViewport the page object
- */
- private void renderInvokeMediumMap(PageViewport pageViewport) {
- if (pageViewport.getExtensionAttachments() != null
- && pageViewport.getExtensionAttachments().size() > 0) {
- Iterator it = pageViewport.getExtensionAttachments().iterator();
- while (it.hasNext()) {
- ExtensionAttachment attachment = (ExtensionAttachment) it.next();
- if (AFPExtensionAttachment.CATEGORY.equals(attachment.getCategory())) {
- AFPExtensionAttachment aea = (AFPExtensionAttachment)attachment;
- if (AFPElementMapping.INVOKE_MEDIUM_MAP.equals(aea.getElementName())) {
- AFPInvokeMediumMap imm = (AFPInvokeMediumMap)attachment;
- String mediumMap = imm.getName();
- if (mediumMap != null) {
- if (!mediumMap.equals(lastMediumMap)) {
- dataStream.createInvokeMediumMap(mediumMap);
- lastMediumMap = mediumMap;
- }
- }
- }
- }
- }
- }
- }
-
- /**
- * Method to render the page extension.
- * <p>
- *
- * @param pageViewport
- * the page object
- */
- private void renderPageObjectExtensions(PageViewport pageViewport) {
- pageSegmentMap.clear();
- if (pageViewport.getExtensionAttachments() != null
- && pageViewport.getExtensionAttachments().size() > 0) {
- // Extract all AFPPageSetup instances from the attachment list on
- // the s-p-m
- Iterator it = pageViewport.getExtensionAttachments().iterator();
- while (it.hasNext()) {
- ExtensionAttachment attachment = (ExtensionAttachment) it.next();
- if (AFPPageSetup.CATEGORY.equals(attachment.getCategory())) {
- if (attachment instanceof AFPPageSetup) {
- AFPPageSetup aps = (AFPPageSetup) attachment;
- String element = aps.getElementName();
- if (AFPElementMapping.INCLUDE_PAGE_SEGMENT
- .equals(element)) {
- String name = aps.getName();
- String source = aps.getValue();
- pageSegmentMap.put(source, name);
- } else if (AFPElementMapping.TAG_LOGICAL_ELEMENT
- .equals(element)) {
- String name = aps.getName();
- String value = aps.getValue();
- dataStream.createTagLogicalElement(name, value);
- } else if (AFPElementMapping.NO_OPERATION.equals(element)) {
- String content = aps.getContent();
- if (content != null) {
- dataStream.createNoOperation(content);
- }
- }
- } else if (attachment instanceof AFPPageOverlay) {
- AFPPageOverlay ipo = (AFPPageOverlay) attachment;
- String element = ipo.getElementName();
- if (AFPElementMapping.INCLUDE_PAGE_OVERLAY.equals(element)) {
- String overlay = ipo.getName();
- if (overlay != null) {
- dataStream.createIncludePageOverlay(overlay, ipo.getX(), ipo.getY());
- }
- }
- }
- }
- }
- }
-
- }
-
- /**
- * Sets the rotation to be used for portrait pages, valid values are 0
- * (default), 90, 180, 270.
- *
- * @param rotation
- * The rotation in degrees.
- */
- public void setPortraitRotation(int rotation) {
- paintingState.setPortraitRotation(rotation);
- }
-
- /**
- * Sets the rotation to be used for landscape pages, valid values are 0, 90,
- * 180, 270 (default).
- *
- * @param rotation
- * The rotation in degrees.
- */
- public void setLandscapeRotation(int rotation) {
- paintingState.setLandscapeRotation(rotation);
- }
-
- // ---=== AFPCustomizable ===---
-
- /** {@inheritDoc} */
- public void setBitsPerPixel(int bitsPerPixel) {
- paintingState.setBitsPerPixel(bitsPerPixel);
- }
-
- /** {@inheritDoc} */
- public void setColorImages(boolean colorImages) {
- paintingState.setColorImages(colorImages);
- }
-
- /** {@inheritDoc} */
- public void setNativeImagesSupported(boolean nativeImages) {
- paintingState.setNativeImagesSupported(nativeImages);
- }
-
- /** {@inheritDoc} */
- public void setCMYKImagesSupported(boolean value) {
- paintingState.setCMYKImagesSupported(value);
- }
-
- /** {@inheritDoc} */
- public void setDitheringQuality(float quality) {
- this.paintingState.setDitheringQuality(quality);
- }
-
- /** {@inheritDoc} */
- public void setShadingMode(AFPShadingMode shadingMode) {
- this.shadingMode = shadingMode;
- }
-
- /** {@inheritDoc} */
- public void setResolution(int resolution) {
- paintingState.setResolution(resolution);
- }
-
- /** {@inheritDoc} */
- public int getResolution() {
- return paintingState.getResolution();
- }
-
- /** {@inheritDoc} */
- public void setDefaultResourceGroupFilePath(String filePath) {
- resourceManager.setDefaultResourceGroupFilePath(filePath);
- }
-
- /** {@inheritDoc} */
- public void setResourceLevelDefaults(AFPResourceLevelDefaults defaults) {
- resourceManager.setResourceLevelDefaults(defaults);
- }
-
- /** {@inheritDoc} */
- protected void establishTransformationMatrix(AffineTransform at) {
- saveGraphicsState();
- concatenateTransformationMatrix(at);
- }
-
- /** {@inheritDoc} */
- public void clip() {
- // TODO
-// log.debug("NYI clip()");
- }
-
- /** {@inheritDoc} */
- public void clipRect(float x, float y, float width, float height) {
- // TODO
-// log.debug("NYI clipRect(x=" + x + ",y=" + y
-// + ",width=" + width + ", height=" + height + ")");
- }
-
- /** {@inheritDoc} */
- public void moveTo(float x, float y) {
- // TODO
-// log.debug("NYI moveTo(x=" + x + ",y=" + y + ")");
- }
-
- /** {@inheritDoc} */
- public void lineTo(float x, float y) {
- // TODO
-// log.debug("NYI lineTo(x=" + x + ",y=" + y + ")");
- }
-
- /** {@inheritDoc} */
- public void closePath() {
- // TODO
-// log.debug("NYI closePath()");
- }
-
- /** Indicates the beginning of a text object. */
- public void beginTextObject() {
- //TODO PDF specific maybe?
-// log.debug("NYI beginTextObject()");
- }
-
- /** Indicates the end of a text object. */
- public void endTextObject() {
- //TODO PDF specific maybe?
-// log.debug("NYI endTextObject()");
- }
-
-}
diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
index 1720667df..8d4b3370c 100644
--- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
@@ -149,7 +149,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
* @param encoding character encoding e.g. 'Cp500', 'UnicodeBigUnmarked'
* @param accessor
* @param afpFontCfg
- * @return
+ * @return the created AFPFont
* @throws ConfigurationException
*/
private AFPFont fontFromType(String type, String codepage, String encoding,
@@ -348,27 +348,12 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
private static final String IMAGES_MODE_COLOR = "color";
/**
- * Configure the AFP renderer.
+ * Throws an UnsupportedOperationException.
*
- * @param renderer AFP renderer
- * @throws FOPException fop exception
- * @see org.apache.fop.render.PrintRendererConfigurator#configure(Renderer)
+ * @param renderer not used
*/
- public void configure(Renderer renderer) throws FOPException {
- Configuration cfg = super.getRendererConfig(renderer);
- if (cfg != null) {
- AFPRenderer afpRenderer = (AFPRenderer)renderer;
-
- try {
- List/*<AFPFontInfo>*/ fontList = buildFontListFromConfiguration(cfg);
- afpRenderer.setFontList(fontList);
- } catch (ConfigurationException e) {
- LogUtil.handleException(log, e,
- userAgent.getFactory().validateUserConfigStrictly());
- }
-
- configure(afpRenderer, cfg);
- }
+ public void configure(Renderer renderer) {
+ throw new UnsupportedOperationException();
}
private void configure(AFPCustomizable customizable, Configuration cfg) throws FOPException {
diff --git a/src/java/org/apache/fop/render/afp/AFPRendererMaker.java b/src/java/org/apache/fop/render/afp/AFPRendererMaker.java
deleted file mode 100644
index d283d992a..000000000
--- a/src/java/org/apache/fop/render/afp/AFPRendererMaker.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.afp;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.AbstractRendererMaker;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererConfigurator;
-
-/**
- * RendererMaker for the AFP Renderer.
- */
-public class AFPRendererMaker extends AbstractRendererMaker {
-
- private static final String[] MIMES = new String[] {
- MimeConstants.MIME_AFP,
- MimeConstants.MIME_AFP_ALT};
-
-
- /**{@inheritDoc} */
- public Renderer makeRenderer(FOUserAgent userAgent) {
- return new AFPRenderer();
- }
-
- /** {@inheritDoc} */
- public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
- return new AFPRendererConfigurator(userAgent);
- }
-
- /** {@inheritDoc} */
- public boolean needsOutputStream() {
- return true;
- }
-
- /** {@inheritDoc} */
- public String[] getSupportedMimeTypes() {
- return MIMES;
- }
-
-}
diff --git a/src/java/org/apache/fop/render/afp/AFPRenderingContext.java b/src/java/org/apache/fop/render/afp/AFPRenderingContext.java
index 35be58c22..22a91dd83 100644
--- a/src/java/org/apache/fop/render/afp/AFPRenderingContext.java
+++ b/src/java/org/apache/fop/render/afp/AFPRenderingContext.java
@@ -43,6 +43,7 @@ public class AFPRenderingContext extends AbstractRenderingContext {
* Main constructor.
* @param userAgent the user agent
* @param resourceManager the resource manager
+ * @param paintingState the painting state
* @param fontInfo the font list
* @param foreignAttributes a map of foreign attributes
*/
@@ -70,6 +71,7 @@ public class AFPRenderingContext extends AbstractRenderingContext {
return this.resourceManager;
}
+ /** @return painting state */
public AFPPaintingState getPaintingState() {
return this.paintingState;
}
diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
index f76c4a89a..7ade64006 100644
--- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
+++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
@@ -174,7 +174,8 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler {
return objectAreaInfo;
}
- private AFPGraphicsObjectInfo createGraphicsObjectInfo(AFPPaintingState paintingState, Graphics2DImagePainter painter,
+ private AFPGraphicsObjectInfo createGraphicsObjectInfo
+ (AFPPaintingState paintingState, Graphics2DImagePainter painter,
FOUserAgent userAgent, AFPResourceInfo resourceInfo, AFPGraphics2D g2d) {
AFPGraphicsObjectInfo graphicsObjectInfo = new AFPGraphicsObjectInfo();
@@ -193,6 +194,11 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler {
return graphicsObjectInfo;
}
+ /**
+ * @param userAgent a user agent instance
+ * @param g2d a graphics context
+ * @return a bridge context
+ */
public static BridgeContext createBridgeContext(FOUserAgent userAgent, AFPGraphics2D g2d) {
ImageManager imageManager = userAgent.getFactory().getImageManager();
@@ -208,7 +214,7 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler {
/** {@inheritDoc} */
public boolean supportsRenderer(Renderer renderer) {
- return (renderer instanceof AFPRenderer);
+ return false;
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java b/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java
index 1228365f2..5374c7051 100644
--- a/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java
+++ b/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java
@@ -44,21 +44,6 @@ import org.apache.fop.render.RenderingContext;
public abstract class AbstractAFPImageHandlerRawStream extends AFPImageHandler
implements ImageHandler {
- /** {@inheritDoc} */
- public AFPDataObjectInfo generateDataObjectInfo(
- AFPRendererImageInfo rendererImageInfo) throws IOException {
- AFPDataObjectInfo dataObjectInfo = super.generateDataObjectInfo(rendererImageInfo);
- ImageRawStream rawStream = (ImageRawStream) rendererImageInfo.getImage();
- AFPRendererContext rendererContext
- = (AFPRendererContext)rendererImageInfo.getRendererContext();
- AFPInfo afpInfo = rendererContext.getInfo();
-
- updateDataObjectInfo(dataObjectInfo, rawStream, afpInfo.getResourceManager());
-
- setAdditionalParameters(dataObjectInfo, rawStream);
- return dataObjectInfo;
- }
-
/**
* Sets additional parameters on the image object info being built. By default, this
* method does nothing but it can be overridden to provide additional functionality.
diff --git a/src/java/org/apache/fop/render/afp/PageSegmentDescriptor.java b/src/java/org/apache/fop/render/afp/PageSegmentDescriptor.java
new file mode 100644
index 000000000..8915a7a59
--- /dev/null
+++ b/src/java/org/apache/fop/render/afp/PageSegmentDescriptor.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.afp;
+
+/**
+ * Class holding information on a page segment.
+ */
+class PageSegmentDescriptor {
+
+ private String name;
+ private String uri;
+
+ /**
+ * Creates a new page segment descriptor.
+ * @param name the page segment name
+ * @param uri the URI identifying the external resource file (may be null if the page segment
+ * shall be referenced rather than embedded)
+ */
+ public PageSegmentDescriptor(String name, String uri) {
+ this.name = name;
+ this.uri = uri;
+ }
+
+ /**
+ * Returns the name of the page segment (usually 8 upper case letters).
+ * @return the name of the page segment
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Returns the URI of the external resource containing the page segment.
+ * @return the URI of the external resource (or null if the resource is not to be embedded)
+ */
+ public String getURI() {
+ return this.uri;
+ }
+
+} \ No newline at end of file
diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java b/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java
index d77e21db2..4e4100bc7 100644
--- a/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java
+++ b/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java
@@ -73,7 +73,7 @@ public class AFPElementMapping extends ElementMapping {
protected void initialize() {
if (foObjs == null) {
- super.foObjs = new java.util.HashMap();
+ super.foObjs = new java.util.HashMap<String, Maker>();
foObjs.put(
TAG_LOGICAL_ELEMENT,
new AFPTagLogicalElementMaker());
@@ -103,7 +103,7 @@ public class AFPElementMapping extends ElementMapping {
static class AFPIncludePageSegmentMaker extends ElementMapping.Maker {
public FONode make(FONode parent) {
- return new AFPPageSetupElement(parent, INCLUDE_PAGE_SEGMENT);
+ return new AFPPageSegmentElement(parent, INCLUDE_PAGE_SEGMENT);
}
}
diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java b/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
index 254b68f1f..d916738eb 100644
--- a/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
+++ b/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
@@ -24,11 +24,13 @@ import java.net.URISyntaxException;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.DefaultHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.render.afp.extensions.AFPPageSegmentElement.AFPPageSegmentSetup;
import org.apache.fop.util.ContentHandlerFactory;
import org.apache.fop.util.ContentHandlerFactory.ObjectBuiltListener;
@@ -39,7 +41,7 @@ public class AFPExtensionHandler extends DefaultHandler
implements ContentHandlerFactory.ObjectSource {
/** Logger instance */
- protected static Log log = LogFactory.getLog(AFPExtensionHandler.class);
+ protected static final Log log = LogFactory.getLog(AFPExtensionHandler.class);
private StringBuffer content = new StringBuffer();
private Attributes lastAttributes;
@@ -52,7 +54,7 @@ public class AFPExtensionHandler extends DefaultHandler
throws SAXException {
boolean handled = false;
if (AFPExtensionAttachment.CATEGORY.equals(uri)) {
- lastAttributes = attributes;
+ lastAttributes = new AttributesImpl(attributes);
handled = true;
if (localName.equals(AFPElementMapping.NO_OPERATION)
|| localName.equals(AFPElementMapping.TAG_LOGICAL_ELEMENT)
@@ -96,6 +98,30 @@ public class AFPExtensionHandler extends DefaultHandler
if (name != null) {
returnedObject.setName(name);
}
+ } else if (AFPElementMapping.INCLUDE_PAGE_SEGMENT.equals(localName)) {
+ AFPPageSegmentSetup pageSetupExtn = null;
+
+ pageSetupExtn = new AFPPageSegmentSetup(localName);
+ this.returnedObject = pageSetupExtn;
+
+ String name = lastAttributes.getValue("name");
+ if (name != null) {
+ returnedObject.setName(name);
+ }
+ String value = lastAttributes.getValue("value");
+ if (value != null && pageSetupExtn != null) {
+ pageSetupExtn.setValue(value);
+ }
+
+ String resourceSrc = lastAttributes.getValue("resource-file");
+ if (resourceSrc != null && pageSetupExtn != null) {
+ pageSetupExtn.setResourceSrc(resourceSrc);
+ }
+
+ if (content.length() > 0 && pageSetupExtn != null) {
+ pageSetupExtn.setContent(content.toString());
+ content.setLength(0); //Reset text buffer (see characters())
+ }
} else {
AFPPageSetup pageSetupExtn = null;
if (AFPElementMapping.INVOKE_MEDIUM_MAP.equals(localName)) {
@@ -117,6 +143,7 @@ public class AFPExtensionHandler extends DefaultHandler
content.setLength(0); //Reset text buffer (see characters())
}
}
+
}
}
diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java b/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java
index f36bd3e12..813cf6ddd 100644
--- a/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java
+++ b/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java
@@ -44,7 +44,7 @@ public class AFPInvokeMediumMapElement extends AbstractAFPExtensionObject {
super.startOfNode();
if (parent.getNameId() != Constants.FO_PAGE_SEQUENCE
&& parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) {
-
+
invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(),
"rule.childOfPageSequence");
}
diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java b/src/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java
index b14a4eb9d..a82fe3457 100644
--- a/src/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java
+++ b/src/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java
@@ -19,8 +19,6 @@
package org.apache.fop.render.afp.extensions;
-import java.net.URI;
-
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPPageSegmentElement.java b/src/java/org/apache/fop/render/afp/extensions/AFPPageSegmentElement.java
new file mode 100644
index 000000000..f7379e02c
--- /dev/null
+++ b/src/java/org/apache/fop/render/afp/extensions/AFPPageSegmentElement.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.afp.extensions;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.extensions.ExtensionAttachment;
+
+/**
+ * This class extends the org.apache.fop.extensions.ExtensionObj class. The
+ * object faciliates extraction of elements from formatted objects based on
+ * the static list as defined in the AFPElementMapping implementation.
+ * <p/>
+ */
+public class AFPPageSegmentElement extends AFPPageSetupElement {
+
+ private static final String ATT_RESOURCE_SRC = "resource-file";
+
+ /**
+ * Constructs an AFP object (called by Maker).
+ *
+ * @param parent the parent formatting object
+ * @param name the name of the afp element
+ */
+ public AFPPageSegmentElement(FONode parent, String name) {
+ super(parent, name);
+ }
+
+
+ private AFPPageSegmentSetup getPageSetupAttachment() {
+ return (AFPPageSegmentSetup)getExtensionAttachment();
+ }
+
+
+ /** {@inheritDoc} */
+ public void processNode(String elementName, Locator locator,
+ Attributes attlist, PropertyList propertyList)
+ throws FOPException {
+
+ AFPPageSegmentSetup pageSetup = getPageSetupAttachment();
+ super.processNode(elementName, locator, attlist, propertyList);
+
+
+ String attr = attlist.getValue(ATT_RESOURCE_SRC);
+
+ if (attr != null && attr.length() > 0) {
+ pageSetup.setResourceSrc(attr);
+ }
+
+ }
+
+ /** {@inheritDoc} */
+ protected ExtensionAttachment instantiateExtensionAttachment() {
+ return new AFPPageSegmentSetup(getLocalName());
+ }
+
+ /**
+ * This is the pass-through value object for the AFP extension.
+ */
+ public static class AFPPageSegmentSetup extends AFPPageSetup {
+
+ private static final long serialVersionUID = 1L;
+
+ private String resourceSrc;
+
+ /**
+ * Default constructor.
+ *
+ * @param elementName the name of the setup code object, may be null
+ */
+ public AFPPageSegmentSetup(String elementName) {
+ super(elementName);
+ }
+
+ /**
+ * Returns the source URI for the page segment.
+ * @return the source URI
+ */
+ public String getResourceSrc() {
+ return resourceSrc;
+ }
+
+ /**
+ * Sets the source URI for the page segment.
+ * @param resourceSrc the source URI
+ */
+ public void setResourceSrc(String resourceSrc) {
+ this.resourceSrc = resourceSrc.trim();
+ }
+
+
+ /** {@inheritDoc} */
+ public void toSAX(ContentHandler handler) throws SAXException {
+ AttributesImpl atts = new AttributesImpl();
+ if (name != null && name.length() > 0) {
+ atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", name);
+ }
+ if (value != null && value.length() > 0) {
+ atts.addAttribute(null, ATT_VALUE, ATT_VALUE, "CDATA", value);
+ }
+
+ if (resourceSrc != null && resourceSrc.length() > 0) {
+ atts.addAttribute(null, ATT_RESOURCE_SRC, ATT_RESOURCE_SRC, "CDATA", resourceSrc);
+ }
+
+ handler.startElement(CATEGORY, elementName, elementName, atts);
+ if (content != null && content.length() > 0) {
+ char[] chars = content.toCharArray();
+ handler.characters(chars, 0, chars.length);
+ }
+ handler.endElement(CATEGORY, elementName, elementName);
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return "AFPPageSegmentSetup(element-name=" + getElementName()
+ + " name=" + getName()
+ + " value=" + getValue()
+ + " resource=" + getResourceSrc() + ")";
+ }
+
+ }
+
+
+}
diff --git a/src/java/org/apache/fop/render/awt/AWTRenderer.java b/src/java/org/apache/fop/render/awt/AWTRenderer.java
index b50708112..99dece24a 100644
--- a/src/java/org/apache/fop/render/awt/AWTRenderer.java
+++ b/src/java/org/apache/fop/render/awt/AWTRenderer.java
@@ -29,14 +29,16 @@ package org.apache.fop.render.awt;
// Java
import java.awt.Color;
import java.awt.Dimension;
-import java.awt.geom.Rectangle2D;
import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
import java.awt.print.PageFormat;
import java.awt.print.Pageable;
import java.awt.print.Paper;
import java.awt.print.Printable;
import java.io.IOException;
+import org.apache.xmlgraphics.util.UnitConv;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FopFactoryConfigurator;
@@ -46,8 +48,8 @@ import org.apache.fop.area.PageViewport;
import org.apache.fop.render.awt.viewer.PreviewDialog;
import org.apache.fop.render.awt.viewer.Renderable;
import org.apache.fop.render.awt.viewer.StatusListener;
-import org.apache.fop.render.java2d.Java2DRenderer;
import org.apache.fop.render.extensions.prepress.PageScale;
+import org.apache.fop.render.java2d.Java2DRenderer;
/**
* The AWTRender outputs the pages generated by the layout engine to a Swing
@@ -60,10 +62,10 @@ public class AWTRenderer extends Java2DRenderer implements Pageable {
public static final String MIME_TYPE = MimeConstants.MIME_FOP_AWT_PREVIEW;
/** flag for debugging */
- public boolean debug;
+ public boolean debug; // CSOK: VisibilityModifier
/** If true, preview dialog is shown. */
- public boolean dialogDisplay = true;
+ public boolean dialogDisplay = true; // CSOK: VisibilityModifier
/** true if the preview dialog should be the main window of the application */
private boolean previewAsMainWindow;
@@ -152,10 +154,10 @@ public class AWTRenderer extends Java2DRenderer implements Pageable {
pageWidth = (int) Math.round(bounds.getWidth() / 1000f);
pageHeight = (int) Math.round(bounds.getHeight() / 1000f);
double scaleX = scaleFactor
- * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
+ * (UnitConv.IN2MM / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
/ userAgent.getTargetPixelUnitToMillimeter();
double scaleY = scaleFactor
- * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
+ * (UnitConv.IN2MM / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
/ userAgent.getTargetPixelUnitToMillimeter();
if (getPageViewport(pageNum).getForeignAttributes() != null) {
String scale = (String) getPageViewport(pageNum).getForeignAttributes().get(
diff --git a/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java b/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java
index a96d73a46..9b3cac0a0 100644
--- a/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java
+++ b/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java
@@ -106,7 +106,7 @@ public class ImageProxyPanel extends JPanel {
/**
* Gets the image data and paints it on screen. Will make
* calls to getPageImage as required.
- * @param graphics
+ * @param graphics a graphics context
* @see javax.swing.JComponent#paintComponent(Graphics)
* @see org.apache.fop.render.java2d.Java2DRenderer#getPageImage(int)
*/
diff --git a/src/java/org/apache/fop/render/awt/viewer/PageChangeEvent.java b/src/java/org/apache/fop/render/awt/viewer/PageChangeEvent.java
index 045ce7fe4..78f09b537 100644
--- a/src/java/org/apache/fop/render/awt/viewer/PageChangeEvent.java
+++ b/src/java/org/apache/fop/render/awt/viewer/PageChangeEvent.java
@@ -27,6 +27,8 @@ import java.util.EventObject;
*/
public class PageChangeEvent extends EventObject {
+ private static final long serialVersionUID = -5969283475959932887L;
+
private int oldPage;
private int newPage;
diff --git a/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java b/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
index 031021a6f..32f31ce4c 100644
--- a/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
+++ b/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java
@@ -17,11 +17,12 @@
/* $Id$ */
+package org.apache.fop.render.awt.viewer;
+
// Originally contributed by:
// Juergen Verwohlt: Juergen.Verwohlt@jCatalog.com,
// Rainer Steinkuhle: Rainer.Steinkuhle@jCatalog.com,
// Stanislav Gorkhover: Stanislav.Gorkhover@jCatalog.com
-package org.apache.fop.render.awt.viewer;
// Java
import java.awt.BorderLayout;
@@ -105,7 +106,8 @@ public class PreviewDialog extends JFrame implements StatusListener {
* @param renderable the Renderable instance that is used to reload/re-render a document
* after modifications.
*/
- public PreviewDialog(FOUserAgent foUserAgent, Renderable renderable) {
+ public PreviewDialog // CSOK: MethodLength
+ (FOUserAgent foUserAgent, Renderable renderable) {
renderer = (AWTRenderer) foUserAgent.getRendererOverride();
this.foUserAgent = foUserAgent;
this.configuredTargetResolution = this.foUserAgent.getTargetResolution();
@@ -579,7 +581,10 @@ public class PreviewDialog extends JFrame implements StatusListener {
}
}
- /** Prints the document */
+ /**
+ * Prints the document.
+ * @param showDialog true if show dialog
+ */
public void startPrinterJob(boolean showDialog) {
//Restore originally configured target resolution
float saveResolution = foUserAgent.getTargetResolution();
diff --git a/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java b/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java
index 0808a7ac9..9a0b3b7bc 100644
--- a/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java
+++ b/src/java/org/apache/fop/render/bitmap/BitmapRendererEventProducer.java
@@ -30,7 +30,10 @@ import org.apache.fop.events.EventProducer;
public interface BitmapRendererEventProducer extends EventProducer {
/** Provider class for the event producer. */
- class Provider {
+ final class Provider {
+
+ private Provider() {
+ }
/**
* Returns an event producer.
diff --git a/src/java/org/apache/fop/render/bitmap/PNGRenderer_onthefly.java b/src/java/org/apache/fop/render/bitmap/PNGRenderer_onthefly.java
deleted file mode 100644
index a6a6e8dfe..000000000
--- a/src/java/org/apache/fop/render/bitmap/PNGRenderer_onthefly.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.bitmap;
-
-import java.awt.image.RenderedImage;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.apache.xmlgraphics.image.codec.png.PNGEncodeParam;
-import org.apache.xmlgraphics.image.codec.png.PNGImageEncoder;
-
-import org.apache.commons.io.IOUtils;
-
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.area.PageViewport;
-import org.apache.fop.render.java2d.Java2DRenderer;
-
-/**
- * PNG Renderer This class actually does not render itself, instead it extends
- * <code>org.apache.fop.render.java2D.Java2DRenderer</code> and just encode
- * rendering results into PNG format using Batik's image codec
- */
-public class PNGRenderer_onthefly extends Java2DRenderer {
-
- /** The MIME type for png-Rendering */
- public static final String MIME_TYPE = "image/png";
-
- /** The file syntax prefix, eg. "page" will output "page1.png" etc */
- private String fileSyntax;
-
- /** The output directory where images are to be written */
- private File outputDir;
-
- /** The PNGEncodeParam for the image */
- private PNGEncodeParam renderParams;
-
- /** The OutputStream for the first Image */
- private OutputStream firstOutputStream;
-
- /** {@inheritDoc} */
- public String getMimeType() {
- return MIME_TYPE;
- }
-
- /** {@inheritDoc} */
- public boolean supportsOutOfOrder() {
- return true;
- }
-
- /** {@inheritDoc} */
- public void startRenderer(OutputStream outputStream) throws IOException {
- log.info("rendering areas to PNG");
- setOutputDirectory();
- this.firstOutputStream = outputStream;
- }
-
- /**
- * Sets the output directory, either from the outfile specified on the
- * command line, or from the directory specified in configuration file. Also
- * sets the file name syntax, eg. "page"
- */
- private void setOutputDirectory() {
-
- // the file provided on the command line
- File f = getUserAgent().getOutputFile();
-
- outputDir = f.getParentFile();
-
- // extracting file name syntax
- String s = f.getName();
- int i = s.lastIndexOf(".");
- if (s.charAt(i - 1) == '1') {
- i--; // getting rid of the "1"
- }
- fileSyntax = s.substring(0, i);
- }
-
- /**
- * {@inheritDoc}
- */
- public void renderPage(PageViewport pageViewport) throws IOException {
-
- // Do the rendering: get the image for this page
- RenderedImage image = (RenderedImage) getPageImage(pageViewport);
-
- // Encode this image
- log.debug("Encoding page" + (getCurrentPageNumber() + 1));
- renderParams = PNGEncodeParam.getDefaultEncodeParam(image);
- OutputStream os = getCurrentOutputStream(getCurrentPageNumber());
- if (os != null) {
- try {
- PNGImageEncoder encoder = new PNGImageEncoder(os, renderParams);
- encoder.encode(image);
- } finally {
- //Only close self-created OutputStreams
- if (os != firstOutputStream) {
- IOUtils.closeQuietly(os);
- }
- }
- }
-
- setCurrentPageNumber(getCurrentPageNumber() + 1);
- }
-
- /**
- * Builds the OutputStream corresponding to this page
- * @param 0-based pageNumber
- * @return the corresponding OutputStream
- */
- private OutputStream getCurrentOutputStream(int pageNumber) {
-
- if (pageNumber == 0) {
- return firstOutputStream;
- }
-
- File f = new File(outputDir + File.separator + fileSyntax
- + (pageNumber + 1) + ".png");
- try {
- OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
- return os;
- } catch (FileNotFoundException e) {
- new FOPException("Can't build the OutputStream\n" + e);
- return null;
- }
- }
-}
diff --git a/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java b/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
index c524ccc3a..5a9cfa21b 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
@@ -31,6 +31,7 @@ import java.awt.image.SinglePixelPackedSampleModel;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Iterator;
+import java.util.NoSuchElementException;
import org.apache.commons.logging.Log;
@@ -133,7 +134,11 @@ public class TIFFRenderer extends Java2DRenderer implements TIFFConstants {
multiWriter.close();
}
} else {
- writer.writeImage((RenderedImage) pageImagesItr.next(), outputStream, writerParams);
+ RenderedImage renderedImage = null;
+ if (pageImagesItr.hasNext()) {
+ renderedImage = (RenderedImage) pageImagesItr.next();
+ }
+ writer.writeImage(renderedImage, outputStream, writerParams);
if (pageImagesItr.hasNext()) {
BitmapRendererEventProducer eventProducer
= BitmapRendererEventProducer.Provider.get(
@@ -186,8 +191,7 @@ public class TIFFRenderer extends Java2DRenderer implements TIFFConstants {
try {
pageImage = getPageImage(current++);
} catch (FOPException e) {
- log.error(e);
- return null;
+ throw new NoSuchElementException(e.getMessage());
}
if (COMPRESSION_CCITT_T4.equalsIgnoreCase(writerParams.getCompressionMethod())
@@ -219,10 +223,12 @@ public class TIFFRenderer extends Java2DRenderer implements TIFFConstants {
}
}
+ /** @param bufferedImageType an image type */
public void setBufferedImageType(int bufferedImageType) {
this.bufferedImageType = bufferedImageType;
}
+ /** @return image writer parameters */
public ImageWriterParams getWriterParams() {
return writerParams;
}
diff --git a/src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java b/src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java
index cd15a9d72..b156b6c3a 100644
--- a/src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java
+++ b/src/java/org/apache/fop/render/intermediate/AbstractIFDocumentHandler.java
@@ -19,9 +19,6 @@
package org.apache.fop.render.intermediate;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import org.apache.fop.apps.FOUserAgent;
/**
@@ -29,9 +26,6 @@ import org.apache.fop.apps.FOUserAgent;
*/
public abstract class AbstractIFDocumentHandler implements IFDocumentHandler {
- /** logging instance */
- private static Log log = LogFactory.getLog(AbstractIFDocumentHandler.class);
-
private IFContext ifContext;
/**
diff --git a/src/java/org/apache/fop/render/intermediate/BorderPainter.java b/src/java/org/apache/fop/render/intermediate/BorderPainter.java
index 75f773291..20402369a 100644
--- a/src/java/org/apache/fop/render/intermediate/BorderPainter.java
+++ b/src/java/org/apache/fop/render/intermediate/BorderPainter.java
@@ -41,7 +41,7 @@ public abstract class BorderPainter {
* @param bpsEnd the border specification on the end side
* @throws IOException if an I/O error occurs while creating the borders
*/
- public void drawBorders(Rectangle borderRect,
+ public void drawBorders(Rectangle borderRect, // CSOK: MethodLength
BorderProps bpsBefore, BorderProps bpsAfter,
BorderProps bpsStart, BorderProps bpsEnd) throws IOException {
int startx = borderRect.x;
@@ -217,7 +217,8 @@ public abstract class BorderPainter {
* @param color the border color
* @throws IOException if an I/O error occurs
*/
- protected abstract void drawBorderLine(int x1, int y1, int x2, int y2,
+ protected abstract void drawBorderLine( // CSOK: ParameterNumber
+ int x1, int y1, int x2, int y2,
boolean horz, boolean startOrBefore, int style, Color color) throws IOException;
/**
diff --git a/src/java/org/apache/fop/render/intermediate/IFConstants.java b/src/java/org/apache/fop/render/intermediate/IFConstants.java
index fa234b4db..34fe2bd2c 100644
--- a/src/java/org/apache/fop/render/intermediate/IFConstants.java
+++ b/src/java/org/apache/fop/render/intermediate/IFConstants.java
@@ -33,22 +33,39 @@ public interface IFConstants extends XMLConstants {
/** XML namespace of the intermediate format. */
String NAMESPACE = "http://xmlgraphics.apache.org/fop/intermediate";
+ /** element name document */
String EL_DOCUMENT = "document";
+ /** element name header */
String EL_HEADER = "header";
+ /** element name trailer */
String EL_TRAILER = "trailer";
+ /** element name page-sequence */
String EL_PAGE_SEQUENCE = "page-sequence";
+ /** element name page */
String EL_PAGE = "page";
+ /** element name page-header */
String EL_PAGE_HEADER = "page-header";
+ /** element name page-trailer */
String EL_PAGE_TRAILER = "page-trailer";
+ /** element name content */
String EL_PAGE_CONTENT = "content";
+ /** element name viewport */
String EL_VIEWPORT = "viewport";
+ /** element name group */
String EL_GROUP = "g";
+ /** element name image */
String EL_IMAGE = "image";
+ /** element name clip-rect */
String EL_CLIP_RECT = "clip-rect";
+ /** element name rect */
String EL_RECT = "rect";
+ /** element name line */
String EL_LINE = "line";
+ /** element name border-rect */
String EL_BORDER_RECT = "border-rect";
+ /** element name font */
String EL_FONT = "font";
+ /** element name text */
String EL_TEXT = "text";
/** Parent element of the logical structure tree. */
String EL_STRUCTURE_TREE = "structure-tree";
diff --git a/src/java/org/apache/fop/render/intermediate/IFContentHandler.java b/src/java/org/apache/fop/render/intermediate/IFContentHandler.java
index 55c65d82a..ac7feb269 100644
--- a/src/java/org/apache/fop/render/intermediate/IFContentHandler.java
+++ b/src/java/org/apache/fop/render/intermediate/IFContentHandler.java
@@ -24,62 +24,74 @@ import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
+/** intermediate format content handler */
public class IFContentHandler implements ContentHandler {
+ /** {@inheritDoc} */
public void characters(char[] arg0, int arg1, int arg2) throws SAXException {
// TODO Auto-generated method stub
}
+ /** {@inheritDoc} */
public void endDocument() throws SAXException {
// TODO Auto-generated method stub
}
+ /** {@inheritDoc} */
public void endElement(String arg0, String arg1, String arg2)
throws SAXException {
// TODO Auto-generated method stub
}
+ /** {@inheritDoc} */
public void endPrefixMapping(String arg0) throws SAXException {
// TODO Auto-generated method stub
}
+ /** {@inheritDoc} */
public void ignorableWhitespace(char[] arg0, int arg1, int arg2)
throws SAXException {
// TODO Auto-generated method stub
}
+ /** {@inheritDoc} */
public void processingInstruction(String arg0, String arg1)
throws SAXException {
// TODO Auto-generated method stub
}
+ /** {@inheritDoc} */
public void setDocumentLocator(Locator arg0) {
// TODO Auto-generated method stub
}
+ /** {@inheritDoc} */
public void skippedEntity(String arg0) throws SAXException {
// TODO Auto-generated method stub
}
+ /** {@inheritDoc} */
public void startDocument() throws SAXException {
// TODO Auto-generated method stub
}
+ /** {@inheritDoc} */
public void startElement(String arg0, String arg1, String arg2,
Attributes arg3) throws SAXException {
// TODO Auto-generated method stub
}
+ /** {@inheritDoc} */
public void startPrefixMapping(String arg0, String arg1)
throws SAXException {
// TODO Auto-generated method stub
diff --git a/src/java/org/apache/fop/render/intermediate/IFDocumentNavigationHandler.java b/src/java/org/apache/fop/render/intermediate/IFDocumentNavigationHandler.java
index eef13e105..09a641ce2 100644
--- a/src/java/org/apache/fop/render/intermediate/IFDocumentNavigationHandler.java
+++ b/src/java/org/apache/fop/render/intermediate/IFDocumentNavigationHandler.java
@@ -45,8 +45,16 @@ public interface IFDocumentNavigationHandler {
*/
void renderBookmarkTree(BookmarkTree tree) throws IFException;
+ /**
+ * @param link a link
+ * @throws IFException of not caught
+ */
void renderLink(Link link) throws IFException;
+ /**
+ * @param action an action
+ * @throws IFException of not caught
+ */
void addResolvedAction(AbstractAction action) throws IFException;
}
diff --git a/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java b/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java
index 34ac0bcb2..6e431e513 100644
--- a/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java
+++ b/src/java/org/apache/fop/render/intermediate/IFGraphicContext.java
@@ -56,6 +56,7 @@ public class IFGraphicContext extends GraphicContext {
return new IFGraphicContext(this);
}
+ /** @param group a group */
public void pushGroup(Group group) {
//this.groupDepth++;
this.groupList.add(group);
@@ -64,44 +65,66 @@ public class IFGraphicContext extends GraphicContext {
}
}
+ /** @return array of groups */
public Group[] getGroups() {
return (Group[])this.groupList.toArray(new Group[getGroupStackSize()]);
}
+ /** @return array of groups after clearing group list */
public Group[] dropGroups() {
Group[] groups = getGroups();
this.groupList.clear();
return groups;
}
+ /** @return size of group list */
public int getGroupStackSize() {
return this.groupList.size();
}
+ /** a group */
public static class Group {
private AffineTransform[] transforms;
+ /**
+ * Construct a Group.
+ * @param transforms an array of transforms
+ */
public Group(AffineTransform[] transforms) {
this.transforms = transforms;
}
+ /**
+ * Construct a Group.
+ * @param transform a transform
+ */
public Group(AffineTransform transform) {
this(new AffineTransform[] {transform});
}
+ /** Default constructor. */
public Group() {
this(EMPTY_TRANSFORM_ARRAY);
}
+ /** @return array of transforms */
public AffineTransform[] getTransforms() {
return this.transforms;
}
+ /**
+ * @param painter a painter
+ * @throws IFException in not caught
+ */
public void start(IFPainter painter) throws IFException {
painter.startGroup(transforms);
}
+ /**
+ * @param painter a painter
+ * @throws IFException in not caught
+ */
public void end(IFPainter painter) throws IFException {
painter.endGroup();
}
@@ -115,33 +138,50 @@ public class IFGraphicContext extends GraphicContext {
}
+ /** a viewport */
public static class Viewport extends Group {
private Dimension size;
private Rectangle clipRect;
+ /**
+ * Construct a viewport.
+ * @param transforms an array of transforms
+ * @param size a dimension
+ * @param clipRect a clip rectangle
+ */
public Viewport(AffineTransform[] transforms, Dimension size, Rectangle clipRect) {
super(transforms);
this.size = size;
this.clipRect = clipRect;
}
+ /**
+ * Construct a viewport.
+ * @param transform a transform
+ * @param size a dimension
+ * @param clipRect a clip rectangle
+ */
public Viewport(AffineTransform transform, Dimension size, Rectangle clipRect) {
this(new AffineTransform[] {transform}, size, clipRect);
}
+ /** @return the viewport's size */
public Dimension getSize() {
return this.size;
}
+ /** @return the clip rectangle */
public Rectangle getClipRect() {
return this.clipRect;
}
+ /** {@inheritDoc} */
public void start(IFPainter painter) throws IFException {
painter.startViewport(getTransforms(), size, clipRect);
}
+ /** {@inheritDoc} */
public void end(IFPainter painter) throws IFException {
painter.endViewport();
}
diff --git a/src/java/org/apache/fop/render/intermediate/IFParser.java b/src/java/org/apache/fop/render/intermediate/IFParser.java
index da5d8a623..645d1ebc6 100644
--- a/src/java/org/apache/fop/render/intermediate/IFParser.java
+++ b/src/java/org/apache/fop/render/intermediate/IFParser.java
@@ -71,7 +71,7 @@ import org.apache.fop.util.XMLUtil;
public class IFParser implements IFConstants {
/** Logger instance */
- protected static Log log = LogFactory.getLog(IFParser.class);
+ protected static final Log log = LogFactory.getLog(IFParser.class);
private static SAXTransformerFactory tFactory
= (SAXTransformerFactory)SAXTransformerFactory.newInstance();
diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java
index 13ac401a7..046d1703b 100644
--- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java
+++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java
@@ -110,7 +110,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
//if optimizations can be done to avoid int->float->int conversions.
/** logging instance */
- protected static Log log = LogFactory.getLog(IFRenderer.class);
+ protected static final Log log = LogFactory.getLog(IFRenderer.class);
/** XML MIME type */
public static final String IF_MIME_TYPE = MimeConstants.MIME_FOP_IF;
@@ -1238,7 +1238,8 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
}
/** {@inheritDoc} */
- protected void drawBorders(float startx, float starty,
+ protected void drawBorders( // CSOK: ParameterNumber
+ float startx, float starty,
float width, float height,
BorderProps bpsBefore, BorderProps bpsAfter,
BorderProps bpsStart, BorderProps bpsEnd) {
@@ -1251,7 +1252,8 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
}
/** {@inheritDoc} */
- protected void drawBorderLine(float x1, float y1, float x2, float y2, boolean horz,
+ protected void drawBorderLine( // CSOK: ParameterNumber
+ float x1, float y1, float x2, float y2, boolean horz,
boolean startOrBefore, int style, Color col) {
//Simplified implementation that is only used by renderTextDecoration()
//drawBorders() is overridden and uses the Painter's high-level method drawBorderRect()
diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java
index 2c45bfcd6..3e178d3cb 100644
--- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java
+++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java
@@ -646,8 +646,11 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler
}
}
- /** {@inheritDoc} */
- protected RenderingContext createRenderingContext() {
+ /**
+ * @return a new rendering context
+ * @throws IllegalStateException unless overridden
+ */
+ protected RenderingContext createRenderingContext() throws IllegalStateException {
throw new IllegalStateException("Should never be called!");
}
diff --git a/src/java/org/apache/fop/render/intermediate/IFState.java b/src/java/org/apache/fop/render/intermediate/IFState.java
index e5b031dd3..4d8325d3e 100644
--- a/src/java/org/apache/fop/render/intermediate/IFState.java
+++ b/src/java/org/apache/fop/render/intermediate/IFState.java
@@ -23,7 +23,8 @@ import java.awt.Color;
import org.apache.xmlgraphics.java2d.color.ColorUtil;
-public class IFState {
+/** a state class for intermediate format data */
+public final class IFState {
private IFState parent;
@@ -52,22 +53,27 @@ public class IFState {
this.textColor = parent.textColor;
}
+ /** @return create state */
public static IFState create() {
return new IFState();
}
+ /** @return push state */
public IFState push() {
return new IFState(this);
}
+ /** @return pop state */
public IFState pop() {
return this.parent;
}
+ /** @return true if font changed */
public boolean isFontChanged() {
return this.fontChanged;
}
+ /** reset font changed */
public void resetFontChanged() {
this.fontChanged = false;
}
diff --git a/src/java/org/apache/fop/render/intermediate/IFUtil.java b/src/java/org/apache/fop/render/intermediate/IFUtil.java
index 955193000..1867b0294 100644
--- a/src/java/org/apache/fop/render/intermediate/IFUtil.java
+++ b/src/java/org/apache/fop/render/intermediate/IFUtil.java
@@ -30,7 +30,10 @@ import org.apache.fop.util.DecimalFormatCache;
/**
* Utility functions for the intermediate format.
*/
-public class IFUtil {
+public final class IFUtil {
+
+ private IFUtil() {
+ }
private static String format(double value) {
if (value == -0.0) {
diff --git a/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java b/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java
index 5ca480f4a..1e613d7eb 100644
--- a/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java
+++ b/src/java/org/apache/fop/render/intermediate/extensions/DocumentNavigationHandler.java
@@ -41,7 +41,7 @@ public class DocumentNavigationHandler extends DefaultHandler
implements DocumentNavigationExtensionConstants {
/** Logger instance */
- protected static Log log = LogFactory.getLog(DocumentNavigationHandler.class);
+ protected static final Log log = LogFactory.getLog(DocumentNavigationHandler.class);
private StringBuffer content = new StringBuffer();
private Stack objectStack = new Stack();
diff --git a/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java b/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java
index a2b4f31b6..4bd548c73 100644
--- a/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java
+++ b/src/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java
@@ -74,7 +74,7 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx
* <p>
* This function will always return a valid value for safety. Use
* {@link #isComplete()} to check if the link is actually complete.
- *
+ *
* @return the page index (0-based)
*/
public int getPageIndex() {
@@ -90,7 +90,7 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx
* <p>
* This function will always return a valid value for safety. Use
* {@link #isComplete()} to check if the link is actually complete.
- *
+ *
* @return the target location (coordinates in millipoints)
*/
public Point getTargetLocation() {
@@ -112,7 +112,7 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx
private boolean isCompleteExceptTargetLocation() {
return (getPageIndex() >= 0);
}
-
+
/** {@inheritDoc} */
public boolean isComplete() {
return this.isCompleteExceptTargetLocation() && (this.targetLocation != null);
@@ -147,9 +147,9 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx
atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getID());
atts.addAttribute(null, "page-index", "page-index",
XMLUtil.CDATA, Integer.toString(pageIndex));
- atts.addAttribute(null, "x", "x", XMLUtil.CDATA,
+ atts.addAttribute(null, "x", "x", XMLUtil.CDATA,
Integer.toString(reportedTargetLocation.x));
- atts.addAttribute(null, "y", "y", XMLUtil.CDATA,
+ atts.addAttribute(null, "y", "y", XMLUtil.CDATA,
Integer.toString(reportedTargetLocation.y));
} else {
atts.addAttribute(null, "idref", "idref", XMLUtil.CDATA, getID());
diff --git a/src/java/org/apache/fop/render/intermediate/util/IFConcatenator.java b/src/java/org/apache/fop/render/intermediate/util/IFConcatenator.java
index 4b0a3fe68..71ee7a0b0 100644
--- a/src/java/org/apache/fop/render/intermediate/util/IFConcatenator.java
+++ b/src/java/org/apache/fop/render/intermediate/util/IFConcatenator.java
@@ -19,7 +19,6 @@
package org.apache.fop.render.intermediate.util;
-
import java.awt.Dimension;
import javax.xml.transform.Source;
@@ -39,12 +38,17 @@ import org.apache.fop.render.intermediate.IFParser;
* <p>
* Note: This class will filter/ignore any document navigation events. Support for this may be
* added later.
+ * <p>
+ * Note: document-level extensions will only be transferred from the first document passed in.
+ * If you need to merge extensions from all the concatenated documents, you may have to merge
+ * these manually on the XML level, for example using XSLT.
*/
public class IFConcatenator {
private IFDocumentHandler targetHandler;
private int nextPageIndex = 0;
+ private boolean inFirstDocument = true;
/**
* Creates a new IF concatenator.
@@ -163,14 +167,17 @@ public class IFConcatenator {
/** {@inheritDoc} */
public void endDocument() throws IFException {
//ignore
+ inFirstDocument = false;
}
/** {@inheritDoc} */
public void handleExtensionObject(Object extension) throws IFException {
- if (inPageSequence) {
+ if (inPageSequence || inFirstDocument) {
//Only pass through when inside page-sequence
+ //or for the first document (for document-level extensions).
super.handleExtensionObject(extension);
}
+ //Note:Extensions from non-first documents are ignored!
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java b/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
index 29570e69f..fb88b8bce 100644
--- a/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
+++ b/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
@@ -95,7 +95,7 @@ public class ConfiguredFontCollection implements FontCollection {
fontInfo.addMetrics(internalName, font);
- List triplets = configFontInfo.getFontTriplets();
+ List<FontTriplet> triplets = configFontInfo.getFontTriplets();
for (int c = 0; c < triplets.size(); c++) {
FontTriplet triplet = (FontTriplet) triplets.get(c);
diff --git a/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java b/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java
index 1d9d7d56e..6540d6e37 100644
--- a/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java
+++ b/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java
@@ -16,6 +16,7 @@
*/
/* $Id$ */
+
package org.apache.fop.render.java2d;
import java.awt.Font;
@@ -29,6 +30,7 @@ import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import org.apache.fop.fonts.CustomFont;
+import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.fonts.FontType;
import org.apache.fop.fonts.LazyFont;
import org.apache.fop.fonts.Typeface;
@@ -36,7 +38,7 @@ import org.apache.fop.fonts.Typeface;
/**
* FontMetricsMapper that delegates most methods to an underlying
* {@link FontMetrics} instance. This class was designed to allow
- * the underlying {@link java.awt.Font} to be loaded from a
+ * the underlying {@link Font} to be loaded from a
* user-configured file not registered in the current graphics environment.
*/
public class CustomFontMetricsMapper extends Typeface implements FontMetricsMapper {
@@ -159,7 +161,7 @@ public class CustomFontMetricsMapper extends Typeface implements FontMetricsMapp
}
/** {@inheritDoc} */
- public final Set getFamilyNames() {
+ public final Set<String> getFamilyNames() {
return typeface.getFamilyNames();
}
diff --git a/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java b/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java
index 17073dd6c..806a07d6c 100644
--- a/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java
+++ b/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java
@@ -28,7 +28,7 @@ import org.apache.fop.fonts.FontMetrics;
public interface FontMetricsMapper extends FontMetrics {
/**
- * Gets a {@link Font} instance of the font that this
+ * Gets a {@link java.awt.Font} instance of the font that this
* {@link FontMetrics} describes in the desired size.
* @param size font size
* @return font with the desired characteristics.
diff --git a/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java b/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java
index c5e0a3f5c..b2b29188b 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DBorderPainter.java
@@ -47,6 +47,10 @@ public class Java2DBorderPainter extends BorderPainter {
private GeneralPath currentPath = null;
+ /**
+ * Construct a java2d border painter.
+ * @param painter a painter
+ */
public Java2DBorderPainter(Java2DPainter painter) {
this.painter = painter;
}
@@ -60,7 +64,8 @@ public class Java2DBorderPainter extends BorderPainter {
}
/** {@inheritDoc} */
- protected void drawBorderLine(int x1, int y1, int x2, int y2, boolean horz,
+ protected void drawBorderLine( // CSOK: ParameterNumber
+ int x1, int y1, int x2, int y2, boolean horz,
boolean startOrBefore, int style, Color color) {
float w = x2 - x1;
float h = y2 - y1;
diff --git a/src/java/org/apache/fop/render/java2d/Java2DImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/java2d/Java2DImageHandlerRenderedImage.java
index c29684118..4bdd52162 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DImageHandlerRenderedImage.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DImageHandlerRenderedImage.java
@@ -27,6 +27,7 @@ import java.awt.image.RenderedImage;
import java.awt.image.WritableRaster;
import java.io.IOException;
+import org.apache.xmlgraphics.image.GraphicsConstants;
import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.ImageInfo;
@@ -76,7 +77,7 @@ public class Java2DImageHandlerRenderedImage implements ImageHandler {
//scaling because of image resolution
//float sourceResolution = java2dContext.getUserAgent().getSourceResolution();
//source resolution seems to be a bad idea, not sure why
- float sourceResolution = 72;
+ float sourceResolution = GraphicsConstants.DEFAULT_DPI;
sourceResolution *= 1000; //we're working in the millipoint area
sx *= sourceResolution / info.getSize().getDpiHorizontal();
sy *= sourceResolution / info.getSize().getDpiVertical();
diff --git a/src/java/org/apache/fop/render/java2d/Java2DPainter.java b/src/java/org/apache/fop/render/java2d/Java2DPainter.java
index a2b9c9613..396645768 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DPainter.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DPainter.java
@@ -33,9 +33,6 @@ import java.util.Stack;
import org.w3c.dom.Document;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontTriplet;
@@ -54,9 +51,6 @@ import org.apache.fop.util.CharUtilities;
*/
public class Java2DPainter extends AbstractIFPainter {
- /** logging instance */
- private static Log log = LogFactory.getLog(Java2DPainter.class);
-
/** the IF context */
protected IFContext ifContext;
diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
index 4cb0c988e..353aefa25 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
@@ -53,6 +53,7 @@ import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
import org.apache.xmlgraphics.image.loader.util.ImageUtil;
+import org.apache.xmlgraphics.util.UnitConv;
import org.apache.fop.ResourceEventProducer;
import org.apache.fop.apps.FOPException;
@@ -317,10 +318,10 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
}
scaleX = scaleX
- * (25.4f / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
+ * (UnitConv.IN2MM / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
/ userAgent.getTargetPixelUnitToMillimeter();
scaleY = scaleY
- * (25.4f / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
+ * (UnitConv.IN2MM / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
/ userAgent.getTargetPixelUnitToMillimeter();
int bitmapWidth = (int) ((pageWidth * scaleX) + 0.5);
int bitmapHeight = (int) ((pageHeight * scaleY) + 0.5);
@@ -536,7 +537,8 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
}
/** {@inheritDoc} */
- protected void drawBorderLine(float x1, float y1, float x2, float y2,
+ protected void drawBorderLine( // CSOK: ParameterNumber
+ float x1, float y1, float x2, float y2,
boolean horz, boolean startOrBefore, int style, Color col) {
Graphics2D g2d = state.getGraph();
float width = x2 - x1;
diff --git a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
index de987af25..4c20a8959 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
@@ -81,16 +81,17 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler
*/
public static class Java2DInfo {
/** see Java2D_STATE */
- public Java2DGraphicsState state;
+ public Java2DGraphicsState state; // CSOK: VisibilityModifier
/** see Java2D_WIDTH */
- public int width;
+ public int width; // CSOK: VisibilityModifier
/** see Java2D_HEIGHT */
- public int height;
+ public int height; // CSOK: VisibilityModifier
/** see Java2D_XPOS */
- public int currentXPosition;
+ public int currentXPosition; // CSOK: VisibilityModifier
/** see Java2D_YPOS */
- public int currentYPosition;
- public boolean paintAsBitmap;
+ public int currentYPosition; // CSOK: VisibilityModifier
+ /** paint as bitmap */
+ public boolean paintAsBitmap; // CSOK: VisibilityModifier
/** {@inheritDoc} */
public String toString() {
diff --git a/src/java/org/apache/fop/render/java2d/Java2DUtil.java b/src/java/org/apache/fop/render/java2d/Java2DUtil.java
index aa2be78e0..7e11ab263 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DUtil.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DUtil.java
@@ -30,7 +30,10 @@ import org.apache.fop.fonts.FontManager;
/**
* Rendering-related utilities for Java2D.
*/
-public class Java2DUtil {
+public final class Java2DUtil {
+
+ private Java2DUtil() {
+ }
/**
* Builds a default {@link FontInfo} object for use with output formats using the Java2D
diff --git a/src/java/org/apache/fop/render/pcl/HardcodedFonts.java b/src/java/org/apache/fop/render/pcl/HardcodedFonts.java
index a1c5a6059..185e1ece5 100644
--- a/src/java/org/apache/fop/render/pcl/HardcodedFonts.java
+++ b/src/java/org/apache/fop/render/pcl/HardcodedFonts.java
@@ -28,10 +28,13 @@ import org.apache.commons.logging.LogFactory;
* This class hold code for selecting a set of hard-coded fonts available in practically all
* PCL implementations. We hope this can be improved in the future.
*/
-class HardcodedFonts {
+final class HardcodedFonts {
+
+ private HardcodedFonts() {
+ }
/** logging instance */
- private static Log log = LogFactory.getLog(HardcodedFonts.class);
+ private static final Log LOG = LogFactory.getLog(HardcodedFonts.class);
/**
* Sets the current font (NOTE: Hard-coded font mappings ATM!)
@@ -58,7 +61,7 @@ class HardcodedFonts {
try {
fontcode = Integer.parseInt(name.substring(1));
} catch (Exception e) {
- log.error(e);
+ LOG.error(e);
}
}
//Note "(ON" selects ISO 8859-1 symbol set as used by PCLGenerator
diff --git a/src/java/org/apache/fop/render/pcl/PCLEventProducer.java b/src/java/org/apache/fop/render/pcl/PCLEventProducer.java
index 8afe0bb94..520c63baa 100644
--- a/src/java/org/apache/fop/render/pcl/PCLEventProducer.java
+++ b/src/java/org/apache/fop/render/pcl/PCLEventProducer.java
@@ -28,7 +28,10 @@ import org.apache.fop.events.EventProducer;
public interface PCLEventProducer extends EventProducer {
/** Provider class for the event producer. */
- class Provider {
+ final class Provider {
+
+ private Provider() {
+ }
/**
* Returns an event producer.
diff --git a/src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java b/src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java
deleted file mode 100644
index f8c9682e9..000000000
--- a/src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.pcl;
-
-import java.awt.Dimension;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-
-import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.xmlgraphics.java2d.GraphicContext;
-import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
-
-import org.apache.fop.render.AbstractGraphics2DAdapter;
-import org.apache.fop.render.RendererContext;
-import org.apache.xmlgraphics.util.UnitConv;
-
-/**
- * Graphics2DAdapter implementation for PCL and HP GL/2.
- */
-public class PCLGraphics2DAdapter extends AbstractGraphics2DAdapter {
-
- /** logging instance */
- private static Log log = LogFactory.getLog(PCLGraphics2DAdapter.class);
-
- /**
- * Main constructor
- */
- public PCLGraphics2DAdapter() {
- }
-
- /** {@inheritDoc} */
- public void paintImage(Graphics2DImagePainter painter,
- RendererContext context,
- int x, int y, int width, int height) throws IOException {
- PCLRendererContext pclContext = PCLRendererContext.wrapRendererContext(context);
- PCLRenderer pcl = (PCLRenderer)context.getRenderer();
- PCLGenerator gen = pcl.gen;
-
- // get the 'width' and 'height' attributes of the image/document
- Dimension dim = painter.getImageSize();
- float imw = (float)dim.getWidth();
- float imh = (float)dim.getHeight();
-
- boolean painted = false;
- boolean paintAsBitmap = pclContext.paintAsBitmap();
- if (!paintAsBitmap) {
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- PCLGenerator tempGen = new PCLGenerator(baout, gen.getMaximumBitmapResolution());
- try {
- GraphicContext ctx = (GraphicContext)pcl.getGraphicContext().clone();
-
- AffineTransform prepareHPGL2 = new AffineTransform();
- prepareHPGL2.scale(0.001, 0.001);
- ctx.setTransform(prepareHPGL2);
-
- PCLGraphics2D graphics = new PCLGraphics2D(tempGen);
- graphics.setGraphicContext(ctx);
- graphics.setClippingDisabled(pclContext.isClippingDisabled());
- Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh);
- painter.paint(graphics, area);
-
- //If we arrive here, the graphic is natively paintable, so write the graphic
- pcl.saveGraphicsState();
- pcl.setCursorPos(x, y);
- gen.writeCommand("*c" + gen.formatDouble4(width / 100f) + "x"
- + gen.formatDouble4(height / 100f) + "Y");
- gen.writeCommand("*c0T");
- gen.enterHPGL2Mode(false);
- gen.writeText("\nIN;");
- gen.writeText("SP1;");
- //One Plotter unit is 0.025mm!
- double scale = imw / UnitConv.mm2pt(imw * 0.025);
- gen.writeText("SC0," + gen.formatDouble4(scale)
- + ",0,-" + gen.formatDouble4(scale) + ",2;");
- gen.writeText("IR0,100,0,100;");
- gen.writeText("PU;PA0,0;\n");
- baout.writeTo(gen.getOutputStream()); //Buffer is written to output stream
- gen.writeText("\n");
-
- gen.enterPCLMode(false);
- pcl.restoreGraphicsState();
- painted = true;
- } catch (UnsupportedOperationException uoe) {
- log.debug(
- "Cannot paint graphic natively. Falling back to bitmap painting. Reason: "
- + uoe.getMessage());
- }
- }
-
- if (!painted) {
- //Fallback solution: Paint to a BufferedImage
- int resolution = Math.round(context.getUserAgent().getTargetResolution());
- BufferedImage bi = paintToBufferedImage(painter, pclContext,
- resolution, !pclContext.isColorCanvas(), false);
-
- pcl.setCursorPos(x, y);
- gen.paintBitmap(bi, new Dimension(width, height), pclContext.isSourceTransparency());
- }
- }
-
-}
diff --git a/src/java/org/apache/fop/render/pcl/PCLPainter.java b/src/java/org/apache/fop/render/pcl/PCLPainter.java
index b58b7f495..afae8ac27 100644
--- a/src/java/org/apache/fop/render/pcl/PCLPainter.java
+++ b/src/java/org/apache/fop/render/pcl/PCLPainter.java
@@ -34,9 +34,6 @@ import java.util.Stack;
import org.w3c.dom.Document;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import org.apache.xmlgraphics.image.loader.ImageException;
import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.ImageProcessingHints;
@@ -65,9 +62,6 @@ import org.apache.fop.util.CharUtilities;
*/
public class PCLPainter extends AbstractIFPainter implements PCLConstants {
- /** logging instance */
- private static Log log = LogFactory.getLog(PCLPainter.class);
-
private static final boolean DEBUG = false;
private PCLDocumentHandler parent;
@@ -396,7 +390,8 @@ public class PCLPainter extends AbstractIFPainter implements PCLConstants {
private static final double SAFETY_MARGIN_FACTOR = 0.05;
- private Rectangle getTextBoundingBox(int x, int y,
+ private Rectangle getTextBoundingBox( // CSOK: ParameterNumber
+ int x, int y,
int letterSpacing, int wordSpacing, int[] dx,
String text,
Font font, FontMetricsMapper metrics) {
diff --git a/src/java/org/apache/fop/render/pcl/PCLRenderer.java b/src/java/org/apache/fop/render/pcl/PCLRenderer.java
deleted file mode 100644
index 831dc99b4..000000000
--- a/src/java/org/apache/fop/render/pcl/PCLRenderer.java
+++ /dev/null
@@ -1,1514 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.pcl;
-
-//Java
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.GeneralPath;
-import java.awt.geom.Line2D;
-import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.RenderedImage;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.List;
-import java.util.Map;
-import java.util.Stack;
-
-import org.w3c.dom.Document;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.xmlgraphics.image.loader.ImageException;
-import org.apache.xmlgraphics.image.loader.ImageFlavor;
-import org.apache.xmlgraphics.image.loader.ImageInfo;
-import org.apache.xmlgraphics.image.loader.ImageManager;
-import org.apache.xmlgraphics.image.loader.ImageSessionContext;
-import org.apache.xmlgraphics.image.loader.ImageSize;
-import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
-import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
-import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
-import org.apache.xmlgraphics.image.loader.util.ImageUtil;
-import org.apache.xmlgraphics.java2d.GraphicContext;
-import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
-import org.apache.xmlgraphics.util.UnitConv;
-
-import org.apache.fop.ResourceEventProducer;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.area.Area;
-import org.apache.fop.area.Block;
-import org.apache.fop.area.BlockViewport;
-import org.apache.fop.area.CTM;
-import org.apache.fop.area.NormalFlow;
-import org.apache.fop.area.PageViewport;
-import org.apache.fop.area.RegionViewport;
-import org.apache.fop.area.Trait;
-import org.apache.fop.area.inline.AbstractTextArea;
-import org.apache.fop.area.inline.ForeignObject;
-import org.apache.fop.area.inline.Image;
-import org.apache.fop.area.inline.InlineArea;
-import org.apache.fop.area.inline.Leader;
-import org.apache.fop.area.inline.SpaceArea;
-import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.area.inline.Viewport;
-import org.apache.fop.area.inline.WordArea;
-import org.apache.fop.datatypes.URISpecification;
-import org.apache.fop.fonts.Font;
-import org.apache.fop.fonts.FontCollection;
-import org.apache.fop.fonts.FontInfo;
-import org.apache.fop.fonts.FontMetrics;
-import org.apache.fop.render.Graphics2DAdapter;
-import org.apache.fop.render.ImageHandlerUtil;
-import org.apache.fop.render.PrintRenderer;
-import org.apache.fop.render.RendererContext;
-import org.apache.fop.render.RendererContextConstants;
-import org.apache.fop.render.RendererEventProducer;
-import org.apache.fop.render.java2d.Base14FontCollection;
-import org.apache.fop.render.java2d.ConfiguredFontCollection;
-import org.apache.fop.render.java2d.FontMetricsMapper;
-import org.apache.fop.render.java2d.InstalledFontCollection;
-import org.apache.fop.render.java2d.Java2DFontMetrics;
-import org.apache.fop.render.java2d.Java2DRenderer;
-import org.apache.fop.render.pcl.extensions.PCLElementMapping;
-import org.apache.fop.traits.BorderProps;
-
-/* Note:
- * There are some commonalities with AbstractPathOrientedRenderer but it's not possible
- * to derive from it due to PCL's restrictions. We may need an additional common subclass to
- * avoid methods copied from AbstractPathOrientedRenderer. Or we wait until after the IF redesign.
- */
-
-/**
- * Renderer for the PCL 5 printer language. It also uses HP GL/2 for certain graphic elements.
- */
-public class PCLRenderer extends PrintRenderer implements PCLConstants {
-
- /** logging instance */
- private static Log log = LogFactory.getLog(PCLRenderer.class);
-
- /** The MIME type for PCL */
- public static final String MIME_TYPE = MimeConstants.MIME_PCL_ALT;
-
- /** The OutputStream to write the PCL stream to */
- protected OutputStream out;
-
- /** The PCL generator */
- protected PCLGenerator gen;
- private boolean ioTrouble = false;
-
- private final Stack graphicContextStack = new Stack();
- private GraphicContext graphicContext = new GraphicContext();
-
- private PCLPageDefinition currentPageDefinition;
- private int currentPrintDirection = 0;
- private GeneralPath currentPath = null;
- private java.awt.Color currentFillColor = null;
-
- /**
- * Utility class which enables all sorts of features that are not directly connected to the
- * normal rendering process.
- */
- private PCLRenderingUtil pclUtil;
-
- /** contains the pageWith of the last printed page */
- private long pageWidth = 0;
- /** contains the pageHeight of the last printed page */
- private long pageHeight = 0;
-
- /**
- * Create the PCL renderer
- */
- public PCLRenderer() {
- }
-
- /** {@inheritDoc} */
- public void setUserAgent(FOUserAgent agent) {
- super.setUserAgent(agent);
- this.pclUtil = new PCLRenderingUtil(getUserAgent());
- }
-
- PCLRenderingUtil getPCLUtil() {
- return this.pclUtil;
- }
-
- /**
- * Configures the renderer to trade speed for quality if desired. One example here is the way
- * that borders are rendered.
- * @param qualityBeforeSpeed true if quality is more important than speed
- */
- public void setQualityBeforeSpeed(boolean qualityBeforeSpeed) {
- pclUtil.setRenderingMode(qualityBeforeSpeed
- ? PCLRenderingMode.QUALITY : PCLRenderingMode.SPEED);
- }
-
- /**
- * Controls whether PJL commands shall be generated by the PCL renderer.
- * @param disable true to disable PJL commands
- */
- public void setPJLDisabled(boolean disable) {
- pclUtil.setPJLDisabled(disable);
- }
-
- /**
- * Indicates whether PJL generation is disabled.
- * @return true if PJL generation is disabled.
- */
- public boolean isPJLDisabled() {
- return pclUtil.isPJLDisabled();
- }
-
- /**
- * Controls whether all text should be generated as bitmaps or only text for which there's
- * no native font.
- * @param allTextAsBitmaps true if all text should be painted as bitmaps
- */
- public void setAllTextAsBitmaps(boolean allTextAsBitmaps) {
- pclUtil.setAllTextAsBitmaps(allTextAsBitmaps);
- }
-
- /**
- * {@inheritDoc}
- */
- public void setupFontInfo(FontInfo inFontInfo) {
- //Don't call super.setupFontInfo() here!
- //The PCLRenderer uses the Java2D FontSetup which needs a special font setup
- //create a temp Image to test font metrics on
- fontInfo = inFontInfo;
- Graphics2D graphics2D = Java2DFontMetrics.createFontMetricsGraphics2D();
-
- FontCollection[] fontCollections = new FontCollection[] {
- new Base14FontCollection(graphics2D),
- new InstalledFontCollection(graphics2D),
- new ConfiguredFontCollection(getFontResolver(), getFontList())
- };
- userAgent.getFactory().getFontManager().setup(
- getFontInfo(), fontCollections);
- }
-
- /**
- * Central exception handler for I/O exceptions.
- * @param ioe IOException to handle
- */
- protected void handleIOTrouble(IOException ioe) {
- if (!ioTrouble) {
- RendererEventProducer eventProducer = RendererEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.ioError(this, ioe);
- ioTrouble = true;
- }
- }
-
- /** {@inheritDoc} */
- public Graphics2DAdapter getGraphics2DAdapter() {
- return new PCLGraphics2DAdapter();
- }
-
- /** @return the GraphicContext used to track coordinate system transformations */
- public GraphicContext getGraphicContext() {
- return this.graphicContext;
- }
-
- /** @return the target resolution */
- protected int getResolution() {
- int resolution = Math.round(userAgent.getTargetResolution());
- if (resolution <= 300) {
- return 300;
- } else {
- return 600;
- }
- }
-
- /** {@inheritDoc} */
- public void startRenderer(OutputStream outputStream) throws IOException {
- log.debug("Rendering areas to PCL...");
- this.out = outputStream;
- this.gen = new PCLGenerator(out, getResolution());
-
- if (!isPJLDisabled()) {
- gen.universalEndOfLanguage();
- gen.writeText("@PJL COMMENT Produced by " + userAgent.getProducer() + "\n");
- if (userAgent.getTitle() != null) {
- gen.writeText("@PJL JOB NAME = \"" + userAgent.getTitle() + "\"\n");
- }
- gen.writeText("@PJL SET RESOLUTION = " + getResolution() + "\n");
- gen.writeText("@PJL ENTER LANGUAGE = PCL\n");
- }
- gen.resetPrinter();
- gen.setUnitOfMeasure(getResolution());
- gen.setRasterGraphicsResolution(getResolution());
- }
-
- /** {@inheritDoc} */
- public void stopRenderer() throws IOException {
- gen.separateJobs();
- gen.resetPrinter();
- if (!isPJLDisabled()) {
- gen.universalEndOfLanguage();
- }
- }
-
- /** {@inheritDoc} */
- public String getMimeType() {
- return MIME_TYPE;
- }
-
- /** {@inheritDoc} */
- public void renderPage(PageViewport page) throws IOException, FOPException {
- saveGraphicsState();
-
- //Paper source
- String paperSource = page.getForeignAttributeValue(PCLElementMapping.PCL_PAPER_SOURCE);
- if (paperSource != null) {
- gen.selectPaperSource(Integer.parseInt(paperSource));
- }
-
- //Output bin
- String outputBin = page.getForeignAttributeValue(PCLElementMapping.PCL_OUTPUT_BIN);
- if (outputBin != null) {
- gen.selectOutputBin(Integer.parseInt(outputBin));
- }
-
- // Is Page duplex?
- String pageDuplex = page.getForeignAttributeValue(PCLElementMapping.PCL_DUPLEX_MODE);
- if (pageDuplex != null) {
- gen.selectDuplexMode(Integer.parseInt(pageDuplex));
- }
-
- //Page size
- final long pagewidth = Math.round(page.getViewArea().getWidth());
- final long pageheight = Math.round(page.getViewArea().getHeight());
- selectPageFormat(pagewidth, pageheight);
-
- super.renderPage(page);
-
- //Eject page
- gen.formFeed();
- restoreGraphicsState();
- }
-
- private void selectPageFormat(long pagewidth, long pageheight) throws IOException {
- //Only set the page format if it changes (otherwise duplex printing won't work)
- if ((pagewidth != this.pageWidth) || (pageheight != this.pageHeight)) {
- this.pageWidth = pagewidth;
- this.pageHeight = pageheight;
-
- this.currentPageDefinition = PCLPageDefinition.getPageDefinition(
- pagewidth, pageheight, 1000);
-
- if (this.currentPageDefinition == null) {
- this.currentPageDefinition = PCLPageDefinition.getDefaultPageDefinition();
- log.warn("Paper type could not be determined. Falling back to: "
- + this.currentPageDefinition.getName());
- }
- if (log.isDebugEnabled()) {
- log.debug("page size: " + currentPageDefinition.getPhysicalPageSize());
- log.debug("logical page: " + currentPageDefinition.getLogicalPageRect());
- }
-
- if (this.currentPageDefinition.isLandscapeFormat()) {
- gen.writeCommand("&l1O"); //Landscape Orientation
- } else {
- gen.writeCommand("&l0O"); //Portrait Orientation
- }
- gen.selectPageSize(this.currentPageDefinition.getSelector());
-
- gen.clearHorizontalMargins();
- gen.setTopMargin(0);
- }
- }
-
- /** Saves the current graphics state on the stack. */
- protected void saveGraphicsState() {
- graphicContextStack.push(graphicContext);
- graphicContext = (GraphicContext)graphicContext.clone();
- }
-
- /** Restores the last graphics state from the stack. */
- protected void restoreGraphicsState() {
- graphicContext = (GraphicContext)graphicContextStack.pop();
- }
-
- /**
- * Clip an area. write a clipping operation given coordinates in the current
- * transform. Coordinates are in points.
- *
- * @param x the x coordinate
- * @param y the y coordinate
- * @param width the width of the area
- * @param height the height of the area
- */
- protected void clipRect(float x, float y, float width, float height) {
- //PCL cannot clip (only HP GL/2 can)
- }
-
- private Point2D transformedPoint(float x, float y) {
- return transformedPoint(Math.round(x), Math.round(y));
- }
-
- private Point2D transformedPoint(int x, int y) {
- return PCLRenderingUtil.transformedPoint(x, y, graphicContext.getTransform(),
- currentPageDefinition, currentPrintDirection);
- }
-
- private void changePrintDirection() {
- AffineTransform at = graphicContext.getTransform();
- int newDir;
- try {
- newDir = PCLRenderingUtil.determinePrintDirection(at);
- if (newDir != this.currentPrintDirection) {
- this.currentPrintDirection = newDir;
- gen.changePrintDirection(this.currentPrintDirection);
- }
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected void startVParea(CTM ctm, Rectangle2D clippingRect) {
- saveGraphicsState();
- AffineTransform at = new AffineTransform(ctm.toArray());
- graphicContext.transform(at);
- changePrintDirection();
- if (log.isDebugEnabled()) {
- log.debug("startVPArea: " + at + " --> " + graphicContext.getTransform());
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected void endVParea() {
- restoreGraphicsState();
- changePrintDirection();
- if (log.isDebugEnabled()) {
- log.debug("endVPArea() --> " + graphicContext.getTransform());
- }
- }
-
- /**
- * Handle block traits.
- * The block could be any sort of block with any positioning
- * so this should render the traits such as border and background
- * in its position.
- *
- * @param block the block to render the traits
- */
- protected void handleBlockTraits(Block block) {
- int borderPaddingStart = block.getBorderAndPaddingWidthStart();
- int borderPaddingBefore = block.getBorderAndPaddingWidthBefore();
-
- float startx = currentIPPosition / 1000f;
- float starty = currentBPPosition / 1000f;
- float width = block.getIPD() / 1000f;
- float height = block.getBPD() / 1000f;
-
- startx += block.getStartIndent() / 1000f;
- startx -= block.getBorderAndPaddingWidthStart() / 1000f;
-
- width += borderPaddingStart / 1000f;
- width += block.getBorderAndPaddingWidthEnd() / 1000f;
- height += borderPaddingBefore / 1000f;
- height += block.getBorderAndPaddingWidthAfter() / 1000f;
-
- drawBackAndBorders(block, startx, starty, width, height);
- }
-
- /**
- * {@inheritDoc}
- * @todo Copied from AbstractPathOrientedRenderer
- */
- protected void handleRegionTraits(RegionViewport region) {
- Rectangle2D viewArea = region.getViewArea();
- float startx = (float)(viewArea.getX() / 1000f);
- float starty = (float)(viewArea.getY() / 1000f);
- float width = (float)(viewArea.getWidth() / 1000f);
- float height = (float)(viewArea.getHeight() / 1000f);
-
- if (region.getRegionReference().getRegionClass() == FO_REGION_BODY) {
- currentBPPosition = region.getBorderAndPaddingWidthBefore();
- currentIPPosition = region.getBorderAndPaddingWidthStart();
- }
- drawBackAndBorders(region, startx, starty, width, height);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void renderText(final TextArea text) {
- renderInlineAreaBackAndBorders(text);
-
- String fontname = getInternalFontNameForArea(text);
- final int fontsize = text.getTraitAsInteger(Trait.FONT_SIZE);
-
- //Determine position
- int saveIP = currentIPPosition;
- final int rx = currentIPPosition + text.getBorderAndPaddingWidthStart();
- int bl = currentBPPosition + text.getOffset() + text.getBaselineOffset();
-
- try {
-
- final Color col = (Color)text.getTrait(Trait.COLOR);
- boolean pclFont = pclUtil.isAllTextAsBitmaps()
- ? false
- : HardcodedFonts.setFont(gen, fontname, fontsize, text.getText());
- if (pclFont) {
- //this.currentFill = col;
- if (col != null) {
- //useColor(ct);
- gen.setTransparencyMode(true, false);
- gen.selectGrayscale(col);
- }
-
- saveGraphicsState();
- graphicContext.translate(rx, bl);
- setCursorPos(0, 0);
- gen.setTransparencyMode(true, true);
- if (text.hasUnderline()) {
- gen.writeCommand("&d0D");
- }
- super.renderText(text); //Updates IPD and renders words and spaces
- if (text.hasUnderline()) {
- gen.writeCommand("&d@");
- }
- restoreGraphicsState();
- } else {
- //Use Java2D to paint different fonts via bitmap
- final Font font = getFontFromArea(text);
- final int baseline = text.getBaselineOffset();
-
- //for cursive fonts, so the text isn't clipped
- int extraWidth = font.getFontSize() / 3;
- final FontMetricsMapper mapper = (FontMetricsMapper)fontInfo.getMetricsFor(
- font.getFontName());
- int maxAscent = mapper.getMaxAscent(font.getFontSize()) / 1000;
- final int additionalBPD = maxAscent - baseline;
-
- Graphics2DAdapter g2a = getGraphics2DAdapter();
- final Rectangle paintRect = new Rectangle(
- rx, currentBPPosition + text.getOffset() - additionalBPD,
- text.getIPD() + extraWidth, text.getBPD() + additionalBPD);
- RendererContext rc = createRendererContext(paintRect.x, paintRect.y,
- paintRect.width, paintRect.height, null);
- Map atts = new java.util.HashMap();
- atts.put(ImageHandlerUtil.CONVERSION_MODE, ImageHandlerUtil.CONVERSION_MODE_BITMAP);
- atts.put(SRC_TRANSPARENCY, "true");
- rc.setProperty(RendererContextConstants.FOREIGN_ATTRIBUTES, atts);
-
- Graphics2DImagePainter painter = new Graphics2DImagePainter() {
-
- public void paint(Graphics2D g2d, Rectangle2D area) {
- g2d.setFont(mapper.getFont(font.getFontSize()));
- g2d.translate(0, baseline + additionalBPD);
- g2d.scale(1000, 1000);
- g2d.setColor(col);
- Java2DRenderer.renderText(text, g2d, font);
- renderTextDecoration(g2d, mapper, fontsize, text, 0, 0);
- }
-
- public Dimension getImageSize() {
- return paintRect.getSize();
- }
-
- };
- g2a.paintImage(painter, rc,
- paintRect.x, paintRect.y, paintRect.width, paintRect.height);
- currentIPPosition = saveIP + text.getAllocIPD();
- }
-
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- /**
- * Paints the text decoration marks.
- * @param g2d Graphics2D instance to paint to
- * @param fm Current typeface
- * @param fontsize Current font size
- * @param inline inline area to paint the marks for
- * @param baseline position of the baseline
- * @param startx start IPD
- */
- private static void renderTextDecoration(Graphics2D g2d,
- FontMetrics fm, int fontsize, InlineArea inline,
- int baseline, int startx) {
- boolean hasTextDeco = inline.hasUnderline()
- || inline.hasOverline()
- || inline.hasLineThrough();
- if (hasTextDeco) {
- float descender = fm.getDescender(fontsize) / 1000f;
- float capHeight = fm.getCapHeight(fontsize) / 1000f;
- float lineWidth = (descender / -4f) / 1000f;
- float endx = (startx + inline.getIPD()) / 1000f;
- if (inline.hasUnderline()) {
- Color ct = (Color) inline.getTrait(Trait.UNDERLINE_COLOR);
- g2d.setColor(ct);
- float y = baseline - descender / 2f;
- g2d.setStroke(new BasicStroke(lineWidth));
- g2d.draw(new Line2D.Float(startx / 1000f, y / 1000f,
- endx, y / 1000f));
- }
- if (inline.hasOverline()) {
- Color ct = (Color) inline.getTrait(Trait.OVERLINE_COLOR);
- g2d.setColor(ct);
- float y = (float)(baseline - (1.1 * capHeight));
- g2d.setStroke(new BasicStroke(lineWidth));
- g2d.draw(new Line2D.Float(startx / 1000f, y / 1000f,
- endx, y / 1000f));
- }
- if (inline.hasLineThrough()) {
- Color ct = (Color) inline.getTrait(Trait.LINETHROUGH_COLOR);
- g2d.setColor(ct);
- float y = (float)(baseline - (0.45 * capHeight));
- g2d.setStroke(new BasicStroke(lineWidth));
- g2d.draw(new Line2D.Float(startx / 1000f, y / 1000f,
- endx, y / 1000f));
- }
- }
- }
-
- /**
- * Sets the current cursor position. The coordinates are transformed to the absolute position
- * on the logical PCL page and then passed on to the PCLGenerator.
- * @param x the x coordinate (in millipoints)
- * @param y the y coordinate (in millipoints)
- */
- void setCursorPos(float x, float y) {
- try {
- Point2D transPoint = transformedPoint(x, y);
- gen.setCursorPos(transPoint.getX(), transPoint.getY());
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- /** Clip using the current path. */
- protected void clip() {
- if (currentPath == null) {
- throw new IllegalStateException("No current path available!");
- }
- //TODO Find a good way to do clipping. PCL itself cannot clip.
- currentPath = null;
- }
-
- /**
- * Closes the current subpath by appending a straight line segment from
- * the current point to the starting point of the subpath.
- */
- protected void closePath() {
- currentPath.closePath();
- }
-
- /**
- * Appends a straight line segment from the current point to (x, y). The
- * new current point is (x, y).
- * @param x x coordinate
- * @param y y coordinate
- */
- protected void lineTo(float x, float y) {
- if (currentPath == null) {
- currentPath = new GeneralPath();
- }
- currentPath.lineTo(x, y);
- }
-
- /**
- * Moves the current point to (x, y), omitting any connecting line segment.
- * @param x x coordinate
- * @param y y coordinate
- */
- protected void moveTo(float x, float y) {
- if (currentPath == null) {
- currentPath = new GeneralPath();
- }
- currentPath.moveTo(x, y);
- }
-
- /**
- * Fill a rectangular area.
- * @param x the x coordinate (in pt)
- * @param y the y coordinate (in pt)
- * @param width the width of the rectangle
- * @param height the height of the rectangle
- */
- protected void fillRect(float x, float y, float width, float height) {
- try {
- setCursorPos(x * 1000, y * 1000);
- gen.fillRect((int)(width * 1000), (int)(height * 1000),
- this.currentFillColor);
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- /**
- * Sets the new current fill color.
- * @param color the color
- */
- protected void updateFillColor(java.awt.Color color) {
- this.currentFillColor = color;
- }
-
- /**
- * {@inheritDoc}
- */
- protected void renderWord(WordArea word) {
- //Font font = getFontFromArea(word.getParentArea());
-
- String s = word.getWord();
-
- try {
- gen.writeText(s);
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
-
- super.renderWord(word);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void renderSpace(SpaceArea space) {
- AbstractTextArea textArea = (AbstractTextArea)space.getParentArea();
- String s = space.getSpace();
- char sp = s.charAt(0);
- Font font = getFontFromArea(textArea);
-
- int tws = (space.isAdjustable()
- ? textArea.getTextWordSpaceAdjust()
- + 2 * textArea.getTextLetterSpaceAdjust()
- : 0);
-
- double dx = (font.getCharWidth(sp) + tws) / 100f;
- try {
- gen.writeCommand("&a+" + gen.formatDouble2(dx) + "H");
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- super.renderSpace(space);
- }
-
- /**
- * Render an inline viewport.
- * This renders an inline viewport by clipping if necessary.
- * @param viewport the viewport to handle
- * @todo Copied from AbstractPathOrientedRenderer
- */
- public void renderViewport(Viewport viewport) {
-
- float x = currentIPPosition / 1000f;
- float y = (currentBPPosition + viewport.getOffset()) / 1000f;
- float width = viewport.getIPD() / 1000f;
- float height = viewport.getBPD() / 1000f;
- // TODO: Calculate the border rect correctly.
- float borderPaddingStart = viewport.getBorderAndPaddingWidthStart() / 1000f;
- float borderPaddingBefore = viewport.getBorderAndPaddingWidthBefore() / 1000f;
- float bpwidth = borderPaddingStart
- + (viewport.getBorderAndPaddingWidthEnd() / 1000f);
- float bpheight = borderPaddingBefore
- + (viewport.getBorderAndPaddingWidthAfter() / 1000f);
-
- drawBackAndBorders(viewport, x, y, width + bpwidth, height + bpheight);
-
- if (viewport.getClip()) {
- saveGraphicsState();
-
- clipRect(x + borderPaddingStart, y + borderPaddingBefore, width, height);
- }
- super.renderViewport(viewport);
-
- if (viewport.getClip()) {
- restoreGraphicsState();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected void renderBlockViewport(BlockViewport bv, List children) {
- // clip and position viewport if necessary
-
- // save positions
- int saveIP = currentIPPosition;
- int saveBP = currentBPPosition;
-
- CTM ctm = bv.getCTM();
- int borderPaddingStart = bv.getBorderAndPaddingWidthStart();
- int borderPaddingBefore = bv.getBorderAndPaddingWidthBefore();
- //This is the content-rect
- float width = bv.getIPD() / 1000f;
- float height = bv.getBPD() / 1000f;
-
-
- if (bv.getPositioning() == Block.ABSOLUTE
- || bv.getPositioning() == Block.FIXED) {
-
- //For FIXED, we need to break out of the current viewports to the
- //one established by the page. We save the state stack for restoration
- //after the block-container has been painted. See below.
- List breakOutList = null;
- if (bv.getPositioning() == Block.FIXED) {
- breakOutList = breakOutOfStateStack();
- }
-
- AffineTransform positionTransform = new AffineTransform();
- positionTransform.translate(bv.getXOffset(), bv.getYOffset());
-
- //"left/"top" (bv.getX/YOffset()) specify the position of the content rectangle
- positionTransform.translate(-borderPaddingStart, -borderPaddingBefore);
-
- saveGraphicsState();
- //Viewport position
- concatenateTransformationMatrix(UnitConv.mptToPt(positionTransform));
-
- //Background and borders
- float bpwidth = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f;
- float bpheight = (borderPaddingBefore + bv.getBorderAndPaddingWidthAfter()) / 1000f;
- drawBackAndBorders(bv, 0, 0, width + bpwidth, height + bpheight);
-
- //Shift to content rectangle after border painting
- AffineTransform contentRectTransform = new AffineTransform();
- contentRectTransform.translate(borderPaddingStart, borderPaddingBefore);
- concatenateTransformationMatrix(UnitConv.mptToPt(contentRectTransform));
-
- //Clipping
- if (bv.getClip()) {
- clipRect(0f, 0f, width, height);
- }
-
- saveGraphicsState();
- //Set up coordinate system for content rectangle
- AffineTransform contentTransform = ctm.toAffineTransform();
- concatenateTransformationMatrix(UnitConv.mptToPt(contentTransform));
-
- currentIPPosition = 0;
- currentBPPosition = 0;
- renderBlocks(bv, children);
-
- restoreGraphicsState();
- restoreGraphicsState();
-
- if (breakOutList != null) {
- restoreStateStackAfterBreakOut(breakOutList);
- }
-
- currentIPPosition = saveIP;
- currentBPPosition = saveBP;
- } else {
-
- currentBPPosition += bv.getSpaceBefore();
-
- //borders and background in the old coordinate system
- handleBlockTraits(bv);
-
- //Advance to start of content area
- currentIPPosition += bv.getStartIndent();
-
- CTM tempctm = new CTM(containingIPPosition, currentBPPosition);
- ctm = tempctm.multiply(ctm);
-
- //Now adjust for border/padding
- currentBPPosition += borderPaddingBefore;
-
- Rectangle2D clippingRect = null;
- if (bv.getClip()) {
- clippingRect = new Rectangle(currentIPPosition, currentBPPosition,
- bv.getIPD(), bv.getBPD());
- }
-
- startVParea(ctm, clippingRect);
- currentIPPosition = 0;
- currentBPPosition = 0;
- renderBlocks(bv, children);
- endVParea();
-
- currentIPPosition = saveIP;
- currentBPPosition = saveBP;
-
- currentBPPosition += (bv.getAllocBPD());
- }
- //currentFontName = saveFontName;
- }
-
- /** {@inheritDoc} */
- protected void renderReferenceArea(Block block) {
- //TODO This is the same code as in AbstractPathOrientedRenderer
- //So there's some optimization potential but not otherwise PCLRenderer is a little
- //difficult to derive from AbstractPathOrientedRenderer. Maybe an additional layer
- //between PrintRenderer and AbstractPathOrientedRenderer is necessary.
-
- // save position and offset
- int saveIP = currentIPPosition;
- int saveBP = currentBPPosition;
-
- //Establish a new coordinate system
- AffineTransform at = new AffineTransform();
- at.translate(currentIPPosition, currentBPPosition);
- at.translate(block.getXOffset(), block.getYOffset());
- at.translate(0, block.getSpaceBefore());
-
- if (!at.isIdentity()) {
- saveGraphicsState();
- concatenateTransformationMatrix(UnitConv.mptToPt(at));
- }
-
- currentIPPosition = 0;
- currentBPPosition = 0;
- handleBlockTraits(block);
-
- List children = block.getChildAreas();
- if (children != null) {
- renderBlocks(block, children);
- }
-
- if (!at.isIdentity()) {
- restoreGraphicsState();
- }
-
- // stacked and relative blocks effect stacking
- currentIPPosition = saveIP;
- currentBPPosition = saveBP;
- }
-
- /** {@inheritDoc} */
- protected void renderFlow(NormalFlow flow) {
- //TODO This is the same code as in AbstractPathOrientedRenderer
- //So there's some optimization potential but not otherwise PCLRenderer is a little
- //difficult to derive from AbstractPathOrientedRenderer. Maybe an additional layer
- //between PrintRenderer and AbstractPathOrientedRenderer is necessary.
-
- // save position and offset
- int saveIP = currentIPPosition;
- int saveBP = currentBPPosition;
-
- //Establish a new coordinate system
- AffineTransform at = new AffineTransform();
- at.translate(currentIPPosition, currentBPPosition);
-
- if (!at.isIdentity()) {
- saveGraphicsState();
- concatenateTransformationMatrix(UnitConv.mptToPt(at));
- }
-
- currentIPPosition = 0;
- currentBPPosition = 0;
- super.renderFlow(flow);
-
- if (!at.isIdentity()) {
- restoreGraphicsState();
- }
-
- // stacked and relative blocks effect stacking
- currentIPPosition = saveIP;
- currentBPPosition = saveBP;
- }
-
- /**
- * Concatenates the current transformation matrix with the given one, therefore establishing
- * a new coordinate system.
- * @param at the transformation matrix to process (coordinates in points)
- */
- protected void concatenateTransformationMatrix(AffineTransform at) {
- if (!at.isIdentity()) {
- graphicContext.transform(UnitConv.ptToMpt(at));
- changePrintDirection();
- }
- }
-
- private List breakOutOfStateStack() {
- log.debug("Block.FIXED --> break out");
- List breakOutList = new java.util.ArrayList();
- while (!this.graphicContextStack.empty()) {
- breakOutList.add(0, this.graphicContext);
- restoreGraphicsState();
- }
- return breakOutList;
- }
-
- private void restoreStateStackAfterBreakOut(List breakOutList) {
- log.debug("Block.FIXED --> restoring context after break-out");
- for (int i = 0, c = breakOutList.size(); i < c; i++) {
- saveGraphicsState();
- this.graphicContext = (GraphicContext)breakOutList.get(i);
- }
- }
-
- /** {@inheritDoc} */
- protected RendererContext createRendererContext(int x, int y, int width, int height,
- Map foreignAttributes) {
- RendererContext context = super.createRendererContext(
- x, y, width, height, foreignAttributes);
- context.setProperty(PCLRendererContextConstants.PCL_COLOR_CANVAS,
- Boolean.valueOf(pclUtil.isColorCanvasEnabled()));
- return context;
- }
-
- /** {@inheritDoc} */
- public void renderImage(Image image, Rectangle2D pos) {
- drawImage(image.getURL(), pos, image.getForeignAttributes());
- }
-
- private static final ImageFlavor[] FLAVORS = new ImageFlavor[]
- {ImageFlavor.GRAPHICS2D,
- ImageFlavor.BUFFERED_IMAGE,
- ImageFlavor.RENDERED_IMAGE,
- ImageFlavor.XML_DOM};
- /**
- * Draw an image at the indicated location.
- * @param uri the URI/URL of the image
- * @param pos the position of the image
- * @param foreignAttributes an optional Map with foreign attributes, may be null
- */
- protected void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) {
- uri = URISpecification.getURL(uri);
- Rectangle posInt = new Rectangle(
- (int)pos.getX(),
- (int)pos.getY(),
- (int)pos.getWidth(),
- (int)pos.getHeight());
- Point origin = new Point(currentIPPosition, currentBPPosition);
- int x = origin.x + posInt.x;
- int y = origin.y + posInt.y;
-
- ImageManager manager = getUserAgent().getFactory().getImageManager();
- ImageInfo info = null;
- try {
- ImageSessionContext sessionContext = getUserAgent().getImageSessionContext();
- info = manager.getImageInfo(uri, sessionContext);
-
- //Only now fully load/prepare the image
- Map hints = ImageUtil.getDefaultHints(sessionContext);
- org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
- info, FLAVORS, hints, sessionContext);
-
- //...and process the image
- if (img instanceof ImageGraphics2D) {
- ImageGraphics2D imageG2D = (ImageGraphics2D)img;
- RendererContext context = createRendererContext(
- posInt.x, posInt.y,
- posInt.width, posInt.height, foreignAttributes);
- getGraphics2DAdapter().paintImage(imageG2D.getGraphics2DImagePainter(),
- context, x, y, posInt.width, posInt.height);
- } else if (img instanceof ImageRendered) {
- ImageRendered imgRend = (ImageRendered)img;
- RenderedImage ri = imgRend.getRenderedImage();
- setCursorPos(x, y);
- gen.paintBitmap(ri,
- new Dimension(posInt.width, posInt.height),
- false);
- } else if (img instanceof ImageXMLDOM) {
- ImageXMLDOM imgXML = (ImageXMLDOM)img;
- renderDocument(imgXML.getDocument(), imgXML.getRootNamespace(),
- pos, foreignAttributes);
- } else {
- throw new UnsupportedOperationException("Unsupported image type: " + img);
- }
-
- } catch (ImageException ie) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null);
- } catch (FileNotFoundException fe) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.imageNotFound(this, (info != null ? info.toString() : uri), fe, null);
- } catch (IOException ioe) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
- }
- }
-
- /** {@inheritDoc} */
- public void renderForeignObject(ForeignObject fo, Rectangle2D pos) {
- Document doc = fo.getDocument();
- String ns = fo.getNameSpace();
- renderDocument(doc, ns, pos, fo.getForeignAttributes());
- }
-
- /**
- * Common method to render the background and borders for any inline area.
- * The all borders and padding are drawn outside the specified area.
- * @param area the inline area for which the background, border and padding is to be
- * rendered
- * @todo Copied from AbstractPathOrientedRenderer
- */
- protected void renderInlineAreaBackAndBorders(InlineArea area) {
- float x = currentIPPosition / 1000f;
- float y = (currentBPPosition + area.getOffset()) / 1000f;
- float width = area.getIPD() / 1000f;
- float height = area.getBPD() / 1000f;
- float borderPaddingStart = area.getBorderAndPaddingWidthStart() / 1000f;
- float borderPaddingBefore = area.getBorderAndPaddingWidthBefore() / 1000f;
- float bpwidth = borderPaddingStart
- + (area.getBorderAndPaddingWidthEnd() / 1000f);
- float bpheight = borderPaddingBefore
- + (area.getBorderAndPaddingWidthAfter() / 1000f);
-
- if (height != 0.0f || bpheight != 0.0f && bpwidth != 0.0f) {
- drawBackAndBorders(area, x, y - borderPaddingBefore
- , width + bpwidth
- , height + bpheight);
- }
- }
-
- /**
- * Draw the background and borders. This draws the background and border
- * traits for an area given the position.
- *
- * @param area the area whose traits are used
- * @param startx the start x position
- * @param starty the start y position
- * @param width the width of the area
- * @param height the height of the area
- */
- protected void drawBackAndBorders(Area area, float startx, float starty,
- float width, float height) {
- BorderProps bpsBefore = (BorderProps) area.getTrait(Trait.BORDER_BEFORE);
- BorderProps bpsAfter = (BorderProps) area.getTrait(Trait.BORDER_AFTER);
- BorderProps bpsStart = (BorderProps) area.getTrait(Trait.BORDER_START);
- BorderProps bpsEnd = (BorderProps) area.getTrait(Trait.BORDER_END);
-
- // draw background
- Trait.Background back;
- back = (Trait.Background) area.getTrait(Trait.BACKGROUND);
- if (back != null) {
-
- // Calculate padding rectangle
- float sx = startx;
- float sy = starty;
- float paddRectWidth = width;
- float paddRectHeight = height;
-
- if (bpsStart != null) {
- sx += bpsStart.width / 1000f;
- paddRectWidth -= bpsStart.width / 1000f;
- }
- if (bpsBefore != null) {
- sy += bpsBefore.width / 1000f;
- paddRectHeight -= bpsBefore.width / 1000f;
- }
- if (bpsEnd != null) {
- paddRectWidth -= bpsEnd.width / 1000f;
- }
- if (bpsAfter != null) {
- paddRectHeight -= bpsAfter.width / 1000f;
- }
-
- if (back.getColor() != null) {
- updateFillColor(back.getColor());
- fillRect(sx, sy, paddRectWidth, paddRectHeight);
- }
-
- // background image
- if (back.getImageInfo() != null) {
- ImageSize imageSize = back.getImageInfo().getSize();
- saveGraphicsState();
- clipRect(sx, sy, paddRectWidth, paddRectHeight);
- int horzCount = (int) ((paddRectWidth * 1000 / imageSize.getWidthMpt()) + 1.0f);
- int vertCount = (int) ((paddRectHeight * 1000 / imageSize.getHeightMpt()) + 1.0f);
- if (back.getRepeat() == EN_NOREPEAT) {
- horzCount = 1;
- vertCount = 1;
- } else if (back.getRepeat() == EN_REPEATX) {
- vertCount = 1;
- } else if (back.getRepeat() == EN_REPEATY) {
- horzCount = 1;
- }
- // change from points to millipoints
- sx *= 1000;
- sy *= 1000;
- if (horzCount == 1) {
- sx += back.getHoriz();
- }
- if (vertCount == 1) {
- sy += back.getVertical();
- }
- for (int x = 0; x < horzCount; x++) {
- for (int y = 0; y < vertCount; y++) {
- // place once
- Rectangle2D pos;
- // Image positions are relative to the currentIP/BP
- pos = new Rectangle2D.Float(
- sx - currentIPPosition
- + (x * imageSize.getWidthMpt()),
- sy - currentBPPosition
- + (y * imageSize.getHeightMpt()),
- imageSize.getWidthMpt(),
- imageSize.getHeightMpt());
- drawImage(back.getURL(), pos, null);
- }
- }
- restoreGraphicsState();
- }
- }
-
- Rectangle2D.Float borderRect = new Rectangle2D.Float(startx, starty, width, height);
- drawBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd);
- }
-
- /**
- * Draws borders.
- * @param borderRect the border rectangle
- * @param bpsBefore the border specification on the before side
- * @param bpsAfter the border specification on the after side
- * @param bpsStart the border specification on the start side
- * @param bpsEnd the border specification on the end side
- */
- protected void drawBorders(Rectangle2D.Float borderRect,
- final BorderProps bpsBefore, final BorderProps bpsAfter,
- final BorderProps bpsStart, final BorderProps bpsEnd) {
- if (bpsBefore == null && bpsAfter == null && bpsStart == null && bpsEnd == null) {
- return; //no borders to paint
- }
- if (PCLRenderingMode.SPEED == pclUtil.getRenderingMode()) {
- drawFastBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd);
- } else {
- drawQualityBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd);
- }
- }
-
- /**
- * Draws borders. Borders are drawn as shaded rectangles with no clipping.
- * @param borderRect the border rectangle
- * @param bpsBefore the border specification on the before side
- * @param bpsAfter the border specification on the after side
- * @param bpsStart the border specification on the start side
- * @param bpsEnd the border specification on the end side
- */
- protected void drawFastBorders(Rectangle2D.Float borderRect,
- final BorderProps bpsBefore, final BorderProps bpsAfter,
- final BorderProps bpsStart, final BorderProps bpsEnd) {
- float startx = borderRect.x;
- float starty = borderRect.y;
- float width = borderRect.width;
- float height = borderRect.height;
- if (bpsBefore != null) {
- float borderWidth = bpsBefore.width / 1000f;
- updateFillColor(bpsBefore.color);
- fillRect(startx, starty, width, borderWidth);
- }
- if (bpsAfter != null) {
- float borderWidth = bpsAfter.width / 1000f;
- updateFillColor(bpsAfter.color);
- fillRect(startx, (starty + height - borderWidth),
- width, borderWidth);
- }
- if (bpsStart != null) {
- float borderWidth = bpsStart.width / 1000f;
- updateFillColor(bpsStart.color);
- fillRect(startx, starty, borderWidth, height);
- }
- if (bpsEnd != null) {
- float borderWidth = bpsEnd.width / 1000f;
- updateFillColor(bpsEnd.color);
- fillRect((startx + width - borderWidth), starty, borderWidth, height);
- }
- }
-
- /**
- * Draws borders. Borders are drawn in-memory and painted as a bitmap.
- * @param borderRect the border rectangle
- * @param bpsBefore the border specification on the before side
- * @param bpsAfter the border specification on the after side
- * @param bpsStart the border specification on the start side
- * @param bpsEnd the border specification on the end side
- */
- protected void drawQualityBorders(Rectangle2D.Float borderRect,
- final BorderProps bpsBefore, final BorderProps bpsAfter,
- final BorderProps bpsStart, final BorderProps bpsEnd) {
- Graphics2DAdapter g2a = getGraphics2DAdapter();
- final Rectangle.Float effBorderRect = new Rectangle2D.Float(
- 0,
- 0,
- borderRect.width,
- borderRect.height);
- final Rectangle paintRect = new Rectangle(
- Math.round(borderRect.x * 1000f),
- Math.round(borderRect.y * 1000f),
- (int)Math.floor(borderRect.width * 1000f) + 1,
- (int)Math.floor(borderRect.height * 1000f) + 1);
- //Add one pixel wide safety margin around the paint area
- int pixelWidth = (int)Math.round(UnitConv.in2mpt(1) / userAgent.getTargetResolution());
- final int xoffset = Math.round(-effBorderRect.x * 1000f) + pixelWidth;
- final int yoffset = pixelWidth;
- paintRect.x += xoffset;
- paintRect.y += yoffset;
- paintRect.width += 2 * pixelWidth;
- paintRect.height += 2 * pixelWidth;
-
- RendererContext rc = createRendererContext(paintRect.x, paintRect.y,
- paintRect.width, paintRect.height, null);
- Map atts = new java.util.HashMap();
- atts.put(ImageHandlerUtil.CONVERSION_MODE, ImageHandlerUtil.CONVERSION_MODE_BITMAP);
- atts.put(SRC_TRANSPARENCY, "true");
- rc.setProperty(RendererContextConstants.FOREIGN_ATTRIBUTES, atts);
-
- Graphics2DImagePainter painter = new Graphics2DImagePainter() {
-
- public void paint(Graphics2D g2d, Rectangle2D area) {
- g2d.translate(xoffset, yoffset);
- g2d.scale(1000, 1000);
- float startx = effBorderRect.x;
- float starty = effBorderRect.y;
- float width = effBorderRect.width;
- float height = effBorderRect.height;
- boolean[] b = new boolean[] {
- (bpsBefore != null), (bpsEnd != null),
- (bpsAfter != null), (bpsStart != null)};
- if (!b[0] && !b[1] && !b[2] && !b[3]) {
- return;
- }
- float[] bw = new float[] {
- (b[0] ? bpsBefore.width / 1000f : 0.0f),
- (b[1] ? bpsEnd.width / 1000f : 0.0f),
- (b[2] ? bpsAfter.width / 1000f : 0.0f),
- (b[3] ? bpsStart.width / 1000f : 0.0f)};
- float[] clipw = new float[] {
- BorderProps.getClippedWidth(bpsBefore) / 1000f,
- BorderProps.getClippedWidth(bpsEnd) / 1000f,
- BorderProps.getClippedWidth(bpsAfter) / 1000f,
- BorderProps.getClippedWidth(bpsStart) / 1000f};
- starty += clipw[0];
- height -= clipw[0];
- height -= clipw[2];
- startx += clipw[3];
- width -= clipw[3];
- width -= clipw[1];
-
- boolean[] slant = new boolean[] {
- (b[3] && b[0]), (b[0] && b[1]), (b[1] && b[2]), (b[2] && b[3])};
- if (bpsBefore != null) {
- //endTextObject();
-
- float sx1 = startx;
- float sx2 = (slant[0] ? sx1 + bw[3] - clipw[3] : sx1);
- float ex1 = startx + width;
- float ex2 = (slant[1] ? ex1 - bw[1] + clipw[1] : ex1);
- float outery = starty - clipw[0];
- float clipy = outery + clipw[0];
- float innery = outery + bw[0];
-
- //saveGraphicsState();
- Graphics2D g = (Graphics2D)g2d.create();
- moveTo(sx1, clipy);
- float sx1a = sx1;
- float ex1a = ex1;
- if (bpsBefore.mode == BorderProps.COLLAPSE_OUTER) {
- if (bpsStart != null && bpsStart.mode == BorderProps.COLLAPSE_OUTER) {
- sx1a -= clipw[3];
- }
- if (bpsEnd != null && bpsEnd.mode == BorderProps.COLLAPSE_OUTER) {
- ex1a += clipw[1];
- }
- lineTo(sx1a, outery);
- lineTo(ex1a, outery);
- }
- lineTo(ex1, clipy);
- lineTo(ex2, innery);
- lineTo(sx2, innery);
- closePath();
- //clip();
- g.clip(currentPath);
- currentPath = null;
- Rectangle2D.Float lineRect = new Rectangle2D.Float(
- sx1a, outery, ex1a - sx1a, innery - outery);
- Java2DRenderer.drawBorderLine(lineRect, true, true,
- bpsBefore.style, bpsBefore.color, g);
- //restoreGraphicsState();
- }
- if (bpsEnd != null) {
- //endTextObject();
-
- float sy1 = starty;
- float sy2 = (slant[1] ? sy1 + bw[0] - clipw[0] : sy1);
- float ey1 = starty + height;
- float ey2 = (slant[2] ? ey1 - bw[2] + clipw[2] : ey1);
- float outerx = startx + width + clipw[1];
- float clipx = outerx - clipw[1];
- float innerx = outerx - bw[1];
-
- //saveGraphicsState();
- Graphics2D g = (Graphics2D)g2d.create();
- moveTo(clipx, sy1);
- float sy1a = sy1;
- float ey1a = ey1;
- if (bpsEnd.mode == BorderProps.COLLAPSE_OUTER) {
- if (bpsBefore != null && bpsBefore.mode == BorderProps.COLLAPSE_OUTER) {
- sy1a -= clipw[0];
- }
- if (bpsAfter != null && bpsAfter.mode == BorderProps.COLLAPSE_OUTER) {
- ey1a += clipw[2];
- }
- lineTo(outerx, sy1a);
- lineTo(outerx, ey1a);
- }
- lineTo(clipx, ey1);
- lineTo(innerx, ey2);
- lineTo(innerx, sy2);
- closePath();
- //clip();
- g.setClip(currentPath);
- currentPath = null;
- Rectangle2D.Float lineRect = new Rectangle2D.Float(
- innerx, sy1a, outerx - innerx, ey1a - sy1a);
- Java2DRenderer.drawBorderLine(lineRect, false, false,
- bpsEnd.style, bpsEnd.color, g);
- //restoreGraphicsState();
- }
- if (bpsAfter != null) {
- //endTextObject();
-
- float sx1 = startx;
- float sx2 = (slant[3] ? sx1 + bw[3] - clipw[3] : sx1);
- float ex1 = startx + width;
- float ex2 = (slant[2] ? ex1 - bw[1] + clipw[1] : ex1);
- float outery = starty + height + clipw[2];
- float clipy = outery - clipw[2];
- float innery = outery - bw[2];
-
- //saveGraphicsState();
- Graphics2D g = (Graphics2D)g2d.create();
- moveTo(ex1, clipy);
- float sx1a = sx1;
- float ex1a = ex1;
- if (bpsAfter.mode == BorderProps.COLLAPSE_OUTER) {
- if (bpsStart != null && bpsStart.mode == BorderProps.COLLAPSE_OUTER) {
- sx1a -= clipw[3];
- }
- if (bpsEnd != null && bpsEnd.mode == BorderProps.COLLAPSE_OUTER) {
- ex1a += clipw[1];
- }
- lineTo(ex1a, outery);
- lineTo(sx1a, outery);
- }
- lineTo(sx1, clipy);
- lineTo(sx2, innery);
- lineTo(ex2, innery);
- closePath();
- //clip();
- g.setClip(currentPath);
- currentPath = null;
- Rectangle2D.Float lineRect = new Rectangle2D.Float(
- sx1a, innery, ex1a - sx1a, outery - innery);
- Java2DRenderer.drawBorderLine(lineRect, true, false,
- bpsAfter.style, bpsAfter.color, g);
- //restoreGraphicsState();
- }
- if (bpsStart != null) {
- //endTextObject();
-
- float sy1 = starty;
- float sy2 = (slant[0] ? sy1 + bw[0] - clipw[0] : sy1);
- float ey1 = sy1 + height;
- float ey2 = (slant[3] ? ey1 - bw[2] + clipw[2] : ey1);
- float outerx = startx - clipw[3];
- float clipx = outerx + clipw[3];
- float innerx = outerx + bw[3];
-
- //saveGraphicsState();
- Graphics2D g = (Graphics2D)g2d.create();
- moveTo(clipx, ey1);
- float sy1a = sy1;
- float ey1a = ey1;
- if (bpsStart.mode == BorderProps.COLLAPSE_OUTER) {
- if (bpsBefore != null && bpsBefore.mode == BorderProps.COLLAPSE_OUTER) {
- sy1a -= clipw[0];
- }
- if (bpsAfter != null && bpsAfter.mode == BorderProps.COLLAPSE_OUTER) {
- ey1a += clipw[2];
- }
- lineTo(outerx, ey1a);
- lineTo(outerx, sy1a);
- }
- lineTo(clipx, sy1);
- lineTo(innerx, sy2);
- lineTo(innerx, ey2);
- closePath();
- //clip();
- g.setClip(currentPath);
- currentPath = null;
- Rectangle2D.Float lineRect = new Rectangle2D.Float(
- outerx, sy1a, innerx - outerx, ey1a - sy1a);
- Java2DRenderer.drawBorderLine(lineRect, false, false,
- bpsStart.style, bpsStart.color, g);
- //restoreGraphicsState();
- }
- }
-
- public Dimension getImageSize() {
- return paintRect.getSize();
- }
-
- };
- try {
- g2a.paintImage(painter, rc,
- paintRect.x - xoffset, paintRect.y, paintRect.width, paintRect.height);
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- /** {@inheritDoc} */
- public void renderLeader(Leader area) {
- renderInlineAreaBackAndBorders(area);
-
- saveGraphicsState();
- int style = area.getRuleStyle();
- float startx = (currentIPPosition + area.getBorderAndPaddingWidthStart()) / 1000f;
- float starty = (currentBPPosition + area.getOffset()) / 1000f;
- float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart()
- + area.getIPD()) / 1000f;
- float ruleThickness = area.getRuleThickness() / 1000f;
- Color col = (Color)area.getTrait(Trait.COLOR);
-
- switch (style) {
- case EN_SOLID:
- case EN_DASHED: //TODO Improve me and following (this is just a quick-fix ATM)
- case EN_DOUBLE:
- case EN_DOTTED:
- case EN_GROOVE:
- case EN_RIDGE:
- updateFillColor(col);
- fillRect(startx, starty, endx - startx, ruleThickness);
- break;
- default:
- throw new UnsupportedOperationException("rule style not supported");
- }
-
- restoreGraphicsState();
- super.renderLeader(area);
- }
-
-}
diff --git a/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java b/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java
index 802ba4176..339880b64 100644
--- a/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java
@@ -57,20 +57,12 @@ public class PCLRendererConfigurator extends PrintRendererConfigurator
}
/**
- * Configure the PCL renderer.
+ * Throws an UnsupportedOperationException.
*
- * @param renderer PCL renderer
- * @throws FOPException fop exception
+ * @param renderer not used
*/
- public void configure(Renderer renderer) throws FOPException {
- Configuration cfg = super.getRendererConfig(renderer);
- if (cfg != null) {
- PCLRenderer pclRenderer = (PCLRenderer)renderer;
-
- PCLRenderingUtil pclUtil = pclRenderer.getPCLUtil();
- configure(cfg, pclUtil);
- }
- super.configure(renderer);
+ public void configure(Renderer renderer) {
+ throw new UnsupportedOperationException();
}
private void configure(Configuration cfg, PCLRenderingUtil pclUtil) throws FOPException {
diff --git a/src/java/org/apache/fop/render/pcl/PCLRendererContext.java b/src/java/org/apache/fop/render/pcl/PCLRendererContext.java
index 6c2c592b1..d54973ac8 100644
--- a/src/java/org/apache/fop/render/pcl/PCLRendererContext.java
+++ b/src/java/org/apache/fop/render/pcl/PCLRendererContext.java
@@ -19,9 +19,6 @@
package org.apache.fop.render.pcl;
-import org.apache.xmlgraphics.util.QName;
-
-import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.render.ImageHandlerUtil;
import org.apache.fop.render.RendererContext;
diff --git a/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java b/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java
deleted file mode 100644
index a7651a6ac..000000000
--- a/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.pcl;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.AbstractRendererMaker;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererConfigurator;
-
-/**
- * RendererMaker for the PCL Renderer.
- */
-public class PCLRendererMaker extends AbstractRendererMaker {
-
- private static final String[] MIMES = new String[] {
- MimeConstants.MIME_PCL,
- MimeConstants.MIME_PCL_ALT
- };
-
- /**{@inheritDoc} */
- public Renderer makeRenderer(FOUserAgent userAgent) {
- return new PCLRenderer();
- }
-
- /** {@inheritDoc} */
- public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
- return new PCLRendererConfigurator(userAgent);
- }
-
- /** {@inheritDoc} */
- public boolean needsOutputStream() {
- return true;
- }
-
- /** {@inheritDoc} */
- public String[] getSupportedMimeTypes() {
- return MIMES;
- }
-}
diff --git a/src/java/org/apache/fop/render/pcl/PCLRenderingContext.java b/src/java/org/apache/fop/render/pcl/PCLRenderingContext.java
index 014b267dd..8ac7fc973 100644
--- a/src/java/org/apache/fop/render/pcl/PCLRenderingContext.java
+++ b/src/java/org/apache/fop/render/pcl/PCLRenderingContext.java
@@ -41,6 +41,7 @@ public abstract class PCLRenderingContext extends AbstractRenderingContext {
* Main constructor.
* @param userAgent the user agent
* @param generator the PCL generator
+ * @param pclUtil rendering utility
*/
public PCLRenderingContext(FOUserAgent userAgent,
PCLGenerator generator, PCLRenderingUtil pclUtil) {
diff --git a/src/java/org/apache/fop/render/pcl/PCLSVGHandler.java b/src/java/org/apache/fop/render/pcl/PCLSVGHandler.java
index fb2389758..f07a7a7e2 100644
--- a/src/java/org/apache/fop/render/pcl/PCLSVGHandler.java
+++ b/src/java/org/apache/fop/render/pcl/PCLSVGHandler.java
@@ -28,13 +28,12 @@ import org.apache.fop.render.RendererContext;
* PCL XML handler for SVG. Uses Apache Batik for SVG processing.
* This handler handles XML for foreign objects when rendering to HP GL/2.
* It renders SVG to HP GL/2 using the PCLGraphics2D.
- * @see PCLGraphics2DAdapter
*/
public class PCLSVGHandler extends AbstractGenericSVGHandler {
/** {@inheritDoc} */
public boolean supportsRenderer(Renderer renderer) {
- return (renderer instanceof PCLRenderer);
+ return false;
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java b/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java
index 700a95c65..08f3a5f44 100644
--- a/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java
+++ b/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java
@@ -57,7 +57,7 @@ public class PCLElementMapping extends ElementMapping {
protected void initialize() {
if (foObjs == null) {
- foObjs = new HashMap();
+ foObjs = new HashMap<String, Maker>();
//No extension elements, yet, only attributes
}
diff --git a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java
index ff7532639..d3cc554c8 100644
--- a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java
+++ b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java
@@ -167,7 +167,7 @@ public abstract class AbstractImageAdapter implements PDFImage {
return null;
}
- /** {@inheritDoc} */
+ /** @return null (if not overridden) */
public String getSoftMask() {
return null;
}
diff --git a/src/java/org/apache/fop/render/pdf/CTMHelper.java b/src/java/org/apache/fop/render/pdf/CTMHelper.java
index ced025ea3..5f1706905 100644
--- a/src/java/org/apache/fop/render/pdf/CTMHelper.java
+++ b/src/java/org/apache/fop/render/pdf/CTMHelper.java
@@ -33,6 +33,10 @@ import org.apache.fop.pdf.PDFNumber;
* @see org.apache.fop.area.CTM
*/
public final class CTMHelper {
+
+ private CTMHelper() {
+ }
+
/**
* <p>Converts the sourceMatrix to a string for use in the PDFRenderer cm operations.</p>
* <p>For example:
diff --git a/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java b/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
index 27d25e15b..e34165d5a 100644
--- a/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
+++ b/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
@@ -66,7 +66,7 @@ public class ImageRenderedAdapter extends AbstractImageAdapter {
*/
public ImageRenderedAdapter(ImageRendered image, String key) {
super(image, key);
- this.encodingHelper = new ImageEncodingHelper(image.getRenderedImage());
+ this.encodingHelper = new ImageEncodingHelper(image.getRenderedImage(), true);
}
/**
diff --git a/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java b/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java
index d1b2e87dd..f8090fdeb 100644
--- a/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java
+++ b/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java
@@ -37,29 +37,39 @@ import org.apache.fop.util.ColorUtil;
public class PDFBorderPainter extends BorderPainter {
/** logging instance */
- private static Log log = LogFactory.getLog(PDFBorderPainter.class);
+ private static final Log LOG = LogFactory.getLog(PDFBorderPainter.class);
private PDFContentGenerator generator;
+ /**
+ * Construct a border painter.
+ * @param generator a pdf content generator
+ */
public PDFBorderPainter(PDFContentGenerator generator) {
this.generator = generator;
}
/** {@inheritDoc} */
- protected void drawBorderLine(int x1, int y1, int x2, int y2, boolean horz,
+ protected void drawBorderLine( // CSOK: ParameterNumber
+ int x1, int y1, int x2, int y2, boolean horz,
boolean startOrBefore, int style, Color col) {
drawBorderLine(generator, x1 / 1000f, y1 / 1000f, x2 / 1000f, y2 / 1000f,
horz, startOrBefore, style, col);
}
- /** {@inheritDoc} */
- public static void drawBorderLine(PDFContentGenerator generator,
- float x1, float y1, float x2, float y2, boolean horz,
- boolean startOrBefore, int style, Color col) {
+ /**
+ * @param generator pdf content generator
+ * @see BorderPainter#drawBorderLine
+ */
+ public static void drawBorderLine( // CSOK: ParameterNumber|MethodLength
+ PDFContentGenerator generator,
+ float x1, float y1, float x2, float y2, boolean horz, // CSOK: JavadocMethod
+ boolean startOrBefore, int style, Color col) { // CSOK: JavadocMethod
+ float colFactor;
float w = x2 - x1;
float h = y2 - y1;
if ((w < 0) || (h < 0)) {
- log.error("Negative extent received (w=" + w + ", h=" + h
+ LOG.error("Negative extent received (w=" + w + ", h=" + h
+ "). Border won't be painted.");
return;
}
@@ -146,8 +156,7 @@ public class PDFBorderPainter extends BorderPainter {
break;
case Constants.EN_GROOVE:
case Constants.EN_RIDGE:
- {
- float colFactor = (style == Constants.EN_GROOVE ? 0.4f : -0.4f);
+ colFactor = (style == Constants.EN_GROOVE ? 0.4f : -0.4f);
generator.add("[] 0 d ");
if (horz) {
Color uppercol = ColorUtil.lightenColor(col, -colFactor);
@@ -181,11 +190,9 @@ public class PDFBorderPainter extends BorderPainter {
+ format(xm1 + w3 + w3) + " " + format(y2) + " l S\n");
}
break;
- }
case Constants.EN_INSET:
case Constants.EN_OUTSET:
- {
- float colFactor = (style == Constants.EN_OUTSET ? 0.4f : -0.4f);
+ colFactor = (style == Constants.EN_OUTSET ? 0.4f : -0.4f);
generator.add("[] 0 d ");
Color c = col;
if (horz) {
@@ -204,7 +211,6 @@ public class PDFBorderPainter extends BorderPainter {
+ format(xm1) + " " + format(y2) + " l S\n");
}
break;
- }
case Constants.EN_HIDDEN:
break;
default:
diff --git a/src/java/org/apache/fop/render/pdf/PDFContentGenerator.java b/src/java/org/apache/fop/render/pdf/PDFContentGenerator.java
index 634551baa..7cc9b7003 100644
--- a/src/java/org/apache/fop/render/pdf/PDFContentGenerator.java
+++ b/src/java/org/apache/fop/render/pdf/PDFContentGenerator.java
@@ -118,7 +118,7 @@ public class PDFContentGenerator {
}
/**
- * Returns the {@link PDFState} associated with this instance.
+ * Returns the {@link PDFPaintingState} associated with this instance.
* @return the PDF state
*/
public PDFPaintingState getState() {
@@ -151,14 +151,18 @@ public class PDFContentGenerator {
}
}
- /** {@inheritDoc} */
+ /** Save graphics state. */
protected void saveGraphicsState() {
endTextObject();
currentState.save();
currentStream.add("q\n");
}
- /** {@inheritDoc} */
+ /**
+ * Save graphics state.
+ * @param structElemType an element type
+ * @param sequenceNum a sequence number
+ */
protected void saveGraphicsState(String structElemType, int sequenceNum) {
endTextObject();
currentState.save();
diff --git a/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java b/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
index bc2f16f45..c1d959dd1 100644
--- a/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
+++ b/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
@@ -39,7 +39,6 @@ import org.apache.fop.fo.extensions.xmp.XMPMetadata;
import org.apache.fop.pdf.PDFAnnotList;
import org.apache.fop.pdf.PDFDocument;
import org.apache.fop.pdf.PDFPage;
-import org.apache.fop.pdf.PDFReference;
import org.apache.fop.pdf.PDFResourceContext;
import org.apache.fop.pdf.PDFResources;
import org.apache.fop.render.extensions.prepress.PageBoundaries;
@@ -51,6 +50,7 @@ import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator;
import org.apache.fop.render.intermediate.IFDocumentNavigationHandler;
import org.apache.fop.render.intermediate.IFException;
import org.apache.fop.render.intermediate.IFPainter;
+import org.apache.fop.render.pdf.extensions.PDFEmbeddedFileExtensionAttachment;
import org.apache.fop.util.XMLUtil;
/**
@@ -92,7 +92,8 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
protected PageReference currentPageRef;
/** Used for bookmarks/outlines. */
- protected Map pageReferences = new java.util.HashMap();
+ protected Map<Integer, PageReference> pageReferences
+ = new java.util.HashMap<Integer, PageReference>();
private final PDFDocumentNavigationHandler documentNavigationHandler
= new PDFDocumentNavigationHandler(this);
@@ -237,7 +238,7 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
pdfUtil.generatePageLabel(index, name);
currentPageRef = new PageReference(currentPage, size);
- this.pageReferences.put(new Integer(index), currentPageRef);
+ this.pageReferences.put(Integer.valueOf(index), currentPageRef);
this.generator = new PDFContentGenerator(this.pdfDoc, this.outputStream,
this.currentPage);
@@ -292,6 +293,14 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
} else if (extension instanceof Metadata) {
XMPMetadata wrapper = new XMPMetadata(((Metadata)extension));
pdfUtil.renderXMPMetadata(wrapper);
+ } else if (extension instanceof PDFEmbeddedFileExtensionAttachment) {
+ PDFEmbeddedFileExtensionAttachment embeddedFile
+ = (PDFEmbeddedFileExtensionAttachment)extension;
+ try {
+ pdfUtil.addEmbeddedFile(embeddedFile);
+ } catch (IOException ioe) {
+ throw new IFException("Error adding embedded file: " + embeddedFile.getSrc(), ioe);
+ }
} else {
log.debug("Don't know how to handle extension object. Ignoring: "
+ extension + " (" + extension.getClass().getName() + ")");
@@ -299,21 +308,22 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
}
PageReference getPageReference(int pageIndex) {
- return (PageReference)this.pageReferences.get(
- new Integer(pageIndex));
+ return this.pageReferences.get(Integer.valueOf(pageIndex));
}
static final class PageReference {
- private final PDFReference pageRef;
+ private final String pageRef;
private final Dimension pageDimension;
private PageReference(PDFPage page, Dimension dim) {
- this.pageRef = page.makeReference();
+ // Avoid keeping references to PDFPage as memory usage is
+ // considerably increased when handling thousands of pages.
+ this.pageRef = page.makeReference().toString();
this.pageDimension = new Dimension(dim);
}
- public PDFReference getPageRef() {
+ public String getPageRef() {
return this.pageRef;
}
diff --git a/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java b/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java
index 5e1b1b250..c8fa481d4 100644
--- a/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java
+++ b/src/java/org/apache/fop/render/pdf/PDFDocumentNavigationHandler.java
@@ -166,10 +166,11 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler
} else if (action instanceof URIAction) {
URIAction u = (URIAction)action;
assert u.isComplete();
+ String uri = u.getURI();
PDFFactory factory = getPDFDoc().getFactory();
- pdfAction = factory.getExternalAction(u.getURI(), u.isNewWindow());
+ pdfAction = factory.getExternalAction(uri, u.isNewWindow());
if (!pdfAction.hasObjectNumber()) {
- //Some PDF actions a pooled
+ //Some PDF actions are pooled
getPDFDoc().registerObject(pdfAction);
}
this.completeActions.put(action.getID(), pdfAction);
@@ -188,7 +189,7 @@ public class PDFDocumentNavigationHandler implements IFDocumentNavigationHandler
p2d = new Point2D.Double(
action.getTargetLocation().x / 1000.0,
(pageRef.getPageDimension().height - action.getTargetLocation().y) / 1000.0);
- String pdfPageRef = pageRef.getPageRef().toString();
+ String pdfPageRef = pageRef.getPageRef();
pdfGoTo.setPageReference(pdfPageRef);
pdfGoTo.setPosition(p2d);
diff --git a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java
deleted file mode 100644
index 102c1ab45..000000000
--- a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.pdf;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-
-import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
-
-import org.apache.fop.render.AbstractGraphics2DAdapter;
-import org.apache.fop.render.RendererContext;
-import org.apache.fop.render.RendererContext.RendererContextWrapper;
-import org.apache.fop.svg.PDFGraphics2D;
-
-/**
- * Graphics2DAdapter implementation for PDF.
- */
-public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter {
-
- private PDFRenderer renderer;
-
- /**
- * Main constructor
- * @param renderer the Renderer instance to which this instance belongs
- */
- public PDFGraphics2DAdapter(PDFRenderer renderer) {
- this.renderer = renderer;
- }
-
- /** {@inheritDoc} */
- public void paintImage(Graphics2DImagePainter painter,
- RendererContext context,
- int x, int y, int width, int height) throws IOException {
-
- PDFContentGenerator generator = renderer.getGenerator();
- PDFSVGHandler.PDFInfo pdfInfo = PDFSVGHandler.getPDFInfo(context);
- float fwidth = width / 1000f;
- float fheight = height / 1000f;
- float fx = x / 1000f;
- float fy = y / 1000f;
-
- // get the 'width' and 'height' attributes of the SVG document
- Dimension dim = painter.getImageSize();
- float imw = (float)dim.getWidth() / 1000f;
- float imh = (float)dim.getHeight() / 1000f;
-
- float sx = pdfInfo.paintAsBitmap ? 1.0f : (fwidth / (float)imw);
- float sy = pdfInfo.paintAsBitmap ? 1.0f : (fheight / (float)imh);
-
- generator.comment("G2D start");
- generator.saveGraphicsState();
- generator.updateColor(Color.black, false, null);
- generator.updateColor(Color.black, true, null);
-
- //TODO Clip to the image area.
-
- // transform so that the coordinates (0,0) is from the top left
- // and positive is down and to the right. (0,0) is where the
- // viewBox puts it.
- generator.add(sx + " 0 0 " + sy + " " + fx + " "
- + fy + " cm\n");
-
-
- final boolean textAsShapes = false;
- if (pdfInfo.pdfContext == null) {
- pdfInfo.pdfContext = pdfInfo.pdfPage;
- }
- PDFGraphics2D graphics = new PDFGraphics2D(textAsShapes,
- pdfInfo.fi, pdfInfo.pdfDoc,
- pdfInfo.pdfContext, pdfInfo.pdfPage.referencePDF(),
- pdfInfo.currentFontName,
- pdfInfo.currentFontSize);
- graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
-
- AffineTransform transform = new AffineTransform();
- transform.translate(fx, fy);
- generator.getState().concatenate(transform);
- graphics.setPaintingState(generator.getState());
- graphics.setOutputStream(pdfInfo.outputStream);
-
- if (pdfInfo.paintAsBitmap) {
- //Fallback solution: Paint to a BufferedImage
- int resolution = (int)Math.round(context.getUserAgent().getTargetResolution());
- RendererContextWrapper ctx = RendererContext.wrapRendererContext(context);
- BufferedImage bi = paintToBufferedImage(painter, ctx, resolution, false, false);
-
- float scale = PDFRenderer.NORMAL_PDF_RESOLUTION
- / context.getUserAgent().getTargetResolution();
- graphics.drawImage(bi, new AffineTransform(scale, 0, 0, scale, 0, 0), null);
- } else {
- Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh);
- painter.paint(graphics, area);
- }
-
- generator.add(graphics.getString());
- generator.restoreGraphicsState();
- generator.comment("G2D end");
- }
-
- /** {@inheritDoc} */
- protected void setRenderingHintsForBufferedImage(Graphics2D g2d) {
- super.setRenderingHintsForBufferedImage(g2d);
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
- RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- }
-
-}
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandler.java b/src/java/org/apache/fop/render/pdf/PDFImageHandler.java
deleted file mode 100644
index 934d306b9..000000000
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandler.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.pdf;
-
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.io.IOException;
-
-import org.apache.xmlgraphics.image.loader.Image;
-
-import org.apache.fop.pdf.PDFXObject;
-import org.apache.fop.render.ImageHandlerBase;
-import org.apache.fop.render.RendererContext;
-
-/**
- * This interface is used for handling all sorts of image type for PDF output.
- */
-public interface PDFImageHandler extends ImageHandlerBase {
-
- /**
- * Generates the PDF objects for the given {@link Image} instance. If the handler generates
- * an XObject, it shall return it or otherwise return null. A generated XObject shall be
- * placed in the current viewport according to the two parameters "origin" and "pos".
- * @param context the PDF renderer context
- * @param image the image to be handled
- * @param origin the current position in the current viewport (in millipoints)
- * @param pos the position and scaling of the image relative to the origin point
- * (in millipoints)
- * @return the generated XObject or null if no XObject was generated
- * @throws IOException if an I/O error occurs
- */
- PDFXObject generateImage(RendererContext context, Image image,
- Point origin, Rectangle pos) throws IOException;
-
-}
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java
index c3242827a..d309a00aa 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java
@@ -21,7 +21,6 @@ package org.apache.fop.render.pdf;
import java.awt.Color;
import java.awt.Dimension;
-import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
@@ -31,9 +30,7 @@ import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
-import org.apache.fop.pdf.PDFXObject;
import org.apache.fop.render.AbstractImageHandlerGraphics2D;
-import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RenderingContext;
import org.apache.fop.render.pdf.PDFLogicalStructureHandler.MarkedContentInfo;
import org.apache.fop.svg.PDFGraphics2D;
@@ -41,37 +38,13 @@ import org.apache.fop.svg.PDFGraphics2D;
/**
* PDFImageHandler implementation which handles Graphics2D images.
*/
-public class PDFImageHandlerGraphics2D extends AbstractImageHandlerGraphics2D
- implements PDFImageHandler {
+public class PDFImageHandlerGraphics2D extends AbstractImageHandlerGraphics2D {
private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
ImageFlavor.GRAPHICS2D,
};
/** {@inheritDoc} */
- public PDFXObject generateImage(RendererContext context, Image image,
- Point origin, Rectangle pos)
- throws IOException {
- PDFRenderer renderer = (PDFRenderer)context.getRenderer();
- /*
- ImageGraphics2D imageG2D = (ImageGraphics2D)image;
- renderer.getGraphics2DAdapter().paintImage(imageG2D.getGraphics2DImagePainter(),
- context, origin.x + pos.x, origin.y + pos.y, pos.width, pos.height);
- */
- PDFRenderingContext pdfContext = new PDFRenderingContext(
- context.getUserAgent(),
- renderer.getGenerator(),
- renderer.currentPage,
- renderer.getFontInfo());
- Rectangle effPos = new Rectangle(origin.x + pos.x, origin.y + pos.y, pos.width, pos.height);
- if (context.getUserAgent().isAccessibilityEnabled()) {
- pdfContext.setMarkedContentInfo(renderer.addCurrentImageToStructureTree());
- }
- handleImage(pdfContext, image, effPos);
- return null;
- }
-
- /** {@inheritDoc} */
public void handleImage(RenderingContext context, Image image, Rectangle pos)
throws IOException {
PDFRenderingContext pdfContext = (PDFRenderingContext)context;
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java
index 75b1d356e..b7d47ad58 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java
@@ -19,7 +19,6 @@
package org.apache.fop.render.pdf;
-import java.awt.Point;
import java.awt.Rectangle;
import java.io.IOException;
@@ -27,48 +26,22 @@ import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
-import org.apache.fop.pdf.PDFDocument;
import org.apache.fop.pdf.PDFImage;
-import org.apache.fop.pdf.PDFResourceContext;
import org.apache.fop.pdf.PDFXObject;
import org.apache.fop.render.ImageHandler;
-import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RenderingContext;
/**
* Image handler implementation which handles CCITT encoded images (CCITT fax group 3/4)
* for PDF output.
*/
-public class PDFImageHandlerRawCCITTFax implements PDFImageHandler, ImageHandler {
+public class PDFImageHandlerRawCCITTFax implements ImageHandler {
private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
ImageFlavor.RAW_CCITTFAX,
};
/** {@inheritDoc} */
- public PDFXObject generateImage(RendererContext context, Image image,
- Point origin, Rectangle pos)
- throws IOException {
- PDFRenderer renderer = (PDFRenderer)context.getRenderer();
- ImageRawCCITTFax ccitt = (ImageRawCCITTFax)image;
- PDFDocument pdfDoc = (PDFDocument)context.getProperty(
- PDFRendererContextConstants.PDF_DOCUMENT);
- PDFResourceContext resContext = (PDFResourceContext)context.getProperty(
- PDFRendererContextConstants.PDF_CONTEXT);
-
- PDFImage pdfimage = new ImageRawCCITTFaxAdapter(ccitt, image.getInfo().getOriginalURI());
- PDFXObject xobj = pdfDoc.addImage(resContext, pdfimage);
-
- float x = (float)pos.getX() / 1000f;
- float y = (float)pos.getY() / 1000f;
- float w = (float)pos.getWidth() / 1000f;
- float h = (float)pos.getHeight() / 1000f;
- renderer.placeImage(x, y, w, h, xobj);
-
- return xobj;
- }
-
- /** {@inheritDoc} */
public void handleImage(RenderingContext context, Image image, Rectangle pos)
throws IOException {
PDFRenderingContext pdfContext = (PDFRenderingContext)context;
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java
index 02dd98ecf..7ac181014 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java
@@ -19,7 +19,6 @@
package org.apache.fop.render.pdf;
-import java.awt.Point;
import java.awt.Rectangle;
import java.io.IOException;
@@ -27,48 +26,22 @@ import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG;
-import org.apache.fop.pdf.PDFDocument;
import org.apache.fop.pdf.PDFImage;
-import org.apache.fop.pdf.PDFResourceContext;
import org.apache.fop.pdf.PDFXObject;
import org.apache.fop.render.ImageHandler;
-import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RenderingContext;
import org.apache.fop.render.pdf.PDFLogicalStructureHandler.MarkedContentInfo;
/**
* Image handler implementation which handles raw JPEG images for PDF output.
*/
-public class PDFImageHandlerRawJPEG implements PDFImageHandler, ImageHandler {
+public class PDFImageHandlerRawJPEG implements ImageHandler {
private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
ImageFlavor.RAW_JPEG,
};
/** {@inheritDoc} */
- public PDFXObject generateImage(RendererContext context, Image image,
- Point origin, Rectangle pos)
- throws IOException {
- PDFRenderer renderer = (PDFRenderer)context.getRenderer();
- ImageRawJPEG jpeg = (ImageRawJPEG)image;
- PDFDocument pdfDoc = (PDFDocument)context.getProperty(
- PDFRendererContextConstants.PDF_DOCUMENT);
- PDFResourceContext resContext = (PDFResourceContext)context.getProperty(
- PDFRendererContextConstants.PDF_CONTEXT);
-
- PDFImage pdfimage = new ImageRawJPEGAdapter(jpeg, image.getInfo().getOriginalURI());
- PDFXObject xobj = pdfDoc.addImage(resContext, pdfimage);
-
- float x = (float)pos.getX() / 1000f;
- float y = (float)pos.getY() / 1000f;
- float w = (float)pos.getWidth() / 1000f;
- float h = (float)pos.getHeight() / 1000f;
- renderer.placeImage(x, y, w, h, xobj);
-
- return xobj;
- }
-
- /** {@inheritDoc} */
public void handleImage(RenderingContext context, Image image, Rectangle pos)
throws IOException {
PDFRenderingContext pdfContext = (PDFRenderingContext)context;
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java
index 3c02cb6f3..e0ff3cdd4 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java
@@ -19,7 +19,6 @@
package org.apache.fop.render.pdf;
-import java.awt.Point;
import java.awt.Rectangle;
import java.io.IOException;
@@ -27,19 +26,16 @@ import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
-import org.apache.fop.pdf.PDFDocument;
import org.apache.fop.pdf.PDFImage;
-import org.apache.fop.pdf.PDFResourceContext;
import org.apache.fop.pdf.PDFXObject;
import org.apache.fop.render.ImageHandler;
-import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RenderingContext;
import org.apache.fop.render.pdf.PDFLogicalStructureHandler.MarkedContentInfo;
/**
* Image handler implementation which handles RenderedImage instances for PDF output.
*/
-public class PDFImageHandlerRenderedImage implements PDFImageHandler, ImageHandler {
+public class PDFImageHandlerRenderedImage implements ImageHandler {
private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
ImageFlavor.BUFFERED_IMAGE,
@@ -47,29 +43,6 @@ public class PDFImageHandlerRenderedImage implements PDFImageHandler, ImageHandl
};
/** {@inheritDoc} */
- public PDFXObject generateImage(RendererContext context, Image image,
- Point origin, Rectangle pos)
- throws IOException {
- PDFRenderer renderer = (PDFRenderer)context.getRenderer();
- ImageRendered imageRend = (ImageRendered)image;
- PDFDocument pdfDoc = (PDFDocument)context.getProperty(
- PDFRendererContextConstants.PDF_DOCUMENT);
- PDFResourceContext resContext = (PDFResourceContext)context.getProperty(
- PDFRendererContextConstants.PDF_CONTEXT);
-
- PDFImage pdfimage = new ImageRenderedAdapter(imageRend, image.getInfo().getOriginalURI());
- PDFXObject xobj = pdfDoc.addImage(resContext, pdfimage);
-
- float x = (float)pos.getX() / 1000f;
- float y = (float)pos.getY() / 1000f;
- float w = (float)pos.getWidth() / 1000f;
- float h = (float)pos.getHeight() / 1000f;
- renderer.placeImage(x, y, w, h, xobj);
-
- return xobj;
- }
-
- /** {@inheritDoc} */
public void handleImage(RenderingContext context, Image image, Rectangle pos)
throws IOException {
PDFRenderingContext pdfContext = (PDFRenderingContext)context;
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java
index e6d2c8a71..d46621068 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java
@@ -38,6 +38,7 @@ import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.image.loader.batik.BatikImageFlavors;
+import org.apache.fop.image.loader.batik.BatikUtil;
import org.apache.fop.render.ImageHandler;
import org.apache.fop.render.RenderingContext;
import org.apache.fop.render.pdf.PDFLogicalStructureHandler.MarkedContentInfo;
@@ -46,6 +47,7 @@ import org.apache.fop.svg.PDFBridgeContext;
import org.apache.fop.svg.PDFGraphics2D;
import org.apache.fop.svg.SVGEventProducer;
import org.apache.fop.svg.SVGUserAgent;
+import org.w3c.dom.Document;
/**
* Image Handler implementation which handles SVG images.
@@ -71,11 +73,6 @@ public class PDFImageHandlerSVG implements ImageHandler {
final float uaResolution = userAgent.getSourceResolution();
SVGUserAgent ua = new SVGUserAgent(userAgent, new AffineTransform());
- //Scale for higher resolution on-the-fly images from Batik
- double s = uaResolution / deviceResolution;
- AffineTransform resolutionScaling = new AffineTransform();
- resolutionScaling.scale(s, s);
-
GVTBuilder builder = new GVTBuilder();
//Controls whether text painted by Batik is generated using text or path operations
@@ -88,9 +85,13 @@ public class PDFImageHandlerSVG implements ImageHandler {
userAgent.getImageSessionContext(),
new AffineTransform());
+ //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
+ //to it.
+ Document clonedDoc = BatikUtil.cloneSVGDocument(imageSVG.getDocument());
+
GraphicsNode root;
try {
- root = builder.build(ctx, imageSVG.getDocument());
+ root = builder.build(ctx, clonedDoc);
builder = null;
} catch (Exception e) {
SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
@@ -99,8 +100,8 @@ public class PDFImageHandlerSVG implements ImageHandler {
return;
}
// get the 'width' and 'height' attributes of the SVG document
- float w = (float)ctx.getDocumentSize().getWidth() * 1000f;
- float h = (float)ctx.getDocumentSize().getHeight() * 1000f;
+ float w = image.getSize().getWidthMpt();
+ float h = image.getSize().getHeightMpt();
float sx = pos.width / w;
float sy = pos.height / h;
@@ -109,6 +110,12 @@ public class PDFImageHandlerSVG implements ImageHandler {
AffineTransform scaling = new AffineTransform(
sx, 0, 0, sy, pos.x / 1000f, pos.y / 1000f);
+ //Scale for higher resolution on-the-fly images from Batik
+ double s = uaResolution / deviceResolution;
+ AffineTransform resolutionScaling = new AffineTransform();
+ resolutionScaling.scale(s, s);
+ resolutionScaling.scale(1.0 / sx, 1.0 / sy);
+
//Transformation matrix that establishes the local coordinate system for the SVG graphic
//in relation to the current coordinate system
AffineTransform imageTransform = new AffineTransform();
@@ -147,7 +154,9 @@ public class PDFImageHandlerSVG implements ImageHandler {
+ " -> " + deviceResolution + "\n");
generator.add(
CTMHelper.toPDFString(resolutionScaling, false) + " cm\n");
- graphics.scale(1 / s, 1 / s);
+ graphics.scale(
+ 1.0 / resolutionScaling.getScaleX(),
+ 1.0 / resolutionScaling.getScaleY());
}
generator.comment("SVG start");
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java
deleted file mode 100644
index 26ba83371..000000000
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.pdf;
-
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.fop.pdf.PDFXObject;
-import org.apache.fop.render.RendererContext;
-import org.apache.xmlgraphics.image.loader.Image;
-import org.apache.xmlgraphics.image.loader.ImageFlavor;
-import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
-import org.w3c.dom.Document;
-
-/**
- * PDFImageHandler implementation which handles XML-based images.
- */
-public class PDFImageHandlerXML implements PDFImageHandler {
-
- private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
- ImageFlavor.XML_DOM,
- };
-
- /** {@inheritDoc} */
- public PDFXObject generateImage(RendererContext context, Image image,
- Point origin, Rectangle pos)
- throws IOException {
- PDFRenderer renderer = (PDFRenderer)context.getRenderer();
- ImageXMLDOM imgXML = (ImageXMLDOM)image;
- Document doc = imgXML.getDocument();
- String ns = imgXML.getRootNamespace();
- Map foreignAttributes = (Map)context.getProperty(
- PDFRendererContextConstants.FOREIGN_ATTRIBUTES);
- renderer.renderDocument(doc, ns, pos, foreignAttributes);
- return null;
- }
-
- /** {@inheritDoc} */
- public int getPriority() {
- return 400;
- }
-
- /** {@inheritDoc} */
- public Class getSupportedImageClass() {
- return ImageXMLDOM.class;
- }
-
- /** {@inheritDoc} */
- public ImageFlavor[] getSupportedImageFlavors() {
- return FLAVORS;
- }
-
-}
diff --git a/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java b/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java
index 42b873270..ba9584597 100644
--- a/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java
+++ b/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java
@@ -87,12 +87,12 @@ class PDFLogicalStructureHandler {
* operator. This is the structure type of the corresponding structure
* element.
*/
- final String tag;
+ final String tag; // CSOK: VisibilityModifier
/**
* The value for the MCID entry of the marked-content sequence's property list.
*/
- final int mcid;
+ final int mcid; // CSOK: VisibilityModifier
private final PDFStructElem parent;
diff --git a/src/java/org/apache/fop/render/pdf/PDFPainter.java b/src/java/org/apache/fop/render/pdf/PDFPainter.java
index f72f09ad0..161b46617 100644
--- a/src/java/org/apache/fop/render/pdf/PDFPainter.java
+++ b/src/java/org/apache/fop/render/pdf/PDFPainter.java
@@ -162,10 +162,7 @@ public class PDFPainter extends AbstractIFPainter {
/**
* Places a previously registered image at a certain place on the page.
- * @param x X coordinate
- * @param y Y coordinate
- * @param w width for image
- * @param h height for image
+ * @param rect the rectangle for the image
* @param xobj the image XObject
*/
private void placeImage(Rectangle rect, PDFXObject xobj) {
@@ -179,10 +176,7 @@ public class PDFPainter extends AbstractIFPainter {
}
/**
* Places a previously registered image at a certain place on the page - Accessibility version
- * @param x X coordinate
- * @param y Y coordinate
- * @param w width for image
- * @param h height for image
+ * @param rect the rectangle for the image
* @param xobj the image XObject
*/
private void placeImageAccess(Rectangle rect, PDFXObject xobj) {
diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
deleted file mode 100644
index aab84807c..000000000
--- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java
+++ /dev/null
@@ -1,1352 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.pdf;
-
-// Java
-import java.awt.Color;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
-
-import org.apache.xmlgraphics.image.loader.ImageException;
-import org.apache.xmlgraphics.image.loader.ImageFlavor;
-import org.apache.xmlgraphics.image.loader.ImageInfo;
-import org.apache.xmlgraphics.image.loader.ImageManager;
-import org.apache.xmlgraphics.image.loader.ImageSessionContext;
-import org.apache.xmlgraphics.image.loader.util.ImageUtil;
-
-import org.apache.fop.ResourceEventProducer;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.area.Area;
-import org.apache.fop.area.Block;
-import org.apache.fop.area.BookmarkData;
-import org.apache.fop.area.CTM;
-import org.apache.fop.area.DestinationData;
-import org.apache.fop.area.LineArea;
-import org.apache.fop.area.OffDocumentExtensionAttachment;
-import org.apache.fop.area.OffDocumentItem;
-import org.apache.fop.area.PageSequence;
-import org.apache.fop.area.PageViewport;
-import org.apache.fop.area.Trait;
-import org.apache.fop.area.inline.AbstractTextArea;
-import org.apache.fop.area.inline.Image;
-import org.apache.fop.area.inline.InlineArea;
-import org.apache.fop.area.inline.InlineParent;
-import org.apache.fop.area.inline.Leader;
-import org.apache.fop.area.inline.SpaceArea;
-import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.area.inline.Viewport;
-import org.apache.fop.area.inline.WordArea;
-import org.apache.fop.datatypes.URISpecification;
-import org.apache.fop.fo.extensions.ExtensionAttachment;
-import org.apache.fop.fo.extensions.xmp.XMPMetadata;
-import org.apache.fop.fonts.Font;
-import org.apache.fop.fonts.LazyFont;
-import org.apache.fop.fonts.SingleByteFont;
-import org.apache.fop.fonts.Typeface;
-import org.apache.fop.pdf.PDFAMode;
-import org.apache.fop.pdf.PDFAction;
-import org.apache.fop.pdf.PDFAnnotList;
-import org.apache.fop.pdf.PDFDocument;
-import org.apache.fop.pdf.PDFEncryptionParams;
-import org.apache.fop.pdf.PDFFactory;
-import org.apache.fop.pdf.PDFGoTo;
-import org.apache.fop.pdf.PDFInfo;
-import org.apache.fop.pdf.PDFLink;
-import org.apache.fop.pdf.PDFNumber;
-import org.apache.fop.pdf.PDFOutline;
-import org.apache.fop.pdf.PDFPage;
-import org.apache.fop.pdf.PDFPaintingState;
-import org.apache.fop.pdf.PDFResourceContext;
-import org.apache.fop.pdf.PDFResources;
-import org.apache.fop.pdf.PDFTextUtil;
-import org.apache.fop.pdf.PDFXMode;
-import org.apache.fop.pdf.PDFXObject;
-import org.apache.fop.render.AbstractPathOrientedRenderer;
-import org.apache.fop.render.Graphics2DAdapter;
-import org.apache.fop.render.RendererContext;
-import org.apache.fop.render.pdf.PDFLogicalStructureHandler.MarkedContentInfo;
-import org.apache.fop.traits.RuleStyle;
-import org.apache.fop.util.AbstractPaintingState;
-import org.apache.fop.util.CharUtilities;
-import org.apache.fop.util.XMLUtil;
-import org.apache.fop.util.AbstractPaintingState.AbstractData;
-
-/**
- * Renderer that renders areas to PDF.
- */
-public class PDFRenderer extends AbstractPathOrientedRenderer implements PDFConfigurationConstants {
-
- /** The MIME type for PDF */
- public static final String MIME_TYPE = MimeConstants.MIME_PDF;
-
- /** Normal PDF resolution (72dpi) */
- public static final int NORMAL_PDF_RESOLUTION = 72;
-
-
- /** Controls whether comments are written to the PDF stream. */
- protected static final boolean WRITE_COMMENTS = true;
-
- /**
- * the PDF Document being created
- */
- protected PDFDocument pdfDoc;
-
- /**
- * Utility class which enables all sorts of features that are not directly connected to the
- * normal rendering process.
- */
- protected PDFRenderingUtil pdfUtil;
-
- /**
- * Map of pages using the PageViewport as the key
- * this is used for prepared pages that cannot be immediately
- * rendered
- */
- private Map pages;
-
- /**
- * Maps unique PageViewport key to PDF page reference
- */
- protected Map pageReferences = new java.util.HashMap();
-
- /**
- * Maps unique PageViewport key back to PageViewport itself
- */
- //protected Map pvReferences = new java.util.HashMap();
-
- /**
- * Maps XSL-FO element IDs to their on-page XY-positions
- * Must be used in conjunction with the page reference to fully specify the PDFGoTo details
- */
- protected Map idPositions = new java.util.HashMap();
-
- /**
- * Maps XSL-FO element IDs to PDFGoTo objects targeting the corresponding areas
- * These objects may not all be fully filled in yet
- */
- protected Map idGoTos = new java.util.HashMap();
-
- /**
- * The PDFGoTos in idGoTos that are not complete yet
- */
- protected List unfinishedGoTos = new java.util.ArrayList();
- // can't use a Set because PDFGoTo.equals returns true if the target is the same,
- // even if the object number differs
-
- /**
- * The output stream to write the document to
- */
- protected OutputStream ostream;
-
- /**
- * the /Resources object of the PDF document being created
- */
- protected PDFResources pdfResources;
-
- /** The current content generator to produce PDF commands with */
- protected PDFContentGenerator generator;
- private PDFBorderPainter borderPainter;
-
- /**
- * the current annotation list to add annotations to
- */
- protected PDFResourceContext currentContext = null;
-
- /**
- * the current page to add annotations to
- */
- protected PDFPage currentPage;
-
- /**
- * the current page's PDF reference string (to avoid numerous function calls)
- */
- protected String currentPageRef;
-
- /** page height */
- protected int pageHeight;
-
- /** Image handler registry */
- private final PDFImageHandlerRegistry imageHandlerRegistry = new PDFImageHandlerRegistry();
-
- private boolean accessEnabled;
-
- private PDFLogicalStructureHandler logicalStructureHandler;
-
- private int pageSequenceIndex;
-
- /** Reference in the structure tree to the image being rendered. */
- private String imageReference;
-
- /**
- * create the PDF renderer
- */
- public PDFRenderer() {
- }
-
- /** {@inheritDoc} */
- public void setUserAgent(FOUserAgent agent) {
- super.setUserAgent(agent);
- this.pdfUtil = new PDFRenderingUtil(getUserAgent());
- accessEnabled = agent.isAccessibilityEnabled();
- }
-
- PDFRenderingUtil getPDFUtil() {
- return this.pdfUtil;
- }
-
- PDFContentGenerator getGenerator() {
- return this.generator;
- }
-
- PDFPaintingState getState() {
- return getGenerator().getState();
- }
-
- /** {@inheritDoc} */
- public void startRenderer(OutputStream stream) throws IOException {
- if (userAgent == null) {
- throw new IllegalStateException("UserAgent must be set before starting the renderer");
- }
- ostream = stream;
- this.pdfDoc = pdfUtil.setupPDFDocument(stream);
- if (accessEnabled) {
- pdfDoc.getRoot().makeTagged();
- logicalStructureHandler = new PDFLogicalStructureHandler(pdfDoc,
- userAgent.getEventBroadcaster());
- }
- }
-
- /**
- * Checks if there are any unfinished PDFGoTos left in the list and resolves them
- * to a default position on the page. Logs a warning, as this should not happen.
- */
- protected void finishOpenGoTos() {
- int count = unfinishedGoTos.size();
- if (count > 0) {
- // TODO : page height may not be the same for all targeted pages
- Point2D.Float defaultPos = new Point2D.Float(0f, pageHeight / 1000f); // top-o-page
- while (!unfinishedGoTos.isEmpty()) {
- PDFGoTo gt = (PDFGoTo) unfinishedGoTos.get(0);
- finishIDGoTo(gt, defaultPos);
- }
- PDFEventProducer eventProducer = PDFEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.nonFullyResolvedLinkTargets(this, count);
- // dysfunctional if pageref is null
- }
- }
-
- /** {@inheritDoc} */
- public void stopRenderer() throws IOException {
- finishOpenGoTos();
-
- pdfDoc.getResources().addFonts(pdfDoc, fontInfo);
- pdfDoc.outputTrailer(ostream);
-
- this.pdfDoc = null;
- ostream = null;
-
- pages = null;
-
- pageReferences.clear();
- //pvReferences.clear();
- pdfResources = null;
- this.generator = null;
- currentContext = null;
- currentPage = null;
-
- idPositions.clear();
- idGoTos.clear();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean supportsOutOfOrder() {
- return !accessEnabled;
- }
-
- /**
- * {@inheritDoc}
- */
- public void processOffDocumentItem(OffDocumentItem odi) {
- if (odi instanceof DestinationData) {
- // render Destinations
- renderDestination((DestinationData) odi);
- } else if (odi instanceof BookmarkData) {
- // render Bookmark-Tree
- renderBookmarkTree((BookmarkData) odi);
- } else if (odi instanceof OffDocumentExtensionAttachment) {
- ExtensionAttachment attachment = ((OffDocumentExtensionAttachment)odi).getAttachment();
- if (XMPMetadata.CATEGORY.equals(attachment.getCategory())) {
- pdfUtil.renderXMPMetadata((XMPMetadata)attachment);
- }
- }
- }
-
- private void renderDestination(DestinationData dd) {
- String targetID = dd.getIDRef();
- if (targetID == null || targetID.length() == 0) {
- throw new IllegalArgumentException("DestinationData must contain a ID reference");
- }
- PageViewport pv = dd.getPageViewport();
- if (pv != null) {
- PDFGoTo gt = getPDFGoToForID(targetID, pv.getKey());
- pdfDoc.getFactory().makeDestination(
- dd.getIDRef(), gt.makeReference());
- } else {
- //Warning already issued by AreaTreeHandler (debug level is sufficient)
- log.debug("Unresolved destination item received: " + dd.getIDRef());
- }
- }
-
- /**
- * Renders a Bookmark-Tree object
- * @param bookmarks the BookmarkData object containing all the Bookmark-Items
- */
- protected void renderBookmarkTree(BookmarkData bookmarks) {
- for (int i = 0; i < bookmarks.getCount(); i++) {
- BookmarkData ext = bookmarks.getSubData(i);
- renderBookmarkItem(ext, null);
- }
- }
-
- private void renderBookmarkItem(BookmarkData bookmarkItem,
- PDFOutline parentBookmarkItem) {
- PDFOutline pdfOutline = null;
-
- String targetID = bookmarkItem.getIDRef();
- if (targetID == null || targetID.length() == 0) {
- throw new IllegalArgumentException("DestinationData must contain a ID reference");
- }
- PageViewport pv = bookmarkItem.getPageViewport();
- if (pv != null) {
- String pvKey = pv.getKey();
- PDFGoTo gt = getPDFGoToForID(targetID, pvKey);
- // create outline object:
- PDFOutline parent = parentBookmarkItem != null
- ? parentBookmarkItem
- : pdfDoc.getOutlineRoot();
- pdfOutline = pdfDoc.getFactory().makeOutline(parent,
- bookmarkItem.getBookmarkTitle(), gt, bookmarkItem.showChildItems());
- } else {
- //Warning already issued by AreaTreeHandler (debug level is sufficient)
- log.debug("Bookmark with IDRef \"" + targetID + "\" has a null PageViewport.");
- }
-
- for (int i = 0; i < bookmarkItem.getCount(); i++) {
- renderBookmarkItem(bookmarkItem.getSubData(i), pdfOutline);
- }
- }
-
- /** {@inheritDoc} */
- public Graphics2DAdapter getGraphics2DAdapter() {
- return new PDFGraphics2DAdapter(this);
- }
-
- /** {@inheritDoc} */
- protected void saveGraphicsState() {
- generator.saveGraphicsState();
- }
-
- /** {@inheritDoc} */
- protected void restoreGraphicsState() {
- generator.restoreGraphicsState();
- }
-
- /** Indicates the beginning of a text object. */
- protected void beginTextObject() {
- generator.beginTextObject();
- }
-
- /** Indicates the end of a text object. */
- protected void endTextObject() {
- generator.endTextObject();
- }
-
- /**
- * Start the next page sequence.
- * For the PDF renderer there is no concept of page sequences
- * but it uses the first available page sequence title to set
- * as the title of the PDF document, and the language of the
- * document.
- * @param pageSequence the page sequence
- */
- public void startPageSequence(PageSequence pageSequence) {
- super.startPageSequence(pageSequence);
- LineArea seqTitle = pageSequence.getTitle();
- if (seqTitle != null) {
- String str = convertTitleToString(seqTitle);
- PDFInfo info = this.pdfDoc.getInfo();
- if (info.getTitle() == null) {
- info.setTitle(str);
- }
- }
- Locale language = null;
- if (pageSequence.getLanguage() != null) {
- String lang = pageSequence.getLanguage();
- String country = pageSequence.getCountry();
- if (lang != null) {
- language = (country == null) ? new Locale(lang) : new Locale(lang, country);
- }
- if (pdfDoc.getRoot().getLanguage() == null) {
- //Only set if not set already (first non-null is used)
- //Note: No checking is performed whether the values are valid!
- pdfDoc.getRoot().setLanguage(XMLUtil.toRFC3066(language));
- }
- }
- pdfUtil.generateDefaultXMPMetadata();
- if (accessEnabled) {
- NodeList nodes = getUserAgent().getStructureTree().getPageSequence(pageSequenceIndex++);
- logicalStructureHandler.processStructureTree(nodes, language);
- }
- }
-
- /**
- * The pdf page is prepared by making the page.
- * The page is made in the pdf document without any contents
- * and then stored to add the contents later.
- * The page objects is stored using the area tree PageViewport
- * as a key.
- *
- * @param page the page to prepare
- */
- public void preparePage(PageViewport page) {
- setupPage(page);
- if (pages == null) {
- pages = new java.util.HashMap();
- }
- pages.put(page, currentPage);
- }
-
- private void setupPage(PageViewport page) {
- this.pdfResources = this.pdfDoc.getResources();
-
- Rectangle2D bounds = page.getViewArea();
- double w = bounds.getWidth();
- double h = bounds.getHeight();
- this.currentPage = this.pdfDoc.getFactory().makePage(
- this.pdfResources,
- (int) Math.round(w / 1000), (int) Math.round(h / 1000),
- page.getPageIndex());
- pageReferences.put(page.getKey(), currentPage.referencePDF());
- //pvReferences.put(page.getKey(), page);
-
- pdfUtil.generatePageLabel(page.getPageIndex(), page.getPageNumberString());
- }
-
- /**
- * This method creates a PDF stream for the current page
- * uses it as the contents of a new page. The page is written
- * immediately to the output stream.
- * {@inheritDoc}
- */
- public void renderPage(PageViewport page)
- throws IOException, FOPException {
- if (pages != null
- && (currentPage = (PDFPage) pages.get(page)) != null) {
- //Retrieve previously prepared page (out-of-line rendering)
- pages.remove(page);
- } else {
- setupPage(page);
- }
- currentPageRef = currentPage.referencePDF();
-
- if (accessEnabled) {
- logicalStructureHandler.startPage(currentPage);
- }
-
- Rectangle bounds = page.getViewArea();
- pageHeight = bounds.height;
-
- this.generator = new PDFContentGenerator(this.pdfDoc, this.ostream, this.currentPage);
- this.borderPainter = new PDFBorderPainter(this.generator);
-
- // Transform the PDF's default coordinate system (0,0 at lower left) to the PDFRenderer's
- saveGraphicsState();
- AffineTransform basicPageTransform = new AffineTransform(1, 0, 0, -1, 0,
- pageHeight / 1000f);
- generator.concatenate(basicPageTransform);
-
- super.renderPage(page);
-
- restoreGraphicsState();
- if (accessEnabled) {
- logicalStructureHandler.endPage();
- }
-
- this.pdfDoc.registerObject(generator.getStream());
- currentPage.setContents(generator.getStream());
- PDFAnnotList annots = currentPage.getAnnotations();
- if (annots != null) {
- this.pdfDoc.addObject(annots);
- }
- this.pdfDoc.addObject(currentPage);
- this.borderPainter = null;
- this.generator.flushPDFDoc();
- this.generator = null;
- }
-
- /** {@inheritDoc} */
- protected void startVParea(CTM ctm, Rectangle2D clippingRect) {
- saveGraphicsState();
- // Set the given CTM in the graphics state
- /*
- currentState.concatenate(
- new AffineTransform(CTMHelper.toPDFArray(ctm)));
- */
-
- if (clippingRect != null) {
- clipRect((float)clippingRect.getX() / 1000f,
- (float)clippingRect.getY() / 1000f,
- (float)clippingRect.getWidth() / 1000f,
- (float)clippingRect.getHeight() / 1000f);
- }
- // multiply with current CTM
- generator.concatenate(new AffineTransform(CTMHelper.toPDFArray(ctm)));
- }
-
- /** {@inheritDoc} */
- protected void endVParea() {
- restoreGraphicsState();
- }
-
- /** {@inheritDoc} */
- protected void concatenateTransformationMatrix(AffineTransform at) {
- generator.concatenate(at);
- }
-
- /**
- * Formats a float value (normally coordinates) as Strings.
- * @param value the value
- * @return the formatted value
- */
- protected static String format(float value) {
- return PDFNumber.doubleOut(value);
- }
-
- /** {@inheritDoc} */
- protected void drawBorderLine(float x1, float y1, float x2, float y2,
- boolean horz, boolean startOrBefore, int style, Color col) {
- PDFBorderPainter.drawBorderLine(generator, x1, y1, x2, y2, horz, startOrBefore, style, col);
- }
-
- /** {@inheritDoc} */
- protected void clipRect(float x, float y, float width, float height) {
- generator.add(format(x) + " " + format(y) + " "
- + format(width) + " " + format(height) + " re ");
- clip();
- }
-
- /**
- * Clip an area.
- */
- protected void clip() {
- generator.add("W\n" + "n\n");
- }
-
- /**
- * Moves the current point to (x, y), omitting any connecting line segment.
- * @param x x coordinate
- * @param y y coordinate
- */
- protected void moveTo(float x, float y) {
- generator.add(format(x) + " " + format(y) + " m ");
- }
-
- /**
- * Appends a straight line segment from the current point to (x, y). The
- * new current point is (x, y).
- * @param x x coordinate
- * @param y y coordinate
- */
- protected void lineTo(float x, float y) {
- generator.add(format(x) + " " + format(y) + " l ");
- }
-
- /**
- * Closes the current subpath by appending a straight line segment from
- * the current point to the starting point of the subpath.
- */
- protected void closePath() {
- generator.add("h ");
- }
-
- /**
- * {@inheritDoc}
- */
- protected void fillRect(float x, float y, float width, float height) {
- if (width > 0 && height > 0) {
- generator.add(format(x) + " " + format(y) + " "
- + format(width) + " " + format(height) + " re f\n");
- }
- }
-
- /**
- * Draw a line.
- *
- * @param startx the start x position
- * @param starty the start y position
- * @param endx the x end position
- * @param endy the y end position
- */
- private void drawLine(float startx, float starty, float endx, float endy) {
- generator.add(format(startx) + " " + format(starty) + " m ");
- generator.add(format(endx) + " " + format(endy) + " l S\n");
- }
-
- /**
- * Breaks out of the state stack to handle fixed block-containers.
- * @return the saved state stack to recreate later
- */
- protected List breakOutOfStateStack() {
- PDFPaintingState paintingState = getState();
- List breakOutList = new java.util.ArrayList();
- AbstractPaintingState.AbstractData data;
- while (true) {
- data = paintingState.getData();
- if (paintingState.restore() == null) {
- break;
- }
- if (breakOutList.size() == 0) {
- generator.comment("------ break out!");
- }
- breakOutList.add(0, data); //Insert because of stack-popping
- generator.restoreGraphicsState(false);
- }
- return breakOutList;
- }
-
- /**
- * Restores the state stack after a break out.
- * @param breakOutList the state stack to restore.
- */
- protected void restoreStateStackAfterBreakOut(List breakOutList) {
- generator.comment("------ restoring context after break-out...");
-// currentState.pushAll(breakOutList);
- AbstractData data;
- Iterator i = breakOutList.iterator();
- while (i.hasNext()) {
- data = (AbstractData)i.next();
- saveGraphicsState();
- AffineTransform at = data.getTransform();
- concatenateTransformationMatrix(at);
- //TODO Break-out: Also restore items such as line width and color
- //Left out for now because all this painting stuff is very
- //inconsistent. Some values go over PDFState, some don't.
- }
- generator.comment("------ done.");
- }
-
- /**
- * Returns area's id if it is the first area in the document with that id
- * (i.e. if the area qualifies as a link target).
- * Otherwise, or if the area has no id, null is returned.
- *
- * <i>NOTE</i>: area must be on currentPageViewport, otherwise result may be wrong!
- *
- * @param area the area for which to return the id
- * @return the area's id (null if the area has no id or
- * other preceding areas have the same id)
- */
- protected String getTargetableID(Area area) {
- String id = (String) area.getTrait(Trait.PROD_ID);
- if (id == null || id.length() == 0
- || !currentPageViewport.isFirstWithID(id)
- || idPositions.containsKey(id)) {
- return null;
- } else {
- return id;
- }
- }
-
- /**
- * Set XY position in the PDFGoTo and add it to the PDF trailer.
- *
- * @param gt the PDFGoTo object
- * @param position the X,Y position to set
- */
- protected void finishIDGoTo(PDFGoTo gt, Point2D.Float position) {
- gt.setPosition(position);
- pdfDoc.addTrailerObject(gt);
- unfinishedGoTos.remove(gt);
- }
-
- /**
- * Set page reference and XY position in the PDFGoTo and add it to the PDF trailer.
- *
- * @param gt the PDFGoTo object
- * @param pdfPageRef the PDF reference string of the target page object
- * @param position the X,Y position to set
- */
- protected void finishIDGoTo(PDFGoTo gt, String pdfPageRef, Point2D.Float position) {
- gt.setPageReference(pdfPageRef);
- finishIDGoTo(gt, position);
- }
-
- /**
- * Get a PDFGoTo pointing to the given id. Create one if necessary.
- * It is possible that the PDFGoTo is not fully resolved yet. In that case
- * it must be completed (and added to the PDF trailer) later.
- *
- * @param targetID the target id of the PDFGoTo
- * @param pvKey the unique key of the target PageViewport
- *
- * @return the PDFGoTo that was found or created
- */
- protected PDFGoTo getPDFGoToForID(String targetID, String pvKey) {
- // Already a PDFGoTo present for this target? If not, create.
- PDFGoTo gt = (PDFGoTo) idGoTos.get(targetID);
- if (gt == null) {
- String pdfPageRef = (String) pageReferences.get(pvKey);
- Point2D.Float position = (Point2D.Float) idPositions.get(targetID);
- // can the GoTo already be fully filled in?
- if (pdfPageRef != null && position != null) {
- // getPDFGoTo shares PDFGoTo objects as much as possible.
- // It also takes care of assignObjectNumber and addTrailerObject.
- gt = pdfDoc.getFactory().getPDFGoTo(pdfPageRef, position);
- } else {
- // Not complete yet, can't use getPDFGoTo:
- gt = new PDFGoTo(pdfPageRef);
- pdfDoc.assignObjectNumber(gt);
- // pdfDoc.addTrailerObject() will be called later, from finishIDGoTo()
- unfinishedGoTos.add(gt);
- }
- idGoTos.put(targetID, gt);
- }
- return gt;
- }
-
- /**
- * Saves id's absolute position on page for later retrieval by PDFGoTos
- *
- * @param id the id of the area whose position must be saved
- * @param pdfPageRef the PDF page reference string
- * @param relativeIPP the *relative* IP position in millipoints
- * @param relativeBPP the *relative* BP position in millipoints
- * @param tf the transformation to apply once the relative positions have been
- * converted to points
- */
- protected void saveAbsolutePosition(String id, String pdfPageRef,
- int relativeIPP, int relativeBPP, AffineTransform tf) {
- Point2D.Float position = new Point2D.Float(relativeIPP / 1000f, relativeBPP / 1000f);
- tf.transform(position, position);
- idPositions.put(id, position);
- // is there already a PDFGoTo waiting to be completed?
- PDFGoTo gt = (PDFGoTo) idGoTos.get(id);
- if (gt != null) {
- finishIDGoTo(gt, pdfPageRef, position);
- }
-/*
- // The code below auto-creates a named destination for every id in the document.
- // This should probably be controlled by a user-configurable setting, as it may
- // make the PDF file grow noticeably.
- // *** NOT YET WELL-TESTED ! ***
- if (true) {
- PDFFactory factory = pdfDoc.getFactory();
- if (gt == null) {
- gt = factory.getPDFGoTo(pdfPageRef, position);
- idGoTos.put(id, gt); // so others can pick it up too
- }
- factory.makeDestination(id, gt.referencePDF(), currentPageViewport);
- // Note: using currentPageViewport is only correct if the id is indeed on
- // the current PageViewport. But even if incorrect, it won't interfere with
- // what gets created in the PDF.
- // For speedup, we should also create a lookup map id -> PDFDestination
- }
-*/
- }
-
- /**
- * Saves id's absolute position on page for later retrieval by PDFGoTos,
- * using the currently valid transformation and the currently valid PDF page reference
- *
- * @param id the id of the area whose position must be saved
- * @param relativeIPP the *relative* IP position in millipoints
- * @param relativeBPP the *relative* BP position in millipoints
- */
- protected void saveAbsolutePosition(String id, int relativeIPP, int relativeBPP) {
- saveAbsolutePosition(id, currentPageRef,
- relativeIPP, relativeBPP, getState().getTransform());
- }
-
- /**
- * If the given block area is a possible link target, its id + absolute position will
- * be saved. The saved position is only correct if this function is called at the very
- * start of renderBlock!
- *
- * @param block the block area in question
- */
- protected void saveBlockPosIfTargetable(Block block) {
- String id = getTargetableID(block);
- if (id != null) {
- // FIXME: Like elsewhere in the renderer code, absolute and relative
- // directions are happily mixed here. This makes sure that the
- // links point to the right location, but it is not correct.
- int ipp = block.getXOffset();
- int bpp = block.getYOffset() + block.getSpaceBefore();
- int positioning = block.getPositioning();
- if (!(positioning == Block.FIXED || positioning == Block.ABSOLUTE)) {
- ipp += currentIPPosition;
- bpp += currentBPPosition;
- }
- AffineTransform tf = positioning == Block.FIXED
- ? getState().getBaseTransform()
- : getState().getTransform();
- saveAbsolutePosition(id, currentPageRef, ipp, bpp, tf);
- }
- }
-
- /**
- * If the given inline area is a possible link target, its id + absolute position will
- * be saved. The saved position is only correct if this function is called at the very
- * start of renderInlineArea!
- *
- * @param inlineArea the inline area in question
- */
- protected void saveInlinePosIfTargetable(InlineArea inlineArea) {
- String id = getTargetableID(inlineArea);
- if (id != null) {
- int extraMarginBefore = 5000; // millipoints
- int ipp = currentIPPosition;
- int bpp = currentBPPosition + inlineArea.getOffset() - extraMarginBefore;
- saveAbsolutePosition(id, ipp, bpp);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected void renderBlock(Block block) {
- saveBlockPosIfTargetable(block);
- super.renderBlock(block);
- }
-
- /** {@inheritDoc} */
- protected void renderLineArea(LineArea line) {
- super.renderLineArea(line);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void renderInlineArea(InlineArea inlineArea) {
- saveInlinePosIfTargetable(inlineArea);
- super.renderInlineArea(inlineArea);
- }
-
- /**
- * Render inline parent area.
- * For pdf this handles the inline parent area traits such as
- * links, border, background.
- * @param ip the inline parent area
- */
- public void renderInlineParent(InlineParent ip) {
-
- boolean annotsAllowed = pdfDoc.getProfile().isAnnotationAllowed();
-
- // stuff we only need if a link must be created:
- Rectangle2D ipRect = null;
- PDFFactory factory = null;
- PDFAction action = null;
- if (annotsAllowed) {
- // make sure the rect is determined *before* calling super!
- int ipp = currentIPPosition;
- int bpp = currentBPPosition + ip.getOffset();
- ipRect = new Rectangle2D.Float(ipp / 1000f, bpp / 1000f,
- ip.getIPD() / 1000f, ip.getBPD() / 1000f);
- AffineTransform transform = getState().getTransform();
- ipRect = transform.createTransformedShape(ipRect).getBounds2D();
-
- factory = pdfDoc.getFactory();
- }
-
- // render contents
- super.renderInlineParent(ip);
-
- boolean linkTraitFound = false;
-
- // try INTERNAL_LINK first
- Trait.InternalLink intLink = (Trait.InternalLink) ip.getTrait(Trait.INTERNAL_LINK);
- if (intLink != null) {
- linkTraitFound = true;
- String pvKey = intLink.getPVKey();
- String idRef = intLink.getIDRef();
- boolean pvKeyOK = pvKey != null && pvKey.length() > 0;
- boolean idRefOK = idRef != null && idRef.length() > 0;
- if (pvKeyOK && idRefOK) {
- if (annotsAllowed) {
- action = getPDFGoToForID(idRef, pvKey);
- }
- } else {
- //Warnings already issued by AreaTreeHandler
- }
- }
-
- // no INTERNAL_LINK, look for EXTERNAL_LINK
- if (!linkTraitFound) {
- Trait.ExternalLink extLink = (Trait.ExternalLink) ip.getTrait(Trait.EXTERNAL_LINK);
- if (extLink != null) {
- String extDest = extLink.getDestination();
- if (extDest != null && extDest.length() > 0) {
- linkTraitFound = true;
- if (annotsAllowed) {
- action = factory.getExternalAction(extDest, extLink.newWindow());
- }
- }
- }
- }
-
- // warn if link trait found but not allowed, else create link
- if (linkTraitFound) {
- if (!annotsAllowed) {
- log.warn("Skipping annotation for a link due to PDF profile: "
- + pdfDoc.getProfile());
- } else if (action != null) {
- PDFLink pdfLink = factory.makeLink(ipRect, action);
- if (accessEnabled) {
- String ptr = (String) ip.getTrait(Trait.PTR);
- logicalStructureHandler.addLinkContentItem(pdfLink, ptr);
- }
- currentPage.addAnnotation(pdfLink);
- }
- }
- }
-
- /** {@inheritDoc} */
- public void renderViewport(Viewport viewport) {
- imageReference = (String) viewport.getTrait(Trait.PTR);
- super.renderViewport(viewport);
- imageReference = null;
- }
-
- private Typeface getTypeface(String fontName) {
- Typeface tf = (Typeface) fontInfo.getFonts().get(fontName);
- if (tf instanceof LazyFont) {
- tf = ((LazyFont)tf).getRealFont();
- }
- return tf;
- }
-
- /** {@inheritDoc} */
- public void renderText(TextArea text) {
- renderInlineAreaBackAndBorders(text);
- Color ct = (Color) text.getTrait(Trait.COLOR);
- updateColor(ct, true);
-
- if (accessEnabled) {
- String ptr = (String) text.getTrait(Trait.PTR);
- MarkedContentInfo mci = logicalStructureHandler.addTextContentItem(ptr);
- if (generator.getTextUtil().isInTextObject()) {
- generator.separateTextElements(mci.tag, mci.mcid);
- }
- generator.beginTextObject(mci.tag, mci.mcid);
- } else {
- beginTextObject();
- }
-
- String fontName = getInternalFontNameForArea(text);
- int size = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue();
-
- // This assumes that *all* CIDFonts use a /ToUnicode mapping
- Typeface tf = getTypeface(fontName);
-
- PDFTextUtil textutil = generator.getTextUtil();
- textutil.updateTf(fontName, size / 1000f, tf.isMultiByte());
-
-
- // word.getOffset() = only height of text itself
- // currentBlockIPPosition: 0 for beginning of line; nonzero
- // where previous line area failed to take up entire allocated space
- int rx = currentIPPosition + text.getBorderAndPaddingWidthStart();
- int bl = currentBPPosition + text.getOffset() + text.getBaselineOffset();
-
- textutil.writeTextMatrix(new AffineTransform(1, 0, 0, -1, rx / 1000f, bl / 1000f));
-
- super.renderText(text);
-
- textutil.writeTJ();
-
- renderTextDecoration(tf, size, text, bl, rx);
- }
-
- /** {@inheritDoc} */
- public void renderWord(WordArea word) {
- Font font = getFontFromArea(word.getParentArea());
- String s = word.getWord();
-
- escapeText(s, word.getLetterAdjustArray(),
- font, (AbstractTextArea)word.getParentArea());
-
- super.renderWord(word);
- }
-
- /** {@inheritDoc} */
- public void renderSpace(SpaceArea space) {
- Font font = getFontFromArea(space.getParentArea());
- String s = space.getSpace();
-
- AbstractTextArea textArea = (AbstractTextArea)space.getParentArea();
- escapeText(s, null, font, textArea);
-
- if (space.isAdjustable()) {
- int tws = -((TextArea) space.getParentArea()).getTextWordSpaceAdjust()
- - 2 * textArea.getTextLetterSpaceAdjust();
-
- if (tws != 0) {
- float adjust = tws / (font.getFontSize() / 1000f);
- generator.getTextUtil().adjustGlyphTJ(adjust);
- }
- }
-
- super.renderSpace(space);
- }
-
- /**
- * Escapes text according to PDF rules.
- * @param s Text to escape
- * @param letterAdjust an array of widths for letter adjustment (may be null)
- * @param font to font in use
- * @param parentArea the parent text area to retrieve certain traits from
- */
- protected void escapeText(String s,
- int[] letterAdjust,
- Font font, AbstractTextArea parentArea) {
- escapeText(s, 0, s.length(), letterAdjust, font, parentArea);
- }
-
- /**
- * Escapes text according to PDF rules.
- * @param s Text to escape
- * @param start the start position in the text
- * @param end the end position in the text
- * @param letterAdjust an array of widths for letter adjustment (may be null)
- * @param font to font in use
- * @param parentArea the parent text area to retrieve certain traits from
- */
- protected void escapeText(String s, int start, int end,
- int[] letterAdjust,
- Font font, AbstractTextArea parentArea) {
- String fontName = font.getFontName();
- float fontSize = font.getFontSize() / 1000f;
- Typeface tf = getTypeface(fontName);
- SingleByteFont singleByteFont = null;
- if (tf instanceof SingleByteFont) {
- singleByteFont = (SingleByteFont)tf;
- }
- PDFTextUtil textutil = generator.getTextUtil();
-
- int l = s.length();
-
- for (int i = start; i < end; i++) {
- char orgChar = s.charAt(i);
- char ch;
- float glyphAdjust = 0;
- if (font.hasChar(orgChar)) {
- ch = font.mapChar(orgChar);
- if (singleByteFont != null && singleByteFont.hasAdditionalEncodings()) {
- int encoding = ch / 256;
- if (encoding == 0) {
- textutil.updateTf(fontName, fontSize, tf.isMultiByte());
- } else {
- textutil.updateTf(fontName + "_" + Integer.toString(encoding),
- fontSize, tf.isMultiByte());
- ch = (char)(ch % 256);
- }
- }
- int tls = (i < l - 1 ? parentArea.getTextLetterSpaceAdjust() : 0);
- glyphAdjust -= tls;
- } else {
- if (CharUtilities.isFixedWidthSpace(orgChar)) {
- //Fixed width space are rendered as spaces so copy/paste works in a reader
- ch = font.mapChar(CharUtilities.SPACE);
- glyphAdjust = font.getCharWidth(ch) - font.getCharWidth(orgChar);
- } else {
- ch = font.mapChar(orgChar);
- }
- }
- if (letterAdjust != null && i < l - 1) {
- glyphAdjust -= letterAdjust[i + 1];
- }
-
- textutil.writeTJMappedChar(ch);
-
- float adjust = glyphAdjust / fontSize;
-
- if (adjust != 0) {
- textutil.adjustGlyphTJ(adjust);
- }
-
- }
- }
-
- /** {@inheritDoc} */
- protected void updateColor(Color col, boolean fill) {
- generator.updateColor(col, fill, null);
- }
-
- /** {@inheritDoc} */
- public void renderImage(Image image, Rectangle2D pos) {
- endTextObject();
- String url = image.getURL();
- putImage(url, pos, image.getForeignAttributes());
- }
-
- /** {@inheritDoc} */
- protected void drawImage(String url, Rectangle2D pos, Map foreignAttributes) {
- endTextObject();
- putImage(url, pos, foreignAttributes);
- }
-
- /**
- * Adds a PDF XObject (a bitmap or form) to the PDF that will later be referenced.
- * @param uri URL of the bitmap
- * @param pos Position of the bitmap
- * @deprecated Use {@link #putImage(String, Rectangle2D, Map)} instead.
- */
- protected void putImage(String uri, Rectangle2D pos) {
- putImage(uri, pos, null);
- }
-
- /**
- * Adds a PDF XObject (a bitmap or form) to the PDF that will later be referenced.
- * @param uri URL of the bitmap
- * @param pos Position of the bitmap
- * @param foreignAttributes foreign attributes associated with the image
- */
- protected void putImage(String uri, Rectangle2D pos, Map foreignAttributes) {
- Rectangle posInt = new Rectangle(
- (int)pos.getX(),
- (int)pos.getY(),
- (int)pos.getWidth(),
- (int)pos.getHeight());
-
- uri = URISpecification.getURL(uri);
- PDFXObject xobject = pdfDoc.getXObject(uri);
- if (xobject != null) {
- float w = (float) pos.getWidth() / 1000f;
- float h = (float) pos.getHeight() / 1000f;
- placeImage((float)pos.getX() / 1000f,
- (float)pos.getY() / 1000f, w, h, xobject);
- return;
- }
- Point origin = new Point(currentIPPosition, currentBPPosition);
- int x = origin.x + posInt.x;
- int y = origin.y + posInt.y;
-
- ImageManager manager = getUserAgent().getFactory().getImageManager();
- ImageInfo info = null;
- try {
- ImageSessionContext sessionContext = getUserAgent().getImageSessionContext();
- info = manager.getImageInfo(uri, sessionContext);
-
- Map hints = ImageUtil.getDefaultHints(sessionContext);
- ImageFlavor[] supportedFlavors = imageHandlerRegistry.getSupportedFlavors();
- org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
- info, supportedFlavors, hints, sessionContext);
-
- //First check for a dynamically registered handler
- PDFImageHandler handler
- = (PDFImageHandler)imageHandlerRegistry.getHandler(img.getClass());
- if (handler != null) {
- if (log.isDebugEnabled()) {
- log.debug("Using PDFImageHandler: " + handler.getClass().getName());
- }
- try {
- RendererContext context = createRendererContext(
- x, y, posInt.width, posInt.height, foreignAttributes);
- handler.generateImage(context, img, origin, posInt);
- } catch (IOException ioe) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.imageWritingError(this, ioe);
- return;
- }
- } else {
- throw new UnsupportedOperationException(
- "No PDFImageHandler available for image: "
- + info + " (" + img.getClass().getName() + ")");
- }
- } catch (ImageException ie) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null);
- } catch (FileNotFoundException fe) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.imageNotFound(this, (info != null ? info.toString() : uri), fe, null);
- } catch (IOException ioe) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
- }
-
- // output new data
- try {
- this.generator.flushPDFDoc();
- } catch (IOException ioe) {
- // ioexception will be caught later
- log.error(ioe.getMessage());
- }
- }
-
- /**
- * Places a previously registered image at a certain place on the page.
- * @param x X coordinate
- * @param y Y coordinate
- * @param w width for image
- * @param h height for image
- * @param xobj the image XObject
- */
- public void placeImage(float x, float y, float w, float h, PDFXObject xobj) {
- if (accessEnabled) {
- MarkedContentInfo mci = logicalStructureHandler.addImageContentItem(imageReference);
- generator.saveGraphicsState(mci.tag, mci.mcid);
- } else {
- saveGraphicsState();
- }
- generator.add(format(w) + " 0 0 "
- + format(-h) + " "
- + format(currentIPPosition / 1000f + x) + " "
- + format(currentBPPosition / 1000f + h + y)
- + " cm\n" + xobj.getName() + " Do\n");
- if (accessEnabled) {
- generator.restoreGraphicsStateAccess();
- } else {
- restoreGraphicsState();
- }
- }
-
- /** {@inheritDoc} */
- protected RendererContext createRendererContext(int x, int y, int width, int height,
- Map foreignAttributes) {
- RendererContext context = super.createRendererContext(
- x, y, width, height, foreignAttributes);
- context.setProperty(PDFRendererContextConstants.PDF_DOCUMENT, pdfDoc);
- context.setProperty(PDFRendererContextConstants.OUTPUT_STREAM, ostream);
- context.setProperty(PDFRendererContextConstants.PDF_PAGE, currentPage);
- context.setProperty(PDFRendererContextConstants.PDF_CONTEXT, currentContext);
- context.setProperty(PDFRendererContextConstants.PDF_STREAM, generator.getStream());
- context.setProperty(PDFRendererContextConstants.PDF_FONT_INFO, fontInfo);
- context.setProperty(PDFRendererContextConstants.PDF_FONT_NAME, "");
- context.setProperty(PDFRendererContextConstants.PDF_FONT_SIZE, new Integer(0));
- return context;
- }
-
- /** {@inheritDoc} */
- public void renderDocument(Document doc, String ns, Rectangle2D pos, Map foreignAttributes) {
- if (accessEnabled) {
- MarkedContentInfo mci = logicalStructureHandler.addImageContentItem(imageReference);
- generator.beginMarkedContentSequence(mci.tag, mci.mcid);
- }
- super.renderDocument(doc, ns, pos, foreignAttributes);
- if (accessEnabled) {
- generator.endMarkedContentSequence();
- }
- }
-
- /**
- * Render leader area.
- * This renders a leader area which is an area with a rule.
- * @param area the leader area to render
- */
- public void renderLeader(Leader area) {
- renderInlineAreaBackAndBorders(area);
-
- int style = area.getRuleStyle();
- int ruleThickness = area.getRuleThickness();
- int startx = currentIPPosition + area.getBorderAndPaddingWidthStart();
- int starty = currentBPPosition + area.getOffset() + (ruleThickness / 2);
- int endx = currentIPPosition
- + area.getBorderAndPaddingWidthStart()
- + area.getIPD();
- Color col = (Color)area.getTrait(Trait.COLOR);
-
- endTextObject();
- borderPainter.drawLine(new Point(startx, starty), new Point(endx, starty),
- ruleThickness, col, RuleStyle.valueOf(style));
- super.renderLeader(area);
- }
-
- /** {@inheritDoc} */
- public String getMimeType() {
- return MIME_TYPE;
- }
-
- /**
- * Sets the PDF/A mode for the PDF renderer.
- * @param mode the PDF/A mode
- */
- public void setAMode(PDFAMode mode) {
- this.pdfUtil.setAMode(mode);
- }
-
- /**
- * Sets the PDF/X mode for the PDF renderer.
- * @param mode the PDF/X mode
- */
- public void setXMode(PDFXMode mode) {
- this.pdfUtil.setXMode(mode);
- }
-
- /**
- * Sets the output color profile for the PDF renderer.
- * @param outputProfileURI the URI to the output color profile
- */
- public void setOutputProfileURI(String outputProfileURI) {
- this.pdfUtil.setOutputProfileURI(outputProfileURI);
- }
-
- /**
- * Sets the filter map to be used by the PDF renderer.
- * @param filterMap the filter map
- */
- public void setFilterMap(Map filterMap) {
- this.pdfUtil.setFilterMap(filterMap);
- }
-
- /**
- * Sets the encryption parameters used by the PDF renderer.
- * @param encryptionParams the encryption parameters
- */
- public void setEncryptionParams(PDFEncryptionParams encryptionParams) {
- this.pdfUtil.setEncryptionParams(encryptionParams);
- }
-
- MarkedContentInfo addCurrentImageToStructureTree() {
- return logicalStructureHandler.addImageContentItem(imageReference);
- }
-}
-
diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java b/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
index f3511298e..9ebb1d5a1 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
@@ -51,22 +51,12 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator {
}
/**
- * Configure the PDF renderer.
- * Get the configuration to be used for pdf stream filters,
- * fonts etc.
+ * Throws an UnsupportedOperationException.
*
- * @param renderer pdf renderer
- * @throws FOPException fop exception
+ * @param renderer not used
*/
- public void configure(Renderer renderer) throws FOPException {
- Configuration cfg = super.getRendererConfig(renderer);
- if (cfg != null) {
- PDFRenderer pdfRenderer = (PDFRenderer)renderer;
- super.configure(renderer);
-
- PDFRenderingUtil pdfUtil = pdfRenderer.getPDFUtil();
- configure(cfg, pdfUtil);
- }
+ public void configure(Renderer renderer) {
+ throw new UnsupportedOperationException();
}
private void configure(Configuration cfg, PDFRenderingUtil pdfUtil) throws FOPException {
@@ -80,20 +70,20 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator {
LogUtil.handleException(log, e, false);
}
- String s = cfg.getChild(PDFRenderer.PDF_A_MODE, true).getValue(null);
+ String s = cfg.getChild(PDFConfigurationConstants.PDF_A_MODE, true).getValue(null);
if (s != null) {
pdfUtil.setAMode(PDFAMode.valueOf(s));
}
- s = cfg.getChild(PDFRenderer.PDF_X_MODE, true).getValue(null);
+ s = cfg.getChild(PDFConfigurationConstants.PDF_X_MODE, true).getValue(null);
if (s != null) {
pdfUtil.setXMode(PDFXMode.valueOf(s));
}
Configuration encryptionParamsConfig
- = cfg.getChild(PDFRenderer.ENCRYPTION_PARAMS, false);
+ = cfg.getChild(PDFConfigurationConstants.ENCRYPTION_PARAMS, false);
if (encryptionParamsConfig != null) {
PDFEncryptionParams encryptionParams = new PDFEncryptionParams();
Configuration ownerPasswordConfig = encryptionParamsConfig.getChild(
- PDFRenderer.OWNER_PASSWORD, false);
+ PDFConfigurationConstants.OWNER_PASSWORD, false);
if (ownerPasswordConfig != null) {
String ownerPassword = ownerPasswordConfig.getValue(null);
if (ownerPassword != null) {
@@ -101,7 +91,7 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator {
}
}
Configuration userPasswordConfig = encryptionParamsConfig.getChild(
- PDFRenderer.USER_PASSWORD, false);
+ PDFConfigurationConstants.USER_PASSWORD, false);
if (userPasswordConfig != null) {
String userPassword = userPasswordConfig.getValue(null);
if (userPassword != null) {
@@ -109,33 +99,33 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator {
}
}
Configuration noPrintConfig = encryptionParamsConfig.getChild(
- PDFRenderer.NO_PRINT, false);
+ PDFConfigurationConstants.NO_PRINT, false);
if (noPrintConfig != null) {
encryptionParams.setAllowPrint(false);
}
Configuration noCopyContentConfig = encryptionParamsConfig.getChild(
- PDFRenderer.NO_COPY_CONTENT, false);
+ PDFConfigurationConstants.NO_COPY_CONTENT, false);
if (noCopyContentConfig != null) {
encryptionParams.setAllowCopyContent(false);
}
Configuration noEditContentConfig = encryptionParamsConfig.getChild(
- PDFRenderer.NO_EDIT_CONTENT, false);
+ PDFConfigurationConstants.NO_EDIT_CONTENT, false);
if (noEditContentConfig != null) {
encryptionParams.setAllowEditContent(false);
}
Configuration noAnnotationsConfig = encryptionParamsConfig.getChild(
- PDFRenderer.NO_ANNOTATIONS, false);
+ PDFConfigurationConstants.NO_ANNOTATIONS, false);
if (noAnnotationsConfig != null) {
encryptionParams.setAllowEditAnnotations(false);
}
pdfUtil.setEncryptionParams(encryptionParams);
}
- s = cfg.getChild(PDFRenderer.KEY_OUTPUT_PROFILE, true).getValue(null);
+ s = cfg.getChild(PDFConfigurationConstants.KEY_OUTPUT_PROFILE, true).getValue(null);
if (s != null) {
pdfUtil.setOutputProfileURI(s);
}
Configuration disableColorSpaceConfig = cfg.getChild(
- PDFRenderer.KEY_DISABLE_SRGB_COLORSPACE, false);
+ PDFConfigurationConstants.KEY_DISABLE_SRGB_COLORSPACE, false);
if (disableColorSpaceConfig != null) {
pdfUtil.setDisableSRGBColorSpace(
disableColorSpaceConfig.getValueAsBoolean(false));
diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java b/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java
deleted file mode 100644
index fb65c9d74..000000000
--- a/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.pdf;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.AbstractRendererMaker;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererConfigurator;
-
-/**
- * RendererMaker for the PDF Renderer.
- */
-public class PDFRendererMaker extends AbstractRendererMaker {
-
- private static final String[] MIMES = new String[] {MimeConstants.MIME_PDF};
-
- /** {@inheritDoc} */
- public Renderer makeRenderer(FOUserAgent userAgent) {
- return new PDFRenderer();
- }
-
- /** {@inheritDoc} */
- public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
- return new PDFRendererConfigurator(userAgent);
- }
-
- /** {@inheritDoc} */
- public boolean needsOutputStream() {
- return true;
- }
-
- /** {@inheritDoc} */
- public String[] getSupportedMimeTypes() {
- return MIMES;
- }
-
-}
diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
index 3d68812b1..ae205a1e5 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
@@ -20,6 +20,7 @@
package org.apache.fop.render.pdf;
import java.awt.color.ICC_Profile;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -33,6 +34,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.image.loader.util.ImageUtil;
import org.apache.xmlgraphics.xmp.Metadata;
import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter;
import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema;
@@ -41,19 +43,27 @@ import org.apache.fop.accessibility.Accessibility;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.extensions.xmp.XMPMetadata;
import org.apache.fop.pdf.PDFAMode;
+import org.apache.fop.pdf.PDFArray;
import org.apache.fop.pdf.PDFConformanceException;
import org.apache.fop.pdf.PDFDictionary;
import org.apache.fop.pdf.PDFDocument;
+import org.apache.fop.pdf.PDFEmbeddedFile;
+import org.apache.fop.pdf.PDFEmbeddedFiles;
import org.apache.fop.pdf.PDFEncryptionManager;
import org.apache.fop.pdf.PDFEncryptionParams;
+import org.apache.fop.pdf.PDFFileSpec;
import org.apache.fop.pdf.PDFICCBasedColorSpace;
import org.apache.fop.pdf.PDFICCStream;
import org.apache.fop.pdf.PDFInfo;
import org.apache.fop.pdf.PDFMetadata;
+import org.apache.fop.pdf.PDFNames;
import org.apache.fop.pdf.PDFNumsArray;
import org.apache.fop.pdf.PDFOutputIntent;
import org.apache.fop.pdf.PDFPageLabels;
+import org.apache.fop.pdf.PDFReference;
+import org.apache.fop.pdf.PDFText;
import org.apache.fop.pdf.PDFXMode;
+import org.apache.fop.render.pdf.extensions.PDFEmbeddedFileExtensionAttachment;
import org.apache.fop.util.ColorProfileUtil;
/**
@@ -413,4 +423,63 @@ class PDFRenderingUtil implements PDFConfigurationConstants {
nums.put(pageIndex, dict);
}
+ /**
+ * Adds an embedded file to the PDF file.
+ * @param embeddedFile the object representing the embedded file to be added
+ * @throws IOException if an I/O error occurs
+ */
+ public void addEmbeddedFile(PDFEmbeddedFileExtensionAttachment embeddedFile)
+ throws IOException {
+ this.pdfDoc.getProfile().verifyEmbeddedFilesAllowed();
+ PDFNames names = this.pdfDoc.getRoot().getNames();
+ if (names == null) {
+ //Add Names if not already present
+ names = this.pdfDoc.getFactory().makeNames();
+ this.pdfDoc.getRoot().setNames(names);
+ }
+
+ //Create embedded file
+ PDFEmbeddedFile file = new PDFEmbeddedFile();
+ this.pdfDoc.registerObject(file);
+ Source src = getUserAgent().resolveURI(embeddedFile.getSrc());
+ InputStream in = ImageUtil.getInputStream(src);
+ if (in == null) {
+ throw new FileNotFoundException(embeddedFile.getSrc());
+ }
+ try {
+ OutputStream out = file.getBufferOutputStream();
+ IOUtils.copyLarge(in, out);
+ } finally {
+ IOUtils.closeQuietly(in);
+ }
+ PDFDictionary dict = new PDFDictionary();
+ dict.put("F", file);
+ String filename = PDFText.toPDFString(embeddedFile.getFilename(), '_');
+ PDFFileSpec fileSpec = new PDFFileSpec(filename);
+ fileSpec.setEmbeddedFile(dict);
+ if (embeddedFile.getDesc() != null) {
+ fileSpec.setDescription(embeddedFile.getDesc());
+ }
+ this.pdfDoc.registerObject(fileSpec);
+
+ //Make sure there is an EmbeddedFiles in the Names dictionary
+ PDFEmbeddedFiles embeddedFiles = names.getEmbeddedFiles();
+ if (embeddedFiles == null) {
+ embeddedFiles = new PDFEmbeddedFiles();
+ this.pdfDoc.assignObjectNumber(embeddedFiles);
+ this.pdfDoc.addTrailerObject(embeddedFiles);
+ names.setEmbeddedFiles(embeddedFiles);
+ }
+
+ //Add to EmbeddedFiles in the Names dictionary
+ PDFArray nameArray = embeddedFiles.getNames();
+ if (nameArray == null) {
+ nameArray = new PDFArray();
+ embeddedFiles.setNames(nameArray);
+ }
+ String name = PDFText.toPDFString(filename);
+ nameArray.add(name);
+ nameArray.add(new PDFReference(fileSpec));
+ }
+
}
diff --git a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
index f9fa8bfeb..434daa5b0 100644
--- a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
+++ b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
@@ -19,26 +19,14 @@
package org.apache.fop.render.pdf;
-import java.awt.Color;
-import java.awt.geom.AffineTransform;
-import java.io.IOException;
import java.io.OutputStream;
import java.util.Map;
-import org.w3c.dom.Document;
-
import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.batik.bridge.BridgeContext;
-import org.apache.batik.bridge.GVTBuilder;
-import org.apache.batik.dom.svg.SVGDOMImplementation;
-import org.apache.batik.gvt.GraphicsNode;
-import org.apache.batik.util.SVGConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fonts.FontInfo;
-import org.apache.fop.image.loader.batik.BatikUtil;
import org.apache.fop.pdf.PDFDocument;
import org.apache.fop.pdf.PDFPage;
import org.apache.fop.pdf.PDFResourceContext;
@@ -47,11 +35,6 @@ import org.apache.fop.render.ImageHandlerUtil;
import org.apache.fop.render.Renderer;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RendererContextConstants;
-import org.apache.fop.svg.PDFAElementBridge;
-import org.apache.fop.svg.PDFBridgeContext;
-import org.apache.fop.svg.PDFGraphics2D;
-import org.apache.fop.svg.SVGEventProducer;
-import org.apache.fop.svg.SVGUserAgent;
/**
* PDF XML handler for SVG (uses Apache Batik).
@@ -97,177 +80,37 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler
*/
public static class PDFInfo {
/** see PDF_DOCUMENT */
- public PDFDocument pdfDoc;
+ public PDFDocument pdfDoc; // CSOK: VisibilityModifier
/** see OUTPUT_STREAM */
- public OutputStream outputStream;
+ public OutputStream outputStream; // CSOK: VisibilityModifier
/** see PDF_PAGE */
- public PDFPage pdfPage;
+ public PDFPage pdfPage; // CSOK: VisibilityModifier
/** see PDF_CONTEXT */
- public PDFResourceContext pdfContext;
+ public PDFResourceContext pdfContext; // CSOK: VisibilityModifier
/** see PDF_STREAM */
//public PDFStream currentStream;
/** see PDF_WIDTH */
- public int width;
+ public int width; // CSOK: VisibilityModifier
/** see PDF_HEIGHT */
- public int height;
+ public int height; // CSOK: VisibilityModifier
/** see PDF_FONT_INFO */
- public FontInfo fi;
+ public FontInfo fi; // CSOK: VisibilityModifier
/** see PDF_FONT_NAME */
- public String currentFontName;
+ public String currentFontName; // CSOK: VisibilityModifier
/** see PDF_FONT_SIZE */
- public int currentFontSize;
+ public int currentFontSize; // CSOK: VisibilityModifier
/** see PDF_XPOS */
- public int currentXPosition;
+ public int currentXPosition; // CSOK: VisibilityModifier
/** see PDF_YPOS */
- public int currentYPosition;
+ public int currentYPosition; // CSOK: VisibilityModifier
/** see PDF_HANDLER_CONFIGURATION */
- public Configuration cfg;
+ public Configuration cfg; // CSOK: VisibilityModifier
/** true if SVG should be rendered as a bitmap instead of natively */
- public boolean paintAsBitmap;
- }
-
- /**
- * {@inheritDoc}
- */
- protected void renderSVGDocument(RendererContext context,
- Document doc) {
- PDFRenderer renderer = (PDFRenderer)context.getRenderer();
- PDFInfo pdfInfo = getPDFInfo(context);
- if (pdfInfo.paintAsBitmap) {
- try {
- super.renderSVGDocument(context, doc);
- } catch (IOException ioe) {
- SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
- context.getUserAgent().getEventBroadcaster());
- eventProducer.svgRenderingError(this, ioe, getDocumentURI(doc));
- }
- return;
- }
- int xOffset = pdfInfo.currentXPosition;
- int yOffset = pdfInfo.currentYPosition;
-
- FOUserAgent userAgent = context.getUserAgent();
- final float deviceResolution = userAgent.getTargetResolution();
- if (log.isDebugEnabled()) {
- log.debug("Generating SVG at " + deviceResolution + "dpi.");
- }
-
- final float uaResolution = userAgent.getSourceResolution();
- SVGUserAgent ua = new SVGUserAgent(userAgent, new AffineTransform());
-
- //Scale for higher resolution on-the-fly images from Batik
- double s = uaResolution / deviceResolution;
- AffineTransform resolutionScaling = new AffineTransform();
- resolutionScaling.scale(s, s);
-
- //Controls whether text painted by Batik is generated using text or path operations
- boolean strokeText = false;
- Configuration cfg = pdfInfo.cfg;
- if (cfg != null) {
- strokeText = cfg.getChild("stroke-text", true).getValueAsBoolean(strokeText);
- }
-
- BridgeContext ctx = new PDFBridgeContext(ua,
- (strokeText ? null : pdfInfo.fi),
- userAgent.getFactory().getImageManager(),
- userAgent.getImageSessionContext(),
- new AffineTransform());
-
- //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
- //to it.
- Document clonedDoc = BatikUtil.cloneSVGDocument(doc);
-
- GraphicsNode root;
- try {
- GVTBuilder builder = new GVTBuilder();
- root = builder.build(ctx, clonedDoc);
- } catch (Exception e) {
- SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
- context.getUserAgent().getEventBroadcaster());
- eventProducer.svgNotBuilt(this, e, getDocumentURI(doc));
- return;
- }
- // get the 'width' and 'height' attributes of the SVG document
- float w = (float)ctx.getDocumentSize().getWidth() * 1000f;
- float h = (float)ctx.getDocumentSize().getHeight() * 1000f;
-
- float sx = pdfInfo.width / w;
- float sy = pdfInfo.height / h;
-
- //Scaling and translation for the bounding box of the image
- AffineTransform scaling = new AffineTransform(
- sx, 0, 0, sy, xOffset / 1000f, yOffset / 1000f);
-
- //Transformation matrix that establishes the local coordinate system for the SVG graphic
- //in relation to the current coordinate system
- AffineTransform imageTransform = new AffineTransform();
- imageTransform.concatenate(scaling);
- imageTransform.concatenate(resolutionScaling);
-
- /*
- * Clip to the svg area.
- * Note: To have the svg overlay (under) a text area then use
- * an fo:block-container
- */
- PDFContentGenerator generator = renderer.getGenerator();
- generator.comment("SVG setup");
- generator.saveGraphicsState();
- generator.setColor(Color.black, false);
- generator.setColor(Color.black, true);
-
- if (!scaling.isIdentity()) {
- generator.comment("viewbox");
- generator.add(CTMHelper.toPDFString(scaling, false) + " cm\n");
- }
-
- //SVGSVGElement svg = ((SVGDocument)doc).getRootElement();
-
- if (pdfInfo.pdfContext == null) {
- pdfInfo.pdfContext = pdfInfo.pdfPage;
- }
- PDFGraphics2D graphics = new PDFGraphics2D(true, pdfInfo.fi,
- pdfInfo.pdfDoc,
- pdfInfo.pdfContext, pdfInfo.pdfPage.referencePDF(),
- pdfInfo.currentFontName, pdfInfo.currentFontSize);
- graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
-
- if (!resolutionScaling.isIdentity()) {
- generator.comment("resolution scaling for " + uaResolution
- + " -> " + deviceResolution + "\n");
- generator.add(
- CTMHelper.toPDFString(resolutionScaling, false) + " cm\n");
- graphics.scale(1 / s, 1 / s);
- }
-
- generator.comment("SVG start");
-
- //Save state and update coordinate system for the SVG image
- generator.getState().save();
- generator.getState().concatenate(imageTransform);
-
- //Now that we have the complete transformation matrix for the image, we can update the
- //transformation matrix for the AElementBridge.
- PDFAElementBridge aBridge = (PDFAElementBridge)ctx.getBridge(
- SVGDOMImplementation.SVG_NAMESPACE_URI, SVGConstants.SVG_A_TAG);
- aBridge.getCurrentTransform().setTransform(generator.getState().getTransform());
-
- graphics.setPaintingState(generator.getState());
- graphics.setOutputStream(pdfInfo.outputStream);
- try {
- root.paint(graphics);
- generator.add(graphics.getString());
- } catch (Exception e) {
- SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
- context.getUserAgent().getEventBroadcaster());
- eventProducer.svgRenderingError(this, e, getDocumentURI(doc));
- }
- generator.getState().restore();
- generator.restoreGraphicsState();
- generator.comment("SVG end");
+ public boolean paintAsBitmap; // CSOK: VisibilityModifier
}
/** {@inheritDoc} */
public boolean supportsRenderer(Renderer renderer) {
- return (renderer instanceof PDFRenderer);
+ return false;
}
}
diff --git a/src/java/org/apache/fop/render/pdf/extensions/AbstractPDFExtensionElement.java b/src/java/org/apache/fop/render/pdf/extensions/AbstractPDFExtensionElement.java
new file mode 100644
index 000000000..2b50112c0
--- /dev/null
+++ b/src/java/org/apache/fop/render/pdf/extensions/AbstractPDFExtensionElement.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.pdf.extensions;
+
+// FOP
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.extensions.ExtensionAttachment;
+
+/**
+ * Base class for the PDF-specific extension elements.
+ */
+public abstract class AbstractPDFExtensionElement extends FONode {
+
+ /**Extension attachment. */
+ protected PDFExtensionAttachment attachment;
+
+ /**
+ * Default constructor
+ *
+ * @param parent parent of this node
+ * @see org.apache.fop.fo.FONode#FONode(FONode)
+ */
+ public AbstractPDFExtensionElement(FONode parent) {
+ super(parent);
+ }
+
+ /** {@inheritDoc} */
+ public String getNamespaceURI() {
+ return PDFElementMapping.NAMESPACE;
+ }
+
+ /** {@inheritDoc} */
+ public String getNormalNamespacePrefix() {
+ return "pdf";
+ }
+
+ /**
+ * Returns the extension attachment.
+ * @return the extension attachment if one is created by the extension element, null otherwise.
+ * @see org.apache.fop.fo.FONode#getExtensionAttachment()
+ */
+ public ExtensionAttachment getExtensionAttachment() {
+ if (attachment == null) {
+ this.attachment = (PDFExtensionAttachment)instantiateExtensionAttachment();
+ }
+ return this.attachment;
+ }
+
+ /**
+ * Instantiates extension attachment object.
+ * @return extension attachment
+ */
+ protected abstract ExtensionAttachment instantiateExtensionAttachment();
+
+}
+
diff --git a/src/java/org/apache/fop/render/pdf/extensions/PDFElementMapping.java b/src/java/org/apache/fop/render/pdf/extensions/PDFElementMapping.java
new file mode 100644
index 000000000..c70ed3635
--- /dev/null
+++ b/src/java/org/apache/fop/render/pdf/extensions/PDFElementMapping.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.pdf.extensions;
+
+import org.apache.fop.fo.ElementMapping;
+import org.apache.fop.fo.FONode;
+
+/**
+ * This class provides the element mapping for the PDF-specific extensions.
+ */
+public class PDFElementMapping extends ElementMapping {
+
+ /** Namespace for the extension */
+ public static final String NAMESPACE = "http://xmlgraphics.apache.org/fop/extensions/pdf";
+
+ /** Main constructor */
+ public PDFElementMapping() {
+ this.namespaceURI = NAMESPACE;
+ }
+
+ /** {@inheritDoc} */
+ protected void initialize() {
+ if (foObjs == null) {
+ foObjs = new java.util.HashMap<String, Maker>();
+ foObjs.put(PDFEmbeddedFileElement.ELEMENT, new PDFEmbeddedFileMaker());
+ }
+ }
+
+ static class PDFEmbeddedFileMaker extends ElementMapping.Maker {
+ public FONode make(FONode parent) {
+ return new PDFEmbeddedFileElement(parent);
+ }
+ }
+}
diff --git a/src/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileElement.java b/src/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileElement.java
new file mode 100644
index 000000000..b2d85dd10
--- /dev/null
+++ b/src/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileElement.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.pdf.extensions;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.datatypes.URISpecification;
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.extensions.ExtensionAttachment;
+
+/**
+ * Extension element for pdf:embedded-file.
+ */
+public class PDFEmbeddedFileElement extends AbstractPDFExtensionElement {
+
+ /** name of element */
+ protected static final String ELEMENT = "embedded-file";
+
+ /**
+ * Main constructor
+ * @param parent parent FO node
+ */
+ protected PDFEmbeddedFileElement(FONode parent) {
+ super(parent);
+ }
+
+ /** {@inheritDoc} */
+ protected void startOfNode() throws FOPException {
+ super.startOfNode();
+ if (parent.getNameId() != Constants.FO_DECLARATIONS) {
+ invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(),
+ "rule.childOfDeclarations");
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void processNode(String elementName, Locator locator,
+ Attributes attlist, PropertyList propertyList)
+ throws FOPException {
+ PDFEmbeddedFileExtensionAttachment embeddedFile
+ = (PDFEmbeddedFileExtensionAttachment)getExtensionAttachment();
+ String desc = attlist.getValue("description");
+ if (desc != null && desc.length() > 0) {
+ embeddedFile.setDesc(desc);
+ }
+ String src = attlist.getValue("src");
+ src = URISpecification.getURL(src);
+ if (src != null && src.length() > 0) {
+ embeddedFile.setSrc(src);
+ } else {
+ missingPropertyError("src");
+ }
+ String filename = attlist.getValue("filename");
+ if (filename == null || filename.length() == 0) {
+ try {
+ URI uri = new URI(src);
+ String path = uri.getPath();
+ int idx = path.lastIndexOf('/');
+ if (idx > 0) {
+ filename = path.substring(idx + 1);
+ } else {
+ filename = path;
+ }
+ embeddedFile.setFilename(filename);
+ } catch (URISyntaxException e) {
+ //Filename could not be deduced from URI
+ missingPropertyError("name");
+ }
+ }
+ embeddedFile.setFilename(filename);
+ }
+
+ /** {@inheritDoc} */
+ public String getLocalName() {
+ return ELEMENT;
+ }
+
+ /** {@inheritDoc} */
+ protected ExtensionAttachment instantiateExtensionAttachment() {
+ return new PDFEmbeddedFileExtensionAttachment();
+ }
+}
diff --git a/src/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileExtensionAttachment.java b/src/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileExtensionAttachment.java
new file mode 100644
index 000000000..5f3f16dbb
--- /dev/null
+++ b/src/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileExtensionAttachment.java
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.pdf.extensions;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * This is the pass-through value object for the PDF extension.
+ */
+public class PDFEmbeddedFileExtensionAttachment extends PDFExtensionAttachment {
+
+ /** element name */
+ protected static final String ELEMENT = "embedded-file";
+
+ /** name of file to be embedded */
+ private static final String ATT_NAME = "filename";
+
+ /** source of file to be embedded (URI) */
+ private static final String ATT_SRC = "src";
+
+ /** a description of the file to be embedded */
+ private static final String ATT_DESC = "desc";
+
+ /** filename attribute */
+ private String filename = null;
+
+ /** description attribute (optional) */
+ private String desc = null;
+
+ /** source name attribute */
+ private String src = null;
+
+ /**
+ * No-argument contructor.
+ */
+ public PDFEmbeddedFileExtensionAttachment() {
+ super();
+ }
+
+ /**
+ * Default constructor.
+ * @param filename the name of the file
+ * @param src the location of the file
+ * @param desc the description of the file
+ */
+ public PDFEmbeddedFileExtensionAttachment(String filename, String src, String desc) {
+ super();
+ this.filename = filename;
+ this.src = src;
+ this.desc = desc;
+ }
+
+ /**
+ * Returns the file name.
+ * @return the file name
+ */
+ public String getFilename() {
+ return filename;
+ }
+
+ /**
+ * Sets the file name.
+ * @param name The file name to set.
+ */
+ public void setFilename(String name) {
+ this.filename = name;
+ }
+
+ /**
+ * Returns the file description.
+ * @return the description
+ */
+ public String getDesc() {
+ return desc;
+ }
+
+ /**
+ * Sets the description of the file.
+ * @param desc the description to set
+ */
+ public void setDesc(String desc) {
+ this.desc = desc;
+ }
+
+ /**
+ * Returns the source URI of the file.
+ * @return the source URI
+ */
+ public String getSrc() {
+ return src;
+ }
+
+ /**
+ * Sets the source URI of the file.
+ * @param src the source URI
+ */
+ public void setSrc(String src) {
+ this.src = src;
+ }
+
+ /** {@inheritDoc} */
+ public String getCategory() {
+ return CATEGORY;
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return "PDFEmbeddedFile(name=" + getFilename() + ", " + getSrc() + ")";
+ }
+
+ /**
+ * @return the element name
+ */
+ protected String getElement() {
+ return ELEMENT;
+ }
+
+ /** {@inheritDoc} */
+ public void toSAX(ContentHandler handler) throws SAXException {
+ AttributesImpl atts = new AttributesImpl();
+ if (filename != null && filename.length() > 0) {
+ atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", filename);
+ }
+ if (src != null && src.length() > 0) {
+ atts.addAttribute(null, ATT_SRC, ATT_SRC, "CDATA", src);
+ }
+ if (desc != null && desc.length() > 0) {
+ atts.addAttribute(null, ATT_DESC, ATT_DESC, "CDATA", desc);
+ }
+ String element = getElement();
+ handler.startElement(CATEGORY, element, element, atts);
+ handler.endElement(CATEGORY, element, element);
+ }
+
+}
diff --git a/src/java/org/apache/fop/render/pdf/extensions/PDFExtensionAttachment.java b/src/java/org/apache/fop/render/pdf/extensions/PDFExtensionAttachment.java
new file mode 100644
index 000000000..a4f5b47b7
--- /dev/null
+++ b/src/java/org/apache/fop/render/pdf/extensions/PDFExtensionAttachment.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.pdf.extensions;
+
+import org.apache.xmlgraphics.util.XMLizable;
+
+import org.apache.fop.fo.extensions.ExtensionAttachment;
+
+/**
+ * This is the pass-through value object for the PDF extension.
+ */
+public abstract class PDFExtensionAttachment implements ExtensionAttachment, XMLizable {
+
+ /** The category URI for this extension attachment. */
+ public static final String CATEGORY = "apache:fop:extensions:pdf";
+
+ /**
+ * Default constructor.
+ */
+ public PDFExtensionAttachment() {
+ //nop
+ }
+
+ /**
+ * @return the category URI
+ * @see org.apache.fop.fo.extensions.ExtensionAttachment#getCategory()
+ */
+ public String getCategory() {
+ return CATEGORY;
+ }
+
+ /** @return type name */
+ public String getType() {
+ String className = getClass().getName();
+ return className.substring(className.lastIndexOf('.') + 3);
+ }
+
+ /**
+ * @return a string representation of this object
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return getType();
+ }
+
+ /** @return element */
+ protected abstract String getElement();
+}
diff --git a/src/java/org/apache/fop/render/pdf/extensions/PDFExtensionHandler.java b/src/java/org/apache/fop/render/pdf/extensions/PDFExtensionHandler.java
new file mode 100644
index 000000000..e7e863a23
--- /dev/null
+++ b/src/java/org/apache/fop/render/pdf/extensions/PDFExtensionHandler.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.pdf.extensions;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+import org.xml.sax.helpers.DefaultHandler;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.util.ContentHandlerFactory;
+import org.apache.fop.util.ContentHandlerFactory.ObjectBuiltListener;
+
+/**
+ * ContentHandler (parser) for restoring PDF extension objects from XML.
+ */
+public class PDFExtensionHandler extends DefaultHandler
+ implements ContentHandlerFactory.ObjectSource {
+
+ /** Logger instance */
+ protected static final Log log = LogFactory.getLog(PDFExtensionHandler.class);
+
+ private Attributes lastAttributes;
+
+ private PDFExtensionAttachment returnedObject;
+ private ObjectBuiltListener listener;
+
+ /** {@inheritDoc} */
+ public void startElement(String uri, String localName, String qName, Attributes attributes)
+ throws SAXException {
+ boolean handled = false;
+ if (PDFExtensionAttachment.CATEGORY.equals(uri)) {
+ lastAttributes = new AttributesImpl(attributes);
+ handled = false;
+ if (localName.equals(PDFEmbeddedFileExtensionAttachment.ELEMENT)) {
+ //handled in endElement
+ handled = true;
+ }
+ }
+ if (!handled) {
+ if (PDFExtensionAttachment.CATEGORY.equals(uri)) {
+ throw new SAXException("Unhandled element " + localName
+ + " in namespace: " + uri);
+ } else {
+ log.warn("Unhandled element " + localName
+ + " in namespace: " + uri);
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ if (PDFExtensionAttachment.CATEGORY.equals(uri)) {
+ if (PDFEmbeddedFileExtensionAttachment.ELEMENT.equals(localName)) {
+ String name = lastAttributes.getValue("name");
+ String src = lastAttributes.getValue("src");
+ String desc = lastAttributes.getValue("description");
+ this.returnedObject = new PDFEmbeddedFileExtensionAttachment(name, src, desc);
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void endDocument() throws SAXException {
+ if (listener != null) {
+ listener.notifyObjectBuilt(getObject());
+ }
+ }
+
+ /** {@inheritDoc} */
+ public Object getObject() {
+ return returnedObject;
+ }
+
+ /** {@inheritDoc} */
+ public void setObjectBuiltListener(ObjectBuiltListener listener) {
+ this.listener = listener;
+ }
+}
diff --git a/src/java/org/apache/fop/render/ps/FontResourceCache.java b/src/java/org/apache/fop/render/ps/FontResourceCache.java
index 7d6f076a7..086117536 100644
--- a/src/java/org/apache/fop/render/ps/FontResourceCache.java
+++ b/src/java/org/apache/fop/render/ps/FontResourceCache.java
@@ -21,18 +21,17 @@ package org.apache.fop.render.ps;
import java.util.Map;
-import org.apache.xmlgraphics.ps.PSResource;
-
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.LazyFont;
import org.apache.fop.fonts.Typeface;
+import org.apache.xmlgraphics.ps.PSResource;
/**
* A cache for font resource objects.
*/
class FontResourceCache {
- private FontInfo fontInfo;
+ private final FontInfo fontInfo;
/** This is a map of PSResource instances of all fonts defined (key: font key) */
private Map fontResources = new java.util.HashMap();
@@ -67,8 +66,8 @@ class FontResourceCache {
postFix = key.substring(pos);
key = key.substring(0, pos);
}
- Map fonts = fontInfo.getFonts();
- Typeface tf = (Typeface)fonts.get(key);
+ Map<String, Typeface> fonts = fontInfo.getFonts();
+ Typeface tf = fonts.get(key);
if (tf instanceof LazyFont) {
tf = ((LazyFont)tf).getRealFont();
}
diff --git a/src/java/org/apache/fop/render/ps/PSBorderPainter.java b/src/java/org/apache/fop/render/ps/PSBorderPainter.java
index cddbe9cd1..1e2964eed 100644
--- a/src/java/org/apache/fop/render/ps/PSBorderPainter.java
+++ b/src/java/org/apache/fop/render/ps/PSBorderPainter.java
@@ -52,7 +52,8 @@ public class PSBorderPainter extends BorderPainter {
}
/** {@inheritDoc} */
- protected void drawBorderLine(int x1, int y1, int x2, int y2, boolean horz,
+ protected void drawBorderLine( // CSOK: ParameterNumber
+ int x1, int y1, int x2, int y2, boolean horz,
boolean startOrBefore, int style, Color col) throws IOException {
drawBorderLine(generator, toPoints(x1), toPoints(y1), toPoints(x2), toPoints(y2),
horz, startOrBefore, style, col);
@@ -66,10 +67,15 @@ public class PSBorderPainter extends BorderPainter {
+ gen.formatDouble(endy) + " lineto stroke newpath");
}
- /** {@inheritDoc} */
- public static void drawBorderLine(PSGenerator gen,
- float x1, float y1, float x2, float y2, boolean horz,
- boolean startOrBefore, int style, Color col) throws IOException {
+ /**
+ * @param gen ps content generator
+ * @see BorderPainter#drawBorderLine
+ */
+ public static void drawBorderLine( // CSOK: ParameterNumber
+ PSGenerator gen,
+ float x1, float y1, float x2, float y2, boolean horz, // CSOK: JavadocMethod
+ boolean startOrBefore, int style, Color col) // CSOK: JavadocMethod
+ throws IOException { // CSOK: JavadocMethod
float w = x2 - x1;
float h = y2 - y1;
if ((w < 0) || (h < 0)) {
diff --git a/src/java/org/apache/fop/render/ps/PSBridgeContext.java b/src/java/org/apache/fop/render/ps/PSBridgeContext.java
index 1ec6acadf..c0244db04 100644
--- a/src/java/org/apache/fop/render/ps/PSBridgeContext.java
+++ b/src/java/org/apache/fop/render/ps/PSBridgeContext.java
@@ -102,6 +102,7 @@ public class PSBridgeContext extends AbstractFOPBridgeContext {
// Make sure any 'sub bridge contexts' also have our bridges.
//TODO There's no matching method in the super-class here
+ /** @return a bridge context */
public BridgeContext createBridgeContext() {
return new PSBridgeContext(getUserAgent(), getDocumentLoader(),
fontInfo,
diff --git a/src/java/org/apache/fop/render/ps/PSEventProducer.java b/src/java/org/apache/fop/render/ps/PSEventProducer.java
index f04205e1c..702380a4d 100644
--- a/src/java/org/apache/fop/render/ps/PSEventProducer.java
+++ b/src/java/org/apache/fop/render/ps/PSEventProducer.java
@@ -28,7 +28,10 @@ import org.apache.fop.events.EventProducer;
public interface PSEventProducer extends EventProducer {
/** Provider class for the event producer. */
- class Provider {
+ final class Provider {
+
+ private Provider() {
+ }
/**
* Returns an event producer.
diff --git a/src/java/org/apache/fop/render/ps/PSFontUtils.java b/src/java/org/apache/fop/render/ps/PSFontUtils.java
index a29210b41..b8d1b63e8 100644
--- a/src/java/org/apache/fop/render/ps/PSFontUtils.java
+++ b/src/java/org/apache/fop/render/ps/PSFontUtils.java
@@ -23,7 +23,6 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
-import java.util.Iterator;
import java.util.Map;
import javax.xml.transform.Source;
@@ -31,13 +30,6 @@ import javax.xml.transform.stream.StreamSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
-import org.apache.xmlgraphics.fonts.Glyphs;
-import org.apache.xmlgraphics.ps.DSCConstants;
-import org.apache.xmlgraphics.ps.PSGenerator;
-import org.apache.xmlgraphics.ps.PSResource;
-import org.apache.xmlgraphics.ps.dsc.ResourceTracker;
-
import org.apache.fop.fonts.Base14Font;
import org.apache.fop.fonts.CustomFont;
import org.apache.fop.fonts.Font;
@@ -47,6 +39,11 @@ import org.apache.fop.fonts.LazyFont;
import org.apache.fop.fonts.SingleByteEncoding;
import org.apache.fop.fonts.SingleByteFont;
import org.apache.fop.fonts.Typeface;
+import org.apache.xmlgraphics.fonts.Glyphs;
+import org.apache.xmlgraphics.ps.DSCConstants;
+import org.apache.xmlgraphics.ps.PSGenerator;
+import org.apache.xmlgraphics.ps.PSResource;
+import org.apache.xmlgraphics.ps.dsc.ResourceTracker;
/**
* Utility code for font handling in PostScript.
@@ -54,7 +51,7 @@ import org.apache.fop.fonts.Typeface;
public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
/** logging instance */
- protected static Log log = LogFactory.getLog(PSFontUtils.class);
+ protected static final Log log = LogFactory.getLog(PSFontUtils.class);
/**
* Generates the PostScript code for the font dictionary. This method should only be
@@ -80,7 +77,8 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
* @return a Map of PSResource instances representing all defined fonts (key: font key)
* @throws IOException in case of an I/O problem
*/
- public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo, Map fonts)
+ public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo,
+ Map<String, Typeface> fonts)
throws IOException {
return writeFontDict(gen, fontInfo, fonts, false);
}
@@ -95,14 +93,12 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
* @return a Map of PSResource instances representing all defined fonts (key: font key)
* @throws IOException in case of an I/O problem
*/
- private static Map writeFontDict(PSGenerator gen, FontInfo fontInfo, Map fonts,
- boolean encodeAllCharacters) throws IOException {
+ private static Map writeFontDict(PSGenerator gen, FontInfo fontInfo,
+ Map<String, Typeface> fonts, boolean encodeAllCharacters) throws IOException {
gen.commentln("%FOPBeginFontDict");
Map fontResources = new java.util.HashMap();
- Iterator iter = fonts.keySet().iterator();
- while (iter.hasNext()) {
- String key = (String)iter.next();
+ for (String key : fonts.keySet()) {
Typeface tf = getTypeFace(fontInfo, fonts, key);
PSResource fontRes = new PSResource(PSResource.TYPE_FONT, tf.getFontName());
fontResources.put(key, fontRes);
@@ -130,7 +126,8 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
return fontResources;
}
- private static void reencodeFonts(PSGenerator gen, Map fonts) throws IOException {
+ private static void reencodeFonts(PSGenerator gen, Map<String, Typeface> fonts)
+ throws IOException {
ResourceTracker tracker = gen.getResourceTracker();
if (!tracker.isResourceSupplied(WINANSI_ENCODING_RESOURCE)) {
@@ -140,10 +137,8 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
gen.commentln("%FOPBeginFontReencode");
//Rewrite font encodings
- Iterator iter = fonts.keySet().iterator();
- while (iter.hasNext()) {
- String key = (String)iter.next();
- Typeface tf = (Typeface)fonts.get(key);
+ for (String key : fonts.keySet()) {
+ Typeface tf = fonts.get(key);
if (tf instanceof LazyFont) {
tf = ((LazyFont)tf).getRealFont();
if (tf == null) {
@@ -172,8 +167,9 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
gen.commentln("%FOPEndFontReencode");
}
- private static Typeface getTypeFace(FontInfo fontInfo, Map fonts, String key) {
- Typeface tf = (Typeface)fonts.get(key);
+ private static Typeface getTypeFace(FontInfo fontInfo, Map<String, Typeface> fonts,
+ String key) {
+ Typeface tf = fonts.get(key);
if (tf instanceof LazyFont) {
tf = ((LazyFont)tf).getRealFont();
}
@@ -181,7 +177,7 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
//This is to avoid an NPE if a malconfigured font is in the configuration but not
//used in the document. If it were used, we wouldn't get this far.
String fallbackKey = fontInfo.getInternalFontKey(Font.DEFAULT_FONT);
- tf = (Typeface)fonts.get(fallbackKey);
+ tf = fonts.get(fallbackKey);
}
return tf;
}
@@ -271,11 +267,9 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
* @return a Map of PSResource instances representing all defined fonts (key: font key)
*/
public static Map determineSuppliedFonts(ResourceTracker resTracker,
- FontInfo fontInfo, Map fonts) {
+ FontInfo fontInfo, Map<String, Typeface> fonts) {
Map fontResources = new java.util.HashMap();
- Iterator iter = fonts.keySet().iterator();
- while (iter.hasNext()) {
- String key = (String)iter.next();
+ for (String key : fonts.keySet()) {
Typeface tf = getTypeFace(fontInfo, fonts, key);
PSResource fontRes = new PSResource("font", tf.getFontName());
fontResources.put(key, fontRes);
@@ -351,8 +345,9 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils {
* @return the PSResource representing the derived font
* @throws IOException In case of an I/O problem
*/
- public static PSResource defineDerivedFont(PSGenerator gen, String baseFontName, String fontName,
- String encoding) throws IOException {
+ public static PSResource defineDerivedFont
+ (PSGenerator gen, String baseFontName, String fontName, String encoding)
+ throws IOException {
PSResource res = new PSResource(PSResource.TYPE_FONT, fontName);
gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE, res);
gen.commentln("%XGCDependencies: font " + baseFontName);
diff --git a/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java b/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java
index 3858cc716..e13591ae3 100644
--- a/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java
+++ b/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java
@@ -30,12 +30,12 @@ import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
import org.apache.xmlgraphics.ps.PSGenerator;
+import org.apache.fop.pdf.PDFFactory;
import org.apache.fop.render.AbstractGraphics2DAdapter;
import org.apache.fop.render.ImageHandlerUtil;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RendererContextConstants;
import org.apache.fop.render.RendererContext.RendererContextWrapper;
-import org.apache.fop.render.pdf.PDFRenderer;
/**
* Graphics2DAdapter implementation for PostScript.
@@ -46,15 +46,7 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter {
private boolean clip = true;
/**
- * Main constructor
- * @param renderer the Renderer instance to which this instance belongs
- */
- public PSGraphics2DAdapter(PSRenderer renderer) {
- this(renderer.gen, true);
- }
-
- /**
- * Constructor for use without a PSRenderer instance.
+ * Creates a new instance.
* @param gen the PostScript generator
* @param clip true if the image should be clipped
*/
@@ -114,7 +106,7 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter {
RendererContextWrapper ctx = RendererContext.wrapRendererContext(context);
BufferedImage bi = paintToBufferedImage(painter, ctx, resolution, false, false);
- float scale = PDFRenderer.NORMAL_PDF_RESOLUTION
+ float scale = PDFFactory.DEFAULT_PDF_RESOLUTION
/ context.getUserAgent().getTargetResolution();
graphics.drawImage(bi, new AffineTransform(scale, 0, 0, scale, 0, 0), null);
} else {
diff --git a/src/java/org/apache/fop/render/ps/PSImageHandler.java b/src/java/org/apache/fop/render/ps/PSImageHandler.java
index ff94fdd2c..0aeafa6fa 100644
--- a/src/java/org/apache/fop/render/ps/PSImageHandler.java
+++ b/src/java/org/apache/fop/render/ps/PSImageHandler.java
@@ -30,7 +30,8 @@ import org.apache.fop.render.RenderingContext;
* Specialized image handler interface for PostScript output. Implementations can optionally
* support creating PostScript forms. The implementation shall check the rendering context
* to see if forms functionality is enabled in the
- * {@link #isCompatible(org.apache.fop.render.RenderingContext, org.apache.xmlgraphics.image.loader.Image)}
+ * {@link #isCompatible(org.apache.fop.render.RenderingContext,
+ * org.apache.xmlgraphics.image.loader.Image)}
* method.
*/
public interface PSImageHandler extends ImageHandler {
diff --git a/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java b/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java
index 41cba7563..839a0cab6 100644
--- a/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java
+++ b/src/java/org/apache/fop/render/ps/PSImageHandlerSVG.java
@@ -23,6 +23,8 @@ import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.io.IOException;
+import org.w3c.dom.Document;
+
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.gvt.GraphicsNode;
@@ -34,6 +36,7 @@ import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
import org.apache.xmlgraphics.ps.PSGenerator;
import org.apache.fop.image.loader.batik.BatikImageFlavors;
+import org.apache.fop.image.loader.batik.BatikUtil;
import org.apache.fop.render.ImageHandler;
import org.apache.fop.render.RenderingContext;
import org.apache.fop.svg.SVGEventProducer;
@@ -70,10 +73,14 @@ public class PSImageHandlerSVG implements ImageHandler {
context.getUserAgent().getFactory().getImageManager(),
context.getUserAgent().getImageSessionContext());
+ //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine)
+ //to it.
+ Document clonedDoc = BatikUtil.cloneSVGDocument(imageSVG.getDocument());
+
GraphicsNode root;
try {
GVTBuilder builder = new GVTBuilder();
- root = builder.build(ctx, imageSVG.getDocument());
+ root = builder.build(ctx, clonedDoc);
} catch (Exception e) {
SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
context.getUserAgent().getEventBroadcaster());
diff --git a/src/java/org/apache/fop/render/ps/PSPainter.java b/src/java/org/apache/fop/render/ps/PSPainter.java
index 38b76fd8a..b8a6d40f6 100644
--- a/src/java/org/apache/fop/render/ps/PSPainter.java
+++ b/src/java/org/apache/fop/render/ps/PSPainter.java
@@ -403,7 +403,8 @@ public class PSPainter extends AbstractIFPainter {
}
}
- private void writeText(String text, int start, int len,
+ private void writeText( // CSOK: ParameterNumber
+ String text, int start, int len,
int letterSpacing, int wordSpacing, int[] dx,
Font font, Typeface tf) throws IOException {
PSGenerator generator = getGenerator();
diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java
deleted file mode 100644
index 103d714bf..000000000
--- a/src/java/org/apache/fop/render/ps/PSRenderer.java
+++ /dev/null
@@ -1,1289 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.ps;
-
-// Java
-import java.awt.Color;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.RenderedImage;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.transform.Source;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.xmlgraphics.image.loader.ImageException;
-import org.apache.xmlgraphics.image.loader.ImageFlavor;
-import org.apache.xmlgraphics.image.loader.ImageInfo;
-import org.apache.xmlgraphics.image.loader.ImageManager;
-import org.apache.xmlgraphics.image.loader.ImageSessionContext;
-import org.apache.xmlgraphics.image.loader.util.ImageUtil;
-import org.apache.xmlgraphics.ps.DSCConstants;
-import org.apache.xmlgraphics.ps.PSDictionary;
-import org.apache.xmlgraphics.ps.PSDictionaryFormatException;
-import org.apache.xmlgraphics.ps.PSGenerator;
-import org.apache.xmlgraphics.ps.PSPageDeviceDictionary;
-import org.apache.xmlgraphics.ps.PSProcSets;
-import org.apache.xmlgraphics.ps.PSResource;
-import org.apache.xmlgraphics.ps.PSState;
-import org.apache.xmlgraphics.ps.dsc.DSCException;
-import org.apache.xmlgraphics.ps.dsc.ResourceTracker;
-import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBoundingBox;
-import org.apache.xmlgraphics.ps.dsc.events.DSCCommentHiResBoundingBox;
-
-import org.apache.fop.ResourceEventProducer;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.area.Area;
-import org.apache.fop.area.BlockViewport;
-import org.apache.fop.area.CTM;
-import org.apache.fop.area.OffDocumentExtensionAttachment;
-import org.apache.fop.area.OffDocumentItem;
-import org.apache.fop.area.PageViewport;
-import org.apache.fop.area.RegionViewport;
-import org.apache.fop.area.Trait;
-import org.apache.fop.area.inline.AbstractTextArea;
-import org.apache.fop.area.inline.Image;
-import org.apache.fop.area.inline.InlineParent;
-import org.apache.fop.area.inline.Leader;
-import org.apache.fop.area.inline.SpaceArea;
-import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.area.inline.WordArea;
-import org.apache.fop.datatypes.URISpecification;
-import org.apache.fop.fo.extensions.ExtensionAttachment;
-import org.apache.fop.fonts.Font;
-import org.apache.fop.fonts.LazyFont;
-import org.apache.fop.fonts.SingleByteFont;
-import org.apache.fop.fonts.Typeface;
-import org.apache.fop.render.AbstractPathOrientedRenderer;
-import org.apache.fop.render.Graphics2DAdapter;
-import org.apache.fop.render.ImageAdapter;
-import org.apache.fop.render.ImageHandler;
-import org.apache.fop.render.ImageHandlerRegistry;
-import org.apache.fop.render.RendererContext;
-import org.apache.fop.render.RendererEventProducer;
-import org.apache.fop.render.ps.extensions.PSCommentAfter;
-import org.apache.fop.render.ps.extensions.PSCommentBefore;
-import org.apache.fop.render.ps.extensions.PSExtensionAttachment;
-import org.apache.fop.render.ps.extensions.PSSetPageDevice;
-import org.apache.fop.render.ps.extensions.PSSetupCode;
-import org.apache.fop.traits.RuleStyle;
-import org.apache.fop.util.CharUtilities;
-
-/**
- * Renderer that renders to PostScript.
- * <br>
- * This class currently generates PostScript Level 2 code. The only exception
- * is the FlateEncode filter which is a Level 3 feature. The filters in use
- * are hardcoded at the moment.
- * <br>
- * This class follows the Document Structuring Conventions (DSC) version 3.0.
- * If anyone modifies this renderer please make
- * sure to also follow the DSC to make it simpler to programmatically modify
- * the generated Postscript files (ex. extract pages etc.).
- * <br>
- * This renderer inserts FOP-specific comments into the PostScript stream which
- * may help certain users to do certain types of post-processing of the output.
- * These comments all start with "%FOP".
- *
- * @author <a href="mailto:fop-dev@xmlgraphics.apache.org">Apache FOP Development Team</a>
- * @version $Id$
- */
-public class PSRenderer extends AbstractPathOrientedRenderer
- implements ImageAdapter, PSSupportedFlavors, PSConfigurationConstants {
-
- /** logging instance */
- private static Log log = LogFactory.getLog(PSRenderer.class);
-
- /** The MIME type for PostScript */
- public static final String MIME_TYPE = "application/postscript";
-
- /** The application producing the PostScript */
- private int currentPageNumber = 0;
-
- /** the OutputStream the PS file is written to */
- private OutputStream outputStream;
- /** the temporary file in case of two-pass processing */
- private File tempFile;
-
- /** The PostScript generator used to output the PostScript */
- protected PSGenerator gen;
- private boolean ioTrouble = false;
-
- private boolean inTextMode = false;
-
- /** Used to temporarily store PSSetupCode instance until they can be written. */
- private List setupCodeList;
-
- /** This is a map of PSResource instances of all fonts defined (key: font key) */
- private Map fontResources;
- /** This is a map of PSResource instances of all forms (key: uri) */
- private Map formResources;
-
- /** encapsulation of dictionary used in setpagedevice instruction **/
- private PSPageDeviceDictionary pageDeviceDictionary;
-
- /**
- * Utility class which enables all sorts of features that are not directly connected to the
- * normal rendering process.
- */
- protected PSRenderingUtil psUtil;
- private PSBorderPainter borderPainter;
-
- /** Is used to determine the document's bounding box */
- private Rectangle2D documentBoundingBox;
-
- /** This is a collection holding all document header comments */
- private Collection headerComments;
-
- /** This is a collection holding all document footer comments */
- private Collection footerComments;
-
- /** {@inheritDoc} */
- public void setUserAgent(FOUserAgent agent) {
- super.setUserAgent(agent);
- this.psUtil = new PSRenderingUtil(getUserAgent());
- }
-
- PSRenderingUtil getPSUtil() {
- return this.psUtil;
- }
-
- /**
- * Sets the landscape mode for this renderer.
- * @param value false will normally generate a "pseudo-portrait" page, true will rotate
- * a "wider-than-long" page by 90 degrees.
- */
- public void setAutoRotateLandscape(boolean value) {
- getPSUtil().setAutoRotateLandscape(value);
- }
-
- /** @return true if the renderer is configured to rotate landscape pages */
- public boolean isAutoRotateLandscape() {
- return getPSUtil().isAutoRotateLandscape();
- }
-
- /**
- * Sets the PostScript language level that the renderer should produce.
- * @param level the language level (currently allowed: 2 or 3)
- */
- public void setLanguageLevel(int level) {
- getPSUtil().setLanguageLevel(level);
- }
-
- /**
- * Return the PostScript language level that the renderer produces.
- * @return the language level
- */
- public int getLanguageLevel() {
- return getPSUtil().getLanguageLevel();
- }
-
- /**
- * Sets the resource optimization mode. If set to true, the renderer does two passes to
- * only embed the necessary resources in the PostScript file. This is slower, but produces
- * smaller files.
- * @param value true to enable the resource optimization
- */
- public void setOptimizeResources(boolean value) {
- getPSUtil().setOptimizeResources(value);
- }
-
- /** @return true if the renderer does two passes to optimize PostScript resources */
- public boolean isOptimizeResources() {
- return getPSUtil().isOptimizeResources();
- }
-
- /** {@inheritDoc} */
- public Graphics2DAdapter getGraphics2DAdapter() {
- return new PSGraphics2DAdapter(this);
- }
-
- /** {@inheritDoc} */
- public ImageAdapter getImageAdapter() {
- return this;
- }
-
- /**
- * Write out a command
- * @param cmd PostScript command
- */
- protected void writeln(String cmd) {
- try {
- gen.writeln(cmd);
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- /**
- * Central exception handler for I/O exceptions.
- * @param ioe IOException to handle
- */
- protected void handleIOTrouble(IOException ioe) {
- if (!ioTrouble) {
- RendererEventProducer eventProducer = RendererEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.ioError(this, ioe);
- ioTrouble = true;
- }
- }
-
- /**
- * Write out a comment
- * @param comment Comment to write
- */
- protected void comment(String comment) {
- try {
- if (comment.startsWith("%")) {
- gen.commentln(comment);
- writeln(comment);
- } else {
- gen.commentln("%" + comment);
- }
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- /**
- * Make sure the cursor is in the right place.
- */
- protected void movetoCurrPosition() {
- moveTo(this.currentIPPosition, this.currentBPPosition);
- }
-
- /** {@inheritDoc} */
- protected void clip() {
- writeln("clip newpath");
- }
-
- /** {@inheritDoc} */
- protected void clipRect(float x, float y, float width, float height) {
- try {
- gen.defineRect(x, y, width, height);
- clip();
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- /** {@inheritDoc} */
- protected void moveTo(float x, float y) {
- writeln(gen.formatDouble(x) + " " + gen.formatDouble(y) + " M");
- }
-
- /**
- * Moves the current point by (x, y) relative to the current position,
- * omitting any connecting line segment.
- * @param x x coordinate
- * @param y y coordinate
- */
- protected void rmoveTo(float x, float y) {
- writeln(gen.formatDouble(x) + " " + gen.formatDouble(y) + " RM");
- }
-
- /** {@inheritDoc} */
- protected void lineTo(float x, float y) {
- writeln(gen.formatDouble(x) + " " + gen.formatDouble(y) + " lineto");
- }
-
- /** {@inheritDoc} */
- protected void closePath() {
- writeln("cp");
- }
-
- /** {@inheritDoc} */
- protected void fillRect(float x, float y, float width, float height) {
- if (width != 0 && height != 0) {
- try {
- gen.defineRect(x, y, width, height);
- gen.writeln("fill");
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
- }
-
- /** {@inheritDoc} */
- protected void updateColor(Color col, boolean fill) {
- try {
- useColor(col);
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- /** {@inheritDoc} */
- protected void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) {
- endTextObject();
- int x = currentIPPosition + (int)Math.round(pos.getX());
- int y = currentBPPosition + (int)Math.round(pos.getY());
- uri = URISpecification.getURL(uri);
- if (log.isDebugEnabled()) {
- log.debug("Handling image: " + uri);
- }
- int width = (int)pos.getWidth();
- int height = (int)pos.getHeight();
- Rectangle targetRect = new Rectangle(x, y, width, height);
-
- ImageManager manager = getUserAgent().getFactory().getImageManager();
- ImageInfo info = null;
- try {
- ImageSessionContext sessionContext = getUserAgent().getImageSessionContext();
- info = manager.getImageInfo(uri, sessionContext);
-
- PSRenderingContext renderingContext = new PSRenderingContext(
- getUserAgent(), gen, getFontInfo());
-
- if (!isOptimizeResources()
- || PSImageUtils.isImageInlined(info, renderingContext)) {
- if (log.isDebugEnabled()) {
- log.debug("Image " + info + " is inlined");
- }
-
- //Determine supported flavors
- ImageFlavor[] flavors;
- ImageHandlerRegistry imageHandlerRegistry
- = userAgent.getFactory().getImageHandlerRegistry();
- flavors = imageHandlerRegistry.getSupportedFlavors(renderingContext);
-
- //Only now fully load/prepare the image
- Map hints = ImageUtil.getDefaultHints(sessionContext);
- org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
- info, flavors, hints, sessionContext);
-
- //Get handler for image
- ImageHandler basicHandler = imageHandlerRegistry.getHandler(renderingContext, img);
-
- //...and embed as inline image
- basicHandler.handleImage(renderingContext, img, targetRect);
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Image " + info + " is embedded as a form later");
- }
- //Don't load image at this time, just put a form placeholder in the stream
- PSResource form = getFormForImage(info.getOriginalURI());
- PSImageUtils.drawForm(form, info, targetRect, gen);
- }
-
- } catch (ImageException ie) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null);
- } catch (FileNotFoundException fe) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.imageNotFound(this, (info != null ? info.toString() : uri), fe, null);
- } catch (IOException ioe) {
- ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
- }
- }
-
- /**
- * Returns a PSResource instance representing a image as a PostScript form.
- * @param uri the image URI
- * @return a PSResource instance
- */
- protected PSResource getFormForImage(String uri) {
- if (uri == null || "".equals(uri)) {
- throw new IllegalArgumentException("uri must not be empty or null");
- }
- if (this.formResources == null) {
- this.formResources = new java.util.HashMap();
- }
- PSResource form = (PSResource)this.formResources.get(uri);
- if (form == null) {
- form = new PSImageFormResource(this.formResources.size() + 1, uri);
- this.formResources.put(uri, form);
- }
- return form;
- }
-
- /** {@inheritDoc} */
- public void paintImage(RenderedImage image, RendererContext context,
- int x, int y, int width, int height) throws IOException {
- float fx = x / 1000f;
- x += currentIPPosition / 1000f;
- float fy = y / 1000f;
- y += currentBPPosition / 1000f;
- float fw = width / 1000f;
- float fh = height / 1000f;
- PSImageUtils.renderBitmapImage(image, fx, fy, fw, fh, gen);
- }
-
- /**
- * Draw a line.
- *
- * @param startx the start x position
- * @param starty the start y position
- * @param endx the x end position
- * @param endy the y end position
- */
- private void drawLine(float startx, float starty, float endx, float endy) {
- writeln(gen.formatDouble(startx) + " "
- + gen.formatDouble(starty) + " M "
- + gen.formatDouble(endx) + " "
- + gen.formatDouble(endy) + " lineto stroke newpath");
- }
-
- /** Saves the graphics state of the rendering engine. */
- public void saveGraphicsState() {
- endTextObject();
- try {
- //delegate
- gen.saveGraphicsState();
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- /** Restores the last graphics state of the rendering engine. */
- public void restoreGraphicsState() {
- try {
- endTextObject();
- //delegate
- gen.restoreGraphicsState();
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- /**
- * Concats the transformation matrix.
- * @param a A part
- * @param b B part
- * @param c C part
- * @param d D part
- * @param e E part
- * @param f F part
- */
- protected void concatMatrix(double a, double b,
- double c, double d,
- double e, double f) {
- try {
- gen.concatMatrix(a, b, c, d, e, f);
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- /**
- * Concats the transformations matrix.
- * @param matrix Matrix to use
- */
- protected void concatMatrix(double[] matrix) {
- try {
- gen.concatMatrix(matrix);
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- /** {@inheritDoc} */
- protected void concatenateTransformationMatrix(AffineTransform at) {
- try {
- gen.concatMatrix(at);
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- private String getPostScriptNameForFontKey(String key) {
- int pos = key.indexOf('_');
- String postFix = null;
- if (pos > 0) {
- postFix = key.substring(pos);
- key = key.substring(0, pos);
- }
- Map fonts = fontInfo.getFonts();
- Typeface tf = (Typeface)fonts.get(key);
- if (tf instanceof LazyFont) {
- tf = ((LazyFont)tf).getRealFont();
- }
- if (tf == null) {
- throw new IllegalStateException("Font not available: " + key);
- }
- if (postFix == null) {
- return tf.getFontName();
- } else {
- return tf.getFontName() + postFix;
- }
- }
-
- /**
- * Returns the PSResource for the given font key.
- * @param key the font key ("F*")
- * @return the matching PSResource
- */
- protected PSResource getPSResourceForFontKey(String key) {
- PSResource res = null;
- if (this.fontResources != null) {
- res = (PSResource)this.fontResources.get(key);
- } else {
- this.fontResources = new java.util.HashMap();
- }
- if (res == null) {
- res = new PSResource(PSResource.TYPE_FONT, getPostScriptNameForFontKey(key));
- this.fontResources.put(key, res);
- }
- return res;
- }
-
- /**
- * Changes the currently used font.
- * @param key key of the font ("F*")
- * @param size font size
- */
- protected void useFont(String key, int size) {
- try {
- PSResource res = getPSResourceForFontKey(key);
- gen.useFont("/" + res.getName(), size / 1000f);
- gen.getResourceTracker().notifyResourceUsageOnPage(res);
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- private void useColor(Color col) throws IOException {
- gen.useColor(col);
- }
-
- /** {@inheritDoc} */
- protected void drawBackAndBorders(Area area, float startx, float starty,
- float width, float height) {
- if (area.hasTrait(Trait.BACKGROUND)
- || area.hasTrait(Trait.BORDER_BEFORE)
- || area.hasTrait(Trait.BORDER_AFTER)
- || area.hasTrait(Trait.BORDER_START)
- || area.hasTrait(Trait.BORDER_END)) {
- comment("%FOPBeginBackgroundAndBorder: "
- + startx + " " + starty + " " + width + " " + height);
- super.drawBackAndBorders(area, startx, starty, width, height);
- comment("%FOPEndBackgroundAndBorder");
- }
- }
-
- /** {@inheritDoc} */
- protected void drawBorderLine(float x1, float y1, float x2, float y2,
- boolean horz, boolean startOrBefore, int style, Color col) {
- try {
- PSBorderPainter.drawBorderLine(gen, x1, y1, x2, y2, horz, startOrBefore, style, col);
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- /** {@inheritDoc} */
- public void startRenderer(OutputStream outputStream)
- throws IOException {
- log.debug("Rendering areas to PostScript...");
-
- this.outputStream = outputStream;
- OutputStream out;
- if (isOptimizeResources()) {
- this.tempFile = File.createTempFile("fop", null);
- out = new java.io.FileOutputStream(this.tempFile);
- out = new java.io.BufferedOutputStream(out);
- } else {
- out = this.outputStream;
- }
-
- //Setup for PostScript generation
- this.gen = new PSGenerator(out) {
- /** Need to subclass PSGenerator to have better URI resolution */
- public Source resolveURI(String uri) {
- return userAgent.resolveURI(uri);
- }
- };
- this.gen.setPSLevel(getLanguageLevel());
- this.borderPainter = new PSBorderPainter(this.gen);
- this.currentPageNumber = 0;
-
- //Initial default page device dictionary settings
- this.pageDeviceDictionary = new PSPageDeviceDictionary();
- pageDeviceDictionary.setFlushOnRetrieval(!getPSUtil().isDSCComplianceEnabled());
- pageDeviceDictionary.put("/ImagingBBox", "null");
- }
-
- private void writeHeader() throws IOException {
- //PostScript Header
- writeln(DSCConstants.PS_ADOBE_30);
- gen.writeDSCComment(DSCConstants.CREATOR, new String[] {userAgent.getProducer()});
- gen.writeDSCComment(DSCConstants.CREATION_DATE, new Object[] {new java.util.Date()});
- gen.writeDSCComment(DSCConstants.LANGUAGE_LEVEL, new Integer(gen.getPSLevel()));
- gen.writeDSCComment(DSCConstants.PAGES, new Object[] {DSCConstants.ATEND});
- gen.writeDSCComment(DSCConstants.BBOX, DSCConstants.ATEND);
- gen.writeDSCComment(DSCConstants.HIRES_BBOX, DSCConstants.ATEND);
- this.documentBoundingBox = new Rectangle2D.Double();
- gen.writeDSCComment(DSCConstants.DOCUMENT_SUPPLIED_RESOURCES,
- new Object[] {DSCConstants.ATEND});
- if (headerComments != null) {
- for (Iterator iter = headerComments.iterator(); iter.hasNext();) {
- PSExtensionAttachment comment = (PSExtensionAttachment)iter.next();
- gen.writeln("%" + comment.getContent());
- }
- }
- gen.writeDSCComment(DSCConstants.END_COMMENTS);
-
- //Defaults
- gen.writeDSCComment(DSCConstants.BEGIN_DEFAULTS);
- gen.writeDSCComment(DSCConstants.END_DEFAULTS);
-
- //Prolog and Setup written right before the first page-sequence, see startPageSequence()
- //Do this only once, as soon as we have all the content for the Setup section!
- //Prolog
- gen.writeDSCComment(DSCConstants.BEGIN_PROLOG);
- PSProcSets.writeStdProcSet(gen);
- PSProcSets.writeEPSProcSet(gen);
- gen.writeDSCComment(DSCConstants.END_PROLOG);
-
- //Setup
- gen.writeDSCComment(DSCConstants.BEGIN_SETUP);
- PSRenderingUtil.writeSetupCodeList(gen, setupCodeList, "SetupCode");
- if (!isOptimizeResources()) {
- this.fontResources = PSFontUtils.writeFontDict(gen, fontInfo);
- } else {
- gen.commentln("%FOPFontSetup"); //Place-holder, will be replaced in the second pass
- }
- gen.writeDSCComment(DSCConstants.END_SETUP);
- }
-
- /** {@inheritDoc} */
- public void stopRenderer() throws IOException {
- //Write trailer
- gen.writeDSCComment(DSCConstants.TRAILER);
- if (footerComments != null) {
- for (Iterator iter = footerComments.iterator(); iter.hasNext();) {
- PSExtensionAttachment comment = (PSExtensionAttachment)iter.next();
- gen.commentln("%" + comment.getContent());
- }
- footerComments.clear();
- }
- gen.writeDSCComment(DSCConstants.PAGES, new Integer(this.currentPageNumber));
- new DSCCommentBoundingBox(this.documentBoundingBox).generate(gen);
- new DSCCommentHiResBoundingBox(this.documentBoundingBox).generate(gen);
- gen.getResourceTracker().writeResources(false, gen);
- gen.writeDSCComment(DSCConstants.EOF);
- gen.flush();
- log.debug("Rendering to PostScript complete.");
- if (isOptimizeResources()) {
- IOUtils.closeQuietly(gen.getOutputStream());
- rewritePostScriptFile();
- }
- if (footerComments != null) {
- headerComments.clear();
- }
- if (pageDeviceDictionary != null) {
- pageDeviceDictionary.clear();
- }
- this.borderPainter = null;
- this.gen = null;
- }
-
- /**
- * Used for two-pass production. This will rewrite the PostScript file from the temporary
- * file while adding all needed resources.
- * @throws IOException In case of an I/O error.
- */
- private void rewritePostScriptFile() throws IOException {
- log.debug("Processing PostScript resources...");
- long startTime = System.currentTimeMillis();
- ResourceTracker resTracker = gen.getResourceTracker();
- InputStream in = new java.io.FileInputStream(this.tempFile);
- in = new java.io.BufferedInputStream(in);
- try {
- try {
- ResourceHandler handler = new ResourceHandler(this.userAgent, this.fontInfo,
- resTracker, this.formResources);
- handler.process(in, this.outputStream,
- this.currentPageNumber, this.documentBoundingBox);
- this.outputStream.flush();
- } catch (DSCException e) {
- throw new RuntimeException(e.getMessage());
- }
- } finally {
- IOUtils.closeQuietly(in);
- if (!this.tempFile.delete()) {
- this.tempFile.deleteOnExit();
- log.warn("Could not delete temporary file: " + this.tempFile);
- }
- }
- if (log.isDebugEnabled()) {
- long duration = System.currentTimeMillis() - startTime;
- log.debug("Resource Processing complete in " + duration + " ms.");
- }
- }
-
- /** {@inheritDoc} */
- public void processOffDocumentItem(OffDocumentItem oDI) {
- if (log.isDebugEnabled()) {
- log.debug("Handling OffDocumentItem: " + oDI.getName());
- }
- if (oDI instanceof OffDocumentExtensionAttachment) {
- ExtensionAttachment attachment = ((OffDocumentExtensionAttachment)oDI).getAttachment();
- if (attachment != null) {
- if (PSExtensionAttachment.CATEGORY.equals(attachment.getCategory())) {
- if (attachment instanceof PSSetupCode) {
- if (setupCodeList == null) {
- setupCodeList = new java.util.ArrayList();
- }
- if (!setupCodeList.contains(attachment)) {
- setupCodeList.add(attachment);
- }
- } else if (attachment instanceof PSSetPageDevice) {
- /**
- * Extract all PSSetPageDevice instances from the
- * attachment list on the s-p-m and add all dictionary
- * entries to our internal representation of the the
- * page device dictionary.
- */
- PSSetPageDevice setPageDevice = (PSSetPageDevice)attachment;
- String content = setPageDevice.getContent();
- if (content != null) {
- try {
- this.pageDeviceDictionary.putAll(PSDictionary.valueOf(content));
- } catch (PSDictionaryFormatException e) {
- PSEventProducer eventProducer = PSEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.postscriptDictionaryParseError(this, content, e);
- }
- }
- } else if (attachment instanceof PSCommentBefore) {
- if (headerComments == null) {
- headerComments = new java.util.ArrayList();
- }
- headerComments.add(attachment);
- } else if (attachment instanceof PSCommentAfter) {
- if (footerComments == null) {
- footerComments = new java.util.ArrayList();
- }
- footerComments.add(attachment);
- }
- }
- }
- }
- super.processOffDocumentItem(oDI);
- }
-
- /** {@inheritDoc} */
- public void renderPage(PageViewport page)
- throws IOException, FOPException {
- log.debug("renderPage(): " + page);
-
- if (this.currentPageNumber == 0) {
- writeHeader();
- }
-
- this.currentPageNumber++;
-
- gen.getResourceTracker().notifyStartNewPage();
- gen.getResourceTracker().notifyResourceUsageOnPage(PSProcSets.STD_PROCSET);
- gen.writeDSCComment(DSCConstants.PAGE, new Object[]
- {page.getPageNumberString(),
- new Integer(this.currentPageNumber)});
-
- double pageWidth = page.getViewArea().width / 1000f;
- double pageHeight = page.getViewArea().height / 1000f;
- boolean rotate = false;
- List pageSizes = new java.util.ArrayList();
- if (getPSUtil().isAutoRotateLandscape() && (pageHeight < pageWidth)) {
- rotate = true;
- pageSizes.add(new Long(Math.round(pageHeight)));
- pageSizes.add(new Long(Math.round(pageWidth)));
- } else {
- pageSizes.add(new Long(Math.round(pageWidth)));
- pageSizes.add(new Long(Math.round(pageHeight)));
- }
- pageDeviceDictionary.put("/PageSize", pageSizes);
-
- if (page.hasExtensionAttachments()) {
- for (Iterator iter = page.getExtensionAttachments().iterator();
- iter.hasNext();) {
- ExtensionAttachment attachment = (ExtensionAttachment) iter.next();
- if (attachment instanceof PSSetPageDevice) {
- /**
- * Extract all PSSetPageDevice instances from the
- * attachment list on the s-p-m and add all
- * dictionary entries to our internal representation
- * of the the page device dictionary.
- */
- PSSetPageDevice setPageDevice = (PSSetPageDevice)attachment;
- String content = setPageDevice.getContent();
- if (content != null) {
- try {
- pageDeviceDictionary.putAll(PSDictionary.valueOf(content));
- } catch (PSDictionaryFormatException e) {
- PSEventProducer eventProducer = PSEventProducer.Provider.get(
- getUserAgent().getEventBroadcaster());
- eventProducer.postscriptDictionaryParseError(this, content, e);
- }
- }
- }
- }
- }
-
- try {
- if (setupCodeList != null) {
- PSRenderingUtil.writeEnclosedExtensionAttachments(gen, setupCodeList);
- setupCodeList.clear();
- }
- } catch (IOException e) {
- log.error(e.getMessage());
- }
- final Integer zero = new Integer(0);
- Rectangle2D pageBoundingBox = new Rectangle2D.Double();
- if (rotate) {
- pageBoundingBox.setRect(0, 0, pageHeight, pageWidth);
- gen.writeDSCComment(DSCConstants.PAGE_BBOX, new Object[] {
- zero, zero, new Long(Math.round(pageHeight)),
- new Long(Math.round(pageWidth)) });
- gen.writeDSCComment(DSCConstants.PAGE_HIRES_BBOX, new Object[] {
- zero, zero, new Double(pageHeight),
- new Double(pageWidth) });
- gen.writeDSCComment(DSCConstants.PAGE_ORIENTATION, "Landscape");
- } else {
- pageBoundingBox.setRect(0, 0, pageWidth, pageHeight);
- gen.writeDSCComment(DSCConstants.PAGE_BBOX, new Object[] {
- zero, zero, new Long(Math.round(pageWidth)),
- new Long(Math.round(pageHeight)) });
- gen.writeDSCComment(DSCConstants.PAGE_HIRES_BBOX, new Object[] {
- zero, zero, new Double(pageWidth),
- new Double(pageHeight) });
- if (getPSUtil().isAutoRotateLandscape()) {
- gen.writeDSCComment(DSCConstants.PAGE_ORIENTATION,
- "Portrait");
- }
- }
- this.documentBoundingBox.add(pageBoundingBox);
- gen.writeDSCComment(DSCConstants.PAGE_RESOURCES,
- new Object[] {DSCConstants.ATEND});
-
- gen.commentln("%FOPSimplePageMaster: " + page.getSimplePageMasterName());
-
- gen.writeDSCComment(DSCConstants.BEGIN_PAGE_SETUP);
-
- if (page.hasExtensionAttachments()) {
- List extensionAttachments = page.getExtensionAttachments();
- for (int i = 0; i < extensionAttachments.size(); i++) {
- Object attObj = extensionAttachments.get(i);
- if (attObj instanceof PSExtensionAttachment) {
- PSExtensionAttachment attachment = (PSExtensionAttachment)attObj;
- if (attachment instanceof PSCommentBefore) {
- gen.commentln("%" + attachment.getContent());
- } else if (attachment instanceof PSSetupCode) {
- gen.writeln(attachment.getContent());
- }
- }
- }
- }
-
- // Write any unwritten changes to page device dictionary
- if (!pageDeviceDictionary.isEmpty()) {
- String content = pageDeviceDictionary.getContent();
- if (getPSUtil().isSafeSetPageDevice()) {
- content += " SSPD";
- } else {
- content += " setpagedevice";
- }
- PSRenderingUtil.writeEnclosedExtensionAttachment(gen, new PSSetPageDevice(content));
- }
-
- if (rotate) {
- gen.writeln(Math.round(pageHeight) + " 0 translate");
- gen.writeln("90 rotate");
- }
- concatMatrix(1, 0, 0, -1, 0, pageHeight);
-
- gen.writeDSCComment(DSCConstants.END_PAGE_SETUP);
-
- //Process page
- super.renderPage(page);
-
- //Show page
- gen.showPage();
- gen.writeDSCComment(DSCConstants.PAGE_TRAILER);
- if (page.hasExtensionAttachments()) {
- List extensionAttachments = page.getExtensionAttachments();
- for (int i = 0; i < extensionAttachments.size(); i++) {
- Object attObj = extensionAttachments.get(i);
- if (attObj instanceof PSExtensionAttachment) {
- PSExtensionAttachment attachment = (PSExtensionAttachment)attObj;
- if (attachment instanceof PSCommentAfter) {
- gen.commentln("%" + attachment.getContent());
- }
- }
- }
- }
- gen.getResourceTracker().writeResources(true, gen);
- }
-
- /** {@inheritDoc} */
- protected void renderRegionViewport(RegionViewport port) {
- if (port != null) {
- comment("%FOPBeginRegionViewport: " + port.getRegionReference().getRegionName());
- super.renderRegionViewport(port);
- comment("%FOPEndRegionViewport");
- }
- }
-
- /** Indicates the beginning of a text object. */
- protected void beginTextObject() {
- if (!inTextMode) {
- saveGraphicsState();
- writeln("BT");
- inTextMode = true;
- }
- }
-
- /** Indicates the end of a text object. */
- protected void endTextObject() {
- if (inTextMode) {
- inTextMode = false; //set before restoreGraphicsState() to avoid recursion
- writeln("ET");
- restoreGraphicsState();
- }
- }
-
- /** {@inheritDoc} */
- public void renderText(TextArea area) {
- renderInlineAreaBackAndBorders(area);
- String fontkey = getInternalFontNameForArea(area);
- int fontsize = area.getTraitAsInteger(Trait.FONT_SIZE);
-
- // This assumes that *all* CIDFonts use a /ToUnicode mapping
- Typeface tf = (Typeface) fontInfo.getFonts().get(fontkey);
-
- //Determine position
- int rx = currentIPPosition + area.getBorderAndPaddingWidthStart();
- int bl = currentBPPosition + area.getOffset() + area.getBaselineOffset();
-
- Color ct = (Color)area.getTrait(Trait.COLOR);
- if (ct != null) {
- try {
- useColor(ct);
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- beginTextObject();
- writeln("1 0 0 -1 " + gen.formatDouble(rx / 1000f)
- + " " + gen.formatDouble(bl / 1000f) + " Tm");
-
- super.renderText(area); //Updates IPD
-
- renderTextDecoration(tf, fontsize, area, bl, rx);
- }
-
- /** {@inheritDoc} */
- protected void renderWord(WordArea word) {
- renderText((TextArea)word.getParentArea(), word.getWord(), word.getLetterAdjustArray());
- super.renderWord(word);
- }
-
- /** {@inheritDoc} */
- protected void renderSpace(SpaceArea space) {
- AbstractTextArea textArea = (AbstractTextArea)space.getParentArea();
- String s = space.getSpace();
- char sp = s.charAt(0);
- Font font = getFontFromArea(textArea);
-
- int tws = (space.isAdjustable()
- ? ((TextArea) space.getParentArea()).getTextWordSpaceAdjust()
- + 2 * textArea.getTextLetterSpaceAdjust()
- : 0);
-
- rmoveTo((font.getCharWidth(sp) + tws) / 1000f, 0);
- super.renderSpace(space);
- }
-
- private Typeface getTypeface(String fontName) {
- Typeface tf = (Typeface)fontInfo.getFonts().get(fontName);
- if (tf instanceof LazyFont) {
- tf = ((LazyFont)tf).getRealFont();
- }
- return tf;
- }
-
- private void renderText(AbstractTextArea area, String text, int[] letterAdjust) {
- String fontkey = getInternalFontNameForArea(area);
- int fontSize = area.getTraitAsInteger(Trait.FONT_SIZE);
- Font font = getFontFromArea(area);
- Typeface tf = getTypeface(font.getFontName());
- SingleByteFont singleByteFont = null;
- if (tf instanceof SingleByteFont) {
- singleByteFont = (SingleByteFont)tf;
- }
-
- int textLen = text.length();
- if (singleByteFont != null && singleByteFont.hasAdditionalEncodings()) {
- int start = 0;
- int currentEncoding = -1;
- for (int i = 0; i < textLen; i++) {
- char c = text.charAt(i);
- char mapped = tf.mapChar(c);
- int encoding = mapped / 256;
- if (currentEncoding != encoding) {
- if (i > 0) {
- writeText(area, text, start, i - start, letterAdjust, fontSize, tf);
- }
- if (encoding == 0) {
- useFont(fontkey, fontSize);
- } else {
- useFont(fontkey + "_" + Integer.toString(encoding), fontSize);
- }
- currentEncoding = encoding;
- start = i;
- }
- }
- writeText(area, text, start, textLen - start, letterAdjust, fontSize, tf);
- } else {
- useFont(fontkey, fontSize);
- writeText(area, text, 0, textLen, letterAdjust, fontSize, tf);
- }
- }
-
- private void writeText(AbstractTextArea area, String text, int start, int len,
- int[] letterAdjust, int fontsize, Typeface tf) {
- int end = start + len;
- int initialSize = text.length();
- initialSize += initialSize / 2;
- StringBuffer sb = new StringBuffer(initialSize);
- if (letterAdjust == null
- && area.getTextLetterSpaceAdjust() == 0
- && area.getTextWordSpaceAdjust() == 0) {
- sb.append("(");
- for (int i = start; i < end; i++) {
- final char c = text.charAt(i);
- final char mapped = (char)(tf.mapChar(c) % 256);
- PSGenerator.escapeChar(mapped, sb);
- }
- sb.append(") t");
- } else {
- sb.append("(");
- int[] offsets = new int[len];
- for (int i = start; i < end; i++) {
- final char c = text.charAt(i);
- final char mapped = tf.mapChar(c);
- char codepoint = (char)(mapped % 256);
- int wordSpace;
-
- if (CharUtilities.isAdjustableSpace(mapped)) {
- wordSpace = area.getTextWordSpaceAdjust();
- } else {
- wordSpace = 0;
- }
- int cw = tf.getWidth(mapped, fontsize) / 1000;
- int ladj = (letterAdjust != null && i < end - 1 ? letterAdjust[i + 1] : 0);
- int tls = (i < end - 1 ? area.getTextLetterSpaceAdjust() : 0);
- offsets[i - start] = cw + ladj + tls + wordSpace;
- PSGenerator.escapeChar(codepoint, sb);
- }
- sb.append(")" + PSGenerator.LF + "[");
- for (int i = 0; i < len; i++) {
- if (i > 0) {
- if (i % 8 == 0) {
- sb.append(PSGenerator.LF);
- } else {
- sb.append(" ");
- }
- }
- sb.append(gen.formatDouble(offsets[i] / 1000f));
- }
- sb.append("]" + PSGenerator.LF + "xshow");
- }
- writeln(sb.toString());
- }
-
- /** {@inheritDoc} */
- protected List breakOutOfStateStack() {
- try {
- List breakOutList = new java.util.ArrayList();
- PSState state;
- while (true) {
- if (breakOutList.size() == 0) {
- endTextObject();
- comment("------ break out!");
- }
- state = gen.getCurrentState();
- if (!gen.restoreGraphicsState()) {
- break;
- }
- breakOutList.add(0, state); //Insert because of stack-popping
- }
- return breakOutList;
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- return null;
- }
- }
-
- /** {@inheritDoc} */
- protected void restoreStateStackAfterBreakOut(List breakOutList) {
- try {
- comment("------ restoring context after break-out...");
- PSState state;
- Iterator i = breakOutList.iterator();
- while (i.hasNext()) {
- state = (PSState)i.next();
- saveGraphicsState();
- state.reestablish(gen);
- }
- comment("------ done.");
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected void startVParea(CTM ctm, Rectangle2D clippingRect) {
- saveGraphicsState();
- if (clippingRect != null) {
- clipRect((float)clippingRect.getX() / 1000f,
- (float)clippingRect.getY() / 1000f,
- (float)clippingRect.getWidth() / 1000f,
- (float)clippingRect.getHeight() / 1000f);
- }
- // multiply with current CTM
- final double[] matrix = ctm.toArray();
- matrix[4] /= 1000f;
- matrix[5] /= 1000f;
- concatMatrix(matrix);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void endVParea() {
- restoreGraphicsState();
- }
-
- /** {@inheritDoc} */
- protected void renderBlockViewport(BlockViewport bv, List children) {
- comment("%FOPBeginBlockViewport: " + bv.toString());
- super.renderBlockViewport(bv, children);
- comment("%FOPEndBlockViewport");
- }
-
- /** {@inheritDoc} */
- protected void renderInlineParent(InlineParent ip) {
- super.renderInlineParent(ip);
- }
-
- /** {@inheritDoc} */
- public void renderLeader(Leader area) {
- renderInlineAreaBackAndBorders(area);
-
- int style = area.getRuleStyle();
- int ruleThickness = area.getRuleThickness();
- int startx = currentIPPosition + area.getBorderAndPaddingWidthStart();
- int starty = currentBPPosition + area.getOffset() + (ruleThickness / 2);
- int endx = currentIPPosition
- + area.getBorderAndPaddingWidthStart()
- + area.getIPD();
- Color col = (Color)area.getTrait(Trait.COLOR);
-
- endTextObject();
- try {
- borderPainter.drawLine(new Point(startx, starty), new Point(endx, starty),
- ruleThickness, col, RuleStyle.valueOf(style));
- } catch (IOException ioe) {
- handleIOTrouble(ioe);
- }
-
- super.renderLeader(area);
- }
-
- /**
- * {@inheritDoc}
- */
- public void renderImage(Image image, Rectangle2D pos) {
- drawImage(image.getURL(), pos, image.getForeignAttributes());
- }
-
- /**
- * {@inheritDoc}
- */
- protected RendererContext createRendererContext(int x, int y, int width, int height,
- Map foreignAttributes) {
- RendererContext context = super.createRendererContext(
- x, y, width, height, foreignAttributes);
- context.setProperty(PSRendererContextConstants.PS_GENERATOR, this.gen);
- context.setProperty(PSRendererContextConstants.PS_FONT_INFO, fontInfo);
- return context;
- }
-
- /** {@inheritDoc} */
- public String getMimeType() {
- return MIME_TYPE;
- }
-
- /**
- * Sets whether or not the safe set page device macro should be used
- * (as opposed to directly invoking setpagedevice) when setting the
- * postscript page device.
- *
- * This option is a useful option when you want to guard against the possibility
- * of invalid/unsupported postscript key/values being placed in the page device.
- *
- * @param safeSetPageDevice setting to false and the renderer will make a
- * standard "setpagedevice" call, setting to true will make a safe set page
- * device macro call (default is false).
- */
- public void setSafeSetPageDevice(boolean safeSetPageDevice) {
- getPSUtil().setSafeSetPageDevice(safeSetPageDevice);
- }
-
- /**
- * Sets whether or not PostScript Document Structuring Conventions (dsc) compliance are
- * enforced.
- * <p>
- * It can cause problems (unwanted PostScript subsystem initgraphics/erasepage calls)
- * on some printers when the pagedevice is set. If this causes problems on a
- * particular implementation then use this setting with a 'false' value to try and
- * minimize the number of setpagedevice calls in the postscript document output.
- * <p>
- * Set this value to false if you experience unwanted blank pages in your
- * postscript output.
- * @param dscCompliant boolean value (default is true)
- */
- public void setDSCCompliant(boolean dscCompliant) {
- getPSUtil().setDSCComplianceEnabled(dscCompliant);
- }
-
-}
diff --git a/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java
index 0f880a928..2280bf0dc 100644
--- a/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java
@@ -45,18 +45,12 @@ public class PSRendererConfigurator extends PrintRendererConfigurator
}
/**
- * Configure the PS renderer.
- * @param renderer postscript renderer
- * @throws FOPException fop exception
+ * Throws an UnsupportedOperationException.
+ *
+ * @param renderer not used
*/
- public void configure(Renderer renderer) throws FOPException {
- Configuration cfg = super.getRendererConfig(renderer);
- if (cfg != null) {
- super.configure(renderer);
-
- PSRenderer psRenderer = (PSRenderer)renderer;
- configure(psRenderer.getPSUtil(), cfg);
- }
+ public void configure(Renderer renderer) {
+ throw new UnsupportedOperationException();
}
private void configure(PSRenderingUtil psUtil, Configuration cfg) {
diff --git a/src/java/org/apache/fop/render/ps/PSRendererContextConstants.java b/src/java/org/apache/fop/render/ps/PSRendererContextConstants.java
index 433f2ce7c..3150e4273 100644
--- a/src/java/org/apache/fop/render/ps/PSRendererContextConstants.java
+++ b/src/java/org/apache/fop/render/ps/PSRendererContextConstants.java
@@ -27,10 +27,9 @@ import org.apache.fop.render.RendererContextConstants;
public interface PSRendererContextConstants extends RendererContextConstants {
/** The PostScript generator that is being used to drawn into. */
- public static final String PS_GENERATOR = "psGenerator";
+ String PS_GENERATOR = "psGenerator";
/** The font information for the PostScript renderer. */
- public static final String PS_FONT_INFO = "psFontInfo";
-
+ String PS_FONT_INFO = "psFontInfo";
}
diff --git a/src/java/org/apache/fop/render/ps/PSRendererMaker.java b/src/java/org/apache/fop/render/ps/PSRendererMaker.java
deleted file mode 100644
index 8c64f2806..000000000
--- a/src/java/org/apache/fop/render/ps/PSRendererMaker.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render.ps;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.AbstractRendererMaker;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererConfigurator;
-
-/**
- * RendererMaker for the PostScript Renderer.
- */
-public class PSRendererMaker extends AbstractRendererMaker {
-
- private static final String[] MIMES = new String[] {MimeConstants.MIME_POSTSCRIPT};
-
- /** {@inheritDoc} */
- public Renderer makeRenderer(FOUserAgent userAgent) {
- return new PSRenderer();
- }
-
- /** {@inheritDoc} */
- public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
- return new PSRendererConfigurator(userAgent);
- }
-
- /** {@inheritDoc} */
- public boolean needsOutputStream() {
- return true;
- }
-
- /** {@inheritDoc} */
- public String[] getSupportedMimeTypes() {
- return MIMES;
- }
-}
diff --git a/src/java/org/apache/fop/render/ps/PSRenderingUtil.java b/src/java/org/apache/fop/render/ps/PSRenderingUtil.java
index 696634a48..d7890d144 100644
--- a/src/java/org/apache/fop/render/ps/PSRenderingUtil.java
+++ b/src/java/org/apache/fop/render/ps/PSRenderingUtil.java
@@ -229,6 +229,7 @@ public class PSRenderingUtil implements PSConfigurationConstants {
this.dscCompliant = value;
}
+ /** @return true if DSC complicance is enabled */
public boolean isDSCComplianceEnabled() {
return this.dscCompliant;
}
diff --git a/src/java/org/apache/fop/render/ps/PSSVGHandler.java b/src/java/org/apache/fop/render/ps/PSSVGHandler.java
index 5cc1a1b01..14e2beddd 100644
--- a/src/java/org/apache/fop/render/ps/PSSVGHandler.java
+++ b/src/java/org/apache/fop/render/ps/PSSVGHandler.java
@@ -30,8 +30,6 @@ import org.apache.avalon.framework.configuration.Configuration;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.gvt.GraphicsNode;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
import org.apache.xmlgraphics.ps.PSGenerator;
@@ -57,9 +55,6 @@ import org.apache.fop.svg.SVGUserAgent;
public class PSSVGHandler extends AbstractGenericSVGHandler
implements PSRendererContextConstants {
- /** logging instance */
- private static Log log = LogFactory.getLog(PSSVGHandler.class);
-
/**
* Create a new PostScript XML handler for use by the PostScript renderer.
*/
@@ -338,7 +333,7 @@ public class PSSVGHandler extends AbstractGenericSVGHandler
/** {@inheritDoc} */
public boolean supportsRenderer(Renderer renderer) {
- return (renderer instanceof PSRenderer);
+ return false;
}
}
diff --git a/src/java/org/apache/fop/render/ps/PSTextPainter.java b/src/java/org/apache/fop/render/ps/PSTextPainter.java
index 23418f4e3..6c009607b 100644
--- a/src/java/org/apache/fop/render/ps/PSTextPainter.java
+++ b/src/java/org/apache/fop/render/ps/PSTextPainter.java
@@ -49,7 +49,7 @@ import org.apache.fop.svg.NativeTextPainter;
import org.apache.fop.util.CharUtilities;
/**
- * Renders the attributed character iterator of a {@link TextNode}.
+ * Renders the attributed character iterator of a text node.
* This class draws the text directly using PostScript text operators so
* the text is not drawn using shapes which makes the PS files larger.
* <p>
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java b/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java
index 2044385a8..54806d047 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java
@@ -38,7 +38,7 @@ public class PSExtensionElementMapping extends ElementMapping {
/** {@inheritDoc} */
protected void initialize() {
if (foObjs == null) {
- foObjs = new java.util.HashMap();
+ foObjs = new java.util.HashMap<String, Maker>();
foObjs.put(PSSetupCodeElement.ELEMENT, new PSSetupCodeMaker());
foObjs.put(PSPageSetupCodeElement.ELEMENT, new PSPageSetupCodeMaker());
foObjs.put(PSSetPageDeviceElement.ELEMENT, new PSSetPageDeviceMaker());
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java b/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java
index dee918f19..d499ef6ab 100644
--- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java
+++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java
@@ -21,6 +21,7 @@ package org.apache.fop.render.ps.extensions;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.DefaultHandler;
import org.apache.commons.logging.Log;
@@ -36,7 +37,7 @@ public class PSExtensionHandler extends DefaultHandler
implements ContentHandlerFactory.ObjectSource {
/** Logger instance */
- protected static Log log = LogFactory.getLog(PSExtensionHandler.class);
+ protected static final Log log = LogFactory.getLog(PSExtensionHandler.class);
private StringBuffer content = new StringBuffer();
private Attributes lastAttributes;
@@ -49,7 +50,7 @@ public class PSExtensionHandler extends DefaultHandler
throws SAXException {
boolean handled = false;
if (PSExtensionAttachment.CATEGORY.equals(uri)) {
- lastAttributes = attributes;
+ lastAttributes = new AttributesImpl(attributes);
handled = false;
if (localName.equals(PSSetupCode.ELEMENT)
|| localName.equals(PSSetPageDevice.ELEMENT)
diff --git a/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java b/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java
index 33a2ff904..8540fcde3 100644
--- a/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java
+++ b/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java
@@ -24,6 +24,7 @@ import java.util.Map;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.properties.FixedLength;
+import org.apache.xmlgraphics.util.UnitConv;
/** Converts XSL-FO units to RTF units
@@ -43,8 +44,8 @@ final class FoUnitsConverter {
public static final float POINT_TO_TWIPS = 20f;
/** millimeters and centimeters to twips: , one point is 1/72 of an inch, one inch is 25.4 mm */
- public static final float IN_TO_TWIPS = 72f * POINT_TO_TWIPS;
- public static final float MM_TO_TWIPS = IN_TO_TWIPS / 25.4f;
+ public static final float IN_TO_TWIPS = UnitConv.IN2PT * POINT_TO_TWIPS;
+ public static final float MM_TO_TWIPS = IN_TO_TWIPS / UnitConv.IN2MM;
public static final float CM_TO_TWIPS = 10 * MM_TO_TWIPS;
diff --git a/src/java/org/apache/fop/render/rtf/RTFEventProducer.java b/src/java/org/apache/fop/render/rtf/RTFEventProducer.java
index b2b47d7f2..5c12c4e2c 100644
--- a/src/java/org/apache/fop/render/rtf/RTFEventProducer.java
+++ b/src/java/org/apache/fop/render/rtf/RTFEventProducer.java
@@ -31,7 +31,10 @@ import org.apache.fop.fo.FONode;
public interface RTFEventProducer extends EventProducer {
/** Provider class for the event producer. */
- class Provider {
+ final class Provider {
+
+ private Provider() {
+ }
/**
* Returns an event producer.
diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java
index fc42a1b8f..35f58e170 100644
--- a/src/java/org/apache/fop/render/rtf/RTFHandler.java
+++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java
@@ -80,11 +80,11 @@ import org.apache.fop.fo.flow.PageNumber;
import org.apache.fop.fo.flow.PageNumberCitation;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableBody;
-import org.apache.fop.fo.flow.table.TableFooter;
-import org.apache.fop.fo.flow.table.TablePart;
import org.apache.fop.fo.flow.table.TableCell;
import org.apache.fop.fo.flow.table.TableColumn;
+import org.apache.fop.fo.flow.table.TableFooter;
import org.apache.fop.fo.flow.table.TableHeader;
+import org.apache.fop.fo.flow.table.TablePart;
import org.apache.fop.fo.flow.table.TableRow;
import org.apache.fop.fo.pagination.Flow;
import org.apache.fop.fo.pagination.PageSequence;
@@ -436,7 +436,8 @@ public class RTFHandler extends FOEventHandler {
RtfTextrun textrun = container.getTextrun();
textrun.addParagraphBreak();
- textrun.popBlockAttributes();
+ int breakValue = toRtfBreakValue(bl.getBreakAfter());
+ textrun.popBlockAttributes(breakValue);
} catch (IOException ioe) {
handleIOTrouble(ioe);
@@ -488,7 +489,8 @@ public class RTFHandler extends FOEventHandler {
RtfTextrun textrun = container.getTextrun();
textrun.addParagraphBreak();
- textrun.popBlockAttributes();
+ int breakValue = toRtfBreakValue(bl.getBreakAfter());
+ textrun.popBlockAttributes(breakValue);
} catch (IOException ioe) {
handleIOTrouble(ioe);
@@ -498,6 +500,21 @@ public class RTFHandler extends FOEventHandler {
}
}
+ private int toRtfBreakValue(int foBreakValue) {
+ switch (foBreakValue) {
+ case Constants.EN_PAGE:
+ return RtfTextrun.BREAK_PAGE;
+ case Constants.EN_EVEN_PAGE:
+ return RtfTextrun.BREAK_EVEN_PAGE;
+ case Constants.EN_ODD_PAGE:
+ return RtfTextrun.BREAK_ODD_PAGE;
+ case Constants.EN_COLUMN:
+ return RtfTextrun.BREAK_COLUMN;
+ default:
+ return RtfTextrun.BREAK_NONE;
+ }
+ }
+
/** {@inheritDoc} */
public void startTable(Table tbl) {
if (bDefer) {
@@ -1468,7 +1485,7 @@ public class RTFHandler extends FOEventHandler {
* @param foNode FO node whose event is to be called
* @param bStart TRUE calls the start handler, FALSE the end handler
*/
- private void invokeDeferredEvent(FONode foNode, boolean bStart) {
+ private void invokeDeferredEvent(FONode foNode, boolean bStart) { // CSOK: MethodLength
if (foNode instanceof PageSequence) {
if (bStart) {
startPageSequence( (PageSequence) foNode);
diff --git a/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
index 764c2c93e..2944b230a 100644
--- a/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
+++ b/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java
@@ -65,11 +65,8 @@ public final class TableAttributesConverter {
/**
* Converts table-only attributes to rtf attributes.
*
- * @param attrs Given attributes
- * @param defaultAttributes Default rtf attributes
- *
+ * @param fobj the table for which the attributes are converted
* @return All valid rtf attributes together
- *
* @throws ConverterException On convertion error
*/
static RtfAttributes convertTableAttributes(Table fobj)
@@ -83,11 +80,8 @@ public final class TableAttributesConverter {
/**
* Converts table-only attributes to rtf attributes.
*
- * @param attrs Given attributes
- * @param defaultAttributes Default rtf attributes
- *
+ * @param part the table part for which the attributes are converted
* @return All valid rtf attributes together
- *
* @throws ConverterException On convertion error
*/
static RtfAttributes convertTablePartAttributes(TablePart part)
@@ -226,8 +220,6 @@ public final class TableAttributesConverter {
* Converts table and row attributes to rtf attributes.
*
* @param fobj FObj to be converted
- * @param defaultAttributes Default rtf attributes
- *
* @return All valid rtf attributes together
* @throws ConverterException On converion error
*/
diff --git a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
index 63c470b5d..d377f740d 100644
--- a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
+++ b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java
@@ -35,6 +35,7 @@ import org.apache.fop.fo.flow.BlockContainer;
import org.apache.fop.fo.flow.Inline;
import org.apache.fop.fo.flow.Leader;
import org.apache.fop.fo.flow.PageNumber;
+import org.apache.fop.fo.flow.table.TableCell;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.CommonFont;
import org.apache.fop.fo.properties.CommonMarginBlock;
@@ -68,7 +69,7 @@ final class TextAttributesConverter {
/**
* Converts all known text FO properties to RtfAttributes
- * @param props list of FO properites, which are to be converted
+ * @param fobj the FO for which the attributes are to be converted
*/
public static RtfAttributes convertAttributes(Block fobj)
throws FOPException {
@@ -80,13 +81,51 @@ final class TextAttributesConverter {
attrBlockMargin(fobj.getCommonMarginBlock(), attrib);
attrBlockTextAlign(fobj.getTextAlign(), attrib);
attrBorder(fobj.getCommonBorderPaddingBackground(), attrib, fobj);
+ attrBreak(fobj, attrib);
return attrib;
}
+ private static void attrBreak(Block fobj, FOPRtfAttributes attrib) {
+ int breakValue = fobj.getBreakBefore();
+ if (breakValue != Constants.EN_AUTO) {
+ //"sect" Creates a new section and a page break,
+ //a simple page break with control word "page" caused
+ //some problems
+ boolean bHasTableCellParent = false;
+ FONode f = fobj;
+ while (f.getParent() != null) {
+ f = f.getParent();
+ if (f instanceof TableCell) {
+ bHasTableCellParent = true;
+ break;
+ }
+ }
+ if (!bHasTableCellParent) {
+ attrib.set("sect");
+ switch (breakValue) {
+ case Constants.EN_EVEN_PAGE:
+ attrib.set("sbkeven");
+ break;
+ case Constants.EN_ODD_PAGE:
+ attrib.set("sbkodd");
+ break;
+ case Constants.EN_COLUMN:
+ attrib.set("sbkcol");
+ break;
+ default:
+ attrib.set("sbkpage");
+ }
+ } else {
+ log.warn("Cannot create break-before for a block inside a table.");
+ }
+ }
+ //Break after is handled in RtfCloseGroupMark
+ }
+
/**
* Converts all known text FO properties to RtfAttributes
- * @param props list of FO properites, which are to be converted
+ * @param fobj FObj whose properties are to be converted
*/
public static RtfAttributes convertBlockContainerAttributes(BlockContainer fobj)
throws FOPException {
@@ -442,7 +481,7 @@ final class TextAttributesConverter {
/**
* Reads background-color from bl and writes it to rtfAttr.
*
- * @param bl the Block object the properties are read from
+ * @param bpb the CommonBorderPaddingBackground from which the properties are read
* @param rtfAttr the RtfAttributes object the attributes are written to
*/
private static void attrBackgroundColor(CommonBorderPaddingBackground bpb,
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java
index aec0237e5..146a8c19c 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/ParagraphKeeptogetherContext.java
@@ -33,26 +33,12 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc;
*
*/
-public class ParagraphKeeptogetherContext {
+public final class ParagraphKeeptogetherContext {
private static int paraKeepTogetherOpen = 0;
private static boolean paraResetProperties = false;
- private static ParagraphKeeptogetherContext instance = null;
- ParagraphKeeptogetherContext() {
- }
-
-
- /**
- * Singelton.
- *
- * @return The instance of ParagraphKeeptogetherContext
- */
- public static ParagraphKeeptogetherContext getInstance() {
- if (instance == null) {
- instance = new ParagraphKeeptogetherContext();
- }
- return instance;
+ private ParagraphKeeptogetherContext() {
}
/**
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBookmark.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBookmark.java
index f691c211c..7da14061e 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBookmark.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfBookmark.java
@@ -59,8 +59,8 @@ public class RtfBookmark extends RtfElement {
* @param writer a <code>Writer</code> value
* @param bookmark Name of the bookmark
*/
- RtfBookmark (RtfContainer parent, Writer w, String bookmark) throws IOException {
- super (parent, w);
+ RtfBookmark (RtfContainer parent, Writer writer, String bookmark) throws IOException {
+ super (parent, writer);
int now = bookmark.length ();
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
index 6123ac563..e2a19389e 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java
@@ -87,8 +87,8 @@ public class RtfExternalGraphic extends RtfElement {
/**
* Convert image data if necessary - for example when format is not supported by rtf.
*
+ * @param format Format type
* @param data Image
- * @param type Format type
*/
public FormatBase convert(FormatBase format, byte[] data) {
return format;
@@ -640,7 +640,7 @@ public class RtfExternalGraphic extends RtfElement {
tmpUrl = new URL (urlString);
} catch (MalformedURLException e) {
try {
- tmpUrl = new File (urlString).toURL ();
+ tmpUrl = new File (urlString).toURI().toURL ();
} catch (MalformedURLException ee) {
throw new ExternalGraphicException("The attribute 'src' of "
+ "<fo:external-graphic> has a invalid value: '"
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java
index 631f2d901..c08008fee 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExtraRowSet.java
@@ -102,6 +102,13 @@ public class RtfExtraRowSet extends RtfContainer {
return result;
}
+ public int hashCode() {
+ int hc = super.hashCode();
+ hc ^= ( hc * 11 ) + xOffset;
+ hc ^= ( hc * 19 ) + rowIndex;
+ return hc;
+ }
+
public boolean equals(Object o) {
return o != null && this.compareTo(o) == 0;
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java
index d5eaa304d..9376f5564 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java
@@ -80,9 +80,10 @@ extends RtfContainer {
* If called, must be called before startDocumentArea
* @return the new RtfHeader
* @throws IOException for I/O problems
+ * @throws RtfStructureException for illegal RTF structure
*/
public RtfHeader startHeader()
- throws IOException {
+ throws IOException, RtfStructureException {
if (header != null) {
throw new RtfStructureException("startHeader called more than once");
}
@@ -128,7 +129,7 @@ extends RtfContainer {
* @throws RtfStructureException for illegal RTF structure
*/
public RtfPageArea startPageArea()
- throws IOException {
+ throws IOException, RtfStructureException {
if (pageArea != null) {
throw new RtfStructureException("startPageArea called more than once");
}
@@ -149,7 +150,7 @@ extends RtfContainer {
* @throws RtfStructureException for illegal RTF structure
*/
public RtfPageArea getPageArea()
- throws IOException {
+ throws IOException, RtfStructureException {
if (pageArea == null) {
return startPageArea();
}
@@ -164,7 +165,7 @@ extends RtfContainer {
* @throws RtfStructureException for illegal RTF structure
*/
public RtfDocumentArea startDocumentArea()
- throws IOException {
+ throws IOException, RtfStructureException {
if (docArea != null) {
throw new RtfStructureException("startDocumentArea called more than once");
}
@@ -187,7 +188,7 @@ extends RtfContainer {
* @throws RtfStructureException for illegal RTF structure
*/
public RtfDocumentArea getDocumentArea()
- throws IOException {
+ throws IOException, RtfStructureException {
if (docArea == null) {
return startDocumentArea();
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFootnote.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFootnote.java
index f3b2ebf72..1a71ed670 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFootnote.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFootnote.java
@@ -17,7 +17,6 @@
/* $Id$ */
-
package org.apache.fop.render.rtf.rtflib.rtfdoc;
//Java
@@ -33,18 +32,27 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTextrun;
*/
public class RtfFootnote extends RtfContainer
implements IRtfTextrunContainer, IRtfListContainer {
- RtfTextrun textrunInline = null;
- RtfContainer body = null;
- RtfList list = null;
- boolean bBody = false;
+ RtfTextrun textrunInline = null; // CSOK: VisibilityModifier
+ RtfContainer body = null; // CSOK: VisibilityModifier
+ RtfList list = null; // CSOK: VisibilityModifier
+ boolean bBody = false; // CSOK: VisibilityModifier
- /** Create an RTF list item as a child of given container with default attributes */
+ /**
+ * Create an RTF list item as a child of given container with default attributes.
+ * @param parent a container
+ * @param w a writer
+ * @throws IOException if not caught
+ */
RtfFootnote(RtfContainer parent, Writer w) throws IOException {
super(parent, w);
textrunInline = new RtfTextrun(this, writer, null);
body = new RtfContainer(this, writer);
}
+ /**
+ * @return a text run
+ * @throws IOException if not caught
+ */
public RtfTextrun getTextrun() throws IOException {
if (bBody) {
RtfTextrun textrun = RtfTextrun.getTextrun(body, writer, null);
@@ -72,6 +80,11 @@ public class RtfFootnote extends RtfContainer
writeGroupMark(false);
}
+ /**
+ * @param attrs some attributes
+ * @return an rtf list
+ * @throws IOException if not caught
+ */
public RtfList newList(RtfAttributes attrs) throws IOException {
if (list != null) {
list.close();
@@ -82,10 +95,12 @@ public class RtfFootnote extends RtfContainer
return list;
}
+ /** start body */
public void startBody() {
bBody = true;
}
+ /** end body */
public void endBody() {
bBody = false;
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfGenerator.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfGenerator.java
index 1dd00c66d..ce51f93a0 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfGenerator.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfGenerator.java
@@ -27,7 +27,12 @@ import java.io.Writer;
*/
public class RtfGenerator extends RtfElement {
- /** Default constructor for the generator element. */
+ /**
+ * Default constructor for the generator element.
+ * @param h a header
+ * @param w a writer
+ * @throws IOException if not caught
+ */
public RtfGenerator(RtfHeader h, Writer w) throws IOException {
super(h, w);
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java
index cd80c6993..a021948ab 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfHyperLink.java
@@ -57,7 +57,7 @@ implements IRtfTextContainer,
/**
- * Default constructor.
+ * A constructor.
*
* @param parent a <code>RtfContainer</code> value
* @param writer a <code>Writer</code> value
@@ -71,6 +71,14 @@ implements IRtfTextContainer,
new RtfText (this, writer, str, attr);
}
+ /**
+ * A constructor.
+ *
+ * @param parent a <code>RtfContainer</code> value
+ * @param writer a <code>Writer</code> value
+ * @param attr a <code>RtfAttributes</code> value
+ * @throws IOException for I/O problems
+ */
public RtfHyperLink (RtfTextrun parent, Writer writer, RtfAttributes attr)
throws IOException {
super ((RtfContainer) parent, writer, attr);
@@ -217,8 +225,11 @@ implements IRtfTextContainer,
return false;
}
- public RtfTextrun getTextrun()
- throws IOException {
+ /**
+ * @return a text run
+ * @throws IOException if not caught
+ */
+ public RtfTextrun getTextrun() throws IOException {
RtfTextrun textrun = RtfTextrun.getTextrun(this, writer, null);
return textrun;
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfJforCmd.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfJforCmd.java
index d7b77f633..b9e53d42f 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfJforCmd.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfJforCmd.java
@@ -39,14 +39,12 @@ public class RtfJforCmd extends RtfContainer {
private static final String PARA_KEEP_OFF = "para-keep:off";
private final RtfAttributes attrib;
- private ParagraphKeeptogetherContext paragraphKeeptogetherContext;
RtfJforCmd(RtfContainer parent, Writer w, RtfAttributes attrs) throws IOException {
super((RtfContainer)parent, w);
attrib = attrs;
- paragraphKeeptogetherContext = ParagraphKeeptogetherContext.getInstance();
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfList.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfList.java
index f44199bee..13748a3bf 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfList.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfList.java
@@ -26,9 +26,8 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc;
* the FOP project.
*/
-import java.io.Writer;
import java.io.IOException;
-import java.util.Date;
+import java.io.Writer;
import java.util.Random;
/**
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java
index 657900574..f014186ed 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java
@@ -62,7 +62,7 @@ extends RtfContainer {
public static final String FOOTERY = "footery";
/** constant for itap level */
public static final String ITAP = "itap";
-
+
/** String array of RtfPage attributes */
public static final String[] PAGE_ATTR = new String[]{
PAGE_WIDTH, PAGE_HEIGHT, LANDSCAPE, MARGIN_TOP, MARGIN_BOTTOM,
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfString.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfString.java
index c7cc6d36f..7ef4b98b9 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfString.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfString.java
@@ -17,6 +17,7 @@
/* $Id$ */
+package org.apache.fop.render.rtf.rtflib.rtfdoc;
/*
* This file is part of the RTF library of the FOP project, which was originally
@@ -25,8 +26,6 @@
* the FOP project.
*/
-package org.apache.fop.render.rtf.rtflib.rtfdoc;
-
import java.io.IOException;
import java.io.Writer;
@@ -59,10 +58,12 @@ public class RtfString extends RtfElement {
RtfStringConverter.getInstance().writeRtfString(writer, text);
}
+ /** @return the text */
public String getText() {
return text;
}
+ /** @param s some text */
public void setText(String s) {
text = s;
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStringConverter.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStringConverter.java
index 40460bb4d..9afe35b29 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStringConverter.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStringConverter.java
@@ -17,6 +17,7 @@
/* $Id$ */
+package org.apache.fop.render.rtf.rtflib.rtfdoc;
/*
* This file is part of the RTF library of the FOP project, which was originally
@@ -25,8 +26,6 @@
* the FOP project.
*/
-package org.apache.fop.render.rtf.rtflib.rtfdoc;
-
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
@@ -36,9 +35,9 @@ import java.io.Writer;
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
-public class RtfStringConverter {
- private static final RtfStringConverter INSTANCE = new RtfStringConverter();
+public final class RtfStringConverter {
+ private static final RtfStringConverter INSTANCE = new RtfStringConverter();
private static final Map SPECIAL_CHARS;
private static final Character DBLQUOTE = new Character('\"');
private static final Character QUOTE = new Character('\'');
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java
index b838fb8a4..30dee96d7 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfStyleSheetTable.java
@@ -17,6 +17,7 @@
/* $Id$ */
+package org.apache.fop.render.rtf.rtflib.rtfdoc;
/*
* This file is part of the RTF library of the FOP project, which was originally
@@ -25,8 +26,6 @@
* the FOP project.
*/
-package org.apache.fop.render.rtf.rtflib.rtfdoc;
-
import java.util.Vector;
import java.util.Hashtable;
import java.io.IOException;
@@ -37,7 +36,7 @@ import java.util.Iterator;
* This class belongs to the <jfor:stylesheet> tag processing.
* @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
*/
-public class RtfStyleSheetTable {
+public final class RtfStyleSheetTable {
//////////////////////////////////////////////////
// @@ Symbolic constants
//////////////////////////////////////////////////
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java
index 09c39be12..da11de1bc 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java
@@ -181,8 +181,8 @@ public class RtfTableCell
}
/** used by RtfTableRow to write the <celldef> cell definition control words
- * @param widthOffset sum of the widths of preceeding cells in same row
- * @return widthOffset + width of this cell
+ * @param offset sum of the widths of preceeding cells in same row
+ * @return offset + width of this cell
*/
int writeCellDef(int offset) throws IOException {
/*
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTemplate.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTemplate.java
index a02d6db8f..74e9eca25 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTemplate.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTemplate.java
@@ -17,6 +17,7 @@
/* $Id$ */
+package org.apache.fop.render.rtf.rtflib.rtfdoc;
/*
* This file is part of the RTF library of the FOP project, which was originally
@@ -25,8 +26,6 @@
* the FOP project.
*/
-package org.apache.fop.render.rtf.rtflib.rtfdoc;
-
import java.io.IOException;
/**
@@ -34,7 +33,7 @@ import java.io.IOException;
* This class belongs to the <jfor:style-template> tag processing.
*/
-public class RtfTemplate {
+public final class RtfTemplate {
/** Singelton instance */
private static RtfTemplate instance = null;
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java
index b176e1ee2..f7c08d628 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfText.java
@@ -17,6 +17,7 @@
/* $Id$ */
+package org.apache.fop.render.rtf.rtflib.rtfdoc;
/*
* This file is part of the RTF library of the FOP project, which was originally
@@ -25,8 +26,6 @@
* the FOP project.
*/
-package org.apache.fop.render.rtf.rtflib.rtfdoc;
-
import java.io.IOException;
import java.io.Writer;
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java
index a9ba432b1..7a9245dd5 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java
@@ -25,9 +25,10 @@ import java.io.Writer;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
+import java.util.Stack;
-// FOP
-import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Class which contains a linear text run. It has methods to add attributes,
@@ -35,9 +36,26 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic;
* @author Peter Herweg, pherweg@web.de
*/
public class RtfTextrun extends RtfContainer {
+
+ /** Constant for no page break */
+ public static final int BREAK_NONE = 0;
+ /** Constant for a normal page break */
+ public static final int BREAK_PAGE = 1;
+ /** Constant for a column break */
+ public static final int BREAK_COLUMN = 2;
+ /** Constant for a even page break */
+ public static final int BREAK_EVEN_PAGE = 3;
+ /** Constant for a odd page break */
+ public static final int BREAK_ODD_PAGE = 4;
+
private boolean bSuppressLastPar = false;
private RtfListItem rtfListItem;
+ /**
+ * logging instance
+ */
+ protected static final Log log = LogFactory.getLog(RtfTextrun.class);
+
/** Manager for handling space-* property. */
private RtfSpaceManager rtfSpaceManager = new RtfSpaceManager();
@@ -68,10 +86,12 @@ public class RtfTextrun extends RtfContainer {
/** Class which represents the closing of a RTF group mark.*/
private class RtfCloseGroupMark extends RtfElement {
+ private int breakType = BREAK_NONE;
- RtfCloseGroupMark(RtfContainer parent, Writer w)
- throws IOException {
+ RtfCloseGroupMark(RtfContainer parent, Writer w, int breakType)
+ throws IOException {
super(parent, w);
+ this.breakType = breakType;
}
/**
@@ -82,11 +102,44 @@ public class RtfTextrun extends RtfContainer {
}
/**
- * write RTF code of all our children
+ * Returns the break type.
+ * @return the break type (BREAK_* constants)
+ */
+ public int getBreakType() {
+ return breakType;
+ }
+
+ /**
+ * Write RTF code of all our children.
* @throws IOException for I/O problems
*/
protected void writeRtfContent() throws IOException {
writeGroupMark(false);
+ boolean bHasTableCellParent = this.getParentOfClass(RtfTableCell.class) != null;
+
+ //Unknown behavior when a table starts a new section,
+ //Word may crash
+ if (breakType != BREAK_NONE) {
+ if (!bHasTableCellParent) {
+ writeControlWord("sect");
+ /* The following modifiers don't seem to appear in the right place */
+ switch (breakType) {
+ case BREAK_EVEN_PAGE:
+ writeControlWord("sbkeven");
+ break;
+ case BREAK_ODD_PAGE:
+ writeControlWord("sbkodd");
+ break;
+ case BREAK_COLUMN:
+ writeControlWord("sbkcol");
+ break;
+ default:
+ writeControlWord("sbkpage");
+ }
+ } else {
+ log.warn("Cannot create break-after for a paragraph inside a table.");
+ }
+ }
}
}
@@ -135,8 +188,18 @@ public class RtfTextrun extends RtfContainer {
*
* @throws IOException for I/O problems
*/
+ private void addCloseGroupMark(int breakType) throws IOException {
+ RtfCloseGroupMark r = new RtfCloseGroupMark(this, writer, breakType);
+ }
+
+ /**
+ * Adds instance of <code>CloseGroupMark</code> as a child, but without a break option.
+ * Inline attributes do not need that for example
+ *
+ * @throws IOException for I/O problems
+ */
private void addCloseGroupMark() throws IOException {
- RtfCloseGroupMark r = new RtfCloseGroupMark(this, writer);
+ RtfCloseGroupMark r = new RtfCloseGroupMark(this, writer, BREAK_NONE);
}
/**
@@ -155,14 +218,14 @@ public class RtfTextrun extends RtfContainer {
/**
* Pops block attributes, notifies all opened blocks about pushing block
* attributes, adds <code>CloseGroupMark</code> as a child.
- *
+ * @param breakType the break type
* @throws IOException for I/O problems
*/
- public void popBlockAttributes() throws IOException {
- rtfSpaceManager.popRtfSpaceSplitter();
- rtfSpaceManager.stopUpdatingSpaceBefore();
- addCloseGroupMark();
- }
+ public void popBlockAttributes(int breakType) throws IOException {
+ rtfSpaceManager.popRtfSpaceSplitter();
+ rtfSpaceManager.stopUpdatingSpaceBefore();
+ addCloseGroupMark(breakType);
+ }
/**
* Pushes inline attributes.
@@ -208,7 +271,8 @@ public class RtfTextrun extends RtfContainer {
//add RtfSpaceSplitter to inherit accumulated space
rtfSpaceManager.pushRtfSpaceSplitter(attrs);
rtfSpaceManager.setCandidate(attrs);
- RtfString r = new RtfString(this, writer, s);
+ // create a string and add it as a child
+ new RtfString(this, writer, s);
rtfSpaceManager.popRtfSpaceSplitter();
}
@@ -228,28 +292,30 @@ public class RtfTextrun extends RtfContainer {
* @throws IOException for I/O problems
*/
public void addParagraphBreak() throws IOException {
- // get copy of children list
- List children = getChildren();
-
- // delete all previous CloseGroupMark
- int deletedCloseGroupCount = 0;
-
- ListIterator lit = children.listIterator(children.size());
- while (lit.hasPrevious()
- && (lit.previous() instanceof RtfCloseGroupMark)) {
- lit.remove();
- deletedCloseGroupCount++;
- }
-
- if (children.size() != 0) {
- // add paragraph break and restore all deleted close group marks
- setChildren(children);
- new RtfParagraphBreak(this, writer);
- for (int i = 0; i < deletedCloseGroupCount; i++) {
- addCloseGroupMark();
- }
- }
- }
+ // get copy of children list
+ List children = getChildren();
+ Stack tmp = new Stack();
+
+ // delete all previous CloseGroupMark
+ int deletedCloseGroupCount = 0;
+
+ ListIterator lit = children.listIterator(children.size());
+ while (lit.hasPrevious()
+ && (lit.previous() instanceof RtfCloseGroupMark)) {
+ tmp.push(Integer.valueOf(((RtfCloseGroupMark)lit.next()).getBreakType()));
+ lit.remove();
+ deletedCloseGroupCount++;
+ }
+
+ if (children.size() != 0) {
+ // add paragraph break and restore all deleted close group marks
+ setChildren(children);
+ new RtfParagraphBreak(this, writer);
+ for (int i = 0; i < deletedCloseGroupCount; i++) {
+ addCloseGroupMark(((Integer)tmp.pop()).intValue());
+ }
+ }
+ }
/**
* Inserts a leader.
@@ -355,8 +421,8 @@ public class RtfTextrun extends RtfContainer {
* Maybe this can be done more efficient.
*/
- boolean bHasTableCellParent =
- this.getParentOfClass(RtfTableCell.class) != null;
+ boolean bHasTableCellParent
+ = this.getParentOfClass(RtfTableCell.class) != null;
RtfAttributes attrBlockLevel = new RtfAttributes();
//determine, if this RtfTextrun is the last child of its parent
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/WhitespaceCollapser.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/WhitespaceCollapser.java
index 339434b69..723b4fb00 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/WhitespaceCollapser.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/WhitespaceCollapser.java
@@ -17,6 +17,7 @@
/* $Id$ */
+package org.apache.fop.render.rtf.rtflib.rtfdoc;
/*
* This file is part of the RTF library of the FOP project, which was originally
@@ -25,8 +26,6 @@
* the FOP project.
*/
-package org.apache.fop.render.rtf.rtflib.rtfdoc;
-
import java.util.Iterator;
import java.util.StringTokenizer;
@@ -34,11 +33,15 @@ import java.util.StringTokenizer;
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
-class WhitespaceCollapser {
+final class WhitespaceCollapser {
+
private static final String SPACE = " ";
private boolean lastEndSpace = true;
- /** remove extra whitespace in RtfText elements that are inside c */
+ /**
+ * Remove extra whitespace in RtfText elements that are inside container.
+ * @param c the container
+ */
WhitespaceCollapser(RtfContainer c) {
// process all texts
for (Iterator it = c.getChildren().iterator(); it.hasNext();) {
@@ -56,6 +59,11 @@ class WhitespaceCollapser {
}
}
+ /** @return last end space */
+ public boolean getLastEndSpace() {
+ return lastEndSpace;
+ }
+
/** process one RtfText from our container */
private void processText(RtfText txt) {
final String newString = processString(txt.getText());
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java
index 430231792..1591bbe26 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/BuilderContext.java
@@ -49,6 +49,10 @@ public class BuilderContext {
/** Rtf options */
private IRtfOptions options;
+ /**
+ * Construct a builder context.
+ * @param rtfOptions some options
+ */
public BuilderContext(IRtfOptions rtfOptions) {
options = rtfOptions;
}
@@ -82,9 +86,13 @@ public class BuilderContext {
return result;
}*/
- /** find the "nearest" container that implements the given interface on our stack
- * @param required if true, ConverterException is thrown if no container found
- * @param forWhichBuilder used in error message if container not found
+ /**
+ * Find the "nearest" container that implements the given interface on our stack.
+ * @param containerClass class of container
+ * @param required if true, ConverterException is thrown if no container found
+ * @param forWhichBuilder used in error message if container not found
+ * @return the container
+ * @throws RtfException if not caught
*/
public RtfContainer getContainer(Class containerClass, boolean required,
Object /*IBuilder*/ forWhichBuilder) throws RtfException {
@@ -103,7 +111,10 @@ public class BuilderContext {
return result;
}
- /** push an RtfContainer on our stack */
+ /**
+ * Push an RtfContainer on our stack.
+ * @param c the container
+ */
public void pushContainer(RtfContainer c) {
containers.push(c);
}
@@ -115,6 +126,9 @@ public class BuilderContext {
* paragraph container to handle what follows the nested block.
* TODO: what happens to elements that are "more on top" than oldC on the
* stack? shouldn't they be closed or something?
+ * @param oldC old container
+ * @param newC new container
+ * @throws Exception if not caught
*/
public void replaceContainer(RtfContainer oldC, RtfContainer newC)
throws Exception {
@@ -150,17 +164,23 @@ public class BuilderContext {
return result;
}
*/
- /** return the current TableContext */
+
+ /** @return the current TableContext */
public TableContext getTableContext() {
return (TableContext)tableContexts.peek();
}
- /** push a TableContext to our stack */
+ /**
+ * Push a TableContext to our stack.
+ * @param tc the table context
+ */
public void pushTableContext(TableContext tc) {
tableContexts.push(tc);
}
- /** pop a TableContext from our stack */
+ /**
+ * Pop a TableContext from our stack.
+ */
public void popTableContext() {
tableContexts.pop();
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageConstants.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageConstants.java
index 859472709..c3dadb652 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageConstants.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageConstants.java
@@ -17,6 +17,7 @@
/* $Id$ */
+package org.apache.fop.render.rtf.rtflib.tools;
/*
* This file is part of the RTF library of the FOP project, which was originally
@@ -25,15 +26,12 @@
* the FOP project.
*/
-package org.apache.fop.render.rtf.rtflib.tools;
-
-
/** Here will be defined all supported image formats.
* This class belongs to the <fo:external-graphic> tag processing.
* @author a.putz@skynamics.com (Andreas Putz)
*/
-public class ImageConstants {
+public final class ImageConstants {
//////////////////////////////////////////////////
// @@ Symbolic constants
//////////////////////////////////////////////////
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java
index c5e3cb191..82367e0ad 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/ImageUtil.java
@@ -17,6 +17,7 @@
/* $Id$ */
+package org.apache.fop.render.rtf.rtflib.tools;
/*
* This file is part of the RTF library of the FOP project, which was originally
@@ -25,13 +26,11 @@
* the FOP project.
*/
-package org.apache.fop.render.rtf.rtflib.tools;
-
/** Misc.utilities for images handling
* This class belongs to the <fo:external-graphic> tag processing.
* @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
*/
-public class ImageUtil {
+public final class ImageUtil {
//////////////////////////////////////////////////
// @@ Construction
diff --git a/src/java/org/apache/fop/render/txt/TXTRenderer.java b/src/java/org/apache/fop/render/txt/TXTRenderer.java
index 3e2fab230..aa36ea28f 100644
--- a/src/java/org/apache/fop/render/txt/TXTRenderer.java
+++ b/src/java/org/apache/fop/render/txt/TXTRenderer.java
@@ -494,7 +494,8 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
/**
* {@inheritDoc}
*/
- protected void drawBorderLine(float x1, float y1, float x2, float y2,
+ protected void drawBorderLine( // CSOK: ParameterNumber
+ float x1, float y1, float x2, float y2,
boolean horz, boolean startOrBefore, int style, Color col) {
int borderHeight = bm.getHeight();
diff --git a/src/java/org/apache/fop/render/txt/TXTStream.java b/src/java/org/apache/fop/render/txt/TXTStream.java
index 49e36be3a..a534d4108 100644
--- a/src/java/org/apache/fop/render/txt/TXTStream.java
+++ b/src/java/org/apache/fop/render/txt/TXTStream.java
@@ -71,10 +71,11 @@ public class TXTStream {
* @param encoding the encoding, if null, "UTF-8" is chosen as default
*/
public void setEncoding(String encoding) {
- if (encoding != null)
+ if (encoding != null) {
this.encoding = encoding;
- else
+ } else {
this.encoding = DEFAULT_ENCODING;
+ }
}
}
diff --git a/src/java/org/apache/fop/render/xml/AbstractXMLRenderer.java b/src/java/org/apache/fop/render/xml/AbstractXMLRenderer.java
index 4f62155a3..497e3c047 100644
--- a/src/java/org/apache/fop/render/xml/AbstractXMLRenderer.java
+++ b/src/java/org/apache/fop/render/xml/AbstractXMLRenderer.java
@@ -43,7 +43,9 @@ import org.xml.sax.SAXException;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.AttributesImpl;
+/** Abstract xml renderer base class. */
public abstract class AbstractXMLRenderer extends PrintRenderer {
+
/** Main namespace in use. */
public static final String NS = "";
@@ -62,6 +64,7 @@ public abstract class AbstractXMLRenderer extends PrintRenderer {
/** The OutputStream to write the generated XML to. */
protected OutputStream out;
+ /** The renderer context. */
protected RendererContext context;
/** A list of ExtensionAttachements received through processOffDocumentItem() */
@@ -237,7 +240,7 @@ public abstract class AbstractXMLRenderer extends PrintRenderer {
}
}
- /** {@inheritDoc} */
+ /** Handle document extension attachments. */
protected void handleDocumentExtensionAttachments() {
if (extensionAttachments != null && extensionAttachments.size() > 0) {
handleExtensionAttachments(extensionAttachments);
diff --git a/src/java/org/apache/fop/servlet/FopPrintServlet.java b/src/java/org/apache/fop/servlet/FopPrintServlet.java
index d446dff54..5c243ecae 100644
--- a/src/java/org/apache/fop/servlet/FopPrintServlet.java
+++ b/src/java/org/apache/fop/servlet/FopPrintServlet.java
@@ -61,6 +61,8 @@ import org.apache.fop.apps.MimeConstants;
*/
public class FopPrintServlet extends FopServlet {
+ private static final long serialVersionUID = 1645706757391617935L;
+
/**
* {@inheritDoc}
*/
diff --git a/src/java/org/apache/fop/servlet/FopServlet.java b/src/java/org/apache/fop/servlet/FopServlet.java
index 304cf21b9..7eb8a2f89 100644
--- a/src/java/org/apache/fop/servlet/FopServlet.java
+++ b/src/java/org/apache/fop/servlet/FopServlet.java
@@ -70,6 +70,8 @@ import org.apache.fop.apps.MimeConstants;
*/
public class FopServlet extends HttpServlet {
+ private static final long serialVersionUID = -908918093488215264L;
+
/** Name of the parameter used for the XSL-FO file */
protected static final String FO_REQUEST_PARAM = "fo";
/** Name of the parameter used for the XML file */
diff --git a/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java b/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java
index acb59ed7d..1622d4f51 100644
--- a/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java
+++ b/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java
@@ -37,12 +37,13 @@ import org.apache.fop.fonts.FontInfo;
*/
public abstract class AbstractFOPBridgeContext extends BridgeContext {
- /** The font list. */
+ /** the font list */
protected final FontInfo fontInfo;
-
+ /** image manager */
protected final ImageManager imageManager;
+ /** image session context */
protected final ImageSessionContext imageSessionContext;
-
+ /** link transform */
protected final AffineTransform linkTransform;
/**
@@ -122,6 +123,10 @@ public abstract class AbstractFOPBridgeContext extends BridgeContext {
return this.imageSessionContext;
}
+ /**
+ * @param className name of bridge class to load and construct
+ * @param testFor class name to test for presence
+ */
protected void putElementBridgeConditional(String className, String testFor) {
try {
Class.forName(testFor);
@@ -137,6 +142,7 @@ public abstract class AbstractFOPBridgeContext extends BridgeContext {
// Make sure any 'sub bridge contexts' also have our bridges.
//TODO There's no matching method in the super-class here
+ /** @return new bridge context */
public abstract BridgeContext createBridgeContext();
}
diff --git a/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java b/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java
index 31895cebe..c4191077f 100644
--- a/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java
+++ b/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java
@@ -160,10 +160,15 @@ public abstract class AbstractFOPImageElementBridge extends SVGImageElementBridg
*/
public class LoaderImageNode extends AbstractGraphicsNode {
+ /** image */
protected final Image image;
+ /** bridge context */
protected final BridgeContext ctx;
+ /** image element */
protected final Element imageElement;
+ /** parsed url */
protected final ParsedURL purl;
+ /** original graphics mode */
protected GraphicsNode origGraphicsNode = null;
/**
diff --git a/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java b/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java
index eec402075..01ef22efa 100644
--- a/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java
+++ b/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java
@@ -26,9 +26,9 @@ import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.DOMImplementation;
-
import org.xml.sax.EntityResolver;
+import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
@@ -47,15 +47,17 @@ import org.apache.batik.util.SVGConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.SimpleLog;
+import org.apache.xmlgraphics.image.GraphicsConstants;
import org.apache.xmlgraphics.image.loader.ImageContext;
import org.apache.xmlgraphics.image.loader.ImageManager;
import org.apache.xmlgraphics.image.loader.ImageSessionContext;
import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* This is the common base class of all of FOP's transcoders.
*/
-public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder {
+public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder implements Configurable {
/**
* The key is used to specify the resolution for on-the-fly images generated
@@ -129,7 +131,10 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder {
this.resolver = resolver;
}
- /** {@inheritDoc} */
+ /**
+ * @param cfg the configuration
+ * @throws ConfigurationException if not caught
+ */
public void configure(Configuration cfg) throws ConfigurationException {
this.cfg = cfg;
}
@@ -222,7 +227,7 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder {
if (hints.containsKey(KEY_DEVICE_RESOLUTION)) {
return ((Float)hints.get(KEY_DEVICE_RESOLUTION)).floatValue();
} else {
- return 72;
+ return GraphicsConstants.DEFAULT_DPI;
}
}
@@ -249,7 +254,7 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder {
protected void setupImageInfrastructure(final String baseURI) {
final ImageContext imageContext = new ImageContext() {
public float getSourceResolution() {
- return 25.4f / userAgent.getPixelUnitToMillimeter();
+ return UnitConv.IN2MM / userAgent.getPixelUnitToMillimeter();
}
};
this.imageManager = new ImageManager(imageContext);
@@ -368,7 +373,7 @@ public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder {
return ((Float)getTranscodingHints().get(key)).floatValue();
} else {
// return 0.3528f; // 72 dpi
- return 25.4f / 96; //96dpi = 0.2645833333333333333f;
+ return UnitConv.IN2MM / 96; //96dpi = 0.2645833333333333333f;
}
}
diff --git a/src/java/org/apache/fop/svg/FOPTextHandler.java b/src/java/org/apache/fop/svg/FOPTextHandler.java
index 8fa9eeedd..cb59c7472 100644
--- a/src/java/org/apache/fop/svg/FOPTextHandler.java
+++ b/src/java/org/apache/fop/svg/FOPTextHandler.java
@@ -19,9 +19,12 @@
package org.apache.fop.svg;
+/** an fop extension to text handler */
public interface FOPTextHandler extends org.apache.xmlgraphics.java2d.TextHandler {
+ /** @param font override font */
void setOverrideFont(org.apache.fop.fonts.Font font);
+ /** @return font info */
org.apache.fop.fonts.FontInfo getFontInfo();
}
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRegistry.java b/src/java/org/apache/fop/svg/FOPTextHandlerAdapter.java
index 59ca6cf38..6f326546e 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRegistry.java
+++ b/src/java/org/apache/fop/svg/FOPTextHandlerAdapter.java
@@ -17,26 +17,15 @@
/* $Id$ */
-package org.apache.fop.render.afp;
+package org.apache.fop.svg;
-import org.apache.fop.render.AbstractImageHandlerRegistry;
+import org.apache.xmlgraphics.java2d.StrokingTextHandler;
/**
- * This class holds references to various image handlers used by the AFP renderer. It also
- * supports automatic discovery of additional handlers available through
- * the class path.
+ * The <code>FOPTextHandlerAdapter</code> class is an adapter class to permit use of
+ * FOPTextHandler without incurring deprecation warnings caused by the underlying
+ * org.apache.xmlgraphics.java2d.TextHandler.drawString(String...) method.
+ * @see org.apache.xmlgraphics.java2d.TextHandler
*/
-public class AFPImageHandlerRegistry extends AbstractImageHandlerRegistry {
-
- /**
- * Main constructor
- */
- public AFPImageHandlerRegistry() {
- }
-
- /** {@inheritDoc} */
- public Class getHandlerClass() {
- return AFPImageHandler.class;
- }
-
+public abstract class FOPTextHandlerAdapter extends StrokingTextHandler implements FOPTextHandler {
}
diff --git a/src/java/org/apache/fop/svg/GraphicsConfiguration.java b/src/java/org/apache/fop/svg/GraphicsConfiguration.java
index 881096b9a..83fd79b9d 100644
--- a/src/java/org/apache/fop/svg/GraphicsConfiguration.java
+++ b/src/java/org/apache/fop/svg/GraphicsConfiguration.java
@@ -29,9 +29,12 @@ import java.awt.image.VolatileImage;
* for JDK 1.3 because there is no VolatileImage there.
*
*/
-abstract public class GraphicsConfiguration extends java.awt.GraphicsConfiguration {
+public abstract class GraphicsConfiguration extends java.awt.GraphicsConfiguration {
/**
+ * @param width of image
+ * @param height of image
+ * @return new volatile image
* @see java.awt.GraphicsConfiguration#createCompatibleVolatileImage(int, int)
* @since JDK 1.4
*/
@@ -40,6 +43,10 @@ abstract public class GraphicsConfiguration extends java.awt.GraphicsConfigurati
}
/**
+ * @param width of image
+ * @param height of image
+ * @param transparency of image
+ * @return new volatile image
* @see java.awt.GraphicsConfiguration#createCompatibleVolatileImage(int, int, int)
* @since JDK 1.5
*/
diff --git a/src/java/org/apache/fop/svg/NativeImageHandler.java b/src/java/org/apache/fop/svg/NativeImageHandler.java
index 8e74cba1d..e9d8116e6 100644
--- a/src/java/org/apache/fop/svg/NativeImageHandler.java
+++ b/src/java/org/apache/fop/svg/NativeImageHandler.java
@@ -19,6 +19,7 @@
package org.apache.fop.svg;
+/** native image handler */
public interface NativeImageHandler {
/**
diff --git a/src/java/org/apache/fop/svg/NativeTextPainter.java b/src/java/org/apache/fop/svg/NativeTextPainter.java
index 7da7269c2..94d426396 100644
--- a/src/java/org/apache/fop/svg/NativeTextPainter.java
+++ b/src/java/org/apache/fop/svg/NativeTextPainter.java
@@ -111,9 +111,9 @@ public abstract class NativeTextPainter extends StrokingTextPainter {
String style = ((posture != null) && (posture.floatValue() > 0.0))
? Font.STYLE_ITALIC : Font.STYLE_NORMAL;
- int weight = ((taWeight != null)
- && (taWeight.floatValue() > 1.0)) ? Font.WEIGHT_BOLD
- : Font.WEIGHT_NORMAL;
+ int weight = toCSSWeight(taWeight != null
+ ? taWeight.floatValue()
+ : TextAttribute.WEIGHT_REGULAR.floatValue());
String firstFontFamily = null;
@@ -176,6 +176,28 @@ public abstract class NativeTextPainter extends StrokingTextPainter {
return (Font[])fonts.toArray(new Font[fonts.size()]);
}
+ private int toCSSWeight(float weight) {
+ if (weight <= TextAttribute.WEIGHT_EXTRA_LIGHT.floatValue()) {
+ return 100;
+ } else if (weight <= TextAttribute.WEIGHT_LIGHT.floatValue()) {
+ return 200;
+ } else if (weight <= TextAttribute.WEIGHT_DEMILIGHT.floatValue()) {
+ return 300;
+ } else if (weight <= TextAttribute.WEIGHT_REGULAR.floatValue()) {
+ return 400;
+ } else if (weight <= TextAttribute.WEIGHT_SEMIBOLD.floatValue()) {
+ return 500;
+ } else if (weight <= TextAttribute.WEIGHT_BOLD.floatValue()) {
+ return 600;
+ } else if (weight <= TextAttribute.WEIGHT_HEAVY.floatValue()) {
+ return 700;
+ } else if (weight <= TextAttribute.WEIGHT_EXTRABOLD.floatValue()) {
+ return 800;
+ } else {
+ return 900;
+ }
+ }
+
/**
* Collects all characters from an {@link AttributedCharacterIterator}.
* @param runaci the character iterator
@@ -190,6 +212,10 @@ public abstract class NativeTextPainter extends StrokingTextPainter {
return chars;
}
+ /**
+ * @param runaci an attributed character iterator
+ * @param layout a text span layout
+ */
protected final void logTextRun(AttributedCharacterIterator runaci, TextSpanLayout layout) {
if (log.isTraceEnabled()) {
int charCount = runaci.getEndIndex() - runaci.getBeginIndex();
@@ -202,6 +228,12 @@ public abstract class NativeTextPainter extends StrokingTextPainter {
}
}
+ /**
+ * @param ch a character
+ * @param layout a text span layout
+ * @param index an index
+ * @param visibleChar visible character flag
+ */
protected final void logCharacter(char ch, TextSpanLayout layout, int index,
boolean visibleChar) {
if (log.isTraceEnabled()) {
diff --git a/src/java/org/apache/fop/svg/PDFBridgeContext.java b/src/java/org/apache/fop/svg/PDFBridgeContext.java
index e8569f881..a38465ed4 100644
--- a/src/java/org/apache/fop/svg/PDFBridgeContext.java
+++ b/src/java/org/apache/fop/svg/PDFBridgeContext.java
@@ -125,6 +125,7 @@ public class PDFBridgeContext extends AbstractFOPBridgeContext {
// Make sure any 'sub bridge contexts' also have our bridges.
//TODO There's no matching method in the super-class here
+ /** @return the new bridge context */
public BridgeContext createBridgeContext() {
return new PDFBridgeContext(getUserAgent(), getDocumentLoader(),
fontInfo,
diff --git a/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java b/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
index 7d777fa14..829d8972d 100644
--- a/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
+++ b/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
@@ -30,6 +30,8 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.StringWriter;
+import org.apache.xmlgraphics.image.GraphicsConstants;
+
import org.apache.fop.Version;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontSetup;
@@ -64,7 +66,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D {
/** Normal PDF resolution (72dpi) */
public static final int NORMAL_PDF_RESOLUTION = 72;
/** Default device resolution (300dpi is a resonable quality for most purposes) */
- public static final int DEFAULT_NATIVE_DPI = 300;
+ public static final int DEFAULT_NATIVE_DPI = GraphicsConstants.DEFAULT_SAMPLE_DPI;
/**
* The device resolution may be different from the normal target resolution. See
@@ -257,6 +259,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D {
if (!pdfContext.isPagePending()) {
return; //ignore
}
+ currentStream.write("Q\n");
//Finish page
PDFStream pdfStream = this.pdfDoc.getFactory().makeStream(
PDFFilterList.CONTENT_FILTER, false);
@@ -322,6 +325,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D {
pdfContext.setCurrentPage(page);
pageRef = page.referencePDF();
+ currentStream.write("q\n");
AffineTransform at = new AffineTransform(1.0, 0.0, 0.0, -1.0,
0.0, height);
currentStream.write("1 0 0 -1 0 " + height + " cm\n");
diff --git a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
index b77518ab0..24974b01a 100644
--- a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
+++ b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
@@ -25,12 +25,15 @@ import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.fonts.CustomFontCollection;
+import org.apache.fop.fonts.FontCollection;
import org.apache.fop.fonts.FontEventListener;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontInfoConfigurator;
import org.apache.fop.fonts.FontManager;
+import org.apache.fop.fonts.FontManagerConfigurator;
import org.apache.fop.fonts.FontResolver;
-import org.apache.fop.fonts.FontSetup;
+import org.apache.fop.fonts.base14.Base14FontCollection;
import org.apache.fop.pdf.PDFDocument;
import org.apache.fop.render.pdf.PDFRendererConfigurator;
@@ -70,29 +73,30 @@ public class PDFDocumentGraphics2DConfigurator {
*/
public static FontInfo createFontInfo(Configuration cfg) throws FOPException {
FontInfo fontInfo = new FontInfo();
+ final boolean strict = false;
+ FontResolver fontResolver = FontManager.createMinimalFontResolver();
+ //TODO The following could be optimized by retaining the FontManager somewhere
+ FontManager fontManager = new FontManager();
if (cfg != null) {
- FontResolver fontResolver = FontManager.createMinimalFontResolver();
- //TODO The following could be optimized by retaining the FontManager somewhere
- FontManager fontManager = new FontManager();
+ FontManagerConfigurator fmConfigurator = new FontManagerConfigurator(cfg);
+ fmConfigurator.configure(fontManager, strict);
+ }
- //TODO Make use of fontBaseURL, font substitution and referencing configuration
- //Requires a change to the expected configuration layout
+ List fontCollections = new java.util.ArrayList();
+ fontCollections.add(new Base14FontCollection(fontManager.isBase14KerningEnabled()));
+ if (cfg != null) {
//TODO Wire in the FontEventListener
- final FontEventListener listener = null;
- final boolean strict = false;
+ FontEventListener listener = null; //new FontEventAdapter(eventBroadcaster);
FontInfoConfigurator fontInfoConfigurator
= new FontInfoConfigurator(cfg, fontManager, fontResolver, listener, strict);
List/*<EmbedFontInfo>*/ fontInfoList = new java.util.ArrayList/*<EmbedFontInfo>*/();
fontInfoConfigurator.configure(fontInfoList);
-
- if (fontManager.useCache()) {
- fontManager.getFontCache().save();
- }
- FontSetup.setup(fontInfo, fontInfoList, fontResolver);
- } else {
- FontSetup.setup(fontInfo);
+ fontCollections.add(new CustomFontCollection(fontResolver, fontInfoList));
}
+ fontManager.setup(fontInfo,
+ (FontCollection[])fontCollections.toArray(
+ new FontCollection[fontCollections.size()]));
return fontInfo;
}
diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java
index fee91bbf8..e93914258 100644
--- a/src/java/org/apache/fop/svg/PDFGraphics2D.java
+++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java
@@ -60,6 +60,7 @@ import org.apache.batik.ext.awt.RenderingHintsKeyExt;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.batik.gvt.PatternPaint;
+import org.apache.xmlgraphics.image.GraphicsConstants;
import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.ImageSize;
import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
@@ -762,7 +763,7 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
* @param fill true if the paint should be set for filling
* @return true if the paint is handled natively, false if the paint should be rasterized
*/
- protected boolean applyPaint(Paint paint, boolean fill) {
+ protected boolean applyPaint(Paint paint, boolean fill) { // CSOK: MethodLength
preparePainting();
if (paint instanceof Color) {
@@ -1039,6 +1040,11 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
return true;
}
+ /**
+ * @param paint some paint
+ * @param shape a shape
+ * @return true (always)
+ */
protected boolean applyUnknownPaint(Paint paint, Shape shape) {
preparePainting();
@@ -1186,6 +1192,8 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
case BasicStroke.CAP_SQUARE:
currentStream.write(2 + " J\n");
break;
+ default:
+ break;
}
int lj = bs.getLineJoin();
@@ -1199,6 +1207,8 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
case BasicStroke.JOIN_BEVEL:
currentStream.write(2 + " j\n");
break;
+ default:
+ break;
}
float lw = bs.getLineWidth();
currentStream.write(PDFNumber.doubleOut(lw) + " w\n");
@@ -1214,7 +1224,11 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
drawInnerRenderedImage(key, img, xform);
}
- /** {@inheritDoc} */
+ /**
+ * @param key a key
+ * @param img an image
+ * @param xform a transform
+ */
public void drawInnerRenderedImage(String key, RenderedImage img, AffineTransform xform) {
preparePainting();
PDFXObject xObject = pdfDoc.getXObject(key);
@@ -1243,7 +1257,8 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
private PDFXObject addRenderedImage(String key, RenderedImage img) {
ImageInfo info = new ImageInfo(null, "image/unknown");
- ImageSize size = new ImageSize(img.getWidth(), img.getHeight(), 72);
+ ImageSize size = new ImageSize(img.getWidth(), img.getHeight(),
+ GraphicsConstants.DEFAULT_DPI);
info.setSize(size);
ImageRendered imgRend = new ImageRendered(info, img, null);
ImageRenderedAdapter adapter = new ImageRenderedAdapter(imgRend, key);
diff --git a/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java b/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java
index 4ec6ad634..a41b7e229 100644
--- a/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java
+++ b/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java
@@ -33,11 +33,11 @@ import java.awt.image.ColorModel;
*/
class PDFGraphicsConfiguration extends GraphicsConfiguration {
// We use this to get a good colormodel..
- private static final BufferedImage BI_WITH_ALPHA =
- new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
+ private static final BufferedImage BI_WITH_ALPHA
+ = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
// We use this to get a good colormodel..
- private static final BufferedImage BI_WITHOUT_ALPHA =
- new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
+ private static final BufferedImage BI_WITHOUT_ALPHA
+ = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
/**
* Construct a buffered image with an alpha channel, unless
diff --git a/src/java/org/apache/fop/svg/PDFGraphicsDevice.java b/src/java/org/apache/fop/svg/PDFGraphicsDevice.java
index 5da2d50ee..538dd16c2 100644
--- a/src/java/org/apache/fop/svg/PDFGraphicsDevice.java
+++ b/src/java/org/apache/fop/svg/PDFGraphicsDevice.java
@@ -39,7 +39,7 @@ class PDFGraphicsDevice extends GraphicsDevice {
/**
* Create a new PDF graphics device.
*
- * @param The gc we should reference
+ * @param gc The graphics configuration we should reference
*/
PDFGraphicsDevice(PDFGraphicsConfiguration gc) {
this.gc = gc;
@@ -62,7 +62,7 @@ class PDFGraphicsDevice extends GraphicsDevice {
* @return an array containing the one graphics configuration
*/
public GraphicsConfiguration[] getConfigurations() {
- return new GraphicsConfiguration[]{ gc };
+ return new GraphicsConfiguration[] {gc};
}
/**
diff --git a/src/java/org/apache/fop/svg/PDFTextPainter.java b/src/java/org/apache/fop/svg/PDFTextPainter.java
index e962d5a59..fe8ad1c7e 100644
--- a/src/java/org/apache/fop/svg/PDFTextPainter.java
+++ b/src/java/org/apache/fop/svg/PDFTextPainter.java
@@ -40,7 +40,7 @@ import org.apache.fop.fonts.FontInfo;
import org.apache.fop.util.CharUtilities;
/**
- * Renders the attributed character iterator of a {@link TextNode}.
+ * Renders the attributed character iterator of a {@link org.apache.batik.gvt.TextNode}.
* This class draws the text directly into the PDFGraphics2D so that
* the text is not drawn using shapes which makes the PDF files larger.
* If the text is simple enough to draw then it sets the font and calls
diff --git a/src/java/org/apache/fop/svg/PDFTranscoder.java b/src/java/org/apache/fop/svg/PDFTranscoder.java
index fc27cb48a..bf08b2fcf 100644
--- a/src/java/org/apache/fop/svg/PDFTranscoder.java
+++ b/src/java/org/apache/fop/svg/PDFTranscoder.java
@@ -27,7 +27,6 @@ import java.io.OutputStream;
import org.w3c.dom.Document;
import org.w3c.dom.svg.SVGLength;
-import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.UnitProcessor;
@@ -73,8 +72,7 @@ import org.apache.fop.fonts.FontInfo;
* @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
* @version $Id$
*/
-public class PDFTranscoder extends AbstractFOPTranscoder
- implements Configurable {
+public class PDFTranscoder extends AbstractFOPTranscoder {
/** Graphics2D instance that is used to paint to */
protected PDFDocumentGraphics2D graphics = null;
diff --git a/src/java/org/apache/fop/svg/SVGEventProducer.java b/src/java/org/apache/fop/svg/SVGEventProducer.java
index 27d7da215..743649717 100644
--- a/src/java/org/apache/fop/svg/SVGEventProducer.java
+++ b/src/java/org/apache/fop/svg/SVGEventProducer.java
@@ -30,7 +30,10 @@ public interface SVGEventProducer extends EventProducer {
/**
* Provider class for the event producer.
*/
- class Provider {
+ final class Provider {
+
+ private Provider() {
+ }
/**
* Returns an event producer.
diff --git a/src/java/org/apache/fop/svg/SVGUtilities.java b/src/java/org/apache/fop/svg/SVGUtilities.java
index 97cd31eed..3401307cf 100644
--- a/src/java/org/apache/fop/svg/SVGUtilities.java
+++ b/src/java/org/apache/fop/svg/SVGUtilities.java
@@ -34,7 +34,11 @@ import org.apache.batik.util.XMLConstants;
/**
* Some utilities for creating svg DOM documents and elements.
*/
-public class SVGUtilities {
+public final class SVGUtilities {
+
+ private SVGUtilities() {
+ }
+
private static final String SVG_NS = SVGDOMImplementation.SVG_NAMESPACE_URI;
/**
@@ -43,7 +47,7 @@ public class SVGUtilities {
* @param height the height of the root svg element
* @return a new SVG Document
*/
- public static final Document createSVGDocument(float width,
+ public static Document createSVGDocument(float width,
float height) {
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
Document doc = impl.createDocument(SVG_NS, "svg", null);
@@ -60,9 +64,9 @@ public class SVGUtilities {
* @param font the font
* @return the width of the string in the given font
*/
- public static final float getStringWidth(String str, java.awt.Font font) {
- Rectangle2D rect =
- font.getStringBounds(str, 0, str.length(),
+ public static float getStringWidth(String str, java.awt.Font font) {
+ Rectangle2D rect
+ = font.getStringBounds(str, 0, str.length(),
new FontRenderContext(new AffineTransform(),
true, true));
return (float)rect.getWidth();
@@ -74,10 +78,10 @@ public class SVGUtilities {
* @param font the font
* @return the height of the string in the given font
*/
- public static final float getStringHeight(String str,
+ public static float getStringHeight(String str,
java.awt.Font font) {
- Rectangle2D rect =
- font.getStringBounds(str, 0, str.length(),
+ Rectangle2D rect
+ = font.getStringBounds(str, 0, str.length(),
new FontRenderContext(new AffineTransform(),
true, true));
return (float)rect.getHeight();
@@ -89,7 +93,7 @@ public class SVGUtilities {
* @param font the font
* @return the bounds of the string
*/
- public static final Rectangle2D getStringBounds(String str,
+ public static Rectangle2D getStringBounds(String str,
java.awt.Font font) {
return font.getStringBounds(str, 0, str.length(),
new FontRenderContext(new AffineTransform(),
@@ -105,7 +109,7 @@ public class SVGUtilities {
* @param y2 the end y position
* @return the new line element
*/
- public static final Element createLine(Document doc, float x, float y,
+ public static Element createLine(Document doc, float x, float y,
float x2, float y2) {
Element ellipse = doc.createElementNS(SVG_NS, "line");
ellipse.setAttributeNS(null, "x1", "" + x);
@@ -124,7 +128,7 @@ public class SVGUtilities {
* @param ry the y axis radius
* @return the new ellipse element
*/
- public static final Element createEllipse(Document doc, float cx,
+ public static Element createEllipse(Document doc, float cx,
float cy, float rx, float ry) {
Element ellipse = doc.createElementNS(SVG_NS, "ellipse");
ellipse.setAttributeNS(null, "cx", "" + cx);
@@ -140,7 +144,7 @@ public class SVGUtilities {
* @param str the string for the d attribute on the path
* @return the new path element
*/
- public static final Element createPath(Document doc, String str) {
+ public static Element createPath(Document doc, String str) {
Element path = doc.createElementNS(SVG_NS, "path");
path.setAttributeNS(null, "d", str);
return path;
@@ -154,7 +158,7 @@ public class SVGUtilities {
* @param str the string
* @return the new text element
*/
- public static final Element createText(Document doc, float x, float y,
+ public static Element createText(Document doc, float x, float y,
String str) {
Element textGraph = doc.createElementNS(SVG_NS, "text");
textGraph.setAttributeNS(null, "x", "" + x);
@@ -173,7 +177,7 @@ public class SVGUtilities {
* @param height the height of the rectangle
* @return the new rectangle element
*/
- public static final Element createRect(Document doc, float x, float y,
+ public static Element createRect(Document doc, float x, float y,
float width, float height) {
Element border = doc.createElementNS(SVG_NS, "rect");
border.setAttributeNS(null, "x", "" + x);
@@ -188,7 +192,7 @@ public class SVGUtilities {
* @param doc the document to create the element
* @return the new g element
*/
- public static final Element createG(Document doc) {
+ public static Element createG(Document doc) {
Element border = doc.createElementNS(SVG_NS, "g");
return border;
}
@@ -200,7 +204,7 @@ public class SVGUtilities {
* @param id the id of the clipping path
* @return the new clip element
*/
- public static final Element createClip(Document doc, Element els,
+ public static Element createClip(Document doc, Element els,
String id) {
Element border = doc.createElementNS(SVG_NS, "clipPath");
border.setAttributeNS(null, "id", id);
@@ -216,7 +220,7 @@ public class SVGUtilities {
* @param height the height to set on the image
* @return a new image element
*/
- public static final Element createImage(Document doc, String ref,
+ public static Element createImage(Document doc, String ref,
float width, float height) {
Element border = doc.createElementNS(SVG_NS, "image");
border.setAttributeNS(XMLConstants.XLINK_NAMESPACE_URI, "href",
@@ -234,7 +238,7 @@ public class SVGUtilities {
* @param width the width to wrap
* @return the new element containing the wrapped text
*/
- public static final Element wrapText(Document doc, String str,
+ public static Element wrapText(Document doc, String str,
java.awt.Font font, float width) {
Element g = createG(doc);
Element text;
diff --git a/src/java/org/apache/fop/text/linebreak/LineBreakStatus.java b/src/java/org/apache/fop/text/linebreak/LineBreakStatus.java
index 15f3434d9..157a480cc 100644
--- a/src/java/org/apache/fop/text/linebreak/LineBreakStatus.java
+++ b/src/java/org/apache/fop/text/linebreak/LineBreakStatus.java
@@ -62,8 +62,9 @@ public class LineBreakStatus {
/**
* Check whether a line break may happen according to the rules described in
- * the <a href="http://unicode.org/reports/tr14/#Algorithm">Unicode Line Breaking Algorithm</a>.
- * The function returns the line breaking status of the point <em>before</em> the given character.
+ * the <a href="http://unicode.org/reports/tr14/#Algorithm">Unicode Line Breaking
+ * Algorithm</a>. The function returns the line breaking status of the point
+ * <em>before</em> the given character.
* The algorithm is the table-driven algorithm, as described in
* <a href="http://unicode.org/reports/tr14/#PairBasedImplementation">
* Unicode Technical Report #14</a>.
@@ -86,6 +87,7 @@ public class LineBreakStatus {
/* Initial conversions */
switch (currentClass) {
+ case 0: // Unassigned codepoint: same treatment as AI
case LineBreakUtils.LINE_BREAK_PROPERTY_AI:
case LineBreakUtils.LINE_BREAK_PROPERTY_SG:
case LineBreakUtils.LINE_BREAK_PROPERTY_XX:
diff --git a/src/java/org/apache/fop/text/linebreak/LineBreakUtils.java b/src/java/org/apache/fop/text/linebreak/LineBreakUtils.java
index 49557a6c9..343191eea 100644
--- a/src/java/org/apache/fop/text/linebreak/LineBreakUtils.java
+++ b/src/java/org/apache/fop/text/linebreak/LineBreakUtils.java
@@ -29,8 +29,15 @@ package org.apache.fop.text.linebreak;
* - commit BOTH changed files
*/
+// CSOFF: WhitespaceAfterCheck
+// CSOFF: LineLengthCheck
+
+/** Line breaking utilities. */
public final class LineBreakUtils {
+ private LineBreakUtils() {
+ }
+
/** Break class constant */
public static final byte DIRECT_BREAK = 0;
/** Break class constant */
@@ -44,179 +51,180 @@ public final class LineBreakUtils {
/** Break class constant */
public static final byte EXPLICIT_BREAK = 5;
- private static final byte PAIR_TABLE[][] = {
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 4, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 1, 1, 1, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 4, 1, 0, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 1, 1, 1, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 0, 1, 4, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 4, 4, 4, 4, 0, 0, 4, 3, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 4, 4, 4, 4, 4, 4, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 1, 0, 4, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 1, 1, 1, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 4, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 1, 0, 0, 0, 4, 2, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 1, 1, 1, 1, 0, 0, 4, 2, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}};
+ private static final byte[][] PAIR_TABLE = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 1, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 4, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 1, 1, 1, 0, 0, 4, 2, 4, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 1, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 4, 1, 0, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 4, 1, 0, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 1, 1, 1, 0, 0, 4, 2, 4, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 1, 1, 1, 0, 1, 4, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 1, 4, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 4, 4, 4, 4, 0, 0, 4, 3, 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 4, 4, 4, 4, 4, 4, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 1, 1, 1, 1, 0, 4, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 1, 1, 1, 0, 0, 4, 2, 4, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 4, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 1, 0, 0, 0, 4, 2, 4, 0, 4, 1, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 1, 1, 1, 1, 0, 0, 4, 2, 4, 0, 4, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 4, 4, 0, 4},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}};
- private static byte lineBreakProperties[][] = new byte[512][];
+ private static byte[][] lineBreakProperties = new byte[512][];
- private static void init_0() {
- lineBreakProperties[0] = new byte[] { 9, 9, 9, 9, 9, 9, 9, 9, 9, 4, 22, 6, 6, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 32, 11, 29, 2, 28, 27, 2, 29, 26, 8, 2, 28, 18, 15, 18, 33, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 18, 18, 2, 2, 2, 11, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 28, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 4, 8, 2, 9};
- lineBreakProperties[1] = new byte[] { 9, 9, 9, 9, 9, 23, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 12, 26, 27, 28, 28, 28, 2, 1, 1, 2, 1, 29, 2, 4, 2, 2, 27, 28, 1, 1, 5, 2, 1, 1, 1, 1, 1, 29, 1, 1, 1, 26, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2};
+ private static void init0() {
+ lineBreakProperties[0] = new byte[] { 9, 9, 9, 9, 9, 9, 9, 9, 9, 4, 23, 6, 6, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 33, 12, 30, 2, 29, 28, 2, 30, 27, 10, 2, 29, 19, 16, 19, 34, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 19, 19, 2, 2, 2, 12, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 27, 29, 10, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 27, 4, 8, 2, 9};
+ lineBreakProperties[1] = new byte[] { 9, 9, 9, 9, 9, 24, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 13, 27, 28, 29, 29, 29, 2, 1, 1, 2, 1, 30, 2, 4, 2, 2, 28, 29, 1, 1, 5, 2, 1, 1, 1, 1, 1, 30, 1, 1, 1, 27, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2};
lineBreakProperties[2] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
lineBreakProperties[5] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 5, 1, 1, 1, 5, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 1, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[6] = new byte[] { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 12, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 12, 12, 12, 12, 12, 12, 12, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 18, 0};
+ lineBreakProperties[6] = new byte[] { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 13, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 13, 13, 13, 13, 13, 13, 13, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 19, 0};
lineBreakProperties[7] = new byte[] { 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
lineBreakProperties[9] = new byte[] { 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[10] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[11] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 0, 18, 4, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 4, 9, 2, 9, 9, 2, 9, 9, 11, 9, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[12] = new byte[] { 2, 2, 2, 2, 0, 0, 2, 2, 2, 27, 27, 27, 18, 18, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 0, 0, 11, 11, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 27, 25, 25, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[13] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 11, 2, 9, 9, 9, 9, 9, 9, 9, 2, 9, 9, 9, 9, 9, 9, 9, 2, 2, 9, 9, 2, 9, 9, 9, 9, 2, 2, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[10] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[11] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 0, 19, 4, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 4, 9, 2, 9, 9, 2, 9, 9, 12, 9, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[12] = new byte[] { 2, 2, 2, 2, 0, 0, 2, 2, 2, 28, 28, 28, 19, 19, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 12, 0, 0, 12, 12, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 28, 26, 26, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[13] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 12, 2, 9, 9, 9, 9, 9, 9, 9, 2, 9, 9, 9, 9, 9, 9, 9, 2, 2, 9, 9, 2, 9, 9, 9, 9, 2, 2, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 2, 2, 2, 2, 2, 2};
lineBreakProperties[14] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[15] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 18, 11, 2, 0, 0, 0, 0, 0};
- lineBreakProperties[16] = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[18] = new byte[] { 0, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 9, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 2, 9, 9, 9, 9, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 4, 4, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2};
- lineBreakProperties[19] = new byte[] { 0, 9, 9, 9, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 0, 0, 2, 2, 2, 2, 0, 0, 9, 2, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 0, 0, 9, 9, 9, 2, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 2, 2, 0, 2, 2, 2, 9, 9, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 2, 2, 28, 28, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0};
- lineBreakProperties[20] = new byte[] { 0, 9, 9, 9, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 0, 9, 0, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 0, 0, 9, 9, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 9, 9, 2, 2, 2, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[21] = new byte[] { 0, 9, 9, 9, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 0, 2, 2, 2, 2, 2, 0, 0, 9, 2, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 0, 9, 9, 9, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 9, 9, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[22] = new byte[] { 0, 9, 9, 9, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 0, 2, 2, 2, 2, 2, 0, 0, 9, 2, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 2, 2, 0, 2, 2, 2, 9, 9, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[23] = new byte[] { 0, 0, 9, 2, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 0, 2, 2, 2, 2, 0, 0, 0, 2, 2, 0, 2, 0, 2, 2, 0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 9, 9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 0, 9, 9, 9, 9, 0, 0, 2, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 2, 2, 2, 2, 2, 2, 2, 2, 2, 28, 2, 0, 0, 0, 0, 0};
- lineBreakProperties[24] = new byte[] { 0, 9, 9, 9, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 0, 0, 0, 2, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2, 9, 9, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[25] = new byte[] { 0, 0, 9, 9, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 0, 0, 9, 2, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 2, 9, 9, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[26] = new byte[] { 0, 0, 9, 9, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 9, 9, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 2, 2, 2, 2, 2, 2, 0, 0, 0, 27, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[15] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 19, 12, 2, 0, 0, 0, 0, 0};
+ lineBreakProperties[16] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 9, 9, 9, 2, 9, 9, 9, 9, 9, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[17] = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[18] = new byte[] { 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 9, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 2, 9, 9, 9, 9, 9, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 4, 4, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 2, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[19] = new byte[] { 0, 9, 9, 9, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 0, 0, 2, 2, 2, 2, 0, 0, 9, 2, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 0, 0, 9, 9, 9, 2, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 2, 2, 0, 2, 2, 2, 9, 9, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 2, 2, 28, 28, 2, 2, 2, 2, 2, 28, 2, 29, 0, 0, 0, 0};
+ lineBreakProperties[20] = new byte[] { 0, 9, 9, 9, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 0, 9, 0, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 0, 0, 9, 9, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 9, 9, 2, 2, 2, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[21] = new byte[] { 0, 9, 9, 9, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 0, 2, 2, 2, 2, 2, 0, 0, 9, 2, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 0, 9, 9, 9, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 9, 9, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[22] = new byte[] { 0, 9, 9, 9, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 0, 2, 2, 2, 2, 2, 0, 0, 9, 2, 9, 9, 9, 9, 9, 9, 9, 0, 0, 9, 9, 0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 2, 2, 0, 2, 2, 2, 9, 9, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[23] = new byte[] { 0, 0, 9, 2, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 0, 2, 2, 2, 2, 0, 0, 0, 2, 2, 0, 2, 0, 2, 2, 0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 9, 9, 9, 9, 9, 0, 0, 0, 9, 9, 9, 0, 9, 9, 9, 9, 0, 0, 2, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 2, 2, 2, 2, 2, 2, 2, 2, 2, 29, 2, 0, 0, 0, 0, 0};
+ lineBreakProperties[24] = new byte[] { 0, 9, 9, 9, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 0, 0, 0, 2, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2, 9, 9, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[25] = new byte[] { 0, 0, 9, 9, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 0, 0, 9, 2, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 2, 9, 9, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[26] = new byte[] { 0, 0, 9, 9, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 9, 9, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 2, 2, 2, 2, 2, 2, 0, 0, 0, 28, 2, 2, 2, 2, 2, 2};
lineBreakProperties[27] = new byte[] { 0, 0, 9, 9, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 0, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[28] = new byte[] { 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 2, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[29] = new byte[] { 0, 30, 30, 0, 30, 0, 0, 30, 30, 0, 30, 0, 0, 30, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 0, 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 30, 0, 30, 0, 30, 0, 0, 30, 30, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 30, 0, 0, 30, 30, 30, 30, 30, 0, 30, 0, 30, 30, 30, 30, 30, 30, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[30] = new byte[] { 2, 5, 5, 5, 5, 2, 5, 5, 12, 5, 5, 4, 12, 11, 11, 11, 11, 11, 12, 2, 11, 2, 2, 2, 9, 9, 2, 2, 2, 2, 2, 2, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 9, 2, 9, 2, 9, 26, 8, 26, 8, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 4};
- lineBreakProperties[31] = new byte[] { 9, 9, 9, 9, 9, 4, 9, 9, 2, 2, 2, 2, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 4, 4, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 0, 2, 2, 5, 5, 4, 5, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[32] = new byte[] { 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 4, 4, 2, 2, 2, 2, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30};
- lineBreakProperties[33] = new byte[] { 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0, 0, 0, 30, 30, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0};
- lineBreakProperties[34] = new byte[] { 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 0, 0, 0, 0, 0, 19, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21};
- lineBreakProperties[35] = new byte[] { 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 0, 0, 0, 0, 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[28] = new byte[] { 0, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 0, 0, 0, 0, 29, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 2, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[29] = new byte[] { 0, 31, 31, 0, 31, 0, 0, 31, 31, 0, 31, 0, 0, 31, 0, 0, 0, 0, 0, 0, 31, 31, 31, 31, 0, 31, 31, 31, 31, 31, 31, 31, 0, 31, 31, 31, 0, 31, 0, 31, 0, 0, 31, 31, 0, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 0, 31, 31, 31, 0, 0, 31, 31, 31, 31, 31, 0, 31, 0, 31, 31, 31, 31, 31, 31, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 31, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[30] = new byte[] { 2, 5, 5, 5, 5, 2, 5, 5, 13, 5, 5, 4, 13, 12, 12, 12, 12, 12, 13, 2, 12, 2, 2, 2, 9, 9, 2, 2, 2, 2, 2, 2, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 9, 2, 9, 2, 9, 27, 8, 27, 8, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 4};
+ lineBreakProperties[31] = new byte[] { 9, 9, 9, 9, 9, 4, 9, 9, 2, 2, 2, 2, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 4, 4, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 0, 2, 2, 5, 5, 4, 5, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[32] = new byte[] { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 4, 4, 2, 2, 2, 2, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31};
+ lineBreakProperties[33] = new byte[] { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 31, 31, 31, 31, 31, 31, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0};
+ lineBreakProperties[34] = new byte[] { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22};
+ lineBreakProperties[35] = new byte[] { 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21};
lineBreakProperties[36] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
lineBreakProperties[37] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
lineBreakProperties[38] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 9, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0};
lineBreakProperties[39] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[40] = new byte[] { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[44] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[45] = new byte[] { 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 8, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[40] = new byte[] { 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[45] = new byte[] { 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 27, 8, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
lineBreakProperties[46] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[47] = new byte[] { 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 4, 4, 24, 30, 4, 2, 4, 28, 30, 30, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[48] = new byte[] { 2, 2, 11, 11, 4, 4, 5, 2, 11, 11, 2, 9, 9, 9, 12, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[49] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[50] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 2, 0, 0, 0, 11, 11, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[51] = new byte[] { 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0, 0, 0, 30, 30, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[52] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[54] = new byte[] { 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0};
- lineBreakProperties[55] = new byte[] { 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 2, 2, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[56] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 4, 4, 4, 4, 4, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0, 0, 2, 2, 2, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4};
- lineBreakProperties[59] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9};
+ lineBreakProperties[47] = new byte[] { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 4, 4, 25, 31, 4, 2, 4, 29, 31, 31, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[48] = new byte[] { 2, 2, 12, 12, 4, 4, 5, 2, 12, 12, 2, 9, 9, 9, 13, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[49] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[50] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 2, 0, 0, 0, 12, 12, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 0, 0, 31, 31, 31, 31, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[51] = new byte[] { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 0, 0, 0, 0, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 31, 31, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[52] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 0, 0, 2, 2, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 0, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 0, 0, 9};
+ lineBreakProperties[53] = new byte[] { 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[54] = new byte[] { 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 4, 4, 2, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0};
+ lineBreakProperties[55] = new byte[] { 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 2, 2, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[56] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 4, 4, 4, 4, 4, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 2, 2, 2, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4};
+ lineBreakProperties[57] = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 9, 2, 2, 2, 2, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[59] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9};
lineBreakProperties[62] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0};
lineBreakProperties[63] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 5, 2, 0};
- lineBreakProperties[64] = new byte[] { 4, 4, 4, 4, 4, 4, 4, 12, 4, 4, 4, 36, 9, 9, 9, 9, 4, 12, 4, 4, 3, 1, 1, 2, 29, 29, 26, 29, 29, 29, 26, 29, 1, 1, 2, 2, 17, 17, 17, 4, 6, 6, 9, 9, 9, 9, 9, 12, 27, 27, 27, 27, 27, 27, 27, 27, 2, 29, 29, 1, 24, 24, 2, 2, 2, 2, 2, 2, 18, 26, 8, 24, 24, 24, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 4, 4, 4, 4, 2, 4, 4, 4, 34, 2, 2, 2, 2, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 2, 2, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 26, 8, 1};
- lineBreakProperties[65] = new byte[] { 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 26, 8, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 28, 28, 28, 28, 28, 28, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[66] = new byte[] { 2, 2, 2, 27, 2, 1, 2, 2, 2, 27, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 28, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 1, 1, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[67] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[68] = new byte[] { 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 1, 2, 2, 2, 1, 2, 1, 28, 28, 2, 1, 2, 2, 2, 2, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[64] = new byte[] { 4, 4, 4, 4, 4, 4, 4, 13, 4, 4, 4, 37, 9, 9, 9, 9, 4, 13, 4, 4, 3, 1, 1, 2, 30, 30, 27, 30, 30, 30, 27, 30, 1, 1, 2, 2, 18, 18, 18, 4, 6, 6, 9, 9, 9, 9, 9, 13, 28, 28, 28, 28, 28, 28, 28, 28, 2, 30, 30, 1, 25, 25, 2, 2, 2, 2, 2, 2, 19, 27, 8, 25, 25, 25, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 4, 4, 4, 4, 2, 4, 4, 4, 35, 2, 2, 2, 2, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 2, 2, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 27, 8, 1};
+ lineBreakProperties[65] = new byte[] { 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 27, 8, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 29, 29, 29, 29, 29, 29, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 28, 29, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[66] = new byte[] { 2, 2, 2, 28, 2, 1, 2, 2, 2, 28, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 29, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[67] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[68] = new byte[] { 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 1, 2, 2, 2, 1, 2, 1, 29, 29, 2, 1, 2, 2, 2, 2, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
lineBreakProperties[69] = new byte[] { 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[70] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[71] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[70] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 27, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[71] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
lineBreakProperties[72] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
lineBreakProperties[73] = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2};
- lineBreakProperties[74] = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[75] = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 1, 2, 2, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
}
- private static void init_1() {
+ private static void init1() {
+ lineBreakProperties[74] = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[75] = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 1, 2, 2, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
lineBreakProperties[76] = new byte[] { 2, 2, 2, 2, 2, 1, 1, 2, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[77] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[78] = new byte[] { 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, 2, 2, 0, 0, 0, 2, 0, 2, 2, 2, 29, 29, 29, 29, 0, 0, 2, 11, 11, 2, 2, 2, 2, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
- lineBreakProperties[79] = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 26, 8, 2, 2, 2, 2, 0, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[83] = new byte[] { 2, 2, 2, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 8, 26, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 8, 2, 2};
- lineBreakProperties[86] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[88] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0};
- lineBreakProperties[89] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 4, 4, 4, 2, 11, 4};
+ lineBreakProperties[77] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
+ lineBreakProperties[78] = new byte[] { 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, 2, 2, 0, 0, 0, 2, 1, 2, 2, 2, 30, 30, 30, 30, 0, 0, 2, 12, 12, 2, 2, 2, 2, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
+ lineBreakProperties[79] = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 27, 8, 2, 2, 2, 2, 0, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[83] = new byte[] { 2, 2, 2, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 27, 8, 27, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 27, 8, 2, 2};
+ lineBreakProperties[86] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[88] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[89] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 12, 4, 4, 4, 2, 12, 4};
lineBreakProperties[90] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
lineBreakProperties[91] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9};
- lineBreakProperties[92] = new byte[] { 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 26, 4, 2, 2, 29, 29, 2, 2, 29, 29, 26, 8, 26, 8, 26, 8, 26, 8, 4, 4, 4, 4, 11, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[93] = new byte[] { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[94] = new byte[] { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
- lineBreakProperties[95] = new byte[] { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0};
- lineBreakProperties[96] = new byte[] { 16, 8, 8, 16, 16, 24, 16, 16, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 16, 16, 26, 8, 26, 8, 26, 8, 26, 8, 24, 26, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 9, 9, 9, 9, 9, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 24, 24, 16, 16, 16, 0, 24, 16, 24, 16, 24, 16, 24, 16, 24, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 24, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
- lineBreakProperties[97] = new byte[] { 16, 16, 16, 24, 16, 24, 16, 24, 16, 16, 16, 16, 16, 16, 24, 16, 16, 16, 16, 16, 16, 24, 24, 0, 0, 9, 9, 24, 24, 24, 24, 16, 24, 24, 16, 24, 16, 24, 16, 24, 16, 24, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 24, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 24, 16, 24, 16, 24, 16, 16, 16, 16, 16, 16, 24, 16, 16, 16, 16, 16, 16, 24, 24, 16, 16, 16, 16, 24, 24, 24, 24, 16};
- lineBreakProperties[98] = new byte[] { 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
- lineBreakProperties[99] = new byte[] { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24};
- lineBreakProperties[100] = new byte[] { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
- lineBreakProperties[101] = new byte[] { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0};
- lineBreakProperties[155] = new byte[] { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[319] = new byte[] { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[320] = new byte[] { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 24, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
- lineBreakProperties[329] = new byte[] { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[332] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 11, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 2, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 2, 2};
- lineBreakProperties[333] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[92] = new byte[] { 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 27, 4, 2, 2, 30, 30, 2, 2, 30, 30, 27, 8, 27, 8, 27, 8, 27, 8, 4, 4, 4, 4, 12, 2, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[93] = new byte[] { 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[94] = new byte[] { 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17};
+ lineBreakProperties[95] = new byte[] { 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0};
+ lineBreakProperties[96] = new byte[] { 17, 8, 8, 17, 17, 25, 17, 17, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 17, 17, 27, 8, 27, 8, 27, 8, 27, 8, 25, 27, 8, 8, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 9, 9, 9, 9, 9, 9, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 25, 25, 17, 17, 17, 0, 25, 17, 25, 17, 25, 17, 25, 17, 25, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 25, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17};
+ lineBreakProperties[97] = new byte[] { 17, 17, 17, 25, 17, 25, 17, 25, 17, 17, 17, 17, 17, 17, 25, 17, 17, 17, 17, 17, 17, 25, 25, 0, 0, 9, 9, 25, 25, 25, 25, 17, 25, 25, 17, 25, 17, 25, 17, 25, 17, 25, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 25, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 25, 17, 25, 17, 25, 17, 17, 17, 17, 17, 17, 25, 17, 17, 17, 17, 17, 17, 25, 25, 17, 17, 17, 17, 25, 25, 25, 25, 17};
+ lineBreakProperties[98] = new byte[] { 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17};
+ lineBreakProperties[99] = new byte[] { 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25};
+ lineBreakProperties[100] = new byte[] { 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1, 1, 1, 1, 1, 1, 1, 1, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17};
+ lineBreakProperties[101] = new byte[] { 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0};
+ lineBreakProperties[155] = new byte[] { 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[320] = new byte[] { 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 25, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17};
+ lineBreakProperties[329] = new byte[] { 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4};
+ lineBreakProperties[332] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 12, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 2, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 2, 2};
+ lineBreakProperties[333] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 2, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0};
lineBreakProperties[335] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2};
- lineBreakProperties[336] = new byte[] { 2, 2, 9, 2, 2, 2, 9, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[337] = new byte[] { 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[338] = new byte[] { 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[340] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 0, 0, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 0, 0, 2, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[344] = new byte[] { 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14};
- lineBreakProperties[345] = new byte[] { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14};
- lineBreakProperties[346] = new byte[] { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14};
- lineBreakProperties[347] = new byte[] { 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14};
- lineBreakProperties[348] = new byte[] { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14};
- lineBreakProperties[349] = new byte[] { 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14};
- lineBreakProperties[350] = new byte[] { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14};
- lineBreakProperties[431] = new byte[] { 14, 14, 14, 14, 14, 14, 14, 14, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- lineBreakProperties[432] = new byte[] { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31};
- lineBreakProperties[448] = new byte[] { 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35};
- lineBreakProperties[500] = new byte[] { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
- lineBreakProperties[501] = new byte[] { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[336] = new byte[] { 2, 2, 9, 2, 2, 2, 9, 2, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 28, 2, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[337] = new byte[] { 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0};
+ lineBreakProperties[338] = new byte[] { 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0};
+ lineBreakProperties[339] = new byte[] { 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 2, 2, 2, 4, 4, 4, 2, 2, 2, 2, 0, 2, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[340] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 2, 4, 4, 4, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 0, 0, 0, 0};
+ lineBreakProperties[341] = new byte[] { 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 31, 31, 31, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[343] = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 4, 9, 9, 0, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, 0, 0, 0, 0};
+ lineBreakProperties[344] = new byte[] { 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15};
+ lineBreakProperties[345] = new byte[] { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15};
+ lineBreakProperties[346] = new byte[] { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15};
+ lineBreakProperties[347] = new byte[] { 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15};
+ lineBreakProperties[348] = new byte[] { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15};
+ lineBreakProperties[349] = new byte[] { 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15};
+ lineBreakProperties[350] = new byte[] { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15};
+ lineBreakProperties[431] = new byte[] { 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 0, 0, 0, 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 0, 0, 0, 0};
+ lineBreakProperties[432] = new byte[] { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32};
+ lineBreakProperties[448] = new byte[] { 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36};
lineBreakProperties[502] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 2, 9, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
lineBreakProperties[503] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[506] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[507] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 27, 2, 0, 0};
- lineBreakProperties[508] = new byte[] { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 18, 8, 8, 18, 18, 11, 11, 26, 8, 17, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 26, 8, 16, 16, 26, 8, 16, 16, 16, 16, 16, 16, 16, 8, 16, 8, 0, 24, 24, 11, 11, 16, 26, 8, 26, 8, 26, 8, 16, 16, 16, 16, 16, 16, 16, 16, 0, 16, 28, 27, 16, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[509] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 34};
- lineBreakProperties[510] = new byte[] { 0, 11, 16, 16, 28, 27, 16, 16, 26, 8, 16, 16, 8, 16, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 24, 24, 16, 16, 16, 11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 26, 16, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 26, 16, 8, 16, 26, 8, 8, 26, 8, 8, 24, 2, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- lineBreakProperties[511] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 24, 24, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 0, 0, 0, 27, 28, 16, 16, 16, 28, 28, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 7, 1, 0, 0};
+ lineBreakProperties[506] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 27, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[507] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 28, 2, 0, 0};
+ lineBreakProperties[508] = new byte[] { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 19, 8, 8, 19, 19, 12, 12, 27, 8, 18, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17, 17, 17, 17, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 27, 8, 17, 17, 27, 8, 17, 17, 17, 17, 17, 17, 17, 8, 17, 8, 0, 25, 25, 12, 12, 17, 27, 8, 27, 8, 27, 8, 17, 17, 17, 17, 17, 17, 17, 17, 0, 17, 29, 28, 17, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[509] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 35};
+ lineBreakProperties[510] = new byte[] { 0, 12, 17, 17, 29, 28, 17, 17, 27, 8, 17, 17, 8, 17, 8, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 25, 25, 17, 17, 17, 12, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 27, 17, 8, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 27, 17, 8, 17, 27, 8, 8, 27, 8, 8, 25, 2, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
+ lineBreakProperties[511] = new byte[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 25, 25, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 0, 0, 0, 28, 29, 17, 17, 17, 29, 29, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 7, 1, 0, 0};
}
static {
- init_0();
- init_1();
+ init0();
+ init1();
lineBreakProperties[3] = lineBreakProperties[2];
lineBreakProperties[4] = lineBreakProperties[2];
lineBreakProperties[8] = lineBreakProperties[2];
- lineBreakProperties[17] = lineBreakProperties[16];
lineBreakProperties[41] = lineBreakProperties[2];
lineBreakProperties[42] = lineBreakProperties[2];
lineBreakProperties[43] = lineBreakProperties[2];
- lineBreakProperties[53] = lineBreakProperties[16];
- lineBreakProperties[57] = lineBreakProperties[16];
+ lineBreakProperties[44] = lineBreakProperties[2];
lineBreakProperties[58] = lineBreakProperties[2];
lineBreakProperties[60] = lineBreakProperties[2];
lineBreakProperties[61] = lineBreakProperties[2];
@@ -225,7 +233,7 @@ public final class LineBreakUtils {
lineBreakProperties[82] = lineBreakProperties[2];
lineBreakProperties[84] = lineBreakProperties[2];
lineBreakProperties[85] = lineBreakProperties[2];
- lineBreakProperties[87] = lineBreakProperties[16];
+ lineBreakProperties[87] = lineBreakProperties[17];
lineBreakProperties[102] = lineBreakProperties[94];
lineBreakProperties[103] = lineBreakProperties[94];
lineBreakProperties[104] = lineBreakProperties[94];
@@ -442,6 +450,7 @@ public final class LineBreakUtils {
lineBreakProperties[316] = lineBreakProperties[94];
lineBreakProperties[317] = lineBreakProperties[94];
lineBreakProperties[318] = lineBreakProperties[94];
+ lineBreakProperties[319] = lineBreakProperties[94];
lineBreakProperties[321] = lineBreakProperties[94];
lineBreakProperties[322] = lineBreakProperties[94];
lineBreakProperties[323] = lineBreakProperties[94];
@@ -453,10 +462,7 @@ public final class LineBreakUtils {
lineBreakProperties[330] = lineBreakProperties[2];
lineBreakProperties[331] = lineBreakProperties[2];
lineBreakProperties[334] = lineBreakProperties[2];
- lineBreakProperties[339] = lineBreakProperties[16];
- lineBreakProperties[341] = lineBreakProperties[16];
- lineBreakProperties[342] = lineBreakProperties[16];
- lineBreakProperties[343] = lineBreakProperties[16];
+ lineBreakProperties[342] = lineBreakProperties[17];
lineBreakProperties[351] = lineBreakProperties[344];
lineBreakProperties[352] = lineBreakProperties[345];
lineBreakProperties[353] = lineBreakProperties[346];
@@ -603,6 +609,8 @@ public final class LineBreakUtils {
lineBreakProperties[497] = lineBreakProperties[448];
lineBreakProperties[498] = lineBreakProperties[94];
lineBreakProperties[499] = lineBreakProperties[94];
+ lineBreakProperties[500] = lineBreakProperties[94];
+ lineBreakProperties[501] = lineBreakProperties[94];
lineBreakProperties[504] = lineBreakProperties[2];
lineBreakProperties[505] = lineBreakProperties[2];
}
@@ -626,68 +634,70 @@ public final class LineBreakUtils {
/** Linebreak property constant */
public static final byte LINE_BREAK_PROPERTY_CM = 9;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_CR = 10;
+ public static final byte LINE_BREAK_PROPERTY_CP = 10;
+ /** Linebreak property constant */
+ public static final byte LINE_BREAK_PROPERTY_CR = 11;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_EX = 11;
+ public static final byte LINE_BREAK_PROPERTY_EX = 12;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_GL = 12;
+ public static final byte LINE_BREAK_PROPERTY_GL = 13;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_H2 = 13;
+ public static final byte LINE_BREAK_PROPERTY_H2 = 14;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_H3 = 14;
+ public static final byte LINE_BREAK_PROPERTY_H3 = 15;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_HY = 15;
+ public static final byte LINE_BREAK_PROPERTY_HY = 16;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_ID = 16;
+ public static final byte LINE_BREAK_PROPERTY_ID = 17;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_IN = 17;
+ public static final byte LINE_BREAK_PROPERTY_IN = 18;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_IS = 18;
+ public static final byte LINE_BREAK_PROPERTY_IS = 19;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_JL = 19;
+ public static final byte LINE_BREAK_PROPERTY_JL = 20;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_JT = 20;
+ public static final byte LINE_BREAK_PROPERTY_JT = 21;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_JV = 21;
+ public static final byte LINE_BREAK_PROPERTY_JV = 22;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_LF = 22;
+ public static final byte LINE_BREAK_PROPERTY_LF = 23;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_NL = 23;
+ public static final byte LINE_BREAK_PROPERTY_NL = 24;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_NS = 24;
+ public static final byte LINE_BREAK_PROPERTY_NS = 25;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_NU = 25;
+ public static final byte LINE_BREAK_PROPERTY_NU = 26;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_OP = 26;
+ public static final byte LINE_BREAK_PROPERTY_OP = 27;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_PO = 27;
+ public static final byte LINE_BREAK_PROPERTY_PO = 28;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_PR = 28;
+ public static final byte LINE_BREAK_PROPERTY_PR = 29;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_QU = 29;
+ public static final byte LINE_BREAK_PROPERTY_QU = 30;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_SA = 30;
+ public static final byte LINE_BREAK_PROPERTY_SA = 31;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_SG = 31;
+ public static final byte LINE_BREAK_PROPERTY_SG = 32;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_SP = 32;
+ public static final byte LINE_BREAK_PROPERTY_SP = 33;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_SY = 33;
+ public static final byte LINE_BREAK_PROPERTY_SY = 34;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_WJ = 34;
+ public static final byte LINE_BREAK_PROPERTY_WJ = 35;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_XX = 35;
+ public static final byte LINE_BREAK_PROPERTY_XX = 36;
/** Linebreak property constant */
- public static final byte LINE_BREAK_PROPERTY_ZW = 36;
+ public static final byte LINE_BREAK_PROPERTY_ZW = 37;
- private static String lineBreakPropertyShortNames[] = {"AI", "AL", "B2", "BA", "BB", "BK", "CB", "CL", "CM", "CR", "EX",
- "GL", "H2", "H3", "HY", "ID", "IN", "IS", "JL", "JT", "JV", "LF", "NL", "NS", "NU", "OP", "PO", "PR", "QU", "SA", "SG", "SP",
- "SY", "WJ", "XX", "ZW"};
+ private static String[] lineBreakPropertyShortNames = {"AI", "AL", "B2", "BA", "BB", "BK", "CB", "CL", "CM",
+ "CP", "CR", "EX", "GL", "H2", "H3", "HY", "ID", "IN", "IS", "JL", "JT", "JV", "LF", "NL", "NS", "NU", "OP",
+ "PO", "PR", "QU", "SA", "SG", "SP", "SY", "WJ", "XX", "ZW"};
- private static String lineBreakPropertyLongNames[] = {"Ambiguous","Alphabetic","Break_Both","Break_After","Break_Before",
- "Mandatory_Break","Contingent_Break","Close_Punctuation","Combining_Mark","Carriage_Return","Exclamation",
- "Glue","H2","H3","Hyphen","Ideographic","Inseparable","Infix_Numeric","JL","JT","JV","Line_Feed","Next_Line",
- "Nonstarter","Numeric","Open_Punctuation","Postfix_Numeric","Prefix_Numeric","Quotation","Complex_Context",
+ private static String[] lineBreakPropertyLongNames = {"Ambiguous","Alphabetic","Break_Both","Break_After","Break_Before",
+ "Mandatory_Break","Contingent_Break","Close_Punctuation","Combining_Mark","Close_Parenthesis","Carriage_Return",
+ "Exclamation","Glue","H2","H3","Hyphen","Ideographic","Inseparable","Infix_Numeric","JL","JT","JV","Line_Feed",
+ "Next_Line","Nonstarter","Numeric","Open_Punctuation","Postfix_Numeric","Prefix_Numeric","Quotation","Complex_Context",
"Surrogate","Space","Break_Symbols","Word_Joiner","Unknown","ZWSpace"};
/**
diff --git a/src/java/org/apache/fop/tools/anttasks/FileCompare.java b/src/java/org/apache/fop/tools/anttasks/FileCompare.java
index d9b64226a..83b0aa896 100644
--- a/src/java/org/apache/fop/tools/anttasks/FileCompare.java
+++ b/src/java/org/apache/fop/tools/anttasks/FileCompare.java
@@ -84,6 +84,7 @@ public class FileCompare {
* @param f1 first file to compare
* @param f2 second file to compare
* @return true if files are same, false otherwise
+ * @throws IOException if not caught
*/
public static boolean compareFiles(File f1, File f2) throws IOException {
return (compareFileSize(f1, f2) && compareBytes(f1, f2));
@@ -91,13 +92,15 @@ public class FileCompare {
/**
* Compare the contents of two files.
- * @param true if files are same byte-by-byte, false otherwise
+ * @param file1 the first file to compare
+ * @param file2 the second file to compare
+ * @return true if files are same byte-by-byte, false otherwise
*/
private static boolean compareBytes(File file1, File file2) throws IOException {
- BufferedInputStream file1Input =
- new BufferedInputStream(new java.io.FileInputStream(file1));
- BufferedInputStream file2Input =
- new BufferedInputStream(new java.io.FileInputStream(file2));
+ BufferedInputStream file1Input
+ = new BufferedInputStream(new java.io.FileInputStream(file1));
+ BufferedInputStream file2Input
+ = new BufferedInputStream(new java.io.FileInputStream(file2));
int charact1 = 0;
int charact2 = 0;
@@ -116,14 +119,12 @@ public class FileCompare {
/**
* Does a file size compare of two files
- * @param true if files are same length, false otherwise
+ * @param oldFile the first file to compare
+ * @param newFile the second file to compare
+ * @return true if files are same length, false otherwise
*/
private static boolean compareFileSize(File oldFile, File newFile) {
- if (oldFile.length() != newFile.length()) {
- return false;
- } else {
- return true;
- }
+ return oldFile.length() == newFile.length();
} // end: compareBytes
private boolean filesExist(File oldFile, File newFile) {
@@ -163,8 +164,8 @@ public class FileCompare {
File oldFile;
File newFile;
try {
- PrintWriter results =
- new PrintWriter(new java.io.FileWriter("results.html"), true);
+ PrintWriter results
+ = new PrintWriter(new java.io.FileWriter("results.html"), true);
this.writeHeader(results);
for (int i = 0; i < filenameList.length; i++) {
oldFile = new File(referenceDirectory + filenameList[i]);
diff --git a/src/java/org/apache/fop/tools/anttasks/Fop.java b/src/java/org/apache/fop/tools/anttasks/Fop.java
index cfb8c8ade..58dd1fb5b 100644
--- a/src/java/org/apache/fop/tools/anttasks/Fop.java
+++ b/src/java/org/apache/fop/tools/anttasks/Fop.java
@@ -20,14 +20,6 @@
package org.apache.fop.tools.anttasks;
// Ant
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.util.GlobPatternMapper;
-
-// Java
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
@@ -36,17 +28,23 @@ import java.net.MalformedURLException;
import java.util.List;
import java.util.Vector;
-// FOP
+import org.xml.sax.SAXException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.impl.SimpleLog;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.util.GlobPatternMapper;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.cli.InputHandler;
-import org.apache.commons.logging.impl.SimpleLog;
-import org.apache.commons.logging.Log;
-import org.xml.sax.SAXException;
-
/**
* Wrapper for FOP which allows it to be accessed from within an Ant task.
* Accepts the inputs:
@@ -156,7 +154,7 @@ public class Fop extends Task {
}
/**
- * Sets the XSLT parameters
+ * Sets the XSLT parameters
* @param xsltParams the XSLT parameters
*/
public void setXsltParams(String xsltParams) {
@@ -267,8 +265,7 @@ public class Fop extends Task {
/**
* Set whether exceptions are thrown.
* default is false.
- *
- * @param force true if always generate.
+ * @param throwExceptions true if exceptions should be thrown
*/
public void setThrowexceptions(boolean throwExceptions) {
this.throwExceptions = throwExceptions;
@@ -308,6 +305,7 @@ public class Fop extends Task {
/**
* Returns the message type corresponding to Project.MSG_*
* representing the current message level.
+ * @return message type
* @see org.apache.tools.ant.Project
*/
public int getMessageType() {
@@ -489,9 +487,6 @@ class FOPTaskStarter {
return new File(file.getParentFile(), name);
}
- /**
- * {@inheritDoc}
- */
public void run() throws FOPException {
//Set base directory
if (task.getBasedir() != null) {
@@ -556,13 +551,13 @@ class FOPTaskStarter {
// OR output file doesn't exist OR
// output file is older than input file
if (task.getForce() || !outf.exists()
- || (task.getXmlFile().lastModified() > outf.lastModified() ||
- task.getXsltFile().lastModified() > outf.lastModified())) {
+ || (task.getXmlFile().lastModified() > outf.lastModified()
+ || task.getXsltFile().lastModified() > outf.lastModified())) {
render(task.getXmlFile(), task.getXsltFile(), outf, outputFormat);
actioncount++;
} else if (outf.exists()
- && (task.getXmlFile().lastModified() <= outf.lastModified() ||
- task.getXsltFile().lastModified() <= outf.lastModified())) {
+ && (task.getXmlFile().lastModified() <= outf.lastModified()
+ || task.getXsltFile().lastModified() <= outf.lastModified())) {
skippedcount++;
}
}
@@ -642,7 +637,8 @@ class FOPTaskStarter {
}
}
- private void renderInputHandler(InputHandler inputHandler, File outFile, String outputFormat) throws Exception {
+ private void renderInputHandler(InputHandler inputHandler, File outFile, String outputFormat)
+ throws Exception {
OutputStream out = null;
try {
out = new java.io.FileOutputStream(outFile);
@@ -693,10 +689,12 @@ class FOPTaskStarter {
try {
renderInputHandler(inputHandler, outFile, outputFormat);
} catch (Exception ex) {
- logger.error("Error rendering xml/xslt files: " + xmlFile + ", " + xsltFile, ex);
+ logger.error("Error rendering xml/xslt files: "
+ + xmlFile + ", " + xsltFile, ex);
}
if (task.getLogFiles()) {
- task.log("xml: " + xmlFile + ", xslt: " + xsltFile + " -> " + outFile, Project.MSG_INFO);
+ task.log("xml: " + xmlFile + ", xslt: "
+ + xsltFile + " -> " + outFile, Project.MSG_INFO);
}
}
}
diff --git a/src/java/org/apache/fop/tools/fontlist/FontSpec.java b/src/java/org/apache/fop/tools/fontlist/FontSpec.java
index ce5c7a6c7..953175abc 100644
--- a/src/java/org/apache/fop/tools/fontlist/FontSpec.java
+++ b/src/java/org/apache/fop/tools/fontlist/FontSpec.java
@@ -22,6 +22,7 @@ package org.apache.fop.tools.fontlist;
import java.util.Collection;
import java.util.Collections;
import java.util.SortedSet;
+import java.util.TreeSet;
import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.fonts.FontTriplet;
@@ -33,8 +34,8 @@ public class FontSpec implements Comparable {
private String key;
private FontMetrics metrics;
- private SortedSet familyNames = new java.util.TreeSet();
- private Collection triplets = new java.util.TreeSet();
+ private SortedSet<String> familyNames = new TreeSet<String>();
+ private Collection triplets = new TreeSet();
/**
* Creates a new font spec.
@@ -50,7 +51,7 @@ public class FontSpec implements Comparable {
* Adds font family names.
* @param names the names
*/
- public void addFamilyNames(Collection names) {
+ public void addFamilyNames(Collection<String> names) {
this.familyNames.addAll(names);
}
diff --git a/src/java/org/apache/fop/traits/BorderProps.java b/src/java/org/apache/fop/traits/BorderProps.java
index d6265fb50..ae7a9a434 100644
--- a/src/java/org/apache/fop/traits/BorderProps.java
+++ b/src/java/org/apache/fop/traits/BorderProps.java
@@ -34,6 +34,8 @@ import org.apache.fop.util.ColorUtil;
*/
public class BorderProps implements Serializable {
+ private static final long serialVersionUID = -886871454032189183L;
+
/** Separate border model */
public static final int SEPARATE = 0;
/** Collapsing border model, for borders inside a table */
@@ -42,13 +44,13 @@ public class BorderProps implements Serializable {
public static final int COLLAPSE_OUTER = 2;
/** Border style (one of EN_*) */
- public int style; // Enum for border style
+ public int style; // Enum for border style // CSOK: VisibilityModifier
/** Border color */
- public Color color;
+ public Color color; // CSOK: VisibilityModifier
/** Border width */
- public int width;
+ public int width; // CSOK: VisibilityModifier
/** Border mode (one of SEPARATE, COLLAPSE_INNER and COLLAPSE_OUTER) */
- public int mode;
+ public int mode; // CSOK: VisibilityModifier
/**
* Constructs a new BorderProps instance.
diff --git a/src/java/org/apache/fop/traits/MinOptMax.java b/src/java/org/apache/fop/traits/MinOptMax.java
index 0f0422799..45b55695f 100644
--- a/src/java/org/apache/fop/traits/MinOptMax.java
+++ b/src/java/org/apache/fop/traits/MinOptMax.java
@@ -56,7 +56,7 @@ public final class MinOptMax implements Serializable {
* @return the corresponding instance
* @throws IllegalArgumentException if <code>min > opt || max < opt</code>.
*/
- public static MinOptMax getInstance(int min, int opt, int max) {
+ public static MinOptMax getInstance(int min, int opt, int max) throws IllegalArgumentException {
if (min > opt) {
throw new IllegalArgumentException("min (" + min + ") > opt (" + opt + ")");
}
@@ -167,7 +167,7 @@ public final class MinOptMax implements Serializable {
* @throws ArithmeticException if this instance has strictly less shrink or stretch
* than the operand
*/
- public MinOptMax minus(MinOptMax operand) {
+ public MinOptMax minus(MinOptMax operand) throws ArithmeticException {
checkCompatibility(getShrink(), operand.getShrink(), "shrink");
checkCompatibility(getStretch(), operand.getStretch(), "stretch");
return new MinOptMax(min - operand.min, opt - operand.opt, max - operand.max);
@@ -192,50 +192,54 @@ public final class MinOptMax implements Serializable {
}
/**
- * Returns an instance with the given value added to the minimal value.
+ * Do not use, backwards compatibility only. Returns an instance with the
+ * given value added to the minimal value.
*
* @param minOperand the minimal value to be added.
* @return an instance with the given value added to the minimal value.
- * @throws IllegalArgumentException if <code>min + minOperand > opt || max < opt</code>.
- * @deprecated Do not use! It's only for backwards compatibility.
+ * @throws IllegalArgumentException if
+ * <code>min + minOperand > opt || max < opt</code>.
*/
- public MinOptMax plusMin(int minOperand) {
+ public MinOptMax plusMin(int minOperand) throws IllegalArgumentException {
return getInstance(min + minOperand, opt, max);
}
/**
- * Returns an instance with the given value subtracted to the minimal value.
+ * Do not use, backwards compatibility only. Returns an instance with the
+ * given value subtracted to the minimal value.
*
* @param minOperand the minimal value to be subtracted.
* @return an instance with the given value subtracted to the minimal value.
- * @throws IllegalArgumentException if <code>min - minOperand > opt || max < opt</code>.
- * @deprecated Do not use! It's only for backwards compatibility.
+ * @throws IllegalArgumentException if
+ * <code>min - minOperand > opt || max < opt</code>.
*/
- public MinOptMax minusMin(int minOperand) {
+ public MinOptMax minusMin(int minOperand) throws IllegalArgumentException {
return getInstance(min - minOperand, opt, max);
}
/**
- * Returns an instance with the given value added to the maximal value.
+ * Do not use, backwards compatibility only. Returns an instance with the
+ * given value added to the maximal value.
*
* @param maxOperand the maximal value to be added.
* @return an instance with the given value added to the maximal value.
- * @throws IllegalArgumentException if <code>min > opt || max < opt + maxOperand</code>.
- * @deprecated Do not use! It's only for backwards compatibility.
+ * @throws IllegalArgumentException if
+ * <code>min > opt || max < opt + maxOperand</code>.
*/
- public MinOptMax plusMax(int maxOperand) {
+ public MinOptMax plusMax(int maxOperand) throws IllegalArgumentException {
return getInstance(min, opt, max + maxOperand);
}
/**
- * Returns an instance with the given value subtracted to the maximal value.
+ * Do not use, backwards compatibility only. Returns an instance with the
+ * given value subtracted to the maximal value.
*
* @param maxOperand the maximal value to be subtracted.
* @return an instance with the given value subtracted to the maximal value.
- * @throws IllegalArgumentException if <code>min > opt || max < opt - maxOperand</code>.
- * @deprecated Do not use! It's only for backwards compatibility.
+ * @throws IllegalArgumentException if
+ * <code>min > opt || max < opt - maxOperand</code>.
*/
- public MinOptMax minusMax(int maxOperand) {
+ public MinOptMax minusMax(int maxOperand) throws IllegalArgumentException {
return getInstance(min, opt, max - maxOperand);
}
@@ -246,7 +250,7 @@ public final class MinOptMax implements Serializable {
* @return the product of this <code>MinOptMax</code> and the given factor
* @throws IllegalArgumentException if the factor is negative
*/
- public MinOptMax mult(int factor) {
+ public MinOptMax mult(int factor) throws IllegalArgumentException {
if (factor < 0) {
throw new IllegalArgumentException("factor < 0; was: " + factor);
} else if (factor == 1) {
diff --git a/src/java/org/apache/fop/traits/SpaceVal.java b/src/java/org/apache/fop/traits/SpaceVal.java
index cb709c73e..f9f5c4991 100644
--- a/src/java/org/apache/fop/traits/SpaceVal.java
+++ b/src/java/org/apache/fop/traits/SpaceVal.java
@@ -65,9 +65,9 @@ public class SpaceVal {
/**
* Constructor for SpaceVal objects based on the full set of properties.
* @param space space to use
- * @param bConditional Conditionality value
- * @param bForcing Forcing value
- * @param iPrecedence Precedence value
+ * @param conditional Conditionality value
+ * @param forcing Forcing value
+ * @param precedence Precedence value
*/
public SpaceVal(MinOptMax space, boolean conditional, boolean forcing, int precedence) {
this.space = space;
@@ -76,6 +76,12 @@ public class SpaceVal {
this.precedence = precedence;
}
+ /**
+ * @param wordSpacing property
+ * @param letterSpacing space value
+ * @param fs font
+ * @return space value
+ */
public static SpaceVal makeWordSpacing(Property wordSpacing, SpaceVal letterSpacing, Font fs) {
if (wordSpacing.getEnum() == Constants.EN_NORMAL) {
// give word spaces the possibility to shrink by a third,
@@ -89,6 +95,10 @@ public class SpaceVal {
}
}
+ /**
+ * @param letterSpacing property
+ * @return space value
+ */
public static SpaceVal makeLetterSpacing(Property letterSpacing) {
if (letterSpacing.getEnum() == Constants.EN_NORMAL) {
// letter spaces are set to zero (or use different values?)
diff --git a/src/java/org/apache/fop/traits/TraitEnum.java b/src/java/org/apache/fop/traits/TraitEnum.java
index 18fdffaab..c473228cb 100644
--- a/src/java/org/apache/fop/traits/TraitEnum.java
+++ b/src/java/org/apache/fop/traits/TraitEnum.java
@@ -21,6 +21,8 @@ package org.apache.fop.traits;
import java.io.Serializable;
+import org.apache.fop.fo.Constants;
+
/** Base class for enumeration classes representing traits. */
public abstract class TraitEnum implements Serializable {
diff --git a/src/java/org/apache/fop/util/AbstractPaintingState.java b/src/java/org/apache/fop/util/AbstractPaintingState.java
index bd1bbb87b..96c3633e6 100644
--- a/src/java/org/apache/fop/util/AbstractPaintingState.java
+++ b/src/java/org/apache/fop/util/AbstractPaintingState.java
@@ -342,7 +342,7 @@ public abstract class AbstractPaintingState implements Cloneable, Serializable {
/**
* Sets the current state data
*
- * @param currentData state data
+ * @param data the state data
*/
protected void setData(AbstractData data) {
this.data = data;
@@ -472,6 +472,7 @@ public abstract class AbstractPaintingState implements Cloneable, Serializable {
/**
* Sets the current AffineTransform.
+ * @param baseTransform the transform
*/
public void setTransform(AffineTransform baseTransform) {
this.transform = baseTransform;
diff --git a/src/java/org/apache/fop/util/ColorExt.java b/src/java/org/apache/fop/util/ColorExt.java
index 95452061a..b87882d99 100644
--- a/src/java/org/apache/fop/util/ColorExt.java
+++ b/src/java/org/apache/fop/util/ColorExt.java
@@ -119,7 +119,8 @@ public final class ColorExt extends Color {
* ICC color values
* @return the requested color object
*/
- public static ColorExt createFromSvgIccColor(float red, float green,
+ public static ColorExt createFromSvgIccColor( // CSOK: ParameterNumber
+ float red, float green,
float blue, float opacity, String profileName, String profileHref,
ColorSpace profileCS, float[] colorValues) {
//TODO this method is not referenced by FOP, can it be deleted?
diff --git a/src/java/org/apache/fop/util/ColorProfileUtil.java b/src/java/org/apache/fop/util/ColorProfileUtil.java
index f234dde66..35b6660dc 100644
--- a/src/java/org/apache/fop/util/ColorProfileUtil.java
+++ b/src/java/org/apache/fop/util/ColorProfileUtil.java
@@ -27,7 +27,10 @@ import java.io.UnsupportedEncodingException;
/**
* Helper methods for handling color profiles.
*/
-public class ColorProfileUtil {
+public final class ColorProfileUtil {
+
+ private ColorProfileUtil() {
+ }
/**
* Returns the profile description of an ICC profile
diff --git a/src/java/org/apache/fop/util/ColorUtil.java b/src/java/org/apache/fop/util/ColorUtil.java
index 5a53a816c..3c456dbbc 100644
--- a/src/java/org/apache/fop/util/ColorUtil.java
+++ b/src/java/org/apache/fop/util/ColorUtil.java
@@ -72,7 +72,7 @@ public final class ColorUtil {
private static Map<String, Color> colorMap = null;
/** Logger instance */
- protected static Log log = LogFactory.getLog(ColorUtil.class);
+ protected static final Log log = LogFactory.getLog(ColorUtil.class);
static {
initializeColorMap();
@@ -805,7 +805,7 @@ public final class ColorUtil {
/**
* Initializes the colorMap with some predefined values.
*/
- private static void initializeColorMap() {
+ private static void initializeColorMap() { // CSOK: MethodLength
colorMap = Collections.synchronizedMap(new java.util.HashMap<String, Color>());
colorMap.put("aliceblue", createColor(240, 248, 255));
diff --git a/src/java/org/apache/fop/util/CommandLineLogger.java b/src/java/org/apache/fop/util/CommandLineLogger.java
index 0da112e5c..a9e59158f 100644
--- a/src/java/org/apache/fop/util/CommandLineLogger.java
+++ b/src/java/org/apache/fop/util/CommandLineLogger.java
@@ -1,9 +1,10 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
-/* contributor license agreements. See the NOTICE file distributed with
-/* this work for additional information regarding copyright ownership.
-/* The ASF licenses this file to You under the Apache License, Version 2.0
-/* (the "License"); you may not use this file except in compliance with
-/* the License. You may obtain a copy of the License at
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
diff --git a/src/java/org/apache/fop/util/ConversionUtils.java b/src/java/org/apache/fop/util/ConversionUtils.java
index f445134fc..fcdb4cdbd 100644
--- a/src/java/org/apache/fop/util/ConversionUtils.java
+++ b/src/java/org/apache/fop/util/ConversionUtils.java
@@ -25,6 +25,9 @@ package org.apache.fop.util;
*/
public final class ConversionUtils {
+ private ConversionUtils() {
+ }
+
/**
* Converts the given base <code>String</code> into
* an array of <code>int</code>, splitting the base along the
diff --git a/src/java/org/apache/fop/util/DataURIResolver.java b/src/java/org/apache/fop/util/DataURIResolver.java
index 99a8318c8..19ca31b22 100644
--- a/src/java/org/apache/fop/util/DataURIResolver.java
+++ b/src/java/org/apache/fop/util/DataURIResolver.java
@@ -32,6 +32,10 @@ public class DataURIResolver implements URIResolver {
private final URIResolver newResolver = new org.apache.xmlgraphics.util.uri.DataURIResolver();
/**
+ * @param href an href
+ * @param base a base
+ * @return a source
+ * @throws TransformerException if not caught
* @deprecated
* @see org.apache.xmlgraphics.util.uri.DataURIResolver#resolve(String,
* String)
diff --git a/src/java/org/apache/fop/util/DataURLUtil.java b/src/java/org/apache/fop/util/DataURLUtil.java
index 8568df274..46ff8635b 100644
--- a/src/java/org/apache/fop/util/DataURLUtil.java
+++ b/src/java/org/apache/fop/util/DataURLUtil.java
@@ -24,23 +24,34 @@ import java.io.InputStream;
import java.io.Writer;
/**
- * @deprecated
+ * @deprecated use org.apache.xmlgraphics.util.uri.DataURLUtil directly
* @see org.apache.xmlgraphics.util.uri.DataURLUtil
*/
-public class DataURLUtil {
+public final class DataURLUtil {
+
+ private DataURLUtil() {
+ }
/**
+ * @param in an input stream
+ * @param mediatype a MIME media type
+ * @return a data url as a string
+ * @throws IOException if not caught
* @deprecated
* @see org.apache.xmlgraphics.util.uri.DataURLUtil#createDataURL(InputStream,
* String)
*/
public static String createDataURL(InputStream in, String mediatype)
- throws IOException {
+ throws IOException {
return org.apache.xmlgraphics.util.uri.DataURLUtil.createDataURL(in,
mediatype);
}
/**
+ * @param in an input stream
+ * @param mediatype a MIME media type
+ * @param writer a writer
+ * @throws IOException if not caught
* @deprecated
* @see org.apache.xmlgraphics.util.uri.DataURLUtil#writeDataURL(InputStream,
* String, Writer)
diff --git a/src/java/org/apache/fop/util/DecimalFormatCache.java b/src/java/org/apache/fop/util/DecimalFormatCache.java
index d8c3b7361..a6634f50b 100644
--- a/src/java/org/apache/fop/util/DecimalFormatCache.java
+++ b/src/java/org/apache/fop/util/DecimalFormatCache.java
@@ -28,7 +28,10 @@ import java.util.Locale;
* is not thread-safe but since FOP needs to format a lot of numbers the same way, it shall
* be cached in a {@link ThreadLocal}.
*/
-public class DecimalFormatCache {
+public final class DecimalFormatCache {
+
+ private DecimalFormatCache() {
+ }
private static final String BASE_FORMAT = "0.################";
diff --git a/src/java/org/apache/fop/util/LogUtil.java b/src/java/org/apache/fop/util/LogUtil.java
index 23f275644..664667a76 100644
--- a/src/java/org/apache/fop/util/LogUtil.java
+++ b/src/java/org/apache/fop/util/LogUtil.java
@@ -25,7 +25,10 @@ import org.apache.fop.apps.FOPException;
/**
* Convenience Logging utility methods used in FOP
*/
-public class LogUtil {
+public final class LogUtil {
+
+ private LogUtil() {
+ }
/**
* Convenience method that handles any error appropriately
diff --git a/src/java/org/apache/fop/util/UnitConv.java b/src/java/org/apache/fop/util/UnitConv.java
index cf599712f..b0c87ec18 100644
--- a/src/java/org/apache/fop/util/UnitConv.java
+++ b/src/java/org/apache/fop/util/UnitConv.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Id: $ */
+/* $Id$ */
package org.apache.fop.util;
@@ -27,6 +27,9 @@ import java.awt.geom.AffineTransform;
*/
public final class UnitConv {
+ private UnitConv() {
+ }
+
/**
* conversion factory from millimeters to inches.
* @deprecated use org.apache.xmlgraphics.util.UnitConv.IN2MM instead.
diff --git a/src/java/org/apache/fop/util/WriterOutputStream.java b/src/java/org/apache/fop/util/WriterOutputStream.java
index e08109ab0..17ec5d658 100644
--- a/src/java/org/apache/fop/util/WriterOutputStream.java
+++ b/src/java/org/apache/fop/util/WriterOutputStream.java
@@ -24,7 +24,7 @@ import java.io.OutputStream;
import java.io.Writer;
/**
- * @deprecated
+ * @deprecated use org.apache.xmlgraphics.util.WriterOutputStream instead
* @see org.apache.xmlgraphics.util.WriterOutputStream
*/
public class WriterOutputStream extends OutputStream {
@@ -32,9 +32,7 @@ public class WriterOutputStream extends OutputStream {
private final org.apache.xmlgraphics.util.WriterOutputStream writerOutputStream;
/**
- * @deprecated
- * @see org.apache.xmlgraphics.util.WriterOutputStream#WriterOutputStream(Writer)
- * String)
+ * @param writer a writer
*/
public WriterOutputStream(Writer writer) {
writerOutputStream = new org.apache.xmlgraphics.util.WriterOutputStream(
@@ -42,52 +40,35 @@ public class WriterOutputStream extends OutputStream {
}
/**
- * @deprecated
- * @see org.apache.xmlgraphics.util.WriterOutputStream#WriterOutputStream(Writer,
- * String) String)
+ * @param writer a writer
+ * @param encoding stream encoding
*/
public WriterOutputStream(Writer writer, String encoding) {
writerOutputStream = new org.apache.xmlgraphics.util.WriterOutputStream(
writer, encoding);
}
- /**
- * @deprecated
- * @see org.apache.xmlgraphics.util.WriterOutputStream#close()
- */
+ /** {@inheritDoc} */
public void close() throws IOException {
writerOutputStream.close();
}
- /**
- * @deprecated
- * @see org.apache.xmlgraphics.util.WriterOutputStream#flush()
- */
+ /** {@inheritDoc} */
public void flush() throws IOException {
writerOutputStream.flush();
}
- /**
- * @deprecated
- * @see org.apache.xmlgraphics.util.WriterOutputStream#write(byte[], int,
- * int)
- */
+ /** {@inheritDoc} */
public void write(byte[] buf, int offset, int length) throws IOException {
writerOutputStream.write(buf, offset, length);
}
- /**
- * @deprecated
- * @see org.apache.xmlgraphics.util.WriterOutputStream#write(byte[])
- */
+ /** {@inheritDoc} */
public void write(byte[] buf) throws IOException {
writerOutputStream.write(buf);
}
- /**
- * @deprecated
- * @see org.apache.xmlgraphics.util.WriterOutputStream#write(int)
- */
+ /** {@inheritDoc} */
public void write(int b) throws IOException {
writerOutputStream.write(b);
}
diff --git a/src/java/org/apache/fop/util/XMLUtil.java b/src/java/org/apache/fop/util/XMLUtil.java
index f7c013a2f..0a55ce573 100644
--- a/src/java/org/apache/fop/util/XMLUtil.java
+++ b/src/java/org/apache/fop/util/XMLUtil.java
@@ -30,7 +30,10 @@ import org.xml.sax.helpers.AttributesImpl;
/**
* A collection of utility method for XML handling.
*/
-public class XMLUtil implements XMLConstants {
+public final class XMLUtil implements XMLConstants {
+
+ private XMLUtil() {
+ }
/**
* Returns an attribute value as a boolean value.
diff --git a/src/java/org/apache/fop/util/bitmap/BitmapImageUtil.java b/src/java/org/apache/fop/util/bitmap/BitmapImageUtil.java
index c08076316..b2706c5c2 100644
--- a/src/java/org/apache/fop/util/bitmap/BitmapImageUtil.java
+++ b/src/java/org/apache/fop/util/bitmap/BitmapImageUtil.java
@@ -32,14 +32,17 @@ import java.awt.image.WritableRaster;
/**
* Utility method for dealing with bitmap images.
*/
-public class BitmapImageUtil {
+public final class BitmapImageUtil {
+
+ private BitmapImageUtil() {
+ }
/**
* Indicates whether an image is a monochrome (1 bit black and white) image.
* @param img the image
* @return true if it's a monochrome image
*/
- public static final boolean isMonochromeImage(RenderedImage img) {
+ public static boolean isMonochromeImage(RenderedImage img) {
return (getColorIndexSize(img) == 2);
}
@@ -48,7 +51,7 @@ public class BitmapImageUtil {
* @param img the image (must be 1 bit monochrome)
* @return true if a zero bit indicates a black/dark pixel, false for a white/bright pixel
*/
- public static final boolean isZeroBlack(RenderedImage img) {
+ public static boolean isZeroBlack(RenderedImage img) {
if (!isMonochromeImage(img)) {
throw new IllegalArgumentException("Image is not a monochrome image!");
}
@@ -65,7 +68,7 @@ public class BitmapImageUtil {
* @param b the blue component
* @return the gray value
*/
- public static final int convertToGray(int r, int g, int b) {
+ public static int convertToGray(int r, int g, int b) {
return (r * 30 + g * 59 + b * 11) / 100;
}
@@ -74,7 +77,7 @@ public class BitmapImageUtil {
* @param rgb the RGB value
* @return the gray value
*/
- public static final int convertToGray(int rgb) {
+ public static int convertToGray(int rgb) {
int r = (rgb & 0xFF0000) >> 16;
int g = (rgb & 0xFF00) >> 8;
int b = rgb & 0xFF;
@@ -86,7 +89,7 @@ public class BitmapImageUtil {
* @param img the image
* @return the size of the color index or 0 if there's no color index
*/
- public static final int getColorIndexSize(RenderedImage img) {
+ public static int getColorIndexSize(RenderedImage img) {
ColorModel cm = img.getColorModel();
if (cm instanceof IndexColorModel) {
IndexColorModel icm = (IndexColorModel)cm;
@@ -101,7 +104,7 @@ public class BitmapImageUtil {
* @param img the image
* @return true if it's a grayscale image
*/
- public static final boolean isGrayscaleImage(RenderedImage img) {
+ public static boolean isGrayscaleImage(RenderedImage img) {
return (img.getColorModel().getColorSpace().getNumComponents() == 1);
}
@@ -111,7 +114,7 @@ public class BitmapImageUtil {
* @param targetDimension the new target dimensions or null if no scaling is necessary
* @return the sRGB image
*/
- public static final BufferedImage convertTosRGB(RenderedImage img,
+ public static BufferedImage convertTosRGB(RenderedImage img,
Dimension targetDimension) {
return convertAndScaleImage(img, targetDimension, BufferedImage.TYPE_INT_RGB);
}
@@ -122,7 +125,7 @@ public class BitmapImageUtil {
* @param targetDimension the new target dimensions or null if no scaling is necessary
* @return the grayscale image
*/
- public static final BufferedImage convertToGrayscale(RenderedImage img,
+ public static BufferedImage convertToGrayscale(RenderedImage img,
Dimension targetDimension) {
return convertAndScaleImage(img, targetDimension, BufferedImage.TYPE_BYTE_GRAY);
}
@@ -133,7 +136,7 @@ public class BitmapImageUtil {
* @param targetDimension the new target dimensions or null if no scaling is necessary
* @return the monochrome image
*/
- public static final BufferedImage convertToMonochrome(RenderedImage img,
+ public static BufferedImage convertToMonochrome(RenderedImage img,
Dimension targetDimension) {
return toBufferedImage(convertToMonochrome(img, targetDimension, 0.0f));
}
@@ -146,7 +149,7 @@ public class BitmapImageUtil {
* Valid values: a value between 0.0f (fastest) and 1.0f (best)
* @return the monochrome image
*/
- public static final RenderedImage convertToMonochrome(RenderedImage img,
+ public static RenderedImage convertToMonochrome(RenderedImage img,
Dimension targetDimension, float quality) {
if (!isMonochromeImage(img)) {
if (quality >= 0.5f) {
@@ -234,6 +237,7 @@ public class BitmapImageUtil {
}
}
+ /** @return the bitmap converter */
public static MonochromeBitmapConverter createDefaultMonochromeBitmapConverter() {
MonochromeBitmapConverter converter = null;
try {
diff --git a/src/java/org/apache/fop/util/bitmap/DitherUtil.java b/src/java/org/apache/fop/util/bitmap/DitherUtil.java
index c61befc9c..2fa2e9402 100644
--- a/src/java/org/apache/fop/util/bitmap/DitherUtil.java
+++ b/src/java/org/apache/fop/util/bitmap/DitherUtil.java
@@ -24,7 +24,10 @@ import java.awt.Color;
/**
* Utility methods for dithering.
*/
-public class DitherUtil {
+public final class DitherUtil {
+
+ private DitherUtil() {
+ }
/** Selects a 2x2 Bayer dither matrix (5 grayscales) */
public static final int DITHER_MATRIX_2X2 = 2;
diff --git a/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java b/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java
index 8c26bd622..41b70046c 100644
--- a/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java
+++ b/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java
@@ -29,7 +29,7 @@ import org.apache.xmlgraphics.util.Service;
/**
* Formats messages based on a template and with a set of named parameters. This is similar to
- * {@link java.util.MessageFormat} but uses named parameters and supports conditional sub-groups.
+ * {@link java.text.MessageFormat} but uses named parameters and supports conditional sub-groups.
* <p>
* Example:
* </p>
@@ -46,24 +46,27 @@ public class AdvancedMessageFormat {
/** Regex that matches "," but not "\," (escaped comma) */
static final Pattern COMMA_SEPARATOR_REGEX = Pattern.compile("(?<!\\\\),");
- private static final Map PART_FACTORIES = new java.util.HashMap();
- private static final List OBJECT_FORMATTERS = new java.util.ArrayList();
- private static final Map FUNCTIONS = new java.util.HashMap();
+ private static final Map<String, PartFactory> PART_FACTORIES
+ = new java.util.HashMap<String, PartFactory>();
+ private static final List<ObjectFormatter> OBJECT_FORMATTERS
+ = new java.util.ArrayList<ObjectFormatter>();
+ private static final Map<Object, Function> FUNCTIONS
+ = new java.util.HashMap<Object, Function>();
private CompositePart rootPart;
static {
- Iterator iter;
- iter = Service.providers(PartFactory.class, true);
+ Iterator<Object> iter;
+ iter = Service.providers(PartFactory.class);
while (iter.hasNext()) {
PartFactory factory = (PartFactory)iter.next();
PART_FACTORIES.put(factory.getFormat(), factory);
}
- iter = Service.providers(ObjectFormatter.class, true);
+ iter = Service.providers(ObjectFormatter.class);
while (iter.hasNext()) {
OBJECT_FORMATTERS.add((ObjectFormatter)iter.next());
}
- iter = Service.providers(Function.class, true);
+ iter = Service.providers(Function.class);
while (iter.hasNext()) {
Function function = (Function)iter.next();
FUNCTIONS.put(function.getName(), function);
@@ -189,7 +192,7 @@ public class AdvancedMessageFormat {
* @param params a Map of named parameters (Contents: <String, Object>)
* @return the formatted message
*/
- public String format(Map params) {
+ public String format(Map<String, Object> params) {
StringBuffer sb = new StringBuffer();
format(params, sb);
return sb.toString();
@@ -200,7 +203,7 @@ public class AdvancedMessageFormat {
* @param params a Map of named parameters (Contents: <String, Object>)
* @param target the target StringBuffer to write the formatted message to
*/
- public void format(Map params, StringBuffer target) {
+ public void format(Map<String, Object> params, StringBuffer target) {
rootPart.write(target, params);
}
@@ -215,14 +218,14 @@ public class AdvancedMessageFormat {
* @param sb the target string buffer
* @param params the parameters to work with
*/
- void write(StringBuffer sb, Map params);
+ void write(StringBuffer sb, Map<String, Object> params);
/**
* Indicates whether there is any content that is generated by this message part.
* @param params the parameters to work with
* @return true if the part has content
*/
- boolean isGenerated(Map params);
+ boolean isGenerated(Map<String, Object> params);
}
/**
@@ -277,7 +280,7 @@ public class AdvancedMessageFormat {
* @param params the message parameters
* @return the function result
*/
- Object evaluate(Map params);
+ Object evaluate(Map<String, Object> params);
/**
* Returns the name of the function.
@@ -294,11 +297,11 @@ public class AdvancedMessageFormat {
this.text = text;
}
- public void write(StringBuffer sb, Map params) {
+ public void write(StringBuffer sb, Map<String, Object> params) {
sb.append(text);
}
- public boolean isGenerated(Map params) {
+ public boolean isGenerated(Map<String, Object> params) {
return true;
}
@@ -316,7 +319,7 @@ public class AdvancedMessageFormat {
this.fieldName = fieldName;
}
- public void write(StringBuffer sb, Map params) {
+ public void write(StringBuffer sb, Map<String, Object> params) {
if (!params.containsKey(fieldName)) {
throw new IllegalArgumentException(
"Message pattern contains unsupported field name: " + fieldName);
@@ -325,7 +328,7 @@ public class AdvancedMessageFormat {
formatObject(obj, sb);
}
- public boolean isGenerated(Map params) {
+ public boolean isGenerated(Map<String, Object> params) {
Object obj = params.get(fieldName);
return obj != null;
}
@@ -349,9 +352,9 @@ public class AdvancedMessageFormat {
target.append(obj);
} else {
boolean handled = false;
- Iterator iter = OBJECT_FORMATTERS.iterator();
+ Iterator<ObjectFormatter> iter = OBJECT_FORMATTERS.iterator();
while (iter.hasNext()) {
- ObjectFormatter formatter = (ObjectFormatter)iter.next();
+ ObjectFormatter formatter = iter.next();
if (formatter.supportsObject(obj)) {
formatter.format(target, obj);
handled = true;
@@ -375,12 +378,12 @@ public class AdvancedMessageFormat {
}
}
- public void write(StringBuffer sb, Map params) {
+ public void write(StringBuffer sb, Map<String, Object> params) {
Object obj = this.function.evaluate(params);
formatObject(obj, sb);
}
- public boolean isGenerated(Map params) {
+ public boolean isGenerated(Map<String, Object> params) {
Object obj = this.function.evaluate(params);
return obj != null;
}
@@ -393,7 +396,7 @@ public class AdvancedMessageFormat {
private static class CompositePart implements Part {
- protected List parts = new java.util.ArrayList();
+ protected List<Part> parts = new java.util.ArrayList<Part>();
private boolean conditional;
private boolean hasSections = false;
@@ -401,7 +404,7 @@ public class AdvancedMessageFormat {
this.conditional = conditional;
}
- private CompositePart(List parts) {
+ private CompositePart(List<Part> parts) {
this.parts.addAll(parts);
this.conditional = true;
}
@@ -411,7 +414,7 @@ public class AdvancedMessageFormat {
throw new NullPointerException("part must not be null");
}
if (hasSections) {
- CompositePart composite = (CompositePart)this.parts.get(this.parts.size() - 1);
+ CompositePart composite = (CompositePart) this.parts.get(this.parts.size() - 1);
composite.addChild(part);
} else {
this.parts.add(part);
@@ -420,20 +423,20 @@ public class AdvancedMessageFormat {
public void newSection() {
if (!hasSections) {
- List p = this.parts;
+ List<Part> p = this.parts;
//Dropping into a different mode...
- this.parts = new java.util.ArrayList();
+ this.parts = new java.util.ArrayList<Part>();
this.parts.add(new CompositePart(p));
hasSections = true;
}
this.parts.add(new CompositePart(true));
}
- public void write(StringBuffer sb, Map params) {
+ public void write(StringBuffer sb, Map<String, Object> params) {
if (hasSections) {
- Iterator iter = this.parts.iterator();
+ Iterator<Part> iter = this.parts.iterator();
while (iter.hasNext()) {
- CompositePart part = (CompositePart)iter.next();
+ Part part = iter.next();
if (part.isGenerated(params)) {
part.write(sb, params);
break;
@@ -441,20 +444,20 @@ public class AdvancedMessageFormat {
}
} else {
if (isGenerated(params)) {
- Iterator iter = this.parts.iterator();
+ Iterator<Part> iter = this.parts.iterator();
while (iter.hasNext()) {
- Part part = (Part)iter.next();
+ Part part = iter.next();
part.write(sb, params);
}
}
}
}
- public boolean isGenerated(Map params) {
+ public boolean isGenerated(Map<String, Object> params) {
if (hasSections) {
- Iterator iter = this.parts.iterator();
+ Iterator<Part> iter = this.parts.iterator();
while (iter.hasNext()) {
- Part part = (Part)iter.next();
+ Part part = iter.next();
if (part.isGenerated(params)) {
return true;
}
@@ -462,9 +465,9 @@ public class AdvancedMessageFormat {
return false;
} else {
if (conditional) {
- Iterator iter = this.parts.iterator();
+ Iterator<Part> iter = this.parts.iterator();
while (iter.hasNext()) {
- Part part = (Part)iter.next();
+ Part part = iter.next();
if (!part.isGenerated(params)) {
return false;
}