]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/HoverHighlighter.java
Use generics type variable for mapping db object.
[simantics/3d.git] / org.simantics.g3d.vtk / src / org / simantics / g3d / vtk / common / HoverHighlighter.java
1 /*******************************************************************************
2  * Copyright (c) 2012, 2013 Association for Decentralized Information Management in
3  * 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.g3d.vtk.common;
13
14 import org.eclipse.jface.viewers.ISelection;
15 import org.simantics.g3d.scenegraph.IG3DNode;
16 import org.simantics.g3d.scenegraph.NodeHighlighter;
17 import org.simantics.g3d.scenegraph.NodeHighlighter.HighlightEventType;
18
19 public class HoverHighlighter extends SelectionHighlighter {
20
21
22         public HoverHighlighter(VtkView panel, VTKNodeMap nodeMap) {
23                 super(panel, nodeMap);
24                 
25         }
26         
27         protected void highlight(ISelection s) {
28                 highlight(s, HighlightEventType.Hover, HighlightEventType.ClearHover);
29         }
30         
31         protected void hilight(IG3DNode node, HighlightEventType type) {
32                 if (node instanceof NodeHighlighter) {
33                         ((NodeHighlighter)node).highlight(type);
34                         return;
35                 }
36                 if (type == HighlightEventType.Hover) {
37                         setSelectedColor(node);
38                 } else if (type == HighlightEventType.ClearHover) {
39                         setDefaultColor(node);
40                 }
41         }
42
43         protected void setDefaultColor(IG3DNode node) {
44                 double color[] = new double[]{0,0,0};
45                 setColor(node, true, color);
46         }
47         
48         protected void setSelectedColor(IG3DNode node) {
49                 double color[] = new double[]{1,0,1};
50                 setColor(node, true, color);
51         }
52         
53 }