-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathWindow.java
More file actions
170 lines (133 loc) · 4.81 KB
/
Window.java
File metadata and controls
170 lines (133 loc) · 4.81 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
package com.arrayfire;
import static com.arrayfire.ArrayFire.*;
public class Window implements AutoCloseable {
protected long ref;
private int r;
private int c;
private ColorMap cmap;
public Window() throws Exception {
ref = 0;
r = c = -1;
cmap = ColorMap.DEFAULT;
initWindow(1280, 720, "ArrayFire");
}
public Window(String title) throws Exception {
ref = 0;
r = c = -1;
cmap = ColorMap.DEFAULT;
initWindow(1280, 720, title);
}
public Window(int width, int height, String title) throws Exception {
ref = 0;
r = c = -1;
cmap = ColorMap.DEFAULT;
initWindow(width, height, title);
}
public Window(int width, int height) throws Exception {
ref = 0;
r = c = -1;
cmap = ColorMap.DEFAULT;
initWindow(width, height, "ArrayFire");
}
public Window(long ref) throws Exception {
this.ref = ref;
r = c = -1;
cmap = ColorMap.DEFAULT;
}
private void initWindow(int width, int height, String title) throws Exception {
ref = Graphics.afInitWindow(width, height, title);
}
protected void set(long ref) {
if (this.ref != 0) {
Graphics.afDestroyWindow(this.ref);
}
this.ref = ref;
}
public void setPos(int x, int y) {
Graphics.afSetPos(ref, x, y);
}
public void setTitle(String title) {
Graphics.afSetTitle(ref, title);
}
public void setSize(int w, int h) {
Graphics.afSetSize(ref, w, h);
}
public void setColorMap(ColorMap cmap) {
this.cmap = cmap;
}
public void image(final Array in, String title) {
Graphics.afDrawImage(ref, in.ref, r, c, title, cmap.getMap());
}
public void plot(final Array in, String title) {
Graphics.afDrawPlotnd(ref, in.ref, r, c, title);
}
public void plot(final Array x, final Array y, String title) {
Graphics.afDrawPlot2d(ref, x.ref, y.ref, r, c, title);
}
public void plot(final Array x, final Array y, final Array z, String title) {
Graphics.afDrawPlot3d(ref, x.ref, y.ref, z.ref, r, c, title);
}
public void scatter(final Array in, MarkerType type, String title) {
Graphics.afDrawScatternd(ref, in.ref, r, c, type.getType(), title);
}
public void scatter(final Array x, final Array y, MarkerType type, String title) {
Graphics.afDrawScatter2d(ref, x.ref, y.ref, c, r, type.getType(), title);
}
public void scatter(final Array x, final Array y, final Array z, MarkerType type, String title) {
Graphics.afDrawScatter3d(ref, x.ref, y.ref, z.ref, c, r, type.getType(), title);
}
public void hist(final Array in, double min, double max, String title) {
Graphics.afDrawHist(ref, in.ref, r, c, min, max, title);
}
public void surface(final Array xVals, final Array yVals, final Array s, String title) {
Graphics.afDrawSurface(ref, s.ref, xVals.ref, yVals.ref, r, c, title);
}
public void vectorField(final Array points, final Array directions, String title) {
Graphics.afDrawVectorFieldnd(ref, points.ref, directions.ref, r, c, title);
}
public void vectorField(final Array xPoints, final Array yPoints, final Array xDirections,
final Array yDirections, String title) {
Graphics.afDrawVectorField2d(ref, xPoints.ref, yPoints.ref, xDirections.ref, yDirections.ref, r,
c, title);
}
public void vectorField(final Array xPoints, final Array yPoints, final Array zPoints,
final Array xDirections, final Array yDirections, final Array zDirections, String title) {
Graphics.afDrawVectorField3d(ref, xPoints.ref, yPoints.ref, zPoints.ref, xDirections.ref,
yDirections.ref, zDirections.ref, r, c, title);
}
public void grid(int rows, int cols) {
Graphics.afGrid(ref, rows, cols);
}
public void setAxesLimits(final Array x, final Array y, boolean isExact) {
Graphics.afSetAxesLimitsCompute(ref, x.ref, y.ref, 0, isExact, r, c);
}
public void setAxesLimits(final Array x, final Array y, final Array z, boolean isExact) {
Graphics.afSetAxesLimitsCompute(ref, x.ref, y.ref, z.ref, isExact, r, c);
}
public void setAxesLimits(float xMin, float xMax, float yMin, float yMax, boolean isExact) {
Graphics.afSetAxesLimits2d(ref, xMin, xMax, yMin, yMax, isExact, r, c);
}
public void setAxesLimits(float xMin, float xMax, float yMin, float yMax, float zMin, float zMax,
boolean isExact) {
Graphics.afSetAxesLimits3d(ref, xMin, xMax, yMin, yMax, zMin, zMax, isExact, r, c);
}
public void setAxesTitles(String xTitle, String yTitle, String zTitle) {
Graphics.afSetAxesTitles(xTitle, yTitle, zTitle);
}
public void show() {
Graphics.afShow(ref);
r = c = -1;
}
public boolean closeWindow() {
return Graphics.afClose(ref);
}
public void setVisibility(boolean isVisible) {
Graphics.afSetVisibility(ref, isVisible);
}
@Override
public void close() throws Exception {
if (ref != 0) {
Graphics.afDestroyWindow(ref);
}
}
}