Skip to content

Commit

Permalink
added increase/decrease by octave
Browse files Browse the repository at this point in the history
improved copy-pasting notes
  • Loading branch information
DoubleDee73 committed Jul 16, 2023
1 parent 4bbccd3 commit b2c5276
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 40 deletions.
23 changes: 22 additions & 1 deletion src/yass/YassActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -1882,11 +1882,21 @@ public void actionPerformed(ActionEvent e) {
table.shiftHeight(+1);
}
};
private final Action incHeightOctave = new AbstractAction(I18.get("edit_height_inc_octave")) {
public void actionPerformed(ActionEvent e) {
table.shiftHeight(+12);
}
};
private final Action decHeight = new AbstractAction(I18.get("edit_height_dec")) {
public void actionPerformed(ActionEvent e) {
table.shiftHeight(-1);
}
};
private final Action decHeightOctave = new AbstractAction(I18.get("edit_height_dec_octave")) {
public void actionPerformed(ActionEvent e) {
table.shiftHeight(-12);
}
};
private final Action incLeft = new AbstractAction(I18.get("edit_length_left_inc")) {
public void actionPerformed(ActionEvent e) {
table.shiftLeftEndian(+1);
Expand Down Expand Up @@ -3433,7 +3443,9 @@ public void mousePressed(MouseEvent e) {
menu.add(shiftLeftRemainder);
menu.add(shiftRightRemainder);
menu.add(incHeight);
menu.add(incHeightOctave);
menu.add(decHeight);
menu.add(decHeightOctave);
menu.addSeparator();
menu.add(copyRows);
menu.add(pasteRows);
Expand Down Expand Up @@ -6985,10 +6997,19 @@ public void registerEditorActions(JComponent c) {
am.put("decHeight", decHeight);
decHeight.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK));

im.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK ), "decHeightOctave");

am.put("decHeightOctave", decHeightOctave);
decHeightOctave.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK ));

im.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_MASK), "incHeight");
am.put("incHeight", incHeight);
incHeight.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_MASK));

im.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK), "incHeightOctave");
am.put("incHeightOctave", incHeightOctave);
incHeightOctave.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));

im.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.CTRL_MASK), "decLeft");
am.put("decLeft", decLeft);
decLeft.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.CTRL_MASK));
Expand Down Expand Up @@ -7052,7 +7073,7 @@ public void registerEditorActions(JComponent c) {
am.put("pasteRows", pasteRows);
pasteRows.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK));

im.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK), "pasteNotes");
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK | InputEvent.SHIFT_DOWN_MASK), "pasteNotes");
am.put("pasteNotes", pasteNotes);
pasteNotes.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK));

Expand Down
78 changes: 39 additions & 39 deletions src/yass/YassTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -2740,7 +2740,7 @@ public int[] enlargeToPages(int i, int j) {
// move back until i-->note
boolean inHeader = !r.isNote();
YassRow r2 = getRowAt(j);
while (!(r2.isNote()) && j < n - 1)
while (r2 != null && !(r2.isNote()) && j < n - 1)
r2 = getRowAt(++j);
// // move forward until j-->note
if (inHeader)
Expand All @@ -2749,7 +2749,7 @@ public int[] enlargeToPages(int i, int j) {
while (r.isNote() && i > 0)
r = getRowAt(--i);
r2 = getRowAt(j);
while (r2.isNote() && j < n - 1)
while (r2 != null && r2.isNote() && j < n - 1)
r2 = getRowAt(++j);
return new int[]{i + 1, j - 1};
}
Expand Down Expand Up @@ -3639,11 +3639,11 @@ public int insertRowsAt(String trstring, int startRow, boolean before) {
long ms = sheet.fromTimeline(pos);
startBeat = msToBeat(ms);
startRow = sheet.nextNote(pos);
if (startRow > 0 && getRowAt(startRow-1).isPageBreak())
if (startRow > 0 && getRowAt(startRow - 1).isPageBreak()) {
appendPageBreak = true;
}
}
}
else {
} else {
YassRow r = getRowAt(startRow);
boolean isSep = r.isPageBreak();
if (!(r.isNote() || isSep)) {
Expand All @@ -3658,6 +3658,10 @@ public int insertRowsAt(String trstring, int startRow, boolean before) {
StringTokenizer st1 = new StringTokenizer(trstring, "\n");
int i = before ? 0 : 1;
int pasteBeat = -1;
boolean reachedEnd = false;
int currentBeat = 0;
int noteEnd = 0;
YassRow row;
for (; st1.hasMoreTokens(); i++) {
StringTokenizer st2 = new StringTokenizer(st1.nextToken(), "\t");
String type = st2.hasMoreTokens() ? st2.nextToken() : "";
Expand All @@ -3670,56 +3674,52 @@ public int insertRowsAt(String trstring, int startRow, boolean before) {
String txt = st2.hasMoreTokens() ? st2.nextToken() : "";
txt = txt.replace(' ', YassRow.SPACE);
int beatInt = Integer.parseInt(beat);
int lengthInt = Integer.parseInt(length);
boolean isSep = type.equals("-");
if (isSep && length.length() > 0) {
int lengthInt = Integer.parseInt(length);
length = (lengthInt + startBeat) + "";
length = Integer.toString(lengthInt + startBeat);
}
row = tm.getRowAt(startRow + num);
currentBeat = startBeat + beatInt - pasteBeat;
noteEnd = currentBeat + lengthInt;
if (!row.isEnd()) {
row.setText(txt);
row.setBeat(String.valueOf(currentBeat));
row.setLength(length);
row.setHeight(height);
row.setType(type);
} else {
reachedEnd = true;
tm.insertRowAt(type, String.valueOf(startBeat + beatInt - pasteBeat),
length, height, txt, startRow + i);
}
tm.insertRowAt(type, String.valueOf(startBeat + beatInt - pasteBeat),
length, height, txt, startRow + i);
num++;
}
if (num > 0 && appendPageBreak) {
YassRow r = tm.getRowAt(startRow+i-1);
if ( r.isNote()) {
boolean finished;
do {
row = tm.getRowAt(startRow + num);
if (row.getBeatInt() < noteEnd) {
tm.removeRowAt(startRow + num);
}
finished = row.isEnd() || (row.getBeatInt() + row.getLengthInt() > noteEnd);
} while (!finished);
if (num > 0 && appendPageBreak && !reachedEnd) {
YassRow r = tm.getRowAt(startRow + i - 1);
if (r.isNote() && !reachedEnd) {
tm.insertRowAt("-", String.valueOf(r.getBeatInt() + r.getLengthInt() + 1),
"", "", "", startRow + i);
i++;
}
}
if (reachedEnd && tm.getEndRow() == null) {
tm.addEndRow();
}
tm.fireTableRowsInserted(before ? startRow : startRow + 1, startRow + i - 1);
} catch (Exception ignored) {}
}
return num;
}

/**
* Description of the Method
*
* @param before Description of the Parameter
* @return Description of the Return Value
*/
public int insertRows(boolean before) {
int startRow = before ? getSelectionModel().getMinSelectionIndex()
: getSelectionModel().getMaxSelectionIndex();
if (startRow < 0) {
return 0;
}
if (startRow == 0) {
before = false;
}

String trstring = null;
try {
Clipboard system = Toolkit.getDefaultToolkit().getSystemClipboard();
trstring = (String) (system.getContents(this)
.getTransferData(DataFlavor.stringFlavor));
} catch (Exception e) {
return 0;
}
return insertRowsAt(trstring, startRow, before);
}

public int insertNotesHere() {
if (sheet != null) {
int pos = sheet.getPlayerPosition();
Expand Down
6 changes: 6 additions & 0 deletions src/yass/YassTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package yass;

import org.apache.commons.lang3.StringUtils;

import javax.swing.table.AbstractTableModel;
import java.util.Enumeration;
import java.util.Hashtable;
Expand Down Expand Up @@ -241,6 +243,10 @@ public void addRow(YassRow r) {
data.addElement(new YassRow(r));
}

public void addEndRow() {
data.addElement(new YassRow("E", StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY));
}

public void insertRowAt(String type, int time, int length, int height, String txt, int i) {
data.insertElementAt(
new YassRow(type, Integer.toString(time), Integer.toString(length), Integer.toString(height), txt), i);
Expand Down
2 changes: 2 additions & 0 deletions src/yass/resources/i18/yass_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ edit_shift_right = Sp
edit_shift_left_remainder = Rest früher
edit_shift_right_remainder = Rest später
edit_height_inc = Höher
edit_height_inc_octave = Oktave höher
edit_height_dec = Tiefer
edit_height_dec_octave = Oktave tiefer
edit_length_left_dec = Start früher
edit_length_left_inc = Start später
edit_length_right_dec = Ende früher
Expand Down
2 changes: 2 additions & 0 deletions src/yass/resources/i18/yass_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ edit_shift_right = Later
edit_shift_left_remainder = Remainder Earlier
edit_shift_right_remainder = Remainder Later
edit_height_inc = Higher
edit_height_inc_octave = Octave higher
edit_height_dec = Lower
edit_height_dec_octave = Octave lower
edit_length_left_dec = Start Earlier
edit_length_left_inc = Start Later
edit_length_right_dec = End Earlier
Expand Down
2 changes: 2 additions & 0 deletions src/yass/resources/i18/yass_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ edit_shift_right = M
edit_shift_left_remainder = Restante Más Temprano
edit_shift_right_remainder = Restante Más Tarde
edit_height_inc = Subir
edit_height_inc_octave = Octava subir
edit_height_dec = Bajar
edit_height_dec_octave = Octava bajar
edit_length_left_dec = Empezar Más Temprano
edit_length_left_inc = Empezar Más Tarde
edit_length_right_dec = Final Más Temprano
Expand Down
2 changes: 2 additions & 0 deletions src/yass/resources/i18/yass_hu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ edit_shift_right = Later
edit_shift_left_remainder = Remainder Earlier
edit_shift_right_remainder = Remainder Later
edit_height_inc = Higher
edit_height_inc_octave = Octave higher
edit_height_dec = Lower
edit_height_dec_octave = Octave lower
edit_length_left_dec = Start Earlier
edit_length_left_inc = Start Later
edit_length_right_dec = End Earlier
Expand Down
2 changes: 2 additions & 0 deletions src/yass/resources/i18/yass_pl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ edit_shift_right = Later
edit_shift_left_remainder = Remainder Earlier
edit_shift_right_remainder = Remainder Later
edit_height_inc = Higher
edit_height_inc_octave = Octave higher
edit_height_dec = Lower
edit_height_dec_octave = Octave lower
edit_length_left_dec = Start Earlier
edit_length_left_inc = Start Later
edit_length_right_dec = End Earlier
Expand Down

0 comments on commit b2c5276

Please sign in to comment.