Skip to content

Commit

Permalink
Charts - inconsistent line thickness when imageDPI > 72 eclipse-birt#…
Browse files Browse the repository at this point in the history
  • Loading branch information
claesrosell authored Nov 8, 2023
1 parent 3089f99 commit 7400052
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
import org.eclipse.birt.chart.util.ChartUtil;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.mozilla.javascript.Scriptable;

import com.ibm.icu.util.ULocale;
Expand All @@ -100,7 +101,6 @@ public final class Generator implements IGenerator {
* An internal style processor.
*/
private IStyleProcessor implicitProcessor;
private boolean fScaleUpdated = false;

/**
* The internal singleton Generator reference created lazily.
Expand Down Expand Up @@ -1014,12 +1014,15 @@ public void refresh(GeneratedChartState gcs) throws ChartException {
*/
@Override
public void render(IDeviceRenderer idr, GeneratedChartState gcs) throws ChartException {
final Chart cm = gcs.getChartModel();
Chart cm = gcs.getChartModel();
final int scale = idr.getDisplayServer().getDpiResolution() / 72;
if (scale != 1 && !fScaleUpdated) {
if (scale != 1) {
// Here multiply by integer scale so that normal dpi (96) won't
// change thickness by default. Only PDF case would change.
fScaleUpdated = true;
// We do it on of copy of the Chart model though, so the original model isn't
// affected.
// This way the model can be rendered multiple times without being deformed
cm = EcoreUtil.copy(cm);
updateDeviceScale(cm, scale);
}

Expand Down Expand Up @@ -1483,7 +1486,7 @@ public void setDefaultBackground(ColorDefinition cd) {
implicitProcessor.setDefaultBackgroundColor(cd);
}

private void updateDeviceScale(EObject component, int scale) {
private static void updateDeviceScale(EObject component, int scale) {
if (component instanceof LineAttributes) {
LineAttributes lia = (LineAttributes) component;
lia.setThickness(lia.getThickness() * scale);
Expand Down

0 comments on commit 7400052

Please sign in to comment.