Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Draw2d
3.3

org.eclipse.draw2d
Class FigureUtilities

java.lang.Object
  extended by
org.eclipse.draw2d.FigureUtilities

public class FigureUtilities
extends java.lang.Object

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 ancestor of both figures, or null.
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 org.eclipse.swt.graphics.Point getStringDimension (java.lang.String s, Font f)
          Returns the dimensions of the String s using the font f.
static  Dimension getStringExtents (java.lang.String s, Font f)
          Returns the Dimensions of s in Font f.
protected static org.eclipse.swt.graphics.Point getTextDimension (java.lang.String s, Font f)
          Returns the dimensions of the String s using the font f.
static  Dimension getTextExtents (java.lang.String text, Font f)
          Returns the Dimensions of the given text, converting newlines and tabs appropriately.
static void getTextExtents (java.lang.String s, Font f, Dimension result)
          Returns the Dimensions of the given text, converting newlines and tabs appropriately.
static int getTextWidth (java.lang.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 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

FigureUtilities

public FigureUtilities()
Method Detail

darker

public static Color darker(Color color)
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

public static FontMetrics getFontMetrics(Font f)
Returns the FontMetrics associated with the passed Font.

Parameters:
f - the font
Returns:
the FontMetrics for the given font
Since:
2.0
See Also:
GC#getFontMetrics()

getGC

protected static GC getGC()
Deprecated. do not mess with this GC

Returns the GC used for various utilities. Advanced graphics must not be switched on by clients using this GC.

Returns:
the GC

getTextDimension

protected static org.eclipse.swt.graphics.Point getTextDimension(java.lang.String s,
                                                                 Font f)
Returns 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:
GC#textExtent(String)

getRoot

public static 
IFigure getRoot(
IFigure figure)
Returns the highest ancestor for the given figure

Parameters:
figure - a figure
Returns:
the root ancestor
Since:
3.0

getStringDimension

protected static org.eclipse.swt.graphics.Point getStringDimension(java.lang.String s,
                                                                   Font f)
Returns 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:
GC#stringExtent(java.lang.String)

getTextExtents

public static 
Dimension getTextExtents(java.lang.String text,
                                       Font f)
Returns 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

getStringExtents

public static 
Dimension getStringExtents(java.lang.String s,
                                         Font f)
Returns the Dimensions of s in Font f.

Parameters:
s - the string
f - the font
Returns:
the dimensions of the given string
Since:
2.0

getTextExtents

public static void getTextExtents(java.lang.String s,
                                  Font f,
                                  
Dimension result)
Returns 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

getTextWidth

public static int getTextWidth(java.lang.String s,
                               Font f)
Returns the width of s in Font f.

Parameters:
s - the string
f - the font
Returns:
the width
Since:
2.0

lighter

public static Color lighter(Color rgb)
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

public static 
Shape makeGhostShape(
Shape s)
Produces a ghosting effect on the shape s.

Parameters:
s - the shape
Returns:
the ghosted shape
Since:
2.0

mixColors

public static Color mixColors(Color c1,
                              Color c2,
                              double weight)
Mixes 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

mixColors

public static Color mixColors(Color c1,
                              Color c2)
Mixes the passed Colors and returns the resulting Color.

Parameters:
c1 - the first color
c2 - the second color
Returns:
the new color
Since:
2.0

paintEtchedBorder

public 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.

Parameters:
g - the graphics object
r - the bounds of the border
shadow - the shadow color
highlight - the highlight color
Since:
2.0

paintGrid

public static void paintGrid(
Graphics g,
                             
IFigure f,
                             
Point origin,
                             int distanceX,
                             int distanceY)
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 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

paintEtchedBorder

public 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.

Parameters:
g - the graphics object
r - the bounds of the border
Since:
2.0

setFont

protected static void setFont(Font f)
Sets Font to passed value.

Parameters:
f - the new font
Since:
2.0

findCommonAncestor

public static 
IFigure findCommonAncestor(
IFigure l,
                                         
IFigure r)
Returns the figure which is the ancestor of both figures, or null. 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 contains the other, null is returned.

Parameters:
l - left
r - right
Returns:
the common ancestor
Since:
3.1

isAncestor

public static boolean isAncestor(
IFigure ancestor,
                                 
IFigure descendant)
Returns true if the ancestor contains the descendant, or is the ancestor of the descendant's parent.

Parameters:
ancestor - the ancestor
descendant - the descendant
Returns:
true if ancestor
Since:
3.2

Eclipse Draw2d
3.3

Copyright (c) IBM Corp. and others 2000, 2007. All Rights Reserved.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire