Class GCStringPrinter

java.lang.Object
com.biglybt.ui.swt.shells.GCStringPrinter

public class GCStringPrinter extends Object
  • Field Details

    • ELLIPSIS

      private static final char ELLIPSIS
      See Also:
    • DEBUG

      private static final boolean DEBUG
      See Also:
    • GOOD_STRING

      private static final String GOOD_STRING
      See Also:
    • FLAG_SKIPCLIP

      public static final int FLAG_SKIPCLIP
      See Also:
    • FLAG_FULLLINESONLY

      public static final int FLAG_FULLLINESONLY
      See Also:
    • FLAG_NODRAW

      public static final int FLAG_NODRAW
      See Also:
    • FLAG_KEEP_URL_INFO

      public static final int FLAG_KEEP_URL_INFO
      See Also:
    • patHREF

      private static final Pattern patHREF
    • patAHREF_TITLE

      private static final Pattern patAHREF_TITLE
    • patAHREF_TARGET

      private static final Pattern patAHREF_TARGET
    • MAX_LINE_LEN

      private static final int MAX_LINE_LEN
      See Also:
    • MAX_WORD_LEN

      private static final int MAX_WORD_LEN
      See Also:
    • cutoff

      private boolean cutoff
    • truncated

      private boolean truncated
    • isWordCut

      private boolean isWordCut
    • gc

      private org.eclipse.swt.graphics.GC gc
    • string

      private String string
    • printArea

      private org.eclipse.swt.graphics.Rectangle printArea
    • swtFlags

      private int swtFlags
    • printFlags

      private int printFlags
    • size

      private org.eclipse.swt.graphics.Point size
    • preferredSize

      private org.eclipse.swt.graphics.Point preferredSize
    • urlColor

      private org.eclipse.swt.graphics.Color urlColor
    • listUrlInfo

      private List<GCStringPrinter.URLInfo> listUrlInfo
    • images

      private org.eclipse.swt.graphics.Image[] images
    • imageScales

      private float[] imageScales
    • iCurrentHeight

      private int iCurrentHeight
    • wrap

      private boolean wrap
    • drawRect

      private org.eclipse.swt.graphics.Rectangle drawRect
  • Constructor Details

    • GCStringPrinter

      public GCStringPrinter(org.eclipse.swt.graphics.GC gc, String string, org.eclipse.swt.graphics.Rectangle printArea, boolean skipClip, boolean fullLinesOnly, int swtFlags)
    • GCStringPrinter

      public GCStringPrinter(org.eclipse.swt.graphics.GC gc, String string, org.eclipse.swt.graphics.Rectangle printArea, int printFlags, int swtFlags)
  • Method Details

    • printString

      public static boolean printString(org.eclipse.swt.graphics.GC gc, String string, org.eclipse.swt.graphics.Rectangle printArea)
    • printString

      public static boolean printString(org.eclipse.swt.graphics.GC gc, String string, org.eclipse.swt.graphics.Rectangle printArea, boolean skipClip, boolean fullLinesOnly)
    • printString

      public static boolean printString(org.eclipse.swt.graphics.GC gc, String string, org.eclipse.swt.graphics.Rectangle printArea, boolean skipClip, boolean fullLinesOnly, int swtFlags)
      Parameters:
      gc - GC to print on
      string - Text to print
      printArea - Area of GC to print text to
      skipClip - Don't set any clipping on the GC. Text may overhang printArea when this is true
      fullLinesOnly - If bottom of a line will be chopped off, do not display it
      swtFlags - SWT flags. SWT.CENTER, SWT.BOTTOM, SWT.TOP, SWT.WRAP
      Returns:
      whether it fit
    • _printString

      private boolean _printString()
    • swt_printString_NoAdvanced

      private boolean swt_printString_NoAdvanced()
    • swt_printString

      private boolean swt_printString()
    • __printString

      private boolean __printString()
      Parameters:
      gc -
      string -
      printArea -
      printFlags -
      swtFlags -
      Returns:
      Since:
      3.0.4.3
    • processLine

      private GCStringPrinter.LineInfo processLine(org.eclipse.swt.graphics.GC gc, GCStringPrinter.LineInfo lineInfo, org.eclipse.swt.graphics.Rectangle printArea, boolean fullLinesOnly, boolean hasMoreElements, boolean isLastLine)
      Parameters:
      hasMoreElements -
      line -
      Since:
      3.0.0.7
    • truncate

      private void truncate(StringBuffer buffer, int len)
    • truncate

      private String truncate(String str)
    • processWord

      private int processWord(org.eclipse.swt.graphics.GC gc, String sLine, String word, org.eclipse.swt.graphics.Rectangle printArea, GCStringPrinter.LineInfo lineInfo, StringBuffer outputLine, StringBuffer space, boolean isLastLine)
      Parameters:
      int - Position of part of word that didn't fit
      Since:
      3.0.0.7
    • drawLine

      private void drawLine(org.eclipse.swt.graphics.GC gc, GCStringPrinter.LineInfo lineInfo, int swtFlags, org.eclipse.swt.graphics.Rectangle printArea, boolean noDraw)
      printArea is updated to the position of the next row
      Parameters:
      gc -
      outputLine -
      swtFlags -
      printArea -
      noDraw -
    • drawText

      private org.eclipse.swt.graphics.Point drawText(org.eclipse.swt.graphics.GC gc, String s, int x, int y, int height, List<org.eclipse.swt.graphics.Rectangle> hitAreas, boolean nodraw, boolean calcExtent)
    • stringExtent

      private static org.eclipse.swt.graphics.Point stringExtent(org.eclipse.swt.graphics.GC gc, String text)
    • textExtent

      private static org.eclipse.swt.graphics.Point textExtent(org.eclipse.swt.graphics.GC gc, String text)
    • drawText

      private static void drawText(org.eclipse.swt.graphics.GC gc, String text, int x, int y, boolean transparent)
    • main

      public static void main(String[] args)
    • printString

      public boolean printString()
    • printString

      public boolean printString(int _printFlags)
    • calculateMetrics

      public void calculateMetrics()
    • printString

      public void printString(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rectangle, int swtFlags)
      DO NOT REMOVE OR CHANGE RETURN TYPE -- USED BY PLUGINS
    • printString2

      public boolean printString2(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rectangle, int swtFlags)
    • getCalculatedSize

      public org.eclipse.swt.graphics.Point getCalculatedSize()
    • getCalculatedPreferredSize

      public org.eclipse.swt.graphics.Point getCalculatedPreferredSize()
    • getUrlColor

      public org.eclipse.swt.graphics.Color getUrlColor()
    • setUrlColor

      public void setUrlColor(org.eclipse.swt.graphics.Color urlColor)
    • getHitUrl

      public GCStringPrinter.URLInfo getHitUrl(int x, int y)
    • getHitUrlInfo

      public GCStringPrinter.URLInfo[] getHitUrlInfo()
    • hasHitUrl

      public boolean hasHitUrl()
    • isCutoff

      public boolean isCutoff()
    • isTruncated

      public boolean isTruncated()
    • setImages

      public void setImages(org.eclipse.swt.graphics.Image[] images)
    • getImageScales

      public float[] getImageScales()
    • setImageScales

      public void setImageScales(float[] imageScales)
    • getText

      public String getText()
      Returns:
      Since:
      4.0.0.1
    • isWordCut

      public boolean isWordCut()
    • getCalculatedDrawRect

      public org.eclipse.swt.graphics.Rectangle getCalculatedDrawRect()
      Get the area that was drawn to. Draw Rectangle is a subset of the original printArea that was painted on. In cases where text was centered vertically, or bottom aligned, y may be larger than printArea.y. x may be difference if text is centered or right aligned. Note: x is only adjusted if text is drawn.

      Returned width and height are the same as getCalculatedSize()

    • getPrintArea

      public org.eclipse.swt.graphics.Rectangle getPrintArea()