refactoring: reducing unneeded complexity

This commit is contained in:
rusefi 2018-12-19 22:18:29 -05:00 committed by Dale Schultz
parent d60da8347c
commit ed91aa4351
1 changed files with 26 additions and 128 deletions

View File

@ -32,34 +32,34 @@ import com.romraider.maps.Table3D;
public class TableMenuBar extends JMenuBar { public class TableMenuBar extends JMenuBar {
private static final long serialVersionUID = -695692646459410510L; private static final long serialVersionUID = -695692646459410510L;
private JMenu fileMenu; private JMenu fileMenu = new JMenu("Table");
private JMenuItem graph; private JMenuItem graph = new JMenuItem("View Graph");
private JMenu compareMenu; private JMenu compareMenu = new JMenu("Compare");
private JRadioButtonMenuItem compareOriginal; private JRadioButtonMenuItem compareOriginal = new JRadioButtonMenuItem("Show Changes");
private JRadioButtonMenuItem compareMap; private JRadioButtonMenuItem compareMap = new JRadioButtonMenuItem("Compare to Another Map");
private JMenu similarOpenTables; private JMenu similarOpenTables = new JMenu("Compare to Table");
private JRadioButtonMenuItem compareOff; private JRadioButtonMenuItem compareOff = new JRadioButtonMenuItem("Off");
private JMenu compareDisplay; private JMenu compareDisplay = new JMenu("Display");
private JRadioButtonMenuItem comparePercent; private JRadioButtonMenuItem comparePercent = new JRadioButtonMenuItem("Percent Difference");
private JRadioButtonMenuItem compareAbsolute; private JRadioButtonMenuItem compareAbsolute = new JRadioButtonMenuItem("Absolute Difference");
private JMenu compareToValue; private JMenu compareToValue = new JMenu("Compare to");
private JRadioButtonMenuItem compareToOriginal; private JRadioButtonMenuItem compareToOriginal = new JRadioButtonMenuItem("Compare to Original Value");
private JRadioButtonMenuItem compareToBin; private JRadioButtonMenuItem compareToBin = new JRadioButtonMenuItem("Compare to Bin Value");
private JMenuItem close; private JMenuItem close;
private JMenu editMenu; private JMenu editMenu = new JMenu("Edit");
private JMenuItem undoSel; private JMenuItem undoSel = new JMenuItem("Undo Selected Changes");
private JMenuItem undoAll; private JMenuItem undoAll = new JMenuItem("Undo All Changes");
private JMenuItem revert; private JMenuItem revert = new JMenuItem("Set Revert Point");
private JMenuItem copySel; private JMenuItem copySel = new JMenuItem("Copy Selection");
private JMenuItem copyTable; private JMenuItem copyTable = new JMenuItem("Copy Table");
private JMenuItem paste; private JMenuItem paste = new JMenuItem("Paste");
private JMenuItem interp; private JMenuItem interp = new JMenuItem("Interpolate");
private JMenuItem vertInterp; private JMenuItem vertInterp = new JMenuItem("Vertical Interpolate");
private JMenuItem horizInterp; private JMenuItem horizInterp = new JMenuItem("Horizontal Interpolate");
private JMenu viewMenu; private JMenu viewMenu = new JMenu("View");
private JMenuItem tableProperties; private JMenuItem tableProperties = new JMenuItem("Table Properties");
private ButtonGroup compareGroup; private ButtonGroup compareGroup;
private ButtonGroup compareDisplayGroup; private ButtonGroup compareDisplayGroup;
@ -73,10 +73,7 @@ public class TableMenuBar extends JMenuBar {
} }
private void initFileMenu(TableFrame frame) { private void initFileMenu(TableFrame frame) {
fileMenu = new JMenu("Table"); close = new JMenuItem("Close Table");
graph = new JMenuItem("View Graph");
compareMenu = new JMenu("Compare");
setClose(new JMenuItem("Close Table"));
initCompareMenu(frame); initCompareMenu(frame);
getClose().setText("Close " + frame.getTable().getName()); getClose().setText("Close " + frame.getTable().getName());
@ -97,17 +94,6 @@ public class TableMenuBar extends JMenuBar {
} }
private void initEditMenu(TableFrame frame) { private void initEditMenu(TableFrame frame) {
editMenu = new JMenu("Edit");
setUndoSel(new JMenuItem("Undo Selected Changes"));
setUndoAll(new JMenuItem("Undo All Changes"));
setRevert(new JMenuItem("Set Revert Point"));
setCopySel(new JMenuItem("Copy Selection"));
setCopyTable(new JMenuItem("Copy Table"));
setPaste(new JMenuItem("Paste"));
setVertInterp(new JMenuItem("Vertical Interpolate"));
setHorizInterp(new JMenuItem("Horizontal Interpolate"));
setInterp(new JMenuItem("Interpolate"));
editMenu.add(getUndoSel()); editMenu.add(getUndoSel());
editMenu.add(getUndoAll()); editMenu.add(getUndoAll());
editMenu.add(getRevert()); editMenu.add(getRevert());
@ -147,11 +133,8 @@ public class TableMenuBar extends JMenuBar {
} }
private void initViewMenu(TableFrame frame) { private void initViewMenu(TableFrame frame) {
viewMenu = new JMenu("View");
viewMenu.setMnemonic('V'); viewMenu.setMnemonic('V');
setTableProperties(new JMenuItem("Table Properties"));
getTableProperties().setToolTipText("Select to view the table properties."); getTableProperties().setToolTipText("Select to view the table properties.");
getTableProperties().setMnemonic('P'); getTableProperties().setMnemonic('P');
getTableProperties().addActionListener(frame); getTableProperties().addActionListener(frame);
@ -165,32 +148,21 @@ public class TableMenuBar extends JMenuBar {
} }
private void initCompareMenu(TableFrame frame) { private void initCompareMenu(TableFrame frame) {
setCompareOriginal(new JRadioButtonMenuItem("Show Changes"));
getCompareOriginal().setToolTipText("Compares the current values to the original or revert point values."); getCompareOriginal().setToolTipText("Compares the current values to the original or revert point values.");
setCompareMap(new JRadioButtonMenuItem("Compare to Another Map"));
getCompareMap().setToolTipText("Compares this table and a selected table."); getCompareMap().setToolTipText("Compares this table and a selected table.");
setSimilarOpenTables(new JMenu("Compare to Table"));
getSimilarOpenTables().setToolTipText("Compares this table to a similar table."); getSimilarOpenTables().setToolTipText("Compares this table to a similar table.");
setCompareOff(new JRadioButtonMenuItem("Off"));
setComparePercent(new JRadioButtonMenuItem("Percent Difference"));
setCompareAbsolute(new JRadioButtonMenuItem("Absolute Difference"));
compareDisplayGroup = new ButtonGroup(); compareDisplayGroup = new ButtonGroup();
compareDisplayGroup.add(getComparePercent()); compareDisplayGroup.add(getComparePercent());
compareDisplayGroup.add(getCompareAbsolute()); compareDisplayGroup.add(getCompareAbsolute());
compareDisplay = new JMenu("Display");
compareDisplay.add(getComparePercent()); compareDisplay.add(getComparePercent());
compareDisplay.add(getCompareAbsolute()); compareDisplay.add(getCompareAbsolute());
setCompareToOriginal(new JRadioButtonMenuItem("Compare to Original Value"));
getCompareToOriginal().setToolTipText("Compares this table to the selected table's original or revert point values."); getCompareToOriginal().setToolTipText("Compares this table to the selected table's original or revert point values.");
setCompareToBin(new JRadioButtonMenuItem("Compare to Bin Value"));
getCompareToBin().setToolTipText("Compares this table to the selected table's current values."); getCompareToBin().setToolTipText("Compares this table to the selected table's current values.");
compareToGroup = new ButtonGroup(); compareToGroup = new ButtonGroup();
compareToGroup.add(getCompareToOriginal()); compareToGroup.add(getCompareToOriginal());
compareToGroup.add(getCompareToBin()); compareToGroup.add(getCompareToBin());
compareToValue = new JMenu("Compare to");
compareToValue.add(getCompareToOriginal()); compareToValue.add(getCompareToOriginal());
compareToValue.add(getCompareToBin()); compareToValue.add(getCompareToBin());
@ -258,150 +230,76 @@ public class TableMenuBar extends JMenuBar {
return undoAll; return undoAll;
} }
public void setUndoAll(JMenuItem undoAll) {
this.undoAll = undoAll;
}
public JMenuItem getRevert() { public JMenuItem getRevert() {
return revert; return revert;
} }
public void setRevert(JMenuItem revert) {
this.revert = revert;
}
public JMenuItem getUndoSel() { public JMenuItem getUndoSel() {
return undoSel; return undoSel;
} }
public void setUndoSel(JMenuItem undoSel) {
this.undoSel = undoSel;
}
public JMenuItem getClose() { public JMenuItem getClose() {
return close; return close;
} }
public void setClose(JMenuItem close) {
this.close = close;
}
public JMenuItem getTableProperties() { public JMenuItem getTableProperties() {
return tableProperties; return tableProperties;
} }
public void setTableProperties(JMenuItem tableProperties) {
this.tableProperties = tableProperties;
}
public JMenuItem getCopySel() { public JMenuItem getCopySel() {
return copySel; return copySel;
} }
public void setCopySel(JMenuItem copySel) {
this.copySel = copySel;
}
public JMenuItem getCopyTable() { public JMenuItem getCopyTable() {
return copyTable; return copyTable;
} }
public void setCopyTable(JMenuItem copyTable) {
this.copyTable = copyTable;
}
public JMenuItem getPaste() { public JMenuItem getPaste() {
return paste; return paste;
} }
public void setPaste(JMenuItem paste) {
this.paste = paste;
}
public JRadioButtonMenuItem getCompareOff() { public JRadioButtonMenuItem getCompareOff() {
return compareOff; return compareOff;
} }
public void setCompareOff(JRadioButtonMenuItem compareOff) {
this.compareOff = compareOff;
}
public JRadioButtonMenuItem getCompareAbsolute() { public JRadioButtonMenuItem getCompareAbsolute() {
return compareAbsolute; return compareAbsolute;
} }
public void setCompareAbsolute(JRadioButtonMenuItem compareAbsolute) {
this.compareAbsolute = compareAbsolute;
}
public JRadioButtonMenuItem getComparePercent() { public JRadioButtonMenuItem getComparePercent() {
return comparePercent; return comparePercent;
} }
public void setComparePercent(JRadioButtonMenuItem comparePercent) {
this.comparePercent = comparePercent;
}
public JRadioButtonMenuItem getCompareOriginal() { public JRadioButtonMenuItem getCompareOriginal() {
return compareOriginal; return compareOriginal;
} }
public void setCompareOriginal(JRadioButtonMenuItem compareOriginal) {
this.compareOriginal = compareOriginal;
}
public JRadioButtonMenuItem getCompareToOriginal() { public JRadioButtonMenuItem getCompareToOriginal() {
return compareToOriginal; return compareToOriginal;
} }
public void setCompareToOriginal(JRadioButtonMenuItem compareToOriginal) {
this.compareToOriginal = compareToOriginal;
}
public JRadioButtonMenuItem getCompareMap() { public JRadioButtonMenuItem getCompareMap() {
return compareMap; return compareMap;
} }
public void setCompareMap(JRadioButtonMenuItem compareMap) {
this.compareMap = compareMap;
}
public JRadioButtonMenuItem getCompareToBin() { public JRadioButtonMenuItem getCompareToBin() {
return compareToBin; return compareToBin;
} }
public void setCompareToBin(JRadioButtonMenuItem compareToBin) {
this.compareToBin = compareToBin;
}
public JMenu getSimilarOpenTables() { public JMenu getSimilarOpenTables() {
return similarOpenTables; return similarOpenTables;
} }
public void setSimilarOpenTables(JMenu similarOpenTables) {
this.similarOpenTables = similarOpenTables;
}
public JMenuItem getInterp() { public JMenuItem getInterp() {
return interp; return interp;
} }
public void setInterp(JMenuItem interp) {
this.interp = interp;
}
public JMenuItem getHorizInterp() { public JMenuItem getHorizInterp() {
return this.horizInterp; return this.horizInterp;
} }
public void setHorizInterp(JMenuItem horizInterp) {
this.horizInterp = horizInterp;
}
public JMenuItem getVertInterp() { public JMenuItem getVertInterp() {
return this.vertInterp; return this.vertInterp;
} }
public void setVertInterp(JMenuItem vertInterp) {
this.vertInterp = vertInterp;
}
} }