Package org.eclipse.graphiti.pattern
Class AbstractBasePattern
- java.lang.Object
-
- org.eclipse.graphiti.pattern.AbstractBasePattern
-
- All Implemented Interfaces:
IFeatureProviderHolder
- Direct Known Subclasses:
AbstractConnectionPattern
,AbstractPattern
public abstract class AbstractBasePattern extends java.lang.Object implements IFeatureProviderHolder
This is the abstract base class for patterns. Clients implementing own patterns should not subclass this class, but useAbstractPattern
orAbstractConnectionPattern
instead.
-
-
Constructor Summary
Constructors Constructor Description AbstractBasePattern()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PictogramElement
add(IAddContext context)
Clients must override this method to provide the functionality to add an existing domain object to a diagram.boolean
canAdd(IAddContext context)
Clients must override this method to indicate the framework that this pattern can add a domain object to the diagram.protected java.lang.Object
getBusinessObjectForPictogramElement(PictogramElement pe)
Helper method that resolves the domain object for the given pictogram element (shape).protected Diagram
getDiagram()
Returns theDiagram
this pattern lives for.protected IDiagramBehavior
getDiagramBehavior()
Returns the diagram behavior instance this pattern lives in.IFeatureProvider
getFeatureProvider()
Returns the feature provider for this pattern.protected IMappingProvider
getMappingProvider()
Returns theIMappingProvider
that can be used to map pictogram elements onto domain objects and vice versa.protected void
link(PictogramElement pe, java.lang.Object businessObject)
Helper method to link aPictogramElement
to a domain object.protected void
link(PictogramElement pe, java.lang.Object[] businessObjects)
Helper method to link aPictogramElement
to a number of domain objects.protected Color
manageColor(int red, int green, int blue)
A convenience method for the color handling which simply callsIGaService.manageColor(Diagram, int, int, int)
to manage aColor
used within theDiagram
.protected Color
manageColor(IColorConstant colorConstant)
A convenience method for the color handling which simply callsIGaService.manageColor(Diagram, IColorConstant)
to manage aColor
used within theDiagram
.protected Font
manageFont(java.lang.String name, int size)
A convenience method for theFont
handling which simply callsIGaService.manageFont(Diagram, String, int)
to manage aFont
used within theDiagram
.protected Font
manageFont(java.lang.String name, int size, boolean isItalic, boolean isBold)
A convenience method for theFont
handling which simply callsIGaService.manageFont(Diagram, String, int, boolean, boolean)
to manage aFont
used within theDiagram
.void
setFeatureProvider(IFeatureProvider featureProvider)
Sets the feature provider for this pattern.
-
-
-
Method Detail
-
add
public PictogramElement add(IAddContext context)
Clients must override this method to provide the functionality to add an existing domain object to a diagram. Corresponds to theIAdd.add(IAddContext)
method. The default implementation simply does nothing and returnsnull
.- Parameters:
context
- The add context holding information about the added domain object.- Returns:
- The root shape of the created pictogram tree.
-
canAdd
public boolean canAdd(IAddContext context)
Clients must override this method to indicate the framework that this pattern can add a domain object to the diagram. Corresponds to theIAdd.canAdd(IAddContext)
method. The default implementation simply returnsfalse
.- Parameters:
context
- The add context holding information about the added domain object.- Returns:
true
, if the domain object can be added,false
otherwise.
-
getFeatureProvider
public IFeatureProvider getFeatureProvider()
Returns the feature provider for this pattern.- Specified by:
getFeatureProvider
in interfaceIFeatureProviderHolder
- Returns:
- Returns the featureProvider.
-
setFeatureProvider
public void setFeatureProvider(IFeatureProvider featureProvider)
Sets the feature provider for this pattern. Note that once a feature provider has been set, it should not be changed again.- Parameters:
featureProvider
- The new featureProvider
-
getBusinessObjectForPictogramElement
protected java.lang.Object getBusinessObjectForPictogramElement(PictogramElement pe)
Helper method that resolves the domain object for the given pictogram element (shape).- Parameters:
pe
- The pictogram element for which a domain object shall be resolved.- Returns:
- The domain object for the given pictogram element or
null
in case none could be found.
-
getDiagramBehavior
protected IDiagramBehavior getDiagramBehavior()
Returns the diagram behavior instance this pattern lives in.- Returns:
- The diagram behavior
- Since:
- 0.10
-
getMappingProvider
protected IMappingProvider getMappingProvider()
Returns theIMappingProvider
that can be used to map pictogram elements onto domain objects and vice versa.- Returns:
- The mapping provider
-
link
protected void link(PictogramElement pe, java.lang.Object businessObject)
Helper method to link aPictogramElement
to a domain object.- Parameters:
pe
- The pictogram elementbusinessObject
- The domain object
-
link
protected void link(PictogramElement pe, java.lang.Object[] businessObjects)
Helper method to link aPictogramElement
to a number of domain objects.- Parameters:
pe
- The pictogram elementbusinessObjects
- The business objects as an array
-
getDiagram
protected Diagram getDiagram()
Returns theDiagram
this pattern lives for.- Returns:
- The diagram
-
manageColor
protected Color manageColor(IColorConstant colorConstant)
A convenience method for the color handling which simply callsIGaService.manageColor(Diagram, IColorConstant)
to manage aColor
used within theDiagram
.- Parameters:
colorConstant
- The color constant to manage.- Returns:
- The managed color.
-
manageColor
protected Color manageColor(int red, int green, int blue)
A convenience method for the color handling which simply callsIGaService.manageColor(Diagram, int, int, int)
to manage aColor
used within theDiagram
.- Parameters:
red
- The red portion of the color to manage.green
- The green portion of the color to manage.blue
- The blue portion of the color to manage.- Returns:
- The managed color.
-
manageFont
protected Font manageFont(java.lang.String name, int size)
A convenience method for theFont
handling which simply callsIGaService.manageFont(Diagram, String, int)
to manage aFont
used within theDiagram
.- Parameters:
name
- The name of the font.size
- The size of the font.- Returns:
- The managed font instance.
- Since:
- 0.9
-
manageFont
protected Font manageFont(java.lang.String name, int size, boolean isItalic, boolean isBold)
A convenience method for theFont
handling which simply callsIGaService.manageFont(Diagram, String, int, boolean, boolean)
to manage aFont
used within theDiagram
.- Parameters:
name
- The name of the font.size
- The size of the font.isItalic
- The italic flag of the font.isBold
- The bold flag of the font.- Returns:
- The managed font instance.
- Since:
- 0.9
-
-