]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.charts/src/org/simantics/charts/editor/ChartKeys.java
Fixed context menu popup location for HiDPI displays with display zoom
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / editor / ChartKeys.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.charts.editor;
13
14 import org.simantics.databoard.util.ObjectUtils;
15 import org.simantics.db.Resource;
16 import org.simantics.utils.datastructures.hints.HintContext;
17
18 /**
19  * @author Tuukka Lehtonen
20  */
21 public class ChartKeys {
22
23     /**
24      * //@deprecated use {@link #chartSourceKey(Resource)} with model resource as argument instead
25      */
26     //@Deprecated
27     //public static final Key KEY_ACTIVE_CHART_SOURCE = new HintContext.KeyOf(ChartData.class, "CHART_DATA");
28
29     public static ChartSourceKey chartSourceKey(Resource model) {
30         return new ChartSourceKey(model);
31     }
32
33     /**
34      * For having multiple different chart data sources. The sources are
35      * identified by resources.
36      */
37     public static class ChartSourceKey extends HintContext.KeyOf {
38
39         private final Resource source;
40
41         public ChartSourceKey(Resource source) {
42             super(ChartData.class, "CHART_DATA(" + source.getResourceId() + ")");
43             this.source = source;
44         }
45
46         public Resource getResource() {
47             return source;
48         }
49
50         @Override
51         public int hashCode() {
52             return source != null ? source.hashCode() : 0;
53         }
54
55         @Override
56         public boolean equals(Object obj) {
57             if (this == obj)
58                 return true;
59             if (!(obj instanceof ChartSourceKey))
60                 return false;
61             ChartSourceKey other = (ChartSourceKey) obj;
62             return ObjectUtils.objectEquals(source, other.source);
63         }
64
65         @Override
66         public String toString() {
67             return getClass().getSimpleName() + "[" + source + "]";
68         }
69
70     }
71
72 }