GraphicAttribute 클래스

GraphicAttribute 클래스

이 클래스는 CHAR_REPLACEMENT 속성과 함께 사용돼요. GraphicAttribute 클래스는 텍스트에 내장된 그래픽을 나타내요. 클라이언트는 이 클래스를 상속해서 자신만의 문자 대체 그래픽을 구현할 수 있어요.

출처: Java API Reference

본문

텍스트에 도형과 이미지를 내장하고 싶은 클라이언트는 이 클래스를 상속할 필요 없이 ShapeGraphicAttributeImageGraphicAttribute 클래스를 사용하면 돼요.

public abstract class GraphicAttribute
extends Object

하위 클래스는 객체가 한번 구성되면 변경 불가능(immutable)하도록 보장해야 해요. TextLayout에서 사용되는 GraphicAttribute를 변형하면 TextLayout의 동작이 정의되지 않아요.

정렬 상수

  • static final int BOTTOM_ALIGNMENT — 그래픽 하단을 줄 하단에 정렬해요.
  • static final int CENTER_BASELINE — 그래픽 원점을 줄의 중심 기준선에 정렬해요.
  • static final int HANGING_BASELINE — 그래픽 원점을 줄의 매달린 기준선에 정렬해요.
  • static final int ROMAN_BASELINE — 그래픽 원점을 줄의 로만 기준선에 정렬해요.
  • static final int TOP_ALIGNMENT — 그래픽 상단을 줄 상단에 정렬해요.

추상 메서드

  • draw(Graphics2D graphics, float x, float y) — 이 GraphicAttribute를 지정한 위치에 렌더링해요.
  • getAdvance() — 이 GraphicAttribute의 advance를 반환해요.
  • getAscent() — 이 GraphicAttribute의 ascent를 반환해요.
  • getDescent() — 이 GraphicAttribute의 descent를 반환해요.

구상 메서드

  • getAlignment() — 이 GraphicAttribute의 정렬을 반환해요.
  • getBounds() — 렌더링 위치에 상대적인, 이 그래픽이 그리는 모든 비트를 감싸는 Rectangle2D를 반환해요.
  • getJustificationInfo() — 이 GraphicAttribute의 정렬 정보를 반환해요.
  • getOutline(AffineTransform tx) — 이 GraphicAttribute가 렌더링하는 영역을 나타내는 Shape를 반환해요.

생성자

protected GraphicAttribute(int alignment)GraphicAttribute를 구성해요.

더 알아보기