Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fa3d768

Browse filesBrowse files
ShadyBoukharyumar456
authored andcommitted
Wrapped all graphics functions. Still needs to be tested.
1 parent c78b0a0 commit fa3d768
Copy full SHA for fa3d768

File tree

5 files changed

+533
-0
lines changed
Filter options

5 files changed

+533
-0
lines changed

‎CMakeLists.txt

Copy file name to clipboardExpand all lines: CMakeLists.txt
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ ADD_JAR(${AF_JAR}
3232
com/arrayfire/Statistics.java
3333
com/util/JNIException.java
3434
com/arrayfire/ArrayFireException.java
35+
com/arrayfire/Window.java
36+
com/arrayfire/Graphics.java
3537
)
3638

3739
ADD_DEPENDENCIES(${AF_JAR} ${AF_LIB})

‎com/arrayfire/Graphics.java

Copy file name to clipboard
+116Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
package com.arrayfire;
2+
3+
class Graphics {
4+
5+
public enum ColorMap {
6+
DEFAULT(0), SPECTRUM(1), COLORS(2), RED(3), MOOD(4), HEAT(5),
7+
BLUE(6), INFERNO(7), MAGMA(8), PLASMA(9), VIRIDIS(10);
8+
9+
private final int map;
10+
11+
private ColorMap(int map) {
12+
this.map = map;
13+
}
14+
15+
public int getMap() {
16+
return map;
17+
}
18+
}
19+
20+
public enum MarkerType {
21+
NONE(0), POINT(1), CIRCLE(2), SQUARE(3), TRIANGLE(4), CROSS(5), PLUS(6), STAR(7);
22+
23+
private final int type;
24+
25+
private MarkerType(int type) {
26+
this.type = type;
27+
}
28+
29+
public int getType() {
30+
return type;
31+
}
32+
}
33+
34+
public static native long afInitWindow(int width, int height, String name);
35+
36+
public static native void afDestroyWindow(long wnd);
37+
38+
public static native void afSetPos(long wnd, int x, int y);
39+
40+
public static native void afSetTitle(long wnd, String title);
41+
42+
public static native void afSetSize(long wnd, int w, int h);
43+
44+
public static native void afDrawImage(long wnd, long arr, int r, int c,
45+
String title, int cmap);
46+
47+
public static native void afDrawPlotnd(long wnd, long arr, int r, int c,
48+
String title);
49+
50+
public static native void afDrawPlot2d(long wnd, long arrX, long arrY,
51+
int r, int c, String title);
52+
53+
public static native void afDrawPlot3d(long wnd, long arrX, long arrY,
54+
long arrZ, int r, int c, String title);
55+
56+
public static native void afDrawScatternd(long wnd, long arr, int r, int c,
57+
int markerType, String title);
58+
59+
public static native void afDrawScatter2d(long wnd, long arrX, long arrY,
60+
int r, int c,
61+
int markerType, String title);
62+
63+
public static native void afDrawScatter3d(long wnd, long arrX, long arrY,
64+
long arrZ, int r, int c,
65+
int markerType, String title);
66+
67+
public static native void afDrawHist(long wnd, long arr, int r, int c,
68+
double min, double max, String title);
69+
70+
public static native void afDrawSurface(long wnd, long arr, long xVals,
71+
long yVals, int r, int c,
72+
String title);
73+
74+
public static native void afDrawVectorFieldnd(long wnd, long points,
75+
long directions, int r,
76+
int c, String title);
77+
78+
public static native void afDrawVectorField2d(long wnd, long xPoints,
79+
long yPoints, long xDirections,
80+
long yDirections, int r,
81+
int c, String title);
82+
83+
public static native void afDrawVectorField3d(long wnd, long xPoints,
84+
long yPoints, long zPoints,
85+
long xDirections,
86+
long yDirections,
87+
long zDirections, int r, int c,
88+
String title);
89+
90+
public static native void afGrid(long wnd, int rows, int columns);
91+
92+
public static native void afSetAxesLimitsCompute(long wnd, long arrX,
93+
long arrY, long arrZ,
94+
boolean isExact, int r,
95+
int c);
96+
97+
public static native void afSetAxesLimits2d(long wnd, float xMin, float xMax,
98+
float yMin, float yMax,
99+
boolean isExact,
100+
int r, int c);
101+
102+
public static native void afSetAxesLimits3d(long wnd, float xMin, float xMax,
103+
float yMin, float yMax,
104+
float zMin,
105+
float zMax, boolean isExact,
106+
int r, int c);
107+
108+
public static native void afSetAxesTitles(String xTitle, String yTitle, String zTitle);
109+
110+
public static native void afShow(long wnd);
111+
112+
public static native boolean afClose(long wnd);
113+
114+
public static native void afSetVisibility(long wnd, boolean isVisible);
115+
116+
}

‎com/arrayfire/Window.java

Copy file name to clipboard
+171Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
package com.arrayfire;
2+
3+
import com.arrayfire.Graphics.ColorMap;
4+
import com.arrayfire.Graphics.MarkerType;
5+
import com.sun.tools.jdeps.Graph;
6+
7+
import jdk.jfr.Unsigned;
8+
9+
public class Window implements AutoCloseable {
10+
11+
protected long ref;
12+
private int r;
13+
private int c;
14+
private ColorMap cmap;
15+
16+
public Window() {
17+
ref = 0;
18+
r = c = -1;
19+
cmap = ColorMap.DEFAULT;
20+
initWindow(1280, 720, "ArrayFire");
21+
}
22+
23+
public Window(String title) {
24+
ref = 0;
25+
r = c = -1;
26+
cmap = ColorMap.DEFAULT;
27+
initWindow(1280, 720, title);
28+
}
29+
30+
public Window(int width, int height, String title) {
31+
ref = 0;
32+
r = c = -1;
33+
cmap = ColorMap.DEFAULT;
34+
initWindow(width, height, title);
35+
}
36+
37+
public Window(int width, int height) {
38+
ref = 0;
39+
r = c = -1;
40+
cmap = ColorMap.DEFAULT;
41+
initWindow(width, height, "ArrayFire");
42+
}
43+
44+
public Window(long ref) {
45+
this.ref = ref;
46+
r = c = -1;
47+
cmap = ColorMap.DEFAULT;
48+
}
49+
50+
private void initWindow(int width, int height, String title) {
51+
ref = Graphics.afInitWindow(width, height, title);
52+
}
53+
54+
protected void set(long ref) {
55+
if (this.ref != 0) {
56+
Graphics.afDestroyWindow(this.ref);
57+
}
58+
this.ref = ref;
59+
}
60+
61+
public void setPos(@Unsigned int x, @Unsigned int y) {
62+
Graphics.afSetPos(ref, x, y);
63+
}
64+
65+
public void setTitle(String title) {
66+
Graphics.afSetTitle(ref, title);
67+
}
68+
69+
public void setSize(@Unsigned int w, @Unsigned int h) {
70+
Graphics.afSetSize(ref, w, h);
71+
}
72+
73+
public void setColorMap(ColorMap cmap) {
74+
this.cmap = cmap;
75+
}
76+
77+
public void image(final Array in, String title) {
78+
Graphics.afDrawImage(ref, in.ref, r, c, title, cmap.getMap());
79+
}
80+
81+
public void plot(final Array in, String title) {
82+
Graphics.afDrawPlotnd(ref, in.ref, r, c, title);
83+
}
84+
85+
public void plot(final Array x, final Array y, String title) {
86+
Graphics.afDrawPlot2d(ref, x.ref, y.ref, r, c, title);
87+
}
88+
89+
public void plot(final Array x, final Array y, final Array z, String title) {
90+
Graphics.afDrawPlot3d(ref, x.ref, y.ref, z.ref, r, c, title);
91+
}
92+
93+
public void scatter(final Array in, MarkerType type, String title) {
94+
Graphics.afDrawScatternd(ref, in.ref, r, c, type.getType(), title);
95+
}
96+
97+
public void scatter(final Array x, final Array y, MarkerType type, String title) {
98+
Graphics.afDrawScatter2d(ref, x.ref, y.ref, c, r, type.getType(), title);
99+
}
100+
101+
public void scatter(final Array x, final Array y, final Array z, MarkerType type, String title) {
102+
Graphics.afDrawScatter3d(ref, x.ref, y.ref, z.ref, c, r, type.getType(), title);
103+
}
104+
105+
public void hist(final Array in, double min, double max, String title) {
106+
Graphics.afDrawHist(ref, in.ref, r, c, min, max, title);
107+
}
108+
109+
public void surface(final Array xVals, final Array yVals, final Array s, String title) {
110+
Graphics.afDrawSurface(ref, s.ref, x.ref, y.ref, r, c, title);
111+
}
112+
113+
public void vectorField(final Array points, final Array directions, String title) {
114+
Graphics.afDrawVectorFieldnd(ref, points.ref, directions.ref, r, c, title);
115+
}
116+
117+
public void vectorField(final Array xPoints, final Array yPoints, final Array xDirections, final Array yDirections,
118+
String title) {
119+
Graphics.afDrawVectorField2d(ref, xPoints.ref, yPoints.ref, xDirections.ref, yDirections.ref, r, c, title);
120+
}
121+
122+
public void vectorField(final Array xPoints, final Array yPoints, final Array zPoints, final Array xDirections,
123+
final Array yDirections, final Array zDirections, String title) {
124+
Graphics.afDrawVectorField3d(ref, xPoints.ref, yPoints.ref, zPoints.ref, xDirections.ref, yDirections.ref,
125+
zDirections.ref, r, c, title);
126+
}
127+
128+
public void grid(int rows, int cols) {
129+
Graphics.afGrid(ref, rows, cols);
130+
}
131+
132+
public void setAxesLimits(final Array x, final Array y, boolean isExact) {
133+
Graphics.afSetAxesLimitsCompute(ref, x.ref, y.ref, 0, isExact, r, c);
134+
}
135+
136+
public void setAxesLimits(final Array x, final Array y, final Array z, boolean isExact) {
137+
Graphics.afSetAxesLimitsCompute(ref, x.ref, y.ref, z.ref, isExact, r, c);
138+
}
139+
140+
public void setAxesLimits(float xMin, float xMax, float yMin, float yMax, boolean isExact) {
141+
Graphics.afSetAxesLimits2d(ref, xMin, xMax, yMin, yMax, isExact, r, c);
142+
}
143+
144+
public void setAxesLimits(float xMin, float xMax, float yMin, float yMax, float zMin, float zMax, boolean isExact) {
145+
Graphics.afSetAxesLimits3d(ref, xMin, xMax, yMin, yMax, zMin, zMax, isExact, r, c);
146+
}
147+
148+
public void setAxesTitles(String xTitle, String yTitle, String zTitle) {
149+
Graphics.afSetAxesTitles(xTitle, yTitle, zTitle);
150+
}
151+
152+
public void show() {
153+
Graphics.afShow(ref);
154+
r = c = -1;
155+
}
156+
157+
public boolean closeWindow() {
158+
return Graphics.afClose(ref);
159+
}
160+
161+
public void setVisibility(boolean isVisible) {
162+
Graphics.afSetVisibility(ref, isVisible);
163+
}
164+
165+
@Override
166+
public void close() throws Exception {
167+
if (ref != 0) {
168+
Graphics.afDestroyWindow(ref);
169+
}
170+
}
171+
}

‎src/CMakeLists.txt

Copy file name to clipboardExpand all lines: src/CMakeLists.txt
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ ADD_LIBRARY(${AF_LIB} SHARED
2121
image.cpp
2222
signal.cpp
2323
statistics.cpp
24+
graphics.cpp
2425
util.cpp
2526
)
2627

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.