Checkstyle fix

This commit is contained in:
Jindra Petřík
2025-04-13 14:13:27 +02:00
parent 859a2f8bdb
commit b1c5f9d0c6
85 changed files with 2486 additions and 2340 deletions
@@ -41,12 +41,7 @@ public class BinDataOutputStream extends OutputStream {
os.write(i);
}
}
public void writeUI16(int value) throws IOException {
write(value & 0xFF);
write((value >> 8) & 0xFF);
}
@Override
public void write(byte[] b) throws IOException {
os.write(b);
@@ -57,6 +52,11 @@ public class BinDataOutputStream extends OutputStream {
os.write(b, off, len);
}
public void writeUI16(int value) throws IOException {
write(value & 0xFF);
write((value >> 8) & 0xFF);
}
public void writeUI32(long value) throws IOException {
write((int) (value & 0xFF));
write((int) ((value >> 8) & 0xFF));
@@ -30,12 +30,14 @@ import javax.imageio.ImageIO;
/**
* Generates bin/*.dat file for images.
*
* @author JPEXS
*/
public class ImageBinDataGenerator {
/**
* Generates data
*
* @param is Input stream
* @param os Output stream
* @param format Image format
@@ -65,7 +67,7 @@ public class ImageBinDataGenerator {
w.writeUI32(0);
w.writeUI32(20 * bimg.getWidth());
w.writeUI32(0);
w.writeUI32(0);
w.writeUI32(20 * bimg.getHeight());
w.write(0x01); //has transparency
@@ -81,19 +83,19 @@ public class ImageBinDataGenerator {
int b = (rgba >> 16) & 0xFF;
int g = (rgba >> 8) & 0xFF;
int r = rgba & 0xFF;
//some weird premultiplication
if (a != 255) {
r = (int)Math.floor(r * a / 256f);
g = (int)Math.floor(g * a / 256f);
b = (int)Math.floor(b * a / 256f);
r = (int) Math.floor(r * a / 256f);
g = (int) Math.floor(g * a / 256f);
b = (int) Math.floor(b * a / 256f);
}
//also weird, but this way it works...
if (a != 0 && a != 255) {
a = a + 1;
}
}
def.write(a);
def.write(b);
def.write(g);
@@ -29,6 +29,7 @@ import javax.imageio.ImageIO;
/**
* Reads bin/*.dat file of lossless images and produces BufferedImage
*
* @author JPEXS
*/
public class LosslessImageBinDataReader {
@@ -87,14 +88,14 @@ public class LosslessImageBinDataReader {
int b = data[pos++] & 0xFF;
int g = data[pos++] & 0xFF;
int r = data[pos++] & 0xFF;
if (a != 0 && a != 255) {
a = a - 1;
r = (int)Math.floor(r * 256f / a);
g = (int)Math.floor(g * 256f / a);
b = (int)Math.floor(b * 256f / a);
}
r = (int) Math.floor(r * 256f / a);
g = (int) Math.floor(g * 256f / a);
b = (int) Math.floor(b * 256f / a);
}
int rgba = r + (g << 8) + (b << 16) + (a << 24);
img.setRGB(x, y, rgba);
@@ -2914,12 +2914,14 @@ public class XFLConverter {
return ret;
}
private static class AccessibilityBag {
private List<AccessibilityItem> items = new ArrayList<>();
public void add(AccessibilityItem item) {
items.add(item);
}
public Map<String, String> getAttributes(String instanceName, int frame) {
Map<String, String> ret = new LinkedHashMap<>();
for (AccessibilityItem item : items) {
@@ -2942,10 +2944,11 @@ public class XFLConverter {
sb.append(item.toString());
}
return sb.toString();
}
}
}
private static class AccessibilityItem {
int startFrame;
int endFrame;
String instanceName;
@@ -2955,19 +2958,18 @@ public class XFLConverter {
public AccessibilityItem(String instanceName, String attributeKey, String attributeValue) {
this(instanceName, attributeKey, attributeValue, 1, Integer.MAX_VALUE);
}
public AccessibilityItem(String instanceName, String attributeKey, String attributeValue, int frame) {
this(instanceName, attributeKey, attributeValue, frame, frame);
}
public AccessibilityItem(String instanceName, String attributeKey, String attributeValue, int startFrame, int endFrame) {
this.startFrame = startFrame;
this.endFrame = endFrame;
this.instanceName = instanceName;
this.attributeKey = attributeKey;
this.attributeValue = attributeValue;
}
}
public boolean contains(String instanceName, int frame) {
if (!Objects.equals(instanceName, this.instanceName)) {
@@ -2978,7 +2980,7 @@ public class XFLConverter {
@Override
public String toString() {
return "[instance: " + instanceName+" key: \"" + attributeKey+"\" value: \"" + attributeValue +"\" frames: " + startFrame + " to " + (endFrame == Integer.MAX_VALUE ? "end" : endFrame) + "]";
return "[instance: " + instanceName + " key: \"" + attributeKey + "\" value: \"" + attributeValue + "\" frames: " + startFrame + " to " + (endFrame == Integer.MAX_VALUE ? "end" : endFrame) + "]";
}
@Override
@@ -3019,10 +3021,7 @@ public class XFLConverter {
return Objects.equals(this.attributeValue, other.attributeValue);
}
}
private static AccessibilityBag getAccessibilityFromPack(AbcIndexing abcIndex, ScriptPack pack) {
int swfVersion = -1;
@@ -3089,7 +3088,7 @@ public class XFLConverter {
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t;
if (abc.method_info.get(tm.method_info).param_types.length != 1) {
continue;
}
}
MethodBody traitBody = abc.findBody(tm.method_info);
List<MethodBody> traitCallStack = new ArrayList<>();
traitCallStack.add(traitBody);
@@ -3112,8 +3111,8 @@ public class XFLConverter {
|| propName.resolvedMultinameName.startsWith("__setTab_"))
&& callProp.arguments.size() == 1) {
frameRangeAccessibilityTraitNames.add(propName.resolvedMultinameName);
}
}
}
}
}
if (frameTraitNames.contains(traitName)) {
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t;
@@ -3144,7 +3143,7 @@ public class XFLConverter {
for (Trait t : instanceInfo.instance_traits.traits) {
if (t instanceof TraitMethodGetterSetter) {
String traitName = t.getName(abc).getName(abc.constants, new ArrayList<>(), true, false);
String traitName = t.getName(abc).getName(abc.constants, new ArrayList<>(), true, false);
if (frameAccessibilityTraitNames.contains(traitName)) {
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t;
MethodBody traitBody = abc.findBody(tm.method_info);
@@ -3246,7 +3245,7 @@ public class XFLConverter {
}
}
}
if (frameRangeAccessibilityTraitNames.contains(traitName)) {
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t;
MethodBody traitBody = abc.findBody(tm.method_info);
@@ -3351,21 +3350,21 @@ public class XFLConverter {
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
for (Trait t : instanceInfo.instance_traits.traits) {
if (allFramesAccessibilityTraitNames.contains(t.getName(abc).getName(abc.constants, new ArrayList<>(), true, false))) {
if (t instanceof TraitMethodGetterSetter) {
@@ -3440,7 +3439,7 @@ public class XFLConverter {
if (setProp.value instanceof FalseItem) {
val = invert ? "true" : "false";
}
ret.add(new AccessibilityItem(parentParentProp.resolvedMultinameName, acProp, val));
ret.add(new AccessibilityItem(parentParentProp.resolvedMultinameName, acProp, val));
}
}
}
@@ -3548,8 +3547,8 @@ public class XFLConverter {
callStack.add(frameBody);
frameBody.convert(swfVersion, callStack, abcIndex, new ConvertData(), "??", ScriptExportMode.AS, false, methodIndex, pack.scriptIndex, classIndex, abc, methodTrait, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), new Traits(), true, new HashSet<>(), new ArrayList<>());
if (frameBody.convertedItems != null) {
if (frameBody.convertedItems != null) {
for (int i = 0; i < frameBody.convertedItems.size(); i++) {
GraphTargetItem ti = frameBody.convertedItems.get(i);
if (ti instanceof CallPropertyAVM2Item) {
@@ -3567,7 +3566,7 @@ public class XFLConverter {
}
}
}
StringBuilderTextWriter writer = new StringBuilderTextWriter(Configuration.getCodeFormatting(), scriptBuilder);
frameBody.toString(swfVersion, callStack, abcIndex, "??", ScriptExportMode.AS, abc, methodTrait, writer, new ArrayList<>(), new HashSet<>());