Beatmup
java_factory.h
Go to the documentation of this file.
1 /*
2  Beatmup image and signal processing library
3  Copyright (C) 2019, lnstadrum
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 #include <jni.h>
21 #include <core/geometry.h>
22 
23 
24 /**
25  Set of utility functions for Java bindings.
26 */
27 class JavaFactory {
28 private:
29  JNIEnv* usedEnv; //!< last used JNIEnv
30 
31  struct {
32  jmethodID constructor;
35 
36  struct {
37  jmethodID constructor;
38  jfieldID ix1, iy1, ix2, iy2;
40 
41  struct {
42  jmethodID constructor;
43  jfieldID ix, iy;
45 
46  struct {
47  jmethodID constructor;
48  jfieldID idr, idg, idb, ida;
49  } color;
50 
51  void initialize(JNIEnv* jenv);
52 public:
53  JavaFactory();
54 
55  /**
56  * \brief Creates Java's AffineMapping object from Beatmup AffineMapping
57  */
59  JNIEnv *jenv,
61  );
62 
63  void setAffineMapping(
64  JNIEnv* jenv,
66  jobject jMapping
67  );
68 
69  /**
70  * \brief Creates Java's IntRectangle object from Beatmup IntRectangle
71  */
73 
75 
76  void setIntPoint(
77  JNIEnv* jenv,
78  const Beatmup::IntPoint& point,
79  jobject jPoint
80  );
81 
82  void setIntPoint(
83  JNIEnv* jenv,
84  int x, int y,
85  jobject jPoint
86  );
87 
88  /**
89  * \brief Creates Java's Color object from Beatmup's color
90  */
91  jobject makeColor(JNIEnv *jenv, const Beatmup::color4i& color);
92 
93  void setColor(JNIEnv* jenv, const Beatmup::color4i& c, jobject jColor);
94 };
2x3 affine mapping containing a 2x2 matrix and a 2D point
Definition: geometry.h:639
Set of utility functions for Java bindings.
Definition: java_factory.h:27
jfieldID ida11
Definition: java_factory.h:33
jfieldID ida21
Definition: java_factory.h:33
jfieldID ida22
Definition: java_factory.h:33
jfieldID idr
Definition: java_factory.h:48
jfieldID idg
Definition: java_factory.h:48
struct JavaFactory::@19 color
void setIntPoint(JNIEnv *jenv, const Beatmup::IntPoint &point, jobject jPoint)
jfieldID iy
Definition: java_factory.h:43
jobject makeIntRectangle(JNIEnv *jenv, const Beatmup::IntRectangle)
Creates Java's IntRectangle object from Beatmup IntRectangle.
jfieldID idy
Definition: java_factory.h:33
jfieldID idb
Definition: java_factory.h:48
void setAffineMapping(JNIEnv *jenv, const Beatmup::AffineMapping &mapping, jobject jMapping)
JNIEnv * usedEnv
last used JNIEnv
Definition: java_factory.h:29
jfieldID ix2
Definition: java_factory.h:38
jfieldID ida
Definition: java_factory.h:48
jfieldID ida12
Definition: java_factory.h:33
jfieldID iy2
Definition: java_factory.h:38
jfieldID idx
Definition: java_factory.h:33
jfieldID ix
Definition: java_factory.h:43
void setColor(JNIEnv *jenv, const Beatmup::color4i &c, jobject jColor)
jfieldID ix1
Definition: java_factory.h:38
struct JavaFactory::@16 affineMapping
jmethodID constructor
Definition: java_factory.h:32
jfieldID iy1
Definition: java_factory.h:38
jobject makeAffineMapping(JNIEnv *jenv, const Beatmup::AffineMapping &mapping)
Creates Java's AffineMapping object from Beatmup AffineMapping.
jobject makeIntPoint(JNIEnv *jenv, const Beatmup::IntPoint)
struct JavaFactory::@17 intRectangle
void initialize(JNIEnv *jenv)
struct JavaFactory::@18 intPoint
jobject makeColor(JNIEnv *jenv, const Beatmup::color4i &color)
Creates Java's Color object from Beatmup's color.
JNIEnv * jenv
JNIEnv jobject
jobject jlong jint jint y
jobject jlong jint x
Beatmup::AffineMapping & mapping
jlong jobject jColor