Example usage for java.awt Graphics create

List of usage examples for java.awt Graphics create

Introduction

In this page you can find the example usage for java.awt Graphics create.

Prototype

public Graphics create(int x, int y, int width, int height) 

Source Link

Document

Creates a new Graphics object based on this Graphics object, but with a new translation and clip area.

Usage

From source file:krasa.cpu.CpuUsagePanel.java

/**
 * it will probably be better synchronized, not sure
 *///  w w w .ja  v  a2s. com
private synchronized void draw(Graphics g, Image bufferedImage) {
    UIUtil.drawImage(g, bufferedImage, 0, 0, null);
    if (UIUtil.isJreHiDPI((Graphics2D) g) && !UIUtil.isUnderDarcula()) {
        Graphics2D g2 = (Graphics2D) g.create(0, 0, getWidth(), getHeight());
        float s = JBUI.sysScale(g2);
        g2.scale(1 / s, 1 / s);
        g2.setColor(UIUtil.isUnderIntelliJLaF() ? Gray.xC9 : Gray.x91);
        g2.drawLine(0, 0, (int) (s * getWidth()), 0);
        g2.scale(1, 1);
        g2.dispose();
    }
}