Skip to content

Commit

Permalink
Code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender committed Nov 14, 2023
1 parent 3c42d9f commit 490438f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2020 Lablicate GmbH.
* Copyright (c) 2018, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -23,7 +23,7 @@

public class Fonts {

private static Map<String, Font> fonts = new HashMap<String, Font>();
private static Map<String, Font> fonts = new HashMap<>();

/**
* Don't dispose the font as a cached version is used.
Expand All @@ -40,9 +40,7 @@ public static Font getCachedFont(Device display, String name, int height, int st
String fontId = name + height + style;
if(!fonts.containsKey(fontId)) {
Font font = new Font(display, name, height, style);
if(font != null) {
fonts.put(fontId, font);
}
fonts.put(fontId, font);
}
//
return fonts.containsKey(fontId) ? fonts.get(fontId) : DisplayUtils.getDisplay().getSystemFont();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020 Lablicate GmbH.
* Copyright (c) 2020, 2023 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.chemclipse.ux.extension.xxd.ui.internal.charts;

import org.eclipse.chemclipse.logging.core.Logger;
import org.eclipse.chemclipse.ux.extension.xxd.ui.preferences.PreferenceConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
Expand All @@ -21,12 +22,14 @@
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swtchart.Resources;

public class LabelBounds {

public static final boolean DEBUG_LOG = false;
public static final boolean DEBUG_FENCES = false;
//
private static final Logger logger = Logger.getLogger(LabelBounds.class);
//
private final float[] pointArray = new float[10];
private final int[] transformedPoints = new int[10];
private final int width;
Expand Down Expand Up @@ -160,9 +163,7 @@ public float offsetX(LabelBounds other) {
float b = (x2 * y1 - x1 * y2) / dx;
w = Math.min((other.getLeftY() - b) / m, getRightX());
}
if(DEBUG_LOG) {
System.out.println("w=" + w + " rx=" + getRightX() + ", olx=" + other.getLeftX());
}
logger.info("w=" + w + " rx=" + getRightX() + ", olx=" + other.getLeftX());
return w - other.getLeftX();
}

Expand All @@ -182,17 +183,15 @@ public float offsetY(LabelBounds other) {
float b = (x2 * y1 - x1 * y2) / dx;
h = Math.min(Math.max(m * x + b, getTopY()), getBottomY());
}
if(DEBUG_LOG) {
System.out.println("h=" + h + ", by = " + getBottomY());
}
logger.info("h=" + h + ", by = " + getBottomY());
return getBottomY() - h + (other.getCy() - getCy());
}

public void paintBounds() {

gc.setTransform(null);
Color old_fg = gc.getForeground();
Font old_font = gc.getFont();
Color oldForeground = gc.getForeground();
Font oldFont = gc.getFont();
try {
Font font = Resources.getFont(PreferenceConstants.DEF_CHROMATOGRAM_PEAK_LABEL_FONT_NAME, 8, PreferenceConstants.DEF_CHROMATOGRAM_PEAK_LABEL_FONT_STYLE);
gc.setFont(font);
Expand All @@ -216,7 +215,7 @@ public void paintBounds() {
float m = (y2 - y1) / dx;
float b = (x2 * y1 - x1 * y2) / dx;
float y = m * x + b;
System.out.println("f(" + x + ")=" + y);
logger.info("f(" + x + ")=" + y);
if(sx == x) {
path.moveTo(x, y);
} else {
Expand Down Expand Up @@ -251,8 +250,8 @@ public void paintBounds() {
}
font.dispose();
} finally {
gc.setFont(old_font);
gc.setForeground(old_fg);
gc.setFont(oldFont);
gc.setForeground(oldForeground);
}
}

Expand Down

0 comments on commit 490438f

Please sign in to comment.