private void readChannel(TGSong song, TGTrack track) { TGChannel channel = this.factory.newChannel(); TGChannelParameter gmChannel1Param = this.factory.newChannelParameter(); TGChannelParameter gmChannel2Param = this.factory.newChannelParameter(); // leo el canal int channel1 = (readByte() & 0xff); gmChannel1Param.setKey(GMChannelRoute.PARAMETER_GM_CHANNEL_1); gmChannel1Param.setValue(Integer.toString(channel1)); // leo el canal de efectos int channel2 = (readByte() & 0xff); gmChannel2Param.setKey(GMChannelRoute.PARAMETER_GM_CHANNEL_2); gmChannel2Param.setValue(Integer.toString(channel2)); // Parseo el banco de sonidos channel.setBank(channel1 == 9 ? TGChannel.DEFAULT_PERCUSSION_BANK : TGChannel.DEFAULT_BANK); // leo el instrumento channel.setProgram(readByte()); // leo el volumen channel.setVolume(readByte()); // leo el balance channel.setBalance(readByte()); // leo el chorus channel.setChorus(readByte()); // leo el reverb channel.setReverb(readByte()); // leo el phaser channel.setPhaser(readByte()); // leo el tremolo channel.setTremolo(readByte()); // ------------------------------------------// for (int i = 0; i < song.countChannels(); i++) { TGChannel channelAux = song.getChannel(i); for (int n = 0; n < channelAux.countParameters(); n++) { TGChannelParameter channelParameter = channelAux.getParameter(n); if (channelParameter.getKey().equals(GMChannelRoute.PARAMETER_GM_CHANNEL_1)) { if (Integer.toString(channel1).equals(channelParameter.getValue())) { channel.setChannelId(channelAux.getChannelId()); } } } } if (channel.getChannelId() <= 0) { channel.setChannelId(song.countChannels() + 1); channel.setName(("#" + channel.getChannelId())); channel.addParameter(gmChannel1Param); channel.addParameter(gmChannel2Param); song.addChannel(channel); } track.setChannelId(channel.getChannelId()); }
private void addSong(TGSong song) { int trackCount = song.countTracks(); if (this.settings.isTrackGroupEnabled() && trackCount > 1) { this.writer.println("\\score {"); if (this.settings.getTrack() == LilypondSettings.ALL_TRACKS) { this.writer.println(indent(1) + "<<"); } } for (int i = 0; i < trackCount; i++) { TGTrack track = song.getTrack(i); if (this.settings.getTrack() == LilypondSettings.ALL_TRACKS || this.settings.getTrack() == track.getNumber()) { if (!this.settings.isTrackGroupEnabled() || trackCount == 1) { this.writer.println("\\score {"); } this.writer.println(indent(1) + "\\" + this.trackID(i, "StaffGroup")); if (!this.settings.isTrackGroupEnabled() || trackCount == 1) { this.addHeader(song, track.getName(), 1); this.writer.println("}"); } } } if (this.settings.isTrackGroupEnabled() && trackCount > 1) { if (this.settings.getTrack() == LilypondSettings.ALL_TRACKS) { this.writer.println(indent(1) + ">>"); } this.addHeader(song, null, 1); this.writer.println("}"); } }
private void readChannel(TGSong song, TGTrack track, List channels) throws IOException { int index = (readInt() - 1); int effectChannel = (readInt() - 1); if (index >= 0 && index < channels.size()) { TGChannel channel = getFactory().newChannel(); ((TGChannel) channels.get(index)).copy(channel); if (channel.getProgram() < 0) { channel.setProgram((short) 0); } if (!channel.isPercussionChannel()) { channel.setEffectChannel((short) effectChannel); } // ------------------------------------------// for (int i = 0; i < song.countChannels(); i++) { TGChannel channelAux = song.getChannel(i); if (channelAux.getChannel() == channel.getChannel()) { channel.setChannelId(channelAux.getChannelId()); } } if (channel.getChannelId() <= 0) { channel.setChannelId(song.countChannels() + 1); channel.setName(("#" + channel.getChannelId())); song.addChannel(channel); } track.setChannelId(channel.getChannelId()); } }
private void write(TGSong song) { // escribo el nombre writeUnsignedByteString(song.getName()); // escribo el artista writeUnsignedByteString(song.getArtist()); // escribo el album writeUnsignedByteString(song.getAlbum()); // escribo el autor writeUnsignedByteString(song.getAuthor()); // escribo la cantidad de measure headers writeShort((short) song.countMeasureHeaders()); // escribo las pistas TGMeasureHeader lastHeader = null; for (TGMeasureHeader header : song.getMeasureHeaders()) { writeMeasureHeader(header, lastHeader); lastHeader = header; } // escribo la cantidad de pistas writeByte(song.countTracks()); // escribo las pistas for (int i = 0; i < song.countTracks(); i++) { TGTrack track = song.getTrack(i); writeTrack(track); } }
private void addHeader(TGSong song, String instrument, int indent) { this.writer.println(indent(indent) + "\\header {"); this.writer.println(indent(indent + 1) + "title = \"" + song.getName() + "\" "); this.writer.println(indent(indent + 1) + "composer = \"" + song.getAuthor() + "\" "); if (this.settings.isTrackNameEnabled() && !this.addTrackTitleOnGroup(song) && instrument != null) { this.writer.println(indent(indent + 1) + "instrument = \"" + instrument + "\" "); } this.writer.println(indent(indent) + "}"); }
private void addSongDefinitions(TGSong song) { for (int i = 0; i < song.countTracks(); i++) { TGTrack track = song.getTrack(i); String id = this.trackID(i, ""); this.temp.reset(); this.addMusic(track, id); this.addLyrics(track, id); this.addScoreStaff(track, id); this.addTabStaff(track, id); this.addStaffGroup(track, id); } }
private TGTrack readTrack(int number, TGSong song) { // header int header = readHeader(); TGTrack track = this.factory.newTrack(); track.setNumber(number); // leo el nombre track.setName(readUnsignedByteString()); // leo el solo track.setSolo((header & TRACK_SOLO) != 0); // leo el mute track.setMute((header & TRACK_MUTE) != 0); // leo el canal readChannel(song, track); // leo la cantidad de compases int measureCount = song.countMeasureHeaders(); // leo los compases TGMeasure lastMeasure = null; for (int i = 0; i < measureCount; i++) { TGMeasure measure = readMeasure(song.getMeasureHeader(i), lastMeasure); track.addMeasure(measure); lastMeasure = measure; } // leo la cantidad de cuerdas int stringCount = readByte(); // leo las cuerdas for (int i = 0; i < stringCount; i++) { track.getStrings().add(readInstrumentString(i + 1)); } // leo el offset track.setOffset(TGTrack.MIN_OFFSET + readByte()); // leo el color readRGBColor(track.getColor()); // leo el lyrics if (((header & TRACK_LYRICS) != 0)) { readLyrics(track.getLyrics()); } return track; }
protected void configureChannelRouter(TGSong song) { this.channelRouter = new GMChannelRouter(); GMChannelRouterConfigurator gmChannelRouterConfigurator = new GMChannelRouterConfigurator(this.channelRouter); gmChannelRouterConfigurator.configureRouter(song.getChannels()); }
private boolean addTrackTitleOnGroup(TGSong song) { if (this.settings.isTrackNameEnabled() && this.settings.isTrackGroupEnabled()) { if (this.settings.getTrack() == LilypondSettings.ALL_TRACKS && song.countTracks() > 1) { return true; } } return false; }
private void readTracks(TGSong song, int count, List channels, TGLyric lyric, int lyricTrack) throws IOException { for (int number = 1; number <= count; number++) { song.addTrack( readTrack( song, number, channels, (number == lyricTrack) ? lyric : getFactory().newLyric())); } }
public PrintStyles createDefaultStyles(TGSong song) { PrintStyles styles = new PrintStyles(); styles.setStyle(TGLayout.DISPLAY_TABLATURE); styles.setFromMeasure(1); styles.setToMeasure(song.countMeasureHeaders()); styles.setTrackNumber(1); return styles; }
private void readTracks( TGSong song, int count, List<TGChannel> channels, TGLyric lyric, int lyricTrack) throws IOException { for (int number = 1; number <= count; number++) { song.addTrack( readTrack(number, channels, (number == lyricTrack) ? lyric : new TGLyricImpl())); } skip((getVersionIndex() == 0 ? 2 : 1)); }
private void readMeasureHeaders(TGSong song, int count) throws IOException { TGTimeSignature timeSignature = new TGTimeSignature(); for (int i = 0; i < count; i++) { if (i > 0) { skip(1); } song.addMeasureHeader(readMeasureHeader(i, timeSignature)); } }
private void readMeasures(TGSong song, int measures, int tracks, int tempoValue) throws IOException { TGTempo tempo = getFactory().newTempo(); tempo.setValue(tempoValue); long start = TGDuration.QUARTER_TIME; for (int i = 0; i < measures; i++) { TGMeasureHeader header = song.getMeasureHeader(i); header.setStart(start); for (int j = 0; j < tracks; j++) { TGTrack track = song.getTrack(j); TGMeasure measure = getFactory().newMeasure(header); track.addMeasure(measure); readMeasure(measure, track, tempo); } tempo.copy(header.getTempo()); start += header.getLength(); } }
private boolean isPercussionChannel(TGSong song, int channelId) { Iterator it = song.getChannels(); while (it.hasNext()) { TGChannel channel = (TGChannel) it.next(); if (channel.getChannelId() == channelId) { return channel.isPercussionChannel(); } } return false; }
private TGSong read() { TGSong song = this.factory.newSong(); // leo el nombre song.setName(readString()); // leo el artista song.setArtist(readString()); // leo el album song.setAlbum(readString()); // leo el autor song.setAuthor(readString()); // leo la cantidad de pistas int trackCount = readInt(); // leo las pistas for (int i = 0; i < trackCount; i++) { song.addTrack(readTrack(song)); } return song; }
private void readInfo(TGSong song) throws IOException { song.setName(readStringByteSizeOfInteger()); readStringByteSizeOfInteger(); song.setArtist(readStringByteSizeOfInteger()); song.setAlbum(readStringByteSizeOfInteger()); song.setAuthor(readStringByteSizeOfInteger()); song.setCopyright(readStringByteSizeOfInteger()); song.setWriter(readStringByteSizeOfInteger()); readStringByteSizeOfInteger(); int comments = readInt(); for (int i = 0; i < comments; i++) { song.setComments(song.getComments() + readStringByteSizeOfInteger()); } }
private TGTrack readTrack(TGSong song) { TGTrack track = this.factory.newTrack(); // leo el numero track.setNumber((int) readLong()); // leo el nombre track.setName(readString()); // leo el canal readChannel(track); // leo la cantidad de compases int measureCount = readInt(); if (song.countMeasureHeaders() == 0) { for (int i = 0; i < measureCount; i++) { TGMeasureHeader header = this.factory.newHeader(); song.addMeasureHeader(header); } } // leo los compases for (int i = 0; i < measureCount; i++) { track.addMeasure(readMeasure(song.getMeasureHeader(i))); } // leo la cantidad de cuerdas int stringCount = readInt(); // leo las cuerdas for (int i = 0; i < stringCount; i++) { track.getStrings().add(readInstrumentString()); } // leo el color readColor(track.getColor()); return track; }
private int parseRepeatAlternative(TGSong song, int measure, int value) { int repeatAlternative = 0; int existentAlternatives = 0; Iterator it = song.getMeasureHeaders(); while (it.hasNext()) { TGMeasureHeader header = (TGMeasureHeader) it.next(); if (header.getNumber() == measure) { break; } if (header.isRepeatOpen()) { existentAlternatives = 0; } existentAlternatives |= header.getRepeatAlternative(); } for (int i = 0; i < 8; i++) { if (value > i && (existentAlternatives & (1 << i)) == 0) { repeatAlternative |= (1 << i); } } return repeatAlternative; }
private TGSong read() { TGSong song = this.factory.newSong(); // leo el nombre song.setName(readUnsignedByteString()); // leo el artista song.setArtist(readUnsignedByteString()); // leo el album song.setAlbum(readUnsignedByteString()); // leo el autor song.setAuthor(readUnsignedByteString()); // leo la cantidad de measure headers int headerCount = readShort(); // leo las pistas TGMeasureHeader lastHeader = null; long headerStart = TGDuration.QUARTER_TIME; for (int i = 0; i < headerCount; i++) { TGMeasureHeader header = readMeasureHeader(i + 1, headerStart, lastHeader); song.addMeasureHeader(header); headerStart += header.getLength(); lastHeader = header; } // leo la cantidad de pistas int trackCount = readByte(); // leo las pistas for (int i = 0; i < trackCount; i++) { song.addTrack(readTrack(i + 1, song)); } return song; }
public void show(final TGViewContext context) { final TGSong song = context.getAttribute(TGDocumentContextAttributes.ATTRIBUTE_SONG); final TGPrintStylesHandler handler = context.getAttribute(ATTRIBUTE_HANDLER); final UIFactory uiFactory = TGApplication.getInstance(context.getContext()).getFactory(); final UIWindow uiParent = context.getAttribute(TGViewContext.ATTRIBUTE_PARENT2); final UITableLayout dialogLayout = new UITableLayout(); final UIWindow dialog = uiFactory.createWindow(uiParent, true, false); dialog.setLayout(dialogLayout); dialog.setText(TuxGuitar.getProperty("options")); // ------------------TRACK SELECTION------------------ UITableLayout trackLayout = new UITableLayout(); UILegendPanel track = uiFactory.createLegendPanel(dialog); track.setLayout(trackLayout); track.setText(TuxGuitar.getProperty("track")); dialogLayout.set( track, 1, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true, 1, 1, 300f, null, null); UILabel trackLabel = uiFactory.createLabel(track); trackLabel.setText(TuxGuitar.getProperty("track")); trackLayout.set( trackLabel, 1, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_CENTER, false, true); final UIDropDownSelect<Integer> tracks = uiFactory.createDropDownSelect(track); for (int number = 1; number <= song.countTracks(); number++) { tracks.addItem( new UISelectItem<Integer>( TuxGuitar.getInstance().getSongManager().getTrack(song, number).getName(), number)); } tracks.setSelectedValue( TuxGuitar.getInstance() .getTablatureEditor() .getTablature() .getCaret() .getTrack() .getNumber()); trackLayout.set(tracks, 1, 2, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true); // ------------------MEASURE RANGE------------------ UITableLayout rangeLayout = new UITableLayout(); UILegendPanel range = uiFactory.createLegendPanel(dialog); range.setLayout(rangeLayout); range.setText(TuxGuitar.getProperty("print.range")); dialogLayout.set( range, 2, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true, 1, 1, 300f, null, null); final int minSelection = 1; final int maxSelection = song.countMeasureHeaders(); UILabel fromLabel = uiFactory.createLabel(range); fromLabel.setText(TuxGuitar.getProperty("edit.from")); rangeLayout.set( fromLabel, 1, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_CENTER, false, true); final UISpinner fromSpinner = uiFactory.createSpinner(range); fromSpinner.setMaximum(maxSelection); fromSpinner.setMinimum(minSelection); fromSpinner.setValue(minSelection); rangeLayout.set( fromSpinner, 1, 2, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true, 1, 1, 60f, null, null); UILabel toLabel = uiFactory.createLabel(range); toLabel.setText(TuxGuitar.getProperty("edit.to")); rangeLayout.set( toLabel, 2, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_CENTER, false, true); final UISpinner toSpinner = uiFactory.createSpinner(range); toSpinner.setMinimum(minSelection); toSpinner.setMaximum(maxSelection); toSpinner.setValue(maxSelection); rangeLayout.set( toSpinner, 2, 2, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true, 1, 1, 60f, null, null); fromSpinner.addSelectionListener( new UISelectionListener() { public void onSelect(UISelectionEvent event) { int fromSelection = fromSpinner.getValue(); int toSelection = toSpinner.getValue(); if (fromSelection < minSelection) { fromSpinner.setValue(minSelection); } else if (fromSelection > toSelection) { fromSpinner.setValue(toSelection); } } }); toSpinner.addSelectionListener( new UISelectionListener() { public void onSelect(UISelectionEvent event) { int toSelection = toSpinner.getValue(); int fromSelection = fromSpinner.getValue(); if (toSelection < fromSelection) { toSpinner.setValue(fromSelection); } else if (toSelection > maxSelection) { toSpinner.setValue(maxSelection); } } }); // ------------------CHECK OPTIONS-------------------- UITableLayout optionsLayout = new UITableLayout(); UILegendPanel options = uiFactory.createLegendPanel(dialog); options.setLayout(optionsLayout); options.setText(TuxGuitar.getProperty("options")); dialogLayout.set( options, 3, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true, 1, 1, 300f, null, null); final UICheckBox tablatureEnabled = uiFactory.createCheckBox(options); tablatureEnabled.setText(TuxGuitar.getProperty("export.tablature-enabled")); tablatureEnabled.setSelected(true); optionsLayout.set( tablatureEnabled, 1, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true); final UICheckBox scoreEnabled = uiFactory.createCheckBox(options); scoreEnabled.setText(TuxGuitar.getProperty("export.score-enabled")); scoreEnabled.setSelected(true); optionsLayout.set( scoreEnabled, 2, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true); final UICheckBox chordNameEnabled = uiFactory.createCheckBox(options); chordNameEnabled.setText(TuxGuitar.getProperty("export.chord-name-enabled")); chordNameEnabled.setSelected(true); optionsLayout.set( chordNameEnabled, 3, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true); final UICheckBox chordDiagramEnabled = uiFactory.createCheckBox(options); chordDiagramEnabled.setText(TuxGuitar.getProperty("export.chord-diagram-enabled")); chordDiagramEnabled.setSelected(true); optionsLayout.set( chordDiagramEnabled, 4, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true); final UICheckBox blackAndWhite = uiFactory.createCheckBox(options); blackAndWhite.setText(TuxGuitar.getProperty("export.black-and-white")); blackAndWhite.setSelected(true); optionsLayout.set( blackAndWhite, 5, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true); tablatureEnabled.addSelectionListener( new UISelectionListener() { public void onSelect(UISelectionEvent event) { if (!tablatureEnabled.isSelected()) { scoreEnabled.setSelected(true); } } }); scoreEnabled.addSelectionListener( new UISelectionListener() { public void onSelect(UISelectionEvent event) { if (!scoreEnabled.isSelected()) { tablatureEnabled.setSelected(true); } } }); // ------------------BUTTONS-------------------------- UITableLayout buttonsLayout = new UITableLayout(0f); UIPanel buttons = uiFactory.createPanel(dialog, false); buttons.setLayout(buttonsLayout); dialogLayout.set( buttons, 4, 1, UITableLayout.ALIGN_RIGHT, UITableLayout.ALIGN_FILL, true, true); UIButton buttonOK = uiFactory.createButton(buttons); buttonOK.setText(TuxGuitar.getProperty("ok")); buttonOK.setDefaultButton(); buttonOK.addSelectionListener( new UISelectionListener() { public void onSelect(UISelectionEvent event) { int style = 0; style |= (scoreEnabled.isSelected() ? TGLayout.DISPLAY_SCORE : 0); style |= (tablatureEnabled.isSelected() ? TGLayout.DISPLAY_TABLATURE : 0); style |= (chordNameEnabled.isSelected() ? TGLayout.DISPLAY_CHORD_NAME : 0); style |= (chordDiagramEnabled.isSelected() ? TGLayout.DISPLAY_CHORD_DIAGRAM : 0); style |= (blackAndWhite.isSelected() ? TGLayout.DISPLAY_MODE_BLACK_WHITE : 0); Integer trackNumber = tracks.getSelectedValue(); PrintStyles printStyles = new PrintStyles(); printStyles.setTrackNumber(trackNumber != null ? trackNumber : -1); printStyles.setFromMeasure(fromSpinner.getValue()); printStyles.setToMeasure(toSpinner.getValue()); printStyles.setStyle(style); dialog.dispose(); handler.updatePrintStyles(printStyles); } }); buttonsLayout.set( buttonOK, 1, 1, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true, 1, 1, 80f, 25f, null); UIButton buttonCancel = uiFactory.createButton(buttons); buttonCancel.setText(TuxGuitar.getProperty("cancel")); buttonCancel.addSelectionListener( new UISelectionListener() { public void onSelect(UISelectionEvent event) { dialog.dispose(); } }); buttonsLayout.set( buttonCancel, 1, 2, UITableLayout.ALIGN_FILL, UITableLayout.ALIGN_FILL, true, true, 1, 1, 80f, 25f, null); buttonsLayout.set(buttonCancel, UITableLayout.MARGIN_RIGHT, 0f); TGDialogUtil.openDialog(dialog, TGDialogUtil.OPEN_STYLE_CENTER | TGDialogUtil.OPEN_STYLE_PACK); }
public void openSettingsDialog(final TGSongStreamContext context, final Runnable callback) { final TGSong song = context.getAttribute(TGDocumentContextAttributes.ATTRIBUTE_SONG); final PrintStyles styles = createDefaultStyles(song); final Shell dialog = DialogUtils.newDialog( TuxGuitar.getInstance().getShell(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); dialog.setLayout(new GridLayout()); dialog.setText(TuxGuitar.getProperty("options")); // ------------------FORMAT SELECTION------------------ Group formatGroup = new Group(dialog, SWT.SHADOW_ETCHED_IN); formatGroup.setLayout(new GridLayout(2, false)); formatGroup.setLayoutData(getGroupData()); formatGroup.setText(TuxGuitar.getProperty("tuxguitar-image.format")); Label formatLabel = new Label(formatGroup, SWT.NULL); formatLabel.setText(TuxGuitar.getProperty("tuxguitar-image.format")); final Combo formatCombo = new Combo(formatGroup, SWT.DROP_DOWN | SWT.READ_ONLY); formatCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); for (int i = 0; i < ImageFormat.IMAGE_FORMATS.length; i++) { formatCombo.add(ImageFormat.IMAGE_FORMATS[i].getName()); } formatCombo.select(0); // ------------------TRACK SELECTION------------------ Group track = new Group(dialog, SWT.SHADOW_ETCHED_IN); track.setLayout(new GridLayout(2, false)); track.setLayoutData(getGroupData()); track.setText(TuxGuitar.getProperty("track")); Label trackLabel = new Label(track, SWT.NULL); trackLabel.setText(TuxGuitar.getProperty("track")); final Combo tracks = new Combo(track, SWT.DROP_DOWN | SWT.READ_ONLY); tracks.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); for (int number = 1; number <= song.countTracks(); number++) { tracks.add(TuxGuitar.getInstance().getSongManager().getTrack(song, number).getName()); } tracks.select( TuxGuitar.getInstance() .getTablatureEditor() .getTablature() .getCaret() .getTrack() .getNumber() - 1); // ------------------MEASURE RANGE------------------ Group range = new Group(dialog, SWT.SHADOW_ETCHED_IN); range.setLayout(new GridLayout(2, false)); range.setLayoutData(getGroupData()); range.setText(TuxGuitar.getProperty("print.range")); final int minSelection = 1; final int maxSelection = song.countMeasureHeaders(); Label fromLabel = new Label(range, SWT.NULL); fromLabel.setText(TuxGuitar.getProperty("edit.from")); final Spinner fromSpinner = new Spinner(range, SWT.BORDER); fromSpinner.setLayoutData(getSpinnerData()); fromSpinner.setMaximum(maxSelection); fromSpinner.setMinimum(minSelection); fromSpinner.setSelection(minSelection); Label toLabel = new Label(range, SWT.NULL); toLabel.setText(TuxGuitar.getProperty("edit.to")); final Spinner toSpinner = new Spinner(range, SWT.BORDER); toSpinner.setLayoutData(getSpinnerData()); toSpinner.setMinimum(minSelection); toSpinner.setMaximum(maxSelection); toSpinner.setSelection(maxSelection); fromSpinner.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int fromSelection = fromSpinner.getSelection(); int toSelection = toSpinner.getSelection(); if (fromSelection < minSelection) { fromSpinner.setSelection(minSelection); } else if (fromSelection > toSelection) { fromSpinner.setSelection(toSelection); } } }); toSpinner.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int toSelection = toSpinner.getSelection(); int fromSelection = fromSpinner.getSelection(); if (toSelection < fromSelection) { toSpinner.setSelection(fromSelection); } else if (toSelection > maxSelection) { toSpinner.setSelection(maxSelection); } } }); // ------------------CHECK OPTIONS-------------------- Group options = new Group(dialog, SWT.SHADOW_ETCHED_IN); options.setLayout(new GridLayout()); options.setLayoutData(getGroupData()); options.setText(TuxGuitar.getProperty("options")); final Button tablatureEnabled = new Button(options, SWT.CHECK); tablatureEnabled.setText(TuxGuitar.getProperty("export.tablature-enabled")); tablatureEnabled.setSelection(true); final Button scoreEnabled = new Button(options, SWT.CHECK); scoreEnabled.setText(TuxGuitar.getProperty("export.score-enabled")); scoreEnabled.setSelection(true); final Button chordNameEnabled = new Button(options, SWT.CHECK); chordNameEnabled.setText(TuxGuitar.getProperty("export.chord-name-enabled")); chordNameEnabled.setSelection(true); final Button chordDiagramEnabled = new Button(options, SWT.CHECK); chordDiagramEnabled.setText(TuxGuitar.getProperty("export.chord-diagram-enabled")); chordDiagramEnabled.setSelection(true); final Button blackAndWhite = new Button(options, SWT.CHECK); blackAndWhite.setText(TuxGuitar.getProperty("export.black-and-white")); blackAndWhite.setSelection(true); tablatureEnabled.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { if (!tablatureEnabled.getSelection()) { scoreEnabled.setSelection(true); } } }); scoreEnabled.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { if (!scoreEnabled.getSelection()) { tablatureEnabled.setSelection(true); } } }); // ------------------BUTTONS-------------------------- Composite buttons = new Composite(dialog, SWT.NONE); buttons.setLayout(new GridLayout(2, false)); buttons.setLayoutData(new GridData(SWT.END, SWT.FILL, true, true)); final Button buttonOK = new Button(buttons, SWT.PUSH); buttonOK.setText(TuxGuitar.getProperty("ok")); buttonOK.setLayoutData(getButtonData()); buttonOK.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { int format = formatCombo.getSelectionIndex(); if (format < 0 || format >= ImageFormat.IMAGE_FORMATS.length) { format = 0; } int style = 0; style |= (scoreEnabled.getSelection() ? TGLayout.DISPLAY_SCORE : 0); style |= (tablatureEnabled.getSelection() ? TGLayout.DISPLAY_TABLATURE : 0); style |= (chordNameEnabled.getSelection() ? TGLayout.DISPLAY_CHORD_NAME : 0); style |= (chordDiagramEnabled.getSelection() ? TGLayout.DISPLAY_CHORD_DIAGRAM : 0); style |= (blackAndWhite.getSelection() ? TGLayout.DISPLAY_MODE_BLACK_WHITE : 0); styles.setTrackNumber(tracks.getSelectionIndex() + 1); styles.setFromMeasure(fromSpinner.getSelection()); styles.setToMeasure(toSpinner.getSelection()); styles.setStyle(style); dialog.dispose(); ImageExporterSettings settings = new ImageExporterSettings(); settings.setStyles(styles); settings.setFormat(ImageFormat.IMAGE_FORMATS[format]); openDirectoryDialog(settings, context, callback); } }); Button buttonCancel = new Button(buttons, SWT.PUSH); buttonCancel.setText(TuxGuitar.getProperty("cancel")); buttonCancel.setLayoutData(getButtonData()); buttonCancel.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { dialog.dispose(); } }); dialog.setDefaultButton(buttonOK); DialogUtils.openDialog(dialog, DialogUtils.OPEN_STYLE_CENTER | DialogUtils.OPEN_STYLE_PACK); }
private void readMeasureHeaders(TGSong song, int count) throws IOException { TGTimeSignature timeSignature = getFactory().newTimeSignature(); for (int i = 0; i < count; i++) { song.addMeasureHeader(readMeasureHeader((i + 1), song, timeSignature)); } }