Beatmup
JavaFactory Class Reference

Set of utility functions for Java bindings. More...

#include <java_factory.h>

Public Member Functions

 JavaFactory ()
 
jobject makeAffineMapping (JNIEnv *jenv, const Beatmup::AffineMapping &mapping)
 Creates Java's AffineMapping object from Beatmup AffineMapping. More...
 
void setAffineMapping (JNIEnv *jenv, const Beatmup::AffineMapping &mapping, jobject jMapping)
 
jobject makeIntRectangle (JNIEnv *jenv, const Beatmup::IntRectangle)
 Creates Java's IntRectangle object from Beatmup IntRectangle. More...
 
jobject makeIntPoint (JNIEnv *jenv, const Beatmup::IntPoint)
 
void setIntPoint (JNIEnv *jenv, const Beatmup::IntPoint &point, jobject jPoint)
 
void setIntPoint (JNIEnv *jenv, int x, int y, jobject jPoint)
 
jobject makeColor (JNIEnv *jenv, const Beatmup::color4i &color)
 Creates Java's Color object from Beatmup's color. More...
 
void setColor (JNIEnv *jenv, const Beatmup::color4i &c, jobject jColor)
 

Private Member Functions

void initialize (JNIEnv *jenv)
 

Private Attributes

JNIEnv * usedEnv
 last used JNIEnv More...
 
struct {
   jmethodID   constructor
 
   jfieldID   ida11
 
   jfieldID   ida12
 
   jfieldID   ida21
 
   jfieldID   ida22
 
   jfieldID   idx
 
   jfieldID   idy
 
affineMapping
 
struct {
   jmethodID   constructor
 
   jfieldID   ix1
 
   jfieldID   iy1
 
   jfieldID   ix2
 
   jfieldID   iy2
 
intRectangle
 
struct {
   jmethodID   constructor
 
   jfieldID   ix
 
   jfieldID   iy
 
intPoint
 
struct {
   jmethodID   constructor
 
   jfieldID   idr
 
   jfieldID   idg
 
   jfieldID   idb
 
   jfieldID   ida
 
color
 

Detailed Description

Set of utility functions for Java bindings.

Definition at line 27 of file java_factory.h.

Constructor & Destructor Documentation

◆ JavaFactory()

JavaFactory::JavaFactory ( )

Definition at line 22 of file java_factory.cpp.

22 : usedEnv(NULL) {}
JNIEnv * usedEnv
last used JNIEnv
Definition: java_factory.h:29

Member Function Documentation

◆ initialize()

void JavaFactory::initialize ( JNIEnv *  jenv)
private

Definition at line 24 of file java_factory.cpp.

24  {
25  if (usedEnv == jenv)
26  return;
27  usedEnv = jenv;
28  // AffineMapping
29  jclass cls = jenv->FindClass("Beatmup/Geometry/AffineMapping");
30  affineMapping.constructor = jenv->GetMethodID(cls, "<init>", "()V");
31  affineMapping.ida11 = jenv->GetFieldID(cls, "a11", "F");
32  affineMapping.ida12 = jenv->GetFieldID(cls, "a12", "F");
33  affineMapping.ida21 = jenv->GetFieldID(cls, "a21", "F");
34  affineMapping.ida22 = jenv->GetFieldID(cls, "a22", "F");
35  affineMapping.idx = jenv->GetFieldID(cls, "x", "F");
36  affineMapping.idy = jenv->GetFieldID(cls, "y", "F");
37  jenv->DeleteLocalRef(cls);
38  // IntRectangle
39  cls = jenv->FindClass("Beatmup/Geometry/IntRectangle");
40  intRectangle.constructor = jenv->GetMethodID(cls, "<init>", "(IIII)V");
41  intRectangle.ix1 = jenv->GetFieldID(cls, "x1", "I");
42  intRectangle.iy1 = jenv->GetFieldID(cls, "y1", "I");
43  intRectangle.ix2 = jenv->GetFieldID(cls, "x2", "I");
44  intRectangle.iy2 = jenv->GetFieldID(cls, "y2", "I");
45  jenv->DeleteLocalRef(cls);
46  // IntPoint
47  cls = jenv->FindClass("Beatmup/Geometry/IntPoint");
48  intPoint.constructor = jenv->GetMethodID(cls, "<init>", "(II)V");
49  intPoint.ix = jenv->GetFieldID(cls, "x", "I");
50  intPoint.iy = jenv->GetFieldID(cls, "y", "I");
51  jenv->DeleteLocalRef(cls);
52  // Color
53  cls = jenv->FindClass("Beatmup/Imaging/Color");
54  color.constructor = jenv->GetMethodID(cls, "<init>", "(IIII)V");
55  color.idr = jenv->GetFieldID(cls, "r", "I");
56  color.idg = jenv->GetFieldID(cls, "g", "I");
57  color.idb = jenv->GetFieldID(cls, "b", "I");
58  color.ida = jenv->GetFieldID(cls, "a", "I");
59  jenv->DeleteLocalRef(cls);
60 }
struct JavaFactory::@19 color
struct JavaFactory::@16 affineMapping
struct JavaFactory::@17 intRectangle
struct JavaFactory::@18 intPoint
JNIEnv jclass
JNIEnv * jenv

◆ makeAffineMapping()

jobject JavaFactory::makeAffineMapping ( JNIEnv *  jenv,
const Beatmup::AffineMapping mapping 
)

Creates Java's AffineMapping object from Beatmup AffineMapping.

Definition at line 63 of file java_factory.cpp.

63  {
65  jclass cls = jenv->FindClass("Beatmup/Geometry/AffineMapping");
66  jobject result = jenv->NewObject(cls, affineMapping.constructor);
67  jenv->DeleteLocalRef(cls);
69  return result;
70 }
void setAffineMapping(JNIEnv *jenv, const Beatmup::AffineMapping &mapping, jobject jMapping)
void initialize(JNIEnv *jenv)
JNIEnv jobject
Beatmup::IntPoint result
Beatmup::AffineMapping & mapping

◆ setAffineMapping()

void JavaFactory::setAffineMapping ( JNIEnv *  jenv,
const Beatmup::AffineMapping mapping,
jobject  jMapping 
)

Definition at line 73 of file java_factory.cpp.

73  {
75  float a11, a12, a21, a22;
77  jenv->SetFloatField(jMapping, affineMapping.ida11, a11);
78  jenv->SetFloatField(jMapping, affineMapping.ida12, a12);
79  jenv->SetFloatField(jMapping, affineMapping.ida21, a21);
80  jenv->SetFloatField(jMapping, affineMapping.ida22, a22);
81  jenv->SetFloatField(jMapping, affineMapping.idx, mapping.position.x);
82  jenv->SetFloatField(jMapping, affineMapping.idy, mapping.position.y);
83 }
void getElements(float &a11, float &a12, float &a21, float &a22) const
Retrieves matrix element values.
Definition: geometry.h:572
return layer isPhantom() ? JNI_TRUE jlong jfloat jfloat jfloat a11
return layer isPhantom() ? JNI_TRUE jlong jfloat jfloat jfloat jfloat jfloat jfloat a22
return layer isPhantom() ? JNI_TRUE jlong jfloat jfloat jfloat jfloat jfloat a21
return layer isPhantom() ? JNI_TRUE jlong jfloat jfloat jfloat jfloat a12

◆ makeIntRectangle()

jobject JavaFactory::makeIntRectangle ( JNIEnv *  jenv,
const Beatmup::IntRectangle  r 
)

Creates Java's IntRectangle object from Beatmup IntRectangle.

Definition at line 85 of file java_factory.cpp.

85  {
87  jclass cls = jenv->FindClass("Beatmup/Geometry/IntRectangle");
88  jobject result = jenv->NewObject(cls, intRectangle.constructor, r.a.x, r.a.y, r.b.x, r.b.y);
89  jenv->DeleteLocalRef(cls);
90  return result;
91 }
jobject jlong jint jint jint r

◆ makeIntPoint()

jobject JavaFactory::makeIntPoint ( JNIEnv *  jenv,
const Beatmup::IntPoint  p 
)

Definition at line 94 of file java_factory.cpp.

94  {
96  jclass cls = jenv->FindClass("Beatmup/Geometry/IntPoint");
97  jobject result = jenv->NewObject(cls, intPoint.constructor, p.x, p.y);
98  jenv->DeleteLocalRef(cls);
99  return result;
100 }
Beatmup::IntPoint p((int) x,(int) y)

◆ setIntPoint() [1/2]

void JavaFactory::setIntPoint ( JNIEnv *  jenv,
const Beatmup::IntPoint point,
jobject  jPoint 
)

Definition at line 103 of file java_factory.cpp.

103  {
104  initialize(jenv);
105  jenv->SetIntField(jPoint, intPoint.ix, point.x);
106  jenv->SetIntField(jPoint, intPoint.iy, point.y);
107 }

◆ setIntPoint() [2/2]

void JavaFactory::setIntPoint ( JNIEnv *  jenv,
int  x,
int  y,
jobject  jPoint 
)

Definition at line 110 of file java_factory.cpp.

110  {
111  initialize(jenv);
112  jenv->SetIntField(jPoint, intPoint.ix, x);
113  jenv->SetIntField(jPoint, intPoint.iy, y);
114 }
jobject jlong jint jint y
jobject jlong jint x

◆ makeColor()

jobject JavaFactory::makeColor ( JNIEnv *  jenv,
const Beatmup::color4i color 
)

Creates Java's Color object from Beatmup's color.

Definition at line 117 of file java_factory.cpp.

117  {
118  initialize(jenv);
119  jclass cls = jenv->FindClass("Beatmup/Imaging/Color");
120  jobject result = jenv->NewObject(cls, color.constructor, c.r, c.g, c.b, c.a);
121  jenv->DeleteLocalRef(cls);
122  return result;
123 }

◆ setColor()

void JavaFactory::setColor ( JNIEnv *  jenv,
const Beatmup::color4i c,
jobject  jColor 
)

Definition at line 126 of file java_factory.cpp.

126  {
127  initialize(jenv);
128  jenv->SetIntField(jColor, color.idr, c.r);
129  jenv->SetIntField(jColor, color.idg, c.g);
130  jenv->SetIntField(jColor, color.idb, c.b);
131  jenv->SetIntField(jColor, color.ida, c.a);
132 }
jlong jobject jColor

Member Data Documentation

◆ usedEnv

JNIEnv* JavaFactory::usedEnv
private

last used JNIEnv

Definition at line 29 of file java_factory.h.

◆ constructor

jmethodID JavaFactory::constructor

Definition at line 32 of file java_factory.h.

◆ ida11

jfieldID JavaFactory::ida11

Definition at line 33 of file java_factory.h.

◆ ida12

jfieldID JavaFactory::ida12

Definition at line 33 of file java_factory.h.

◆ ida21

jfieldID JavaFactory::ida21

Definition at line 33 of file java_factory.h.

◆ ida22

jfieldID JavaFactory::ida22

Definition at line 33 of file java_factory.h.

◆ idx

jfieldID JavaFactory::idx

Definition at line 33 of file java_factory.h.

◆ idy

jfieldID JavaFactory::idy

Definition at line 33 of file java_factory.h.

◆ 

struct { ... } JavaFactory::affineMapping

◆ ix1

jfieldID JavaFactory::ix1

Definition at line 38 of file java_factory.h.

◆ iy1

jfieldID JavaFactory::iy1

Definition at line 38 of file java_factory.h.

◆ ix2

jfieldID JavaFactory::ix2

Definition at line 38 of file java_factory.h.

◆ iy2

jfieldID JavaFactory::iy2

Definition at line 38 of file java_factory.h.

◆ 

struct { ... } JavaFactory::intRectangle

◆ ix

jfieldID JavaFactory::ix

Definition at line 43 of file java_factory.h.

◆ iy

jfieldID JavaFactory::iy

Definition at line 43 of file java_factory.h.

◆ 

struct { ... } JavaFactory::intPoint

◆ idr

jfieldID JavaFactory::idr

Definition at line 48 of file java_factory.h.

◆ idg

jfieldID JavaFactory::idg

Definition at line 48 of file java_factory.h.

◆ idb

jfieldID JavaFactory::idb

Definition at line 48 of file java_factory.h.

◆ ida

jfieldID JavaFactory::ida

Definition at line 48 of file java_factory.h.

◆ 

struct { ... } JavaFactory::color

The documentation for this class was generated from the following files: