RequestSlengAdapter.java
7.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.scene7.is.sleng.BlendModeEnum
* com.scene7.is.sleng.CacheStorageEnum
* com.scene7.is.sleng.ColorProfileSet
* com.scene7.is.sleng.ColorSpec
* com.scene7.is.sleng.ImageAccessException
* com.scene7.is.sleng.Layer
* com.scene7.is.sleng.MergeOrderEnum
* com.scene7.is.sleng.PathAttrSpec
* com.scene7.is.sleng.Sleng
* com.scene7.is.sleng.SlengCodeGenerator
* com.scene7.is.sleng.SlengDelegate
* com.scene7.is.sleng.Text
* com.scene7.is.sleng.TextAttrSpec
* com.scene7.is.util.Size
* org.jetbrains.annotations.NotNull
*/
package com.scene7.is.ps.provider;
import com.scene7.is.sleng.BlendModeEnum;
import com.scene7.is.sleng.CacheStorageEnum;
import com.scene7.is.sleng.ColorProfileSet;
import com.scene7.is.sleng.ColorSpec;
import com.scene7.is.sleng.ImageAccessException;
import com.scene7.is.sleng.Layer;
import com.scene7.is.sleng.MergeOrderEnum;
import com.scene7.is.sleng.PathAttrSpec;
import com.scene7.is.sleng.Sleng;
import com.scene7.is.sleng.SlengCodeGenerator;
import com.scene7.is.sleng.SlengDelegate;
import com.scene7.is.sleng.Text;
import com.scene7.is.sleng.TextAttrSpec;
import com.scene7.is.util.Size;
import java.net.URL;
import org.jetbrains.annotations.NotNull;
public class RequestSlengAdapter
extends SlengDelegate {
private static final int UNDEFINED = Integer.MIN_VALUE;
private final SlengCodeGenerator generator;
int offsetToBaseLayer = Integer.MIN_VALUE;
int offsetToGlobalBase = Integer.MIN_VALUE;
int offsetToWorkLayer = Integer.MIN_VALUE;
public RequestSlengAdapter(SlengCodeGenerator delegee) {
super((Sleng)delegee);
this.generator = delegee;
}
int globalBaseOffset() {
return this.offsetToGlobalBase;
}
int baseLayerOffset() {
return this.offsetToBaseLayer;
}
int workLayerOffset() {
return this.offsetToWorkLayer;
}
void setBaseLayer() {
this.offsetToBaseLayer = 0;
}
void setWorkLayer() {
this.offsetToWorkLayer = 0;
}
void setGlobalSpace() {
this.offsetToGlobalBase = 0;
}
public void openText(Size size, ColorSpec layerColor, ColorSpec bgColor, Text text, TextAttrSpec attr, PathAttrSpec pathAttr, ColorProfileSet inputProfiles, double xScale, double yScale) throws ImageAccessException {
super.openText(size, layerColor, bgColor, text, attr, pathAttr, inputProfiles, xScale, yScale);
this.addLayer();
}
public void openFxg(@NotNull String path, @NotNull String query, @NotNull byte[] versionKey) throws ImageAccessException {
super.openFxg(path, query, versionKey);
this.addLayer();
}
public void openImage(String path) throws ImageAccessException {
super.openImage(path);
this.addLayer();
}
public void openImage(String path, int width, int height) throws ImageAccessException {
super.openImage(path, width, height);
this.addLayer();
}
public void openURL(URL url, boolean validation) throws ImageAccessException {
super.openURL(url, validation);
this.addLayer();
}
public void openSolid(double width, double height, ColorSpec layerColor) throws ImageAccessException {
super.openSolid(width, height, layerColor);
this.addLayer();
}
public void embed(byte[] code, CacheStorageEnum cacheStorage, boolean cachePyramidLevels) throws ImageAccessException {
super.embed(code, cacheStorage, cachePyramidLevels);
this.addLayer();
}
public void insertLayer(Layer layer) {
super.insertLayer(layer);
this.addLayer();
}
public void dup() throws ImageAccessException {
super.dup();
this.addLayer();
}
public void merge(@NotNull MergeOrderEnum order, @NotNull BlendModeEnum blend, boolean subPixel) throws ImageAccessException {
super.merge(order, blend, subPixel);
this.removeLayer();
}
public void mask(boolean invert) throws ImageAccessException {
super.mask(invert);
this.removeLayer();
}
public void drop() throws ImageAccessException {
super.drop();
this.removeLayer();
}
public void swap() {
super.swap();
if (this.offsetToBaseLayer == 0) {
this.offsetToBaseLayer = 1;
} else if (this.offsetToBaseLayer == 1) {
this.offsetToBaseLayer = 0;
}
if (this.offsetToWorkLayer == 0) {
this.offsetToWorkLayer = 1;
} else if (this.offsetToWorkLayer == 1) {
this.offsetToWorkLayer = 0;
}
}
public void peekLayer(int offset) {
super.peekLayer(offset);
if (offset == this.offsetToBaseLayer) {
this.offsetToBaseLayer = 0;
} else if (this.offsetToBaseLayer >= 0 && offset < 0) {
++this.offsetToBaseLayer;
} else if (this.offsetToBaseLayer >= 0 && offset > this.offsetToBaseLayer) {
++this.offsetToBaseLayer;
} else if (this.offsetToBaseLayer < 0 && offset > this.offsetToBaseLayer) {
++this.offsetToBaseLayer;
}
if (offset == this.offsetToWorkLayer) {
this.offsetToWorkLayer = 0;
} else if (this.offsetToWorkLayer >= 0 && offset < 0) {
++this.offsetToWorkLayer;
} else if (this.offsetToWorkLayer >= 0 && offset > this.offsetToWorkLayer) {
++this.offsetToWorkLayer;
} else if (this.offsetToWorkLayer < 0 && offset > this.offsetToWorkLayer) {
++this.offsetToWorkLayer;
}
}
public void setLayer(int offset) {
super.setLayer(offset);
this.offsetToBaseLayer -= offset;
this.offsetToWorkLayer -= offset;
}
public void cloneLayer(int offset) throws ImageAccessException {
super.cloneLayer(offset);
this.addLayer();
}
public void openBase() {
super.openBase();
this.addBase();
}
public void dropBase() {
super.dropBase();
this.removeBase();
}
public void popBase() {
super.popBase();
this.removeBase();
}
public void pushBase() {
super.pushBase();
this.addBase();
}
public byte[] getCode() {
return this.generator.getCode();
}
private void addLayer() {
if (this.offsetToBaseLayer >= 0) {
++this.offsetToBaseLayer;
}
if (this.offsetToWorkLayer >= 0) {
++this.offsetToWorkLayer;
}
}
private void removeLayer() {
if (this.offsetToBaseLayer > 0) {
--this.offsetToBaseLayer;
} else if (this.offsetToBaseLayer == 0) {
this.offsetToBaseLayer = Integer.MIN_VALUE;
}
if (this.offsetToWorkLayer > 0) {
--this.offsetToWorkLayer;
} else if (this.offsetToWorkLayer == 0) {
this.offsetToWorkLayer = Integer.MIN_VALUE;
}
}
private void addBase() {
if (this.offsetToGlobalBase >= 0) {
++this.offsetToGlobalBase;
}
}
private void removeBase() {
if (this.offsetToGlobalBase > 0) {
--this.offsetToGlobalBase;
} else if (this.offsetToGlobalBase == 0) {
this.offsetToGlobalBase = Integer.MIN_VALUE;
}
}
}