Skip to content

Commit

Permalink
old GUI cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
klk32003 committed Mar 31, 2020
1 parent 7bb4557 commit f92d560
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 119 deletions.
4 changes: 2 additions & 2 deletions java/src/jmri/jmrit/DebugMenu.java
Expand Up @@ -42,8 +42,8 @@ public DebugMenu(JPanel panel) {
"jmri.jmrit.log.Log4JTreePane"));
add(new JSeparator());
JMenu vsdMenu = new JMenu(Bundle.getMessage("MenuItemVSDecoder"));
vsdMenu.add(new jmri.jmrit.vsdecoder.VSDecoderCreationAction(Bundle.getMessage("MenuItemVSDecoderManager"), true));
vsdMenu.add(new jmri.jmrit.vsdecoder.swing.ManageLocationsAction(Bundle.getMessage("MenuItemVSDecoderLocationManager"), null));
vsdMenu.add(new jmri.jmrit.vsdecoder.VSDecoderCreationAction(Bundle.getMessage("MenuItemVSDecoderManager")));
vsdMenu.add(new jmri.jmrit.vsdecoder.swing.ManageLocationsAction(Bundle.getMessage("MenuItemVSDecoderLocationManager")));
vsdMenu.add(new jmri.jmrit.vsdecoder.swing.VSDPreferencesAction(Bundle.getMessage("MenuItemVSDecoderPreferences")));
add(vsdMenu);

Expand Down
92 changes: 2 additions & 90 deletions java/src/jmri/jmrit/vsdecoder/VSDecoder.java
Expand Up @@ -62,32 +62,9 @@ public class VSDecoder implements PropertyChangeListener {
int topspeed_rev;
int setup_index; // Can be set by a Route

// List of registered event listeners
protected javax.swing.event.EventListenerList listenerList = new javax.swing.event.EventListenerList();

HashMap<String, VSDSound> sound_list; // list of sounds
HashMap<String, SoundEvent> event_list; // list of events

/**
* Construct a VSDecoder with a given name and ID (system name)
*
* @param id (String) System Name of this VSDecoder
* @param name (String) Sound Profile name for this VSDecoder
*/
@Deprecated
public VSDecoder(String id, String name) {

config = new VSDConfig();
config.setProfileName(name);
config.setId(id);

sound_list = new HashMap<String, VSDSound>();
event_list = new HashMap<String, SoundEvent>();

// Force re-initialization
initialized = _init();
}

/**
* Construct a VSDecoder with the given system name (id) and configuration
* (config)
Expand Down Expand Up @@ -223,49 +200,6 @@ public String getVSDFilePath() {
return config.getVSDPath();
}

// VSDecoder Events
/**
* Add a listener for this object's events
*
* @param listener handle
*/
public void addEventListener(VSDecoderListener listener) {
listenerList.add(VSDecoderListener.class, listener);
}

/**
* Remove a listener for this object's events
*
* @param listener handle
*/
public void removeEventListener(VSDecoderListener listener) {
listenerList.remove(VSDecoderListener.class, listener);
}

/**
* Fire an event to this object's listeners
*/
private void fireMyEvent(VSDecoderEvent evt) {
for (VSDecoderListener l : listenerList.getListeners(VSDecoderListener.class)) {
l.eventAction(evt);
}
}

/**
* Handle Window events from this VSDecoder's GUI window.
*
* @param e the window event to handle
*/
public void windowChange(java.awt.event.WindowEvent e) {
log.debug("decoder.windowChange() - {}", e.toString());
log.debug("param string: {}", e.paramString());
// if (e.paramString().equals("WINDOW_CLOSING")) {
// Shut down the sounds.
this.shutdown();

// }
}

/**
* Shut down this VSDecoder and all of its associated sounds.
*/
Expand Down Expand Up @@ -451,7 +385,7 @@ public void setPosition(PhysicalLocation p) {
if (create_xy_series) {
log.info("{}: {}\t{}", this.getAddress(), (float) Math.round(p.x*10000)/10000, p.y);
}
log.debug("( " + this.getAddress() + ") Set Position: " + p.toString());
log.debug("( " + this.getAddress() + ") Set Position: " + p);

this.lastPos = p; // save this position

Expand All @@ -476,7 +410,6 @@ public void setPosition(PhysicalLocation p) {
for (VSDSound vs : sound_list.values()) {
vs.setVolume(tv);
}
fireMyEvent(new VSDecoderEvent(this, VSDecoderEvent.EventType.LOCATION_CHANGE, p));
}

/**
Expand Down Expand Up @@ -528,28 +461,7 @@ public void propertyChange(PropertyChangeEvent evt) {
return;
}

// Respond to events from the old GUI.
if ((property.equals(VSDManagerFrame.PCIDMap.get(VSDManagerFrame.PropertyChangeID.MUTE)))
|| (property.equals(VSDecoderPane.PCIDMap.get(VSDecoderPane.PropertyChangeID.MUTE)))) {
// Either GUI Mute button
log.debug("VSD: Mute change. value: {}", evt.getNewValue());
Boolean b = (Boolean) evt.getNewValue();
this.mute(b.booleanValue());

} else if ((property.equals(VSDManagerFrame.PCIDMap.get(VSDManagerFrame.PropertyChangeID.VOLUME_CHANGE)))
|| (property.equals(VSDecoderPane.PCIDMap.get(VSDecoderPane.PropertyChangeID.VOLUME_CHANGE)))) {
// Either GUI Volume slider
log.debug("VSD: Volume change. value: {}", evt.getNewValue());
// Slider gives integer 0-100. Need to change that to a float 0.0-1.0
this.setMasterVolume((1.0f * (Integer) evt.getNewValue()) / 100.0f);

} else if (property.equals(VSDecoderPane.PCIDMap.get(VSDecoderPane.PropertyChangeID.ADDRESS_CHANGE))) {
// OLD GUI Address Change
log.debug("Decoder set address: {}", (LocoAddress) evt.getNewValue());
this.setAddress((LocoAddress) evt.getNewValue());
this.enable();

} else if (property.equals(Train.TRAIN_LOCATION_CHANGED_PROPERTY)) {
if (property.equals(Train.TRAIN_LOCATION_CHANGED_PROPERTY)) {
// Train Location Move (either GUI)
PhysicalLocation p = getTrainPosition((Train) evt.getSource());
if (p != null) {
Expand Down
8 changes: 0 additions & 8 deletions java/src/jmri/jmrit/vsdecoder/VSDecoderBundle.properties
Expand Up @@ -2,14 +2,6 @@
#
# Default properties for the jmri.jmrit.VSDecoder GUI elements

# Just needed for VSDecoderPane.java (old GUI) and VSDecoderPaneTest.java
# To remove, when "old GUI" is removed
WindowTitle = test
VSDecoderFileMenuLoadProfile = test
VSDecoderFileMenuSaveProfile = test
VSDecoderFileMenuPreferences = test
RosterSaveButtonToolTip = test

# Load VSD File action messages
VSDecoderFileMenuLoadVSDFile = Load VSD File
LoadVSDFileChooserFilterLabel = VSD File/s
Expand Down
22 changes: 4 additions & 18 deletions java/src/jmri/jmrit/vsdecoder/VSDecoderCreationAction.java
@@ -1,12 +1,8 @@
package jmri.jmrit.vsdecoder;

import java.awt.event.ActionEvent;
import java.awt.GraphicsEnvironment;
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.UIManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* <hr>
Expand All @@ -26,23 +22,17 @@
*/
public class VSDecoderCreationAction extends AbstractAction {

Boolean _useNewGUI = false;

/**
* Constructor
*
* @param s Name for the action.
*/
public VSDecoderCreationAction(String s, Boolean ng) {
public VSDecoderCreationAction(String s) {
super(s);
_useNewGUI = ng;
if (GraphicsEnvironment.isHeadless()) {
log.info("GUI lookAndFeel: {}", UIManager.getLookAndFeel().getName());
}
}

public VSDecoderCreationAction() {
this("Virtual Sound Decoder", true);
this("Virtual Sound Decoder");
}

/**
Expand All @@ -54,17 +44,13 @@ public VSDecoderCreationAction() {
public void actionPerformed(ActionEvent e) {
JFrame tf;

if (_useNewGUI) {
tf = VSDecoderManager.instance().provideManagerFrame(); // headless will return null
} else {
tf = new VSDecoderFrame(); // old GUI
}
tf = VSDecoderManager.instance().provideManagerFrame(); // headless will return null

if (tf != null) {
tf.toFront();
}
}

private final static Logger log = LoggerFactory.getLogger(VSDecoderCreationAction.class);
//private final static Logger log = LoggerFactory.getLogger(VSDecoderCreationAction.class);

}
Expand Up @@ -43,7 +43,7 @@ public class ManageLocationsAction extends AbstractAction {
private HashMap<String, PhysicalLocation> opsMap;
private ListeningSpot listenerLoc;

public ManageLocationsAction(String s, String a) {
public ManageLocationsAction(String s) {
super(s);
}

Expand Down

0 comments on commit f92d560

Please sign in to comment.