Class GFFigureUtil
java.lang.Object
org.eclipse.graphiti.ui.internal.figures.GFFigureUtil
A utility class containing static helper-methods for Graphiti figures.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Boolean
containsPointInEllipse
(org.eclipse.draw2d.geometry.Rectangle r, int x, int y) Returns if the given point is contained in the ellipse defined by the bounding rectangle.static Boolean
containsPointInLine
(int x1, int y1, int x2, int y2, int x, int y, int lineWidth) Returns if the given point is contained in this line.static Boolean
containsPointInPolygon
(org.eclipse.draw2d.geometry.PointList points, int x, int y) Returns if the given point is contained in this polygon.static Boolean
containsPointInPolyline
(org.eclipse.draw2d.geometry.PointList points, int x, int y, int lineWidth) Returns if the given point is contained in this polyline.protected static void
drawRichText
(org.eclipse.draw2d.Graphics g, String draw, int x, int y, int bidiLevel, boolean mirrored, int currentOffset, IConfigurationProviderInternal configurationProvider, AbstractText text) static void
drawRichText
(org.eclipse.draw2d.Graphics g, String draw, int x, int y, IConfigurationProviderInternal configurationProvider, AbstractText text) static org.eclipse.draw2d.geometry.PointList
getAdjustedPointList
(org.eclipse.draw2d.geometry.PointList points, double zoom, double lw) Returns a new instance of the input point-list, which is adjusted regarding the given zoom-factor and line-width.static org.eclipse.draw2d.geometry.Rectangle
getAdjustedRectangle
(org.eclipse.draw2d.geometry.Rectangle rectangle, double zoom, int lw) Returns a new instance of the input rectangle zoomed by the zoom-level and shrinked by the half line-width.static org.eclipse.swt.graphics.Path
getBezierPath
(List<BezierPoint> origPoints, boolean isClosed) Returns a path which draws a bezier-curve through the given bezier-point-list.static org.eclipse.draw2d.geometry.Rectangle
getPathBounds
(org.eclipse.swt.graphics.Path path) Returns the rectangular bounds of a given Path.static org.eclipse.draw2d.geometry.PointList
getPointList
(Polyline polyline) Returns a draw2d point-list of the given polygon model-element.static org.eclipse.draw2d.geometry.PointList
getTranslatedPointList
(org.eclipse.draw2d.geometry.PointList points, int dx, int dy) Returns a new PointList, which results from translating the given PointList.static boolean
hasBezierDistance
(List<BezierPoint> points) Returns true, if at least one of the points in the list has a bezier-distance != 0.static void
paintColorFlow
(IResourceRegistryHolder registryHolder, org.eclipse.draw2d.geometry.Rectangle rectangle, org.eclipse.draw2d.Graphics graphics, GradientColoredArea coloredArea, double zoom, boolean vertical) Fills a given rectangle with a gradient color-flow on the given Graphics.
-
Constructor Details
-
GFFigureUtil
public GFFigureUtil()
-
-
Method Details
-
paintColorFlow
public static void paintColorFlow(IResourceRegistryHolder registryHolder, org.eclipse.draw2d.geometry.Rectangle rectangle, org.eclipse.draw2d.Graphics graphics, GradientColoredArea coloredArea, double zoom, boolean vertical) Fills a given rectangle with a gradient color-flow on the given Graphics. For this the rectangle is separated into several inner rectangles. Those inner rectangles are calculated from the given rectangle by percentage-values. Each inner rectangle has a start-color and end-color, which define the gradient of the color-flow.Example: The parameters [Color.red, Color.yellow, Color.green] and [0, 20, 80] would result in a filled rectangle, where the top 20% are flow from red to yellow and the next 80% flow from yellow to green.
- Parameters:
registryHolder
- To get theIResourceRegistry.getSwtColor(int, int, int)
.rectangle
- The rectangle, which to fill with the gradient color-flow.graphics
- The Graphics, on which to fill the rectangle.coloredArea
- The area of the rectangle and the colors used for filling.zoom
- The current zoom-levelvertical
- If true, fills the area vertically, otherwise horizontally
-
containsPointInEllipse
Returns if the given point is contained in the ellipse defined by the bounding rectangle. Possible results are- Boolean.TRUE = the point is located directly in the ellipse.
- Boolean.FALSE = the point is located outside the bounding box of the ellipse.
- null = the point is located inside the bounding box of the ellipse
- Parameters:
r
- The bounding-rectangle of the ellipse.x
- The x-coordinate of the point to check.y
- The y-coordinate of the point to check.- Returns:
- If the given point is contained in the ellipse defined by the bounding rectangle.
-
containsPointInLine
public static Boolean containsPointInLine(int x1, int y1, int x2, int y2, int x, int y, int lineWidth) Returns if the given point is contained in this line. Possible results are- Boolean.TRUE = the point is located directly on the line.
- Boolean.FALSE = the point is located outside the bounding box of the line.
- null = the point is located inside the bounding box of the line
- Parameters:
x1
- The x-coordinate of the start-point of the line.y1
- The y-coordinate of the start-point of the line.x2
- The x-coordinate of the end-point of the line.y2
- The y-coordinate of the end-point of the line.x
- The x-coordinate of the point to check.y
- The y-coordinate of the point to check.lineWidth
- The width of the line.- Returns:
- If the given point is contained in this line.
-
containsPointInPolyline
public static Boolean containsPointInPolyline(org.eclipse.draw2d.geometry.PointList points, int x, int y, int lineWidth) Returns if the given point is contained in this polyline. Possible results are- Boolean.TRUE = the point is located directly on the polyline.
- Boolean.FALSE = the point is located outside the bounding box of the polyline.
- null = the point is located inside the bounding box of the polyline
- Parameters:
points
- The points of the polyline.x
- The x-coordinate of the point to check.y
- The y-coordinate of the point to check.lineWidth
- The width of the line.- Returns:
- If the given point is contained in this polyline.
-
containsPointInPolygon
public static Boolean containsPointInPolygon(org.eclipse.draw2d.geometry.PointList points, int x, int y) Returns if the given point is contained in this polygon. Possible results are- Boolean.TRUE = the point is located directly in the polygon.
- Boolean.FALSE = the point is located outside the bounding box of the polygon.
- null = the point is located inside the bounding box of the polygon
- Parameters:
points
- The points of the polygon.x
- The x-coordinate of the point to check.y
- The y-coordinate of the point to check.- Returns:
- If the given point is contained in this polygon.
-
getPointList
Returns a draw2d point-list of the given polygon model-element.- Parameters:
polyline
- The polygon model-element for which to return the draw2d point-list.- Returns:
- A draw2d point-list of the given polygon model-element.
-
getPathBounds
public static org.eclipse.draw2d.geometry.Rectangle getPathBounds(org.eclipse.swt.graphics.Path path) Returns the rectangular bounds of a given Path.- Parameters:
path
- The Path for which to return the bounds.- Returns:
- The rectangular bounds of a given Path.
-
getAdjustedRectangle
public static org.eclipse.draw2d.geometry.Rectangle getAdjustedRectangle(org.eclipse.draw2d.geometry.Rectangle rectangle, double zoom, int lw) Returns a new instance of the input rectangle zoomed by the zoom-level and shrinked by the half line-width.- Parameters:
rectangle
- The rectangle to zoom and shrink.zoom
- The zoom-level to use.lw
- The line-width to use.- Returns:
- A new instance of the input rectangle zoomed by the zoom-level and shrinked by the half line-width. Returns null, if input rectangle is null.
-
getAdjustedPointList
public static org.eclipse.draw2d.geometry.PointList getAdjustedPointList(org.eclipse.draw2d.geometry.PointList points, double zoom, double lw) Returns a new instance of the input point-list, which is adjusted regarding the given zoom-factor and line-width. Concretely this means the following:- All points are zoomed by the given zoom-factor.
- All points are translated towards the center by half the line-width. This way the point-list stays insides its bounds even for a big line-width.
- Parameters:
points
- The point-list which to adjust.zoom
- The zoom-factor by which to zoom all points.lw
- The line-width, which to consider when translating towards the center.
-
getTranslatedPointList
public static org.eclipse.draw2d.geometry.PointList getTranslatedPointList(org.eclipse.draw2d.geometry.PointList points, int dx, int dy) Returns a new PointList, which results from translating the given PointList.- Parameters:
points
- The PointList, which is used as source for translation. It is not changed.dx
- The x-value to translate.dy
- The y-value to translate.- Returns:
- A new PointList, which results from translating the source PointList.
-
getBezierPath
public static org.eclipse.swt.graphics.Path getBezierPath(List<BezierPoint> origPoints, boolean isClosed) Returns a path which draws a bezier-curve through the given bezier-point-list.- Parameters:
origPoints
- The bezier-points through which to draw the bezier-curve.isClosed
- If true, then the path will be closed, so that the bezier-curve ends at the start-point. Note, that the result is different to a path with the same start/end point but where isClosed is false, because in that case there is no rounded corner at the start/end point.- Returns:
- A path which draws a bezier-curve through the given point-list.
-
hasBezierDistance
Returns true, if at least one of the points in the list has a bezier-distance != 0.- Parameters:
points
- The points, which bezier-distances to check.- Returns:
- true, if at least one of the points in the list has a bezier-distance != 0.
-
drawRichText
public static void drawRichText(org.eclipse.draw2d.Graphics g, String draw, int x, int y, IConfigurationProviderInternal configurationProvider, AbstractText text) -
drawRichText
protected static void drawRichText(org.eclipse.draw2d.Graphics g, String draw, int x, int y, int bidiLevel, boolean mirrored, int currentOffset, IConfigurationProviderInternal configurationProvider, AbstractText text)
-