Skip to content

Commit

Permalink
Addresses the problem in #3815 (record are not accessible by serializer)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed May 30, 2023
1 parent 7f328e8 commit 8e87a0f
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 27 deletions.
@@ -1,11 +1,11 @@
/*******************************************************************************************************
*
* GamaColorConverter.java, in ummisco.gama.serialize, is part of the source code of the GAMA modeling and simulation
* platform (v.2.0.0).
* platform (v.1.9.2).
*
* (c) 2007-2023 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU)
*
* Visit https://github.com/gama-platform/gama2 for license information and contacts.
* Visit https://github.com/gama-platform/gama for license information and contacts.
*
********************************************************************************************************/
package ummisco.gama.serializer.gamaType.converters;
Expand All @@ -17,38 +17,14 @@

import msi.gama.runtime.IScope;
import msi.gama.util.GamaColor;
import ummisco.gama.serializer.gamaType.reduced.GamaColorRecord;

/**
* The Class GamaColorConverter.
*/
@SuppressWarnings ("rawtypes")
public class GamaColorConverter extends AbstractGamaConverter<GamaColor, GamaColor> {

/**
* The GamaColorRecord.
*/
public static record GamaColorRecord(float r, float g, float b, float a) {
/**
* Instantiates a new gama color reducer.
*
* @param c
* the c
*/
public GamaColorRecord(final GamaColor c) {
this(c.red(), c.green(), c.blue(), c.alpha());
}

/**
* Construct object.
*
* @return the object
*/
public GamaColor constructObject() {
return new GamaColor(r / 255d, g / 255d, b / 255d, a / 255d);
}

}

/**
* Instantiates a new gama color converter.
*
Expand Down
@@ -0,0 +1,72 @@
/*******************************************************************************************************
*
* GamaColorRecord.java, in ummisco.gama.serialize, is part of the source code of the GAMA modeling and simulation
* platform (v.1.9.2).
*
* (c) 2007-2023 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU)
*
* Visit https://github.com/gama-platform/gama for license information and contacts.
*
********************************************************************************************************/
package ummisco.gama.serializer.gamaType.reduced;

import msi.gama.util.GamaColor;

/**
* The GamaColorRecord.
*/
public class GamaColorRecord {

/** The r. */
float r;

/** The g. */
float g;

/** The b. */
float b;

/** The a. */
float a;

/**
* Instantiates a new gama color record.
*
* @author Alexis Drogoul (alexis.drogoul@ird.fr)
* @param r
* the r.
* @param g
* the g.
* @param b
* the b.
* @param a
* the a.
* @date 30 mai 2023
*/
public GamaColorRecord(final float r, final float g, final float b, final float a) {
this.r = r;
this.g = g;
this.b = b;
this.a = a;
}

/**
* Instantiates a new gama color reducer.
*
* @param c
* the c
*/
public GamaColorRecord(final GamaColor c) {
this(c.red(), c.green(), c.blue(), c.alpha());
}

/**
* Construct object.
*
* @return the object
*/
public GamaColor constructObject() {
return new GamaColor(r / 255d, g / 255d, b / 255d, a / 255d);
}

}

0 comments on commit 8e87a0f

Please sign in to comment.