From e9eb1717855817a70bf3d23526fe1218d2c75e7b Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 22 Apr 2014 00:32:31 +0200 Subject: [PATCH] initial --- .../src/com/intellij/util/ui/JBImageIcon.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 platform/util/src/com/intellij/util/ui/JBImageIcon.java diff --git a/platform/util/src/com/intellij/util/ui/JBImageIcon.java b/platform/util/src/com/intellij/util/ui/JBImageIcon.java new file mode 100644 index 000000000000..8d8bc6e40b00 --- /dev/null +++ b/platform/util/src/com/intellij/util/ui/JBImageIcon.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.util.ui; + +import javax.swing.*; +import java.awt.*; +import java.awt.image.ImageObserver; + +/** + * HiDPI-aware image icon + * + * @author Konstantin Bulenkov + */ +public class JBImageIcon extends ImageIcon { + public JBImageIcon(Image image) { + super(image); + } + + @Override + public final synchronized void paintIcon(final Component c, final Graphics g, final int x, final int y) { + final ImageObserver observer = getImageObserver(); + + UIUtil.drawImage(g, getImage(), x, y, observer == null ? c : observer); + } +}