1 /*
2 * This file is a part of CAST project.
3 * (c) Copyright 2007, AGH University of Science & Technology
4 * All rights reserved. Check the documentation for licensing terms.
5 * https://caribou.iisg.agh.edu.pl/trac/cast
6 */
7 package pl.edu.agh.cast.zestalgorithms.actions;
8
9 import org.eclipse.zest.layouts.LayoutAlgorithm;
10
11 import pl.edu.agh.cast.schema.editor.action.layout.AbstractSetLayoutAction;
12 import pl.edu.agh.cast.schema.editor.layout.algorithm.ILayoutAlgorithm;
13 import pl.edu.agh.cast.zestalgorithms.core.LayoutAlgorithmAdapter;
14
15 /**
16 * Abstract action for layout algorithm adapters - just creates adapters for algorithms specified in constructor
17 *
18 * @author Paweł Koperek <pkoperek@gmail.com>
19 * @author Mateusz Kupisz <mkupisz@gmail.com>
20 *
21 */
22 public abstract class AbstractLayoutAlgorithmAction extends AbstractSetLayoutAction {
23
24 private LayoutAlgorithm algorithm;
25
26 /**
27 * Default constructor. Stores passed instance of {@link LayoutAlgorithm}.
28 *
29 * @param algorithm
30 * Instance of {@link LayoutAlgorithm}.
31 */
32 public AbstractLayoutAlgorithmAction(LayoutAlgorithm algorithm) {
33 this.algorithm = algorithm;
34 }
35
36 /**
37 * Simply creates new {@link LayoutAlgorithmAdapter} wrapping the instance of algorithm passed in constructor and
38 * returns it.
39 *
40 * @return Instance of {@link LayoutAlgorithmAdapter}
41 */
42 @Override
43 protected ILayoutAlgorithm getAlgorithm() {
44 return new LayoutAlgorithmAdapter(algorithm);
45 }
46 }