1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 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.layer;
14 import java.util.Collection;
17 import org.simantics.db.Resource;
18 import org.simantics.db.exception.DatabaseException;
19 import org.simantics.db.function.DbConsumer;
20 import org.simantics.g2d.layers.ILayer;
21 import org.simantics.g2d.layers.SimpleLayer;
24 * @author Tuukka Lehtonen
26 public class GraphLayer {
28 public static final String PROP_VISIBLE = "PROP_VISIBLE";
29 public static final String PROP_FOCUSABLE = "PROP_FOCUSABLE";
31 private final String name;
33 private final Resource layer;
35 private boolean active;
37 private final Map<String, Resource> tags;
39 public GraphLayer(String name, Resource layer, Map<String, Resource> tags, boolean active) {
46 public GraphLayer withName(String name) {
47 return new GraphLayer(name, layer, tags, active);
50 public String getName() {
54 public Resource getLayer() {
58 public Resource getVisible() {
59 return tags.get(PROP_VISIBLE);
62 public Resource getFocusable() {
63 return tags.get(PROP_FOCUSABLE);
66 public boolean isActive() {
70 public ILayer getILayer() {
71 return new SimpleLayer(name);
74 public Collection<Resource> getTags() {
78 public void forEachTag(DbConsumer<Resource> consumer) throws DatabaseException {
79 for (Resource r : tags.values())
84 public int hashCode() {
87 result = prime * result + (active ? 1231 : 1237);
88 result = prime * result + ((layer == null) ? 0 : layer.hashCode());
89 result = prime * result + ((name == null) ? 0 : name.hashCode());
90 result = prime * result + ((tags == null) ? 0 : tags.hashCode());
95 public boolean equals(Object obj) {
100 if (getClass() != obj.getClass())
102 GraphLayer other = (GraphLayer) obj;
103 if (active != other.active)
106 if (other.layer != null)
108 } else if (!layer.equals(other.layer))
111 if (other.name != null)
113 } else if (!name.equals(other.name))
116 if (other.tags != null)
118 } else if (!tags.equals(other.tags))