pax_global_header 0000666 0000000 0000000 00000000064 14157706453 0014526 g ustar 00root root 0000000 0000000 52 comment=2d1241cbbc318896c870b49ac9e3c53b8cc90e1a
pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/ 0000775 0000000 0000000 00000000000 14157706453 0021500 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/.github/ 0000775 0000000 0000000 00000000000 14157706453 0023040 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/.github/workflows/ 0000775 0000000 0000000 00000000000 14157706453 0025075 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/.github/workflows/codeql-analysis.yml 0000664 0000000 0000000 00000004475 14157706453 0030722 0 ustar 00root root 0000000 0000000 # For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ master, pdfbox-3.0.0 ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, pdfbox-3.0.0 ]
schedule:
- cron: '25 20 * * 4'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/.github/workflows/maven.yml 0000664 0000000 0000000 00000001332 14157706453 0026725 0 ustar 00root root 0000000 0000000 # This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Java CI with Maven
on:
push:
branches: [ master, pdfbox-3.0.0 ]
pull_request:
branches: [ master, pdfbox-3.0.0 ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: ['8','11']
steps:
- uses: actions/checkout@v2
- name: Set up JDK ${{matrix.java}}
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: ${{matrix.java}}
- name: Maven -v
run: mvn -v
- name: Build with Maven
run: mvn -B package --file pom.xml
pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/.gitignore 0000664 0000000 0000000 00000000150 14157706453 0023464 0 ustar 00root root 0000000 0000000 target
.idea
graphics2d.iml
/parent.iml
/extended-tests/extended-tests.iml
/pdfboxgraphics2d-parent.iml
pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/.travis.yml 0000664 0000000 0000000 00000000152 14157706453 0023607 0 ustar 00root root 0000000 0000000 language: java
install: mvn install -DskipTests -Dgpg.skip
jdk:
- openjdk8
- openjdk11
- openjdk17
pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/LICENSE-2.0.txt 0000664 0000000 0000000 00000026136 14157706453 0023630 0 ustar 00root root 0000000 0000000
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed 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.
pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/README.md 0000664 0000000 0000000 00000046701 14157706453 0022767 0 ustar 00root root 0000000 0000000 [](https://travis-ci.org/rototor/pdfbox-graphics2d)
# pdfbox-graphics2d
Graphics2D Bridge for Apache PDFBox
## Intro
Using this library you can use any Graphics2D API based SVG / graph / chart library to embed those graphics as vector
drawing in a PDF. In combination with PDFBox PDFRenderer/PageDrawer you can also "rerender" PDF pages and change certain
aspects
(
e.g. [change the color mapping and perform an overfill](graphics2d/src/test/java/de/rototor/pdfbox/graphics2d/PdfRerenderTest.java))
.
The following features are supported:
- Drawing any shape using ```draw...()``` and ```fill...()``` methods from Graphics2D.
- Drawing images. The default is to always lossless compress them. You could plugin your own ```Image```
-> ```PDImageXObject``` conversion if you want to encode the images as jpeg.
- All ```BasicStroke``` attributes.
- ```Paint```:
- ```Color```. You can specify your own color mapping implementation to special map the (RGB)
colors to ```PDColor```. Beside using CMYK colors you can also use spot colors.
- ```GradientPaint```, ```LinearGradientPaint``` and ```RadialGradientPaint```. There are some restrictions:
- ```GradientPaint``` always generates acyclic gradients.
- ```TexturePaint```.
- Drawing text. By default all text is drawn as vector shapes, so no fonts are embedded. RTL languages are supported.
It's possible to use fonts, but this loses some features (especially RTL support)
and you must provide the TTF files of the fonts if the default PDF fonts are not enough.
The following features are not supported (yet):
- ```(Alpha-)Composite``` with a rule different then ```AlphaComposite.SRC_OVER```.
- ```copyArea()```. This is not possible to implement.
- ```hit()```. Why would you want to use that?
- ```setXORMode()```. Their is no blend mode in PDF which would allow to emulate this, so this is
not possible to be implemeted.
## Download
This library is available through Maven:
```xml
de.rototor.pdfboxgraphics2d0.34
```
This library targets Java 1.6 and should work with Java 1.6. But at the moment it is only tested
with Java 8 and Java 11.
## Example Usage
```java
public class PDFGraphics2DSample {
public static main(String[] argv) {
PDDocument document = new PDDocument();
PDPage page = new PDPage(PDRectangle.A4);
document.addPage(page);
/*
* Creates the Graphics and sets a size in pixel. This size is used for the BBox of the XForm.
* So everything drawn outside (0x0)-(width,height) will be clipped.
*/
PdfBoxGraphics2D pdfBoxGraphics2D = new PdfBoxGraphics2D(document, 400, 400);
/*
* Now do your drawing. By default all texts are rendered as vector shapes
*/
/* ... */
/*
* Dispose when finished
*/
pdfBoxGraphics2D.dispose();
/*
* After dispose() of the graphics object we can get the XForm.
*/
PDFormXObject xform = pdfBoxGraphics2D.getXFormObject();
/*
* Build a matrix to place the form
*/
Matrix matrix = new Matrix();
/*
* Note: As PDF coordinates start at the bottom left corner, we move up from there.
*/
matrix.translate(0, 20);
PDPageContentStream contentStream = new PDPageContentStream(document, page);
contentStream.transform(matrix);
/*
* Now finally draw the form. As we not do any scaling, the form drawn has a size of 5,5 x 5,5 inches,
* because PDF uses 72 DPI for its lengths by default. If you want to scale, skew or rotate the form you can
* of course do this. And you can also draw the form more then once. Think of the XForm as a stamper.
*/
contentStream.drawForm(xform);
contentStream.close();
document.save(new File("mysample.pdf"));
document.close();
}
}
```
See also [manual drawing](graphics2d/src/test/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2dTest.java)
and [drawing SVGs](graphics2d/src/test/java/de/rototor/pdfbox/graphics2d/RenderSVGsTest.java). The testdrivers are only
smoke tests, i.e. they don't explicit test the result, they just run and test if the their are crashes. You have to
manually compare the PDF result of the testdriver with the also generated PNG compare image.
## Rendering text using fonts vs vectors
When rendering a text in a PDF file you can choose two methods:
- Render the text using a font as text.
- Render the text using TextLayout as vector graphics.
Rendering a text using a font is the normal and preferred way to display a text:
- The text can be copied and is searchable.
- Usually it takes less space then when using vector shapes.
- When printing in PrePress (Digital / Offset Print) the RIP usually handles text special to ensure the best possible
reading experience. E.g. RGB Black is usually mapped to a black with some cyan. This gives a "deeper" black,
especially if you have a large black area. But if you use a RGB black to render text it is usually mapped to pure
black to avoid any printing registration mismatches, which would be very bad for reading the text.
- Note: When rendering a text using a font you should always embed the needed subset of the font into the PDF. Otherwise
not every (=most) PDF viewers will be able to display the text correctly, if they don't have the font or have a
different version of the font, which can happen across different OS and OS versions.
- Note: Not all PDF viewer can handle all fonts correctly. E.g. PDFBox 1.8 was not able to handle fonts right. But
nowadays all PDF viewers should be able to handle fonts fine.
- Note: ```TextAttribute.LIGATURES``` is currently not supported.
- Note: ```TextAttribute.BACKGROUND``` is currently not supported.
- Note: There is no Bidi support at the moment. See the [problems](https://issues.apache.org/jira/browse/PDFBOX-3550)
PDFBox has with rendering RTL languages at the moment.
On the other site rendering a text using vector shapes has the following properties:
- The text is always displayed the same. They will be no differences between the PDF viewers.
- The text is not searchable and can not be copied.
- Note: Vector shapes take more space than a embedded font.
- Note: You may want to manually alter the color mapping to e.g. ensure a black text is printed using pure CMYK black.
If you do not plan to print the PDF in offset or digital print you can ignore that. This will make no difference for
your normal desktop printer.
- Note: When using Apache Batik to draw SVGs the text will always be drawn as vector shape. Batik always converts texts
to vector shapes first and then applies the transforms on it (if there are any). So PdfBoxGraphics2D never even gets a
chance to draw the text using a PDF font. In theory, this could be solved by installing an appropriate text painter on
the Batik bridge context. But no one has created such a text painter yet.
If you want to get a 1:1 mapping of your ```Graphics2D``` drawing in the PDF you should use the vector mode. If you want
to have the text searchable and only use LTR languanges (i.e. latin-based)
you may try the text mode. For this mode to work you need the font files (.ttf / .ttc) of the fonts you want to use and
must register it with this library. Using the normal Java font API it is not possible to access the underlying font
file. So a manual mapping of Font to PDFont is needed.
### Example how to use the font mapping
The font mapping is done using the ```PdfBoxGraphics2DFontTextDrawer``` class. There you register the fonts you have. By
default the mapping tries to only use fonts when all features used by the drawn text are supported. If your text uses a
features which is not supported (e.g. RTL text) then it falls back to using vectorized text.
If you always want to force the use of fonts you can use the class ```PdfBoxGraphics2DFontTextForcedDrawer```. But this
is unsafe and not recommend, because if some text can not be rendered using the given fonts it will not be drawn at all
(e.g. if a font misses a needed glyph).
If you want to use the default PDF fonts as much as possible to have no embedded fonts you can use the class
```PdfBoxGraphics2DFontTextDrawerDefaultFonts```. This class will always use a default PDF font, but you can also
register additional fonts.
```java
public class PDFGraphics2DSample {
public static main(String[] argv) {
/*
* Document creation and init as in the example above
*/
// ...
/*
* Register your fonts
*/
PdfBoxGraphics2DFontTextDrawer fontTextDrawer = new PdfBoxGraphics2DFontTextDrawer();
try {
/*
* Register the font using a file
*/
fontTextDrawer.registerFont(new File("..path..to../DejaVuSerifCondensed.ttf"));
/*
* Or register the font using a stream
*/
fontTextDrawer.registerFont(
PDFGraphics2DSample.class.getResourceAsStream("DejaVuSerifCondensed.ttf"));
/*
* You already have a PDFont in the document? Then make it known to the library.
*/
fontTextDrawer.registerFont("My Custom Font", pdMyCustomFont);
/*
* Create the graphics
*/
PdfBoxGraphics2D pdfBoxGraphics2D = new PdfBoxGraphics2D(document, 400, 400);
/*
* Set the fontTextDrawer on the Graphics2D. Note:
* You can and should reuse the PdfBoxGraphics2DFontTextDrawer
* within the same PDDocument if you use multiple PdfBoxGraphics2D.
*/
pdfBoxGraphics2D.setFontTextDrawer(fontTextDrawer);
/* Do you're drawing */
/*
* Dispose when finished
*/
pdfBoxGraphics2D.dispose();
/*
* Use the result as above
*/
// ...
} finally {
/*
* If you register a font using a stream then a tempfile
* will be created in the background.
* Close the PdfBoxGraphics2DFontTextDrawer to free any
* tempfiles created for the fonts.
*/
fontTextDrawer.close();
}
}
}
```
You can also complete customize the font mapping if you derive from ```PdfBoxGraphics2DFontTextDrawer```:
```java
class MyPdfBoxGraphics2DFontTextDrawer extends PdfBoxGraphics2DFontTextDrawer {
@Override
protected PDFont mapFont(Font font, IFontTextDrawerEnv env)
throws IOException, FontFormatException {
// Using the font, especially the font.getFontName() or font.getFamily() to determine which
// font to use... return null if the font can not be mapped. You can also call registerFont() here.
// Default lookup in the registered fonts
return super.mapFont(font, env);
}
}
```
This allows you to load the fonts on demand.
## Compression
By default the content stream data is compressed using the zlib default level 6. If you want to get the maximum
compression out of PDFBox you should set a system property before generating your PDF:
```java
System.setProperty(Filter.SYSPROP_DEFLATELEVEL,"9");
```
## Creating PDF reports
If you want to create complex PDF reports with text and graphs mixed it is recommend to not use PDFBox and this library
directly, as both are very low level. Instead you should use
[OpenHtmlToPdf](https://github.com/danfickle/openhtmltopdf). OpenHtmlToPdf allows you to build your reports using HTML (
which you can generate with any template engine you like, e.g. Apache FreeMarker) and place custom graphs
(which are draw using Graphics2D using this library) with <object> HTML tags.
## Changes
Version 0.34:
- Per default specify the rendering hint ```RenderingHints.KEY_FRACTIONALMETRICS=RenderingHints.VALUE_FRACTIONALMETRICS_ON```.
We always render into a vector space, so we don't have to round to ints while drawing text. Thanks to @paatero for bringing this up ([#32](https://github.com/rototor/pdfbox-graphics2d/issues/32)).
- Upgrade to PDFBox 2.0.25
- It is not allowed to make state changes after defining a path and before clipping / drawing, at least acording to the PDF specification
[PDFBOX-5322](https://issues.apache.org/jira/browse/PDFBOX-5322). Fixed the ordering here.
Version 0.33:
- Don't crash when drawString() is called with an empty string [#31](https://github.com/rototor/pdfbox-graphics2d/issues/31).
Thanks @Kischloren for the report.
Version 0.32:
- It is now possible to draw within a marked content sequence. PdfBoxGraphics2D got a new
drawInMarkedContentSequence() method for this. This is usefull if you want to mark some parts of a drawing so that you
can later do some special processing on it. Or if you simply want to provide
accesibility information for the content you draw. See also e.g. https://www.w3.org/TR/WCAG20-TECHS/PDF21.html or the
section 14.8.4.3.3 in the PDF specification.
- Upgrade to PDFBox 2.0.24
Version 0.31:
- Support for colors with overprint.
- New PdfBoxGraphics2DColor class to allow using any kind of color. E.g. PDSeperation based colors.
Version 0.30:
- Clip invalid miter limit values [#29](https://github.com/rototor/pdfbox-graphics2d/issues/29). Thanks to @kiwiwings
for reporting this.
- Added a new module for extended-tests. This module will contain tests with 3rdparty library which by themself depend
on pdfbox-graphics2d. It also now contains a new class DebugCodeGeneratingGraphics2d
(by @kiwiwings) which helps creating isolated testcases.
- Upgrade to PDFBox 2.0.22
Version 0.29:
- Fix a bug where the AlphaComposite alpha value would be mixed with a color alpha value when drawing images. When
setting a transparent color this had resulted in a invisible image. Thanks to @kiwiwings for reporting this.
- Initial support for ```TextAttribute.UNDERLINE``` and ```Textattribute.STRIKETHROUGH``` when using a font to render a
text.
Version 0.28:
- Fix handling of AttributedString (off-by-one error). Thanks for @kiwiwings for pointing out the error and providing a
fix [#27](https://github.com/rototor/pdfbox-graphics2d/issues/27).
- Upgrade to PDFBox 2.0.21
- Respect that default fonts may not allow to be embedded. (PDFBox 2.0.21 now respects the flags within a TTF font, so
we also must do this)
- When painting an image with an AlphaComposite the alpha is now respected correctly.
Version 0.27:
- Internal API breakage to implement getFontMetrics().stringWidth() correctly in the case a PDFont is used to draw the
text [#16](https://github.com/rototor/pdfbox-graphics2d/issues/16). Thanks to @megri for reporting this problem.
- Reverted back to PDFBox 2.0.19 because of rendering
issues [PDFBOX-4886](https://issues.apache.org/jira/browse/PDFBOX-4886).
Version 0.26:
- Added a [CMYK color mapper](graphics2d/src/main/java/de/rototor/pdfbox/graphics2d/RGBtoCMYKColorMapper.java), which
converts the paint colors to CMYK using an ICC Profile. Thanks to @larrylynn-wf for providing this
feature [#22](https://github.com/rototor/pdfbox-graphics2d/issues/22).
- Upgrade to PDFBox 2.0.20
- Initial support for [Apache PDFBox TilingPaint](https://github.com/rototor/pdfbox-graphics2d/pull/25). Thanks to
@p1xel. Currently this is not clean and also not correct in many cases.
Version 0.25:
- Upgrade to PDFBox 2.0.17
- Correctly handle GradientPaint fractions.
- Correctly handle SVG LinearGradientPaint's in ObjectBoundingBox
mode [#19](https://github.com/rototor/pdfbox-graphics2d/issues/19). Thanks to @larrylynn-wf for the report and the
idea how to fix it.
- Internal API breakage to support non quadratic SVG gradients
correctly [#19](https://github.com/rototor/pdfbox-graphics2d/issues/19).
Version 0.24:
- Upgrade to PDFBox 2.0.16
Version 0.23:
- Correctly handle even odd winding rules when clipping and filling shapes.
Version 0.22:
- Upgrade the PDFBox version to 2.0.15
Version 0.21:
- Provide the current XORMode color in the IPaintEnv. And document that XORMode is not working as it's not possible to
emulate. Thanks @gredler for pointing this out [#14](https://github.com/rototor/pdfbox-graphics2d/issues/14). But you
can do whatever you want with that information in your IPdfBoxGraphics2DPaintAplier subclass.
- Upgrade the PDFBox version to 2.0.14
- Handle PDFBox ShadingPaint's.
Version 0.20:
- Handle null transforms in drawImage() correctly. I.e. dont throw a NullPointerException, just ignore the not existing
transform.
- Cache the different environments for the mapper/drawer/applier. This is a minor memory saving.
Version 0.19:
- You can now influence the shape fill/draw operations by setting a custom IPdfBoxGraphics2DDrawControl. This allows to
do different things like e.g. draw an overfill for shapes (i.e. make shapes have a additional border). This can be
useful if you need to preprocess a PDF for pre-press.
Version 0.18:
- setPaint(null) will cause the following fillXXX() and drawXXX() operations to be ignored. This allows in combination
with PDFRenderer/PageDrawer to extract parts of a PDF page. E.g. you can draw only certain seperation colors into the
resulting PDF if you filter the paints in PageDrawer.getPaint() and extract a seperation color from a PDF in that way.
- New class PdfBoxGraphics2DCMYKColor() which derives from java.awt.Color to be able to specify a CMYK color when
painting.
- The default PdfBoxGraphics2DColorMapper now also supports mapping of "legacy" old iText 2 CMYKColor's.
Version 0.17:
- Upgrade the PDFBox version to 2.0.12
Versoin 0.16:
- Added new method ```disposeDanglingChildGraphics()``` to cleanup all dangling child graphics. This allows to use this
graphics adapter with old legacy code which does not correctly call ```dispose()``` on the graphics it used.
Version 0.15:
- Upgrade the PDFBox version to 2.0.11
Version 0.14:
- Don't write invalid path commands into the stream, as this will break rendering in Acrobat Reader. Thanks
@FabioVassallo [#12](https://github.com/rototor/pdfbox-graphics2d/pull/12)
Version 0.13:
- Ugraded the PDFBox version to 2.0.9
Version 0.12:
- Don't share resources between XForm's, as Acrobat Reader does not like that.
Version 0.11:
- Support Batik SVG PatternPaint. Thanks @vipcxj
for [pointing this out and providing a testfile](https://github.com/danfickle/openhtmltopdf/issues/170#issuecomment-362294830)
.
- Compress embedded image ICC Profile Data
Version 0.10:
- Don't export the same extended graphics state over and over again. Same for
shadings. [#8](https://github.com/rototor/pdfbox-graphics2d/issues/8)
Version 0.9:
- Compress the content stream generated for the XForm.
- When drawing the same image multiple times, it is only encoded once now.
Version 0.8:
- Implemented ```PdfBoxGraphics2DFontTextDrawerDefaultFonts``` to allow preferring default PDF fonts over vectorized
text [#5](https://github.com/rototor/pdfbox-graphics2d/issues/5).
Version 0.7:
- Bugfixes on the font based text support. Now also gradients can be used to paint text.
Version 0.6:
- Implemented basic support for using fonts to render texts.
Version 0.5:
- Fixed ```getClip()``` and ```clip(Shape)``` handling. Both did not correctly handle transforms. This bug was exposed
by Batik 1.9 and found by @ketanmpandya. Thanks
@ketanmpandya [#2](https://github.com/rototor/pdfbox-graphics2d/pull/2),
OpenHtmlToPdf [#99](https://github.com/danfickle/openhtmltopdf/issues/99)
Version 0.4:
- Initial support for basic ```AlphaComposite```. Thanks
@FabioVassallo [#1](https://github.com/rototor/pdfbox-graphics2d/pull/1)
- When drawing a shape with a zero or negative size don't use ```PDShadings```, as they won't work.Thanks
@FabioVassallo [#1](https://github.com/rototor/pdfbox-graphics2d/pull/1)
Version 0.3:
- Fix for a NPE when calling ```setClip()``` with null.
- Upgrade to PDFBox 2.0.5, replacing the usage of ```appendRawCommands()```
with ```setMiterLimit()```.
Version 0.2:
- The paint applier (Mapping of ```java.awt.Paint``` to PDF) can be customized, so you can map special paints if needed.
- Support for ```TexturePaint```
## Licence
Licenced using the Apache Licence 2.0.
pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/ 0000775 0000000 0000000 00000000000 14157706453 0024440 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/pom.xml 0000664 0000000 0000000 00000002747 14157706453 0025767 0 ustar 00root root 0000000 0000000
4.0.0PDFBox-Graphics2d - Extended TestsGraphics2D Bridge for Apache PDFBox - Extended Tests Moduleextended-testsjarde.rototor.pdfboxpdfboxgraphics2d-parent0.34de.rototor.pdfboxgraphics2d0.34org.apache.poipoi${poi.version}org.apache.poipoi-ooxml${poi.version}jakarta.xml.bindjakarta.xml.bind-api2.3.2org.glassfish.jaxbjaxb-runtime2.3.2UTF-84.1.2
pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/ 0000775 0000000 0000000 00000000000 14157706453 0025227 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/main/ 0000775 0000000 0000000 00000000000 14157706453 0026153 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/main/java/ 0000775 0000000 0000000 00000000000 14157706453 0027074 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/main/java/.keep 0000664 0000000 0000000 00000000000 14157706453 0030007 0 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/main/java/de/ 0000775 0000000 0000000 00000000000 14157706453 0027464 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/main/java/de/rototor/ 0000775 0000000 0000000 00000000000 14157706453 0031174 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/main/java/de/rototor/pdfbox/ 0000775 0000000 0000000 00000000000 14157706453 0032456 5 ustar 00root root 0000000 0000000 graphics2d/ 0000775 0000000 0000000 00000000000 14157706453 0034425 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/main/java/de/rototor/pdfbox extendedtests/ 0000775 0000000 0000000 00000000000 14157706453 0037310 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/main/java/de/rototor/pdfbox/graphics2d DebugCodeGeneratingGraphics2d.java 0000664 0000000 0000000 00000115236 14157706453 0045717 0 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/main/java/de/rototor/pdfbox/graphics2d/extendedtests /* ====================================================================
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.
==================================================================== */
package de.rototor.pdfbox.graphics2d.extendedtests;
import java.awt.*;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.font.TextAttribute;
import java.awt.geom.AffineTransform;
import java.awt.geom.Path2D;
import java.awt.geom.PathIterator;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ImageObserver;
import java.awt.image.RenderedImage;
import java.awt.image.renderable.RenderableImage;
import java.io.PrintStream;
import java.text.AttributedCharacterIterator;
import java.text.AttributedCharacterIterator.Attribute;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
public class DebugCodeGeneratingGraphics2d extends Graphics2D
{
private BufferedImage bufimg;
private final Graphics2D g2D;
private final PrintStream log;
public DebugCodeGeneratingGraphics2d()
{
this(System.out);
}
public DebugCodeGeneratingGraphics2d(PrintStream log)
{
bufimg = new BufferedImage(1000, 1000, 2);
g2D = (Graphics2D) bufimg.getGraphics();
this.log = log;
}
public DebugCodeGeneratingGraphics2d(PrintStream log, Graphics2D g2D)
{
this.g2D = g2D;
this.log = log;
}
public void addRenderingHints(Map, ?> hints)
{
String l = "addRenderingHinds(Map):" + "\n hints = " + hints;
log.println(l);
for (Map.Entry, ?> entry : hints.entrySet())
{
System.out.println(" map.put(" + entry.getKey() + ", " + entry.getValue());
}
g2D.addRenderingHints(hints);
}
public void clip(Shape s)
{
String l = "clip(Shape):" + "\n s = " + s;
log.println(l);
g2D.clip(s);
}
private void pathToString(StringBuilder sb, Path2D p)
{
sb.append("Path2D p = new Path2D.Double(" + p.getWindingRule() + ");\n");
double[] coords = new double[6];
for (PathIterator pi = p.getPathIterator(null); !pi.isDone(); pi.next())
{
// The type will be SEG_LINETO, SEG_MOVETO, or SEG_CLOSE
// Because the Area is composed of straight lines
switch (pi.currentSegment(coords))
{
case PathIterator.SEG_MOVETO:
sb.append("p.moveTo(" + coords[0] + "," + coords[1] + ");\n");
break;
case PathIterator.SEG_LINETO:
sb.append("p.lineTo(" + coords[0] + "," + coords[1] + ");\n");
break;
case PathIterator.SEG_QUADTO:
sb.append("p.quadTo(" + coords[0] + "," + coords[1] + "," + coords[2] + ","
+ coords[3] + ");\n");
break;
case PathIterator.SEG_CUBICTO:
sb.append("p.curveTo(" + coords[0] + "," + coords[1] + "," + coords[2] + ","
+ coords[3] + "," + coords[4] + "," + coords[5] + ");\n");
break;
case PathIterator.SEG_CLOSE:
sb.append("p.closePath();\n");
break;
}
}
}
public void draw(Shape s)
{
if (s instanceof Path2D)
{
StringBuilder sb = new StringBuilder();
pathToString(sb, (Path2D) s);
sb.append("g.draw(p);");
log.println(sb.toString());
}
else
{
log.println("g.draw(" + s + ")");
}
g2D.draw(s);
}
public void drawGlyphVector(GlyphVector g, float x, float y)
{
String l = "drawGlyphVector(GlyphVector, float, float):" + "\n g = " + g + "\n x = " + x
+ "\n y = " + y;
log.println(l);
g2D.drawGlyphVector(g, x, y);
}
public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
{
String l = "drawImage(BufferedImage, BufferedImageOp, x, y):" + "\n img = " + img
+ "\n op = " + op + "\n x = " + x + "\n y = " + y;
log.println(l);
g2D.drawImage(img, op, x, y);
}
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
{
String l = "drawImage(Image,AfflineTransform,ImageObserver):" + "\n img = " + img
+ "\n xform = " + xform + "\n obs = " + obs;
log.println(l);
return g2D.drawImage(img, xform, obs);
}
public void drawRenderableImage(RenderableImage img, AffineTransform xform)
{
String l = "drawRenderableImage(RenderableImage, AfflineTransform):" + "\n img = " + img
+ "\n xform = " + xform;
log.println(l);
g2D.drawRenderableImage(img, xform);
}
public void drawRenderedImage(RenderedImage img, AffineTransform xform)
{
String l = "drawRenderedImage(RenderedImage, AffineTransform):" + "\n img = " + img
+ "\n xform = " + xform;
log.println(l);
g2D.drawRenderedImage(img, xform);
}
public void drawString(String s, float x, float y)
{
String l = "drawString(s,x,y):" + "\n s = " + s + "\n x = " + x + "\n y = " + y;
log.println(l);
g2D.drawString(s, x, y);
}
public void fill(Shape s)
{
if (s instanceof Path2D)
{
StringBuilder sb = new StringBuilder();
pathToString(sb, (Path2D) s);
sb.append("g.fill(p);");
log.println(sb.toString());
}
else
{
log.println("g.fill(" + s + ")");
}
g2D.fill(s);
}
public Color getBackground()
{
log.println("getBackground():");
return g2D.getBackground();
}
public Composite getComposite()
{
log.println("getComposite():");
return g2D.getComposite();
}
public GraphicsConfiguration getDeviceConfiguration()
{
log.println("getDeviceConfiguration():");
return g2D.getDeviceConfiguration();
}
public FontRenderContext getFontRenderContext()
{
log.println("getFontRenderContext():");
return g2D.getFontRenderContext();
}
public Paint getPaint()
{
log.println("getPaint():");
return g2D.getPaint();
}
public Object getRenderingHint(RenderingHints.Key hintKey)
{
log.println("getRenderingHint(\"" + hintKey + "\")");
return g2D.getRenderingHint(hintKey);
}
public RenderingHints getRenderingHints()
{
log.println("getRenderingHints():");
return g2D.getRenderingHints();
}
public Stroke getStroke()
{
log.println("getStroke():");
return g2D.getStroke();
}
public AffineTransform getTransform()
{
log.println("getTransform():");
return g2D.getTransform();
}
public boolean hit(Rectangle rect, Shape s, boolean onStroke)
{
String l = "hit(Rectangle, Shape, onStroke):" + "\n rect = " + rect + "\n s = " + s
+ "\n onStroke = " + onStroke;
log.println(l);
return g2D.hit(rect, s, onStroke);
}
public void rotate(double theta)
{
String l = "rotate(theta):" + "\n theta = " + theta;
log.println(l);
g2D.rotate(theta);
}
public void rotate(double theta, double x, double y)
{
String l = "rotate(double,double,double):" + "\n theta = " + theta + "\n x = " + x
+ "\n y = " + y;
log.println(l);
g2D.rotate(theta, x, y);
}
public void scale(double sx, double sy)
{
log.println("g.scale(" + sx + "," + sy + ");");
g2D.scale(sx, sy);
}
public void setBackground(Color color)
{
log.println(String.format(Locale.ROOT, "setBackground(new Color(0x%08X))", color.getRGB()));
g2D.setBackground(color);
}
private static final String[] COMPOSITE_RULES = { "CLEAR", "SRC", "SRC_OVER", "DST_OVER",
"SRC_IN", "DST_IN", "SRC_OUT", "DST_OUT", "DST", "SRC_ATOP", "DST_ATOP", "XOR" };
public void setComposite(Composite comp)
{
String l = "g.setComposite(";
if (comp instanceof AlphaComposite)
{
AlphaComposite ac = (AlphaComposite) comp;
l += "AlphaComposite.getInstance(AlphaComposite." + COMPOSITE_RULES[Math.max(0,
Math.min(COMPOSITE_RULES.length - 1, ac.getRule()))] + ", " + ac.getAlpha()
+ "f));";
}
else
{
l += comp.toString() + ");";
}
log.println(l);
g2D.setComposite(comp);
}
public void setPaint(Paint paint)
{
String l = "g.setPaint(";
if (paint instanceof Color)
{
l += String.format(Locale.ROOT, "new Color(0x%08X));", ((Color) paint).getRGB());
}
else
{
l += paint.toString() + ");";
}
log.println(l);
g2D.setPaint(paint);
}
public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
{
log.println("g.setRenderingHint(" + mapHint(hintKey) + ", " + mapHint(hintValue) + ");");
g2D.setRenderingHint(hintKey, hintValue);
}
private static String mapHint(Object hint)
{
if (hint == null)
{
return "null";
}
if (hint instanceof AffineTransform)
{
return mapTransform((AffineTransform) hint);
}
for (int i = 0; i < HINTS.length; i += 2)
{
if (hint == HINTS[i])
{
return (String) HINTS[i + 1];
}
}
return "\"" + hint.toString() + "\"";
}
public void setRenderingHints(Map, ?> hints)
{
String l = "setRenderingHints(Map):" + "\n hints = " + hints;
log.println(l);
g2D.setRenderingHints(hints);
}
public void setStroke(Stroke s)
{
String l;
if (s instanceof BasicStroke)
{
BasicStroke bs = (BasicStroke) s;
String cap = new String[] { "BUTT", "ROUND", "SQUARE" }[bs.getEndCap()];
String join = new String[] { "MITER", "ROUND", "BEVEL" }[bs.getLineJoin()];
l = "g.setStroke(new BasicStroke(" + bs.getLineWidth() + "f, BasicStroke.CAP_" + cap
+ ", BasicStroke.JOIN_" + join + ", " + bs.getMiterLimit() + "f, "
+ Arrays.toString(bs.getDashArray()) + ", " + bs.getDashPhase() + "f));";
}
else
{
l = "g.setStroke(" + s + ");";
}
log.println(l);
g2D.setStroke(s);
}
private static String mapTransform(AffineTransform tx)
{
return tx.isIdentity() ? "new AffineTransform()" :
"new AffineTransform(" + tx.getScaleX() + "f," + tx.getShearY() + "f,"
+ tx.getShearX() + "f," + tx.getScaleY() + "f," + tx.getTranslateX() + "f,"
+ tx.getTranslateY() + "f)";
}
public void setTransform(AffineTransform Tx)
{
log.println("g.setTransform(" + mapTransform(Tx) + ");");
g2D.setTransform(Tx);
}
public void shear(double shx, double shy)
{
String l = "shear(shx, dhy):" + "\n shx = " + shx + "\n shy = " + shy;
log.println(l);
g2D.shear(shx, shy);
}
public void transform(AffineTransform Tx)
{
String l = "transform(AffineTransform):" + "\n Tx = " + Tx;
log.println(l);
g2D.transform(Tx);
}
public void translate(double tx, double ty)
{
String l = "translate(double, double):" + "\n tx = " + tx + "\n ty = " + ty;
log.println(l);
g2D.translate(tx, ty);
}
public void clearRect(int x, int y, int width, int height)
{
String l = "clearRect(int,int,int,int):" + "\n x = " + x + "\n y = " + y + "\n width = "
+ width + "\n height = " + height;
log.println(l);
g2D.clearRect(x, y, width, height);
}
public void clipRect(int x, int y, int width, int height)
{
String l =
"clipRect(int, int, int, int):" + "\n x = " + x + "\n y = " + y + "\n width = "
+ width + "height = " + height;
log.println(l);
g2D.clipRect(x, y, width, height);
}
public void copyArea(int x, int y, int width, int height, int dx, int dy)
{
String l = "copyArea(int,int,int,int):" + "\n x = " + x + "\n y = " + y + "\n width = "
+ width + "\n height = " + height;
log.println(l);
g2D.copyArea(x, y, width, height, dx, dy);
}
public Graphics create()
{
log.println("create():");
return g2D.create();
}
public Graphics create(int x, int y, int width, int height)
{
String l = "create(int,int,int,int):" + "\n x = " + x + "\n y = " + y + "\n width = "
+ width + "\n height = " + height;
log.println(l);
return g2D.create(x, y, width, height);
}
public BufferedImage getDebugImage() {
return bufimg;
}
public void dispose()
{
log.println("dispose():");
g2D.dispose();
}
public void draw3DRect(int x, int y, int width, int height, boolean raised)
{
String l = "draw3DRect(int,int,int,int,boolean):" + "\n x = " + x + "\n y = " + y
+ "\n width = " + width + "\n height = " + height + "\n raised = " + raised;
log.println(l);
g2D.draw3DRect(x, y, width, height, raised);
}
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
{
String l = "drawArc(int,int,int,int,int,int):" + "\n x = " + x + "\n y = " + y
+ "\n width = " + width + "\n height = " + height + "\n startAngle = "
+ startAngle + "\n arcAngle = " + arcAngle;
log.println(l);
g2D.drawArc(x, y, width, height, startAngle, arcAngle);
}
public void drawBytes(byte[] data, int offset, int length, int x, int y)
{
String l = "drawBytes(byte[],int,int,int,int):" + "\n data = " + Arrays.toString(data)
+ "\n offset = " + offset + "\n length = " + length + "\n x = " + x + "\n y = "
+ y;
log.println(l);
g2D.drawBytes(data, offset, length, x, y);
}
public void drawChars(char[] data, int offset, int length, int x, int y)
{
String l = "drawChars(data,int,int,int,int):" + "\n data = " + Arrays.toString(data)
+ "\n offset = " + offset + "\n length = " + length + "\n x = " + x + "\n y = "
+ y;
log.println(l);
g2D.drawChars(data, offset, length, x, y);
}
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
int sx2, int sy2, ImageObserver observer)
{
String l = "drawImage(Image,int,int,int,int,int,int,int,int,ImageObserver):" + "\n img = "
+ img + "\n dx1 = " + dx1 + "\n dy1 = " + dy1 + "\n dx2 = " + dx2 + "\n dy2 = "
+ dy2 + "\n sx1 = " + sx1 + "\n sy1 = " + sy1 + "\n sx2 = " + sx2 + "\n sy2 = "
+ sy2 + "\n observer = " + observer;
log.println(l);
return g2D.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer);
}
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
int sx2, int sy2, Color bgcolor, ImageObserver observer)
{
String l = "drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver):"
+ "\n img = " + img + "\n dx1 = " + dx1 + "\n dy1 = " + dy1 + "\n dx2 = " + dx2
+ "\n dy2 = " + dy2 + "\n sx1 = " + sx1 + "\n sy1 = " + sy1 + "\n sx2 = " + sx2
+ "\n sy2 = " + sy2 + "\n bgcolor = " + bgcolor + "\n observer = " + observer;
log.println(l);
return g2D.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer);
}
public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
{
String l = "drawImage(Image,int,int,Color,ImageObserver):" + "\n img = " + img + "\n x = "
+ x + "\n y = " + y + "\n bgcolor = " + bgcolor + "\n observer = " + observer;
log.println(l);
return g2D.drawImage(img, x, y, bgcolor, observer);
}
public boolean drawImage(Image img, int x, int y, ImageObserver observer)
{
String l = "drawImage(Image,int,int,observer):" + "\n img = " + img + "\n x = " + x
+ "\n y = " + y + "\n observer = " + observer;
log.println(l);
return g2D.drawImage(img, x, y, observer);
}
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor,
ImageObserver observer)
{
String l = "drawImage(Image,int,int,int,int,Color,ImageObserver):" + "\n img = " + img
+ "\n x = " + x + "\n y = " + y + "\n width = " + width + "\n height = "
+ height + "\n bgcolor = " + bgcolor + "\n observer = " + observer;
log.println(l);
return g2D.drawImage(img, x, y, width, height, bgcolor, observer);
}
public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
{
String l =
"drawImage(Image,int,int,width,height,observer):" + "\n img = " + img + "\n x = "
+ x + "\n y = " + y + "\n width = " + width + "\n height = " + height
+ "\n observer = " + observer;
log.println(l);
return g2D.drawImage(img, x, y, width, height, observer);
}
public void drawLine(int x1, int y1, int x2, int y2)
{
String l = "drawLine(int,int,int,int):" + "\n x1 = " + x1 + "\n y1 = " + y1 + "\n x2 = "
+ x2 + "\n y2 = " + y2;
log.println(l);
g2D.drawLine(x1, y1, x2, y2);
}
public void drawOval(int x, int y, int width, int height)
{
String l = "drawOval(int,int,int,int):" + "\n x = " + x + "\n y = " + y + "\n width = "
+ width + "\n height = " + height;
log.println(l);
g2D.drawOval(x, y, width, height);
}
public void drawPolygon(Polygon p)
{
String l = "drawPolygon(Polygon):" + "\n p = " + p;
log.println(l);
g2D.drawPolygon(p);
}
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
{
String l = "drawPolygon(int[],int[],int):" + "\n xPoints = " + Arrays.toString(xPoints)
+ "\n yPoints = " + Arrays.toString(yPoints) + "\n nPoints = " + nPoints;
log.println(l);
g2D.drawPolygon(xPoints, yPoints, nPoints);
}
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
{
String l = "drawPolyline(int[],int[],int):" + "\n xPoints = " + Arrays.toString(xPoints)
+ "\n yPoints = " + Arrays.toString(yPoints) + "\n nPoints = " + nPoints;
log.println(l);
g2D.drawPolyline(xPoints, yPoints, nPoints);
}
public void drawRect(int x, int y, int width, int height)
{
String l = "drawRect(int,int,int,int):" + "\n x = " + x + "\n y = " + y + "\n width = "
+ width + "\n height = " + height;
log.println(l);
g2D.drawRect(x, y, width, height);
}
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
{
String l = "drawRoundRect(int,int,int,int,int,int):" + "\n x = " + x + "\n y = " + y
+ "\n width = " + width + "\n height = " + height + "\n arcWidth = " + arcWidth
+ "\n arcHeight = " + arcHeight;
log.println(l);
g2D.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
}
private static String mapAttribute(Object attr)
{
if (attr == null)
{
return "null";
}
if (attr instanceof Font)
{
Font f = (Font) attr;
final String[] STYLE = { "Font.PLAIN", "Font.BOLD", "Font.ITALIC",
"Font.BOLD | Font.ITALIC" };
return "new Font(\"" + f.getFamily(Locale.ROOT) + "\"," + STYLE[f.getStyle()] + ","
+ f.getSize() + ")";
}
if (attr instanceof Color)
{
return String.format(Locale.ROOT, "new Color(0x%08X)", ((Color) attr).getRGB());
}
for (int i = 0; i < ATTRS.length; i += 2)
{
if (attr == ATTRS[i])
{
return (String) ATTRS[i + 1];
}
}
return "\"" + attr.toString() + "\"";
}
public void drawString(AttributedCharacterIterator iterator, float x, float y)
{
final int startIdx = iterator.getIndex();
final Map> attMap = new HashMap>();
StringBuilder sb = new StringBuilder();
for (char ch = iterator.current();
ch != AttributedCharacterIterator.DONE; ch = iterator.next())
{
sb.append(ch);
for (Map.Entry e : iterator.getAttributes().entrySet())
{
Attribute k = e.getKey();
Object v = e.getValue();
Map positionMap = attMap.get(k);
if (positionMap == null)
{
positionMap = new LinkedHashMap();
attMap.put(k, positionMap);
}
positionMap.put(iterator.getIndex(), v);
}
}
String l = "AttributedString as = new AttributedString(\"" + sb + "\");\n";
sb.setLength(0);
sb.append(l);
for (Map.Entry> me : attMap.entrySet())
{
int startPos = -2, lastPos = -2;
Object lastObj = null;
for (Map.Entry mo : me.getValue().entrySet())
{
int pos = mo.getKey();
Object obj = mo.getValue();
if (lastPos < pos - 1 || obj != lastObj)
{
if (startPos >= 0)
{
Attribute at = me.getKey();
sb.append(
"as.addAttribute(" + mapAttribute(me.getKey()) + "," + mapAttribute(
lastObj) + "," + startPos + "," + (lastPos + 1) + ");\n");
}
startPos = pos;
}
lastPos = pos;
lastObj = obj;
}
if (lastObj != null)
{
sb.append(
"as.addAttribute(" + mapAttribute(me.getKey()) + "," + mapAttribute(lastObj)
+ "," + startPos + "," + (lastPos + 1) + ");\n");
}
}
sb.append("g.drawString(as.getIterator()," + x + "f," + y + "f);");
log.println(sb.toString());
iterator.setIndex(startIdx);
g2D.drawString(iterator, x, y);
}
public void drawString(AttributedCharacterIterator iterator, int x, int y)
{
drawString(iterator, (float) x, (float) y);
}
public void drawString(String str, int x, int y)
{
String l =
"drawString(str,int,int):" + "\n str = " + str + "\n x = " + x + "\n y = " + y;
log.println(l);
g2D.drawString(str, x, y);
}
public void fill3DRect(int x, int y, int width, int height, boolean raised)
{
String l = "fill3DRect(int,int,int,int,boolean):" + "\n x = " + x + "\n y = " + y
+ "\n width = " + width + "\n height = " + height + "\n raised = " + raised;
log.println(l);
g2D.fill3DRect(x, y, width, height, raised);
}
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
{
String l = "fillArc(int,int,int,int,int,int):" + "\n x = " + x + "\n y = " + y
+ "\n width = " + width + "\n height = " + height + "\n startAngle = "
+ startAngle + "\n arcAngle = " + arcAngle;
log.println(l);
g2D.fillArc(x, y, width, height, startAngle, arcAngle);
}
public void fillOval(int x, int y, int width, int height)
{
String l = "fillOval(int,int,int,int):" + "\n x = " + x + "\n y = " + y + "\n width = "
+ width + "\n height = " + height;
log.println(l);
g2D.fillOval(x, y, width, height);
}
public void fillPolygon(Polygon p)
{
String l = "fillPolygon(Polygon):" + "\n p = " + p;
log.println(l);
g2D.fillPolygon(p);
}
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
{
String l = "fillPolygon(int[],int[],int):" + "\n xPoints = " + Arrays.toString(xPoints)
+ "\n yPoints = " + Arrays.toString(yPoints) + "\n nPoints = " + nPoints;
log.println(l);
g2D.fillPolygon(xPoints, yPoints, nPoints);
}
public void fillRect(int x, int y, int width, int height)
{
log.println("g.fillRect(" + x + "," + y + "," + width + "," + height + ");");
g2D.fillRect(x, y, width, height);
}
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
{
log.println(
"fillRoundRect(" + x + "," + y + "," + width + "," + height + "," + arcWidth + ","
+ arcHeight + ")");
g2D.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
}
// FIXME: should be protected
// FindBugs, category MALICIOUS_CODE, FI_PUBLIC_SHOULD_BE_PROTECTED
// A class's finalize() method should have protected access, not public
@Override
public final void finalize()
{
log.println("finalize():");
g2D.dispose();
dispose();
}
public Shape getClip()
{
log.println("getClip():");
return g2D.getClip();
}
public Rectangle getClipBounds()
{
log.println("getClipBounds():");
return g2D.getClipBounds();
}
public Rectangle getClipBounds(Rectangle r)
{
String l = "getClipBounds(Rectangle):" + "\n r = " + r;
log.println(l);
return g2D.getClipBounds(r);
}
public Color getColor()
{
log.println("getColor():");
return g2D.getColor();
}
public Font getFont()
{
log.println("getFont():");
return g2D.getFont();
}
public FontMetrics getFontMetrics()
{
log.println("getFontMetrics():");
return g2D.getFontMetrics();
}
public FontMetrics getFontMetrics(Font f)
{
log.println("getFontMetrics():");
return g2D.getFontMetrics(f);
}
public boolean hitClip(int x, int y, int width, int height)
{
String l = "hitClip(int,int,int,int):" + "\n x = " + x + "\n y = " + y + "\n width = "
+ width + "\n height = " + height;
log.println(l);
return g2D.hitClip(x, y, width, height);
}
public void setClip(Shape clip)
{
String l = "setClip(Shape):" + "\n clip = " + clip;
PathIterator pathIterator = clip.getPathIterator(null);
double[] vals = new double[6];
StringBuilder key = new StringBuilder();
while (!pathIterator.isDone())
{
int type = pathIterator.currentSegment(vals);
switch (type)
{
case PathIterator.SEG_CUBICTO:
key.append("C");
key.append(vals[0]).append(":").append(vals[1]).append(":").append(vals[2])
.append(":").append(vals[3]).append(":").append(vals[4]).append(":")
.append(vals[5]);
break;
case PathIterator.SEG_LINETO:
key.append("L");
key.append(vals[0]).append(":").append(vals[1]).append(":");
break;
case PathIterator.SEG_MOVETO:
key.append("M");
key.append(vals[0]).append(":").append(vals[1]).append(":");
break;
case PathIterator.SEG_QUADTO:
key.append("Q");
key.append(vals[0]).append(":").append(vals[1]).append(":").append(vals[2])
.append(":").append(vals[3]);
break;
case PathIterator.SEG_CLOSE:
key.append("cp");
break;
default:
break;
}
pathIterator.next();
}
log.println(l + " " + key.toString());
g2D.setClip(clip);
}
public void setClip(int x, int y, int width, int height)
{
String l = "setClip(int,int,int,int):" + "\n x = " + x + "\n y = " + y + "\n width = "
+ width + "\n height = " + height;
log.println(l);
g2D.setClip(x, y, width, height);
}
public void setColor(Color c)
{
log.printf(Locale.ROOT, "g.setColor(new Color(0x%08X));%n", c.getRGB());
g2D.setColor(c);
}
public void setFont(Font font)
{
String l = "setFont(Font):" + "\n font = " + font;
log.println(l);
g2D.setFont(font);
}
public void setPaintMode()
{
log.println("setPaintMode():");
g2D.setPaintMode();
}
public void setXORMode(Color c1)
{
String l = "setXORMode(Color):" + "\n c1 = " + c1;
log.println(l);
g2D.setXORMode(c1);
}
public String toString()
{
log.println("toString():");
return g2D.toString();
}
public void translate(int x, int y)
{
String l = "translate(int,int):" + "\n x = " + x + "\n y = " + y;
log.println(l);
g2D.translate(x, y);
}
private static final Object[] HINTS = { RenderingHints.KEY_ANTIALIASING,
"RenderingHints.KEY_ANTIALIASING", RenderingHints.VALUE_ANTIALIAS_ON,
"RenderingHints.VALUE_ANTIALIAS_ON", RenderingHints.VALUE_ANTIALIAS_OFF,
"RenderingHints.VALUE_ANTIALIAS_OFF", RenderingHints.VALUE_ANTIALIAS_DEFAULT,
"RenderingHints.VALUE_ANTIALIAS_DEFAULT", RenderingHints.KEY_RENDERING,
"RenderingHints.KEY_RENDERING", RenderingHints.VALUE_RENDER_SPEED,
"RenderingHints.VALUE_RENDER_SPEED", RenderingHints.VALUE_RENDER_QUALITY,
"RenderingHints.VALUE_RENDER_QUALITY", RenderingHints.VALUE_RENDER_DEFAULT,
"RenderingHints.VALUE_RENDER_DEFAULT", RenderingHints.KEY_DITHERING,
"RenderingHints.KEY_DITHERING", RenderingHints.VALUE_DITHER_DISABLE,
"RenderingHints.VALUE_DITHER_DISABLE", RenderingHints.VALUE_DITHER_ENABLE,
"RenderingHints.VALUE_DITHER_ENABLE", RenderingHints.VALUE_DITHER_DEFAULT,
"RenderingHints.VALUE_DITHER_DEFAULT", RenderingHints.KEY_TEXT_ANTIALIASING,
"RenderingHints.KEY_TEXT_ANTIALIASING", RenderingHints.VALUE_TEXT_ANTIALIAS_ON,
"RenderingHints.VALUE_TEXT_ANTIALIAS_ON", RenderingHints.VALUE_TEXT_ANTIALIAS_OFF,
"RenderingHints.VALUE_TEXT_ANTIALIAS_OFF", RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT,
"RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT", RenderingHints.VALUE_TEXT_ANTIALIAS_GASP,
"RenderingHints.VALUE_TEXT_ANTIALIAS_GASP",
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB,
"RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB",
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR,
"RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR",
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VRGB,
"RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VRGB",
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR,
"RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR", RenderingHints.KEY_TEXT_LCD_CONTRAST,
"RenderingHints.KEY_TEXT_LCD_CONTRAST", RenderingHints.KEY_FRACTIONALMETRICS,
"RenderingHints.KEY_FRACTIONALMETRICS", RenderingHints.VALUE_FRACTIONALMETRICS_OFF,
"RenderingHints.VALUE_FRACTIONALMETRICS_OFF", RenderingHints.VALUE_FRACTIONALMETRICS_ON,
"RenderingHints.VALUE_FRACTIONALMETRICS_ON",
RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT,
"RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT", RenderingHints.KEY_INTERPOLATION,
"RenderingHints.KEY_INTERPOLATION", RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
"RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR",
RenderingHints.VALUE_INTERPOLATION_BILINEAR,
"RenderingHints.VALUE_INTERPOLATION_BILINEAR",
RenderingHints.VALUE_INTERPOLATION_BICUBIC,
"RenderingHints.VALUE_INTERPOLATION_BICUBIC", RenderingHints.KEY_ALPHA_INTERPOLATION,
"RenderingHints.KEY_ALPHA_INTERPOLATION",
RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED,
"RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED",
RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY,
"RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY",
RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT,
"RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT", RenderingHints.KEY_COLOR_RENDERING,
"RenderingHints.KEY_COLOR_RENDERING", RenderingHints.VALUE_COLOR_RENDER_SPEED,
"RenderingHints.VALUE_COLOR_RENDER_SPEED", RenderingHints.VALUE_COLOR_RENDER_QUALITY,
"RenderingHints.VALUE_COLOR_RENDER_QUALITY", RenderingHints.VALUE_COLOR_RENDER_DEFAULT,
"RenderingHints.VALUE_COLOR_RENDER_DEFAULT", RenderingHints.KEY_STROKE_CONTROL,
"RenderingHints.KEY_STROKE_CONTROL", RenderingHints.VALUE_STROKE_DEFAULT,
"RenderingHints.VALUE_STROKE_DEFAULT", RenderingHints.VALUE_STROKE_NORMALIZE,
"RenderingHints.VALUE_STROKE_NORMALIZE", RenderingHints.VALUE_STROKE_PURE,
"RenderingHints.VALUE_STROKE_PURE" };
private static final Object[] ATTRS = { TextAttribute.FAMILY, "TextAttribute.FAMILY",
TextAttribute.WEIGHT, "TextAttribute.WEIGHT", TextAttribute.WEIGHT_EXTRA_LIGHT,
"TextAttribute.WEIGHT_EXTRA_LIGHT", TextAttribute.WEIGHT_LIGHT,
"TextAttribute.WEIGHT_LIGHT", TextAttribute.WEIGHT_DEMILIGHT,
"TextAttribute.WEIGHT_DEMILIGHT", TextAttribute.WEIGHT_REGULAR,
"TextAttribute.WEIGHT_REGULAR", TextAttribute.WEIGHT_SEMIBOLD,
"TextAttribute.WEIGHT_SEMIBOLD", TextAttribute.WEIGHT_MEDIUM,
"TextAttribute.WEIGHT_MEDIUM", TextAttribute.WEIGHT_DEMIBOLD,
"TextAttribute.WEIGHT_DEMIBOLD", TextAttribute.WEIGHT_BOLD, "TextAttribute.WEIGHT_BOLD",
TextAttribute.WEIGHT_HEAVY, "TextAttribute.WEIGHT_HEAVY",
TextAttribute.WEIGHT_EXTRABOLD, "TextAttribute.WEIGHT_EXTRABOLD",
TextAttribute.WEIGHT_ULTRABOLD, "TextAttribute.WEIGHT_ULTRABOLD", TextAttribute.WIDTH,
"TextAttribute.WIDTH", TextAttribute.WIDTH_CONDENSED, "TextAttribute.WIDTH_CONDENSED",
TextAttribute.WIDTH_SEMI_CONDENSED, "TextAttribute.WIDTH_SEMI_CONDENSED",
TextAttribute.WIDTH_REGULAR, "TextAttribute.WIDTH_REGULAR",
TextAttribute.WIDTH_SEMI_EXTENDED, "TextAttribute.WIDTH_SEMI_EXTENDED",
TextAttribute.WIDTH_EXTENDED, "TextAttribute.WIDTH_EXTENDED", TextAttribute.POSTURE,
"TextAttribute.POSTURE", TextAttribute.POSTURE_REGULAR, "TextAttribute.POSTURE_REGULAR",
TextAttribute.POSTURE_OBLIQUE, "TextAttribute.POSTURE_OBLIQUE", TextAttribute.SIZE,
"TextAttribute.SIZE", TextAttribute.TRANSFORM, "TextAttribute.TRANSFORM",
TextAttribute.SUPERSCRIPT, "TextAttribute.SUPERSCRIPT", TextAttribute.SUPERSCRIPT_SUPER,
"TextAttribute.SUPERSCRIPT_SUPER", TextAttribute.SUPERSCRIPT_SUB,
"TextAttribute.SUPERSCRIPT_SUB", TextAttribute.FONT, "TextAttribute.FONT",
TextAttribute.CHAR_REPLACEMENT, "TextAttribute.CHAR_REPLACEMENT",
TextAttribute.FOREGROUND, "TextAttribute.FOREGROUND", TextAttribute.BACKGROUND,
"TextAttribute.BACKGROUND", TextAttribute.UNDERLINE, "TextAttribute.UNDERLINE",
TextAttribute.UNDERLINE_ON, "TextAttribute.UNDERLINE_ON", TextAttribute.STRIKETHROUGH,
"TextAttribute.STRIKETHROUGH", TextAttribute.STRIKETHROUGH_ON,
"TextAttribute.STRIKETHROUGH_ON", TextAttribute.RUN_DIRECTION,
"TextAttribute.RUN_DIRECTION", TextAttribute.RUN_DIRECTION_LTR,
"TextAttribute.RUN_DIRECTION_LTR", TextAttribute.RUN_DIRECTION_RTL,
"TextAttribute.RUN_DIRECTION_RTL", TextAttribute.BIDI_EMBEDDING,
"TextAttribute.BIDI_EMBEDDING", TextAttribute.JUSTIFICATION,
"TextAttribute.JUSTIFICATION", TextAttribute.JUSTIFICATION_FULL,
"TextAttribute.JUSTIFICATION_FULL", TextAttribute.JUSTIFICATION_NONE,
"TextAttribute.JUSTIFICATION_NONE", TextAttribute.INPUT_METHOD_HIGHLIGHT,
"TextAttribute.INPUT_METHOD_HIGHLIGHT", TextAttribute.INPUT_METHOD_UNDERLINE,
"TextAttribute.INPUT_METHOD_UNDERLINE", TextAttribute.UNDERLINE_LOW_ONE_PIXEL,
"TextAttribute.UNDERLINE_LOW_ONE_PIXEL", TextAttribute.UNDERLINE_LOW_TWO_PIXEL,
"TextAttribute.UNDERLINE_LOW_TWO_PIXEL", TextAttribute.UNDERLINE_LOW_DOTTED,
"TextAttribute.UNDERLINE_LOW_DOTTED", TextAttribute.UNDERLINE_LOW_GRAY,
"TextAttribute.UNDERLINE_LOW_GRAY", TextAttribute.UNDERLINE_LOW_DASHED,
"TextAttribute.UNDERLINE_LOW_DASHED", TextAttribute.SWAP_COLORS,
"TextAttribute.SWAP_COLORS", TextAttribute.SWAP_COLORS_ON,
"TextAttribute.SWAP_COLORS_ON", TextAttribute.NUMERIC_SHAPING,
"TextAttribute.NUMERIC_SHAPING", TextAttribute.KERNING, "TextAttribute.KERNING",
TextAttribute.KERNING_ON, "TextAttribute.KERNING_ON", TextAttribute.LIGATURES,
"TextAttribute.LIGATURES", TextAttribute.LIGATURES_ON, "TextAttribute.LIGATURES_ON",
TextAttribute.TRACKING, "TextAttribute.TRACKING", TextAttribute.TRACKING_TIGHT,
"TextAttribute.TRACKING_TIGHT", TextAttribute.TRACKING_LOOSE,
"TextAttribute.TRACKING_LOOSE" };
}
pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/main/resources/ 0000775 0000000 0000000 00000000000 14157706453 0030165 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/main/resources/.keep 0000664 0000000 0000000 00000000000 14157706453 0031100 0 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/test/ 0000775 0000000 0000000 00000000000 14157706453 0026206 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/test/java/ 0000775 0000000 0000000 00000000000 14157706453 0027127 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/test/java/de/ 0000775 0000000 0000000 00000000000 14157706453 0027517 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/test/java/de/rototor/ 0000775 0000000 0000000 00000000000 14157706453 0031227 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/test/java/de/rototor/pdfbox/ 0000775 0000000 0000000 00000000000 14157706453 0032511 5 ustar 00root root 0000000 0000000 graphics2d/ 0000775 0000000 0000000 00000000000 14157706453 0034460 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/test/java/de/rototor/pdfbox extendedtests/ 0000775 0000000 0000000 00000000000 14157706453 0037343 5 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/test/java/de/rototor/pdfbox/graphics2d TestGraphicsFillBug.java 0000664 0000000 0000000 00000005527 14157706453 0044064 0 ustar 00root root 0000000 0000000 pdfbox-graphics2d-pdfboxgraphics2d-parent-0.34/extended-tests/src/test/java/de/rototor/pdfbox/graphics2d/extendedtests package de.rototor.pdfbox.graphics2d.extendedtests;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.rendering.PDFRenderer;
import org.junit.Test;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.geom.Ellipse2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.Path2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import static java.awt.image.BufferedImage.TYPE_INT_ARGB;
public class TestGraphicsFillBug
{
@Test
public void testGraphicsFillBug() throws IOException
{
InputStream resourceAsStream = TestGraphicsFillBug.class.getResourceAsStream(
"PDFBOX-5322_reduced.pdf");
PDDocument doc = PDDocument.load(resourceAsStream);
PDFRenderer pdfRenderer = new PDFRenderer(doc);
DebugCodeGeneratingGraphics2d gfx = new DebugCodeGeneratingGraphics2d();
gfx.setBackground(Color.WHITE);
gfx.clearRect(0, 0, 1000, 1000);
pdfRenderer.renderPageToGraphics(0, gfx);
ImageIO.write(gfx.getDebugImage(), "PNG", new File("target/test/graphisfillbug_debug.png"));
new File("target/test/").mkdirs();
ImageIO.write(pdfRenderer.renderImage(0, 1f), "PNG",
new File("target/test/graphisfillbug.png"));
}
@Test
public void testAntialiasingPathDrawBug() throws IOException
{
BufferedImage image = new BufferedImage(500, 300, TYPE_INT_ARGB);
Graphics2D g = image.createGraphics();
g.setBackground(new Color(0xFFFFFFFF));
g.clearRect(0, 0, 1000, 1000);
Map