Package org.eclipse.draw2d
Class FigureUtilities
java.lang.Object
org.eclipse.draw2d.FigureUtilities
Provides miscellaneous Figure operations.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic ColorReturns a new Color the same as the passed color in a darker hue.static IFigurefindCommonAncestor(IFigure l, IFigure r) Returns the figure which is the nearest common ancestor of both figures, ornullif there is no common ancestor.static FontMetricsReturns the FontMetrics associated with the passed Font.protected static GCgetGC()Deprecated.do not mess with this GCstatic IFigureReturns the highest ancestor for the given figureprotected static PointgetStringDimension(String s, Font f) Returns the dimensions of the String s using the font f.static DimensiongetStringExtents(String s, Font f) Returns the Dimensions of s in Font f.protected static PointgetTextDimension(String s, Font f) Returns the dimensions of the String s using the font f.static DimensiongetTextExtents(String text, Font f) Returns the Dimensions of the given text, converting newlines and tabs appropriately.static voidgetTextExtents(String s, Font f, Dimension result) Returns the Dimensions of the given text, converting newlines and tabs appropriately.static intgetTextWidth(String s, Font f) Returns the width of s in Font f.static booleanisAncestor(IFigure ancestor, IFigure descendant) Returnstrueif the ancestor contains the descendant, or is the ancestor of the descendant's parent.static booleanisNotFullyClipped(IFigure figure) Determines whether the given figure is showing and not (completely) clipped.static ColorReturns a Color the same as the passed color in a lighter hue.static ShapeProduces a ghosting effect on the shape s.static ColorMixes the passed Colors and returns the resulting Color.static ColorMixes the passed Colors and returns the resulting Color.static voidPaints a border with an etching effect, having a shadow of a darker version of g's background color, and a highlight a lighter version of g's background color.static voidpaintEtchedBorder(Graphics g, Rectangle r, Color shadow, Color highlight) Paints a border with an etching effect, having a shadow of Color shadow and highlight of Color highlight.static voidHelper method to paint a grid.protected static voidSets Font to passed value.
- 
Constructor Details- 
FigureUtilitiespublic FigureUtilities()
 
- 
- 
Method Details- 
darkerReturns a new Color the same as the passed color in a darker hue.- Parameters:
- color- the color to darken
- Returns:
- the darkened color
- Since:
- 2.0
 
- 
getFontMetricsReturns the FontMetrics associated with the passed Font.- Parameters:
- f- the font
- Returns:
- the FontMetrics for the given font
- Since:
- 2.0
- See Also:
 
- 
getGCDeprecated.do not mess with this GCReturns the GC used for various utilities. Advanced graphics must not be switched on by clients using this GC.- Returns:
- the GC
 
- 
getTextDimensionReturns the dimensions of the String s using the font f. Tab expansion and carriage return processing are performed.- Parameters:
- s- the string
- f- the font
- Returns:
- the text's dimensions
- See Also:
 
- 
getRootReturns the highest ancestor for the given figure- Parameters:
- figure- a figure
- Returns:
- the root ancestor
- Since:
- 3.0
 
- 
getStringDimensionReturns the dimensions of the String s using the font f. No tab expansion or carriage return processing will be performed.- Parameters:
- s- the string
- f- the font
- Returns:
- the string's dimensions
- See Also:
 
- 
getTextExtentsReturns the Dimensions of the given text, converting newlines and tabs appropriately.- Parameters:
- text- the text
- f- the font
- Returns:
- the dimensions of the given text
- Since:
- 2.0
 
- 
getStringExtentsReturns the Dimensions of s in Font f.- Parameters:
- s- the string
- f- the font
- Returns:
- the dimensions of the given string
- Since:
- 2.0
 
- 
getTextExtentsReturns the Dimensions of the given text, converting newlines and tabs appropriately.- Parameters:
- s- the string
- f- the font
- result- the Dimension that will contain the result of this calculation
- Since:
- 2.0
 
- 
getTextWidthReturns the width of s in Font f.- Parameters:
- s- the string
- f- the font
- Returns:
- the width
- Since:
- 2.0
 
- 
lighterReturns a Color the same as the passed color in a lighter hue.- Parameters:
- rgb- the color
- Returns:
- the lighter color
- Since:
- 2.0
 
- 
makeGhostShapeProduces a ghosting effect on the shape s.- Parameters:
- s- the shape
- Returns:
- the ghosted shape
- Since:
- 2.0
 
- 
mixColorsMixes the passed Colors and returns the resulting Color.- Parameters:
- c1- the first color
- c2- the second color
- weight- the first color's weight from 0-1
- Returns:
- the new color
- Since:
- 2.0
 
- 
mixColorsMixes the passed Colors and returns the resulting Color.- Parameters:
- c1- the first color
- c2- the second color
- Returns:
- the new color
- Since:
- 2.0
 
- 
paintEtchedBorderPaints a border with an etching effect, having a shadow of Color shadow and highlight of Color highlight.- Parameters:
- g- the graphics object
- r- the bounds of the border
- shadow- the shadow color
- highlight- the highlight color
- Since:
- 2.0
 
- 
paintGridHelper method to paint a grid. Painting is optimized as it is restricted to the Graphics' clip.- Parameters:
- g- The Graphics object to be used for painting
- f- The figure in which the grid is to be painted
- origin- Any point where the grid lines are expected to intersect
- distanceX- Distance between vertical grid lines; if 0 or less, vertical grid lines will not be drawn
- distanceY- Distance between horizontal grid lines; if 0 or less, horizontal grid lines will not be drawn
- Since:
- 3.0
 
- 
paintEtchedBorderPaints a border with an etching effect, having a shadow of a darker version of g's background color, and a highlight a lighter version of g's background color.- Parameters:
- g- the graphics object
- r- the bounds of the border
- Since:
- 2.0
 
- 
setFontSets Font to passed value.- Parameters:
- f- the new font
- Since:
- 2.0
 
- 
findCommonAncestorReturns the figure which is the nearest common ancestor of both figures, ornullif there is no common ancestor. A figure is an ancestor if it is the parent of another figure, or if it is the ancestor of that figure's parent. If one figure is the ancestor of the other, it is returned as the common ancestor.- Parameters:
- l- left
- r- right
- Returns:
- the common ancestor, if it exists, or null.
- Since:
- 3.1
 
- 
isAncestorReturnstrueif the ancestor contains the descendant, or is the ancestor of the descendant's parent.- Parameters:
- ancestor- the ancestor
- descendant- the descendant
- Returns:
- trueif ancestor
- Since:
- 3.2
 
- 
isNotFullyClippedDetermines whether the given figure is showing and not (completely) clipped.- Parameters:
- figure- The figure to test
- Returns:
- trueif the given figure is showing and not completely clipped,- falseotherwise.
- Since:
- 3.7
 
 
-