-
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fix splashscreen not showing black background only on windows and l…
…inux - implement duplicate overview dialog - introduce config variable ApplicationConfiguration.FILM_EVALUATE_DUPLICATES - refactor out CommonStatsEvaluationTask - code cleanup - relax error reporting in DatenFilm.setDatumLong
- Loading branch information
1 parent
0affbfb
commit 1f4cd52
Showing
13 changed files
with
531 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/mediathek/gui/duplicates/BigSenderPenaltyComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package mediathek.gui.duplicates; | ||
|
||
import mediathek.daten.DatenFilm; | ||
|
||
import java.util.Comparator; | ||
|
||
public class BigSenderPenaltyComparator implements Comparator<DatenFilm> { | ||
@Override | ||
public int compare(DatenFilm s1, DatenFilm s2) { | ||
// "ARD" und "ZDF" immer am Ende um die kleineren Mediatheken nicht zu benachteiligen | ||
final var s1_sender = s1.getSender(); | ||
final var s2_sender = s2.getSender(); | ||
if (s1_sender.equals("ARD") || s1_sender.equals("ZDF")) { | ||
return 1; | ||
} | ||
if (s2_sender.equals("ARD") || s2_sender.equals("ZDF")) { | ||
return -1; | ||
} | ||
// Alphabetisch sortieren für alle anderen | ||
return s1.compareTo(s2); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/mediathek/gui/duplicates/CommonStatsEvaluationTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package mediathek.gui.duplicates; | ||
|
||
import ca.odell.glazedlists.TransactionList; | ||
import com.google.common.base.Stopwatch; | ||
import mediathek.config.Daten; | ||
import mediathek.daten.DatenFilm; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
public class CommonStatsEvaluationTask implements Runnable { | ||
private static final Logger logger = LogManager.getLogger(); | ||
|
||
@Override | ||
public void run() { | ||
Stopwatch watch = Stopwatch.createStarted(); | ||
final var films = Daten.getInstance().getListeFilme().parallelStream() | ||
.filter(f -> !f.isLivestream()) | ||
.toList(); | ||
|
||
var statisticsList = Daten.getInstance().getCommonStatistics(); | ||
|
||
Map<String, Long> statisticsMap = films.parallelStream() | ||
.collect(Collectors.groupingBy(DatenFilm::getSender, Collectors.counting())); | ||
TransactionList<FilmStatistics> tList = new TransactionList<>(statisticsList); | ||
statisticsList.getReadWriteLock().writeLock().lock(); | ||
tList.beginEvent(true); | ||
tList.clear(); | ||
for (var sender : statisticsMap.keySet()) { | ||
tList.add(new FilmStatistics(sender, statisticsMap.get(sender))); | ||
} | ||
tList.commitEvent(); | ||
statisticsList.getReadWriteLock().writeLock().unlock(); | ||
watch.stop(); | ||
|
||
logger.trace("common stats calculation took: {}", watch); | ||
logger.trace("Number of films: {}", films.size()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/mediathek/gui/duplicates/overview/CustomTreeCellRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package mediathek.gui.duplicates.overview; | ||
|
||
import mediathek.daten.DatenFilm; | ||
|
||
import javax.swing.*; | ||
import javax.swing.tree.DefaultMutableTreeNode; | ||
import javax.swing.tree.DefaultTreeCellRenderer; | ||
import java.awt.*; | ||
|
||
class CustomTreeCellRenderer | ||
extends DefaultTreeCellRenderer { | ||
public Component getTreeCellRendererComponent( | ||
JTree tree, | ||
Object value, | ||
boolean selected, | ||
boolean expanded, | ||
boolean leaf, | ||
int row, | ||
boolean hasFocus) { | ||
// Allow the original renderer to set up the label | ||
Component c = super.getTreeCellRendererComponent( | ||
tree, value, selected, | ||
expanded, leaf, row, | ||
hasFocus); | ||
|
||
var node = (DefaultMutableTreeNode) value; | ||
if (node.isRoot()) | ||
return c; | ||
|
||
switch (node.getUserObject()) { | ||
case DatenFilm f -> { | ||
setText(f.getTitle()); | ||
setToolTipText(prepareTooltipText(f)); | ||
} | ||
case String s -> setText(String.format("%s (%d)", s, node.getChildCount())); | ||
default -> setText(value.toString()); | ||
} | ||
|
||
return c; | ||
} | ||
|
||
private String prepareTooltipText(DatenFilm f) { | ||
var s = """ | ||
<html> | ||
<b>Thema:</b> %s<br> | ||
<b>Titel:</b> %s<br> | ||
<b>gesendet:</b> %s %s<br> | ||
</html> | ||
"""; | ||
return String.format(s, f.getThema(), f.getTitle(), | ||
f.getSendeDatum(), f.getSendeZeit()); | ||
} | ||
} |
Oops, something went wrong.