Package com.biglybt.ui.swt.shells
Class GCStringPrinter
- java.lang.Object
-
- com.biglybt.ui.swt.shells.GCStringPrinter
-
public class GCStringPrinter extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
GCStringPrinter.LineInfo
static class
GCStringPrinter.URLInfo
-
Field Summary
Fields Modifier and Type Field Description private boolean
cutoff
private static boolean
DEBUG
private org.eclipse.swt.graphics.Rectangle
drawRect
private static char
ELLIPSIS
static int
FLAG_FULLLINESONLY
static int
FLAG_KEEP_URL_INFO
static int
FLAG_NODRAW
static int
FLAG_SKIPCLIP
private org.eclipse.swt.graphics.GC
gc
private static java.lang.String
GOOD_STRING
private int
iCurrentHeight
private org.eclipse.swt.graphics.Image[]
images
private float[]
imageScales
private boolean
isWordCut
private java.util.List<GCStringPrinter.URLInfo>
listUrlInfo
private static int
MAX_LINE_LEN
private static int
MAX_WORD_LEN
private static java.util.regex.Pattern
patAHREF_TARGET
private static java.util.regex.Pattern
patAHREF_TITLE
private static java.util.regex.Pattern
patHREF
private org.eclipse.swt.graphics.Point
preferredSize
private org.eclipse.swt.graphics.Rectangle
printArea
private int
printFlags
private org.eclipse.swt.graphics.Point
size
private java.lang.String
string
private int
swtFlags
private boolean
truncated
private org.eclipse.swt.graphics.Color
urlColor
private boolean
wrap
-
Constructor Summary
Constructors Constructor Description GCStringPrinter(org.eclipse.swt.graphics.GC gc, java.lang.String string, org.eclipse.swt.graphics.Rectangle printArea, boolean skipClip, boolean fullLinesOnly, int swtFlags)
GCStringPrinter(org.eclipse.swt.graphics.GC gc, java.lang.String string, org.eclipse.swt.graphics.Rectangle printArea, int printFlags, int swtFlags)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
__printString()
private boolean
_printString()
void
calculateMetrics()
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 rowprivate static void
drawText(org.eclipse.swt.graphics.GC gc, java.lang.String text, int x, int y, boolean transparent)
private org.eclipse.swt.graphics.Point
drawText(org.eclipse.swt.graphics.GC gc, java.lang.String s, int x, int y, int height, java.util.List<org.eclipse.swt.graphics.Rectangle> hitAreas, boolean nodraw, boolean calcExtent)
org.eclipse.swt.graphics.Rectangle
getCalculatedDrawRect()
Get the area that was drawn to.org.eclipse.swt.graphics.Point
getCalculatedPreferredSize()
org.eclipse.swt.graphics.Point
getCalculatedSize()
GCStringPrinter.URLInfo
getHitUrl(int x, int y)
GCStringPrinter.URLInfo[]
getHitUrlInfo()
float[]
getImageScales()
org.eclipse.swt.graphics.Rectangle
getPrintArea()
java.lang.String
getText()
org.eclipse.swt.graphics.Color
getUrlColor()
boolean
hasHitUrl()
boolean
isCutoff()
boolean
isTruncated()
boolean
isWordCut()
static void
main(java.lang.String[] args)
boolean
printString()
boolean
printString(int _printFlags)
static boolean
printString(org.eclipse.swt.graphics.GC gc, java.lang.String string, org.eclipse.swt.graphics.Rectangle printArea)
static boolean
printString(org.eclipse.swt.graphics.GC gc, java.lang.String string, org.eclipse.swt.graphics.Rectangle printArea, boolean skipClip, boolean fullLinesOnly)
static boolean
printString(org.eclipse.swt.graphics.GC gc, java.lang.String string, org.eclipse.swt.graphics.Rectangle printArea, boolean skipClip, boolean fullLinesOnly, int swtFlags)
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 PLUGINSboolean
printString2(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rectangle, int swtFlags)
private GCStringPrinter.LineInfo
processLine(org.eclipse.swt.graphics.GC gc, GCStringPrinter.LineInfo lineInfo, org.eclipse.swt.graphics.Rectangle printArea, boolean fullLinesOnly, boolean hasMoreElements)
private int
processWord(org.eclipse.swt.graphics.GC gc, java.lang.String sLine, java.lang.String word, org.eclipse.swt.graphics.Rectangle printArea, GCStringPrinter.LineInfo lineInfo, java.lang.StringBuffer outputLine, java.lang.StringBuffer space)
void
setImages(org.eclipse.swt.graphics.Image[] images)
void
setImageScales(float[] imageScales)
void
setUrlColor(org.eclipse.swt.graphics.Color urlColor)
private static org.eclipse.swt.graphics.Point
stringExtent(org.eclipse.swt.graphics.GC gc, java.lang.String text)
private boolean
swt_printString()
private boolean
swt_printString_NoAdvanced()
private static org.eclipse.swt.graphics.Point
textExtent(org.eclipse.swt.graphics.GC gc, java.lang.String text)
private java.lang.String
truncate(java.lang.String str)
private void
truncate(java.lang.StringBuffer buffer, int len)
-
-
-
Field Detail
-
ELLIPSIS
private static final char ELLIPSIS
- See Also:
- Constant Field Values
-
DEBUG
private static final boolean DEBUG
- See Also:
- Constant Field Values
-
GOOD_STRING
private static final java.lang.String GOOD_STRING
- See Also:
- Constant Field Values
-
FLAG_SKIPCLIP
public static final int FLAG_SKIPCLIP
- See Also:
- Constant Field Values
-
FLAG_FULLLINESONLY
public static final int FLAG_FULLLINESONLY
- See Also:
- Constant Field Values
-
FLAG_NODRAW
public static final int FLAG_NODRAW
- See Also:
- Constant Field Values
-
FLAG_KEEP_URL_INFO
public static final int FLAG_KEEP_URL_INFO
- See Also:
- Constant Field Values
-
patHREF
private static final java.util.regex.Pattern patHREF
-
patAHREF_TITLE
private static final java.util.regex.Pattern patAHREF_TITLE
-
patAHREF_TARGET
private static final java.util.regex.Pattern patAHREF_TARGET
-
MAX_LINE_LEN
private static final int MAX_LINE_LEN
- See Also:
- Constant Field Values
-
MAX_WORD_LEN
private static final int MAX_WORD_LEN
- See Also:
- Constant Field Values
-
cutoff
private boolean cutoff
-
truncated
private boolean truncated
-
isWordCut
private boolean isWordCut
-
gc
private org.eclipse.swt.graphics.GC gc
-
string
private java.lang.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 java.util.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 Detail
-
GCStringPrinter
public GCStringPrinter(org.eclipse.swt.graphics.GC gc, java.lang.String string, org.eclipse.swt.graphics.Rectangle printArea, boolean skipClip, boolean fullLinesOnly, int swtFlags)
-
GCStringPrinter
public GCStringPrinter(org.eclipse.swt.graphics.GC gc, java.lang.String string, org.eclipse.swt.graphics.Rectangle printArea, int printFlags, int swtFlags)
-
-
Method Detail
-
printString
public static boolean printString(org.eclipse.swt.graphics.GC gc, java.lang.String string, org.eclipse.swt.graphics.Rectangle printArea)
-
printString
public static boolean printString(org.eclipse.swt.graphics.GC gc, java.lang.String string, org.eclipse.swt.graphics.Rectangle printArea, boolean skipClip, boolean fullLinesOnly)
-
printString
public static boolean printString(org.eclipse.swt.graphics.GC gc, java.lang.String string, org.eclipse.swt.graphics.Rectangle printArea, boolean skipClip, boolean fullLinesOnly, int swtFlags)
- Parameters:
gc
- GC to print onstring
- Text to printprintArea
- Area of GC to print text toskipClip
- Don't set any clipping on the GC. Text may overhang printArea when this is truefullLinesOnly
- If bottom of a line will be chopped off, do not display itswtFlags
- 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)
- Parameters:
hasMoreElements
-line
-- Since:
- 3.0.0.7
-
truncate
private void truncate(java.lang.StringBuffer buffer, int len)
-
truncate
private java.lang.String truncate(java.lang.String str)
-
processWord
private int processWord(org.eclipse.swt.graphics.GC gc, java.lang.String sLine, java.lang.String word, org.eclipse.swt.graphics.Rectangle printArea, GCStringPrinter.LineInfo lineInfo, java.lang.StringBuffer outputLine, java.lang.StringBuffer space)
- 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, java.lang.String s, int x, int y, int height, java.util.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, java.lang.String text)
-
textExtent
private static org.eclipse.swt.graphics.Point textExtent(org.eclipse.swt.graphics.GC gc, java.lang.String text)
-
drawText
private static void drawText(org.eclipse.swt.graphics.GC gc, java.lang.String text, int x, int y, boolean transparent)
-
main
public static void main(java.lang.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 java.lang.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 asgetCalculatedSize()
-
getPrintArea
public org.eclipse.swt.graphics.Rectangle getPrintArea()
-
-