Debian Codegraph @

src/com/bulenkov/iconloader/JBHiDPIScaledImage.java

raw symbols SCIP
1 /*
2 * Copyright 2000-2014 JetBrains s.r.o.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.bulenkov.iconloader;
18
19 import java.awt.*;
20 import java.awt.image.BufferedImage;
21
22 /**
23 * @author Konstantin Bulenkov
24 */
25 public class JBHiDPIScaledImage extends BufferedImage {
26 private final Image myImage;
27
28 public JBHiDPIScaledImage(int width, int height, int type) {
29 this(null, 2 * width, 2 * height, type);
30 }
31
32 public JBHiDPIScaledImage(Image image, int width, int height, int type) {
33 super(width, height, type);
34 myImage = image;
35 }
36
37 public Image getDelegate() {
38 return myImage;
39 }
40
41 @Override
42 public Graphics2D createGraphics() {
43 final Graphics2D g = super.createGraphics();
44
45 if (myImage == null) {
46 return new HiDPIScaledGraphics(g, this);
47 }
48
49 return g;
50 }
51 }