fix(html): fix hashCode for triangle

The bug caused HTML class and CSS selector to have different IDs, breaking triangle rendering.
This commit was merged in pull request #20.
This commit is contained in:
2026-03-27 15:06:46 +01:00
parent da70c9f568
commit ba37b199de
4 changed files with 370 additions and 2 deletions

View File

@@ -66,11 +66,11 @@ public class HTMLDraftman implements ShapeVisitor {
@Override
public void visitTriangle(STriangle sTriangle) {
htmlOutput.printf("<div class=\"triangle%d\"></div>\n", this.hashCode());
htmlOutput.printf("<div class=\"triangle%d\"></div>\n", sTriangle.hashCode());
var bounds = sTriangle.getBounds();
ColorAttributes colAttrs = (ColorAttributes) sTriangle.getAttributes(ColorAttributes.ID);
String colorString = formatCSSColor(colAttrs.filledColor);
StringJoiner joiner = new StringJoiner("\n", ".triangle%d{\n".formatted(this.hashCode()), "\n}\n");
StringJoiner joiner = new StringJoiner("\n", ".triangle%d{\n".formatted(sTriangle.hashCode()), "\n}\n");
joiner.add(" position: absolute;");
joiner.add(" top: %dpx;".formatted(bounds.y));
joiner.add(" left: %dpx;".formatted(bounds.x));