Skip to content

Commit

Permalink
Allow user turn on/off the border and the board border is no longer s…
Browse files Browse the repository at this point in the history
…upported, add another option if needed (#637)
  • Loading branch information
zsalch authored Oct 12, 2019
1 parent 65660c9 commit 36bd642
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 87 deletions.
34 changes: 18 additions & 16 deletions src/main/java/featurecat/lizzie/gui/BasicInfoPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,25 @@ private void drawCaptured(Graphics2D g, int posX, int posY, int width, int heigh
g.fillRect(posX, posY, width, height);

// border. does not include bottom edge
int strokeRadius = 3;
int strokeRadius = Lizzie.config.showBorder ? 3 : 1;
g.setStroke(new BasicStroke(strokeRadius == 1 ? strokeRadius : 2 * strokeRadius));
g.drawLine(
posX + strokeRadius,
posY + strokeRadius,
posX - strokeRadius + width,
posY + strokeRadius);
g.drawLine(
posX + strokeRadius,
posY + 3 * strokeRadius,
posX + strokeRadius,
posY - strokeRadius + height);
g.drawLine(
posX - strokeRadius + width,
posY + 3 * strokeRadius,
posX - strokeRadius + width,
posY - strokeRadius + height);
if (Lizzie.config.showBorder) {
g.drawLine(
posX + strokeRadius,
posY + strokeRadius,
posX - strokeRadius + width,
posY + strokeRadius);
g.drawLine(
posX + strokeRadius,
posY + 3 * strokeRadius,
posX + strokeRadius,
posY - strokeRadius + height);
g.drawLine(
posX - strokeRadius + width,
posY + 3 * strokeRadius,
posX - strokeRadius + width,
posY - strokeRadius + height);
}

// Draw middle line
g.drawLine(
Expand Down
34 changes: 20 additions & 14 deletions src/main/java/featurecat/lizzie/gui/BoardRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1042,16 +1042,17 @@ private void drawWoodenBoard(Graphics2D g) {
boardWidth + 4 * shadowRadius,
boardHeight + 4 * shadowRadius);

if (Lizzie.config.showBorder) {
g.setStroke(new BasicStroke(shadowRadius * 2));
// draw border
g.setColor(new Color(0, 0, 0, 50));
g.drawRect(
x - shadowRadius,
y - shadowRadius,
boardWidth + 2 * shadowRadius,
boardHeight + 2 * shadowRadius);
}
// The board border is no longer supported, add another option if needed
// if (Lizzie.config.showBorder) {
// g.setStroke(new BasicStroke(shadowRadius * 2));
// // draw border
// g.setColor(new Color(0, 0, 0, 50));
// g.drawRect(
// x - shadowRadius,
// y - shadowRadius,
// boardWidth + 2 * shadowRadius,
// boardHeight + 2 * shadowRadius);
// }
g.setStroke(new BasicStroke(1));

} else {
Expand Down Expand Up @@ -1511,8 +1512,11 @@ public Point getLocation() {
* @param boardLength the boardLength of the board
*/
public void setBoardLength(int boardWidth, int boardHeight) {
this.shadowRadius =
Lizzie.config.showBorder ? (int) (max(boardWidth, boardHeight) * MARGIN / 6) : 0;
// The board border is no longer supported, add another option if needed
// this.shadowRadius =
// Lizzie.config.showBorder ? (int) (max(boardWidth, boardHeight) * MARGIN / 6) :
// 0;this.shadowRadius =
this.shadowRadius = 0;
this.boardWidth = boardWidth - 4 * shadowRadius;
this.boardHeight = boardHeight - 4 * shadowRadius;
this.x = x + 2 * shadowRadius;
Expand All @@ -1534,8 +1538,10 @@ public void setBoardParam(int[] param) {
// re-center board
// setLocation(x + (boardWidth0 - boardWidth) / 2, y + (boardHeight0 - boardHeight) / 2);

this.shadowRadius =
Lizzie.config.showBorder ? (int) (max(boardWidth, boardHeight) * MARGIN / 6) : 0;
// The board border is no longer supported, add another option if needed
// this.shadowRadius =
// Lizzie.config.showBorder ? (int) (max(boardWidth, boardHeight) * MARGIN / 6) : 0;
this.shadowRadius = 0;
this.boardWidth = boardWidth - 4 * shadowRadius;
this.boardHeight = boardHeight - 4 * shadowRadius;
this.x = x + 2 * shadowRadius;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/featurecat/lizzie/gui/ConfigDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public class ConfigDialog extends JDialog {
public JRadioButton rdoShowMoveNumberLast;
public JTextField txtShowMoveNumber;
public JCheckBox chkShowBlunderBar;
public JCheckBox chkShowBorder;
public JCheckBox chkDynamicWinrateGraphWidth;
public JCheckBox chkAppendWinrateToComment;
public JCheckBox chkHoldBestMovesToSgf;
Expand Down Expand Up @@ -983,6 +984,13 @@ public void stateChanged(ChangeEvent e) {
chkShowSubBoard.setBounds(170, 116, 57, 23);
uiTab.add(chkShowSubBoard);

JLabel lblShowBorder = new JLabel(resourceBundle.getString("LizzieConfig.title.showBorder"));
lblShowBorder.setBounds(372, 119, 157, 16);
uiTab.add(lblShowBorder);
chkShowBorder = new JCheckBox("");
chkShowBorder.setBounds(536, 116, 57, 23);
uiTab.add(chkShowBorder);

JLabel lblShowCoordinates =
new JLabel(resourceBundle.getString("LizzieConfig.title.showCoordinates"));
lblShowCoordinates.setBounds(6, 146, 157, 16);
Expand Down Expand Up @@ -1187,6 +1195,7 @@ protected DocumentFilter getDocumentFilter() {
chkShowSubBoard.setSelected(Lizzie.config.showSubBoard);
chkShowCoordinates.setSelected(Lizzie.config.showCoordinates);
chkShowBlunderBar.setSelected(Lizzie.config.showBlunderBar);
chkShowBorder.setSelected(Lizzie.config.showBorder);
chkDynamicWinrateGraphWidth.setSelected(Lizzie.config.dynamicWinrateGraphWidth);
chkAppendWinrateToComment.setSelected(Lizzie.config.appendWinrateToComment);
chkHoldBestMovesToSgf.setSelected(Lizzie.config.holdBestMovesToSgf);
Expand Down Expand Up @@ -2504,6 +2513,8 @@ private void saveConfig() {

Lizzie.config.showBlunderBar = chkShowBlunderBar.isSelected();
Lizzie.config.uiConfig.putOpt("show-blunder-bar", Lizzie.config.showBlunderBar);
Lizzie.config.showBorder = chkShowBorder.isSelected();
Lizzie.config.uiConfig.putOpt("show-border", Lizzie.config.showBorder);
Lizzie.config.dynamicWinrateGraphWidth = chkDynamicWinrateGraphWidth.isSelected();
Lizzie.config.uiConfig.putOpt(
"dynamic-winrate-graph-width", Lizzie.config.dynamicWinrateGraphWidth);
Expand Down
81 changes: 46 additions & 35 deletions src/main/java/featurecat/lizzie/gui/LizzieFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -826,14 +826,16 @@ public void drawControls() {

g.setColor(new Color(0, 0, 0, 130));
g.fillRect(commandsX, commandsY, boxWidth, boxHeight);
int strokeRadius = 2;
int strokeRadius = Lizzie.config.showBorder ? 2 : 1;
g.setStroke(new BasicStroke(strokeRadius == 1 ? strokeRadius : 2 * strokeRadius));
g.setColor(new Color(0, 0, 0, 60));
g.drawRect(
commandsX + strokeRadius,
commandsY + strokeRadius,
boxWidth - 2 * strokeRadius,
boxHeight - 2 * strokeRadius);
if (Lizzie.config.showBorder) {
g.setColor(new Color(0, 0, 0, 60));
g.drawRect(
commandsX + strokeRadius,
commandsY + strokeRadius,
boxWidth - 2 * strokeRadius,
boxHeight - 2 * strokeRadius);
}
int verticalLineX = (int) (commandsX + boxWidth * 0.3);
g.setColor(new Color(0, 0, 0, 60));
g.drawLine(
Expand Down Expand Up @@ -870,21 +872,23 @@ private void drawCommandString(Graphics2D g) {

Font font = new Font(Lizzie.config.fontName, Font.PLAIN, (int) (maxSize * 0.03));
String commandString = resourceBundle.getString("LizzieFrame.prompt.showControlsHint");
int strokeRadius = 2;
int strokeRadius = Lizzie.config.showBorder ? 2 : 0;

int showCommandsHeight = (int) (font.getSize() * 1.1);
int showCommandsWidth = g.getFontMetrics(font).stringWidth(commandString) + 4 * strokeRadius;
int showCommandsX = mainPanel.getInsets().left;
int showCommandsY = mainPanel.getHeight() - showCommandsHeight - mainPanel.getInsets().bottom;
g.setColor(new Color(0, 0, 0, 130));
g.fillRect(showCommandsX, showCommandsY, showCommandsWidth, showCommandsHeight);
g.setStroke(new BasicStroke(2 * strokeRadius));
g.setColor(new Color(0, 0, 0, 60));
g.drawRect(
showCommandsX + strokeRadius,
showCommandsY + strokeRadius,
showCommandsWidth - 2 * strokeRadius,
showCommandsHeight - 2 * strokeRadius);
if (Lizzie.config.showBorder) {
g.setStroke(new BasicStroke(2 * strokeRadius));
g.setColor(new Color(0, 0, 0, 60));
g.drawRect(
showCommandsX + strokeRadius,
showCommandsY + strokeRadius,
showCommandsWidth - 2 * strokeRadius,
showCommandsHeight - 2 * strokeRadius);
}
g.setStroke(new BasicStroke(1));

g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Expand Down Expand Up @@ -936,17 +940,19 @@ private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int
g.fillRect(posX, posY, width, height);

// border. does not include bottom edge
int strokeRadius = 3;
int strokeRadius = Lizzie.config.showBorder ? 3 : 1;
g.setStroke(new BasicStroke(strokeRadius == 1 ? strokeRadius : 2 * strokeRadius));
g.drawLine(
posX + strokeRadius, posY + strokeRadius,
posX - strokeRadius + width, posY + strokeRadius);
g.drawLine(
posX + strokeRadius, posY + 3 * strokeRadius,
posX + strokeRadius, posY - strokeRadius + height);
g.drawLine(
posX - strokeRadius + width, posY + 3 * strokeRadius,
posX - strokeRadius + width, posY - strokeRadius + height);
if (Lizzie.config.showBorder) {
g.drawLine(
posX + strokeRadius, posY + 3 * strokeRadius,
posX + strokeRadius, posY - strokeRadius + height);
g.drawLine(
posX - strokeRadius + width, posY + 3 * strokeRadius,
posX - strokeRadius + width, posY - strokeRadius + height);
}

// resize the box now so it's inside the border
posX += 2 * strokeRadius;
Expand Down Expand Up @@ -1067,20 +1073,25 @@ private void drawCaptured(Graphics2D g, int posX, int posY, int width, int heigh
g.fillRect(posX, posY, width, height);

// border. does not include bottom edge
int strokeRadius = 3;
int strokeRadius = Lizzie.config.showBorder ? 3 : 1;
g.setStroke(new BasicStroke(strokeRadius == 1 ? strokeRadius : 2 * strokeRadius));
g.drawLine(
posX + strokeRadius, posY + strokeRadius, posX - strokeRadius + width, posY + strokeRadius);
g.drawLine(
posX + strokeRadius,
posY + 3 * strokeRadius,
posX + strokeRadius,
posY - strokeRadius + height);
g.drawLine(
posX - strokeRadius + width,
posY + 3 * strokeRadius,
posX - strokeRadius + width,
posY - strokeRadius + height);
if (Lizzie.config.showBorder) {
g.drawLine(
posX + strokeRadius,
posY + strokeRadius,
posX - strokeRadius + width,
posY + strokeRadius);
g.drawLine(
posX + strokeRadius,
posY + 3 * strokeRadius,
posX + strokeRadius,
posY - strokeRadius + height);
g.drawLine(
posX - strokeRadius + width,
posY + 3 * strokeRadius,
posX - strokeRadius + width,
posY - strokeRadius + height);
}

// Draw middle line
g.drawLine(
Expand Down
20 changes: 11 additions & 9 deletions src/main/java/featurecat/lizzie/gui/VariationTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,21 +238,23 @@ public Optional<BoardHistoryNode> draw(
YSPACING = (Lizzie.config.showLargeSubBoard() ? 20 : 30);
XSPACING = YSPACING;

int strokeRadius = 2;
int strokeRadius = Lizzie.config.showBorder ? 2 : 0;
if (!calc) {
// Draw background
area.setBounds(posx, posy, width, height);
g.setColor(new Color(0, 0, 0, 60));
g.fillRect(posx, posy, width, height);

// draw edge of panel
g.setStroke(new BasicStroke(2 * strokeRadius));
g.drawLine(
posx + strokeRadius,
posy + strokeRadius,
posx + strokeRadius,
posy - strokeRadius + height);
g.setStroke(new BasicStroke(1));
if (Lizzie.config.showBorder) {
// draw edge of panel
g.setStroke(new BasicStroke(2 * strokeRadius));
g.drawLine(
posx + strokeRadius,
posy + strokeRadius,
posx + strokeRadius,
posy - strokeRadius + height);
g.setStroke(new BasicStroke(1));
}
}

int middleY = posy + height / 2;
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/featurecat/lizzie/gui/WinrateGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,20 @@ public void draw(Graphics2D g, int posx, int posy, int width, int height) {
g.fillRect(posx, posy, width, height);

// draw border
int strokeRadius = 3;
int strokeRadius = Lizzie.config.showBorder ? 3 : 1;
g.setStroke(new BasicStroke(strokeRadius == 1 ? strokeRadius : 2 * strokeRadius));
g.setPaint(borderGradient);
g.drawRect(
posx + strokeRadius,
posy + strokeRadius,
width - 2 * strokeRadius,
height - 2 * strokeRadius);
if (Lizzie.config.showBorder) {
g.drawRect(
posx + strokeRadius,
posy + strokeRadius,
width - 2 * strokeRadius,
height - 2 * strokeRadius);
} else {
g.drawLine(
posx + strokeRadius, posy + strokeRadius,
posx - strokeRadius + width, posy + strokeRadius);
}

g.setPaint(original);

Expand Down
16 changes: 9 additions & 7 deletions src/main/java/featurecat/lizzie/gui/WinratePane.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,19 @@ private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int
g.fillRect(posX, posY, width, height);

// border. does not include bottom edge
int strokeRadius = 3;
int strokeRadius = Lizzie.config.showBorder ? 3 : 1;
g.setStroke(new BasicStroke(strokeRadius == 1 ? strokeRadius : 2 * strokeRadius));
g.drawLine(
posX + strokeRadius, posY + strokeRadius,
posX - strokeRadius + width, posY + strokeRadius);
g.drawLine(
posX + strokeRadius, posY + 3 * strokeRadius,
posX + strokeRadius, posY - strokeRadius + height);
g.drawLine(
posX - strokeRadius + width, posY + 3 * strokeRadius,
posX - strokeRadius + width, posY - strokeRadius + height);
if (Lizzie.config.showBorder) {
g.drawLine(
posX + strokeRadius, posY + 3 * strokeRadius,
posX + strokeRadius, posY - strokeRadius + height);
g.drawLine(
posX - strokeRadius + width, posY + 3 * strokeRadius,
posX - strokeRadius + width, posY - strokeRadius + height);
}

// resize the box now so it's inside the border
posX += 2 * strokeRadius;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/l10n/DisplayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ LizzieConfig.title.showMoveNumberNo=Do not
LizzieConfig.title.showMoveNumberAll=All
LizzieConfig.title.showMoveNumberLast=Last
LizzieConfig.title.showBlunderBar=Show Blunder Bar
LizzieConfig.title.showBorder=Show Border
LizzieConfig.title.dynamicWinrateGraphWidth=Dynamic Winrate Graph Width
LizzieConfig.title.appendWinrateToComment=Append Winrate To Comment
LizzieConfig.title.holdBestMovesToSgf=Hold Best Moves To Sgf
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/l10n/DisplayStrings_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ LizzieConfig.title.showMoveNumberNo=\u4E0D\u663E\u793A
LizzieConfig.title.showMoveNumberAll=\u5168\u90E8
LizzieConfig.title.showMoveNumberLast=\u6700\u540E
LizzieConfig.title.showBlunderBar=\u663E\u793A\u80DC\u7387\u53D8\u5316\u6761
LizzieConfig.title.showBorder=\u663E\u793A\u8FB9\u6846
LizzieConfig.title.dynamicWinrateGraphWidth=\u52A8\u6001\u80DC\u7387\u9762\u677F\u5BBD\u5EA6
LizzieConfig.title.appendWinrateToComment=\u5728\u8BC4\u8BBA\u4E2D\u9644\u52A0\u80DC\u7387
LizzieConfig.title.holdBestMovesToSgf=\u4FDD\u6301\u9009\u70B9\u81F3\u68CB\u8C31
Expand Down

0 comments on commit 36bd642

Please sign in to comment.