All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.actelion.research.gui.hidpi.HiDPIIcon Maven / Gradle / Ivy

There is a newer version: 2024.12.1
Show newest version
package com.actelion.research.gui.hidpi;

import com.actelion.research.gui.LookAndFeelHelper;

import javax.swing.*;
import java.awt.*;

/**
 * Created by thomas on 07/12/15.
 */
public class HiDPIIcon extends ImageIcon {

	public HiDPIIcon(final Image image) {
		super(image);
	}

	public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
		if (HiDPIHelper.getRetinaScaleFactor() == 2) {
			x = 1;
			y = 1;
			if (LookAndFeelHelper.isQuaQua()) {
				x++;
				y++;
				}

			Image image = getImage();
			int width = image.getWidth(null);
			int height = image.getHeight(null);
			g.drawImage(image, x, y, width / 2, height / 2, null);
			}
		else {
			x = 1;
			y = 1;
			if (LookAndFeelHelper.isQuaQua()) {
				x++;
				y++;
				}

			Image image = getImage();
			g.drawImage(image, x, y, null);
			}
		}
	}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy