1 /*******************************************************************************
2 * Copyright (c) 2012 Association for Decentralized Information Management in
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.modeling.typicals.rules;
14 import java.awt.geom.AffineTransform;
16 import org.simantics.db.Resource;
17 import org.simantics.db.WriteGraph;
18 import org.simantics.db.exception.DatabaseException;
19 import org.simantics.diagram.synchronization.graph.DiagramGraphUtil;
20 import org.simantics.modeling.typicals.ITypicalSynchronizationRule;
21 import org.simantics.modeling.typicals.TypicalInfo;
24 * @author Tuukka Lehtonen
26 public enum TransformRule implements ITypicalSynchronizationRule {
30 public static TransformRule getInstance() {
35 public boolean synchronize(WriteGraph graph, Resource template, Resource instance, TypicalInfo info) throws DatabaseException {
36 AffineTransform at = DiagramGraphUtil.getAffineTransform(graph, template);
37 AffineTransform copyAt = DiagramGraphUtil.getAffineTransform(graph, instance);
38 if (!at.equals(copyAt)) {
39 info.messageLog.add("\t\t\ttransform");
40 DiagramGraphUtil.setTransform(graph, instance, at);