Skip to content

Commit 273ef60

Browse files
Fix java example
1 parent 04594a4 commit 273ef60

3 files changed

Lines changed: 38 additions & 37 deletions

File tree

cmake/FesapiJavaExample.java

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Licensed to the Apache Software Foundation (ASF) under one
2323
import java.util.stream.LongStream;
2424

2525
import com.f2i_consulting.fesapi.SWIGTYPE_p_double;
26+
import com.f2i_consulting.fesapi.SWIGTYPE_p_unsigned_char;
2627
import com.f2i_consulting.fesapi.SWIGTYPE_p_unsigned_int;
2728
import com.f2i_consulting.fesapi.SWIGTYPE_p_unsigned_short;
2829
import com.f2i_consulting.fesapi.StringVector;
@@ -99,7 +100,7 @@ public class FesapiJavaExample {
99100
*/
100101
static {
101102
try {
102-
System.loadLibrary("${ASSEMBLY_NAME}");
103+
System.loadLibrary("${CPP_LIBRARY_NAME}-${Fesapi_VERSION_MAJOR}.${Fesapi_VERSION_MINOR}");
103104
}
104105
catch (UnsatisfiedLinkError e) {
105106
System.out.println("UnsatisfiedLinkError : " + e.toString());
@@ -537,27 +538,27 @@ private static void serializeGraphicalInformationSet(DataObjectRepository repo,
537538

538539
// associating a discrete color map to dicreteProp1
539540
DiscreteColorMap discrColMap = repo.createDiscreteColorMap("3daf4661-ae8f-4357-adee-0b0159bdd0a9", "Discrete color map");
540-
SWIGTYPE_p_unsigned_int discrColMapRgbColors = fesapi.new_UInt32Array(18);
541+
SWIGTYPE_p_unsigned_char discrColMapRgbColors = fesapi.new_UInt8Array(18);
541542
SWIGTYPE_p_double discrColMapAlphas = fesapi.new_DoubleArray(6);
542543
try {
543-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 0, 255);
544-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 1, 0);
545-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 2, 0);
546-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 3, 0);
547-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 4, 255);
548-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 5, 0);
549-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 6, 0);
550-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 7, 0);
551-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 8, 255);
552-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 9, 169);
553-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 10, 84);
554-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 11, 27);
555-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 12, 0);
556-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 13, 0);
557-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 14, 0);
558-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 15, 255);
559-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 16, 255);
560-
fesapi.UInt32Array_setitem(discrColMapRgbColors, 17, 255);
544+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 0L, (short) 255);
545+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 1L, (short) 0);
546+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 2L, (short) 0);
547+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 3L, (short) 0);
548+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 4L, (short) 255);
549+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 5L, (short) 0);
550+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 6L, (short) 0);
551+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 7L, (short) 0);
552+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 8L, (short) 255);
553+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 9L, (short) 169);
554+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 10L, (short) 84);
555+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 11L, (short) 27);
556+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 12L, (short) 0);
557+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 13L, (short) 0);
558+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 14L, (short) 0);
559+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 15L, (short) 255);
560+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 16L, (short) 255);
561+
fesapi.UInt8Array_setitem(discrColMapRgbColors, 17L, (short) 255);
561562

562563
fesapi.DoubleArray_setitem(discrColMapAlphas, 0, 1.);
563564
fesapi.DoubleArray_setitem(discrColMapAlphas, 1, 1.);
@@ -574,10 +575,10 @@ private static void serializeGraphicalInformationSet(DataObjectRepository repo,
574575
discrColMapTitles.add("black");
575576
discrColMapTitles.add("white");
576577

577-
discrColMap.setRgbColors(6, discrColMapRgbColors, discrColMapAlphas, discrColMapTitles);
578+
discrColMap.setRgbColors(6, discrColMapRgbColors, discrColMapAlphas, null, discrColMapTitles);
578579
}
579580
finally {
580-
fesapi.delete_UInt32Array(discrColMapRgbColors);
581+
fesapi.delete_UInt8Array(discrColMapRgbColors);
581582
fesapi.delete_DoubleArray(discrColMapAlphas);
582583
}
583584

@@ -627,15 +628,15 @@ private static void serializeGraphicalInformationSet(DataObjectRepository repo,
627628
contColMapContProp.pushBackDoubleHdf5Array2dOfValues(values, numPointInFastestDirection, numPointsInSlowestDirection, hdfProxy);
628629

629630
ContinuousColorMap contColMap = repo.createContinuousColorMap("a207faa2-963e-48d6-b3ad-53f6c1fc4dd4", "Continuous color map", resqml22__InterpolationDomain.rgb, resqml22__InterpolationMethod.linear);
630-
SWIGTYPE_p_unsigned_int contColMapRgbColors = fesapi.new_UInt32Array(6);
631+
SWIGTYPE_p_unsigned_char contColMapRgbColors = fesapi.new_UInt8Array(6);
631632
SWIGTYPE_p_double contColMapAlphas = fesapi.new_DoubleArray(2);
632633
try {
633-
fesapi.UInt32Array_setitem(contColMapRgbColors, 0, 0);
634-
fesapi.UInt32Array_setitem(contColMapRgbColors, 1, 255);
635-
fesapi.UInt32Array_setitem(contColMapRgbColors, 2, 0);
636-
fesapi.UInt32Array_setitem(contColMapRgbColors, 3, 255);
637-
fesapi.UInt32Array_setitem(contColMapRgbColors, 4, 0);
638-
fesapi.UInt32Array_setitem(contColMapRgbColors, 5, 0);
634+
fesapi.UInt8Array_setitem(contColMapRgbColors, 0L, (short) 0);
635+
fesapi.UInt8Array_setitem(contColMapRgbColors, 1L, (short) 255);
636+
fesapi.UInt8Array_setitem(contColMapRgbColors, 2L, (short) 0);
637+
fesapi.UInt8Array_setitem(contColMapRgbColors, 3L, (short) 255);
638+
fesapi.UInt8Array_setitem(contColMapRgbColors, 4L, (short) 0);
639+
fesapi.UInt8Array_setitem(contColMapRgbColors, 5L, (short) 0);
639640

640641
fesapi.DoubleArray_setitem(contColMapAlphas, 0, 1.);
641642
fesapi.DoubleArray_setitem(contColMapAlphas, 1, 1.);
@@ -644,10 +645,10 @@ private static void serializeGraphicalInformationSet(DataObjectRepository repo,
644645
contColMapColTitles.add("green");
645646
contColMapColTitles.add("red");
646647

647-
contColMap.setRgbColors(2, contColMapRgbColors, contColMapAlphas, contColMapColTitles);
648+
contColMap.setRgbColors(2, contColMapRgbColors, contColMapAlphas, null, contColMapColTitles);
648649
}
649650
finally {
650-
fesapi.delete_UInt32Array(contColMapRgbColors);
651+
fesapi.delete_UInt8Array(contColMapRgbColors);
651652
fesapi.delete_DoubleArray(contColMapAlphas);
652653
}
653654

@@ -769,12 +770,12 @@ private static void deserialize()
769770
if (graphicalInformationSet.hasDiscreteColorMap(targetObject)) {
770771
DiscreteColorMap discreteColorMap = graphicalInformationSet.getDiscreteColorMap(targetObject);
771772
System.out.println("discrete color map title: " + discreteColorMap.getTitle());
772-
SWIGTYPE_p_unsigned_int r = fesapi.new_UInt32Array(1);
773-
SWIGTYPE_p_unsigned_int g = fesapi.new_UInt32Array(1);
774-
SWIGTYPE_p_unsigned_int b = fesapi.new_UInt32Array(1);
773+
SWIGTYPE_p_unsigned_char r = fesapi.new_UInt8Array(1);
774+
SWIGTYPE_p_unsigned_char g = fesapi.new_UInt8Array(1);
775+
SWIGTYPE_p_unsigned_char b = fesapi.new_UInt8Array(1);
775776
for (int colorIndex = 0; colorIndex < discreteColorMap.getColorCount(); ++colorIndex) {
776777
discreteColorMap.getRgbColor(colorIndex, r, g, b);
777-
System.out.print(colorIndex + ": (" + fesapi.UInt32Array_getitem(r, 0) + ", " + fesapi.UInt32Array_getitem(g, 0) + ", " + fesapi.UInt32Array_getitem(b, 0) + ", ");
778+
System.out.print(colorIndex + ": (" + fesapi.UInt8Array_getitem(r, 0) + ", " + fesapi.UInt8Array_getitem(g, 0) + ", " + fesapi.UInt8Array_getitem(b, 0) + ", ");
778779
System.out.print(discreteColorMap.getAlpha(colorIndex));
779780
if (discreteColorMap.hasColorTitle(colorIndex)) {
780781
System.out.print(", " + discreteColorMap.getColorTitle(colorIndex));

src/resqml2/AbstractColorMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace RESQML2_NS
5757
* @param colorCount the size (number of colors) of the color map
5858
* @param rgbColors array (of size colorCount * 3) of RGB colors with hsvColors[3*i] is red component, hsvColors[3*i + 1] is green component and hsvColors[3*i + 2] is blue component of the ith color (red, green and blue are in range [0, 255])
5959
* @param alphas array (of size colorCount) of numeric values in the range [0, 1] for alpha transparency channel (0 means transparent and 1 means opaque). If alphas == nullptr (default value), default alpha value is 1.
60-
* @param indices array (of size solorCount) of color indices. These indices are cast to unsigned int in the case of a discrete color map. If indices == nullptr (default value), indices are set from 0 to colorCount - 1
60+
* @param indices array (of size colorCount) of color indices. These indices are cast to unsigned int in the case of a discrete color map. If indices == nullptr (default value), indices are set from 0 to colorCount - 1
6161
* @param colorTitles vector (of size colorCount) of color titles. Titles are not set if colorTitles is empty (default value)
6262
*/
6363
DLL_IMPORT_OR_EXPORT void setRgbColors(uint64_t colorCount,

swig/swigResqml2Include.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,7 @@ namespace RESQML2_NS
20582058
* @param colorCount the size (number of colors) of the color map
20592059
* @param rgbColors array (of size colorCount * 3) of RGB colors with hsvColors[3*i] is red componant, hsvColors[3*i + 1] is green component and hsvColors[3*i + 2] is blue component of the ith color (red, green and blue are in range [0, 255])
20602060
* @param alphas array (of size colorCount) of numeric values in the range [0, 1] for alpha transparency channel (0 means transparent and 1 means opaque). If alphas == nullptr (default value), default alpha value is 1.
2061-
* @param indices array (of size solorCount) of color indices. These indices are cast to unsigned int in the case of a discrete color map. If indices == nullptr (default value), indices are set from 0 to colorCount - 1
2061+
* @param indices array (of size colorCount) of color indices. These indices are cast to unsigned int in the case of a discrete color map. If indices == nullptr (default value), indices are set from 0 to colorCount - 1
20622062
* @param colorTitles vector (of size colorCount) of color titles. Titles are not set if colorTitles is empty (default value)
20632063
*/
20642064
void setRgbColors(uint64_t colorCount,

0 commit comments

Comments
 (0)