Package org.eclipse.draw2d
Class FigureUtilities
java.lang.Object
org.eclipse.draw2d.FigureUtilities
Provides miscellaneous Figure operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Color
Returns a new Color the same as the passed color in a darker hue.static IFigure
findCommonAncestor
(IFigure l, IFigure r) Returns the figure which is the nearest common ancestor of both figures, ornull
if there is no common ancestor.static FontMetrics
Returns the FontMetrics associated with the passed Font.protected static GC
getGC()
Deprecated.do not mess with this GCstatic IFigure
Returns the highest ancestor for the given figureprotected static Point
getStringDimension
(String s, Font f) Returns the dimensions of the String s using the font f.static Dimension
getStringExtents
(String s, Font f) Returns the Dimensions of s in Font f.protected static Point
getTextDimension
(String s, Font f) Returns the dimensions of the String s using the font f.static Dimension
getTextExtents
(String text, Font f) Returns the Dimensions of the given text, converting newlines and tabs appropriately.static void
getTextExtents
(String s, Font f, Dimension result) Returns the Dimensions of the given text, converting newlines and tabs appropriately.static int
getTextWidth
(String s, Font f) Returns the width of s in Font f.static boolean
isAncestor
(IFigure ancestor, IFigure descendant) Returnstrue
if the ancestor contains the descendant, or is the ancestor of the descendant's parent.static boolean
isNotFullyClipped
(IFigure figure) Determines whether the given figure is showing and not (completely) clipped.static Color
Returns a Color the same as the passed color in a lighter hue.static Shape
Produces a ghosting effect on the shape s.static Color
Mixes the passed Colors and returns the resulting Color.static Color
Mixes the passed Colors and returns the resulting Color.static void
Paints 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 void
paintEtchedBorder
(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 void
Helper method to paint a grid.protected static void
Sets Font to passed value.
-
Constructor Details
-
FigureUtilities
public FigureUtilities()
-
-
Method Details
-
darker
Returns 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
-
getFontMetrics
Returns the FontMetrics associated with the passed Font.- Parameters:
f
- the font- Returns:
- the FontMetrics for the given font
- Since:
- 2.0
- See Also:
-
getGC
Deprecated.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
-
getTextDimension
Returns the dimensions of the String s using the font f. Tab expansion and carriage return processing are performed.- Parameters:
s
- the stringf
- the font- Returns:
- the text's dimensions
- See Also:
-
getRoot
Returns the highest ancestor for the given figure- Parameters:
figure
- a figure- Returns:
- the root ancestor
- Since:
- 3.0
-
getStringDimension
Returns the dimensions of the String s using the font f. No tab expansion or carriage return processing will be performed.- Parameters:
s
- the stringf
- the font- Returns:
- the string's dimensions
- See Also:
-
getTextExtents
Returns the Dimensions of the given text, converting newlines and tabs appropriately.- Parameters:
text
- the textf
- the font- Returns:
- the dimensions of the given text
- Since:
- 2.0
-
getStringExtents
Returns the Dimensions of s in Font f.- Parameters:
s
- the stringf
- the font- Returns:
- the dimensions of the given string
- Since:
- 2.0
-
getTextExtents
Returns the Dimensions of the given text, converting newlines and tabs appropriately.- Parameters:
s
- the stringf
- the fontresult
- the Dimension that will contain the result of this calculation- Since:
- 2.0
-
getTextWidth
Returns the width of s in Font f.- Parameters:
s
- the stringf
- the font- Returns:
- the width
- Since:
- 2.0
-
lighter
Returns a Color the same as the passed color in a lighter hue.- Parameters:
rgb
- the color- Returns:
- the lighter color
- Since:
- 2.0
-
makeGhostShape
Produces a ghosting effect on the shape s.- Parameters:
s
- the shape- Returns:
- the ghosted shape
- Since:
- 2.0
-
mixColors
Mixes the passed Colors and returns the resulting Color.- Parameters:
c1
- the first colorc2
- the second colorweight
- the first color's weight from 0-1- Returns:
- the new color
- Since:
- 2.0
-
mixColors
Mixes the passed Colors and returns the resulting Color.- Parameters:
c1
- the first colorc2
- the second color- Returns:
- the new color
- Since:
- 2.0
-
paintEtchedBorder
Paints a border with an etching effect, having a shadow of Color shadow and highlight of Color highlight.- Parameters:
g
- the graphics objectr
- the bounds of the bordershadow
- the shadow colorhighlight
- the highlight color- Since:
- 2.0
-
paintGrid
Helper 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 paintingf
- The figure in which the grid is to be paintedorigin
- Any point where the grid lines are expected to intersectdistanceX
- Distance between vertical grid lines; if 0 or less, vertical grid lines will not be drawndistanceY
- Distance between horizontal grid lines; if 0 or less, horizontal grid lines will not be drawn- Since:
- 3.0
-
paintEtchedBorder
Paints 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 objectr
- the bounds of the border- Since:
- 2.0
-
setFont
Sets Font to passed value.- Parameters:
f
- the new font- Since:
- 2.0
-
findCommonAncestor
Returns the figure which is the nearest common ancestor of both figures, ornull
if 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
- leftr
- right- Returns:
- the common ancestor, if it exists, or
null
. - Since:
- 3.1
-
isAncestor
Returnstrue
if the ancestor contains the descendant, or is the ancestor of the descendant's parent.- Parameters:
ancestor
- the ancestordescendant
- the descendant- Returns:
true
if ancestor- Since:
- 3.2
-
isNotFullyClipped
Determines whether the given figure is showing and not (completely) clipped.- Parameters:
figure
- The figure to test- Returns:
true
if the given figure is showing and not completely clipped,false
otherwise.- Since:
- 3.7
-