Skip to content

Commit 106f86d

Browse files
committed
unified rectangle drawing
1 parent 7fcea44 commit 106f86d

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

src/main/java/net/itarray/automotion/internal/DrawableScreenshot.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ public void drawHorizontalLine(Scalar y) {
6464
graphics.drawHorizontalLine(y.intValue(), extend.getX().intValue());
6565
}
6666

67-
public void drawRectangle(int x, int y, int width, int height) {
68-
drawingConfiguration.setHighlightedElementStyle(graphics);
69-
graphics.drawRectByExtend(x, y, width, height);
70-
}
71-
7267
public void saveDrawing() {
7368
try {
7469
ImageIO.write(drawings, "png", drawingsOutput);
@@ -79,10 +74,21 @@ public void saveDrawing() {
7974
drawings.getGraphics().dispose();
8075
}
8176

82-
public void drawRootElement(UIElement rootElement) {
77+
public void drawRoot(UIElement rootElement) {
8378
drawingConfiguration.setRootElementStyle(graphics);
84-
int x = rootElement.getX().intValue();
85-
int y = rootElement.getY().intValue();
86-
graphics.drawRectByExtend(x, y, rootElement.getWidth().intValue(), rootElement.getHeight().intValue());
79+
basicDraw(rootElement);
80+
}
81+
82+
public void draw(UIElement element) {
83+
drawingConfiguration.setHighlightedElementStyle(graphics);
84+
basicDraw(element);
85+
}
86+
87+
private void basicDraw(UIElement element) {
88+
int x = element.getOrigin().getX().intValue();
89+
int y = element.getOrigin().getY().intValue();
90+
int width = element.getWidth().intValue();
91+
int height = element.getHeight().intValue();
92+
graphics.drawRectByExtend(x, y, width, height);
8793
}
8894
}

src/main/java/net/itarray/automotion/internal/ResponsiveUIValidatorBase.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,14 @@ public void add(String message) {
137137
@Override
138138
public void draw(UIElement element) {
139139
if (isWithReport()) {
140-
int x = element.getOrigin().getX().intValue();
141-
int y = element.getOrigin().getY().intValue();
142-
int width = element.getWidth().intValue();
143-
int height = element.getHeight().intValue();
144-
getDrawableScreenshot().drawRectangle(x, y, width, height);
140+
getDrawableScreenshot().draw(element);
145141
}
146142
}
147143

148144
@Override
149145
public void drawRoot(UIElement element) {
150146
if (isWithReport()) {
151-
getDrawableScreenshot().drawRootElement(element);
147+
getDrawableScreenshot().drawRoot(element);
152148
}
153149
}
154150

0 commit comments

Comments
 (0)