diff --git a/source/net/filebot/similarity/EpisodeMetrics.java b/source/net/filebot/similarity/EpisodeMetrics.java index 672b0b69..944f3e1f 100644 --- a/source/net/filebot/similarity/EpisodeMetrics.java +++ b/source/net/filebot/similarity/EpisodeMetrics.java @@ -1,6 +1,5 @@ package net.filebot.similarity; -import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; import static java.util.regex.Pattern.*; @@ -161,7 +160,7 @@ public enum EpisodeMetrics implements SimilarityMetric { } // 1:SxE && Title, 2:SxE - return (float) ((max(sxe, 0) * title) + (floor(sxe) / 10)); + return (float) ((Math.max(sxe, 0) * title) + (Math.floor(sxe) / 10)); } public Object getTitle(Object o) { @@ -191,7 +190,7 @@ public enum EpisodeMetrics implements SimilarityMetric { sum /= f1.length * f2.length; // normalize into 3 similarity levels - return (float) (ceil(sum * 3) / 3); + return (float) (Math.ceil(sum * 3) / 3); } protected String[] normalize(Object[] objects) { @@ -244,13 +243,13 @@ public enum EpisodeMetrics implements SimilarityMetric { float max = 0; for (String s1 : f1) { for (String s2 : f2) { - max = max(super.getSimilarity(s1, s2), max); + max = Math.max(super.getSimilarity(s1, s2), max); } } // normalize absolute similarity to similarity rank (4 ranks in total), // so we are less likely to fall for false positives in this pass, and move on to the next one - return (float) (floor(max * 4) / 4); + return (float) (Math.floor(max * 4) / 4); } @Override @@ -287,7 +286,7 @@ public enum EpisodeMetrics implements SimilarityMetric { public float getSimilarity(Object o1, Object o2) { // normalize absolute similarity to similarity rank (4 ranks in total), // so we are less likely to fall for false positives in this pass, and move on to the next one - return (float) (floor(super.getSimilarity(o1, o2) * 4) / 4); + return (float) (Math.floor(super.getSimilarity(o1, o2) * 4) / 4); } @Override @@ -311,13 +310,13 @@ public enum EpisodeMetrics implements SimilarityMetric { float max = 0; for (String s1 : f1) { for (String s2 : f2) { - max = max(super.getSimilarity(s1, s2), max); + max = Math.max(super.getSimilarity(s1, s2), max); } } // normalize absolute similarity to similarity rank (4 ranks in total), // so we are less likely to fall for false positives in this pass, and move on to the next one - return (float) (floor(max * 4) / 4); + return (float) (Math.floor(max * 4) / 4); } @Override @@ -395,11 +394,11 @@ public enum EpisodeMetrics implements SimilarityMetric { s1 = stripReleaseInfo(s1, false); s2 = stripReleaseInfo(s2, false); - int length = min(s1.length(), s2.length()); + int length = Math.min(s1.length(), s2.length()); s1 = s1.substring(0, length); s2 = s2.substring(0, length); - return (float) (floor(super.getSimilarity(s1, s2) * 4) / 4); + return (float) (Math.floor(super.getSimilarity(s1, s2) * 4) / 4); }; @Override @@ -415,7 +414,7 @@ public enum EpisodeMetrics implements SimilarityMetric { float lowerBound = super.getSimilarity(normalize(o1, true), normalize(o2, true)); float upperBound = super.getSimilarity(normalize(o1, false), normalize(o2, false)); - return max(lowerBound, upperBound); + return Math.max(lowerBound, upperBound); }; @Override @@ -459,7 +458,7 @@ public enum EpisodeMetrics implements SimilarityMetric { for (String s1 : f1) { for (String s2 : f2) { if (s1 != null && s2 != null) { - max = max(super.getSimilarity(s1, s2), max); + max = Math.max(super.getSimilarity(s1, s2), max); if (max >= 1) { return max; } @@ -578,7 +577,7 @@ public enum EpisodeMetrics implements SimilarityMetric { if (r1 < 0 || r2 < 0) return -1; - return max(r1, r2); + return Math.max(r1, r2); } public float getScore(Object object) { @@ -586,7 +585,7 @@ public enum EpisodeMetrics implements SimilarityMetric { SeriesInfo seriesInfo = ((Episode) object).getSeriesInfo(); if (seriesInfo != null && seriesInfo.getRating() != null && seriesInfo.getRatingCount() != null) { if (seriesInfo.getRatingCount() >= 20) { - return (float) floor(seriesInfo.getRating() / 3); // BOOST POPULAR SHOWS and PUT INTO 3 GROUPS + return (float) Math.floor(seriesInfo.getRating() / 3); // BOOST POPULAR SHOWS and PUT INTO 3 GROUPS } if (seriesInfo.getRatingCount() >= 1) { return 0; // PENALIZE SHOWS WITH FEW RATINGS @@ -605,7 +604,7 @@ public enum EpisodeMetrics implements SimilarityMetric { float r1 = getScore(o1); float r2 = getScore(o2); - return max(r1, r2) >= 0.1 ? 1 : 0; + return Math.max(r1, r2) >= 0.1 ? 1 : 0; } public float getScore(Object object) { diff --git a/source/net/filebot/similarity/MetricCascade.java b/source/net/filebot/similarity/MetricCascade.java index f4de1107..646160e7 100644 --- a/source/net/filebot/similarity/MetricCascade.java +++ b/source/net/filebot/similarity/MetricCascade.java @@ -1,7 +1,5 @@ package net.filebot.similarity; -import static java.lang.Math.*; - public class MetricCascade implements SimilarityMetric { private final SimilarityMetric[] cascade; @@ -15,7 +13,7 @@ public class MetricCascade implements SimilarityMetric { float f = 0; for (SimilarityMetric metric : cascade) { float similarity = metric.getSimilarity(o1, o2); - if (abs(similarity) >= abs(f)) { + if (Math.abs(similarity) >= Math.abs(f)) { // perfect match, ignore remaining metrics if (similarity >= 1) { return similarity; diff --git a/source/net/filebot/similarity/SequenceMatchSimilarity.java b/source/net/filebot/similarity/SequenceMatchSimilarity.java index 28d51aa9..7c64f50e 100644 --- a/source/net/filebot/similarity/SequenceMatchSimilarity.java +++ b/source/net/filebot/similarity/SequenceMatchSimilarity.java @@ -1,6 +1,5 @@ package net.filebot.similarity; -import static java.lang.Math.*; import static net.filebot.similarity.CommonSequenceMatcher.*; import static net.filebot.similarity.Normalization.*; @@ -32,7 +31,7 @@ public class SequenceMatchSimilarity implements SimilarityMetric { } protected float similarity(String match, String s1, String s2) { - return (float) match.length() / min(s1.length(), s2.length()); + return (float) match.length() / Math.min(s1.length(), s2.length()); } protected String normalize(Object object) { diff --git a/source/net/filebot/similarity/TimeStampMetric.java b/source/net/filebot/similarity/TimeStampMetric.java index 2b4473b9..fac822e9 100644 --- a/source/net/filebot/similarity/TimeStampMetric.java +++ b/source/net/filebot/similarity/TimeStampMetric.java @@ -1,14 +1,10 @@ package net.filebot.similarity; - -import static java.lang.Math.*; - import java.io.File; import java.nio.file.Files; import java.nio.file.attribute.BasicFileAttributes; - public class TimeStampMetric implements SimilarityMetric { @Override @@ -19,13 +15,12 @@ public class TimeStampMetric implements SimilarityMetric { if (t1 <= 0 || t2 <= 0) return -1; - float min = min(t1, t2); - float max = max(t1, t2); + float min = Math.min(t1, t2); + float max = Math.max(t1, t2); return min / max; } - public long getTimeStamp(Object obj) { if (obj instanceof File) { try { diff --git a/source/net/filebot/subtitle/SubtitleMetrics.java b/source/net/filebot/subtitle/SubtitleMetrics.java index 00457962..d082cda2 100644 --- a/source/net/filebot/subtitle/SubtitleMetrics.java +++ b/source/net/filebot/subtitle/SubtitleMetrics.java @@ -1,6 +1,5 @@ package net.filebot.subtitle; -import static java.lang.Math.*; import static java.util.Collections.*; import static net.filebot.Logging.*; import static net.filebot.media.MediaDetection.*; @@ -122,7 +121,7 @@ public enum SubtitleMetrics implements SimilarityMetric { @Override protected float similarity(String match, String s1, String s2) { - return (float) match.length() / max(s1.length(), s2.length()) > 0.8 ? 1 : 0; + return (float) match.length() / Math.max(s1.length(), s2.length()) > 0.8 ? 1 : 0; } private final Map xattrCache = new WeakHashMap(64); @@ -171,11 +170,11 @@ public enum SubtitleMetrics implements SimilarityMetric { private Map getSubtitleProperties(OpenSubtitlesSubtitleDescriptor subtitle) { try { Map props = new HashMap(); - float fps = round(subtitle.getMovieFPS()); // round because most FPS values in the database are bad anyway + float fps = Math.round(subtitle.getMovieFPS()); // round because most FPS values in the database are bad anyway if (fps > 0) { props.put(FPS, fps); } - long seconds = (long) floor(subtitle.getMovieTimeMS() / (double) 1000); + long seconds = (long) Math.floor(subtitle.getMovieTimeMS() / (double) 1000); if (seconds > 0) { props.put(SECONDS, seconds); } @@ -195,11 +194,11 @@ public enum SubtitleMetrics implements SimilarityMetric { Map props = new HashMap(); MediaInfo mediaInfo = new MediaInfo().open(file); - float fps = round(Float.parseFloat(mediaInfo.get(StreamKind.Video, 0, "FrameRate"))); + float fps = Math.round(Float.parseFloat(mediaInfo.get(StreamKind.Video, 0, "FrameRate"))); if (fps > 0) { props.put(FPS, fps); } - long seconds = (long) floor(Long.parseLong(mediaInfo.get(StreamKind.Video, 0, "Duration")) / (double) 1000); + long seconds = (long) Math.floor(Long.parseLong(mediaInfo.get(StreamKind.Video, 0, "Duration")) / (double) 1000); if (seconds > 0) { props.put(SECONDS, seconds); } diff --git a/source/net/filebot/subtitle/SubtitleUtilities.java b/source/net/filebot/subtitle/SubtitleUtilities.java index ec9543ab..eb35071f 100644 --- a/source/net/filebot/subtitle/SubtitleUtilities.java +++ b/source/net/filebot/subtitle/SubtitleUtilities.java @@ -1,6 +1,5 @@ package net.filebot.subtitle; -import static java.lang.Math.*; import static java.util.Collections.*; import static java.util.stream.Collectors.*; import static net.filebot.Logging.*; @@ -359,7 +358,7 @@ public final class SubtitleUtilities { try (SubRipWriter out = new SubRipWriter(buffer)) { for (SubtitleElement it : decodeSubtitles(data)) { if (outputTimingOffset != 0) { - it = new SubtitleElement(max(0, it.getStart() + outputTimingOffset), max(0, it.getEnd() + outputTimingOffset), it.getText()); + it = new SubtitleElement(Math.max(0, it.getStart() + outputTimingOffset), Math.max(0, it.getEnd() + outputTimingOffset), it.getText()); } out.write(it); } diff --git a/source/net/filebot/ui/episodelist/SeasonSpinnerModel.java b/source/net/filebot/ui/episodelist/SeasonSpinnerModel.java index c869177d..19c79d84 100644 --- a/source/net/filebot/ui/episodelist/SeasonSpinnerModel.java +++ b/source/net/filebot/ui/episodelist/SeasonSpinnerModel.java @@ -1,6 +1,5 @@ package net.filebot.ui.episodelist; -import static java.lang.Math.*; import static java.util.Collections.*; import java.util.List; @@ -35,7 +34,7 @@ class SeasonSpinnerModel extends SpinnerListModel { } public void spin(int steps) { - for (int i = 0; i < abs(steps); i++) { + for (int i = 0; i < Math.abs(steps); i++) { setValue(i < 0 ? getPreviousValue() : getNextValue()); } } diff --git a/source/net/filebot/ui/list/IndexedBindingBean.java b/source/net/filebot/ui/list/IndexedBindingBean.java index 3e7976e4..dc1d8b42 100644 --- a/source/net/filebot/ui/list/IndexedBindingBean.java +++ b/source/net/filebot/ui/list/IndexedBindingBean.java @@ -1,7 +1,5 @@ package net.filebot.ui.list; -import static net.filebot.util.FileUtilities.*; - import java.io.File; import java.util.List; import java.util.Map; diff --git a/source/net/filebot/ui/sfv/ChecksumButton.java b/source/net/filebot/ui/sfv/ChecksumButton.java index 47a78f5e..689b6ae8 100644 --- a/source/net/filebot/ui/sfv/ChecksumButton.java +++ b/source/net/filebot/ui/sfv/ChecksumButton.java @@ -1,12 +1,10 @@ package net.filebot.ui.sfv; - import static java.awt.Color.*; import static java.awt.Cursor.*; import static java.awt.Font.*; import static java.awt.RenderingHints.*; -import static java.lang.Math.*; import java.awt.Dimension; import java.awt.Font; @@ -20,17 +18,15 @@ import javax.swing.JToggleButton; import net.filebot.ResourceManager; - public class ChecksumButton extends JToggleButton { private static final Icon contentArea = ResourceManager.getIcon("button.checksum"); private static final Icon contentAreaSelected = ResourceManager.getIcon("button.checksum.selected"); - public ChecksumButton(Action action) { super(action); - setPreferredSize(new Dimension(max(contentAreaSelected.getIconWidth(), contentArea.getIconWidth()), max(contentAreaSelected.getIconHeight(), contentArea.getIconHeight()))); + setPreferredSize(new Dimension(Math.max(contentAreaSelected.getIconWidth(), contentArea.getIconWidth()), Math.max(contentAreaSelected.getIconHeight(), contentArea.getIconHeight()))); setMinimumSize(getPreferredSize()); setMaximumSize(getPreferredSize()); @@ -45,7 +41,6 @@ public class ChecksumButton extends JToggleButton { setEnabled(true); } - @Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); @@ -54,7 +49,6 @@ public class ChecksumButton extends JToggleButton { setCursor(getPredefinedCursor(enabled ? HAND_CURSOR : DEFAULT_CURSOR)); } - @Override protected void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; @@ -64,14 +58,14 @@ public class ChecksumButton extends JToggleButton { // paint background image in the center if (isSelected()) { - contentAreaSelected.paintIcon(this, g2d, (int) round((getWidth() - contentAreaSelected.getIconWidth()) / (double) 2), (int) round((getHeight() - contentAreaSelected.getIconHeight()) / (double) 2)); + contentAreaSelected.paintIcon(this, g2d, (int) Math.round((getWidth() - contentAreaSelected.getIconWidth()) / (double) 2), (int) Math.round((getHeight() - contentAreaSelected.getIconHeight()) / (double) 2)); } else { - contentArea.paintIcon(this, g2d, (int) round((getWidth() - contentArea.getIconWidth()) / (double) 2), (int) round((getHeight() - contentArea.getIconHeight()) / (double) 2)); + contentArea.paintIcon(this, g2d, (int) Math.round((getWidth() - contentArea.getIconWidth()) / (double) 2), (int) Math.round((getHeight() - contentArea.getIconHeight()) / (double) 2)); } Rectangle2D textBounds = g2d.getFontMetrics().getStringBounds(getText(), g2d); // draw text in the center - g2d.drawString(getText(), round((getWidth() - textBounds.getWidth()) / 2) + 1, round(getHeight() / 2 - textBounds.getY() - textBounds.getHeight() / 2)); + g2d.drawString(getText(), Math.round((getWidth() - textBounds.getWidth()) / 2) + 1, Math.round(getHeight() / 2 - textBounds.getY() - textBounds.getHeight() / 2)); } } diff --git a/source/net/filebot/ui/sfv/ChecksumComputationService.java b/source/net/filebot/ui/sfv/ChecksumComputationService.java index 108287d1..86211c51 100644 --- a/source/net/filebot/ui/sfv/ChecksumComputationService.java +++ b/source/net/filebot/ui/sfv/ChecksumComputationService.java @@ -1,7 +1,5 @@ package net.filebot.ui.sfv; -import static java.lang.Math.*; - import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.util.HashSet; @@ -103,7 +101,7 @@ class ChecksumComputationService { // for a few files, use one thread // for lots of files, use multiple threads // e.g 50 files ~ 1 thread, 200 files ~ 2 threads, 1000 files ~ 3 threads, 40000 files ~ 5 threads - return (int) max(1, round(sqrt(threadPoolSize) + log10(getQueue().size()) - 1)); + return (int) Math.max(1, Math.round(Math.sqrt(threadPoolSize) + Math.log10(getQueue().size()) - 1)); } @Override diff --git a/source/net/filebot/ui/sfv/SfvPanel.java b/source/net/filebot/ui/sfv/SfvPanel.java index c65bf499..4ea615d3 100644 --- a/source/net/filebot/ui/sfv/SfvPanel.java +++ b/source/net/filebot/ui/sfv/SfvPanel.java @@ -1,6 +1,5 @@ package net.filebot.ui.sfv; -import static java.lang.Math.*; import static net.filebot.ui.sfv.ChecksumTableModel.*; import static net.filebot.ui.transfer.BackgroundFileTransferablePolicy.*; import static net.filebot.util.FileUtilities.*; @@ -184,7 +183,7 @@ public class SfvPanel extends JComponent { computationService.purge(); // auto select next row - selectedRow = min(selectedRow, table.getRowCount() - 1); + selectedRow = Math.min(selectedRow, table.getRowCount() - 1); table.getSelectionModel().setSelectionInterval(selectedRow, selectedRow); } diff --git a/source/net/filebot/util/ui/ListView.java b/source/net/filebot/util/ui/ListView.java index 69ae0ea1..cbd822eb 100644 --- a/source/net/filebot/util/ui/ListView.java +++ b/source/net/filebot/util/ui/ListView.java @@ -1,9 +1,6 @@ package net.filebot.util.ui; - -import static java.lang.Math.*; - import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; @@ -23,12 +20,10 @@ import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; import javax.swing.event.MouseInputAdapter; - public class ListView extends JList { protected final BlockSelectionHandler blockSelectionHandler = new BlockSelectionHandler(); - public ListView(ListModel dataModel) { super(dataModel); setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); @@ -45,7 +40,6 @@ public class ListView extends JList { addMouseMotionListener(blockSelectionHandler); } - public void addSelectionInterval(Rectangle selection) { Point p1 = selection.getLocation(); Point p2 = new Point(p1.x + selection.width, p1.y + selection.height); @@ -62,7 +56,6 @@ public class ListView extends JList { } } - @Override public void paintComponent(Graphics g) { super.paintComponent(g); @@ -75,7 +68,6 @@ public class ListView extends JList { } } - protected void paintBlockSelection(Graphics2D g2d, Rectangle selection) { g2d.setPaint(SwingUI.derive(getSelectionBackground(), 0.3f)); g2d.fill(selection); @@ -84,24 +76,20 @@ public class ListView extends JList { g2d.draw(selection); } - protected String convertValueToText(Object value) { return value.toString(); } - protected Icon convertValueToIcon(Object value) { return null; } - protected class ListViewRenderer extends DefaultListCellRenderer { public ListViewRenderer() { setOpaque(false); } - @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Icon icon = convertValueToIcon(value); @@ -125,7 +113,6 @@ public class ListView extends JList { return this; } - @Override protected void paintComponent(Graphics g) { // paint selection background for the text area only, not the whole cell @@ -140,14 +127,12 @@ public class ListView extends JList { } }; - protected class BlockSelectionHandler extends MouseInputAdapter { private Rectangle selection; private Point origin; - @Override public void mousePressed(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && !isSelectedIndex(locationToIndex(e.getPoint()))) { @@ -155,7 +140,6 @@ public class ListView extends JList { } } - @Override public void mouseDragged(MouseEvent e) { if (origin == null) @@ -167,8 +151,8 @@ public class ListView extends JList { // keep point within component bounds Point p2 = e.getPoint(); - p2.x = max(0, min(getWidth() - 1, p2.x)); - p2.y = max(0, min(getHeight() - 1, p2.y)); + p2.x = Math.max(0, Math.min(getWidth() - 1, p2.x)); + p2.y = Math.max(0, Math.min(getHeight() - 1, p2.y)); // update selection bounds selection.setFrameFromDiagonal(origin, p2); @@ -184,7 +168,6 @@ public class ListView extends JList { repaint(); } - @Override public void mouseReleased(MouseEvent e) { origin = null; @@ -196,7 +179,6 @@ public class ListView extends JList { repaint(); } - public Rectangle getSelection() { return selection; }