Skip to content

Commit

Permalink
Small style changes
Browse files Browse the repository at this point in the history
Signed-off-by: Jørgen Austvik <jaustvik@acm.org>
  • Loading branch information
austvik committed Oct 15, 2022
1 parent f3209ec commit a06588c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
4 changes: 2 additions & 2 deletions bundles/org.openhab.binding.nanoleaf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ In this case:

### Panel Layout

Unfortunately it is not easy to find out which panel gets which id, and this becomes pretty important if you have lots of them and want to assign rules.

For canvas that use square panels, you can request the layout through a [console command](https://www.openhab.org/docs/administration/console.html):

then issue the following command:
Expand All @@ -94,6 +92,8 @@ Compare the following output with the right picture at the beginning of the arti
41451
```

For other canvases, use the Layout channel on the controller to get a picture of the layout with the thing IDs.

## Thing Configuration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,7 @@ public static boolean checkRequiredFirmware(@Nullable String modelId, @Nullable

for (int i = 0; i < currentVer.length; ++i) {
if (currentVer[i] != requiredVer[i]) {
if (currentVer[i] > requiredVer[i]) {
return true;
}

return false;
return (currentVer[i] > requiredVer[i]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ private void updateLayout(PanelLayout panelLayout) {
updateState(CHANNEL_LAYOUT, new RawType(bytes, "image/png"));
}
} catch (IOException ioex) {
logger.info("Failed to create layout image", ioex);
logger.warn("Failed to create layout image", ioex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,23 @@ public static byte[] render(PanelLayout panelLayout) throws IOException {
Point2D current = new Point2D(NanoleafBindingConstants.LAYOUT_BORDER_WIDTH + rotated.getX() - min.getX(),
NanoleafBindingConstants.LAYOUT_BORDER_WIDTH - rotated.getY() - min.getY());

g2.fillOval((int) current.getX() - NanoleafBindingConstants.LAYOUT_LIGHT_RADIUS / 2,
(int) current.getY() - NanoleafBindingConstants.LAYOUT_LIGHT_RADIUS / 2,
g2.fillOval(current.getX() - NanoleafBindingConstants.LAYOUT_LIGHT_RADIUS / 2,
current.getY() - NanoleafBindingConstants.LAYOUT_LIGHT_RADIUS / 2,
NanoleafBindingConstants.LAYOUT_LIGHT_RADIUS, NanoleafBindingConstants.LAYOUT_LIGHT_RADIUS);
g2.drawString(Integer.toString(panel.getPanelId()), (int) current.getX(), (int) current.getY());
g2.drawString(Integer.toString(panel.getPanelId()), current.getX(), current.getY());

if (sideCounter == 0) {
first = current;
}

if (sideCounter > 0 && sideCounter != expectedSides && prev != null) {
g2.drawLine((int) prev.getX(), (int) prev.getY(), (int) current.getX(), (int) current.getY());
g2.drawLine(prev.getX(), prev.getY(), current.getX(), current.getY());
}

sideCounter++;

if (sideCounter == expectedSides && first != null) {
g2.drawLine((int) current.getX(), (int) current.getY(), (int) first.getX(), (int) first.getY());
g2.drawLine(current.getX(), current.getY(), first.getX(), first.getY());
sideCounter = 0;
}

Expand All @@ -110,19 +110,17 @@ private static double calculateRotation(GlobalOrientation globalOrientation) {
}

private static Point2D[] findSize(Collection<PositionDatum> panels, double rotationRadians) {

int maxX = 0;
int maxY = 0;
int minX = 0;
int minY = 0;

for (PositionDatum panel : panels) {
var rotated = new Point2D(panel.getPosX(), panel.getPosY()).rotate(rotationRadians);

maxX = Math.max((int) rotated.getX(), maxX);
maxY = Math.max((int) rotated.getY(), maxY);
minX = Math.min((int) rotated.getX(), minX);
minY = Math.min((int) rotated.getY(), minY);
maxX = Math.max(rotated.getX(), maxX);
maxY = Math.max(rotated.getY(), maxY);
minX = Math.min(rotated.getX(), minX);
minY = Math.min(rotated.getY(), minY);
}

return new Point2D[] { new Point2D(minX, minY), new Point2D(maxX, maxY) };
Expand Down

0 comments on commit a06588c

Please sign in to comment.