]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/tooltip/TextTooltipProvider.java
G2DParentNode handles "undefined" child bounds separately
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / tooltip / TextTooltipProvider.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 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.g2d.tooltip;
13
14 import java.awt.Frame;
15 import java.awt.Label;
16
17 import org.simantics.g2d.element.IElement;
18 /**
19  * Simple tool-tip showing a label
20  * 
21  * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
22  *
23  */
24 public abstract class TextTooltipProvider implements TooltipProvider {
25         private Frame frame;
26         
27         @Override
28         public void showTooltip(IElement element, int x, int y) {
29                 frame = new Frame(getTooltipText(element));
30                 frame.setFocusableWindowState(false);
31                 frame.setUndecorated(true);
32                 Label label = new Label(getTooltipText(element));
33                 frame.add(label);
34                 frame.pack();
35                 frame.setVisible(true);
36                 frame.setLocation(x,y-32);
37         }
38         
39         @Override
40         public void hideTooltip(IElement element) {
41                 frame.setVisible(false);
42                 frame.dispose();
43                 frame = null;
44         }
45         
46         public abstract String getTooltipText(IElement element);
47 }