Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void play() throws MusicGenerationException
songPartWork = songContextWork.getSongParts().get(0);
var cls = songContextWork.getSong().getChordLeadSheet();
firstChordSymbol = cls.getItems(songPartWork.getParentSection(), CLI_ChordSymbol.class).get(0);
var dynSession = UpdateProviderSongSession.getSession(songContextWork, true, true, false, false, false, Sequencer.LOOP_CONTINUOUSLY, null);
var dynSession = UpdateProviderSongSession.getSession(songContextWork, true, false, false, false, Sequencer.LOOP_CONTINUOUSLY, null);
dynSession.setPreUpdateBufferTimeMs(5); // Each user chord change generates only 2 song changes (remove and add 1 CLI_ChordSymbol)
dynSession.setPostUpdateSleepTimeMs(100); // This allow user to change chord quickly
dynSession.setUserErrorExceptionHandler(null); // User execption may occur depending on timing, as we remove then add a chord symbol at section start
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public CL_SelectionUtilities(Lookup lookup)

Collections.sort(items);
Collections.sort(selectedBars);

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
*/
public interface IR_Copiable
{

/**
* If true, ItemRenderer should represent the copy mode, possibly using the provided CopyIndicator.
*
Expand All @@ -45,7 +44,6 @@ public interface IR_Copiable
*/
static public class CopyIndicator
{

private static final CrossShape crossShape = new CrossShape(3, 2);

static public void drawCopyIndicator(Graphics2D g2)
Expand Down
13 changes: 12 additions & 1 deletion app/CL_EditorImpl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
<version>4.1.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<groupId>org.jjazzlab.app</groupId>
<artifactId>cl_editorimpl</artifactId>
<name>CL_EditorImpl</name>
<packaging>nbm</packaging>

<build>
<plugins>
<plugin>
Expand All @@ -20,6 +22,7 @@
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.jjazzlab.core</groupId>
Expand Down Expand Up @@ -105,7 +108,15 @@
<groupId>org.jjazzlab.core</groupId>
<artifactId>utilities</artifactId>
<version>${project.version}</version>
</dependency>
</dependency>
<dependency>
<!-- This is only needed for one setting used in the transposition feature (saved with PlaybackSettings).
If the dependency needs to be removed, it should be easy to move somewhere else. -->
<groupId>org.jjazzlab.core</groupId>
<artifactId>musiccontrol</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util-lookup</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.AttributedString;
import java.util.Objects;
import java.util.logging.Level;
Expand All @@ -49,19 +50,22 @@
import org.jjazz.cl_editor.itemrenderer.api.IR_Type;
import org.jjazz.cl_editor.itemrenderer.api.ItemRenderer;
import org.jjazz.cl_editor.itemrenderer.api.ItemRendererSettings;
import org.jjazz.musiccontrol.api.PlaybackSettings;
import org.jjazz.uiutilities.api.TextLayoutUtils;
import org.jjazz.utilities.api.ResUtil;

/**
* An ItemRenderer for ChordSymbols.
* <p>
*/
public class IR_ChordSymbol extends ItemRenderer implements IR_Copiable
public class IR_ChordSymbol extends ItemRenderer implements IR_Copiable, PropertyChangeListener
{

private final static int OPTION_LINE_V_PADDING = 1; // Additional space for the option line
private final static int OPTION_LINE_THICKNESS = 1; // Additional space for the option line
private static final Logger LOGGER = Logger.getLogger(IR_ChordSymbol.class.getSimpleName());

private AttributedString attChordString;
private int transposition;
private boolean copyMode;
private final IR_ChordSymbolSettings settings;
private int zoomFactor = 50;
Expand All @@ -76,42 +80,70 @@ public class IR_ChordSymbol extends ItemRenderer implements IR_Copiable
private ChordRenderingInfo cri;
private Timer timer;
private Color optionLineColor;
private static final Logger LOGGER = Logger.getLogger(IR_ChordSymbol.class.getSimpleName());
private final PlaybackSettings playbackSettings;

@SuppressWarnings("LeakingThisInConstructor")
public IR_ChordSymbol(CLI_ChordSymbol item, ItemRendererSettings irSettings)
{
super(item, IR_Type.ChordSymbol);
LOGGER.log(Level.FINE, "IR_ChordSymbol() item={0}", item);


// Apply settings and listen to their changes
settings = irSettings.getIR_ChordSymbolSettings();
settings.addPropertyChangeListener(this);
setFont(settings.getFont());

// Listen to transposition option changes
playbackSettings = PlaybackSettings.getInstance();
playbackSettings.addPropertyChangeListener(PlaybackSettings.PROP_CHORD_SYMBOLS_DISPLAY_TRANSPOSITION, this);
setTransposition(playbackSettings.getChordSymbolsDisplayTransposition());

// Listen to color change
getModel().getClientProperties().addPropertyChangeListener(this);

updateForegroundColor();

modelChanged();
modelChanged(); // Shown chord changes
}

/**
* Sets a transposition to be applied before rendering the chord.
*
* @param newTransposition
*/
private void setTransposition(int newTransposition)
{
transposition = newTransposition;
var chord = getModel().getData();
if (chord != null)
{
ExtChordSymbol modelChord = (ExtChordSymbol) chord;
ExtChordSymbol newChord = modelChord.getTransposedChordSymbol(transposition, null);
updateRendering(newChord);
}
}

@Override
public void modelChanged()
{
var chord = getModel().getData();
if (chord != null)
{
ExtChordSymbol modelChord = (ExtChordSymbol) getModel().getData();
ExtChordSymbol newChord = modelChord.getTransposedChordSymbol(transposition, null);
updateRendering(newChord);
}
}

private void updateRendering(ExtChordSymbol newChord)
{
// Save previous state
ExtChordSymbol oldEcs = ecs;
ChordRenderingInfo oldCri = cri;
String oldChordSymbolString = chordSymbolString;
ChordSymbol oldAltChordSymbol = altChordSymbol;


// Update our state
ecs = (ExtChordSymbol) getModel().getData();
ecs = newChord;
cri = ecs.getRenderingInfo();
chordSymbolString = ecs.getOriginalName();
altChordSymbol = ecs.getAlternateChordSymbol();
Expand Down Expand Up @@ -262,6 +294,7 @@ public void cleanup()
super.cleanup();
getModel().getClientProperties().removePropertyChangeListener(this);
settings.removePropertyChangeListener(this);
playbackSettings.removePropertyChangeListener(PlaybackSettings.PROP_CHORD_SYMBOLS_DISPLAY_TRANSPOSITION, this);
}

private void updateToolTipText()
Expand Down Expand Up @@ -451,6 +484,9 @@ public void propertyChange(PropertyChangeEvent e)
{
updateForegroundColor();
}
} else if (PlaybackSettings.PROP_CHORD_SYMBOLS_DISPLAY_TRANSPOSITION.equals(e.getPropertyName()))
{
setTransposition((int) e.getNewValue());
}
}

Expand Down Expand Up @@ -484,5 +520,4 @@ private void updateForegroundColor()
optionLineColor = c;
setForeground(c);
}

}
Loading