1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 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.g3d.vtk.common;
14 import org.eclipse.jface.viewers.ISelection;
15 import org.simantics.g3d.scenegraph.NodeHighlighter;
16 import org.simantics.g3d.scenegraph.NodeHighlighter.HighlightEventType;
17 import org.simantics.g3d.scenegraph.base.INode;
19 public class HoverHighlighter<DBObject> extends SelectionHighlighter<DBObject> {
21 public HoverHighlighter(VtkView panel, VTKNodeMap<DBObject,?> nodeMap) {
22 super(panel, nodeMap);
26 protected void highlight(ISelection s) {
27 highlight(s, HighlightEventType.Hover, HighlightEventType.ClearHover);
31 protected void hilight(INode node, HighlightEventType type) {
32 if (node instanceof NodeHighlighter) {
33 ((NodeHighlighter)node).highlight(type);
36 if (type == HighlightEventType.Hover) {
37 setSelectedColor(node);
38 } else if (type == HighlightEventType.ClearHover) {
39 setDefaultColor(node);
44 protected void setDefaultColor(INode node) {
45 double color[] = new double[]{0,0,0};
46 setColor(node, true, color);
50 protected void setSelectedColor(INode node) {
51 double color[] = new double[]{1,0,1};
52 setColor(node, true, color);