blob: 4f6a9f13fd5b263e90a766dafa6d0111a8def410 [file] [log] [blame]
/*******************************************************************************
* <copyright>
*
* Copyright (c) 2013, 2013 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* SAP AG - initial API, implementation and documentation
*
* </copyright>
*
*******************************************************************************/
package org.eclipse.fmc.blockdiagram.editor.algorithm.comment;
import org.eclipse.fmc.blockdiagram.editor.model.FMCTypeChecker;
import org.eclipse.fmc.blockdiagram.editor.model.FMCTypeCheckerFactory;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
/**
* This factory produces Comment algorithms depending on an already existing
* comment instance. The factory is responsible for creating the appropriate
* algorithm. This class is singleton.
*
* @author Heiko Witteborg
*
*/
public class CommentAlgorithmFactory {
private static CommentAlgorithmFactory instance;
private FMCTypeChecker helper = FMCTypeCheckerFactory.getInstance();
private BraceAlgorithm brace = null;
private CommentAlgorithmFactory() {
}
/**
* Lazy initialization method of this factory.
*
* @return The singleton instance of this factory.
*/
public static synchronized CommentAlgorithmFactory getInstance() {
if (instance == null) {
instance = new CommentAlgorithmFactory();
}
return instance;
}
/**
* Returns the brace algorithm singleton instance.
* @return BraceAlgorithm object.
*/
public BraceAlgorithm getBrace() {
if (brace == null) {
brace = new BraceAlgorithm();
}
return brace;
}
/**
* Returns the appropriate algorithm for the already existing pictogram
* element.
*
* @param picto
* The pictogram element to find the algorithm for.
* @return The appropriate FMCNodeAlgorithm instance.
*
*/
public CommentAlgorithm getShape(PictogramElement picto) {
if (helper.isBrace(picto)) {
return getBrace();
}
return null;
}
}