Class TextAnnotationPositioned


  • public class TextAnnotationPositioned
    extends java.lang.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​(java.lang.String string, boolean fromLeft, boolean fromTop, int textRow)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void drawHorizontallyCenteredString​(java.lang.String string, boolean fromTop, java.awt.Graphics2D g2d, java.awt.Component window, int topAndBottomMargin)  
      static void drawPositionedString​(TextAnnotationPositioned annotation, java.awt.Graphics2D g2d, int displayedAreaWidth, int displayedAreaHeight, int topAndBottomMargin, int leftAndRightMargin)  
      static void drawPositionedString​(TextAnnotationPositioned annotation, java.awt.Graphics2D g2d, java.awt.Component window, int topAndBottomMargin, int leftAndRightMargin)  
      static void drawPositionedString​(TextAnnotationPositioned annotation, java.awt.Graphics2D g2d, java.awt.FontMetrics fontMetrics, int stringHeight, int displayedAreaWidth, int displayedAreaHeight, int topAndBottomMargin, int leftAndRightMargin)  
      static void drawPositionedString​(java.lang.String string, boolean fromLeft, boolean fromTop, int textRow, java.awt.Graphics2D g2d, java.awt.Component window, int topAndBottomMargin, int leftAndRightMargin)  
      static void drawPositionedString​(java.lang.String string, boolean fromLeft, boolean fromTop, int textRow, java.awt.Graphics2D g2d, java.awt.FontMetrics fontMetrics, int stringHeight, int displayedAreaWidth, int displayedAreaHeight, int topAndBottomMargin, int leftAndRightMargin)  
      static void drawShadowedString​(java.lang.String string, int x, int y, java.awt.Graphics2D g2d)
      static void drawVerticallyCenteredString​(java.lang.String string, boolean fromLeft, java.awt.Graphics2D g2d, java.awt.Component window, int leftAndRightMargin)  
      static void drawVerticallyCenteredString​(java.lang.String string, boolean fromLeft, java.awt.Graphics2D g2d, java.awt.Component window, int verticalOffset, int leftAndRightMargin)  
      java.lang.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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TextAnnotationPositioned

        public TextAnnotationPositioned​(java.lang.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 Detail

      • getString

        public java.lang.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,
                                                java.awt.Graphics2D g2d,
                                                java.awt.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,
                                                java.awt.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,
                                                java.awt.Graphics2D g2d,
                                                java.awt.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​(java.lang.String string,
                                                boolean fromLeft,
                                                boolean fromTop,
                                                int textRow,
                                                java.awt.Graphics2D g2d,
                                                java.awt.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​(java.lang.String string,
                                                boolean fromLeft,
                                                boolean fromTop,
                                                int textRow,
                                                java.awt.Graphics2D g2d,
                                                java.awt.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​(java.lang.String string,
                                                        boolean fromLeft,
                                                        java.awt.Graphics2D g2d,
                                                        java.awt.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​(java.lang.String string,
                                                        boolean fromLeft,
                                                        java.awt.Graphics2D g2d,
                                                        java.awt.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​(java.lang.String string,
                                                          boolean fromTop,
                                                          java.awt.Graphics2D g2d,
                                                          java.awt.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
      • drawShadowedString

        public static void drawShadowedString​(java.lang.String string,
                                              int x,
                                              int y,
                                              java.awt.Graphics2D g2d)