org.openbp.cockpit.modeler.util
Class FigureUtil

java.lang.Object
  extended by org.openbp.cockpit.modeler.util.FigureUtil

public class FigureUtil
extends java.lang.Object

Figure utility methods.

Author:
Heiko Erhardt

Method Summary
static java.awt.Image combineImages(java.awt.Image base, java.awt.Image overlay, int x, int y, int overlayWidth, int overlayHeight)
          Combines two images into a single one by overlaying the base image with the overlay image.
static java.awt.Image copyImage(java.awt.Image image)
          Copies an image.
static XFigure createShadowFigure(XFigure presentationFigure)
          Creates a shadow figure by cloning the given presentation figure.
static Skin determineProcessSkin(ProcessItem process)
          Gets the skin to use for the given process.
static CH.ifa.draw.framework.Figure findChildFigure(CH.ifa.draw.framework.Figure figure, int x, int y, java.lang.Class figureClass)
          Finds a (direct) child figure within the given figure.
static CH.ifa.draw.framework.Figure findInnermostFigure(CH.ifa.draw.framework.Figure figure, int x, int y, java.lang.Class figureClass)
          Finds the figure that contains the given point within the given figure.
static SymbolDescriptor getSymbolDescriptorForModelObject(Skin skin, ModelObject o)
          Gets the symbol descriptor from the given skin that can be used to display the given model object.
static java.util.List getTypedFigureList(CH.ifa.draw.framework.Figure parentFigure, java.lang.Class figureClass)
          Creates a list of figures that match the given type.
static boolean isVerticalRelationship(CH.ifa.draw.framework.Figure f1, CH.ifa.draw.framework.Figure f2)
          Checks if two figures relate rather vertical or horizontal.
static java.lang.String printInt(double d)
          Prints a double value as an integer.
static boolean synchronizeText(TitleFigure figure)
          Synchronizes a title figure with the text of its associated content object.
static void updateItemGeometry(Skin skin, Item item)
          Updates the geometry string of an item according to the number of sockets that are connected to the item.
static void updateSkin(CH.ifa.draw.framework.Figure figure)
          Updates the figure according to the currently selected skin.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findInnermostFigure

public static CH.ifa.draw.framework.Figure findInnermostFigure(CH.ifa.draw.framework.Figure figure,
                                                               int x,
                                                               int y,
                                                               java.lang.Class figureClass)
Finds the figure that contains the given point within the given figure. If the given figure is composite figure, the method will return the direct or indirect child figure that contains the point and is the deepest figure in the figure hierarchy.

Parameters:
figure - Parent figure
x - X coordinate of the point
y - Y coordinate of the point
figureClass - Figure class if a child figure of a particular type should be retrieved or null for any type of child figure
Returns:
The figure or null if the point does not lie within the figure or its sub figures

findChildFigure

public static CH.ifa.draw.framework.Figure findChildFigure(CH.ifa.draw.framework.Figure figure,
                                                           int x,
                                                           int y,
                                                           java.lang.Class figureClass)
Finds a (direct) child figure within the given figure.

Parameters:
figure - Parent figure
x - X coordinate of the point
y - Y coordinate of the point
figureClass - Figure class if a child figure of a particular type should be retrieved or null for any type of child figure
Returns:
The child figure if the given figure is a composite figure and there is a child figure that contains the given point or null if no such child figure exists

getTypedFigureList

public static java.util.List getTypedFigureList(CH.ifa.draw.framework.Figure parentFigure,
                                                java.lang.Class figureClass)
Creates a list of figures that match the given type.

Parameters:
parentFigure - Parent figure to enumerate
figureClass - Class of the figures to return
Returns:
The list or null if no appropiate figures have been found

createShadowFigure

public static XFigure createShadowFigure(XFigure presentationFigure)
Creates a shadow figure by cloning the given presentation figure.

Parameters:
presentationFigure - Presentation figure to clone
Returns:
The shadow figure
The fill and frame color attributes will be adjusted accordingly. The 'IsShadow' attribute will be set to true. If the figure is a child figure, it won't have a parent figure assigned.

isVerticalRelationship

public static boolean isVerticalRelationship(CH.ifa.draw.framework.Figure f1,
                                             CH.ifa.draw.framework.Figure f2)
Checks if two figures relate rather vertical or horizontal.

Parameters:
f1 - Event
f2 - Event
Returns:
true: The vertical distance between the figures is greater than the horizontal one.
false: Otherwise

synchronizeText

public static boolean synchronizeText(TitleFigure figure)
Synchronizes a title figure with the text of its associated content object.

Parameters:
figure - Figure to updateFigure
Returns:
true: The text of the figure has changed.
false: No text change

combineImages

public static java.awt.Image combineImages(java.awt.Image base,
                                           java.awt.Image overlay,
                                           int x,
                                           int y,
                                           int overlayWidth,
                                           int overlayHeight)
Combines two images into a single one by overlaying the base image with the overlay image. If the specified position would cause the overlay image to appear out of the bounds of the base image, the position will be adjusted automatically.

Parameters:
base - Base image
overlay - Overlay image
x - X position of overlay image
y - Y position of overlay image
overlayWidth - Width of the overlay image; 0 for its regular size
overlayHeight - height of the overlay image; 0 for its regular size
Returns:
The new combined image or null on error

copyImage

public static java.awt.Image copyImage(java.awt.Image image)
Copies an image.

Parameters:
image - Image to copy
Returns:
The copied image or null on error

determineProcessSkin

public static Skin determineProcessSkin(ProcessItem process)
Gets the skin to use for the given process.

Parameters:
process - Process
Returns:
the skin

updateSkin

public static void updateSkin(CH.ifa.draw.framework.Figure figure)
Updates the figure according to the currently selected skin.

Parameters:
figure - Figure to update

getSymbolDescriptorForModelObject

public static SymbolDescriptor getSymbolDescriptorForModelObject(Skin skin,
                                                                 ModelObject o)
Gets the symbol descriptor from the given skin that can be used to display the given model object.

Parameters:
skin - Process skin
o - Object to display
Returns:
The symbol descriptor

updateItemGeometry

public static void updateItemGeometry(Skin skin,
                                      Item item)
Updates the geometry string of an item according to the number of sockets that are connected to the item.

Parameters:
skin - Process skin used for display or null for the default skin
item - Item to update

printInt

public static java.lang.String printInt(double d)
Prints a double value as an integer. Performs appropriate rounding.



Copyright © 2011. All Rights Reserved.