-
Notifications
You must be signed in to change notification settings - Fork 96
/
VControlTest.java
59 lines (49 loc) · 1.49 KB
/
VControlTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package org.eclipse.nebula.cwt.svg;
import java.io.IOException;
import java.io.InputStream;
import org.eclipse.nebula.cwt.v.VCanvas;
import org.eclipse.nebula.cwt.v.VGridLayout;
import org.eclipse.nebula.cwt.v.VLabel;
import org.eclipse.nebula.cwt.v.VPanel;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class VControlTest {
public static void main(final String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
shell.setText("Test");
SvgDocument SVG_BACK = null;
try (final InputStream in = VControlTest.class.getResourceAsStream("caretLeft.svg")) {
SVG_BACK = SvgDocument.load(in);
}
catch (IOException e) {
e.printStackTrace();
}
if(SVG_BACK == null) {
return;
}
VCanvas vCanvas = new VCanvas(shell,SWT.NONE);
VPanel vPanel = vCanvas.getPanel();
VGridLayout layout = new VGridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
vPanel.setLayout(layout);
VLabel vLabel = new VLabel(vPanel, SWT.NONE);
vLabel.setImage(SVG_BACK);
Point size = vCanvas.computeSize(SWT.DEFAULT, SWT.DEFAULT);
System.out.println(size);
// display the shell...
shell.open();
shell.pack();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}