Class AnnotationUtils


  • public class AnnotationUtils
    extends Object
    Helper methods for annotations.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • AnnotationUtils

        public AnnotationUtils()
    • Method Detail

      • applyFormatOptions

        public static String applyFormatOptions​(String value,
                                                String format)
        Applies further format options. Does nothing if format or value are empty.
        Parameters:
        value - the value to format
        format - the format to apply
        Returns:
        the processed value
      • applyLabelFormat

        public static String applyLabelFormat​(LocatedObject object,
                                              String typeSuffix,
                                              String labelFormat)
        Applies the label format to the object to generate a display string.
        Parameters:
        object - the object to use as basis
        typeSuffix - the meta-data key for the type
        labelFormat - the label format to use
        Returns:
        the generated label
      • calcStringDimenions

        public static Dimension calcStringDimenions​(Graphics g,
                                                    Font f,
                                                    String s)
        Calculates the string dimensions in pixels.
        Parameters:
        g - the graphics context
        f - the font to use
        s - the string to measure
        Returns:
        the dimensions in pixels
      • drawString

        public static void drawString​(Graphics g,
                                      Rectangle rect,
                                      ImageAnchor anchor,
                                      String label,
                                      int offsetX,
                                      int offsetY,
                                      Font font)
        Draws the string at the specified position.
        Parameters:
        g - the graphics context
        rect - the reference for the anchor
        anchor - the anchor to use
        label - the label to draw
        offsetX - the X offset from the anchor
        offsetY - the Y offset from the anchor
        font - the font to use