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 use `AbstractPattern` or `AbstractConnectionPattern` instead.

### Constructor Summary

Constructors
`AbstractBasePattern()`

### Method Summary

All Methods Instance Methods Concrete Methods
`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 the `Diagram` 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 the `IMappingProvider` 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 a `PictogramElement` to a domain object.
`protected void` `link​(PictogramElement pe, java.lang.Object[] businessObjects)` Helper method to link a `PictogramElement` to a number of domain objects.
`protected Color` `manageColor​(int red, int green, int blue)` A convenience method for the color handling which simply calls `IGaService.manageColor(Diagram, int, int, int)` to manage a `Color` used within the `Diagram`.
`protected Color` `manageColor​(IColorConstant colorConstant)` A convenience method for the color handling which simply calls `IGaService.manageColor(Diagram, IColorConstant)` to manage a `Color` used within the `Diagram`.
`protected Font` `manageFont​(java.lang.String name, int size)` A convenience method for the `Font` handling which simply calls `IGaService.manageFont(Diagram, String, int)` to manage a `Font` used within the `Diagram`.
`protected Font` `manageFont​(java.lang.String name, int size, boolean isItalic, boolean isBold)` A convenience method for the `Font` handling which simply calls `IGaService.manageFont(Diagram, String, int, boolean, boolean)` to manage a `Font` used within the `Diagram`.
`void` `setFeatureProvider​(IFeatureProvider featureProvider)` Sets the feature provider for this pattern.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### AbstractBasePattern

    public AbstractBasePattern()

### 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 the `IAdd.add(IAddContext)` method. The default implementation simply does nothing and returns `null`.

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 the `IAdd.canAdd(IAddContext)` method. The default implementation simply returns `false`.

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 interface `IFeatureProviderHolder`
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 the `IMappingProvider` 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 a `PictogramElement` to a domain object.

Parameters:
  `pe` - The pictogram element
  `businessObject` - The domain object

#### link

    protected void link​(PictogramElement pe,
                        java.lang.Object[] businessObjects)

Helper method to link a `PictogramElement` to a number of domain objects.

Parameters:
  `pe` - The pictogram element
  `businessObjects` - The business objects as an array

#### getDiagram

    protected Diagram getDiagram()

Returns the `Diagram` this pattern lives for.

Returns:
  The diagram

#### manageColor

    protected Color manageColor​(IColorConstant colorConstant)

A convenience method for the color handling which simply calls `IGaService.manageColor(Diagram, IColorConstant)` to manage a `Color` used within the `Diagram`.

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 calls `IGaService.manageColor(Diagram, int, int, int)` to manage a `Color` used within the `Diagram`.

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 the `Font` handling which simply calls `IGaService.manageFont(Diagram, String, int)` to manage a `Font` used within the `Diagram`.

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 the `Font` handling which simply calls `IGaService.manageFont(Diagram, String, int, boolean, boolean)` to manage a `Font` used within the `Diagram`.

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