Skip to content

Commit

Permalink
Styling fixes
Browse files Browse the repository at this point in the history
final public -> public final
Fix trailing newlines
  • Loading branch information
Gaming32 committed Feb 13, 2022
1 parent 804ee4d commit eab0111
Show file tree
Hide file tree
Showing 253 changed files with 2,782 additions and 2,729 deletions.
53 changes: 53 additions & 0 deletions add_trailing_newlines.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import os

# linesep = os.linesep.encode('ascii')
linesep = b'\n'


def dir_parts(dir: str) -> tuple[str]:
return tuple(os.path.normpath(dir).split(os.sep))


def is_in_dir(dir: str, in_: tuple[str]) -> bool:
return tuple(dir.split(os.sep, len(in_)))[:len(in_)] == in_


def is_in_dirs(dir: str, in_: tuple[tuple[str]]) -> bool:
return any(is_in_dir(dir, i) for i in in_)


def add_trailing_newlines(path: str) -> bool:
with open(path, 'r+b') as fp:
fp.seek(-len(linesep), 2)
if fp.read(len(linesep)) != linesep:
fp.write(linesep)
return True
return False


skip_parts = (
'.git',
'bin',
'dist',
'cache',
'__pycache__',
'lib',
'sorting_networks',
'src/main/resources',
'wrapper'
)
skip_parts = tuple(dir_parts(d) for d in skip_parts)

for (dir, dirs, files) in os.walk('.'):
if dir == '.':
dir = ''
else:
dir = os.path.normpath(dir)
if is_in_dirs(dir, skip_parts):
continue
for file in files:
file = os.path.join(dir, file)
if add_trailing_newlines(file):
print('Wrote ', file)
else:
print('Skipped', file)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.arrayv.dialogs;

final public class ImportShuffleDialog extends FileDialog {
public final class ImportShuffleDialog extends FileDialog {
public ImportShuffleDialog() {
super();

Expand All @@ -9,4 +9,4 @@ public ImportShuffleDialog() {
fileDialog.showOpenDialog(null);
this.file = fileDialog.getSelectedFile();
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/io/github/arrayv/frames/ArrayFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,4 @@ public void mouseExited(MouseEvent e) {
private javax.swing.JSlider jSlider1;
private javax.swing.JSlider jSlider2;
// End of variables declaration//GEN-END:variables
}
}
2 changes: 1 addition & 1 deletion src/main/java/io/github/arrayv/frames/ImageFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ public void updatePreview(CustomImage visual) {
this.lblNewLabel_2.setIcon(imageIcon);
this.lblNewLabel_2.setText("");
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/io/github/arrayv/frames/SoundFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,4 @@ public void actionPerformed(ActionEvent e) {
gbc_btnNewButton_2.gridy = 6;
contentPane.add(btnNewButton_2, gbc_btnNewButton_2);
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/io/github/arrayv/frames/UtilFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -586,4 +586,4 @@ private void jComboBox1ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerfor
private javax.swing.JCheckBox jCheckBox9;
@SuppressWarnings("rawtypes")
private javax.swing.JComboBox jComboBox1;
}
}
2 changes: 1 addition & 1 deletion src/main/java/io/github/arrayv/prompts/SortPrompt.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ of this software and associated documentation files (the "Software"), to deal
*
*/

final public class SortPrompt extends javax.swing.JFrame implements AppFrame {
public final class SortPrompt extends javax.swing.JFrame implements AppFrame {
public class PlaceholderTextField extends JTextField {
/**
* Shamelessly copied from https://stackoverflow.com/a/16229082/8840278
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/arrayv/prompts/ViewPrompt.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,4 @@ private void disparityChordsActionPerformed(java.awt.event.ActionEvent evt) {
private javax.swing.JButton disparityBarGraph;
private javax.swing.JButton disparityChords;
private javax.swing.JLabel jLabel1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.Comparator;

final public class SortComparator implements Comparator<SortInfo> {
public final class SortComparator implements Comparator<SortInfo> {
public SortComparator() {}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/arrayv/visuals/Visual.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ public static void drawFancyFinishLine(int logOfLen, int index, int position, Gr
}

public abstract void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights);
}
}
2 changes: 1 addition & 1 deletion src/main/java/io/github/arrayv/visuals/VisualStyles.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ public VisualStyles getCurrentVisual() {
}

public abstract void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights);
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/github/arrayv/visuals/bars/BarGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import utils.Highlights;
import utils.Renderer;

final public class BarGraph extends Visual {
public final class BarGraph extends Visual {

public BarGraph(ArrayVisualizer ArrayVisualizer) {
super(ArrayVisualizer);
Expand Down Expand Up @@ -57,4 +57,4 @@ else if (ArrayVisualizer.colorEnabled()) {
this.mainRender.fillRect(0, Renderer.getYOffset() + Renderer.getViewSize() - 20, ArrayVisualizer.currentWidth(), 1);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import utils.Highlights;
import utils.Renderer;

final public class DisparityBarGraph extends Visual {
public final class DisparityBarGraph extends Visual {

public DisparityBarGraph(ArrayVisualizer ArrayVisualizer) {
super(ArrayVisualizer);
Expand Down Expand Up @@ -51,4 +51,4 @@ else if (ArrayVisualizer.colorEnabled())
this.mainRender.fillRect(0, Renderer.getYOffset() + Renderer.getViewSize() - 20, ArrayVisualizer.currentWidth(), 1);
}
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/github/arrayv/visuals/bars/Rainbow.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ of this software and associated documentation files (the "Software"), to deal
*
*/

final public class Rainbow extends Visual {
public final class Rainbow extends Visual {
public Rainbow(ArrayVisualizer ArrayVisualizer) {
super(ArrayVisualizer);
}
Expand Down Expand Up @@ -69,4 +69,4 @@ public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Re
this.mainRender.fillRect(0, Renderer.getYOffset() + Renderer.getViewSize() - 20, ArrayVisualizer.currentWidth(), 1);
}
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/github/arrayv/visuals/bars/SineWave.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ of this software and associated documentation files (the "Software"), to deal
*
*/

final public class SineWave extends Visual {
public final class SineWave extends Visual {

public SineWave(ArrayVisualizer ArrayVisualizer) {
super(ArrayVisualizer);
Expand Down Expand Up @@ -74,4 +74,4 @@ else if (ArrayVisualizer.colorEnabled())
this.mainRender.fillRect(0, Renderer.getYOffset() + Renderer.getViewSize() - 20, ArrayVisualizer.currentWidth(), 1);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ of this software and associated documentation files (the "Software"), to deal
*
*/

final public class ColorCircle extends Visual {
public final class ColorCircle extends Visual {

public ColorCircle(ArrayVisualizer ArrayVisualizer) {
super(ArrayVisualizer);
Expand Down Expand Up @@ -99,4 +99,4 @@ public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Re
if (x[1] != x[2] || y[1] != y[2]) this.mainRender.fillPolygon(x, y, 3);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ of this software and associated documentation files (the "Software"), to deal
*
*/

final public class DisparityChords extends Visual {
public final class DisparityChords extends Visual {

public DisparityChords(ArrayVisualizer ArrayVisualizer) {
super(ArrayVisualizer);
Expand Down Expand Up @@ -87,4 +87,4 @@ public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Re
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ of this software and associated documentation files (the "Software"), to deal
*
*/

final public class DisparityCircle extends Visual {
public final class DisparityCircle extends Visual {

public DisparityCircle(ArrayVisualizer ArrayVisualizer) {
super(ArrayVisualizer);
Expand Down Expand Up @@ -82,4 +82,4 @@ else if (ArrayVisualizer.colorEnabled())
}
this.extraRender.setStroke(ArrayVisualizer.getDefaultStroke());
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/github/arrayv/visuals/circles/Spiral.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ of this software and associated documentation files (the "Software"), to deal
*
*/

final public class Spiral extends Visual {
public final class Spiral extends Visual {

public Spiral(ArrayVisualizer ArrayVisualizer) {
super(ArrayVisualizer);
Expand Down Expand Up @@ -88,4 +88,4 @@ else if (ArrayVisualizer.colorEnabled())
}
this.extraRender.setStroke(ArrayVisualizer.getDefaultStroke());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ of this software and associated documentation files (the "Software"), to deal
*
*/

final public class DisparityDots extends Visual {
public final class DisparityDots extends Visual {

public DisparityDots(ArrayVisualizer ArrayVisualizer) {
super(ArrayVisualizer);
Expand Down Expand Up @@ -111,4 +111,4 @@ else if (ArrayVisualizer.colorEnabled())
}
}
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/github/arrayv/visuals/dots/ScatterPlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ of this software and associated documentation files (the "Software"), to deal
*
*/

final public class ScatterPlot extends Visual {
public final class ScatterPlot extends Visual {
public ScatterPlot(ArrayVisualizer ArrayVisualizer) {
super(ArrayVisualizer);
}
Expand Down Expand Up @@ -112,4 +112,4 @@ else if (ArrayVisualizer.colorEnabled()) {
this.mainRender.fillRect(0, Renderer.getYOffset() + Renderer.getViewSize() - 20, ArrayVisualizer.currentWidth(), 1);
}
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/github/arrayv/visuals/dots/SpiralDots.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ of this software and associated documentation files (the "Software"), to deal
*
*/

final public class SpiralDots extends Visual {
public final class SpiralDots extends Visual {

public SpiralDots(ArrayVisualizer ArrayVisualizer) {
super(ArrayVisualizer);
Expand Down Expand Up @@ -111,4 +111,4 @@ else if (ArrayVisualizer.colorEnabled())
}
}
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/github/arrayv/visuals/dots/WaveDots.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ of this software and associated documentation files (the "Software"), to deal
*
*/

final public class WaveDots extends Visual {
public final class WaveDots extends Visual {
public WaveDots(ArrayVisualizer ArrayVisualizer) {
super(ArrayVisualizer);
}
Expand Down Expand Up @@ -109,4 +109,4 @@ else if (ArrayVisualizer.colorEnabled())
this.mainRender.fillRect(0, Renderer.getYOffset() + Renderer.getViewSize() - 20, ArrayVisualizer.currentWidth(), 1);
}
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/github/arrayv/visuals/misc/HoopStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ of this software and associated documentation files (the "Software"), to deal
*
*/

final public class HoopStack extends Visual {
public final class HoopStack extends Visual {
public HoopStack(ArrayVisualizer ArrayVisualizer) {
super(ArrayVisualizer);
}
Expand Down Expand Up @@ -76,4 +76,4 @@ else if (Highlights.containsPosition(i)) {
}
this.mainRender.setStroke(ArrayVisualizer.getDefaultStroke());
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/github/arrayv/visuals/misc/PixelMesh.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ of this software and associated documentation files (the "Software"), to deal
*
*/

final public class PixelMesh extends Visual {
public final class PixelMesh extends Visual {
public PixelMesh(ArrayVisualizer ArrayVisualizer) {
super(ArrayVisualizer);
}
Expand Down Expand Up @@ -76,4 +76,4 @@ else if (Highlights.containsPosition(idx)) {
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/main/ArrayManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,4 @@ public void refreshArray(int[] array, int currentLen, ArrayVisualizer ArrayVisua

ArrayVisualizer.resetAllStatistics();
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/panes/JEnhancedOptionPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// Many thanks to Freek de Bruijn on StackOverflow for providing a custom JOptionPane.
// https://stackoverflow.com/questions/14407804/how-to-change-the-default-text-of-buttons-in-joptionpane-showinputdialog?noredirect=1&lq=1
final public class JEnhancedOptionPane extends JOptionPane {
public final class JEnhancedOptionPane extends JOptionPane {
/**
*
*/
Expand All @@ -27,4 +27,4 @@ public static String showInputDialog(final String title, final Object message, f
final Object value = pane.getInputValue();
return (value == UNINITIALIZED_VALUE) ? null : (String) value;
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/panes/JErrorPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import javax.swing.JOptionPane;
import javax.swing.JTextArea;

final public class JErrorPane extends JOptionPane {
public final class JErrorPane extends JOptionPane {
/**
*
*/
Expand Down Expand Up @@ -45,4 +45,4 @@ public static void invokeCustomErrorMessage(String errorMsg) {
JOptionPane.showMessageDialog(null, errorMsg, "Error", JOptionPane.ERROR_MESSAGE);
errorMessageActive = false;
}
}
}
Loading

0 comments on commit eab0111

Please sign in to comment.