Skip to content

Commit 60c4ffb

Browse files
committed
checkstyle - formatting - part 7
1 parent 987791b commit 60c4ffb

9 files changed

Lines changed: 194 additions & 167 deletions

File tree

openpdf-html/src/main/java/org/openpdf/css/parser/CSSParser.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,9 @@ private void font_face(Stylesheet stylesheet) throws IOException {
475475
int maxLoops = 1024 * 1024; // 1M is too much, 1K is probably too...
476476
int i = 0;
477477
while (true) {
478-
if (++i >= maxLoops)
478+
if (++i >= maxLoops) {
479479
throw new CSSParseException(t, Token.TK_RBRACE, getCurrentLine());
480+
}
480481
skip_whitespace();
481482
t = la();
482483
if (t == Token.TK_RBRACE) {
@@ -630,6 +631,7 @@ private String pseudo_page() throws IOException {
630631
throw new CSSParseException(t, Token.TK_COLON, getCurrentLine());
631632
}
632633
}
634+
633635
// operator
634636
// : '/' S* | COMMA S* | /* empty */
635637
// ;
@@ -820,7 +822,7 @@ private Selector mergeSimpleSelectors(List<Selector> selectors, List<Token> comb
820822
Selector result = null;
821823
for (int i = 0; i < count - 1; i++) {
822824
Selector first = selectors.get(i);
823-
Selector second = selectors.get(i+1);
825+
Selector second = selectors.get(i + 1);
824826
Token combinator = combinators.get(i);
825827

826828
if (first.getPseudoElement() != null) {
@@ -856,7 +858,7 @@ private Selector mergeSimpleSelectors(List<Selector> selectors, List<Token> comb
856858
result = second;
857859
}
858860
if (i > 0) {
859-
for (int j = i-1; j >= 0; j--) {
861+
for (int j = i - 1; j >= 0; j--) {
860862
Selector selector = selectors.get(j);
861863
if (selector.getChainedSelector() == first) {
862864
selector.setChainedSelector(second);
@@ -1589,7 +1591,7 @@ private PropertyValue function(Token operatorToken) throws IOException {
15891591
//in accordance to http://www.w3.org/TR/css3-gcpm/#cmyk-colors
15901592
result = new PropertyValue(createCMYKColorFromFunction(params), operatorToken);
15911593
} else {
1592-
result = new PropertyValue(new FSFunction(f.substring(0, f.length()-1), params), operatorToken);
1594+
result = new PropertyValue(new FSFunction(f.substring(0, f.length() - 1), params), operatorToken);
15931595
}
15941596

15951597
skip_whitespace();
@@ -1611,7 +1613,7 @@ private FSCMYKColor createCMYKColorFromFunction(List<PropertyValue> params) {
16111613
float[] colorComponents = new float[4];
16121614

16131615
for (int i = 0; i < params.size(); i++) {
1614-
colorComponents[i] = parseCMYKColorComponent(params.get(i), (i+1)); //Warning on the truncation?
1616+
colorComponents[i] = parseCMYKColorComponent(params.get(i), (i + 1)); //Warning on the truncation?
16151617
}
16161618

16171619
return new FSCMYKColor(colorComponents[0], colorComponents[1], colorComponents[2], colorComponents[3]);
@@ -1676,7 +1678,7 @@ private short validateType(int index, PropertyValue value) {
16761678
short type = value.getPrimitiveType();
16771679
if (type != CSS_PERCENTAGE && type != CSS_NUMBER) {
16781680
throw new CSSParseException(
1679-
"Parameter " + (index +1) + " to the rgb() function is " +
1681+
"Parameter " + (index + 1) + " to the rgb() function is " +
16801682
"not a number or percentage", getCurrentLine());
16811683
}
16821684

@@ -1755,7 +1757,7 @@ private int convertToInteger(char hexchar1) {
17551757

17561758
private void skip_whitespace() throws IOException {
17571759
Token t;
1758-
while ( (t = next()) == Token.TK_S) {
1760+
while ((t = next()) == Token.TK_S) {
17591761
// skip
17601762
}
17611763
push(t);
@@ -1948,18 +1950,18 @@ private static String processEscapes(char[] ch, int start, int end) {
19481950

19491951
if (c == '\\') {
19501952
// eat escaped newlines and handle te\st == test situations
1951-
if (i < end - 2 && (ch[i+1] == '\r' && ch[i+2] == '\n')) {
1953+
if (i < end - 2 && (ch[i + 1] == '\r' && ch[i + 2] == '\n')) {
19521954
i += 2;
19531955
continue;
19541956
} else {
1955-
if ((i+1) < ch.length && (ch[i+1] == '\n' || ch[i+1] == '\r' || ch[i+1] == '\f')) {
1957+
if ((i + 1) < ch.length && (ch[i + 1] == '\n' || ch[i + 1] == '\r' || ch[i + 1] == '\f')) {
19561958
i++;
19571959
continue;
1958-
} else if ((i+1) >= ch.length) {
1960+
} else if ((i + 1) >= ch.length) {
19591961
// process \ escaped (\\)
19601962
result.append(c);
19611963
continue;
1962-
} else if (! isHexChar(ch[i+1])) {
1964+
} else if (! isHexChar(ch[i + 1])) {
19631965
continue;
19641966
}
19651967
}
@@ -1972,17 +1974,17 @@ private static String processEscapes(char[] ch, int start, int end) {
19721974

19731975
int cvalue = Integer.parseInt(new String(ch, current, i - current), 16);
19741976
if (cvalue < 0xFFFF) {
1975-
result.append((char)cvalue);
1977+
result.append((char) cvalue);
19761978
}
19771979

19781980
i--;
19791981

1980-
if (i < end - 2 && (ch[i+1] == '\r' && ch[i+2] == '\n')) {
1982+
if (i < end - 2 && (ch[i + 1] == '\r' && ch[i + 2] == '\n')) {
19811983
i += 2;
19821984
} else if (i < end - 1 &&
1983-
(ch[i+1] == ' ' || ch[i+1] == '\t' ||
1984-
ch[i+1] == '\n' || ch[i+1] == '\r' ||
1985-
ch[i+1] == '\f')) {
1985+
(ch[i + 1] == ' ' || ch[i + 1] == '\t' ||
1986+
ch[i + 1] == '\n' || ch[i + 1] == '\r' ||
1987+
ch[i + 1] == '\f')) {
19861988
i++;
19871989
}
19881990
} else {

openpdf-html/src/main/java/org/openpdf/render/BorderPainter.java

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ public class BorderPainter {
3838
public static final int BOTTOM = 4;
3939
public static final int RIGHT = 8;
4040
public static final int ALL = TOP | LEFT | BOTTOM | RIGHT;
41+
4142
/**
4243
* Generates a full round rectangle that is made of bounds and border
44+
*
4345
* @param bounds Dimensions of the rect
4446
* @param border The border specs
4547
* @param inside Set true if you want the inner bounds of borders
@@ -56,6 +58,7 @@ public static Shape generateBorderBounds(Rectangle bounds, BorderPropertySet bor
5658

5759
/**
5860
* Generates one side of a border
61+
*
5962
* @param bounds bounds of the container
6063
* @param side what side you want
6164
* @param border border props
@@ -65,8 +68,10 @@ public static Shape generateBorderBounds(Rectangle bounds, BorderPropertySet bor
6568
public static Path2D generateBorderShape(Rectangle bounds, int side, BorderPropertySet border, boolean drawInterior) {
6669
return generateBorderShape(bounds, side, border, drawInterior, 0, 1, true);
6770
}
71+
6872
/**
6973
* Generates one side of a border
74+
*
7075
* @param bounds bounds of the container
7176
* @param side what side you want
7277
* @param border border props
@@ -80,6 +85,7 @@ public static Path2D generateBorderShape(Rectangle bounds, int side, BorderPrope
8085

8186
/**
8287
* Generates one side of a border
88+
*
8389
* @param bounds bounds of the container
8490
* @param side what side you want
8591
* @param border border props
@@ -115,39 +121,39 @@ public static Path2D generateBorderShape(Rectangle bounds, int side, BorderPrope
115121
if (widthSum != 0.0f) { // Avoid NaN
116122
angle = fullAngle * props.getTop() / widthSum;
117123
}
118-
appendPath(path, 0-props.getLeft(), 0-props.getTop(), props.getLeftCorner().left(), props.getLeftCorner().right(), 90+angle+overlapAngle, -angle-overlapAngle, props.getTop(), props.getLeft(), scaledOffset, true);
124+
appendPath(path, 0 - props.getLeft(), 0 - props.getTop(), props.getLeftCorner().left(), props.getLeftCorner().right(), 90 + angle + overlapAngle, -angle - overlapAngle, props.getTop(), props.getLeft(), scaledOffset, true);
119125

120126
angle = defaultAngle;
121127
widthSum = props.getTop() + props.getRight();
122128
if (widthSum != 0.0f) { // Avoid NaN
123129
angle = fullAngle * props.getTop() / widthSum;
124130
}
125-
appendPath(path, sideWidth+props.getRight(), 0-props.getTop(), props.getRightCorner().right(), props.getRightCorner().left(), 90, -angle-overlapAngle, props.getTop(), props.getRight(), scaledOffset, false);
131+
appendPath(path, sideWidth + props.getRight(), 0 - props.getTop(), props.getRightCorner().right(), props.getRightCorner().left(), 90, -angle - overlapAngle, props.getTop(), props.getRight(), scaledOffset, false);
126132

127-
if(drawInterior) {
133+
if (drawInterior) {
128134
//border = border.normalizeBorderRadius(new Rectangle((int)(bounds.width), (int)(bounds.height)));
129135
//props = new RelativeBorderProperties(bounds, border, 0f, side, 1+scaledOffset, 1);
130136

131-
appendPath(path, sideWidth, 0, props.getRightCorner().right(), props.getRightCorner().left(), 90-angle-overlapAngle, angle+overlapAngle, props.getTop(), props.getRight(), scaledOffset+1, false);
137+
appendPath(path, sideWidth, 0, props.getRightCorner().right(), props.getRightCorner().left(), 90 - angle - overlapAngle, angle + overlapAngle, props.getTop(), props.getRight(), scaledOffset + 1, false);
132138

133139
angle = defaultAngle;
134140
widthSum = props.getTop() + props.getLeft();
135141
if (widthSum != 0.0f) { // Avoid NaN
136142
angle = fullAngle * props.getTop() / widthSum;
137143
}
138-
appendPath(path, 0, 0, props.getLeftCorner().left(), props.getLeftCorner().right(), 90, angle+overlapAngle, props.getTop(), props.getLeft(), scaledOffset+1, true);
144+
appendPath(path, 0, 0, props.getLeftCorner().left(), props.getLeftCorner().right(), 90, angle + overlapAngle, props.getTop(), props.getLeft(), scaledOffset + 1, true);
139145
path.closePath();
140146
}
141147

142148

143149
path.transform(AffineTransform.getTranslateInstance(
144-
(!props.isDimensionsSwapped() ? -bounds.width/2f : -bounds.height/2f) + (scaledOffset+1)*props.getLeft(),
145-
(props.isDimensionsSwapped() ? -bounds.width/2f : -bounds.height/2f) + (scaledOffset+1)*props.getTop()));
150+
(!props.isDimensionsSwapped() ? -bounds.width / 2f : -bounds.height / 2f) + (scaledOffset + 1) * props.getLeft(),
151+
(props.isDimensionsSwapped() ? -bounds.width / 2f : -bounds.height / 2f) + (scaledOffset + 1) * props.getTop()));
146152
path.transform(AffineTransform.getRotateInstance(
147153
props.getRotation()));
148154
// empirical: add 0.5 to better play with rasterization rules
149155
path.transform(AffineTransform.getTranslateInstance(
150-
bounds.width/2f+bounds.x, bounds.height/2f+bounds.y));
156+
bounds.width / 2f + bounds.x, bounds.height / 2f + bounds.y));
151157

152158
return path;
153159
}
@@ -187,36 +193,36 @@ private static class RelativeBorderProperties {
187193
public RelativeBorderProperties(BorderPropertySet props, int side, float widthScale) {
188194

189195
if ((side & BorderPainter.TOP) == BorderPainter.TOP) {
190-
_top = props.top()*widthScale;
191-
_left = props.left()*widthScale;
192-
_right = props.right()*widthScale;
196+
_top = props.top() * widthScale;
197+
_left = props.left() * widthScale;
198+
_right = props.right() * widthScale;
193199
_leftCorner = props.getTopLeft();
194200
_rightCorner = props.getTopRight();
195201
_rotation = 0;
196202
_dimensionsSwapped = false;
197203
} else if ((side & BorderPainter.RIGHT) == BorderPainter.RIGHT) {
198-
_top = props.right()*widthScale;
199-
_left = props.top()*widthScale;
200-
_right = props.bottom()*widthScale;
204+
_top = props.right() * widthScale;
205+
_left = props.top() * widthScale;
206+
_right = props.bottom() * widthScale;
201207
_leftCorner = props.getTopRight();
202208
_rightCorner = props.getBottomRight();
203-
_rotation = Math.PI/2;
209+
_rotation = Math.PI / 2;
204210
_dimensionsSwapped = true;
205211
} else if ((side & BorderPainter.BOTTOM) == BorderPainter.BOTTOM) {
206-
_top = props.bottom()*widthScale;
207-
_left = props.right()*widthScale;
208-
_right = props.left()*widthScale;
212+
_top = props.bottom() * widthScale;
213+
_left = props.right() * widthScale;
214+
_right = props.left() * widthScale;
209215
_leftCorner = props.getBottomRight();
210216
_rightCorner = props.getBottomLeft();
211217
_rotation = Math.PI;
212218
_dimensionsSwapped = false;
213219
} else if ((side & BorderPainter.LEFT) == BorderPainter.LEFT) {
214-
_top = props.left()*widthScale;
215-
_left = props.bottom()*widthScale;
216-
_right = props.top()*widthScale;
220+
_top = props.left() * widthScale;
221+
_left = props.bottom() * widthScale;
222+
_right = props.top() * widthScale;
217223
_leftCorner = props.getBottomLeft();
218224
_rightCorner = props.getTopLeft();
219-
_rotation = 3*Math.PI/2;
225+
_rotation = 3 * Math.PI / 2;
220226
_dimensionsSwapped = true;
221227
} else {
222228
throw new IllegalArgumentException("No side found");
@@ -226,15 +232,19 @@ public RelativeBorderProperties(BorderPropertySet props, int side, float widthSc
226232
public BorderRadiusCorner getRightCorner() {
227233
return _rightCorner;
228234
}
235+
229236
public BorderRadiusCorner getLeftCorner() {
230237
return _leftCorner;
231238
}
239+
232240
public float getTop() {
233241
return _top;
234242
}
243+
235244
public float getLeft() {
236245
return _left;
237246
}
247+
238248
public float getRight() {
239249
return _right;
240250
}
@@ -319,19 +329,19 @@ private static void paintBorderSide(OutputDevice outputDevice, final BorderPrope
319329
0, 1, currentSide);
320330
} else if (borderSideStyle == IdentValue.SOLID) {
321331
outputDevice.setStroke(new BasicStroke(1f));
322-
if(currentSide == TOP) {
332+
if (currentSide == TOP) {
323333
outputDevice.setColor(border.topColor());
324334
outputDevice.fill(generateBorderShape(bounds, TOP, border, true, 0, 1, true));
325335
}
326-
if(currentSide == RIGHT) {
336+
if (currentSide == RIGHT) {
327337
outputDevice.setColor(border.rightColor());
328338
outputDevice.fill(generateBorderShape(bounds, RIGHT, border, true, 0, 1, true));
329339
}
330-
if(currentSide == BOTTOM) {
340+
if (currentSide == BOTTOM) {
331341
outputDevice.setColor(border.bottomColor());
332342
outputDevice.fill(generateBorderShape(bounds, BOTTOM, border, true, 0, 1, true));
333343
}
334-
if(currentSide == LEFT) {
344+
if (currentSide == LEFT) {
335345
outputDevice.setColor(border.leftColor());
336346
outputDevice.fill(generateBorderShape(bounds, LEFT, border, true, 0, 1, true));
337347
}
@@ -340,10 +350,18 @@ private static void paintBorderSide(OutputDevice outputDevice, final BorderPrope
340350
paintDoubleBorder(outputDevice, border, bounds, currentSide);
341351
} else {
342352
int thickness = 0;
343-
if (currentSide == BorderPainter.TOP) thickness = (int) border.top();
344-
if (currentSide == BorderPainter.BOTTOM) thickness = (int) border.bottom();
345-
if (currentSide == BorderPainter.RIGHT) thickness = (int) border.right();
346-
if (currentSide == BorderPainter.LEFT) thickness = (int) border.left();
353+
if (currentSide == BorderPainter.TOP) {
354+
thickness = (int) border.top();
355+
}
356+
if (currentSide == BorderPainter.BOTTOM) {
357+
thickness = (int) border.bottom();
358+
}
359+
if (currentSide == BorderPainter.RIGHT) {
360+
thickness = (int) border.right();
361+
}
362+
if (currentSide == BorderPainter.LEFT) {
363+
thickness = (int) border.left();
364+
}
347365
if (borderSideStyle == IdentValue.DASHED) {
348366
//outputDevice.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
349367
paintPatternedRect(outputDevice, bounds, border, border, new float[]{8.0f + thickness * 2, 4.0f + thickness}, currentSide, xOffset);
@@ -362,10 +380,10 @@ private static void paintDoubleBorder(
362380
OutputDevice outputDevice, BorderPropertySet border,
363381
Rectangle bounds, int currentSide) {
364382
// draw outer border
365-
paintSolid(outputDevice, bounds, border, 0, 1/3f, currentSide);
383+
paintSolid(outputDevice, bounds, border, 0, 1 / 3f, currentSide);
366384
// draw inner border
367385
//paintSolid(outputDevice, bounds, border, 1, 1/3f, sides, currentSide, bevel);
368-
paintSolid(outputDevice, bounds, border, 2, 1/3f, currentSide);
386+
paintSolid(outputDevice, bounds, border, 2, 1 / 3f, currentSide);
369387
}
370388

371389
/**
@@ -389,22 +407,22 @@ private static void paintPatternedRect(OutputDevice outputDevice,
389407
outputDevice.setColor(color.topColor());
390408
outputDevice.setStroke(new BasicStroke(2f * border.top(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, pattern, xOffset));
391409
outputDevice.drawBorderLine(
392-
path, BorderPainter.TOP, (int)border.top(), false);
410+
path, BorderPainter.TOP, (int) border.top(), false);
393411
} else if (currentSide == BorderPainter.LEFT) {
394412
outputDevice.setColor(color.leftColor());
395413
outputDevice.setStroke(new BasicStroke(2f * border.left(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, pattern, 0));
396414
outputDevice.drawBorderLine(
397-
path, BorderPainter.LEFT, (int)border.left(), false);
415+
path, BorderPainter.LEFT, (int) border.left(), false);
398416
} else if (currentSide == BorderPainter.RIGHT) {
399417
outputDevice.setColor(color.rightColor());
400418
outputDevice.setStroke(new BasicStroke(2f * border.right(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, pattern, 0));
401419
outputDevice.drawBorderLine(
402-
path, BorderPainter.RIGHT, (int)border.right(), false);
420+
path, BorderPainter.RIGHT, (int) border.right(), false);
403421
} else if (currentSide == BorderPainter.BOTTOM) {
404422
outputDevice.setColor(color.bottomColor());
405423
outputDevice.setStroke(new BasicStroke(2f * border.bottom(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, pattern, xOffset));
406424
outputDevice.drawBorderLine(
407-
path, BorderPainter.BOTTOM, (int)border.bottom(), false);
425+
path, BorderPainter.BOTTOM, (int) border.bottom(), false);
408426
}
409427

410428
outputDevice.setClip(old_clip);

0 commit comments

Comments
 (0)