GraphicsConfiguration 클래스
GraphicsConfiguration 클래스
GraphicsConfiguration 클래스는 프린터나 모니터 같은 그래픽 대상의 특성을 설명해요. 단일 그래픽 장치와 연관된 GraphicsConfiguration 객체가 여러 개 있을 수 있으며, 서로 다른 그리기 모드나 성능을 나타내요. 대응하는 네이티브 구조는 플랫폼마다 달라요.
본문
예를 들어 X11 윈도우 시스템에서는 각 visual이 서로 다른 GraphicsConfiguration이에요. Microsoft Windows에서는 GraphicsConfiguration이 현재 해상도와 색상 깊이에서 사용 가능한 PixelFormat을 나타내요.
public abstract class GraphicsConfiguration
extends Object
가상 장치 다중 화면 환경
데스크톱 영역이 여러 물리 화면 장치에 걸쳐 있는 가상 장치 환경에서는 GraphicsConfiguration 객체의 bounds가 가상 좌표계에 상대적이에요. 컴포넌트 위치를 설정할 때는 getBounds로 원하는 GraphicsConfiguration의 bounds를 얻고 그 좌표로 위치를 오프셋해야 해요.
Frame f = new Frame(gc); // gc는 GraphicsConfiguration
Rectangle bounds = gc.getBounds();
f.setLocation(10 + bounds.x, 10 + bounds.y);
환경 판별
환경이 가상 장치 환경인지 확인하려면 시스템의 모든 GraphicsConfiguration에 getBounds를 호출해요. 반환된 bounds 중 어느 원점이 (0, 0)이 아니면 가상 장치 환경이에요. getBounds로 가상 장치의 bounds도 계산할 수 있는데, 모든 bounds의 합집합이 가상 장치의 bounds예요.
Rectangle virtualBounds = new Rectangle();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
for (int j = 0; j < gs.length; j++) {
GraphicsDevice gd = gs[j];
GraphicsConfiguration[] gc = gd.getConfigurations();
for (int i = 0; i < gc.length; i++) {
virtualBounds = virtualBounds.union(gc[i].getBounds());
}
}
주요 메서드
getBounds()— 이 구성의 경계 사각형을 반환해요.getDevice()— 이 구성과 연관된GraphicsDevice를 반환해요.getColorModel()— 기본 색상 모델을 반환해요.getDefaultTransform()/getNormalizingTransform()— 기본·정규화 변환을 반환해요.createCompatibleImage(...)— 구성과 호환되는 이미지를 만들어요.getBufferCapabilities()— 버퍼 기능을 반환해요.