Skip to content

Commit

Permalink
[#75] Highlight borders of reachable filled cells.
Browse files Browse the repository at this point in the history
  • Loading branch information
soulne4ny committed Dec 19, 2012
1 parent b222dbf commit c362354
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Swing/src/com/yarcat/chemistrylines/swing/SwingField.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.awt.Color;

import javax.swing.border.Border;

import com.yarcat.chemistrylines.algorithms.Path;
import com.yarcat.chemistrylines.field.Cell;
import com.yarcat.chemistrylines.field.Cell.Mark;
Expand Down Expand Up @@ -39,6 +41,12 @@ private boolean marked(Mark m) {
return cell().hasMark(m);
}

@Override
void updateStyle() {
super.updateStyle();
setBorder(getEdge());
}

@Override
Color getBgColor() {
Color bg;
Expand All @@ -53,6 +61,11 @@ Color getBgColor() {
}
return bg;
}

private Border getEdge() {
return !isEmpty() && marked(Mark.ReachableFromSource)
? style.REACHABLE_BORDER : style.DEFAULT_BORDER;
}
}

class FieldSelection implements SelectionListener {
Expand Down
6 changes: 4 additions & 2 deletions Swing/src/com/yarcat/chemistrylines/swing/style.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ public class style {
private static final Color HIGHLIGHT_FG = Color.YELLOW;

// @formatter:off
private final static Border BORDER =
final static Border DEFAULT_BORDER =
BorderFactory.createLineBorder(new Color(0x55, 0x44, 0x33));
final static Border REACHABLE_BORDER =
BorderFactory.createLineBorder(new Color(0x20, 0x00, 0x30), 2);
// @formatter:on

static Component defaultColor(Component c) {
Expand All @@ -41,7 +43,7 @@ static void button(JLabel b) {

static void frame(JComponent c) {
defaultColor(c);
c.setBorder(BORDER);
c.setBorder(DEFAULT_BORDER);
c.setOpaque(true);
}
}

0 comments on commit c362354

Please sign in to comment.