Skip to content

Commit 52dc934

Browse files
authored
MatParam: format code (#2202)
MatParam: format code update License year
1 parent 8181057 commit 52dc934

File tree

1 file changed

+41
-30
lines changed

1 file changed

+41
-30
lines changed

jme3-core/src/main/java/com/jme3/material/MatParam.java

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2021 jMonkeyEngine
2+
* Copyright (c) 2009-2024 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -31,16 +31,26 @@
3131
*/
3232
package com.jme3.material;
3333

34+
import java.io.IOException;
35+
import java.util.Arrays;
36+
3437
import com.jme3.asset.TextureKey;
35-
import com.jme3.export.*;
36-
import com.jme3.math.*;
38+
import com.jme3.export.InputCapsule;
39+
import com.jme3.export.JmeExporter;
40+
import com.jme3.export.JmeImporter;
41+
import com.jme3.export.OutputCapsule;
42+
import com.jme3.export.Savable;
43+
import com.jme3.math.ColorRGBA;
44+
import com.jme3.math.Matrix3f;
45+
import com.jme3.math.Matrix4f;
46+
import com.jme3.math.Quaternion;
47+
import com.jme3.math.Vector2f;
48+
import com.jme3.math.Vector3f;
49+
import com.jme3.math.Vector4f;
3750
import com.jme3.shader.VarType;
3851
import com.jme3.texture.Texture;
3952
import com.jme3.texture.Texture.WrapMode;
4053

41-
import java.io.IOException;
42-
import java.util.Arrays;
43-
4454
/**
4555
* Describes a material parameter. This is used for both defining a name and type
4656
* as well as a material parameter value.
@@ -58,8 +68,8 @@ public class MatParam implements Savable, Cloneable {
5868
/**
5969
* Create a new material parameter. For internal use only.
6070
*
61-
* @param type the type of the parameter
62-
* @param name the desired parameter name
71+
* @param type the type of the parameter
72+
* @param name the desired parameter name
6373
* @param value the desired parameter value (alias created)
6474
*/
6575
public MatParam(VarType type, String name, Object value) {
@@ -75,20 +85,19 @@ public MatParam(VarType type, String name, Object value) {
7585
protected MatParam() {
7686
}
7787

78-
7988
public boolean isTypeCheckEnabled() {
8089
return typeCheck;
8190
}
8291

83-
8492
/**
8593
* Enable type check for this param.
8694
* When type check is enabled a RuntimeException is thrown if
8795
* an object of the wrong type is passed to setValue.
88-
* @param v (default = true)
96+
*
97+
* @param typeCheck (default = true)
8998
*/
90-
public void setTypeCheckEnabled(boolean v) {
91-
typeCheck = v;
99+
public void setTypeCheckEnabled(boolean typeCheck) {
100+
this.typeCheck = typeCheck;
92101
}
93102

94103
/**
@@ -102,6 +111,7 @@ public VarType getVarType() {
102111

103112
/**
104113
* Returns the name of the material parameter.
114+
*
105115
* @return the name of the material parameter.
106116
*/
107117
public String getName() {
@@ -158,15 +168,16 @@ public void setValue(Object value) {
158168
}
159169
}
160170
if (!valid) {
161-
throw new RuntimeException("Trying to assign a value of type " + value.getClass() + " to " + this.getName() + " of type " + type.name() + ". Valid types are "
162-
+ Arrays.deepToString(type.getJavaType()));
171+
throw new RuntimeException("Trying to assign a value of type " + value.getClass()
172+
+ " to " + this.getName()
173+
+ " of type " + type.name()
174+
+ ". Valid types are " + Arrays.deepToString(type.getJavaType()));
163175
}
164176
}
165177
}
166178
this.value = value;
167179
}
168180

169-
170181
/**
171182
* Returns the material parameter value as it would appear in a J3M
172183
* file. E.g.
@@ -274,35 +285,35 @@ public String getValueAsString() {
274285
case TextureCubeMap:
275286
Texture texVal = (Texture) value;
276287
TextureKey texKey = (TextureKey) texVal.getKey();
277-
if (texKey == null){
278-
//throw new UnsupportedOperationException("The specified MatParam cannot be represented in J3M");
288+
if (texKey == null) {
289+
// throw new UnsupportedOperationException("The specified MatParam cannot be represented in J3M");
279290
// this is used in toString and the above line causes blender materials to throw this exception.
280291
// toStrings should be very robust IMO as even debuggers often invoke toString and logging code
281292
// often does as well, even implicitly.
282-
return texVal+":returned null key";
293+
return texVal + ":returned null key";
283294
}
284295

285296
String ret = "";
286297
if (texKey.isFlipY()) {
287298
ret += "Flip ";
288299
}
289300

290-
//Wrap mode
301+
// Wrap mode
291302
ret += getWrapMode(texVal, Texture.WrapAxis.S);
292303
ret += getWrapMode(texVal, Texture.WrapAxis.T);
293304
ret += getWrapMode(texVal, Texture.WrapAxis.R);
294305

295-
//Min and Mag filter
296-
Texture.MinFilter def = Texture.MinFilter.BilinearNoMipMaps;
297-
if(texVal.getImage().hasMipmaps() || texKey.isGenerateMips()){
306+
// Min and Mag filter
307+
Texture.MinFilter def = Texture.MinFilter.BilinearNoMipMaps;
308+
if (texVal.getImage().hasMipmaps() || texKey.isGenerateMips()) {
298309
def = Texture.MinFilter.Trilinear;
299310
}
300-
if(texVal.getMinFilter() != def){
301-
ret += "Min" + texVal.getMinFilter().name()+ " ";
311+
if (texVal.getMinFilter() != def) {
312+
ret += "Min" + texVal.getMinFilter().name() + " ";
302313
}
303314

304-
if(texVal.getMagFilter() != Texture.MagFilter.Bilinear){
305-
ret += "Mag" + texVal.getMagFilter().name()+ " ";
315+
if (texVal.getMagFilter() != Texture.MagFilter.Bilinear) {
316+
ret += "Mag" + texVal.getMagFilter().name() + " ";
306317
}
307318

308319
return ret + "\"" + texKey.getName() + "\"";
@@ -315,12 +326,12 @@ private String getWrapMode(Texture texVal, Texture.WrapAxis axis) {
315326
WrapMode mode = WrapMode.EdgeClamp;
316327
try {
317328
mode = texVal.getWrap(axis);
318-
} catch (IllegalArgumentException e) {
319-
//this axis doesn't exist on the texture
329+
} catch (IllegalArgumentException ex) {
330+
// this axis doesn't exist on the texture
320331
return "";
321332
}
322333
if (mode != WrapMode.EdgeClamp) {
323-
return"Wrap"+ mode.name() + "_" + axis.name() + " ";
334+
return "Wrap" + mode.name() + "_" + axis.name() + " ";
324335
}
325336
return "";
326337
}

0 commit comments

Comments
 (0)