Package org.eclipse.graphiti.pattern
Class AbstractBasePattern
java.lang.Object
org.eclipse.graphiti.pattern.AbstractBasePattern
- All Implemented Interfaces:
IFeatureProviderHolder
- Direct Known Subclasses:
AbstractConnectionPattern
,AbstractPattern
This is the abstract base class for patterns. Clients implementing own
patterns should not subclass this class, but use
AbstractPattern
or
AbstractConnectionPattern
instead.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd
(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 Object
Helper method that resolves the domain object for the given pictogram element (shape).protected Diagram
Returns theDiagram
this pattern lives for.protected IDiagramBehavior
Returns the diagram behavior instance this pattern lives in.Returns the feature provider for this pattern.protected IMappingProvider
Returns theIMappingProvider
that can be used to map pictogram elements onto domain objects and vice versa.protected void
link
(PictogramElement pe, Object businessObject) Helper method to link aPictogramElement
to a domain object.protected void
link
(PictogramElement pe, 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
(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
(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.
-
Constructor Details
-
AbstractBasePattern
public AbstractBasePattern()
-
-
Method Details
-
add
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
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
Returns the feature provider for this pattern.- Specified by:
getFeatureProvider
in interfaceIFeatureProviderHolder
- Returns:
- Returns the featureProvider.
-
setFeatureProvider
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
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
Returns the diagram behavior instance this pattern lives in.- Returns:
- The diagram behavior
- Since:
- 0.10
-
getMappingProvider
Returns theIMappingProvider
that can be used to map pictogram elements onto domain objects and vice versa.- Returns:
- The mapping provider
-
link
Helper method to link aPictogramElement
to a domain object.- Parameters:
pe
- The pictogram elementbusinessObject
- The domain object
-
link
Helper method to link aPictogramElement
to a number of domain objects.- Parameters:
pe
- The pictogram elementbusinessObjects
- The business objects as an array
-
getDiagram
Returns theDiagram
this pattern lives for.- Returns:
- The diagram
-
manageColor
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
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
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
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
-