|
Eclipse Draw2d 3.8.0.201206011245 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.draw2d.FigureUtilities
public class FigureUtilities
Provides miscellaneous Figure operations.
Constructor Summary | |
---|---|
FigureUtilities()
|
Method Summary | |
---|---|
static Color |
darker(Color 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, or null if there is no common ancestor. |
static FontMetrics |
getFontMetrics(Font f)
Returns the FontMetrics associated with the passed Font. |
protected static GC |
getGC()
Deprecated. do not mess with this GC |
static IFigure |
getRoot(IFigure figure)
Returns the highest ancestor for the given figure |
protected 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)
Returns true 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 |
lighter(Color rgb)
Returns a Color the same as the passed color in a lighter hue. |
static Shape |
makeGhostShape(Shape s)
Produces a ghosting effect on the shape s. |
static Color |
mixColors(Color c1,
Color c2)
Mixes the passed Colors and returns the resulting Color. |
static Color |
mixColors(Color c1,
Color c2,
double weight)
Mixes the passed Colors and returns the resulting Color. |
static void |
paintEtchedBorder(Graphics g,
Rectangle r)
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 |
paintGrid(Graphics g,
IFigure f,
Point origin,
int distanceX,
int distanceY)
Helper method to paint a grid. |
protected static void |
setFont(Font f)
Sets Font to passed value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FigureUtilities()
Method Detail |
---|
public static Color darker(Color color)
color
- the color to darken
public static FontMetrics getFontMetrics(Font f)
f
- the font
GC.getFontMetrics()
protected static GC getGC()
protected static Point getTextDimension(String s, Font f)
s
- the stringf
- the font
GC.textExtent(String)
public static IFigure getRoot(IFigure figure)
figure
- a figure
protected static Point getStringDimension(String s, Font f)
s
- the stringf
- the font
GC.stringExtent(java.lang.String)
public static Dimension getTextExtents(String text, Font f)
text
- the textf
- the font
public static Dimension getStringExtents(String s, Font f)
s
- the stringf
- the font
public static void getTextExtents(String s, Font f, Dimension result)
s
- the stringf
- the fontresult
- the Dimension that will contain the result of this calculationpublic static int getTextWidth(String s, Font f)
s
- the stringf
- the font
public static Color lighter(Color rgb)
rgb
- the color
public static Shape makeGhostShape(Shape s)
s
- the shape
public static Color mixColors(Color c1, Color c2, double weight)
c1
- the first colorc2
- the second colorweight
- the first color's weight from 0-1
public static Color mixColors(Color c1, Color c2)
c1
- the first colorc2
- the second color
public static void paintEtchedBorder(Graphics g, Rectangle r, Color shadow, Color highlight)
g
- the graphics objectr
- the bounds of the bordershadow
- the shadow colorhighlight
- the highlight colorpublic static void paintGrid(Graphics g, IFigure f, Point origin, int distanceX, int distanceY)
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 drawnpublic static void paintEtchedBorder(Graphics g, Rectangle r)
g
- the graphics objectr
- the bounds of the borderprotected static void setFont(Font f)
f
- the new fontpublic static IFigure findCommonAncestor(IFigure l, IFigure r)
null
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.
l
- leftr
- right
null
.public static boolean isAncestor(IFigure ancestor, IFigure descendant)
true
if the ancestor contains the descendant, or is
the ancestor of the descendant's parent.
ancestor
- the ancestordescendant
- the descendant
true
if ancestorpublic static boolean isNotFullyClipped(IFigure figure)
figure
- The figure to test
true
if the given figure is showing and not
completely clipped, false
otherwise.
|
Eclipse Draw2d 3.8.0.201206011245 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |