mirror of https://github.com/rusefi/RomRaider.git
Added multiply values function. Need to play with keystrokes to make '*' commit when focus is in set value field
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@180 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
26a4af0e19
commit
51ee51df97
|
@ -292,4 +292,8 @@ public class DataCell extends JLabel implements MouseListener, Serializable {
|
|||
public void refreshValue() {
|
||||
setBinValue(binValue);
|
||||
}
|
||||
|
||||
public void multiply(double factor) {
|
||||
setRealValue(Double.parseDouble(getText()) * factor+"");
|
||||
}
|
||||
}
|
|
@ -194,6 +194,11 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
paste();
|
||||
}
|
||||
};
|
||||
Action multiplyAction = new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
getFrame().getToolBar().multiply();
|
||||
}
|
||||
};
|
||||
|
||||
// set input mapping
|
||||
InputMap im = getInputMap(WHEN_IN_FOCUSED_WINDOW);
|
||||
|
@ -218,6 +223,7 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
KeyStroke num7 = KeyStroke.getKeyStroke('7');
|
||||
KeyStroke num8 = KeyStroke.getKeyStroke('8');
|
||||
KeyStroke num9 = KeyStroke.getKeyStroke('9');
|
||||
KeyStroke mulKey = KeyStroke.getKeyStroke('*');
|
||||
KeyStroke numPoint = KeyStroke.getKeyStroke('.');
|
||||
KeyStroke copy = KeyStroke.getKeyStroke("control C");
|
||||
KeyStroke paste = KeyStroke.getKeyStroke("control V");
|
||||
|
@ -245,6 +251,7 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
im.put(numPoint, "numPointAction");
|
||||
im.put(copy, "copyAction");
|
||||
im.put(paste, "pasteAction");
|
||||
im.put(mulKey, "mulAction");
|
||||
|
||||
getActionMap().put(im.get(right), rightAction);
|
||||
getActionMap().put(im.get(left), leftAction);
|
||||
|
@ -267,6 +274,7 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
getActionMap().put(im.get(num8), num8Action);
|
||||
getActionMap().put(im.get(num9), num9Action);
|
||||
getActionMap().put(im.get(numPoint), numPointAction);
|
||||
getActionMap().put(im.get(mulKey), multiplyAction);
|
||||
getActionMap().put(im.get(copy), copyAction);
|
||||
getActionMap().put(im.get(paste), pasteAction);
|
||||
|
||||
|
@ -619,6 +627,16 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void multiply(double factor) {
|
||||
if (!isStatic && !locked) {
|
||||
for (DataCell cell : data) {
|
||||
if (cell.isSelected()) {
|
||||
cell.multiply(factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setRealValue(String realValue) {
|
||||
if (!isStatic && !locked) {
|
||||
|
|
|
@ -96,6 +96,11 @@ public class Table2D extends Table {
|
|||
axis.increment(increment);
|
||||
}
|
||||
|
||||
public void multiply(double factor) {
|
||||
super.multiply(factor);
|
||||
axis.multiply(factor);
|
||||
}
|
||||
|
||||
public void clearSelection() {
|
||||
axis.clearSelection(true);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
|
|
|
@ -347,6 +347,20 @@ public class Table3D extends Table {
|
|||
xAxis.increment(increment);
|
||||
yAxis.increment(increment);
|
||||
}
|
||||
|
||||
public void multiply(double factor) {
|
||||
if (!isStatic && !locked) {
|
||||
for (int x = 0; x < this.getSizeX(); x++) {
|
||||
for (int y = 0; y < this.getSizeY(); y++) {
|
||||
if (data[x][y].isSelected()) {
|
||||
data[x][y].multiply(factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
xAxis.multiply(factor);
|
||||
yAxis.multiply(factor);
|
||||
}
|
||||
|
||||
public void clearSelection() {
|
||||
xAxis.clearSelection(true);
|
||||
|
|
|
@ -34,6 +34,7 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
|
|||
private JButton incrementCoarse = new JButton(new ImageIcon("./graphics/icon-inccoarse.png"));
|
||||
private JButton decrementCoarse = new JButton(new ImageIcon("./graphics/icon-deccoarse.png"));
|
||||
private JButton setValue = new JButton("Set");
|
||||
private JButton multiply = new JButton("Mul");
|
||||
|
||||
private JFormattedTextField incrementByFine = new JFormattedTextField(new DecimalFormat("#.####"));
|
||||
private JFormattedTextField incrementByCoarse = new JFormattedTextField(new DecimalFormat("#.####"));
|
||||
|
@ -60,6 +61,7 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
|
|||
this.add(setValueText);
|
||||
this.add(new JLabel(" "));
|
||||
this.add(setValue);
|
||||
this.add(multiply);
|
||||
this.add(new JLabel(" "));
|
||||
this.add(scaleSelection);
|
||||
|
||||
|
@ -73,6 +75,8 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
|
|||
decrementCoarse.setBorder(new LineBorder(new Color(150,150,150), 1));
|
||||
setValue.setMaximumSize(new Dimension(33,23));
|
||||
setValue.setBorder(new LineBorder(new Color(150,150,150), 1));
|
||||
multiply.setMaximumSize(new Dimension(33,23));
|
||||
multiply.setBorder(new LineBorder(new Color(150,150,150), 1));
|
||||
scaleSelection.setMaximumSize(new Dimension(80,23));
|
||||
scaleSelection.setFont(new Font("Tahoma", Font.PLAIN, 11));
|
||||
|
||||
|
@ -94,12 +98,14 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
|
|||
setValueText.setToolTipText("Set Absolute Value");
|
||||
incrementByFine.setToolTipText("Fine Value Adjustment");
|
||||
incrementByCoarse.setToolTipText("Coarse Value Adjustment");
|
||||
multiply.setToolTipText("Multiply Value");
|
||||
|
||||
incrementFine.addMouseListener(this);
|
||||
decrementFine.addMouseListener(this);
|
||||
incrementCoarse.addMouseListener(this);
|
||||
decrementCoarse.addMouseListener(this);
|
||||
setValue.addMouseListener(this);
|
||||
multiply.addMouseListener(this);
|
||||
scaleSelection.addItemListener(this);
|
||||
|
||||
try {
|
||||
|
@ -160,6 +166,7 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
|
|||
else if (e.getSource() == decrementCoarse) decrementCoarse();
|
||||
else if (e.getSource() == incrementFine) incrementFine();
|
||||
else if (e.getSource() == decrementFine) decrementFine();
|
||||
else if (e.getSource() == multiply) multiply();
|
||||
else if (e.getSource() == setValue) setValue();
|
||||
|
||||
table.colorize();
|
||||
|
@ -168,7 +175,10 @@ public class TableToolBar extends JToolBar implements MouseListener, ItemListene
|
|||
public void setValue() {
|
||||
table.setRealValue(setValueText.getText()+"");
|
||||
}
|
||||
|
||||
|
||||
public void multiply() {
|
||||
table.multiply(Double.parseDouble(setValueText.getText()));
|
||||
}
|
||||
|
||||
public void incrementFine() {
|
||||
table.increment(Double.parseDouble(incrementByFine.getValue()+""));
|
||||
|
|
Loading…
Reference in New Issue