diff --git a/java/src/jmri/jmrix/can/cbus/CbusEventHighlighter.java b/java/src/jmri/jmrix/can/cbus/CbusEventHighlighter.java index d5379c09373..e670d60fa43 100644 --- a/java/src/jmri/jmrix/can/cbus/CbusEventHighlighter.java +++ b/java/src/jmri/jmrix/can/cbus/CbusEventHighlighter.java @@ -28,19 +28,29 @@ public class CbusEventHighlighter { */ public CbusEventHighlighter() { } - + /** - * highlight an event, based on previous settings. + * Highlight a CAN Frame, based on previous settings. * - * @param m CanMessage to highlight. + * @param m CanMessage or CanReply to highlight. * @return true if event matches */ - public boolean highlight(CanMessage m) { - return !((doNotHighlight(m)) - || ((_dir != CbusConstants.EVENT_DIR_EITHER) + public boolean highlight(AbstractMessage m){ + if (m instanceof CanMessage){ + return !((doNotHighlight(m)) + || ((_dir != CbusConstants.EVENT_DIR_EITHER) && (_dir != CbusConstants.EVENT_DIR_OUT))); + } + else if (m instanceof CanReply){ + return !((doNotHighlight(m)) + || ((_dir != CbusConstants.EVENT_DIR_EITHER) + && (_dir != CbusConstants.EVENT_DIR_IN))); + } + else { + return false; + } } - + /** * * @param m CanFrame to test against @@ -53,14 +63,6 @@ private boolean doNotHighlight(AbstractMessage m) { || ((_type != CbusConstants.EVENT_EITHER) && (_type != CbusMessage.getEventType(m)))); } - - public boolean highlight(CanReply r) { - return !((doNotHighlight(r)) - || ((_dir != CbusConstants.EVENT_DIR_EITHER) - && (_dir != CbusConstants.EVENT_DIR_IN))); - } - - // control terms to be included in highlight /** * Set whether NN (Node Number) will be included in highlight. diff --git a/java/src/jmri/jmrix/can/cbus/swing/CbusEventHighlightFrame.java b/java/src/jmri/jmrix/can/cbus/swing/CbusEventHighlightFrame.java index 36cdc87630d..73c94ad9f42 100644 --- a/java/src/jmri/jmrix/can/cbus/swing/CbusEventHighlightFrame.java +++ b/java/src/jmri/jmrix/can/cbus/swing/CbusEventHighlightFrame.java @@ -4,16 +4,15 @@ import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.WindowConstants; -import jmri.jmrix.can.CanMessage; -import jmri.jmrix.can.CanReply; +import jmri.jmrix.AbstractMessage; import jmri.jmrix.can.cbus.CbusConstants; import jmri.jmrix.can.cbus.CbusEventHighlighter; import jmri.jmrix.can.cbus.swing.console.CbusConsolePane; import jmri.jmrix.can.cbus.swing.configtool.ConfigToolPane; import jmri.util.JmriJFrame; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +// import org.slf4j.Logger; +// import org.slf4j.LoggerFactory; /** * Frame to control an instance of CBUS highlighter to highlight events. @@ -44,7 +43,6 @@ public class CbusEventHighlightFrame extends JmriJFrame { */ public CbusEventHighlightFrame(CbusConsolePane console, ConfigToolPane evCap) { super(); - log.debug("CbusEventhighlightFrame(CbusEventFilter) ctor called"); for (int i = 0; i < HIGHLIGHTERS; i++) { _highlight[i] = new CbusEventHighlighter(); _highlightActive[i] = false; @@ -52,14 +50,17 @@ public CbusEventHighlightFrame(CbusConsolePane console, ConfigToolPane evCap) { _console = console; _evCap = evCap; this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); - log.debug("CbusEventFilterFrame(CbusEventFilter) ctor done"); } protected CbusEventHighlightFrame() { super(); } - protected String title() { + /** + * {@inheritDoc} + */ + @Override + public String getTitle() { if ( _console != null) { return _console.getTitle() + " " + Bundle.getMessage("EventHighlightTitle"); } @@ -69,9 +70,6 @@ else if ( _evCap != null) { return(Bundle.getMessage("EventHighlightTitle")); } - protected void init() { - } - /** * {@inheritDoc} */ @@ -85,7 +83,7 @@ public void dispose() { */ @Override public void initComponents() { - setTitle(title()); + setTitle(getTitle()); // Panels will be added downwards getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); @@ -102,6 +100,9 @@ public void initComponents() { pack(); } + /** + * Enable Highlighter. + */ public void enable(int index, int nn, boolean nnEn, int ev, boolean evEn, int ty, int dr) { _highlight[index].setNn(nn); @@ -162,6 +163,10 @@ private void appendDirection( StringBuilder sb, int index ){ } } + /** + * Disable a Highlighter by Index Number. + * @param index Highlighter Index number + */ public void disable(int index) { _highlightActive[index] = false; if ( _console != null) { @@ -169,9 +174,13 @@ public void disable(int index) { } } - public int highlight(CanMessage m) { - int i; - for (i = 0; i < HIGHLIGHTERS; i++) { + /** + * Get whether to Highlight a particular CAN Frame. + * @param m CanMessage or CanReply + * @return -1 to NOT Highlight, else Highlighter Number. + */ + public int highlight(AbstractMessage m) { + for (int i = 0; i < HIGHLIGHTERS; i++) { if (_highlightActive[i] && _highlight[i].highlight(m)) { return i; } @@ -179,19 +188,14 @@ public int highlight(CanMessage m) { return -1; } - public int highlight(CanReply r) { - int i; - for (i = 0; i < HIGHLIGHTERS; i++) { - if (_highlightActive[i] && _highlight[i].highlight(r)) { - return i; - } - } - return -1; - } - + /** + * Get Colour for a particular highlighter. + * @param i Highlight index + * @return Highlight Colour + */ public Color getColor(int i) { return highlightColors[i]; } - private final static Logger log = LoggerFactory.getLogger(CbusEventHighlightFrame.class); + // private final static Logger log = LoggerFactory.getLogger(CbusEventHighlightFrame.class); }