Skip to content

Commit

Permalink
[refactor] make fields of RectPropertySet private
Browse files Browse the repository at this point in the history
unfortunatelly, I could not make the final because the setters are actually used. :(
  • Loading branch information
asolntsev committed Oct 24, 2024
1 parent 7bb7779 commit b3d83dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,23 +192,23 @@ public static BorderPropertySet newInstance(

@Override
public String toString() {
return "BorderPropertySet[top=%s,right=%s,bottom=%s,left=%s]".formatted(_top, _right, _bottom, _left);
return "BorderPropertySet[top=%s,right=%s,bottom=%s,left=%s]".formatted(top(), right(), bottom(), left());
}

public boolean noTop() {
return styles.top() == NONE || (int) _top == 0;
return styles.top() == NONE || (int) top() == 0;
}

public boolean noRight() {
return styles.right() == NONE || (int) _right == 0;
return styles.right() == NONE || (int) right() == 0;
}

public boolean noBottom() {
return styles.bottom() == NONE || (int) _bottom == 0;
return styles.bottom() == NONE || (int) bottom() == 0;
}

public boolean noLeft() {
return styles.left() == NONE || (int) _left == 0;
return styles.left() == NONE || (int) left() == 0;
}

public IdentValue topStyle() {
Expand Down Expand Up @@ -285,7 +285,7 @@ public BorderPropertySet normalizedInstance(Rectangle bounds) {
new BorderRadiusCorner(factor * corners.bottomRight().getMaxLeft(bounds.height), factor * corners.bottomRight().getMaxRight(bounds.width)),
new BorderRadiusCorner(factor * corners.bottomLeft().getMaxLeft(bounds.width), factor * corners.bottomLeft().getMaxRight(bounds.height))
);
return new BorderPropertySet(_top, _right, _bottom, _left,
return new BorderPropertySet(top(), right(), bottom(), left(),
styles,
normalizedCorners,
colors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@
* some rectangular area, and per-side thickness.
*/
public class RectPropertySet {
// HACK
public static final RectPropertySet ALL_ZEROS = new RectPropertySet(0, 0, 0, 0);

protected float _top;
protected float _right;
protected float _bottom;
protected float _left;

protected RectPropertySet() {
_top = _right = _bottom = _left = 0f;
}
private float _top;
private float _right;
private float _bottom;
private float _left;

public RectPropertySet(
float top,
Expand Down Expand Up @@ -98,12 +93,7 @@ public void setLeft(float _left) {
}

public RectPropertySet copyOf() {
RectPropertySet newRect = new RectPropertySet();
newRect._top = _top;
newRect._right = _right;
newRect._bottom = _bottom;
newRect._left = _left;
return newRect;
return new RectPropertySet(_top, _right, _bottom, _left);
}

public boolean isAllZeros() {
Expand Down

0 comments on commit b3d83dc

Please sign in to comment.