Package com.pixelmed.display

# Class TextAnnotationPositioned

java.lang.Object
com.pixelmed.display.TextAnnotationPositioned

public class TextAnnotationPositioned extends Object

A class to encapsulate a text annotation positioned left or right and top or bottom with row offset relative to an abstract rectanglular frame.

## Constructor Summary

Constructors
Constructor
Description
`TextAnnotationPositioned(String string, boolean fromLeft, boolean fromTop, int textRow)`

## Method Summary

Modifier and Type
Method
Description
`static void`
`drawHorizontallyCenteredString(String string, boolean fromTop, Graphics2D g2d, Component window, int topAndBottomMargin)`
`static void`
`drawPositionedString(TextAnnotationPositioned annotation, Graphics2D g2d, int displayedAreaWidth, int displayedAreaHeight, int topAndBottomMargin, int leftAndRightMargin)`
`static void`
`drawPositionedString(TextAnnotationPositioned annotation, Graphics2D g2d, Component window, int topAndBottomMargin, int leftAndRightMargin)`
`static void`
`drawPositionedString(TextAnnotationPositioned annotation, Graphics2D g2d, FontMetrics fontMetrics, int stringHeight, int displayedAreaWidth, int displayedAreaHeight, int topAndBottomMargin, int leftAndRightMargin)`
`static void`
`drawPositionedString(String string, boolean fromLeft, boolean fromTop, int textRow, Graphics2D g2d, Component window, int topAndBottomMargin, int leftAndRightMargin)`
`static void`
`drawPositionedString(String string, boolean fromLeft, boolean fromTop, int textRow, Graphics2D g2d, FontMetrics fontMetrics, int stringHeight, int displayedAreaWidth, int displayedAreaHeight, int topAndBottomMargin, int leftAndRightMargin)`
`static void`
`drawVerticallyCenteredString(String string, boolean fromLeft, Graphics2D g2d, Component window, int leftAndRightMargin)`
`static void`
`drawVerticallyCenteredString(String string, boolean fromLeft, Graphics2D g2d, Component window, int verticalOffset, int leftAndRightMargin)`
`String`
`getString()`
Get the text of the annotation.
`int`
`getTextRow()`
Get the text row.
`boolean`
`isLeft()`
Get the position relative to the left or right of the frame.
`boolean`
`isTop()`
Get the position relative to the top or bottom of the frame.

### Methods inherited from class java.lang.Object

`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### TextAnnotationPositioned

public TextAnnotationPositioned(String string, boolean fromLeft, boolean fromTop, int textRow)

Parameters:
  `string` - the annotation
  `fromLeft` - true if positioned at the left of the frame, false if right
  `fromTop` - true if positioned at the top of the frame, false if bottom
  `textRow` - the number of text rows from the top or bottom (numbered from 0)

## Method Details

### getString

public String getString()

Get the text of the annotation.

Returns:
  the annotation

### isLeft

public boolean isLeft()

Get the position relative to the left or right of the frame.

Returns:
  true if positioned at the left of the frame, false if right

### isTop

public boolean isTop()

Get the position relative to the top or bottom of the frame.

Returns:
  true if positioned at the top of the frame, false if bottom

### getTextRow

public int getTextRow()

Get the text row.

Returns:
  the number of text rows from the top or bottom (numbered from 0)

### drawPositionedString

public static void drawPositionedString(TextAnnotationPositioned annotation, Graphics2D g2d, Component window, int topAndBottomMargin, int leftAndRightMargin)

Parameters:
  `annotation` - the text and position to be drawn
  `g2d` - the drawing context
  `window` - the actual component being drawn into
  `topAndBottomMargin` - the margin to allow at the top and bottom of the frame, in pixels
  `leftAndRightMargin` - the margin to allow at the left and right of the frame, in pixels

### drawPositionedString

public static void drawPositionedString(TextAnnotationPositioned annotation, Graphics2D g2d, int displayedAreaWidth, int displayedAreaHeight, int topAndBottomMargin, int leftAndRightMargin)

Parameters:
  `annotation` - the text and position to be drawn
  `g2d` - the drawing context
  `displayedAreaWidth` - the width of the frame being drawn into, in pixels
  `displayedAreaHeight` - the height of the frame being drawn into, in pixels
  `topAndBottomMargin` - the margin to allow at the top and bottom of the frame, in pixels
  `leftAndRightMargin` - the margin to allow at the left and right of the frame, in pixels

### drawPositionedString

public static void drawPositionedString(TextAnnotationPositioned annotation, Graphics2D g2d, FontMetrics fontMetrics, int stringHeight, int displayedAreaWidth, int displayedAreaHeight, int topAndBottomMargin, int leftAndRightMargin)

Parameters:
  `annotation` - the text and position to be drawn
  `g2d` - the drawing context
  `fontMetrics` - the font metrics (already extracted from g2d, with which it must be consistent)
  `stringHeight` - the height used for all rows of text (already extracted from fontMetrics, with which it must be consistent)
  `displayedAreaWidth` - the width of the frame being drawn into, in pixels
  `displayedAreaHeight` - the height of the frame being drawn into, in pixels
  `topAndBottomMargin` - the margin to allow at the top and bottom of the frame, in pixels
  `leftAndRightMargin` - the margin to allow at the left and right of the frame, in pixels

### drawPositionedString

public static void drawPositionedString(String string, boolean fromLeft, boolean fromTop, int textRow, Graphics2D g2d, Component window, int topAndBottomMargin, int leftAndRightMargin)

Parameters:
  `string` - the text to be drawn
  `fromLeft` - true if positioned at the left of the frame, false if right
  `fromTop` - true if positioned at the top of the frame, false if bottom
  `textRow` - the number of text rows from the top or bottom (numbered from 0)
  `g2d` - the drawing context
  `window` - the actual component being drawn into
  `topAndBottomMargin` - the margin to allow at the top and bottom of the frame, in pixels
  `leftAndRightMargin` - the margin to allow at the left and right of the frame, in pixels

### drawPositionedString

public static void drawPositionedString(String string, boolean fromLeft, boolean fromTop, int textRow, Graphics2D g2d, FontMetrics fontMetrics, int stringHeight, int displayedAreaWidth, int displayedAreaHeight, int topAndBottomMargin, int leftAndRightMargin)

Parameters:
  `string` - the text to be drawn
  `fromLeft` - true if positioned at the left of the frame, false if right
  `fromTop` - true if positioned at the top of the frame, false if bottom
  `textRow` - the number of text rows from the top or bottom (numbered from 0)
  `g2d` - the drawing context
  `fontMetrics` - the font metrics (already extracted from g2d, with which it must be consistent)
  `stringHeight` - the height used for all rows of text (already extracted from fontMetrics, with which it must be consistent)
  `displayedAreaWidth` - the width of the frame being drawn into, in pixels
  `displayedAreaHeight` - the height of the frame being drawn into, in pixels
  `topAndBottomMargin` - the margin to allow at the top and bottom of the frame, in pixels
  `leftAndRightMargin` - the margin to allow at the left and right of the frame, in pixels

### drawVerticallyCenteredString

public static void drawVerticallyCenteredString(String string, boolean fromLeft, Graphics2D g2d, Component window, int leftAndRightMargin)

Parameters:
  `string` - the text to be drawn
  `fromLeft` - true if positioned at the left of the frame, false if right
  `g2d` - the drawing context
  `window` - the actual component being drawn into
  `leftAndRightMargin` - the margin to allow at the left and right of the frame, in pixels

### drawVerticallyCenteredString

public static void drawVerticallyCenteredString(String string, boolean fromLeft, Graphics2D g2d, Component window, int verticalOffset, int leftAndRightMargin)

Parameters:
  `string` - the text to be drawn
  `fromLeft` - true if positioned at the left of the frame, false if right
  `g2d` - the drawing context
  `window` - the actual component being drawn into
  `verticalOffset` - a downwards offset from the vertical center, in text rows (not pixels)
  `leftAndRightMargin` - the margin to allow at the left and right of the frame, in pixels

### drawHorizontallyCenteredString

public static void drawHorizontallyCenteredString(String string, boolean fromTop, Graphics2D g2d, Component window, int topAndBottomMargin)

Parameters:
  `string` - the text to be drawn
  `fromTop` - true if positioned at the top of the frame, false if bottom
  `g2d` - the drawing context
  `window` - the actual component being drawn into
  `topAndBottomMargin` - the margin to allow at the top and bottom of the frame, in pixels