Skip to content
Snippets Groups Projects
Commit 617a58c7 authored by Anian Bühler's avatar Anian Bühler
Browse files

added/fixed "isBad"-functionality to RBHiglightHandler

parent d4facd63
Branches
No related tags found
1 merge request!1Dev preferences
...@@ -21,6 +21,7 @@ import javax.swing.SwingUtilities; ...@@ -21,6 +21,7 @@ import javax.swing.SwingUtilities;
import edu.mit.blocks.workspace.RBParent; import edu.mit.blocks.workspace.RBParent;
import edu.mit.blocks.codeblocks.Block;
import edu.mit.blocks.codeblockutil.GraphicsManager; import edu.mit.blocks.codeblockutil.GraphicsManager;
/** /**
...@@ -41,10 +42,12 @@ public class RBHighlightHandler extends JComponent implements ComponentListener, ...@@ -41,10 +42,12 @@ public class RBHighlightHandler extends JComponent implements ComponentListener,
private Area blockArea = null; private Area blockArea = null;
private RenderableBlock rb; private RenderableBlock rb;
private BufferedImage hImage; private BufferedImage hImage;
private Block block = null;
public RBHighlightHandler(RenderableBlock rb) { public RBHighlightHandler(RenderableBlock rb) {
super(); super();
this.rb = rb; this.rb = rb;
this.block = rb.getBlock();
setSize(HIGHLIGHT_STROKE_WIDTH / 2, 1); setSize(HIGHLIGHT_STROKE_WIDTH / 2, 1);
this.setOpaque(false); this.setOpaque(false);
hColor = null; hColor = null;
...@@ -122,17 +125,19 @@ public class RBHighlightHandler extends JComponent implements ComponentListener, ...@@ -122,17 +125,19 @@ public class RBHighlightHandler extends JComponent implements ComponentListener,
} }
// cache the focus so it'll know when it needs to redraw later. // cache the focus so it'll know when it needs to redraw later.
hasFocus = rb.getBlock().hasFocus(); //hasFocus = rb.getBlock().hasFocus();
hasFocus = block.hasFocus();
boolean isBad = block.isBad();
Color color = null; Color color = null;
if (hColor != null) { if (hColor != null) {
color = hColor; color = hColor;
} else if (rb.getBlock().hasFocus()) { } else if (hasFocus) {
color = new Color(200, 200, 255); //Color.BLUE); color = new Color(200, 200, 255); //Color.BLUE);
} else if (isBad) {
color = new Color(255, 100, 100); //Color.RED);
} else if (isSearchResult) { } else if (isSearchResult) {
color = new Color(255, 255, 120); //Color.YELLOW); color = new Color(255, 255, 120); //Color.YELLOW);
} else if (rb.getBlock().isBad()) {
color = new Color(255, 100, 100); //Color.RED);
} else { } else {
GraphicsManager.recycleGCCompatibleImage(hImage); GraphicsManager.recycleGCCompatibleImage(hImage);
hImage = null; hImage = null;
......
...@@ -273,7 +273,6 @@ public class RenderableBlock extends JComponent implements SearchableElement, ...@@ -273,7 +273,6 @@ public class RenderableBlock extends JComponent implements SearchableElement,
} else { } else {
blockArea = new Area(); blockArea = new Area();
} }
highlighter = new RBHighlightHandler(this); highlighter = new RBHighlightHandler(this);
String blockDescription = getBlock().getBlockDescription(); String blockDescription = getBlock().getBlockDescription();
......
...@@ -26,7 +26,7 @@ import edu.mit.blocks.codeblockutil.Canvas; ...@@ -26,7 +26,7 @@ import edu.mit.blocks.codeblockutil.Canvas;
class FactoryCanvas extends JPanel implements Canvas, SearchableContainer, RBParent, ComponentListener { class FactoryCanvas extends JPanel implements Canvas, SearchableContainer, RBParent, ComponentListener {
private static final long serialVersionUID = 328149080291L; private static final long serialVersionUID = 328149080291L;
private static final int BORDER_WIDTH = 10; private static final int BORDER_WIDTH = 8;
/** The highlight of this canvas */ /** The highlight of this canvas */
private Color highlight = null; private Color highlight = null;
/** The color of this canvas */ /** The color of this canvas */
...@@ -66,7 +66,7 @@ class FactoryCanvas extends JPanel implements Canvas, SearchableContainer, RBPar ...@@ -66,7 +66,7 @@ class FactoryCanvas extends JPanel implements Canvas, SearchableContainer, RBPar
public void updateContainsSearchResults(boolean containsSearchResults) { public void updateContainsSearchResults(boolean containsSearchResults) {
Color previousHighlight = this.highlight; Color previousHighlight = this.highlight;
if (containsSearchResults) { if (containsSearchResults) {
this.setHighlight(Color.yellow); this.setHighlight(Color.black);
} else { } else {
this.setHighlight(null); this.setHighlight(null);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment