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 useAbstractPatternorAbstractConnectionPatterninstead.
-
-
Constructor Summary
Constructors Constructor Description AbstractBasePattern()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PictogramElementadd(IAddContext context)Clients must override this method to provide the functionality to add an existing domain object to a diagram.booleancanAdd(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.ObjectgetBusinessObjectForPictogramElement(PictogramElement pe)Helper method that resolves the domain object for the given pictogram element (shape).protected DiagramgetDiagram()Returns theDiagramthis pattern lives for.protected IDiagramBehaviorgetDiagramBehavior()Returns the diagram behavior instance this pattern lives in.IFeatureProvidergetFeatureProvider()Returns the feature provider for this pattern.protected IMappingProvidergetMappingProvider()Returns theIMappingProviderthat can be used to map pictogram elements onto domain objects and vice versa.protected voidlink(PictogramElement pe, java.lang.Object businessObject)Helper method to link aPictogramElementto a domain object.protected voidlink(PictogramElement pe, java.lang.Object[] businessObjects)Helper method to link aPictogramElementto a number of domain objects.protected ColormanageColor(int red, int green, int blue)A convenience method for the color handling which simply callsIGaService.manageColor(Diagram, int, int, int)to manage aColorused within theDiagram.protected ColormanageColor(IColorConstant colorConstant)A convenience method for the color handling which simply callsIGaService.manageColor(Diagram, IColorConstant)to manage aColorused within theDiagram.protected FontmanageFont(java.lang.String name, int size)A convenience method for theFonthandling which simply callsIGaService.manageFont(Diagram, String, int)to manage aFontused within theDiagram.protected FontmanageFont(java.lang.String name, int size, boolean isItalic, boolean isBold)A convenience method for theFonthandling which simply callsIGaService.manageFont(Diagram, String, int, boolean, boolean)to manage aFontused within theDiagram.voidsetFeatureProvider(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,falseotherwise.
-
getFeatureProvider
public IFeatureProvider getFeatureProvider()
Returns the feature provider for this pattern.- Specified by:
getFeatureProviderin 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
nullin 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 theIMappingProviderthat 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 aPictogramElementto 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 aPictogramElementto a number of domain objects.- Parameters:
pe- The pictogram elementbusinessObjects- The business objects as an array
-
getDiagram
protected Diagram getDiagram()
Returns theDiagramthis 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 aColorused 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 aColorused 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 theFonthandling which simply callsIGaService.manageFont(Diagram, String, int)to manage aFontused 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 theFonthandling which simply callsIGaService.manageFont(Diagram, String, int, boolean, boolean)to manage aFontused 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
-
-