From: Dan B. <dan...@us...> - 2007-06-28 21:55:57
|
Update of /cvsroot/jmri/jmri/jmrit/display In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv5117/src/jmri/jmrit/display Modified Files: TurnoutIcon.java Log Message: Turnouts with feedback can optionally transition through the inconsistent state icon for better panel animation. This new feature is enabled by the tristate selection in the turnout popup menu. The default for this feature is "true". Index: TurnoutIcon.java =================================================================== RCS file: /cvsroot/jmri/jmri/jmrit/display/TurnoutIcon.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** TurnoutIcon.java 26 Jun 2007 04:17:27 -0000 1.29 --- TurnoutIcon.java 28 Jun 2007 21:55:54 -0000 1.30 *************** *** 123,128 **** } - private boolean useUnknownIcon = true; // allow panel to display unknown icon - // update icon as state of turnout changes public void propertyChange(java.beans.PropertyChangeEvent e) { --- 123,126 ---- *************** *** 131,152 **** + e.getNewValue()); ! // if there's feedback, we always know the state of the turnout ! // so we reusing the unknown state icon for the transistion state ! // between turnout command given and turnout response received ! if (useUnknownIcon & (turnout.getFeedbackMode() != Turnout.DIRECT)) { ! if (e.getPropertyName().equals("CommandedState")) { ! if (turnout.getCommandedState() != turnout.getKnownState()) { ! int now = Turnout.UNKNOWN; ! displayState(now); ! } ! // this takes care of the quick double click ! if (turnout.getCommandedState() == turnout.getKnownState()) { ! int now = ((Integer) e.getNewValue()).intValue(); ! displayState(now); ! } } } ! ! if (e.getPropertyName().equals("KnownState")) { int now = ((Integer) e.getNewValue()).intValue(); --- 129,148 ---- + e.getNewValue()); ! // when there's feedback, transition through inconsistent icon for better ! // animation ! if (super.getTristate() ! && (turnout.getFeedbackMode() != Turnout.DIRECT) ! && (e.getPropertyName().equals("CommandedState"))) { ! if (turnout.getCommandedState() != turnout.getKnownState()) { ! int now = Turnout.INCONSISTENT; ! displayState(now); ! } ! // this takes care of the quick double click ! if (turnout.getCommandedState() == turnout.getKnownState()) { ! int now = ((Integer) e.getNewValue()).intValue(); ! displayState(now); } } ! if (e.getPropertyName().equals("KnownState")) { int now = ((Integer) e.getNewValue()).intValue(); *************** *** 174,210 **** */ protected void showPopUp(MouseEvent e) { ! if (!getEditable()) return; ! ours = this; ! if (popup==null) { ! popup = new JPopupMenu(); ! popup.add(new JMenuItem(getNameString())); ! if (icon) popup.add(new AbstractAction("Rotate") { ! public void actionPerformed(ActionEvent e) { ! closed.setRotation(closed.getRotation()+1, ours); ! thrown.setRotation(thrown.getRotation()+1, ours); ! unknown.setRotation(unknown.getRotation()+1, ours); ! inconsistent.setRotation(inconsistent.getRotation()+1, ours); ! displayState(turnoutState()); ! } ! }); ! addDisableMenuEntry(popup); ! ! popup.add(new AbstractAction("Remove") { ! public void actionPerformed(ActionEvent e) { ! remove(); ! dispose(); ! } ! }); ! } // end creation of pop-up menu ! popup.show(e.getComponent(), e.getX(), e.getY()); ! } /** ! * Drive the current state of the display from the state of the ! * turnout. ! */ void displayState(int state) { log.debug("displayState "+state); --- 170,213 ---- */ protected void showPopUp(MouseEvent e) { ! if (!getEditable()) ! return; ! ours = this; ! // create popup each time called, tristate added if turnout has feedback ! popup = new JPopupMenu(); ! popup.add(new JMenuItem(getNameString())); ! if (icon) ! popup.add(new AbstractAction("Rotate") { ! public void actionPerformed(ActionEvent e) { ! closed.setRotation(closed.getRotation() + 1, ours); ! thrown.setRotation(thrown.getRotation() + 1, ours); ! unknown.setRotation(unknown.getRotation() + 1, ours); ! inconsistent.setRotation(inconsistent.getRotation() + 1, ! ours); ! displayState(turnoutState()); ! } ! }); ! addDisableMenuEntry(popup); ! // add tristate option if turnout has feedback ! if (turnout.getFeedbackMode() != Turnout.DIRECT) { ! addTristateEntry(popup); ! } ! popup.add(new AbstractAction("Remove") { ! public void actionPerformed(ActionEvent e) { ! remove(); ! dispose(); ! } ! }); ! ! // end creation of pop-up menu ! ! popup.show(e.getComponent(), e.getX(), e.getY()); ! } /** ! * Drive the current state of the display from the state of the turnout. ! */ void displayState(int state) { log.debug("displayState "+state); |