1 /*******************************************************************************
2 * Copyright (c) 2007, 2015 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.diagram.synchronization.graph;
14 import java.awt.geom.AffineTransform;
16 import org.simantics.db.Resource;
17 import org.simantics.db.WriteGraph;
18 import org.simantics.db.common.CommentMetadata;
19 import org.simantics.db.common.utils.NameUtils;
20 import org.simantics.db.exception.DatabaseException;
21 import org.simantics.diagram.synchronization.ModificationAdapter;
22 import org.simantics.modeling.ModelingResources;
25 * @author Tuukka Lehtonen
27 public class TransformElement extends ModificationAdapter {
29 Resource elementResource;
32 public TransformElement(Resource element, AffineTransform tr) {
34 this.elementResource = element;
39 public void perform(WriteGraph g) throws DatabaseException {
40 DiagramGraphUtil.setTransform(g, elementResource, tr);
42 // Add comment to change set.
43 CommentMetadata cm = g.getMetadata(CommentMetadata.class);
44 ModelingResources MOD = ModelingResources.getInstance(g);
45 Resource component = g.getPossibleObject(elementResource, MOD.ElementToComponent);
46 if (component != null)
47 g.addMetadata(cm.add("Transformed " + NameUtils.getSafeName(g, component)));
49 g.addMetadata(cm.add("Transformed " + elementResource));