Class JxnTextPainter

    • Constructor Detail

      • JxnTextPainter

        public JxnTextPainter​(String text,
                              double x0,
                              double y0)
        Creates an instance for display of text centered at position (x0,y0) in a PlotFrame.
      • JxnTextPainter

        public JxnTextPainter​(double value,
                              double x0,
                              double y0)
        Creates an instance for display of value as text in a PlotFrame.
        Use @JxnTextPainter( format( value, nDec ), x0, y0 ) to show value with nDec decimals.
      • JxnTextPainter

        public JxnTextPainter​(long value,
                              double x0,
                              double y0)
        Creates an instance for display of value as text in a PlotFrame.
      • JxnTextPainter

        public JxnTextPainter​(double value,
                              double x0,
                              double y0,
                              Color textColor)
      • JxnTextPainter

        public JxnTextPainter​(long value,
                              double x0,
                              double y0,
                              Color textColor)
    • Method Detail

      • toString

        public String toString()
        Returns text and position as String.
        Overrides:
        toString in class Object
      • setBackground

        public JxnTextPainter setBackground​(Color backgroundColor)
        Changes the background color of the text (default is white) for this instance.
        Example:
           pf = plot( cos 2 PI t, sin 2 PI t, BLACK, 0, 2., 0. )
           pf.setFont( @Font( "", 0, 20 ) ) 
           pf.add( @JxnTextPainter( "abc", -0.7,  0.7 ) )  ! default: black on white background
           pf.add( @JxnTextPainter( "def",  0.7,  0.7, B ).setBackground() )  ! no background
           pf.add( @JxnTextPainter( "ghi", -0.7, -0.7, R ).setBackground( @Color( 1., 1., 1., 0.875 ) ) )  
           !                                                     ! white background with alpha (opaqueness)
           pf.add( @JxnTextPainter( "jkl",  0.7, -0.7, G ).setBackground( Color.pink ) )  ! pink background
         
        Returns:
        this
      • setBackground

        public JxnTextPainter setBackground()
        Shows text without background.
        Returns:
        this
      • setFont

        public JxnTextPainter setFont​(Font f)
        Changes the text font. See java.awt.Font for details.
        Returns:
        this
      • setShift

        public JxnTextPainter setShift​(double xShift,
                                       double yShift)
        Shifts the text position.
        Example: setShift(0.5,0.5) moves the text, so that the lower left corner is at the position (x0,y0) defined in JxnTextPainter
        Parameters:
        xShift - shifts text horizontal in units of the text width
        yShift - shifts text vertical in units of the text height
        Returns:
        this
      • setShift

        public JxnTextPainter setShift​(int anchor)
        Shifts the text position using constants from class KmgGraphicsScaler.
        Example: setShift( KmgGraphicsScaler.NORTHEAST ) is equivalent to setShift(0.5,0.5)
        Returns:
        this
      • setSpace

        public JxnTextPainter setSpace​(int iSpace)
        Sets additional space. Relevant only together with setShift.
        Parameters:
        iSpace - additional shift by iSpace pixels in the direction defined by setShift
        Returns:
        this
      • setSpace

        public JxnTextPainter setSpace​(double space)
        Sets additional space. Relevant only together with setShift.
        Note: setSpace(double space) overrules a value set by setSpace(int iSpace)
        Parameters:
        space - additional shift in units of the text height in the direction defined by setShift
        Returns:
        this
      • paint

        public void paint​(KmgGraphicsScaler sk)
        Description copied from interface: KmgXYPainter
        Paints the graphical object (called internally).