MCPcopy Create free account
hub / github.com/SpaiR/imgui-java / ExampleImPlot

Class ExampleImPlot

example/src/main/java/ExampleImPlot.java:13–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11import java.net.URI;
12
13public class ExampleImPlot {
14 private static final String URL = "https://github.com/epezent/implot/tree/v1.0";
15 private static final ImBoolean showDemo = new ImBoolean(false);
16
17 private static final int[] xs = {0, 1, 2, 3, 4, 5};
18 private static final int[] ys = {0, 1, 2, 3, 4, 5};
19 private static final int[] ys1 = {0, 0, 1, 2, 3, 4};
20 private static final int[] ys2 = {1, 2, 3, 4, 5, 6};
21
22 // Showcase for implot v1.0 PR #672: per-index LineColors, MarkerFillColors, and MarkerSizes.
23 private static final ImPlotSpec perIndexSpec;
24
25 static {
26 ImPlot.createContext();
27
28 perIndexSpec = new ImPlotSpec();
29 perIndexSpec.setMarker(ImPlotMarker.Circle);
30 perIndexSpec.setLineColors(new int[]{
31 ImColor.rgb(239, 83, 80), // red
32 ImColor.rgb(255, 167, 38), // orange
33 ImColor.rgb(255, 238, 88), // yellow
34 ImColor.rgb(102, 187, 106), // green
35 ImColor.rgb(66, 165, 245), // blue
36 ImColor.rgb(171, 71, 188), // purple
37 });
38 perIndexSpec.setMarkerFillColors(new int[]{
39 ImColor.rgb(239, 83, 80),
40 ImColor.rgb(255, 167, 38),
41 ImColor.rgb(255, 238, 88),
42 ImColor.rgb(102, 187, 106),
43 ImColor.rgb(66, 165, 245),
44 ImColor.rgb(171, 71, 188),
45 });
46 perIndexSpec.setMarkerSizes(new float[]{4f, 6f, 8f, 10f, 12f, 14f});
47 }
48
49 public static void show(ImBoolean showImPlotWindow) {
50 ImGui.setNextWindowSize(500, 400, ImGuiCond.Once);
51 ImGui.setNextWindowPos(ImGui.getMainViewport().getPosX() + 100, ImGui.getMainViewport().getPosY() + 100, ImGuiCond.Once);
52 if (ImGui.begin("ImPlot Demo", showImPlotWindow)) {
53 ImGui.text("This a demo for ImPlot");
54
55 ImGui.alignTextToFramePadding();
56 ImGui.text("Repo:");
57 ImGui.sameLine();
58 if (ImGui.button(URL)) {
59 try {
60 Desktop.getDesktop().browse(new URI(URL));
61 } catch (Exception e) {
62 e.printStackTrace();
63 }
64 }
65
66 ImGui.checkbox("Show ImPlot Built-In Demo", showDemo);
67
68 if (showDemo.get()) {
69 ImPlot.showDemoWindow(showDemo);
70 } else {

Callers

nothing calls this directly

Calls 6

createContextMethod · 0.95
rgbMethod · 0.95
setMarkerMethod · 0.80
setLineColorsMethod · 0.45
setMarkerFillColorsMethod · 0.45
setMarkerSizesMethod · 0.45

Tested by

no test coverage detected