Repository navigation
Expand file tree
/
Copy pathExampleImPlot.java
More file actions
60 lines (49 loc) · 1.94 KB
/
Copy pathExampleImPlot.java
File metadata and controls
60 lines (49 loc) · 1.94 KB
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
60
import imgui.extension.implot.ImPlot;
import imgui.flag.ImGuiCond;
import imgui.internal.ImGui;
import imgui.type.ImBoolean;
import java.awt.Desktop;
import java.net.URI;
public class ExampleImPlot {
private static final String URL = "https://github.com/epezent/implot/tree/555ff68";
private static final ImBoolean showDemo = new ImBoolean(false);
private static final Integer[] xs = {0, 1, 2, 3, 4, 5};
private static final Integer[] ys = {0, 1, 2, 3, 4, 5};
private static final Integer[] ys1 = {0, 0, 1, 2, 3, 4};
private static final Integer[] ys2 = {1, 2, 3, 4, 5, 6};
static {
ImPlot.createContext();
}
public static void show(ImBoolean showImPlotWindow) {
ImGui.setNextWindowSize(500, 400, ImGuiCond.Once);
ImGui.setNextWindowPos(ImGui.getMainViewport().getPosX() + 100, ImGui.getMainViewport().getPosY() + 100, ImGuiCond.Once);
if (ImGui.begin("ImPlot Demo", showImPlotWindow)) {
ImGui.text("This a demo for ImPlot");
ImGui.alignTextToFramePadding();
ImGui.text("Repo:");
ImGui.sameLine();
if (ImGui.button(URL)) {
try {
Desktop.getDesktop().browse(new URI(URL));
} catch (Exception e) {
e.printStackTrace();
}
}
ImGui.checkbox("Show ImPlot Built-In Demo", showDemo);
if (ImPlot.beginPlot("Example Plot")) {
ImPlot.plotShaded("Shaded", xs, ys1, ys2);
ImPlot.plotLine("Line", xs, ys);
ImPlot.plotBars("Bars", xs, ys);
ImPlot.endPlot();
}
if (ImPlot.beginPlot("Example Scatterplot")) {
ImPlot.plotScatter("Scatter", xs, ys);
ImPlot.endPlot();
}
if (showDemo.get()) {
ImPlot.showDemoWindow(showDemo);
}
}
ImGui.end();
}
}