Skip to content

Commit

Permalink
Small amendment to fix from bug #170
Browse files Browse the repository at this point in the history
  • Loading branch information
jfree committed Oct 23, 2020
1 parent bbd2c29 commit 7881741
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/main/java/org/jfree/chart/ChartPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.EventListener;
import java.util.List;
Expand Down Expand Up @@ -1358,16 +1359,15 @@ else if (drawHeight > this.maximumDrawHeight) {
final double globalScaleX = globalTransform.getScaleX();
final double globalScaleY = globalTransform.getScaleY();

final double scaledWidth = available.getWidth() * globalScaleX;
final double scaledHeight = available.getHeight() * globalScaleY;
final int scaledWidth = (int) (available.getWidth() * globalScaleX);
final int scaledHeight = (int) (available.getHeight() * globalScaleY);

// do we need to resize the buffer?
if ((this.chartBuffer == null)
|| (this.chartBufferWidth != scaledWidth)
|| (this.chartBufferHeight != scaledHeight)) {

this.chartBufferWidth = (int) scaledWidth;
this.chartBufferHeight = (int) scaledHeight;
this.chartBufferWidth = scaledWidth;
this.chartBufferHeight = scaledHeight;
GraphicsConfiguration gc = g2.getDeviceConfiguration();
this.chartBuffer = gc.createCompatibleImage(
this.chartBufferWidth, this.chartBufferHeight,
Expand All @@ -1380,8 +1380,9 @@ else if (drawHeight > this.maximumDrawHeight) {

this.refreshBuffer = false; // clear the flag

// scale graphics of the buffer to the same value as global Swing graphics
// this allow to paint all elements as usual but applies all necessary smothing
// scale graphics of the buffer to the same value as global
// Swing graphics - this allow to paint all elements as usual
// but applies all necessary smoothing
Graphics2D bufferG2 = (Graphics2D) this.chartBuffer.getGraphics();
bufferG2.scale(globalScaleX, globalScaleY);

Expand Down

0 comments on commit 7881741

Please sign in to comment.