Skip to content

Commit

Permalink
Fix overlap of movenums in variation tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiraoka committed Mar 10, 2021
1 parent 6fd686b commit 13e1a36
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/featurecat/lizzie/gui/VariationTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import featurecat.lizzie.util.Utils;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
Expand Down Expand Up @@ -118,8 +119,13 @@ public Optional<BoardHistoryNode> drawTree(

// Draw all the nodes and lines in this lane (not variations)
Color curcolor = null;
Font origFont = null, movenumFont = null;
if (!calc) {
curcolor = g.getColor();
origFont = g.getFont();
movenumFont =
new Font(
Lizzie.config.uiFontName, Font.PLAIN, Lizzie.config.showLargeSubBoard() ? 10 : 12);
if (curposx > minposx && posy > 0) {
if (startNode.previous().isPresent()) {
if (Lizzie.config.showCommentNodeColor && !cur.getData().comment.isEmpty()) {
Expand All @@ -146,13 +152,15 @@ public Optional<BoardHistoryNode> drawTree(
g.drawRect(curposx, posy, DOT_DIAM, DOT_DIAM);
}
g.setColor(Color.WHITE);
g.setFont(movenumFont);
int moveMNNumber = startNode.getData().moveMNNumber;
g.drawString(
String.valueOf(moveMNNumber < 0 ? 0 : moveMNNumber),
curposx + RING_DIAM,
posy + RING_DIAM);
}
g.setColor(curcolor);
g.setFont(origFont);
}

// Draw main line
Expand Down Expand Up @@ -204,8 +212,10 @@ public Optional<BoardHistoryNode> drawTree(
+ (diff > 0 ? dotoffset + 1 : dotoffsety)
+ (Lizzie.config.nodeColorMode == 0 ? 1 : 0));
g.setColor(Color.WHITE);
g.setFont(movenumFont);
g.drawString(
String.valueOf(cur.getData().moveMNNumber), curposx + RING_DIAM, posy + RING_DIAM);
g.setFont(origFont);
}
}
// Now we have drawn all the nodes in this variation, and has reached the bottom of this
Expand Down Expand Up @@ -244,8 +254,8 @@ public Optional<BoardHistoryNode> draw(
}

// Use dense tree for saving space if large-subboard
YSPACING = (Lizzie.config.showLargeSubBoard() ? 30 : 40);
XSPACING = YSPACING;
XSPACING = 40;
YSPACING = (int) (XSPACING * (Lizzie.config.showLargeSubBoard() ? 0.75 : 1));

int strokeRadius = Lizzie.config.showBorder ? 2 : 0;
if (!calc) {
Expand Down

0 comments on commit 13e1a36

Please sign in to comment.