Skip to content

Commit

Permalink
changes changed
Browse files Browse the repository at this point in the history
  • Loading branch information
berndmoos committed Aug 19, 2024
1 parent 1f3fda8 commit 7b67e04
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 30 deletions.
3 changes: 3 additions & 0 deletions src/org/exmaralda/exakt/exmaraldaSearch/COMACorpus.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public void readCorpus(File file, boolean index) throws JDOMException, IOExcepti
fetchAttributes("//Speaker", speakerAttributes, FIXED_SPEAKER_ATTRIBUTES);
fetchAttributes("//Communication", communicationAttributes, FIXED_COMMUNICATION_ATTRIBUTES);
fetchAttributes("//Transcription", transcriptionAttributes, FIXED_TRANSCRIPTION_ATTRIBUTES);

// do something here for #492
// fetchAttributes("//Communication/Setting", communicationAttributes, FIXED_COMMUNICATION_ATTRIBUTES);
}

@Override
Expand Down
2 changes: 0 additions & 2 deletions src/org/exmaralda/exakt/search/CorpusInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

package org.exmaralda.exakt.search;

import java.util.*;

/**
*
* @author thomas
Expand Down
3 changes: 0 additions & 3 deletions src/org/exmaralda/exakt/search/XMLCorpusComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.jdom.input.SAXBuilder;
import org.xml.sax.InputSource;

/**
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* PlayAction.java
*
* Created on 14. Mai 2008, 16:59
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package org.exmaralda.folker.actions.partiturviewactions;

import java.awt.event.ActionEvent;
import org.exmaralda.folker.actions.AbstractApplicationAction;
import javax.swing.*;
import org.exmaralda.folker.application.AbstractTimeviewPartiturPlayerControl;
/**
*
* @author thomas
*/
public class AssignTimesToEventAction extends AbstractApplicationAction {

/** Creates a new instance of PlayAction
* @param ac
* @param name
* @param icon */
public AssignTimesToEventAction(AbstractTimeviewPartiturPlayerControl ac, String name, Icon icon) {
super(ac, name, icon);
}

@Override
public void actionPerformed(ActionEvent e) {
System.out.println("[*** AssignTimesToEventAction ***]");
applicationControl.assignTimesToEvent();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
*/
public class PlayAction extends AbstractApplicationAction {

/** Creates a new instance of PlayAction */
/** Creates a new instance of PlayAction
* @param ac
* @param name
* @param icon */
public PlayAction(AbstractTimeviewPartiturPlayerControl ac, String name, Icon icon) {
super(ac, name, icon);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
package org.exmaralda.folker.application;

import java.awt.Component;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JToggleButton;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
Expand All @@ -24,6 +27,9 @@
import org.exmaralda.folker.timeview.TimeSelectionEvent;
import org.exmaralda.folker.timeview.TimeSelectionListener;
import org.exmaralda.folker.utilities.Constants;
import org.exmaralda.folker.utilities.FOLKERInternationalizer;
import org.exmaralda.partitureditor.jexmaralda.Event;
import org.exmaralda.partitureditor.jexmaralda.JexmaraldaException;
import org.exmaralda.partitureditor.jexmaralda.Tier;
import org.exmaralda.partitureditor.jexmaralda.Timeline;
import org.exmaralda.partitureditor.jexmaralda.TimelineItem;
Expand Down Expand Up @@ -102,6 +108,7 @@ public abstract class AbstractTimeviewPartiturPlayerControl
public org.exmaralda.folker.actions.partiturviewactions.AddEventInPartiturAction addEventInPartiturAction;
public org.exmaralda.folker.actions.partiturviewactions.AppendIntervalInPartiturAction appendIntervalInPartiturAction;
public org.exmaralda.folker.actions.partiturviewactions.AssignTimesAction assignTimesAction;
public org.exmaralda.folker.actions.partiturviewactions.AssignTimesToEventAction assignTimesToEventAction; // issue #374
public org.exmaralda.folker.actions.partiturviewactions.WhisperASRAction whisperASRAction;
public org.exmaralda.folker.actions.partiturviewactions.AddIntervalInPartiturAction addIntervalInPartiturAction;
// ---------------------------
Expand Down Expand Up @@ -194,6 +201,9 @@ void initActions(){
assignTimesAction = new org.exmaralda.folker.actions.partiturviewactions.AssignTimesAction(this, "", c.getIcon(Constants.TIMESTAMP_EVENT_ICON));
assignTimesAction.setEnabled(false);

assignTimesToEventAction = new org.exmaralda.folker.actions.partiturviewactions.AssignTimesToEventAction(this, "", c.getIcon(Constants.TIMESTAMP_EVENT_ICON));
assignTimesToEventAction.setEnabled(false);

// -----------------
changeZoomAction = new org.exmaralda.folker.actions.waveformactions.ChangeZoomAction(this, "", c.getIcon(Constants.ZOOM_ICON));

Expand Down Expand Up @@ -387,6 +397,64 @@ public void assignTimes() {
timeViewer.fireSelectionDetached();
}
}

public void assignTimesToEvent(){
try {
double selStart = selectionStart;
double selEnd = selectionEnd;

Timeline timeline = partitur.getModel().getTranscription().getBody().getCommonTimeline();
// 17-08-2024, for issue #374
Event selectedEvent = partitur.getModel().getEvent(partitur.selectionStartRow, partitur.selectionStartCol);


Tier tier = partitur.getModel().getTier(partitur.selectionStartRow);
for (int pos=0; pos<tier.getNumberOfEvents(); pos++){
Event existingEvent = tier.getEventAt(pos);
if (existingEvent.getStart().equals(selectedEvent.getStart())) continue;
double start = timeline.getTimelineItemWithID(existingEvent.getStart()).getTime();
double end = timeline.getTimelineItemWithID(existingEvent.getEnd()).getTime();

boolean positionIsOccupied =
(start<selStart/1000.0 && end>selStart/1000.0) ||
(start<selEnd/1000.0 && end>selEnd/1000.0);

if (positionIsOccupied){
JOptionPane.showMessageDialog(partitur, FOLKERInternationalizer.getString("misc.positionTaken"));
return;
}


}

Event newEvent = new Event();
newEvent.setDescription(selectedEvent.getDescription());
partitur.getModel().deleteEvent(partitur.selectionStartRow, partitur.selectionStartCol);




partitur.commitEdit(true);
int[] cols = partitur.getModel().insertInterval(selStart/1000.0, selEnd/1000.0, 0.001);
int col1 = cols[0];
int col2 = cols[1];

newEvent.setStart(timeline.getTimelineItemAt(col1).getID());
newEvent.setEnd(timeline.getTimelineItemAt(col2).getID());

partitur.getModel().getTier(partitur.selectionStartRow).addEvent(newEvent);
int startCol = timeline.lookupID(newEvent.getStart());
int endCol = timeline.lookupID(newEvent.getEnd());
partitur.getModel().fireEventAdded(partitur.selectionStartRow, startCol, endCol);
partitur.getModel().fireCellSpanChanged(partitur.selectionStartRow, startCol);
partitur.setNewSelection(partitur.selectionStartRow, startCol, true);



} catch (JexmaraldaException ex) {
Logger.getLogger(AbstractTimeviewPartiturPlayerControl.class.getName()).log(Level.SEVERE, null, ex);
}
}


public void appendInterval(){
Expand Down Expand Up @@ -594,6 +662,12 @@ public void processTimeSelectionEvent(TimeSelectionEvent event) {
((selectionStart!=selectionEnd) && (partitur.aWholeColumnIsSelected || partitur.aSeriesOfColumnsIsSelected))
|| (selectionStart==selectionEnd) && (partitur.aWholeColumnIsSelected));

assignTimesToEventAction.setEnabled(
(selectionStart!=selectionEnd) //&& partitur.aSingleCellIsSelected
//&& partitur.isEditing
&& partitur.getModel().containsEvent(partitur.selectionStartRow, partitur.selectionStartCol)
);

decreaseSelectionStartAction.setEnabled(selectionStart!=selectionEnd);
increaseSelectionStartAction.setEnabled(selectionStart!=selectionEnd);
decreaseSelectionEndAction.setEnabled(selectionStart!=selectionEnd);
Expand Down
3 changes: 1 addition & 2 deletions src/org/exmaralda/folker/application/ApplicationControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.exmaralda.folker.matchlist.MatchListDialog;
import org.exmaralda.folker.utilities.FOLKERInternationalizer;
import org.exmaralda.folker.utilities.PreferencesUtilities;
import org.exmaralda.folker.videopanel.VideoFrame;
import org.exmaralda.folker.videopanel.VideoPanel;
import org.exmaralda.masker.MaskFileDialog;
import org.exmaralda.masker.MaskTimeCreator;
Expand Down Expand Up @@ -811,7 +810,7 @@ void assignActions(){
applicationFrame.mainPanel.shrinkRightButton.setToolTipText(FOLKERInternationalizer.getString("partituractions.shrinkRight"));

// 12-08-2024, issue #374
applicationFrame.mainPanel.assignTimesInPartiturButton.setAction(assignTimesAction);
applicationFrame.mainPanel.assignTimesInPartiturButton.setAction(assignTimesToEventAction);
applicationFrame.mainPanel.assignTimesInPartiturButton.setText(null);
applicationFrame.mainPanel.assignTimesInPartiturButton.setToolTipText("Zeit neu zuweisen");

Expand Down
16 changes: 8 additions & 8 deletions src/org/exmaralda/folker/application/MainPanel.form
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,6 @@
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="assignTimesInPartiturButton">
<Properties>
<Property name="text" type="java.lang.String" value="jButton1"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="playbackControlsPanel">
Expand Down Expand Up @@ -804,6 +796,14 @@
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="assignTimesInPartiturButton">
<Properties>
<Property name="text" type="java.lang.String" value="jButton1"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
</SubComponents>
Expand Down
8 changes: 4 additions & 4 deletions src/org/exmaralda/folker/application/MainPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ private void initComponents() {
selectionsControlPanel = new javax.swing.JPanel();
shiftSelectionButton = new javax.swing.JButton();
detachSelectionButton = new javax.swing.JButton();
assignTimesInPartiturButton = new javax.swing.JButton();
playbackControlsPanel = new javax.swing.JPanel();
playNextSegmentButton = new javax.swing.JButton();
textViewPanel = new javax.swing.JPanel();
Expand Down Expand Up @@ -122,6 +121,7 @@ private void initComponents() {
insertPauseInPartiturButton = new javax.swing.JButton();
removeEventInPartiturButton = new javax.swing.JButton();
maskInPartiturButton = new javax.swing.JButton();
assignTimesInPartiturButton = new javax.swing.JButton();
contributionViewPanel = new javax.swing.JPanel();
contributionViewSplitPane = new javax.swing.JSplitPane();
contributionTablePanel = new javax.swing.JPanel();
Expand Down Expand Up @@ -278,9 +278,6 @@ private void initComponents() {
detachSelectionButton.setText("jButton1");
selectionsControlPanel.add(detachSelectionButton);

assignTimesInPartiturButton.setText("jButton1");
selectionsControlPanel.add(assignTimesInPartiturButton);

controlsPanel.add(selectionsControlPanel, java.awt.BorderLayout.EAST);

playNextSegmentButton.setText("jButton1");
Expand Down Expand Up @@ -421,6 +418,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
maskInPartiturButton.setText("jButton1");
partiturViewButtonPanel.add(maskInPartiturButton);

assignTimesInPartiturButton.setText("jButton1");
partiturViewButtonPanel.add(assignTimesInPartiturButton);

partiturViewPanel.add(partiturViewButtonPanel, java.awt.BorderLayout.NORTH);

textViewsTabbedPane.addTab(FOLKERInternationalizer.getString("gui.partitur"), null, partiturViewPanel, FOLKERInternationalizer.getString("gui.partiturtooltip"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,14 @@ protected void paintComponent(Graphics g) {
markTriangle.addPoint((int)(getMarkPixel()), 6);
g.fillPolygon(markTriangle);
}

if (this.getPlayAndSelectStartTime()>=0){
float startPixel = this.getPixelForMilisecond(getPlayAndSelectStartTime());
float endPixel = this.getPixelForMilisecond(this.getCursorTime());
g.setColor(Color.GRAY);
g.fillRect((int)startPixel, 0, (int)(endPixel-startPixel), 20);
}

}

@Override
Expand Down Expand Up @@ -622,6 +630,7 @@ public void setCursorPositionPixel(float cpp) {
repaint();
BUFFER_REDRAW_NECESSARY = true;
}

}

public float getMarkPixel() {
Expand Down Expand Up @@ -836,10 +845,10 @@ public void processPlayableEvent(PlayableEvent e) {
//SwingUtilities.invokeLater(new Runnable(){
// @Override
// public void run() {
setCursorPositionPixel(pixel);
BUFFER_REDRAW_NECESSARY = false;
repaint();
BUFFER_REDRAW_NECESSARY = true;
setCursorPositionPixel(pixel);
BUFFER_REDRAW_NECESSARY = false;
repaint();
BUFFER_REDRAW_NECESSARY = true;
// }
//});
} else if ((e.getType() == PlayableEvent.PLAYBACK_STOPPED)){
Expand All @@ -854,6 +863,24 @@ public void processPlayableEvent(PlayableEvent e) {
}
}


// #490
double playAndSelectStartTime = -1.0;

public void setPlayAndSelectStartTime() {
playAndSelectStartTime = this.getCursorTime();
}

public void resetPlayAndSelectStartTime() {
playAndSelectStartTime = -1.0;
}

public double getPlayAndSelectStartTime() {
return playAndSelectStartTime;
}






Expand Down
27 changes: 23 additions & 4 deletions src/org/exmaralda/folker/utilities/FOLKERInternationalization.xml
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,22 @@
</subdomain>
<subdomain name="context_menu">
<item id="context_menu.assignSpeaker">
<translation lang="en" trans="Assign speaker"/>
<translation lang="de" trans="Sprecher zuordnen"/>
<translation lang="fr" trans="Assigner locuteur"/>
<translation lang="en" trans="Assign speaker"/>
<translation lang="de" trans="Sprecher zuordnen"/>
<translation lang="fr" trans="Assigner locuteur"/>
</item>
context_menu.assignSpeaker
<item id="context_menu.mergeSegments">
<translation lang="en" trans="Merge segments"/>
<translation lang="de" trans="Segmente verbinden"/>
<translation lang="fr" trans="Fusionner les segments"/>
</item>
<item id="context_menu.removeSegment">
<translation lang="en" trans="Remove segment(s)"/>
<translation lang="de" trans="Segment(e) entfernen"/>
<translation lang="fr" trans="Supprimer un/des segment(s)"/>
</item>


</subdomain>
</subdomain>
<!-- ************************************************************************************* -->
Expand Down Expand Up @@ -1453,6 +1464,14 @@

</subdomain>
<subdomain name="miscellaneous">
<item id="misc.positionTaken">
<translation lang="en"
trans="There is another event at this position. Cannot reassign times."/>
<translation lang="de"
trans="Es gibt ein anderes Ereignis an dieser Position. Zeiten können nicht neu zugewiesen werden."/>
<translation lang="fr"
trans="There is another event at this position. Cannot reassign times."/>
</item>
<item id="misc.basicTranscription">
<translation lang="en"
trans="EXMARaLDA Basic Transcription (*.exb)"/>
Expand Down
Loading

0 comments on commit 7b67e04

Please sign in to comment.