IllegalArgumentException when exporting graph to image files
TroubleshootingSummary
Explains how to avoid IllegalArgumentExceptions when exporting graph to image files.
Description
When the requested size for an image to be exported is negative, ImageOutputHandlers will complain with an error message similiar to the one below:
java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0
If there is no current view registered for the graph, a default view will be used. By default, the size of that view equals the size of the bounding box of the graph. So the errow messeage indicated that either the graph is empty and there is no view associated with it or the associated view has negative size. To remedy this problem, it's best to explicitly configure the associated view for the graph. Knowledge base article 32 shows how this can be done.
Categories this article belongs to:
yFiles for Java > yFiles Viewer > Input and Output > Exporting a Graph's Visual Representation
Applies to:
yFiles for Java 2: 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.10, 2.11, 2.12, 2.13, 2.14, 2.15, 2.16, 2.17, 2.18
Keywords:
IllegalArgumentException - JPG - GIF - export - image - negative size