Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
return NO_SUCH_PAGE;
}

Graphics2D printerGraphics = null;
Graphics2D graphics2D = null;
// work on a private copy so the caller's Graphics2D state (transform, clip, color,
// background, stroke) is never mutated. Disposing the copy in the finally block
// releases its resources without affecting the original.
Graphics2D printerGraphics = (Graphics2D) graphics.create();
Graphics2D graphics2D = printerGraphics;

try
{
printerGraphics = (Graphics2D) graphics;
graphics2D = printerGraphics;

// capture the DPI that will be used for rasterizing the image
// if rasterizing is specified
float rasterDpi = dpi;
Expand Down Expand Up @@ -324,10 +324,11 @@ public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
}
finally
{
if (graphics2D != null && graphics2D != printerGraphics)
if (graphics2D != printerGraphics)
{
graphics2D.dispose();
}
printerGraphics.dispose();
}
}

Expand Down