diff --git a/.github/workflows/checkstyle.yml b/.github/workflows/checkstyle.yml
new file mode 100644
index 00000000..c8027638
--- /dev/null
+++ b/.github/workflows/checkstyle.yml
@@ -0,0 +1,15 @@
+name: checkstyle
+on: [pull_request, push, workflow_dispatch]
+
+jobs:
+ checkstyle:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up JDK 8
+ uses: actions/setup-java@v2.1.0
+ with:
+ java-version: 8
+ distribution: zulu
+ - name: Run checkstyle with Maven
+ run: mvn -Dcheckstyle.violationSeverity=warning checkstyle:check
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 00000000..d90744e5
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,6 @@
+{
+ "recommendations": [
+ "vscjava.vscode-java-pack",
+ "shengchen.vscode-checkstyle"
+ ]
+}
\ No newline at end of file
diff --git a/.vscode/java-formatter.xml b/.vscode/java-formatter.xml
new file mode 100644
index 00000000..a957a9aa
--- /dev/null
+++ b/.vscode/java-formatter.xml
@@ -0,0 +1,382 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.vscode/settings.json b/.vscode/settings.json
index c5f3f6b9..1a5d3835 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,3 +1,5 @@
{
- "java.configuration.updateBuildConfiguration": "interactive"
-}
\ No newline at end of file
+ "java.configuration.updateBuildConfiguration": "interactive",
+ "java.checkstyle.configuration": "${workspaceFolder}\\checkstyle.xml",
+ "java.checkstyle.version": "9.3"
+}
diff --git a/README.md b/README.md
index 4a6c71bd..c7c6e1e7 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
# ArrayV
-

-
+
+
Over 200 sorting algorithms animated with 15 unique graphic designs
diff --git a/checkstyle.xml b/checkstyle.xml
new file mode 100644
index 00000000..1ffa516c
--- /dev/null
+++ b/checkstyle.xml
@@ -0,0 +1,137 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
index 2135596b..481ffc45 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,7 +90,7 @@
attach-sources
- jar
+ jar-no-fork
@@ -108,8 +108,38 @@
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ 3.1.2
+
+ checkstyle.xml
+ true
+ true
+
+
+
+ validate
+ validate
+
+ check
+
+
+ warning
+ false
+
+
+
+
+
+ com.puppycrawl.tools
+ checkstyle
+ 9.3
+
+
+
-
+
maven-clean-plugin
diff --git a/src/main/java/io/github/arrayv/dialogs/ShuffleDialog.java b/src/main/java/io/github/arrayv/dialogs/ShuffleDialog.java
index e4e6d2fe..baf02ff3 100644
--- a/src/main/java/io/github/arrayv/dialogs/ShuffleDialog.java
+++ b/src/main/java/io/github/arrayv/dialogs/ShuffleDialog.java
@@ -58,7 +58,7 @@ of this software and associated documentation files (the "Software"), to deal
public final class ShuffleDialog extends javax.swing.JDialog implements AppFrame {
private static final long serialVersionUID = 1L;
- private ArrayManager ArrayManager;
+ private ArrayManager arrayManager;
private List distributions;
private static boolean perShuffleDelay = false;
@@ -68,24 +68,24 @@ public final class ShuffleDialog extends javax.swing.JDialog implements AppFrame
* Creates new form SortPrompt
*/
@SuppressWarnings("unchecked")
- public ShuffleDialog(ArrayManager ArrayManager, JFrame frame) {
+ public ShuffleDialog(ArrayManager arrayManager, JFrame frame) {
super(frame, "ArrayV Advanced Shuffle Editor", true);
- this.ArrayManager = ArrayManager;
+ this.arrayManager = arrayManager;
initComponents();
bypassEvents = true;
- this.shuffleEditor.graph = ArrayManager.getShuffle();
- jList4.setListData(ArrayManager.getDistributionIDs());
- for (int i = 0; i < ArrayManager.getDistributions().length; i++) {
- if (ArrayManager.getDistribution().equals(ArrayManager.getDistributions()[i])) {
+ this.shuffleEditor.setShuffle(arrayManager.getShuffle());
+ jList4.setListData(arrayManager.getDistributionIDs());
+ for (int i = 0; i < arrayManager.getDistributions().length; i++) {
+ if (arrayManager.getDistribution().equals(arrayManager.getDistributions()[i])) {
jList4.setSelectedIndex(i);
break;
}
}
- distributions = Arrays.stream(ArrayManager.getDistributions())
+ distributions = Arrays.stream(arrayManager.getDistributions())
.filter(dist -> dist.getName() != "Custom")
.collect(Collectors.toList());
Object[] distributionNames = distributions.stream()
@@ -95,12 +95,12 @@ public ShuffleDialog(ArrayManager ArrayManager, JFrame frame) {
jList1.setListData(distributionNames);
jList3.setListData(distributionNames);
- jList2.setListData(ArrayManager.getShuffleIDs());
+ jList2.setListData(arrayManager.getShuffleIDs());
jTextField1.setText(Double.toString(
perShuffleDelay ?
- shuffleEditor.graph.sleepRatio / shuffleEditor.graph.size() :
- shuffleEditor.graph.sleepRatio
+ shuffleEditor.getShuffle().getSleepRatio() / shuffleEditor.getShuffle().size() :
+ shuffleEditor.getShuffle().getSleepRatio()
));
jCheckBox1.setSelected(perShuffleDelay);
bypassEvents = false;
@@ -109,7 +109,7 @@ public ShuffleDialog(ArrayManager ArrayManager, JFrame frame) {
@Override
public void windowClosed(WindowEvent e) {
if (perShuffleDelay = jCheckBox1.isSelected()) {
- shuffleEditor.graph.sleepRatio *= shuffleEditor.graph.size();
+ shuffleEditor.getShuffle().setSleepRatio(shuffleEditor.getShuffle().getSleepRatio() * shuffleEditor.getShuffle().size());
}
}
});
@@ -355,38 +355,38 @@ private void jButton1ActionPerformed() {//GEN-FIRST:event_jButton1ActionPerforme
JErrorPane.invokeCustomErrorMessage("Error Parsing File: " + e.getMessage());
return;
}
- ArrayManager.setShuffle(newShuffle);
+ arrayManager.setShuffle(newShuffle);
if (jCheckBox1.isSelected()) {
- shuffleEditor.graph.sleepRatio /= shuffleEditor.graph.size();
+ shuffleEditor.getShuffle().setSleepRatio(shuffleEditor.getShuffle().getSleepRatio() / shuffleEditor.getShuffle().size());
}
jTextField1.setForeground(Color.BLACK);
- jTextField1.setText(Double.toString(newShuffle.sleepRatio));
- this.shuffleEditor.graph = newShuffle;
+ jTextField1.setText(Double.toString(newShuffle.getSleepRatio()));
+ this.shuffleEditor.setShuffle(newShuffle);
this.shuffleEditor.repaint();
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed() {//GEN-FIRST:event_jButton1ActionPerformed
FileDialog fileDialog = new ExportShuffleDialog();
- double oldSleepRatio = shuffleEditor.graph.sleepRatio;
+ double oldSleepRatio = shuffleEditor.getShuffle().getSleepRatio();
if (jCheckBox1.isSelected()) {
- shuffleEditor.graph.sleepRatio *= shuffleEditor.graph.size();
+ shuffleEditor.getShuffle().setSleepRatio(shuffleEditor.getShuffle().getSleepRatio() * shuffleEditor.getShuffle().size());
}
try {
- new GraphWriter(shuffleEditor.graph).write(fileDialog.file);
+ new GraphWriter(shuffleEditor.getShuffle()).write(fileDialog.file);
} catch (IOException e) {
- shuffleEditor.graph.sleepRatio = oldSleepRatio;
+ shuffleEditor.getShuffle().setSleepRatio(oldSleepRatio);
e.printStackTrace();
JErrorPane.invokeCustomErrorMessage("IO Error: " + e.getMessage());
return;
}
- shuffleEditor.graph.sleepRatio = oldSleepRatio;
+ shuffleEditor.getShuffle().setSleepRatio(oldSleepRatio);
JOptionPane.showMessageDialog(null,
"Successfully exported current shuffle to file \"" + fileDialog.file.getAbsolutePath() + "\"",
"Advanced Shuffle Editor", JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton3ActionPerformed() {//GEN-FIRST:event_jButton1ActionPerformed
- shuffleEditor.graph.removeAllDisconnected();
+ shuffleEditor.getShuffle().removeAllDisconnected();
shuffleEditor.repaint();
}//GEN-LAST:event_jButton1ActionPerformed
@@ -401,21 +401,21 @@ private void jTextField1TextChanged(DocumentEvent e) {//GEN-FIRST:event_jList1Va
return;
}
jTextField1.setForeground(Color.BLACK);
- shuffleEditor.graph.sleepRatio = sleepRatio;
+ shuffleEditor.getShuffle().setSleepRatio(sleepRatio);
}//GEN-LAST:event_jList1ValueChanged
private void addToGraph(ShuffleInfo shuffle) {
- Point safePos = shuffleEditor.graph.findSafeCoordinates(100, 100, 20, 20);
- shuffleEditor.graph.addDisconnected(shuffle, safePos.x, safePos.y);
+ Point safePos = shuffleEditor.getShuffle().findSafeCoordinates(100, 100, 20, 20);
+ shuffleEditor.getShuffle().addDisconnected(shuffle, safePos.x, safePos.y);
}
private void jList4ValueChanged(javax.swing.event.ListSelectionEvent evt) throws Exception {//GEN-FIRST:event_jList1ValueChanged
if (bypassEvents)
return;
int selection = jList4.getSelectedIndex();
- Distributions[] distributions = ArrayManager.getDistributions();
+ Distributions[] distributions = arrayManager.getDistributions();
if (selection >= 0 && selection < distributions.length)
- ArrayManager.setDistribution(distributions[selection]);
+ arrayManager.setDistribution(distributions[selection]);
}//GEN-LAST:event_jList1ValueChanged
private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) throws Exception {//GEN-FIRST:event_jList1ValueChanged
@@ -454,7 +454,7 @@ private void jList2ValueChanged(javax.swing.event.ListSelectionEvent evt) throws
if (bypassEvents)
return;
int selection = jList2.getSelectedIndex();
- Shuffles[] shuffles = ArrayManager.getShuffles();
+ Shuffles[] shuffles = arrayManager.getShuffles();
if (selection >= 0 && selection < shuffles.length)
addToGraph(new ShuffleInfo(shuffles[selection]));
shuffleEditor.repaint();
diff --git a/src/main/java/io/github/arrayv/frames/AppFrame.java b/src/main/java/io/github/arrayv/frames/AppFrame.java
index 5da65c1e..b0b4b519 100644
--- a/src/main/java/io/github/arrayv/frames/AppFrame.java
+++ b/src/main/java/io/github/arrayv/frames/AppFrame.java
@@ -29,7 +29,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public interface AppFrame {
- abstract void reposition();
- abstract boolean isVisible();
- abstract void dispose();
+ void reposition();
+ boolean isVisible();
+ void dispose();
}
diff --git a/src/main/java/io/github/arrayv/frames/ArrayFrame.java b/src/main/java/io/github/arrayv/frames/ArrayFrame.java
index 23f4aba0..6d53ab27 100644
--- a/src/main/java/io/github/arrayv/frames/ArrayFrame.java
+++ b/src/main/java/io/github/arrayv/frames/ArrayFrame.java
@@ -47,7 +47,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class ArrayFrame extends javax.swing.JFrame {
- final private static long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
private int[] array;
@@ -55,8 +55,8 @@ public final class ArrayFrame extends javax.swing.JFrame {
private ArrayVisualizer arrayVisualizer;
private AppFrame abstractFrame;
private Highlights Highlights;
- private JFrame Frame;
- private UtilFrame UtilFrame;
+ private JFrame frame;
+ private UtilFrame utilFrame;
private boolean lockToPow2;
@@ -67,19 +67,19 @@ public ArrayFrame(int[] array, ArrayVisualizer arrayVisualizer) {
this.arrayManager = arrayVisualizer.getArrayManager();
this.Highlights = arrayVisualizer.getHighlights();
- this.Frame = arrayVisualizer.getMainWindow();
- this.UtilFrame = arrayVisualizer.getUtilFrame();
+ this.frame = arrayVisualizer.getMainWindow();
+ this.utilFrame = arrayVisualizer.getUtilFrame();
setUndecorated(true);
initComponents();
- setLocation(Math.min((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth(), Frame.getX() + Frame.getWidth()), Frame.getY() + 29);
+ setLocation(Math.min((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth(), frame.getX() + frame.getWidth()), frame.getY() + 29);
setAlwaysOnTop(false);
setVisible(true);
}
public void reposition(){
toFront();
- setLocation(Math.min((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth() - UtilFrame.getWidth(), Frame.getX() + Frame.getWidth()), Frame.getY() + 29);
+ setLocation(Math.min((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth() - utilFrame.getWidth(), frame.getX() + frame.getWidth()), frame.getY() + 29);
if (this.abstractFrame != null && abstractFrame.isVisible())
abstractFrame.reposition();
}
@@ -133,7 +133,7 @@ public void keyReleased(KeyEvent e) {
};
this.addKeyListener(kListener);
- int usePower = ArrayVisualizer.MAX_LENGTH_POWER * 100000;
+ int usePower = ArrayVisualizer.getMaxLengthPower() * 100000;
int useDefault = (int)Math.min(1100000, usePower);
this.jLabel1 = new javax.swing.JLabel();
this.jLabel2 = new javax.swing.JLabel();
@@ -280,36 +280,36 @@ public void mouseExited(MouseEvent e) {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER, true)
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER, true)
.addGroup(layout.createSequentialGroup()
- .addContainerGap()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, true)
+ .addComponent(this.jLabel1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, true)
- .addComponent(this.jLabel1)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, true)
- .addComponent(this.jSlider1)
- .addGap(0, 10, Short.MAX_VALUE))))
+ .addComponent(this.jSlider1)
+ .addGap(0, 10, Short.MAX_VALUE))))
.addGap(sliderGap, sliderGap, sliderGap)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, true)
- .addComponent(this.jLabel2)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, true)
- .addComponent(this.jSlider2)
- .addGap(0, 10, Short.MAX_VALUE))))
- );
+ .addComponent(this.jLabel2)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, true)
+ .addComponent(this.jSlider2)
+ .addGap(0, 10, Short.MAX_VALUE))))
+ );
layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, true)
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, true)
.addGroup(layout.createSequentialGroup()
.addGap(5, 5, 5)
.addComponent(this.jLabel1)
.addGap(5, 5, 5)
- .addComponent(this.jSlider1, UtilFrame.getHeight() - 26, UtilFrame.getHeight() - 26, UtilFrame.getHeight() - 26))
+ .addComponent(this.jSlider1, utilFrame.getHeight() - 26, utilFrame.getHeight() - 26, utilFrame.getHeight() - 26))
.addGroup(layout.createSequentialGroup()
.addGap(5, 5, 5)
.addComponent(this.jLabel2)
.addGap(5, 5, 5)
- .addComponent(this.jSlider2, UtilFrame.getHeight() - 26, UtilFrame.getHeight() - 26, UtilFrame.getHeight() - 26))
- );
+ .addComponent(this.jSlider2, utilFrame.getHeight() - 26, utilFrame.getHeight() - 26, utilFrame.getHeight() - 26))
+ );
pack();
}// //GEN-END:initComponents
diff --git a/src/main/java/io/github/arrayv/frames/ImageFrame.java b/src/main/java/io/github/arrayv/frames/ImageFrame.java
index 63aa6099..3a2348e3 100644
--- a/src/main/java/io/github/arrayv/frames/ImageFrame.java
+++ b/src/main/java/io/github/arrayv/frames/ImageFrame.java
@@ -44,8 +44,7 @@ of this software and associated documentation files (the "Software"), to deal
import io.github.arrayv.visuals.image.CustomImage;
public class ImageFrame extends JFrame {
-
- public static ImageFrame defaultFrame;
+ private static ImageFrame defaultFrame;
/**
*
@@ -53,7 +52,7 @@ public class ImageFrame extends JFrame {
private static final long serialVersionUID = 1L;
private volatile JPanel contentPane;
- private volatile JLabel lblNewLabel_2;
+ private volatile JLabel lblNewLabel2;
/**
* Create the frame.
@@ -65,38 +64,38 @@ public ImageFrame(CustomImage visual) {
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
- GridBagLayout gbl_contentPane = new GridBagLayout();
- gbl_contentPane.columnWidths = new int[]{0, 0, 0};
- gbl_contentPane.rowHeights = new int[]{0, 32, 0, 0, 0};
- gbl_contentPane.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
- gbl_contentPane.rowWeights = new double[]{0.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
- contentPane.setLayout(gbl_contentPane);
+ GridBagLayout gblContentPane = new GridBagLayout();
+ gblContentPane.columnWidths = new int[]{0, 0, 0};
+ gblContentPane.rowHeights = new int[]{0, 32, 0, 0, 0};
+ gblContentPane.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
+ gblContentPane.rowWeights = new double[]{0.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
+ contentPane.setLayout(gblContentPane);
JLabel lblNewLabel = new JLabel("Current image:");
- GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
- gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
- gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
- gbc_lblNewLabel.gridx = 0;
- gbc_lblNewLabel.gridy = 0;
- contentPane.add(lblNewLabel, gbc_lblNewLabel);
-
- JLabel lblNewLabel_1 = new JLabel(visual.getCurrentImageName());
- GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
- gbc_lblNewLabel_1.anchor = GridBagConstraints.WEST;
- gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 0);
- gbc_lblNewLabel_1.gridx = 1;
- gbc_lblNewLabel_1.gridy = 0;
- contentPane.add(lblNewLabel_1, gbc_lblNewLabel_1);
-
- this.lblNewLabel_2 = new JLabel(" ");
- lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);
- GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
- gbc_lblNewLabel_2.fill = GridBagConstraints.BOTH;
- gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 0);
- gbc_lblNewLabel_2.gridwidth = 2;
- gbc_lblNewLabel_2.gridx = 0;
- gbc_lblNewLabel_2.gridy = 1;
- contentPane.add(this.lblNewLabel_2, gbc_lblNewLabel_2);
+ GridBagConstraints gbcLblNewLabel = new GridBagConstraints();
+ gbcLblNewLabel.anchor = GridBagConstraints.EAST;
+ gbcLblNewLabel.insets = new Insets(0, 0, 5, 5);
+ gbcLblNewLabel.gridx = 0;
+ gbcLblNewLabel.gridy = 0;
+ contentPane.add(lblNewLabel, gbcLblNewLabel);
+
+ JLabel lblNewLabel1 = new JLabel(visual.getCurrentImageName());
+ GridBagConstraints gbcLblNewLabel1 = new GridBagConstraints();
+ gbcLblNewLabel1.anchor = GridBagConstraints.WEST;
+ gbcLblNewLabel1.insets = new Insets(0, 0, 5, 0);
+ gbcLblNewLabel1.gridx = 1;
+ gbcLblNewLabel1.gridy = 0;
+ contentPane.add(lblNewLabel1, gbcLblNewLabel1);
+
+ this.lblNewLabel2 = new JLabel(" ");
+ lblNewLabel2.setHorizontalAlignment(SwingConstants.CENTER);
+ GridBagConstraints gbcLblNewLabel2 = new GridBagConstraints();
+ gbcLblNewLabel2.fill = GridBagConstraints.BOTH;
+ gbcLblNewLabel2.insets = new Insets(0, 0, 5, 0);
+ gbcLblNewLabel2.gridwidth = 2;
+ gbcLblNewLabel2.gridx = 0;
+ gbcLblNewLabel2.gridy = 1;
+ contentPane.add(this.lblNewLabel2, gbcLblNewLabel2);
JButton btnNewButton = new JButton("Load default artwork");
btnNewButton.addActionListener(new ActionListener() {
@@ -105,37 +104,41 @@ public void actionPerformed(ActionEvent e) {
visual.loadDefaultArtwork(ImageFrame.this);
}
});
- GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
- gbc_btnNewButton.fill = GridBagConstraints.VERTICAL;
- gbc_btnNewButton.gridheight = 2;
- gbc_btnNewButton.anchor = GridBagConstraints.EAST;
- gbc_btnNewButton.insets = new Insets(0, 0, 5, 5);
- gbc_btnNewButton.gridx = 0;
- gbc_btnNewButton.gridy = 2;
- contentPane.add(btnNewButton, gbc_btnNewButton);
-
- JButton btnNewButton_1 = new JButton("Choose image...");
- btnNewButton_1.addActionListener(new ActionListener() {
+ GridBagConstraints gbcBtnNewButton = new GridBagConstraints();
+ gbcBtnNewButton.fill = GridBagConstraints.VERTICAL;
+ gbcBtnNewButton.gridheight = 2;
+ gbcBtnNewButton.anchor = GridBagConstraints.EAST;
+ gbcBtnNewButton.insets = new Insets(0, 0, 5, 5);
+ gbcBtnNewButton.gridx = 0;
+ gbcBtnNewButton.gridy = 2;
+ contentPane.add(btnNewButton, gbcBtnNewButton);
+
+ JButton btnNewButton1 = new JButton("Choose image...");
+ btnNewButton1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
visual.loadCustomImage(ImageFrame.this);
}
});
- GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints();
- gbc_btnNewButton_1.fill = GridBagConstraints.VERTICAL;
- gbc_btnNewButton_1.gridheight = 2;
- gbc_btnNewButton_1.insets = new Insets(0, 0, 5, 0);
- gbc_btnNewButton_1.anchor = GridBagConstraints.WEST;
- gbc_btnNewButton_1.gridx = 1;
- gbc_btnNewButton_1.gridy = 2;
- contentPane.add(btnNewButton_1, gbc_btnNewButton_1);
+ GridBagConstraints gbcBtnNewButton1 = new GridBagConstraints();
+ gbcBtnNewButton1.fill = GridBagConstraints.VERTICAL;
+ gbcBtnNewButton1.gridheight = 2;
+ gbcBtnNewButton1.insets = new Insets(0, 0, 5, 0);
+ gbcBtnNewButton1.anchor = GridBagConstraints.WEST;
+ gbcBtnNewButton1.gridx = 1;
+ gbcBtnNewButton1.gridy = 2;
+ contentPane.add(btnNewButton1, gbcBtnNewButton1);
}
public void updatePreview(CustomImage visual) {
BufferedImage img = visual.getImage();
- Image scaledImg = img.getScaledInstance((int) (this.lblNewLabel_2.getWidth() * 0.75), this.lblNewLabel_2.getHeight(), Image.SCALE_SMOOTH);
+ Image scaledImg = img.getScaledInstance((int) (this.lblNewLabel2.getWidth() * 0.75), this.lblNewLabel2.getHeight(), Image.SCALE_SMOOTH);
ImageIcon imageIcon = new ImageIcon(scaledImg);
- this.lblNewLabel_2.setIcon(imageIcon);
- this.lblNewLabel_2.setText("");
+ this.lblNewLabel2.setIcon(imageIcon);
+ this.lblNewLabel2.setText("");
+ }
+
+ public static ImageFrame getDefaultFrame() {
+ return defaultFrame;
}
}
diff --git a/src/main/java/io/github/arrayv/frames/SoundFrame.java b/src/main/java/io/github/arrayv/frames/SoundFrame.java
index c8429005..d928aca6 100644
--- a/src/main/java/io/github/arrayv/frames/SoundFrame.java
+++ b/src/main/java/io/github/arrayv/frames/SoundFrame.java
@@ -65,19 +65,19 @@ public SoundFrame(Sounds sounds) {
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
- GridBagLayout gbl_contentPane = new GridBagLayout();
- gbl_contentPane.columnWidths = new int[]{0, 0, 0};
- gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
- gbl_contentPane.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
- gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
- contentPane.setLayout(gbl_contentPane);
+ GridBagLayout gblContentPane = new GridBagLayout();
+ gblContentPane.columnWidths = new int[]{0, 0, 0};
+ gblContentPane.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
+ gblContentPane.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE};
+ gblContentPane.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
+ contentPane.setLayout(gblContentPane);
JLabel lblNewLabel = new JLabel("Current soundbank:");
- GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
- gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
- gbc_lblNewLabel.gridx = 0;
- gbc_lblNewLabel.gridy = 0;
- contentPane.add(lblNewLabel, gbc_lblNewLabel);
+ GridBagConstraints gbcLblNewLabel = new GridBagConstraints();
+ gbcLblNewLabel.insets = new Insets(0, 0, 5, 5);
+ gbcLblNewLabel.gridx = 0;
+ gbcLblNewLabel.gridy = 0;
+ contentPane.add(lblNewLabel, gbcLblNewLabel);
JButton btnNewButton = new JButton("Default sounds");
btnNewButton.addActionListener(new ActionListener() {
@@ -86,55 +86,55 @@ public void actionPerformed(ActionEvent e) {
sounds.selectDefaultSoundbank(SoundFrame.this);
}
});
- GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
- gbc_btnNewButton.insets = new Insets(0, 0, 5, 0);
- gbc_btnNewButton.gridx = 1;
- gbc_btnNewButton.gridy = 0;
- contentPane.add(btnNewButton, gbc_btnNewButton);
-
- JLabel lblNewLabel_1 = new JLabel(sounds.getSelectedSoundbank());
- GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
- gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
- gbc_lblNewLabel_1.gridx = 0;
- gbc_lblNewLabel_1.gridy = 1;
- contentPane.add(lblNewLabel_1, gbc_lblNewLabel_1);
-
- JButton btnNewButton_1 = new JButton("Choose soundbank...");
- btnNewButton_1.addActionListener(new ActionListener() {
+ GridBagConstraints gbcBtnNewButton = new GridBagConstraints();
+ gbcBtnNewButton.insets = new Insets(0, 0, 5, 0);
+ gbcBtnNewButton.gridx = 1;
+ gbcBtnNewButton.gridy = 0;
+ contentPane.add(btnNewButton, gbcBtnNewButton);
+
+ JLabel lblNewLabel1 = new JLabel(sounds.getSelectedSoundbank());
+ GridBagConstraints gbcLblNewLabel1 = new GridBagConstraints();
+ gbcLblNewLabel1.insets = new Insets(0, 0, 5, 5);
+ gbcLblNewLabel1.gridx = 0;
+ gbcLblNewLabel1.gridy = 1;
+ contentPane.add(lblNewLabel1, gbcLblNewLabel1);
+
+ JButton btnNewButton1 = new JButton("Choose soundbank...");
+ btnNewButton1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
sounds.selectCustomSoundbank(SoundFrame.this);
}
});
- GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints();
- gbc_btnNewButton_1.insets = new Insets(0, 0, 5, 0);
- gbc_btnNewButton_1.gridx = 1;
- gbc_btnNewButton_1.gridy = 1;
- contentPane.add(btnNewButton_1, gbc_btnNewButton_1);
+ GridBagConstraints gbcBtnNewButton1 = new GridBagConstraints();
+ gbcBtnNewButton1.insets = new Insets(0, 0, 5, 0);
+ gbcBtnNewButton1.gridx = 1;
+ gbcBtnNewButton1.gridy = 1;
+ contentPane.add(btnNewButton1, gbcBtnNewButton1);
JSeparator separator = new JSeparator();
- GridBagConstraints gbc_separator = new GridBagConstraints();
- gbc_separator.insets = new Insets(0, 0, 5, 5);
- gbc_separator.gridx = 0;
- gbc_separator.gridy = 2;
- contentPane.add(separator, gbc_separator);
-
- JLabel lblNewLabel_2 = new JLabel("Choose a sample / instrument:");
- GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
- gbc_lblNewLabel_2.anchor = GridBagConstraints.WEST;
- gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
- gbc_lblNewLabel_2.gridx = 0;
- gbc_lblNewLabel_2.gridy = 3;
- contentPane.add(lblNewLabel_2, gbc_lblNewLabel_2);
+ GridBagConstraints gbcSeparator = new GridBagConstraints();
+ gbcSeparator.insets = new Insets(0, 0, 5, 5);
+ gbcSeparator.gridx = 0;
+ gbcSeparator.gridy = 2;
+ contentPane.add(separator, gbcSeparator);
+
+ JLabel lblNewLabel2 = new JLabel("Choose a sample / instrument:");
+ GridBagConstraints gbcLblNewLabel2 = new GridBagConstraints();
+ gbcLblNewLabel2.anchor = GridBagConstraints.WEST;
+ gbcLblNewLabel2.insets = new Insets(0, 0, 5, 5);
+ gbcLblNewLabel2.gridx = 0;
+ gbcLblNewLabel2.gridy = 3;
+ contentPane.add(lblNewLabel2, gbcLblNewLabel2);
JScrollPane scrollPane = new JScrollPane();
- GridBagConstraints gbc_scrollPane = new GridBagConstraints();
- gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
- gbc_scrollPane.gridwidth = 2;
- gbc_scrollPane.fill = GridBagConstraints.BOTH;
- gbc_scrollPane.gridx = 0;
- gbc_scrollPane.gridy = 5;
- contentPane.add(scrollPane, gbc_scrollPane);
+ GridBagConstraints gbcScrollPane = new GridBagConstraints();
+ gbcScrollPane.insets = new Insets(0, 0, 5, 0);
+ gbcScrollPane.gridwidth = 2;
+ gbcScrollPane.fill = GridBagConstraints.BOTH;
+ gbcScrollPane.gridx = 0;
+ gbcScrollPane.gridy = 5;
+ contentPane.add(scrollPane, gbcScrollPane);
JList list = new JList();
scrollPane.setViewportView(list);
@@ -151,17 +151,17 @@ public void valueChanged(ListSelectionEvent e) {
}
});
- JButton btnNewButton_2 = new JButton("Select sound");
- btnNewButton_2.addActionListener(new ActionListener() {
+ JButton btnNewButton2 = new JButton("Select sound");
+ btnNewButton2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
sounds.setInstrumentChoice(SoundFrame.this.instrumentChoice);
}
});
- GridBagConstraints gbc_btnNewButton_2 = new GridBagConstraints();
- gbc_btnNewButton_2.anchor = GridBagConstraints.EAST;
- gbc_btnNewButton_2.gridx = 1;
- gbc_btnNewButton_2.gridy = 6;
- contentPane.add(btnNewButton_2, gbc_btnNewButton_2);
+ GridBagConstraints gbcBtnNewButton2 = new GridBagConstraints();
+ gbcBtnNewButton2.anchor = GridBagConstraints.EAST;
+ gbcBtnNewButton2.gridx = 1;
+ gbcBtnNewButton2.gridy = 6;
+ contentPane.add(btnNewButton2, gbcBtnNewButton2);
}
}
diff --git a/src/main/java/io/github/arrayv/frames/UtilFrame.java b/src/main/java/io/github/arrayv/frames/UtilFrame.java
index 7a6a3a1f..32e270a1 100644
--- a/src/main/java/io/github/arrayv/frames/UtilFrame.java
+++ b/src/main/java/io/github/arrayv/frames/UtilFrame.java
@@ -44,43 +44,43 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class UtilFrame extends javax.swing.JFrame {
- final private static long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
private boolean jCheckBox9WarningShown = true; //set to false to enable warning
private int[] array;
- private ArrayManager ArrayManager;
- private ArrayVisualizer ArrayVisualizer;
+ private ArrayManager arrayManager;
+ private ArrayVisualizer arrayVisualizer;
private Delays Delays;
private AppFrame abstractFrame;
private Highlights Highlights;
- private JFrame Frame;
- private Timer RealTimer;
+ private JFrame frame;
+ private Timer Timer;
private Sounds Sounds;
public UtilFrame(int[] array, ArrayVisualizer arrayVisualizer) {
this.array = array;
- this.ArrayVisualizer = arrayVisualizer;
- this.ArrayManager = ArrayVisualizer.getArrayManager();
+ this.arrayVisualizer = arrayVisualizer;
+ this.arrayManager = arrayVisualizer.getArrayManager();
- this.Delays = ArrayVisualizer.getDelays();
- this.Frame = ArrayVisualizer.getMainWindow();
- this.Highlights = ArrayVisualizer.getHighlights();
- this.RealTimer = ArrayVisualizer.getTimer();
- this.Sounds = ArrayVisualizer.getSounds();
+ this.Delays = arrayVisualizer.getDelays();
+ this.frame = arrayVisualizer.getMainWindow();
+ this.Highlights = arrayVisualizer.getHighlights();
+ this.Timer = arrayVisualizer.getTimer();
+ this.Sounds = arrayVisualizer.getSounds();
setUndecorated(true);
initComponents();
- setLocation(Math.min((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth(), Frame.getX() + Frame.getWidth()), Frame.getY() + 29);
+ setLocation(Math.min((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth(), frame.getX() + frame.getWidth()), frame.getY() + 29);
setAlwaysOnTop(false);
setVisible(true);
}
public void reposition(ArrayFrame af){
toFront();
- setLocation(Math.min((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth(), Frame.getX() + Frame.getWidth() + af.getWidth()), Frame.getY() + 29);
+ setLocation(Math.min((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth(), frame.getX() + frame.getWidth() + af.getWidth()), frame.getY() + 29);
if (this.abstractFrame != null && abstractFrame.isVisible())
abstractFrame.reposition();
}
@@ -262,79 +262,79 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1ActionPerformed();
}
});
- if (ArrayVisualizer.disabledStabilityCheck) {
+ if (arrayVisualizer.isDisabledStabilityCheck()) {
jComboBox1.removeItem("Stability Check");
}
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER, true)
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER, true)
.addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER, true)
- .addComponent(this.jLabel1)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, true)
- .addComponent(this.jCheckBox1)
- .addComponent(this.jCheckBox2)
- .addComponent(this.jCheckBox3)
- .addComponent(this.jCheckBox4)
- .addComponent(this.jCheckBox6)
- .addComponent(this.jCheckBox7)
- .addComponent(this.jCheckBox8)
- .addComponent(this.jCheckBox9)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, true)
- .addComponent(this.jCheckBox5)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
- .addComponent(this.jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(this.jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(this.jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(this.jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(this.jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(this.jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(this.jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(this.jComboBox1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
- .addGap(0, 10, Short.MAX_VALUE))
- );
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER, true)
+ .addComponent(this.jLabel1)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, true)
+ .addComponent(this.jCheckBox1)
+ .addComponent(this.jCheckBox2)
+ .addComponent(this.jCheckBox3)
+ .addComponent(this.jCheckBox4)
+ .addComponent(this.jCheckBox6)
+ .addComponent(this.jCheckBox7)
+ .addComponent(this.jCheckBox8)
+ .addComponent(this.jCheckBox9)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, true)
+ .addComponent(this.jCheckBox5)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
+ .addComponent(this.jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(this.jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(this.jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(this.jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(this.jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(this.jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(this.jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(this.jComboBox1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
+ .addGap(0, 10, Short.MAX_VALUE))
+ );
layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, true)
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, true)
.addGroup(layout.createSequentialGroup()
- .addGap(5, 5, 5)
- .addComponent(this.jLabel1)
- .addGap(7, 7, 7)
- .addComponent(this.jComboBox1)
- .addGap(10, 10, 10)
- .addComponent(this.jButton2)
- .addGap(5, 5, 5)
- .addComponent(this.jCheckBox2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(this.jCheckBox8)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(this.jCheckBox9)
- .addGap(7, 7, 7)
- .addComponent(this.jButton3)
- .addGap(12, 12, 12)
- .addComponent(this.jButton1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(this.jButton7)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(this.jButton4)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(this.jButton6)
- .addGap(7, 7, 7)
- .addComponent(this.jCheckBox1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(this.jCheckBox7)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(this.jCheckBox5)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(this.jCheckBox3)
- .addGap(8, 8, 8)
- .addComponent(this.jButton5)
- .addGap(5, 5, 5)
- .addComponent(this.jCheckBox6)
- .addComponent(this.jCheckBox4))
- );
+ .addGap(5, 5, 5)
+ .addComponent(this.jLabel1)
+ .addGap(7, 7, 7)
+ .addComponent(this.jComboBox1)
+ .addGap(10, 10, 10)
+ .addComponent(this.jButton2)
+ .addGap(5, 5, 5)
+ .addComponent(this.jCheckBox2)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(this.jCheckBox8)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(this.jCheckBox9)
+ .addGap(7, 7, 7)
+ .addComponent(this.jButton3)
+ .addGap(12, 12, 12)
+ .addComponent(this.jButton1)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(this.jButton7)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(this.jButton4)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(this.jButton6)
+ .addGap(7, 7, 7)
+ .addComponent(this.jCheckBox1)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(this.jCheckBox7)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(this.jCheckBox5)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(this.jCheckBox3)
+ .addGap(8, 8, 8)
+ .addComponent(this.jButton5)
+ .addGap(5, 5, 5)
+ .addComponent(this.jCheckBox6)
+ .addComponent(this.jCheckBox4))
+ );
pack();
}// //GEN-END:initComponents
@@ -352,7 +352,7 @@ private void jButton1ActionPerformed() {//GEN-FIRST:event_jButton1ActionPerforme
if (tmp)
return;
}
- this.abstractFrame = new SortPrompt(this.array, this.ArrayVisualizer, this.Frame, this);
+ this.abstractFrame = new SortPrompt(this.array, this.arrayVisualizer, this.frame, this);
jButton1.setText("Close");
jButton2ResetText();
jButton6ResetText();
@@ -379,7 +379,7 @@ private void jButton2ActionPerformed() {//GEN-FIRST:event_jButton2ActionPerforme
if (tmp)
return;
}
- this.abstractFrame = new ViewPrompt(this.ArrayVisualizer, this.Frame, this);
+ this.abstractFrame = new ViewPrompt(this.arrayVisualizer, this.frame, this);
jButton2.setText("Close");
jButton1ResetText();
jButton6ResetText();
@@ -424,11 +424,11 @@ private void jButton3ActionPerformed() {//GEN-FIRST:event_jButton3ActionPerforme
}//GEN-LAST:event_jButton3ActionPerformed
private void jCheckBox1ActionPerformed() {//GEN-FIRST:event_jCheckBox2ActionPerformed
- ArrayVisualizer.toggleShuffleAnimation(jCheckBox1.isSelected());
+ arrayVisualizer.toggleShuffleAnimation(jCheckBox1.isSelected());
}//GEN-LAST:event_jCheckBox1ActionPerformed
private void jCheckBox2ActionPerformed() {//GEN-FIRST:event_jCheckBox3ActionPerformed
- ArrayVisualizer.toggleLinkedDots(jCheckBox2.isSelected());
+ arrayVisualizer.toggleLinkedDots(jCheckBox2.isSelected());
}//GEN-LAST:event_jCheckBox2ActionPerformed
private void jCheckBox3ActionPerformed() {//GEN-FIRST:event_jCheckBox3ActionPerformed
@@ -440,15 +440,15 @@ private void jButton4ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerforme
}//GEN-LAST:event_jButton4ActionPerformed
private void jButton7ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerformed
- ArrayVisualizer.setCanceled(true);
+ arrayVisualizer.setCanceled(true);
}//GEN-LAST:event_jButton4ActionPerformed
private void jCheckBox4ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerformed
- RealTimer.toggleRealTimer(jCheckBox4.isSelected());
+ Timer.toggleRealTimer(jCheckBox4.isSelected());
}//GEN-LAST:event_jCheckBox4ActionPerformed
private void jButton5ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerformed
- ArrayVisualizer.resetAllStatistics();
+ arrayVisualizer.resetAllStatistics();
}//GEN-LAST:event_jButton6ActionPerformed
private void jCheckBox5ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerformed
@@ -468,7 +468,7 @@ private void jButton6ActionPerformed() {//GEN-FIRST:event_jButton2ActionPerforme
if (tmp)
return;
}
- this.abstractFrame = new ShufflePrompt(this.ArrayManager, this.Frame, this);
+ this.abstractFrame = new ShufflePrompt(this.arrayManager, this.frame, this);
jButton6.setText("Close");
jButton1ResetText();
jButton2ResetText();
@@ -479,7 +479,7 @@ public void jButton6ResetText() {
}
private void jCheckBox6ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerformed
- ArrayVisualizer.toggleStatistics(jCheckBox6.isSelected());
+ arrayVisualizer.toggleStatistics(jCheckBox6.isSelected());
}//GEN-LAST:event_jCheckBox6ActionPerformed
private void jCheckBox7ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerformed
@@ -487,7 +487,7 @@ private void jCheckBox7ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerfor
}//GEN-LAST:event_jCheckBox7ActionPerformed
private void jCheckBox8ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerformed
- ArrayVisualizer.toggleColor(jCheckBox8.isSelected());
+ arrayVisualizer.toggleColor(jCheckBox8.isSelected());
}//GEN-LAST:event_jCheckBox8ActionPerformed
private void jCheckBox9ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerformed
@@ -506,42 +506,42 @@ private void jCheckBox9ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerfor
}
jCheckBox9WarningShown = true;
}
- ArrayVisualizer.toggleExternalArrays(jCheckBox9.isSelected());
+ arrayVisualizer.toggleExternalArrays(jCheckBox9.isSelected());
}//GEN-LAST:event_jCheckBox8ActionPerformed
private void jComboBox1ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerformed
switch ((String)jComboBox1.getSelectedItem()) {
case "Sorting":
- if (ArrayVisualizer.enableBenchmarking(false))
+ if (arrayVisualizer.enableBenchmarking(false))
break;
jButton6.setEnabled(true);
- ArrayVisualizer.setComparator(0);
+ arrayVisualizer.setComparator(0);
break;
case "AntiQSort":
- if (ArrayVisualizer.enableBenchmarking(false))
+ if (arrayVisualizer.enableBenchmarking(false))
break;
if (this.abstractFrame != null && abstractFrame.isVisible()){
abstractFrame.dispose();
jButton6ResetText();
}
jButton6.setEnabled(false);
- ArrayVisualizer.setComparator(1);
+ arrayVisualizer.setComparator(1);
break;
case "Stability Check":
- if (ArrayVisualizer.enableBenchmarking(false))
+ if (arrayVisualizer.enableBenchmarking(false))
break;
jButton6.setEnabled(true);
- ArrayVisualizer.setComparator(2);
+ arrayVisualizer.setComparator(2);
break;
case "Sorting Networks":
- if (ArrayVisualizer.enableBenchmarking(false))
+ if (arrayVisualizer.enableBenchmarking(false))
break;
jButton6.setEnabled(true);
- ArrayVisualizer.setComparator(4);
- if (ArrayVisualizer.getCurrentLength() > 1024) {
+ arrayVisualizer.setComparator(4);
+ if (arrayVisualizer.getCurrentLength() > 1024) {
JOptionPane.showMessageDialog(
null,
"Large sorting networks can take a long time (and high RAM usage) to visualize.\n" +
@@ -552,16 +552,16 @@ private void jComboBox1ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerfor
break;
case "Reversed Sorting":
- if (ArrayVisualizer.enableBenchmarking(false))
+ if (arrayVisualizer.enableBenchmarking(false))
break;
jButton6.setEnabled(true);
- ArrayVisualizer.setComparator(3);
+ arrayVisualizer.setComparator(3);
break;
case "*Simple* Benchmarking":
jButton6.setEnabled(true);
- ArrayVisualizer.setComparator(0);
- ArrayVisualizer.enableBenchmarking(true);
+ arrayVisualizer.setComparator(0);
+ arrayVisualizer.enableBenchmarking(true);
break;
}
}//GEN-LAST:event_jCheckBox8ActionPerformed
diff --git a/src/main/java/io/github/arrayv/main/ArrayManager.java b/src/main/java/io/github/arrayv/main/ArrayManager.java
index eba7dce7..31d2c4f6 100644
--- a/src/main/java/io/github/arrayv/main/ArrayManager.java
+++ b/src/main/java/io/github/arrayv/main/ArrayManager.java
@@ -46,9 +46,9 @@ public final class ArrayManager {
private boolean hadDistributionAllocationError;
- private volatile boolean MUTABLE;
+ private volatile boolean mutableLength;
- private ArrayVisualizer ArrayVisualizer;
+ private ArrayVisualizer arrayVisualizer;
private Delays Delays;
private Highlights Highlights;
private ShuffleGraph shuffle;
@@ -56,7 +56,7 @@ public final class ArrayManager {
private Writes Writes;
public ArrayManager(ArrayVisualizer arrayVisualizer) {
- this.ArrayVisualizer = arrayVisualizer;
+ this.arrayVisualizer = arrayVisualizer;
this.shuffle = ShuffleGraph.single(Shuffles.RANDOM);
this.distribution = Distributions.LINEAR;
@@ -65,9 +65,9 @@ public ArrayManager(ArrayVisualizer arrayVisualizer) {
hadDistributionAllocationError = false;
- this.Delays = ArrayVisualizer.getDelays();
- this.Highlights = ArrayVisualizer.getHighlights();
- this.Writes = ArrayVisualizer.getWrites();
+ this.Delays = arrayVisualizer.getDelays();
+ this.Highlights = arrayVisualizer.getHighlights();
+ this.Writes = arrayVisualizer.getWrites();
this.shuffleIDs = new String[this.shuffleTypes.length];
for (int i = 0; i < this.shuffleTypes.length; i++)
@@ -77,24 +77,25 @@ public ArrayManager(ArrayVisualizer arrayVisualizer) {
for (int i = 0; i < this.distributionTypes.length; i++)
this.distributionIDs[i] = this.distributionTypes[i].getName();
- this.MUTABLE = true;
+ this.mutableLength = true;
}
public boolean isLengthMutable() {
- return this.MUTABLE;
+ return this.mutableLength;
}
- public void toggleMutableLength(boolean Bool) {
- this.MUTABLE = Bool;
+
+ public void toggleMutableLength(boolean mutableLength) {
+ this.mutableLength = mutableLength;
}
//TODO: Fix minimum to zero
public void initializeArray(int[] array) {
- if (ArrayVisualizer.doingStabilityCheck()) {
- ArrayVisualizer.resetStabilityTable();
- ArrayVisualizer.resetIndexTable();
+ if (arrayVisualizer.doingStabilityCheck()) {
+ arrayVisualizer.resetStabilityTable();
+ arrayVisualizer.resetIndexTable();
}
- int currentLen = ArrayVisualizer.getCurrentLength();
+ int currentLen = arrayVisualizer.getCurrentLength();
int[] temp;
try {
@@ -105,14 +106,14 @@ public void initializeArray(int[] array) {
hadDistributionAllocationError = true;
temp = array;
}
- distribution.initializeArray(temp, this.ArrayVisualizer);
+ distribution.initializeArray(temp, this.arrayVisualizer);
- double uniqueFactor = (double)currentLen/ArrayVisualizer.getUniqueItems();
+ double uniqueFactor = (double)currentLen/arrayVisualizer.getUniqueItems();
for (int i = 0; i < currentLen; i++)
temp[i] = (int)(uniqueFactor*(int)(temp[i]/uniqueFactor))+(int)uniqueFactor/2;
System.arraycopy(temp, 0, array, 0, currentLen);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.updateNow();
}
public String[] getShuffleIDs() {
@@ -160,48 +161,48 @@ public Distributions getDistribution() {
}
public void setDistribution(Distributions choice) {
this.distribution = choice;
- this.distribution.selectDistribution(ArrayVisualizer.getArray(), ArrayVisualizer);
- if (!ArrayVisualizer.isActive())
- this.initializeArray(ArrayVisualizer.getArray());
+ this.distribution.selectDistribution(arrayVisualizer.getArray(), arrayVisualizer);
+ if (!arrayVisualizer.isActive())
+ this.initializeArray(arrayVisualizer.getArray());
}
public boolean containsShuffle(Shuffles shuffle) {
return this.shuffle.contains(new ShuffleInfo(shuffle));
}
- public void shuffleArray(int[] array, int currentLen, ArrayVisualizer ArrayVisualizer) {
+ public void shuffleArray(int[] array, int currentLen, ArrayVisualizer arrayVisualizer) {
this.initializeArray(array);
- String tmp = ArrayVisualizer.getHeading();
- ArrayVisualizer.setHeading("Shuffling...");
+ String tmp = arrayVisualizer.getHeading();
+ arrayVisualizer.setHeading("Shuffling...");
double speed = Delays.getSleepRatio();
- if (ArrayVisualizer.isActive()) {
- double sleepRatio = ArrayVisualizer.getCurrentLength()/1024d;
- sleepRatio *= shuffle.sleepRatio;
+ if (arrayVisualizer.isActive()) {
+ double sleepRatio = arrayVisualizer.getCurrentLength()/1024d;
+ sleepRatio *= shuffle.getSleepRatio();
Delays.setSleepRatio(sleepRatio);
}
- shuffle.shuffleArray(array, this.ArrayVisualizer);
+ shuffle.shuffleArray(array, this.arrayVisualizer);
Delays.setSleepRatio(speed);
Highlights.clearAllMarks();
- ArrayVisualizer.setHeading(tmp);
+ arrayVisualizer.setHeading(tmp);
}
private void stableShuffle(int[] array, int length) {
double speed = Delays.getSleepRatio();
- if (ArrayVisualizer.isActive()) {
- double sleepRatio = ArrayVisualizer.getCurrentLength()/1024d;
+ if (arrayVisualizer.isActive()) {
+ double sleepRatio = arrayVisualizer.getCurrentLength()/1024d;
Delays.setSleepRatio(sleepRatio);
}
int[] counts = new int[length];
int[] prefixSum = new int[length];
- int[] table = ArrayVisualizer.getStabilityTable();
+ int[] table = arrayVisualizer.getStabilityTable();
for (int i = 0; i < length; i++)
counts[array[i]]++;
@@ -220,33 +221,33 @@ private void stableShuffle(int[] array, int length) {
for (int i = length-1; i >= 0; i--)
Writes.write(array, i, --prefixSum[array[i]], 0.5, true, false);
- ArrayVisualizer.setIndexTable();
+ arrayVisualizer.setIndexTable();
Delays.setSleepRatio(speed);
}
- public void refreshArray(int[] array, int currentLen, ArrayVisualizer ArrayVisualizer) {
+ public void refreshArray(int[] array, int currentLen, ArrayVisualizer arrayVisualizer) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
JErrorPane.invokeErrorMessage(e);
}
- ArrayVisualizer.resetAllStatistics();
+ arrayVisualizer.resetAllStatistics();
Highlights.clearAllMarks();
- ArrayVisualizer.setHeading("");
- if (!ArrayVisualizer.useAntiQSort()) {
- this.shuffleArray(array, currentLen, ArrayVisualizer);
+ arrayVisualizer.setHeading("");
+ if (!arrayVisualizer.useAntiQSort()) {
+ this.shuffleArray(array, currentLen, arrayVisualizer);
- if (ArrayVisualizer.doingStabilityCheck())
+ if (arrayVisualizer.doingStabilityCheck())
this.stableShuffle(array, currentLen);
- int[] validateArray = ArrayVisualizer.getValidationArray();
+ int[] validateArray = arrayVisualizer.getValidationArray();
if (validateArray != null) {
System.arraycopy(array, 0, validateArray, 0, currentLen);
Arrays.sort(validateArray, 0, currentLen);
- if (ArrayVisualizer.reversedComparator()) {
+ if (arrayVisualizer.reversedComparator()) {
for (int i = 0, j = currentLen - 1; i < j; i++, j--) {
int temp = validateArray[i];
validateArray[i] = validateArray[j];
@@ -264,6 +265,6 @@ public void refreshArray(int[] array, int currentLen, ArrayVisualizer ArrayVisua
JErrorPane.invokeErrorMessage(e);
}
- ArrayVisualizer.resetAllStatistics();
+ arrayVisualizer.resetAllStatistics();
}
}
diff --git a/src/main/java/io/github/arrayv/main/ArrayVisualizer.java b/src/main/java/io/github/arrayv/main/ArrayVisualizer.java
index de6b42c5..341745ee 100644
--- a/src/main/java/io/github/arrayv/main/ArrayVisualizer.java
+++ b/src/main/java/io/github/arrayv/main/ArrayVisualizer.java
@@ -114,7 +114,9 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class ArrayVisualizer {
+ // @checkstyle:off StaticVariableName
private static ArrayVisualizer INSTANCE = null;
+ // @checkstyle:on StaticVariableName
private enum StatisticType {
LINE_BREAK,
@@ -132,6 +134,7 @@ private enum StatisticType {
AUX_ALLOC,
SEGMENTS;
+ // @checkstyle:off IndentationCheck - It doesn't like {{ syntax
private static final Map CONFIG_KEYS = Collections.unmodifiableMap(new HashMap() {{
put("", LINE_BREAK);
put("sort", SORT_IDENTITY);
@@ -148,14 +151,15 @@ private enum StatisticType {
put("auxlen", AUX_ALLOC);
put("segments", SEGMENTS);
}});
+ // @checkstyle:on IndentationCheck
}
final JFrame window;
- final private int MIN_ARRAY_VAL;
- final private int MAX_ARRAY_VAL;
+ private final int minArrayVal;
+ private final int maxArrayVal;
- final private Properties buildInfo;
+ private final Properties buildInfo;
final int[] array;
final int[] validateArray;
@@ -171,11 +175,11 @@ private enum StatisticType {
private volatile int sortLength;
private volatile int uniqueItems;
- private ArrayManager ArrayManager;
- private SortAnalyzer SortAnalyzer;
+ private ArrayManager arrayManager;
+ private SortAnalyzer sortAnalyzer;
- private UtilFrame UtilFrame;
- private ArrayFrame ArrayFrame;
+ private UtilFrame utilFrame;
+ private ArrayFrame arrayFrame;
private Visual[] visualClasses;
@@ -183,7 +187,7 @@ private enum StatisticType {
private Thread visualsThread;
private volatile boolean visualsEnabled;
- public final boolean disabledStabilityCheck;
+ private final boolean disabledStabilityCheck;
private String category;
private String heading;
@@ -194,30 +198,23 @@ private enum StatisticType {
private volatile int currentGap;
- private boolean SHUFFLEANIM;
+ private boolean showShuffleAnimation;
- private volatile boolean ANALYZE;
-
- private volatile boolean POINTER;
+ private volatile boolean highlightAsAnalysis;
private Statistics statSnapshot;
private String fontSelection;
private double fontSelectionScale;
- private volatile boolean TEXTDRAW;
- private volatile boolean COLOR;
- private volatile boolean DISPARITYDRAW;
- private volatile boolean LINEDRAW;
- private volatile boolean PIXELDRAW;
- private volatile boolean RAINBOW;
- private volatile boolean SPIRALDRAW;
- private volatile boolean WAVEDRAW;
- private volatile boolean EXTARRAYS;
-
- private volatile boolean ANTIQSORT;
- private volatile boolean STABILITY;
- private volatile boolean NETWORKS;
- private volatile boolean REVERSED;
+ private volatile boolean showStatistics;
+ private volatile boolean showColor;
+ private volatile boolean showLines;
+ private volatile boolean showExternalArrays;
+
+ private volatile boolean useAntiQSort;
+ private volatile boolean stabilityChecking;
+ private volatile boolean visualizingNetworks;
+ private volatile boolean reversedComparator;
private volatile boolean isCanceled;
@@ -232,19 +229,19 @@ private enum StatisticType {
private Delays Delays;
private Highlights Highlights;
- private MultipleScript MultipleScript;
+ private MultipleScript multipleScript;
private Reads Reads;
- private Renderer Renderer;
+ private Renderer renderer;
private Sounds Sounds;
private Timer Timer;
- private VisualStyles VisualStyles;
+ private VisualStyles visualStyles;
private Writes Writes;
- private AntiQSort AntiQSort;
+ private AntiQSort antiQSort;
private volatile int updateVisualsForced;
- public volatile boolean benchmarking;
+ private volatile boolean benchmarking;
- public static int MAX_LENGTH_POWER = 15;
+ private static int maxLengthPower;
private volatile boolean hidden;
private volatile boolean frameSkipped;
@@ -287,11 +284,11 @@ public synchronized void drop(DropTargetDropEvent e) {
List droppedFiles = (List)e.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
int success = 0;
for (File file : droppedFiles) {
- if (ArrayVisualizer.this.SortAnalyzer.importSort(file, false)) {
+ if (ArrayVisualizer.this.sortAnalyzer.importSort(file, false)) {
success++;
}
}
- ArrayVisualizer.this.SortAnalyzer.sortSorts();
+ ArrayVisualizer.this.sortAnalyzer.sortSorts();
ArrayVisualizer.this.refreshSorts();
if (success == 0) {
JErrorPane.invokeCustomErrorMessage("Failed to import all " + droppedFiles.size() + " sorts");
@@ -319,9 +316,9 @@ public boolean dispatchKeyEvent(KeyEvent e) {
Thread thread = new Thread("ScriptSortThread") {
@Override
public void run(){
- RunScriptedSorts RunScriptedSorts = new RunScriptedSorts(ArrayVisualizer.this);
+ RunScriptedSorts runScriptedSorts = new RunScriptedSorts(ArrayVisualizer.this);
try {
- RunScriptedSorts.runThread(ArrayVisualizer.this.getArray(), 0, 0, false);
+ runScriptedSorts.runThread(ArrayVisualizer.this.getArray(), 0, 0, false);
} catch (Exception e) {
JErrorPane.invokeErrorMessage(e);
}
@@ -383,12 +380,12 @@ public void run() {
e.printStackTrace();
}
- this.MIN_ARRAY_VAL = 2;
- this.MAX_ARRAY_VAL = (int)Math.pow(2, MAX_LENGTH_POWER);
+ this.minArrayVal = 2;
+ this.maxArrayVal = (int)Math.pow(2, maxLengthPower);
int[] array;
try {
- array = new int[this.MAX_ARRAY_VAL];
+ array = new int[this.maxArrayVal];
} catch (OutOfMemoryError e) {
JErrorPane.invokeCustomErrorMessage("Failed to allocate main array. The program will now exit.");
System.exit(1);
@@ -396,7 +393,7 @@ public void run() {
}
this.array = array;
- this.sortLength = this.MAX_ARRAY_VAL;
+ this.sortLength = this.maxArrayVal;
this.arrays = new ArrayList<>();
this.arrays.add(this.array);
@@ -455,6 +452,7 @@ public void run() {
"ArrayVisualizer",
JOptionPane.WARNING_MESSAGE
);
+ // @checkstyle:off IndentationCheck - There's custom indentation here to make things more readable
statsConfig = new StatisticType[] {
StatisticType.SORT_IDENTITY,
StatisticType.ARRAY_LENGTH,
@@ -472,11 +470,12 @@ public void run() {
StatisticType.AUX_ALLOC,
StatisticType.SEGMENTS
};
+ // @checkstyle:on IndentationCheck
} else {
statsConfig = statsInfoList.toArray(new StatisticType[statsInfoList.size()]);
}
- this.sortLength = Math.min(2048, this.MAX_ARRAY_VAL);
+ this.sortLength = Math.min(2048, this.maxArrayVal);
this.uniqueItems = this.sortLength;
this.formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US);
@@ -485,29 +484,29 @@ public void run() {
this.symbols.setGroupingSeparator(',');
this.formatter.setDecimalFormatSymbols(this.symbols);
- this.Highlights = new Highlights(this, this.MAX_ARRAY_VAL);
+ this.Highlights = new Highlights(this, this.maxArrayVal);
this.Sounds = new Sounds(this.array, this);
this.Delays = new Delays(this);
this.Timer = new Timer(this);
this.Reads = new Reads(this);
- this.Renderer = new Renderer(this);
+ this.renderer = new Renderer(this);
this.Writes = new Writes(this);
- this.AntiQSort = new AntiQSort(this);
+ this.antiQSort = new AntiQSort(this);
SoundFrame test = new SoundFrame(this.Sounds);
test.setVisible(true);
- this.ArrayManager = new ArrayManager(this);
- this.SortAnalyzer = new SortAnalyzer(this);
+ this.arrayManager = new ArrayManager(this);
+ this.sortAnalyzer = new SortAnalyzer(this);
- this.SortAnalyzer.analyzeSorts();
+ this.sortAnalyzer.analyzeSorts();
this.refreshSorts();
int[] stabilityTable, indexTable, validateArray;
boolean disabledStabilityCheck;
try {
- stabilityTable = new int[this.MAX_ARRAY_VAL];
- indexTable = new int[this.MAX_ARRAY_VAL];
+ stabilityTable = new int[this.maxArrayVal];
+ indexTable = new int[this.maxArrayVal];
disabledStabilityCheck = false;
} catch (OutOfMemoryError e) {
JErrorPane.invokeCustomErrorMessage("Failed to allocate arrays for stability check. This feature will be disabled.");
@@ -516,7 +515,7 @@ public void run() {
disabledStabilityCheck = true;
}
try {
- validateArray = new int[this.MAX_ARRAY_VAL];
+ validateArray = new int[this.maxArrayVal];
} catch (OutOfMemoryError e) {
JErrorPane.invokeCustomErrorMessage("Failed to allocate array for improved validation. This feature will be disabled.");
validateArray = null;
@@ -530,7 +529,7 @@ public void run() {
this.resetIndexTable();
}
- this.MultipleScript = new MultipleScript(this);
+ this.multipleScript = new MultipleScript(this);
this.category = "";
this.heading = "";
@@ -539,27 +538,22 @@ public void run() {
this.statSnapshot = new Statistics(this);
- this.UtilFrame = new UtilFrame(this.array, this);
- this.ArrayFrame = new ArrayFrame(this.array, this);
+ this.utilFrame = new UtilFrame(this.array, this);
+ this.arrayFrame = new ArrayFrame(this.array, this);
- this.UtilFrame.reposition(this.ArrayFrame);
+ this.utilFrame.reposition(this.arrayFrame);
- this.SHUFFLEANIM = true;
- this.ANALYZE = false;
- this.POINTER = false;
- this.TEXTDRAW = true;
+ this.showShuffleAnimation = true;
+ this.highlightAsAnalysis = false;
+ this.showStatistics = true;
- this.COLOR = false;
- this.DISPARITYDRAW = false;
- this.LINEDRAW = false;
- this.PIXELDRAW = false;
- this.RAINBOW = false;
- this.SPIRALDRAW = false;
- this.EXTARRAYS = false;
+ this.showColor = false;
+ this.showLines = false;
+ this.showExternalArrays = false;
- this.ANTIQSORT = false;
- this.STABILITY = false;
- this.NETWORKS = false;
+ this.useAntiQSort = false;
+ this.stabilityChecking = false;
+ this.visualizingNetworks = false;
this.isCanceled = false;
@@ -571,7 +565,7 @@ public void run() {
this.ch = 0;
this.cw = 0;
- this.ArrayManager.initializeArray(this.array);
+ this.arrayManager.initializeArray(this.array);
//TODO: Overhaul visual code to properly reflect Swing (JavaFX?) style and conventions
this.toggleVisualUpdates(false);
@@ -620,11 +614,11 @@ public void run() {
try {
if (ArrayVisualizer.this.updateVisualsForced > 0) {
ArrayVisualizer.this.updateVisualsForced--;
- ArrayVisualizer.this.Renderer.updateVisualsStart(ArrayVisualizer.this);
+ ArrayVisualizer.this.renderer.updateVisualsStart(ArrayVisualizer.this);
int[][] arrays = ArrayVisualizer.this.arrays.toArray(new int[][] { });
- ArrayVisualizer.this.Renderer.drawVisual(ArrayVisualizer.this.VisualStyles, arrays, ArrayVisualizer.this, ArrayVisualizer.this.Highlights);
+ ArrayVisualizer.this.renderer.drawVisual(ArrayVisualizer.this.visualStyles, arrays, ArrayVisualizer.this, ArrayVisualizer.this.Highlights);
- if (ArrayVisualizer.this.TEXTDRAW) {
+ if (ArrayVisualizer.this.showStatistics) {
ArrayVisualizer.this.statSnapshot.updateStats(ArrayVisualizer.this);
ArrayVisualizer.this.updateFontSize();
ArrayVisualizer.this.drawStats(Color.BLACK, true);
@@ -640,7 +634,7 @@ public void run() {
e.printStackTrace();
}
long endTime = System.currentTimeMillis();
- statSnapshot.frameTimeMillis = endTime - startTime;
+ statSnapshot.setFrameTimeMillis(endTime - startTime);
}
}
};
@@ -658,9 +652,9 @@ public JFrame getWindow() {
}
public void refreshSorts() {
- this.sorts = this.SortAnalyzer.getSorts();
- this.invalidSorts = this.SortAnalyzer.getInvalidSorts();
- this.sortSuggestions = this.SortAnalyzer.getSuggestions();
+ this.sorts = this.sortAnalyzer.getSorts();
+ this.invalidSorts = this.sortAnalyzer.getInvalidSorts();
+ this.sortSuggestions = this.sortAnalyzer.getSuggestions();
}
private void drawStats(Color textColor, boolean dropShadow) {
@@ -761,11 +755,14 @@ public boolean enableBenchmarking(boolean enabled) {
} else if (this.benchmarking) {
if (this.getCurrentLength() >= Math.pow(2, 23)) {
- int warning = JOptionPane.showOptionDialog(this.getMainWindow(), "Warning! "
- + "Your computer's GPU probably can't handle more than 2^23 elements at any "
- + "framrate not significantly less than 1. Would you still like "
- + "to re-enable graphics?", "Warning!", 2, JOptionPane.WARNING_MESSAGE,
- null, new String[] { "Yes", "Please save my GPU!" }, "Please save my GPU!");
+ int warning = JOptionPane.showOptionDialog(
+ this.getMainWindow(),
+ "Warning! "
+ + "Your computer's CPU probably can't handle more than 2^23 elements at any "
+ + "framrate not significantly less than 1. Would you still like "
+ + "to re-enable graphics?",
+ "Warning!", 2, JOptionPane.WARNING_MESSAGE,
+ null, new String[] { "Yes", "Please save my GPU!" }, "Please save my GPU!");
if (warning != 0) {
enabled = true;
}
@@ -818,7 +815,7 @@ public void resetIndexTable() {
}
public boolean isSorted() {
- return this.statSnapshot.findSegments(this.array, this.sortLength, this.REVERSED)[0] == 1;
+ return this.statSnapshot.findSegments(this.array, this.sortLength, this.reversedComparator)[0] == 1;
}
public int[] getArray() {
@@ -830,10 +827,10 @@ public ArrayList getArrays() {
}
public ArrayManager getArrayManager() {
- return this.ArrayManager;
+ return this.arrayManager;
}
public SortAnalyzer getSortAnalyzer() {
- return this.SortAnalyzer;
+ return this.sortAnalyzer;
}
public Delays getDelays() {
return this.Delays;
@@ -845,7 +842,7 @@ public Reads getReads() {
return this.Reads;
}
public Renderer getRender() {
- return this.Renderer;
+ return this.renderer;
}
public Sounds getSounds() {
return this.Sounds;
@@ -854,13 +851,13 @@ public Timer getTimer() {
return this.Timer;
}
public VisualStyles getVisualStyles() {
- return this.VisualStyles;
+ return this.visualStyles;
}
public Writes getWrites() {
return this.Writes;
}
public MultipleScript getScriptParser() {
- return this.MultipleScript;
+ return this.multipleScript;
}
public Visual[] getVisuals() {
@@ -868,11 +865,11 @@ public Visual[] getVisuals() {
}
public UtilFrame getUtilFrame() {
- return this.UtilFrame;
+ return this.utilFrame;
}
public ArrayFrame getArrayFrame() {
- return this.ArrayFrame;
+ return this.arrayFrame;
}
public SortInfo[] getSorts() {
@@ -890,10 +887,10 @@ public void runSortingThread() {
}
public int getMinimumLength() {
- return this.MIN_ARRAY_VAL;
+ return this.minArrayVal;
}
public int getMaximumLength() {
- return this.MAX_ARRAY_VAL;
+ return this.maxArrayVal;
}
public void resetAllStatistics() {
@@ -909,51 +906,51 @@ public boolean isActive() {
public void setComparator(int comparator) {
switch (comparator) {
case 0:
- this.REVERSED = false;
- this.ANTIQSORT = false;
- this.STABILITY = false;
- this.NETWORKS = false;
+ this.reversedComparator = false;
+ this.useAntiQSort = false;
+ this.stabilityChecking = false;
+ this.visualizingNetworks = false;
break;
case 1:
- this.REVERSED = false;
- this.ANTIQSORT = true;
- this.STABILITY = false;
- this.NETWORKS = false;
+ this.reversedComparator = false;
+ this.useAntiQSort = true;
+ this.stabilityChecking = false;
+ this.visualizingNetworks = false;
break;
case 2:
- this.REVERSED = false;
- this.ANTIQSORT = false;
- this.STABILITY = true;
- this.NETWORKS = false;
+ this.reversedComparator = false;
+ this.useAntiQSort = false;
+ this.stabilityChecking = true;
+ this.visualizingNetworks = false;
break;
case 3:
- this.REVERSED = true;
- this.ANTIQSORT = false;
- this.STABILITY = false;
- this.NETWORKS = false;
+ this.reversedComparator = true;
+ this.useAntiQSort = false;
+ this.stabilityChecking = false;
+ this.visualizingNetworks = false;
break;
case 4:
- this.REVERSED = false;
- this.ANTIQSORT = false;
- this.STABILITY = false;
- this.NETWORKS = true;
+ this.reversedComparator = false;
+ this.useAntiQSort = false;
+ this.stabilityChecking = false;
+ this.visualizingNetworks = true;
break;
}
}
public boolean generateSortingNetworks() {
- return this.NETWORKS;
+ return this.visualizingNetworks;
}
public boolean useAntiQSort() {
- return this.ANTIQSORT;
+ return this.useAntiQSort;
}
public void initAntiQSort() {
- this.AntiQSort.beginSort(this.array, this.sortLength);
+ this.antiQSort.beginSort(this.array, this.sortLength);
}
public void finishAntiQSort(String name) {
- int[] result = this.AntiQSort.getResult();
- this.AntiQSort.hideResult();
+ int[] result = this.antiQSort.getResult();
+ this.antiQSort.hideResult();
String outName = "antiqsort_" + name + "_" + this.sortLength;
if (!ArrayFileWriter.writeArray(outName, result, sortLength)) {
return;
@@ -961,18 +958,18 @@ public void finishAntiQSort(String name) {
JOptionPane.showMessageDialog(null, "Successfully saved output to file \"" + outName + "\"", "AntiQSort", JOptionPane.INFORMATION_MESSAGE);
}
public int antiqCompare(int left, int right) {
- int cmp = this.AntiQSort.compare(left, right);
+ int cmp = this.antiQSort.compare(left, right);
if (cmp == 0)
return 0;
return cmp / Math.abs(cmp);
}
public boolean doingStabilityCheck() {
- return this.STABILITY;
+ return this.stabilityChecking;
}
public boolean reversedComparator() {
- return this.REVERSED;
+ return this.reversedComparator;
}
// These next five methods should be part of ArrayManager
@@ -1004,10 +1001,11 @@ public int getLogBaseTwoOfLength() {
}
public boolean shuffleEnabled() {
- return this.SHUFFLEANIM;
+ return this.showShuffleAnimation;
}
- public void toggleShuffleAnimation(boolean Bool) {
- this.SHUFFLEANIM = Bool;
+
+ public void toggleShuffleAnimation(boolean showShuffleAnimation) {
+ this.showShuffleAnimation = showShuffleAnimation;
}
public String getCategory() {
@@ -1029,8 +1027,13 @@ public void setExtraHeading(String text) {
this.extraHeading = text;
}
+ /**
+ * @deprecated No longer does anything (always returns {@code false})
+ * @return {@code false}
+ */
+ @Deprecated
public boolean pointerActive() {
- return this.POINTER;
+ return false;
}
public JFrame getMainWindow() {
@@ -1151,11 +1154,12 @@ public void updateFontSize() {
this.mainRender.setFont(this.typeFace);
}
- public void toggleAnalysis(boolean Bool) {
- this.ANALYZE = Bool;
+ public void toggleAnalysis(boolean highlightAsAnalysis) {
+ this.highlightAsAnalysis = highlightAsAnalysis;
}
+
public boolean analysisEnabled() {
- return this.ANALYZE;
+ return this.highlightAsAnalysis;
}
public int halfCircle() {
@@ -1176,7 +1180,7 @@ public synchronized void verifySortAndSweep() {
String temp = this.heading;
this.heading = "Verifying sort...";
- int cmpVal = this.REVERSED ? -1 : 1;
+ int cmpVal = this.reversedComparator ? -1 : 1;
boolean success = true, stable = true;
int unstableIdx = 0;
@@ -1229,7 +1233,7 @@ public synchronized void verifySortAndSweep() {
// if (tempStability && success)
// JOptionPane.showMessageDialog(this.window, "This sort is stable!", "Information", JOptionPane.OK_OPTION, null);
- if (this.STABILITY && success && !stable) {
+ if (this.stabilityChecking && success && !stable) {
boolean tempSound = this.Sounds.isEnabled();
this.Sounds.toggleSound(false);
this.Highlights.toggleFancyFinish(false);
@@ -1303,42 +1307,69 @@ public void endSort() {
this.Highlights.clearAllMarks();
}
- public void togglePointer(boolean Bool) {
- this.POINTER = Bool;
+ /**
+ * @deprecated No longer does anything
+ */
+ @Deprecated
+ public void togglePointer(boolean showPointer) {
}
- public void toggleDistance(boolean Bool) {
- this.DISPARITYDRAW = Bool;
+
+ /**
+ * @deprecated No longer does anything
+ */
+ @Deprecated
+ public void toggleDistance(boolean unused) {
}
- public void togglePixels(boolean Bool) {
- this.PIXELDRAW = Bool;
+
+ /**
+ * @deprecated No longer does anything
+ */
+ @Deprecated
+ public void togglePixels(boolean usePixels) {
}
- public void toggleRainbow(boolean Bool) {
- this.RAINBOW = Bool;
+
+ /**
+ * @deprecated No longer does anything
+ */
+ @Deprecated
+ public void toggleRainbow(boolean rainbow) {
}
- public void toggleSpiral(boolean Bool) {
- this.SPIRALDRAW = Bool;
+
+ /**
+ * @deprecated No longer does anything
+ */
+ @Deprecated
+ public void toggleSpiral(boolean spiral) {
}
- public void toggleLinkedDots(boolean Bool) {
- this.LINEDRAW = Bool;
+
+ public void toggleLinkedDots(boolean showLines) {
+ this.showLines = showLines;
}
- public void toggleStatistics(boolean Bool) {
- this.TEXTDRAW = Bool;
+
+ public void toggleStatistics(boolean showStatistics) {
+ this.showStatistics = showStatistics;
}
- public void toggleColor(boolean Bool) {
- this.COLOR = Bool;
+
+ public void toggleColor(boolean showColor) {
+ this.showColor = showColor;
}
- public void toggleWave(boolean Bool) {
- this.WAVEDRAW = Bool;
+
+ /**
+ * @deprecated No longer does anything
+ */
+ @Deprecated
+ public void toggleWave(boolean useWave) {
}
- public void toggleExternalArrays(boolean Bool) {
- this.EXTARRAYS = Bool;
+
+ public void toggleExternalArrays(boolean showExternalArrays) {
+ this.showExternalArrays = showExternalArrays;
}
public void setVisual(VisualStyles choice) {
if (choice == io.github.arrayv.visuals.VisualStyles.CUSTOM_IMAGE) {
((CustomImage) this.visualClasses[9]).enableImgMenu();
}
- this.VisualStyles = choice;
+ this.visualStyles = choice;
synchronized (this) {
this.updateNow();
}
@@ -1359,33 +1390,65 @@ public void setCanceled(boolean canceled) {
}
public void repositionFrames() {
- this.ArrayFrame.reposition();
- this.UtilFrame.reposition(this.ArrayFrame);
+ this.arrayFrame.reposition();
+ this.utilFrame.reposition(this.arrayFrame);
}
+ /**
+ * @deprecated No longer does anything (always returns {@code false})
+ * @return {@code false}
+ */
+ @Deprecated
public boolean rainbowEnabled() {
- return this.RAINBOW;
+ return false;
}
+
public boolean colorEnabled() {
- return this.COLOR;
+ return this.showColor;
}
+
+ /**
+ * @deprecated No longer does anything (always returns {@code false})
+ * @return {@code false}
+ */
+ @Deprecated
public boolean spiralEnabled() {
- return this.SPIRALDRAW;
+ return false;
}
+
+ /**
+ * @deprecated No longer does anything (always returns {@code false})
+ * @return {@code false}
+ */
+ @Deprecated
public boolean distanceEnabled() {
- return this.DISPARITYDRAW;
+ return false;
}
+
+ /**
+ * @deprecated No longer does anything (always returns {@code false})
+ * @return {@code false}
+ */
+ @Deprecated
public boolean pixelsEnabled() {
- return this.PIXELDRAW;
+ return false;
}
+
public boolean linesEnabled() {
- return this.LINEDRAW;
+ return this.showLines;
}
+
+ /**
+ * @deprecated No longer does anything (always returns {@code false})
+ * @return {@code false}
+ */
+ @Deprecated
public boolean waveEnabled() {
- return this.WAVEDRAW;
+ return false;
}
+
public boolean externalArraysEnabled() {
- return this.EXTARRAYS;
+ return this.showExternalArrays;
}
public DecimalFormat getNumberFormat() {
@@ -1401,7 +1464,7 @@ private static String parseStringArray(String[] stringArray) {
}
private void drawWindows() {
- this.VisualStyles = io.github.arrayv.visuals.VisualStyles.BARS;
+ this.visualStyles = io.github.arrayv.visuals.VisualStyles.BARS;
this.category = "Select a Sort";
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
@@ -1438,8 +1501,8 @@ public void windowClosing(WindowEvent close) {
this.window.setVisible(true);
this.visualsThread.start();
- this.UtilFrame.setVisible(true);
- this.ArrayFrame.setVisible(true);
+ this.utilFrame.setVisible(true);
+ this.arrayFrame.setVisible(true);
this.window.createBufferStrategy(2);
@@ -1453,10 +1516,18 @@ public void windowClosing(WindowEvent close) {
}
}
+ public boolean isDisabledStabilityCheck() {
+ return disabledStabilityCheck;
+ }
+
+ public static int getMaxLengthPower() {
+ return maxLengthPower;
+ }
+
public static void main(String[] args) {
System.setProperty("sun.java2d.d3d", "false");
if (args.length > 0) {
- ArrayVisualizer.MAX_LENGTH_POWER = Integer.parseInt(args[0]);
+ ArrayVisualizer.maxLengthPower = Integer.parseInt(args[0]);
}
new ArrayVisualizer();
}
diff --git a/src/main/java/io/github/arrayv/main/SortAnalyzer.java b/src/main/java/io/github/arrayv/main/SortAnalyzer.java
index 60214fc3..e152bbaa 100644
--- a/src/main/java/io/github/arrayv/main/SortAnalyzer.java
+++ b/src/main/java/io/github/arrayv/main/SortAnalyzer.java
@@ -88,7 +88,7 @@ public final class SortAnalyzer {
"import sorts.templates.SortComparator;", "import io.github.arrayv.sortdata.SortComparator;"
);
- private final Set> EXTRA_SORTS = new HashSet<>();
+ private final Set> extraSorts = new HashSet<>();
static {
try {
@@ -122,11 +122,11 @@ public boolean didSortComeFromExtra(Sort sort) {
}
public boolean didSortComeFromExtra(Class> sort) {
- return EXTRA_SORTS.contains(sort);
+ return extraSorts.contains(sort);
}
private void setSortCameFromExtra(Class> sort) {
- EXTRA_SORTS.add(sort);
+ extraSorts.add(sort);
}
@SuppressWarnings("unchecked")
@@ -260,7 +260,7 @@ public void unloadAllExtraSorts() {
}
}
sorts.subList(j, sorts.size()).clear();
- EXTRA_SORTS.clear();
+ extraSorts.clear();
}
public void installOrUpdateExtraSorts(ProgressMonitor monitor) throws IOException {
@@ -389,11 +389,13 @@ private String readPackageName() {
StringBuilder result = new StringBuilder();
boolean isAfterDot = true;
while (true) {
+ // @checkstyle:off IndentationCheck - It looks nicer how it is
if (isAfterDot) {
if (
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
- c == '_' || c == '$') {
+ c == '_' || c == '$'
+ ) {
result.appendCodePoint(c);
} else {
throw new IllegalArgumentException("Illegal character in package name: " + new String(Character.toChars(c)));
@@ -404,7 +406,8 @@ private String readPackageName() {
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9') ||
- c == '_' || c == '$') {
+ c == '_' || c == '$'
+ ) {
result.appendCodePoint(c);
} else if (c == '.') {
result.append('.');
@@ -413,6 +416,7 @@ private String readPackageName() {
throw new IllegalArgumentException("Illegal character in package name: " + new String(Character.toChars(c)));
}
}
+ // @checkstyle:on IndentationCheck
if (advance()) {
throw new IllegalArgumentException("EOF");
}
@@ -489,6 +493,7 @@ public boolean importSort(File file, boolean showConfirmation) {
int success;
try {
fileManager.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(CACHE_DIR));
+ // @checkstyle:off ParenPadCheck
CompilationTask task = compiler.getTask(
null, // out
fileManager, // fileManager
@@ -499,6 +504,7 @@ public boolean importSort(File file, boolean showConfirmation) {
null, // classes
jFiles // compilationUnits
);
+ // @checkstyle:on ParenPadCheck
try {
// Code that would work except that reflection is safer (I think) when using APIs that may be removed
// com.sun.tools.javac.main.Main.Result result = ((com.sun.tools.javac.api.JavacTaskImpl)task).doCall();
@@ -655,10 +661,10 @@ public String[] getInvalidSorts() {
return null;
}
- String[] InvalidSorts = new String[invalidSorts.size()];
- InvalidSorts = invalidSorts.toArray(InvalidSorts);
+ String[] invalidSorts = new String[this.invalidSorts.size()];
+ invalidSorts = this.invalidSorts.toArray(invalidSorts);
- return InvalidSorts;
+ return invalidSorts;
}
public String[] getSuggestions() {
if (suggestions.size() < 1) {
diff --git a/src/main/java/io/github/arrayv/panels/ShufflePanel.java b/src/main/java/io/github/arrayv/panels/ShufflePanel.java
index c4d948c6..38b6994b 100644
--- a/src/main/java/io/github/arrayv/panels/ShufflePanel.java
+++ b/src/main/java/io/github/arrayv/panels/ShufflePanel.java
@@ -20,7 +20,7 @@
public class ShufflePanel extends JPanel implements KeyListener {
int camX = 0, camY = 0;
int prevX = 0, prevY = 0;
- public ShuffleGraph graph;
+ private ShuffleGraph graph;
public ShufflePanel() {
setPreferredSize(new Dimension(700, 450));
@@ -57,6 +57,14 @@ public void keyPressed(KeyEvent e) {
public void keyReleased(KeyEvent e) {
}
+ public ShuffleGraph getShuffle() {
+ return graph;
+ }
+
+ public void setShuffle(ShuffleGraph shuffle) {
+ this.graph = shuffle;
+ }
+
protected class MouseHandler extends MouseAdapter {
@Override
public void mousePressed(MouseEvent e) {
diff --git a/src/main/java/io/github/arrayv/panes/JEnhancedOptionPane.java b/src/main/java/io/github/arrayv/panes/JEnhancedOptionPane.java
index efaecccf..e209367f 100644
--- a/src/main/java/io/github/arrayv/panes/JEnhancedOptionPane.java
+++ b/src/main/java/io/github/arrayv/panes/JEnhancedOptionPane.java
@@ -8,23 +8,21 @@
// 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
public final class JEnhancedOptionPane extends JOptionPane {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- public static String showInputDialog(final String title, final Object message, final Object[] options) throws HeadlessException {
- final JOptionPane pane = new JOptionPane(message, QUESTION_MESSAGE,
- OK_CANCEL_OPTION, null,
- options, null);
- pane.setWantsInput(true);
- pane.setComponentOrientation((getRootFrame()).getComponentOrientation());
- pane.setMessageType(QUESTION_MESSAGE);
- pane.selectInitialValue();
- final JDialog dialog = pane.createDialog(null, title);
- dialog.setVisible(true);
- dialog.dispose();
- final Object value = pane.getInputValue();
- return (value == UNINITIALIZED_VALUE) ? null : (String) value;
- }
+ public static String showInputDialog(final String title, final Object message, final Object[] options)
+ throws HeadlessException {
+ final JOptionPane pane = new JOptionPane(message, QUESTION_MESSAGE,
+ OK_CANCEL_OPTION, null,
+ options, null);
+ pane.setWantsInput(true);
+ pane.setComponentOrientation((getRootFrame()).getComponentOrientation());
+ pane.setMessageType(QUESTION_MESSAGE);
+ pane.selectInitialValue();
+ final JDialog dialog = pane.createDialog(null, title);
+ dialog.setVisible(true);
+ dialog.dispose();
+ final Object value = pane.getInputValue();
+ return (value == UNINITIALIZED_VALUE) ? null : (String) value;
+ }
}
diff --git a/src/main/java/io/github/arrayv/panes/JErrorPane.java b/src/main/java/io/github/arrayv/panes/JErrorPane.java
index a9571382..00215e84 100644
--- a/src/main/java/io/github/arrayv/panes/JErrorPane.java
+++ b/src/main/java/io/github/arrayv/panes/JErrorPane.java
@@ -12,7 +12,7 @@ public final class JErrorPane extends JOptionPane {
*/
private static final long serialVersionUID = 1L;
- public volatile static boolean errorMessageActive = false;
+ private static volatile boolean errorMessageActive = false;
private static JTextArea createTextArea(String errorMsg) {
JTextArea error = new JTextArea();
@@ -45,4 +45,8 @@ public static void invokeCustomErrorMessage(String errorMsg) {
JOptionPane.showMessageDialog(null, errorMsg, "Error", JOptionPane.ERROR_MESSAGE);
errorMessageActive = false;
}
+
+ public static boolean isErrorMessageActive() {
+ return errorMessageActive;
+ }
}
diff --git a/src/main/java/io/github/arrayv/prompts/ShufflePrompt.java b/src/main/java/io/github/arrayv/prompts/ShufflePrompt.java
index 9d4ad837..ec701f2e 100644
--- a/src/main/java/io/github/arrayv/prompts/ShufflePrompt.java
+++ b/src/main/java/io/github/arrayv/prompts/ShufflePrompt.java
@@ -43,9 +43,9 @@ of this software and associated documentation files (the "Software"), to deal
public final class ShufflePrompt extends javax.swing.JFrame implements AppFrame {
private static final long serialVersionUID = 1L;
- private ArrayManager ArrayManager;
- private JFrame Frame;
- private UtilFrame UtilFrame;
+ private ArrayManager arrayManager;
+ private JFrame frame;
+ private UtilFrame utilFrame;
private DefaultListModel shuffleModel;
private boolean initializing;
@@ -54,32 +54,32 @@ public final class ShufflePrompt extends javax.swing.JFrame implements AppFrame
* Creates new form SortPrompt
*/
@SuppressWarnings("unchecked")
- public ShufflePrompt(ArrayManager ArrayManager, JFrame frame, UtilFrame utilFrame) {
- this.ArrayManager = ArrayManager;
- this.Frame = frame;
- this.UtilFrame = utilFrame;
+ public ShufflePrompt(ArrayManager arrayManager, JFrame frame, UtilFrame utilFrame) {
+ this.arrayManager = arrayManager;
+ this.frame = frame;
+ this.utilFrame = utilFrame;
setAlwaysOnTop(true);
setUndecorated(true);
initComponents();
initializing = true;
- jList1.setListData(ArrayManager.getDistributionIDs());
- for (int i = 0; i < ArrayManager.getDistributions().length; i++) {
- if (ArrayManager.getDistribution().equals(ArrayManager.getDistributions()[i])) {
+ jList1.setListData(arrayManager.getDistributionIDs());
+ for (int i = 0; i < arrayManager.getDistributions().length; i++) {
+ if (arrayManager.getDistribution().equals(arrayManager.getDistributions()[i])) {
jList1.setSelectedIndex(i);
break;
}
}
shuffleModel = new DefaultListModel<>();
jList2.setModel(shuffleModel);
- Arrays.stream(ArrayManager.getShuffleIDs()).forEach(shuffleModel::addElement);
- if (ArrayManager.getShuffle().size() > 1) {
+ Arrays.stream(arrayManager.getShuffleIDs()).forEach(shuffleModel::addElement);
+ if (arrayManager.getShuffle().size() > 1) {
shuffleModel.add(0, "Advanced");
jList2.setSelectedIndex(0);
} else {
- for (int i = 0; i < ArrayManager.getShuffles().length; i++) {
- if (ArrayManager.containsShuffle(ArrayManager.getShuffles()[i])) {
+ for (int i = 0; i < arrayManager.getShuffles().length; i++) {
+ if (arrayManager.containsShuffle(arrayManager.getShuffles()[i])) {
jList2.setSelectedIndex(i);
break;
}
@@ -97,7 +97,7 @@ public ShufflePrompt(ArrayManager ArrayManager, JFrame frame, UtilFrame utilFram
@Override
public void reposition() {
- setLocation(Frame.getX()+(Frame.getWidth()-getWidth())/2,Frame.getY()+(Frame.getHeight()-getHeight())/2);
+ setLocation(frame.getX()+(frame.getWidth()-getWidth())/2, frame.getY()+(frame.getHeight()-getHeight())/2);
}
@@ -164,7 +164,7 @@ public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
@@ -185,9 +185,9 @@ public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
.addGap(20, 20, 20))
.addGroup(javax.swing.GroupLayout.Alignment.CENTER, layout.createSequentialGroup()
.addComponent(this.jButton1)))
- );
+ );
layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
@@ -206,24 +206,24 @@ public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
.addGap(10, 10, 10)
.addComponent(this.jButton1)
.addGap(15, 15, 15))
- );
+ );
pack();
}// //GEN-END:initComponents
private void jButton1ActionPerformed() {//GEN-FIRST:event_jList1ValueChanged
- UtilFrame.jButton6ResetText();
+ utilFrame.jButton6ResetText();
dispose();
- new ShuffleDialog(ArrayManager, this);
+ new ShuffleDialog(arrayManager, this);
}//GEN-LAST:event_jList1ValueChanged
private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) throws Exception {//GEN-FIRST:event_jList1ValueChanged
if (initializing)
return;
int selection = jList1.getSelectedIndex();
- Distributions[] distributions = ArrayManager.getDistributions();
+ Distributions[] distributions = arrayManager.getDistributions();
if (selection >= 0 && selection < distributions.length)
- ArrayManager.setDistribution(distributions[selection]);
+ arrayManager.setDistribution(distributions[selection]);
}//GEN-LAST:event_jList1ValueChanged
private void jList2ValueChanged(javax.swing.event.ListSelectionEvent evt) throws Exception {//GEN-FIRST:event_jList1ValueChanged
@@ -235,9 +235,9 @@ private void jList2ValueChanged(javax.swing.event.ListSelectionEvent evt) throws
shuffleModel.remove(0);
selection--;
}
- Shuffles[] shuffles = ArrayManager.getShuffles();
+ Shuffles[] shuffles = arrayManager.getShuffles();
if (selection >= 0 && selection < shuffles.length)
- ArrayManager.setShuffleSingle(shuffles[selection]);
+ arrayManager.setShuffleSingle(shuffles[selection]);
}//GEN-LAST:event_jList1ValueChanged
// Variables declaration - do not modify//GEN-BEGIN:variables
diff --git a/src/main/java/io/github/arrayv/prompts/SortPrompt.java b/src/main/java/io/github/arrayv/prompts/SortPrompt.java
index 9fc89f09..83ddb96e 100644
--- a/src/main/java/io/github/arrayv/prompts/SortPrompt.java
+++ b/src/main/java/io/github/arrayv/prompts/SortPrompt.java
@@ -112,15 +112,15 @@ public void setPlaceholder(final String s) {
private int[] array;
- private ArrayVisualizer ArrayVisualizer;
- private JFrame Frame;
- private UtilFrame UtilFrame;
+ private ArrayVisualizer arrayVisualizer;
+ private JFrame frame;
+ private UtilFrame utilFrame;
public SortPrompt(int[] array, ArrayVisualizer arrayVisualizer, JFrame frame, UtilFrame utilFrame) {
this.array = array;
- this.ArrayVisualizer = arrayVisualizer;
- this.Frame = frame;
- this.UtilFrame = utilFrame;
+ this.arrayVisualizer = arrayVisualizer;
+ this.frame = frame;
+ this.utilFrame = utilFrame;
setAlwaysOnTop(true);
setUndecorated(true);
@@ -144,21 +144,23 @@ public SortPrompt(int[] array, ArrayVisualizer arrayVisualizer, JFrame frame, Ut
@Override
public void reposition() {
- setLocation(Frame.getX()+(Frame.getWidth()-getWidth())/2,Frame.getY()+(Frame.getHeight()-getHeight())/2);
+ setLocation(frame.getX()+(frame.getWidth()-getWidth())/2, frame.getY()+(frame.getHeight()-getHeight())/2);
}
private void loadSortThreads() {
this.categorySortThreads = new Hashtable<>();
- categorySortThreads.put("Concurrent Sorts", new RunConcurrentSorts (ArrayVisualizer));
- categorySortThreads.put("Distribution Sorts", new RunDistributionSorts (ArrayVisualizer));
- categorySortThreads.put("Exchange Sorts", new RunExchangeSorts (ArrayVisualizer));
- categorySortThreads.put("Hybrid Sorts", new RunHybridSorts (ArrayVisualizer));
- categorySortThreads.put("Impractical Sorts", new RunImpracticalSorts (ArrayVisualizer));
- categorySortThreads.put("Insertion Sorts", new RunInsertionSorts (ArrayVisualizer));
- categorySortThreads.put("Merge Sorts", new RunMergeSorts (ArrayVisualizer));
- categorySortThreads.put("Miscellaneous Sorts", new RunMiscellaneousSorts(ArrayVisualizer));
- categorySortThreads.put("Quick Sorts", new RunQuickSorts (ArrayVisualizer));
- categorySortThreads.put("Selection Sorts", new RunSelectionSorts (ArrayVisualizer));
+ // @checkstyle:off MethodParamPadCheck
+ categorySortThreads.put("Concurrent Sorts", new RunConcurrentSorts (arrayVisualizer));
+ categorySortThreads.put("Distribution Sorts", new RunDistributionSorts (arrayVisualizer));
+ categorySortThreads.put("Exchange Sorts", new RunExchangeSorts (arrayVisualizer));
+ categorySortThreads.put("Hybrid Sorts", new RunHybridSorts (arrayVisualizer));
+ categorySortThreads.put("Impractical Sorts", new RunImpracticalSorts (arrayVisualizer));
+ categorySortThreads.put("Insertion Sorts", new RunInsertionSorts (arrayVisualizer));
+ categorySortThreads.put("Merge Sorts", new RunMergeSorts (arrayVisualizer));
+ categorySortThreads.put("Miscellaneous Sorts", new RunMiscellaneousSorts(arrayVisualizer));
+ categorySortThreads.put("Quick Sorts", new RunQuickSorts (arrayVisualizer));
+ categorySortThreads.put("Selection Sorts", new RunSelectionSorts (arrayVisualizer));
+ // @checkstyle:on MethodParamPadCheck
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -175,22 +177,11 @@ private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jComboBox1.setModel(new DefaultComboBoxModel<>(SortInfo.getCategories(ArrayVisualizer.getSorts())));
+ jComboBox1.setModel(new DefaultComboBoxModel<>(SortInfo.getCategories(arrayVisualizer.getSorts())));
jComboBox1.insertItemAt("All Sorts", 0);
jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
- jList1.setModel(new javax.swing.AbstractListModel() {
-
- private static final long serialVersionUID = 1L;
-
- String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
- @Override
- public int getSize() { return strings.length; }
- @Override
- public Object getElementAt(int i) { return strings[i]; }
- });
-
jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
@Override
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
@@ -249,24 +240,24 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
JPanel extraSortsManagementPanel = new JPanel();
JButton installExtraSortPackButton = new JButton(
- ArrayVisualizer.getSortAnalyzer().extraSortsInstalled() ?
+ arrayVisualizer.getSortAnalyzer().extraSortsInstalled() ?
"Update Extra Sorts Pack" :
"Install Extra Sorts Pack"
);
installExtraSortPackButton.addActionListener(e -> {
- UtilFrame.jButton1ResetText();
- UtilFrame.jButton1Disable();
+ utilFrame.jButton1ResetText();
+ utilFrame.jButton1Disable();
dispose();
new Thread(() -> {
ProgressMonitor installProgress = new ProgressMonitor(
- ArrayVisualizer.getMainWindow(),
+ arrayVisualizer.getMainWindow(),
"Installing...",
"Installing...",
0, 1
);
installProgress.setMillisToDecideToPopup(500);
installProgress.setMillisToPopup(500);
- SortAnalyzer analyzer = ArrayVisualizer.getSortAnalyzer();
+ SortAnalyzer analyzer = arrayVisualizer.getSortAnalyzer();
boolean success;
try {
analyzer.installOrUpdateExtraSorts(installProgress);
@@ -282,21 +273,21 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
analyzer.unloadAllExtraSorts();
analyzer.analyzeSortsExtrasOnly();
analyzer.sortSorts();
- ArrayVisualizer.refreshSorts();
- UtilFrame.jButton1Enable();
+ arrayVisualizer.refreshSorts();
+ utilFrame.jButton1Enable();
JOptionPane.showMessageDialog(
- ArrayVisualizer.getMainWindow(),
+ arrayVisualizer.getMainWindow(),
"Successfully installed and loaded extra sorts pack!",
"Install Extra Sorts Pack",
JOptionPane.INFORMATION_MESSAGE
);
} else {
- UtilFrame.jButton1Enable();
+ utilFrame.jButton1Enable();
}
}, "ExtraSortsInstall").start();
});
extraSortsManagementPanel.add(installExtraSortPackButton);
- if (ArrayVisualizer.getSortAnalyzer().extraSortsInstalled()) {
+ if (arrayVisualizer.getSortAnalyzer().extraSortsInstalled()) {
JCheckBox showExtraSorts = new JCheckBox("Show Extra Sorts");
showExtraSorts.setSelected(SortPrompt.showExtraSorts);
showExtraSorts.addActionListener(e -> {
@@ -330,7 +321,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(extraSortsManagementPanel))
.addGroup(Alignment.CENTER, layout.createSequentialGroup()
.addComponent(this.jButton2))
- );
+ );
layout.setVerticalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -350,7 +341,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(extraSortsManagementPanel)
.addComponent(this.jButton2)
.addGap(5, 5, 5))
- );
+ );
pack();
}// //GEN-END:initComponents
@@ -359,11 +350,11 @@ private void jButton1ActionPerformed() {//GEN-FIRST:event_jButton1ActionPerforme
new Thread("AllSortsThread") {
@Override
public void run(){
- RunAllSorts RunAllSorts = new RunAllSorts(ArrayVisualizer);
- RunAllSorts.reportAllSorts(array);
+ RunAllSorts runAllSorts = new RunAllSorts(arrayVisualizer);
+ runAllSorts.reportAllSorts(array);
}
}.start();
- UtilFrame.jButton1ResetText();
+ utilFrame.jButton1ResetText();
dispose();
}//GEN-LAST:event_jButton1ActionPerformed
@@ -375,10 +366,10 @@ public void run(){
if (f == null) {
return;
}
- ArrayVisualizer.getSortAnalyzer().importSort(f);
+ arrayVisualizer.getSortAnalyzer().importSort(f);
}
}.start();
- UtilFrame.jButton1ResetText();
+ utilFrame.jButton1ResetText();
dispose();
}//GEN-LAST:event_jButton1ActionPerformed
@@ -391,7 +382,7 @@ private void jButton3ActionPerformed() {//GEN-FIRST:event_jButton1ActionPerforme
JErrorPane.invokeErrorMessage(e);
}
}
- UtilFrame.jButton1ResetText();
+ utilFrame.jButton1ResetText();
dispose();
}//GEN-LAST:event_jButton1ActionPerformed
@@ -399,7 +390,7 @@ private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN
@SuppressWarnings("rawtypes")
String sortName = (String)((JList)evt.getSource()).getSelectedValue();
SortInfo sortNotFinal = null;
- for (SortInfo sort : ArrayVisualizer.getSorts()) {
+ for (SortInfo sort : arrayVisualizer.getSorts()) {
if (sort.getListName().equals(sortName)) {
sortNotFinal = sort;
break;
@@ -409,11 +400,11 @@ private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN
new Thread("SortingThread") {
@Override
public void run() {
- RunSort sortThread = new RunSort(ArrayVisualizer);
+ RunSort sortThread = new RunSort(arrayVisualizer);
sortThread.runSort(array, selection.getId());
}
}.start();
- UtilFrame.jButton1ResetText();
+ utilFrame.jButton1ResetText();
dispose();
}//GEN-LAST:event_jList1ValueChanged
@@ -424,7 +415,7 @@ private void loadSorts() {
ArrayList sorts = new ArrayList<>();
String searchTerms = jTextField1.getText().toLowerCase();
boolean isSearching = !searchTerms.isEmpty();
- for (SortInfo sort : ArrayVisualizer.getSorts()) {
+ for (SortInfo sort : arrayVisualizer.getSorts()) {
if (index == 0 || sort.getCategory().equals(category)) {
if (!showExtraSorts && sort.isFromExtra()) continue;
if (isSearching && !sort.getListName().toLowerCase().contains(searchTerms)) continue;
diff --git a/src/main/java/io/github/arrayv/prompts/ViewPrompt.java b/src/main/java/io/github/arrayv/prompts/ViewPrompt.java
index 5f38beed..870b8cf8 100644
--- a/src/main/java/io/github/arrayv/prompts/ViewPrompt.java
+++ b/src/main/java/io/github/arrayv/prompts/ViewPrompt.java
@@ -40,14 +40,14 @@ of this software and associated documentation files (the "Software"), to deal
public final class ViewPrompt extends javax.swing.JFrame implements AppFrame {
private static final long serialVersionUID = 1L;
- private ArrayVisualizer ArrayVisualizer;
- private JFrame Frame;
- private UtilFrame UtilFrame;
+ private ArrayVisualizer arrayVisualizer;
+ private JFrame frame;
+ private UtilFrame utilFrame;
public ViewPrompt(ArrayVisualizer arrayVisualizer, JFrame frame, UtilFrame utilFrame) {
- this.ArrayVisualizer = arrayVisualizer;
- this.Frame = frame;
- this.UtilFrame = utilFrame;
+ this.arrayVisualizer = arrayVisualizer;
+ this.frame = frame;
+ this.utilFrame = utilFrame;
setAlwaysOnTop(true);
setUndecorated(true);
@@ -58,7 +58,7 @@ public ViewPrompt(ArrayVisualizer arrayVisualizer, JFrame frame, UtilFrame utilF
@Override
public void reposition(){
- setLocation(Frame.getX() + ((Frame.getWidth() - getWidth()) / 2), Frame.getY() + ((Frame.getHeight() - getHeight()) / 2));
+ setLocation(frame.getX() + ((frame.getWidth() - getWidth()) / 2), frame.getY() + ((frame.getHeight() - getHeight()) / 2));
}
// //GEN-BEGIN:initComponents
@@ -271,109 +271,103 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
pack();
}// //GEN-END:initComponents
- private void setAllFieldsFalse(){
- ArrayVisualizer.togglePointer(false);
- ArrayVisualizer.toggleDistance(false);
- ArrayVisualizer.togglePixels(false);
- ArrayVisualizer.toggleRainbow(false);
- ArrayVisualizer.toggleSpiral(false);
- ArrayVisualizer.toggleWave(false);
+ private void setAllFieldsFalse() {
}
private void barGraphActionPerformed(java.awt.event.ActionEvent evt) {
setAllFieldsFalse();
- ArrayVisualizer.setVisual(VisualStyles.BARS);
- UtilFrame.jButton2ResetText();
+ arrayVisualizer.setVisual(VisualStyles.BARS);
+ utilFrame.jButton2ResetText();
dispose();
}
private void dotGraphActionPerformed(java.awt.event.ActionEvent evt) {
setAllFieldsFalse();
- ArrayVisualizer.setVisual(VisualStyles.DOTS);
- UtilFrame.jButton2ResetText();
+ arrayVisualizer.setVisual(VisualStyles.DOTS);
+ utilFrame.jButton2ResetText();
dispose();
}
private void rainbowActionPerformed(java.awt.event.ActionEvent evt) {
setAllFieldsFalse();
- ArrayVisualizer.setVisual(VisualStyles.RAINBOW);
- UtilFrame.jButton2ResetText();
+ arrayVisualizer.setVisual(VisualStyles.RAINBOW);
+ utilFrame.jButton2ResetText();
dispose();
}
private void triangleMeshActionPerformed(java.awt.event.ActionEvent evt) {
setAllFieldsFalse();
- ArrayVisualizer.setVisual(VisualStyles.PIXEL_MESH);
- UtilFrame.jButton2ResetText();
+ arrayVisualizer.setVisual(VisualStyles.PIXEL_MESH);
+ utilFrame.jButton2ResetText();
dispose();
}
private void colorCircleActionPerformed(java.awt.event.ActionEvent evt) {
//TODO: Pointer as separate option
setAllFieldsFalse();
- ArrayVisualizer.setVisual(VisualStyles.COLOR_CIRCLE);
- if (ArrayVisualizer.getCurrentLength() == 2) ArrayVisualizer.setCurrentLength(4);
- UtilFrame.jButton2ResetText();
+ arrayVisualizer.setVisual(VisualStyles.COLOR_CIRCLE);
+ if (arrayVisualizer.getCurrentLength() == 2) arrayVisualizer.setCurrentLength(4);
+ utilFrame.jButton2ResetText();
dispose();
}
private void spiralActionPerformed(java.awt.event.ActionEvent evt) {
setAllFieldsFalse();
- ArrayVisualizer.setVisual(VisualStyles.SPIRAL);
- if (ArrayVisualizer.getCurrentLength() == 2) ArrayVisualizer.setCurrentLength(4);
- UtilFrame.jButton2ResetText();
+ arrayVisualizer.setVisual(VisualStyles.SPIRAL);
+ if (arrayVisualizer.getCurrentLength() == 2) arrayVisualizer.setCurrentLength(4);
+ utilFrame.jButton2ResetText();
dispose();
}
private void disparityActionPerformed(java.awt.event.ActionEvent evt) {
setAllFieldsFalse();
- ArrayVisualizer.setVisual(VisualStyles.DISP_CIRCLE);
- if (ArrayVisualizer.getCurrentLength() == 2) ArrayVisualizer.setCurrentLength(4);
- UtilFrame.jButton2ResetText();
+ arrayVisualizer.setVisual(VisualStyles.DISP_CIRCLE);
+ if (arrayVisualizer.getCurrentLength() == 2) arrayVisualizer.setCurrentLength(4);
+ utilFrame.jButton2ResetText();
dispose();
}
private void customImageActionPerformed(java.awt.event.ActionEvent evt) {
setAllFieldsFalse();
- ArrayVisualizer.setVisual(VisualStyles.CUSTOM_IMAGE);
- UtilFrame.jButton2ResetText();
+ arrayVisualizer.setVisual(VisualStyles.CUSTOM_IMAGE);
+ utilFrame.jButton2ResetText();
dispose();
}
private void disparityDotsActionPerformed(java.awt.event.ActionEvent evt) {
setAllFieldsFalse();
- ArrayVisualizer.setVisual(VisualStyles.DISP_DOTS);
- if (ArrayVisualizer.getCurrentLength() == 2) ArrayVisualizer.setCurrentLength(4);
- UtilFrame.jButton2ResetText();
+ arrayVisualizer.setVisual(VisualStyles.DISP_DOTS);
+ if (arrayVisualizer.getCurrentLength() == 2) arrayVisualizer.setCurrentLength(4);
+ utilFrame.jButton2ResetText();
dispose();
}
private void spiralDotsActionPerformed(java.awt.event.ActionEvent evt) {
setAllFieldsFalse();
- ArrayVisualizer.setVisual(VisualStyles.SPIRAL_DOTS);
- if (ArrayVisualizer.getCurrentLength() == 2) ArrayVisualizer.setCurrentLength(4);
- UtilFrame.jButton2ResetText();
+ arrayVisualizer.setVisual(VisualStyles.SPIRAL_DOTS);
+ if (arrayVisualizer.getCurrentLength() == 2) arrayVisualizer.setCurrentLength(4);
+ utilFrame.jButton2ResetText();
dispose();
}
private void sineWaveActionPerformed(java.awt.event.ActionEvent evt) {
setAllFieldsFalse();
- ArrayVisualizer.setVisual(VisualStyles.SINE_WAVE);
- UtilFrame.jButton2ResetText();
+ arrayVisualizer.setVisual(VisualStyles.SINE_WAVE);
+ utilFrame.jButton2ResetText();
dispose();
}
private void waveDotsActionPerformed(java.awt.event.ActionEvent evt) {
setAllFieldsFalse();
- ArrayVisualizer.setVisual(VisualStyles.WAVE_DOTS);
- UtilFrame.jButton2ResetText();
+ arrayVisualizer.setVisual(VisualStyles.WAVE_DOTS);
+ utilFrame.jButton2ResetText();
dispose();
}
private void hoopStackActionPerformed(java.awt.event.ActionEvent evt) {
setAllFieldsFalse();
- ArrayVisualizer.setVisual(VisualStyles.HOOP_STACK);
- UtilFrame.jButton2ResetText();
+ arrayVisualizer.setVisual(VisualStyles.HOOP_STACK);
+ utilFrame.jButton2ResetText();
dispose();
}
private void disparityBarGraphActionPerformed(java.awt.event.ActionEvent evt) {
setAllFieldsFalse();
- ArrayVisualizer.setVisual(VisualStyles.DISP_BARS);
- UtilFrame.jButton2ResetText();
+ arrayVisualizer.setVisual(VisualStyles.DISP_BARS);
+ utilFrame.jButton2ResetText();
dispose();
}
private void disparityChordsActionPerformed(java.awt.event.ActionEvent evt) {
setAllFieldsFalse();
- ArrayVisualizer.setVisual(VisualStyles.DISP_CHORDS);
- UtilFrame.jButton2ResetText();
+ arrayVisualizer.setVisual(VisualStyles.DISP_CHORDS);
+ utilFrame.jButton2ResetText();
dispose();
}
diff --git a/src/main/java/io/github/arrayv/threads/RunConcurrentSorts.java b/src/main/java/io/github/arrayv/threads/RunConcurrentSorts.java
index 78b33b9b..a6d78c94 100644
--- a/src/main/java/io/github/arrayv/threads/RunConcurrentSorts.java
+++ b/src/main/java/io/github/arrayv/threads/RunConcurrentSorts.java
@@ -54,6 +54,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class RunConcurrentSorts extends MultipleSortThread {
+ // @checkstyle:off MemberNameCheck
private Sort FoldSort;
private Sort CreaseSort;
private Sort MatrixSort;
@@ -76,6 +77,7 @@ public final class RunConcurrentSorts extends MultipleSortThread {
private Sort PairwiseMergeSortIterative;
private Sort PairwiseMergeSortRecursive;
private Sort WeaveSortParallel;
+ // @checkstyle:on MemberNameCheck
public RunConcurrentSorts(ArrayVisualizer arrayVisualizer) {
super(arrayVisualizer);
diff --git a/src/main/java/io/github/arrayv/threads/RunDistributionSorts.java b/src/main/java/io/github/arrayv/threads/RunDistributionSorts.java
index 3a60d2bc..90ae1dd1 100644
--- a/src/main/java/io/github/arrayv/threads/RunDistributionSorts.java
+++ b/src/main/java/io/github/arrayv/threads/RunDistributionSorts.java
@@ -51,6 +51,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class RunDistributionSorts extends MultipleSortThread {
+ // @checkstyle:off MemberNameCheck
private Sort CountingSort;
private Sort PigeonholeSort;
private Sort OptimizedPigeonholeSort;
@@ -70,6 +71,7 @@ public final class RunDistributionSorts extends MultipleSortThread {
private Sort TimeSort;
private Sort StacklessAmericanFlagSort;
private Sort StacklessBinaryQuickSort;
+ // @checkstyle:on MemberNameCheck
public RunDistributionSorts(ArrayVisualizer arrayVisualizer) {
super(arrayVisualizer);
diff --git a/src/main/java/io/github/arrayv/threads/RunExchangeSorts.java b/src/main/java/io/github/arrayv/threads/RunExchangeSorts.java
index 11c9b9c5..27c5332a 100644
--- a/src/main/java/io/github/arrayv/threads/RunExchangeSorts.java
+++ b/src/main/java/io/github/arrayv/threads/RunExchangeSorts.java
@@ -62,6 +62,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class RunExchangeSorts extends MultipleSortThread {
+ // @checkstyle:off MemberNameCheck
private Sort UnoptimizedBubbleSort;
private Sort BubbleSort;
private Sort UnoptimizedCocktailShakerSort;
@@ -91,6 +92,7 @@ public final class RunExchangeSorts extends MultipleSortThread {
private Sort StableQuickSortParallel;
private Sort ThreeSmoothCombSortParallel;
private Sort SlopeSort;
+ // @checkstyle:on MemberNameCheck
public RunExchangeSorts(ArrayVisualizer arrayVisualizer) {
super(arrayVisualizer);
diff --git a/src/main/java/io/github/arrayv/threads/RunHybridSorts.java b/src/main/java/io/github/arrayv/threads/RunHybridSorts.java
index 66a19cef..5b09fee9 100644
--- a/src/main/java/io/github/arrayv/threads/RunHybridSorts.java
+++ b/src/main/java/io/github/arrayv/threads/RunHybridSorts.java
@@ -65,6 +65,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class RunHybridSorts extends MultipleSortThread {
+ // @checkstyle:off MemberNameCheck
private Sort HybridCombSort;
private Sort IntroCircleSortRecursive;
private Sort IntroCircleSortIterative;
@@ -97,6 +98,7 @@ public final class RunHybridSorts extends MultipleSortThread {
private Sort RemiSort;
private Sort StacklessDualPivotQuickSort;
private Sort AdaptiveGrailSort;
+ // @checkstyle:on MemberNameCheck
public RunHybridSorts(ArrayVisualizer arrayVisualizer) {
super(arrayVisualizer);
diff --git a/src/main/java/io/github/arrayv/threads/RunImpracticalSorts.java b/src/main/java/io/github/arrayv/threads/RunImpracticalSorts.java
index 14079926..44189012 100644
--- a/src/main/java/io/github/arrayv/threads/RunImpracticalSorts.java
+++ b/src/main/java/io/github/arrayv/threads/RunImpracticalSorts.java
@@ -56,6 +56,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class RunImpracticalSorts extends MultipleSortThread {
+ // @checkstyle:off MemberNameCheck
private Sort BadSort;
private Sort StoogeSort;
private Sort SillySort;
@@ -80,6 +81,7 @@ public final class RunImpracticalSorts extends MultipleSortThread {
private Sort GuessSort;
private Sort BogoBogoSort;
private Sort QuadStoogeSort;
+ // @checkstyle:on MemberNameCheck
public RunImpracticalSorts(ArrayVisualizer arrayVisualizer) {
super(arrayVisualizer);
diff --git a/src/main/java/io/github/arrayv/threads/RunInsertionSorts.java b/src/main/java/io/github/arrayv/threads/RunInsertionSorts.java
index 98be6ea7..739a79b3 100644
--- a/src/main/java/io/github/arrayv/threads/RunInsertionSorts.java
+++ b/src/main/java/io/github/arrayv/threads/RunInsertionSorts.java
@@ -48,6 +48,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class RunInsertionSorts extends MultipleSortThread {
+ // @checkstyle:off MemberNameCheck
private Sort InsertionSort;
private Sort DoubleInsertionSort;
private Sort BinaryInsertionSort;
@@ -62,6 +63,7 @@ public final class RunInsertionSorts extends MultipleSortThread {
private Sort LibrarySort;
private Sort ShellSortParallel;
private Sort TreeSort;
+ // @checkstyle:on MemberNameCheck
public RunInsertionSorts(ArrayVisualizer arrayVisualizer) {
super(arrayVisualizer);
diff --git a/src/main/java/io/github/arrayv/threads/RunMergeSorts.java b/src/main/java/io/github/arrayv/threads/RunMergeSorts.java
index 8a0000d9..e62b5728 100644
--- a/src/main/java/io/github/arrayv/threads/RunMergeSorts.java
+++ b/src/main/java/io/github/arrayv/threads/RunMergeSorts.java
@@ -50,6 +50,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class RunMergeSorts extends MultipleSortThread {
+ // @checkstyle:off MemberNameCheck
private Sort MergeSort;
private Sort BottomUpMergeSort;
private Sort TwinSort;
@@ -67,6 +68,7 @@ public final class RunMergeSorts extends MultipleSortThread {
private Sort NewShuffleMergeSort;
private Sort RotateMergeSortParallel;
private Sort WeavedMergeSort;
+ // @checkstyle:on MemberNameCheck
public RunMergeSorts(ArrayVisualizer arrayVisualizer) {
super(arrayVisualizer);
diff --git a/src/main/java/io/github/arrayv/threads/RunMiscellaneousSorts.java b/src/main/java/io/github/arrayv/threads/RunMiscellaneousSorts.java
index 6b0c0e8a..670ba7d7 100644
--- a/src/main/java/io/github/arrayv/threads/RunMiscellaneousSorts.java
+++ b/src/main/java/io/github/arrayv/threads/RunMiscellaneousSorts.java
@@ -35,8 +35,10 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class RunMiscellaneousSorts extends MultipleSortThread {
+ // @checkstyle:off MemberNameCheck
private Sort PancakeSort;
private Sort BurntPancakeSort;
+ // @checkstyle:on MemberNameCheck
public RunMiscellaneousSorts(ArrayVisualizer arrayVisualizer) {
super(arrayVisualizer);
diff --git a/src/main/java/io/github/arrayv/threads/RunScriptedSorts.java b/src/main/java/io/github/arrayv/threads/RunScriptedSorts.java
index 88f8ea08..a857818b 100644
--- a/src/main/java/io/github/arrayv/threads/RunScriptedSorts.java
+++ b/src/main/java/io/github/arrayv/threads/RunScriptedSorts.java
@@ -50,12 +50,12 @@ protected synchronized void executeSortList(int[] array) throws Exception {
protected synchronized void executeSortList(MultipleScript.ScriptCommand[] commands, int[] array) throws Exception {
for (MultipleScript.ScriptCommand command : commands) {
- if (command.type == MultipleScript.ScriptCommand.CommandType.SetCategory) {
- String category = (String)command.argument;
+ if (command.getType() == MultipleScript.ScriptCommand.CommandType.SetCategory) {
+ String category = (String)command.getArgument();
RunScriptedSorts.this.currentCategory = category;
arrayVisualizer.setCategory(category);
- } else if (command.type == MultipleScript.ScriptCommand.CommandType.SortCall) {
- MultipleScript.SortCallInfo info = (MultipleScript.SortCallInfo)command.argument;
+ } else if (command.getType() == MultipleScript.ScriptCommand.CommandType.SortCall) {
+ MultipleScript.SortCallInfo info = (MultipleScript.SortCallInfo)command.getArgument();
RunScriptedSorts.this.runIndividualSort(
info.getAlgortitm(),
info.getBucketCount(),
@@ -85,7 +85,7 @@ public void run() {
int sortCount = 0;
for (MultipleScript.ScriptCommand command : commands) {
- if (command.type == MultipleScript.ScriptCommand.CommandType.SortCall) {
+ if (command.getType() == MultipleScript.ScriptCommand.CommandType.SortCall) {
sortCount++;
}
}
diff --git a/src/main/java/io/github/arrayv/threads/RunSelectionSorts.java b/src/main/java/io/github/arrayv/threads/RunSelectionSorts.java
index dbbeaaaf..7e78e42b 100644
--- a/src/main/java/io/github/arrayv/threads/RunSelectionSorts.java
+++ b/src/main/java/io/github/arrayv/threads/RunSelectionSorts.java
@@ -51,6 +51,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class RunSelectionSorts extends MultipleSortThread {
+ // @checkstyle:off MemberNameCheck
private Sort SelectionSort;
private Sort DoubleSelectionSort;
private Sort CycleSort;
@@ -69,6 +70,7 @@ public final class RunSelectionSorts extends MultipleSortThread {
private Sort ClassicTournamentSort;
private Sort StableCycleSort;
private Sort TriangularHeapSort;
+ // @checkstyle:on MemberNameCheck
public RunSelectionSorts(ArrayVisualizer arrayVisualizer) {
super(arrayVisualizer);
diff --git a/src/main/java/io/github/arrayv/threads/RunSort.java b/src/main/java/io/github/arrayv/threads/RunSort.java
index 4ce53277..f8814398 100644
--- a/src/main/java/io/github/arrayv/threads/RunSort.java
+++ b/src/main/java/io/github/arrayv/threads/RunSort.java
@@ -196,7 +196,7 @@ public void run() {
if (warning == 0) goAhead = true;
else goAhead = false;
}
- }
+ }
} else {
goAhead = true;
}
@@ -229,7 +229,7 @@ public void run() {
if (antiq)
arrayVisualizer.finishAntiQSort(sort.getClass().getSimpleName());
else if (networks) {
- ArrayList indicesList = arrayVisualizer.getReads().networkIndices;
+ ArrayList indicesList = arrayVisualizer.getReads().getNetworkIndices();
SortingNetworkGenerator.encodeNetworkAndDisplay(
sort.getClass().getSimpleName(),
indicesList,
diff --git a/src/main/java/io/github/arrayv/utils/ArrayFileWriter.java b/src/main/java/io/github/arrayv/utils/ArrayFileWriter.java
index 9de3c922..861201f6 100644
--- a/src/main/java/io/github/arrayv/utils/ArrayFileWriter.java
+++ b/src/main/java/io/github/arrayv/utils/ArrayFileWriter.java
@@ -7,6 +7,9 @@
import io.github.arrayv.panes.JErrorPane;
public final class ArrayFileWriter {
+ private ArrayFileWriter() {
+ }
+
public static boolean writeArray(String fileName, int[] array, int length) {
try {
FileWriter writer = new FileWriter(fileName);
diff --git a/src/main/java/io/github/arrayv/utils/ArrayVList.java b/src/main/java/io/github/arrayv/utils/ArrayVList.java
index 3de58aa2..fd67f7d5 100644
--- a/src/main/java/io/github/arrayv/utils/ArrayVList.java
+++ b/src/main/java/io/github/arrayv/utils/ArrayVList.java
@@ -17,12 +17,14 @@
import io.github.arrayv.main.ArrayVisualizer;
public class ArrayVList extends AbstractList implements RandomAccess, Cloneable, java.io.Serializable {
- final static int DEFAULT_CAPACITY = 128;
- final static double DEFAULT_GROW_FACTOR = 2;
-
- static ArrayVisualizer arrayVisualizer;
- static Reads Reads;
- static Writes Writes;
+ private static final int DEFAULT_CAPACITY = 128;
+ private static final double DEFAULT_GROW_FACTOR = 2;
+
+ private static ArrayVisualizer arrayVisualizer;
+ // @checkstyle:off StaticVariableNameCheck
+ private static Reads Reads;
+ private static Writes Writes;
+ // @checkstyle:on StaticVariableNameCheck
int[] internal;
double growFactor;
diff --git a/src/main/java/io/github/arrayv/utils/Delays.java b/src/main/java/io/github/arrayv/utils/Delays.java
index 922af451..f7e1773f 100644
--- a/src/main/java/io/github/arrayv/utils/Delays.java
+++ b/src/main/java/io/github/arrayv/utils/Delays.java
@@ -32,8 +32,8 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class Delays {
- private volatile double SLEEPRATIO;
- private volatile boolean SKIPPED;
+ private volatile double sleepRatio;
+ private volatile boolean skipped;
private double delay;
@@ -45,15 +45,15 @@ public final class Delays {
private Sounds Sounds;
public Delays(ArrayVisualizer arrayVisualizer) {
- this.SLEEPRATIO = 1.0;
- this.SKIPPED = false;
+ this.sleepRatio = 1.0;
+ this.skipped = false;
this.formatter = arrayVisualizer.getNumberFormat();
this.Sounds = arrayVisualizer.getSounds();
}
public String displayCurrentDelay() {
- if (this.SKIPPED)
+ if (this.skipped)
return "Canceled";
if (this.paused)
return "Paused";
@@ -94,26 +94,26 @@ public void updateDelayForTimeSort(double value) {
}
public double getSleepRatio() {
- return this.SLEEPRATIO;
+ return this.sleepRatio;
}
public void setSleepRatio(double sleepRatio) {
- this.SLEEPRATIO = sleepRatio;
+ this.sleepRatio = sleepRatio;
}
public boolean skipped() {
- return this.SKIPPED;
+ return this.skipped;
}
- public void changeSkipped(boolean Bool) {
- this.SKIPPED = Bool;
- if (this.SKIPPED) this.Sounds.changeNoteDelayAndFilter(1);
+ public void changeSkipped(boolean skipped) {
+ this.skipped = skipped;
+ if (this.skipped) this.Sounds.changeNoteDelayAndFilter(1);
}
public boolean paused() {
return this.paused;
}
- public void changePaused(boolean Bool) {
- this.paused = Bool;
- this.Sounds.toggleSound(!Bool);
+ public void changePaused(boolean paused) {
+ this.paused = paused;
+ this.Sounds.toggleSound(!paused);
}
public void togglePaused() {
this.changePaused(!this.paused);;
@@ -124,14 +124,14 @@ public void sleep(double millis) {
return;
}
- this.delay += (millis * (1 / this.SLEEPRATIO));
- this.currentDelay = (millis * (1 / this.SLEEPRATIO));
+ this.delay += (millis * (1 / this.sleepRatio));
+ this.currentDelay = (millis * (1 / this.sleepRatio));
this.Sounds.changeNoteDelayAndFilter((int) this.currentDelay);
try {
// With this for loop, you can change the speed of sorts without waiting for the current delay to finish.
- if (!this.SKIPPED) {
+ if (!this.skipped) {
while (this.paused || this.delay >= 1) {
Thread.sleep(1);
if (!this.paused)
diff --git a/src/main/java/io/github/arrayv/utils/Distributions.java b/src/main/java/io/github/arrayv/utils/Distributions.java
index 91a9ae00..73bdfa3d 100644
--- a/src/main/java/io/github/arrayv/utils/Distributions.java
+++ b/src/main/java/io/github/arrayv/utils/Distributions.java
@@ -43,8 +43,8 @@ public String getName() {
return "Linear";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
for (int i = 0; i < currentLen; i++)
array[i] = i;
@@ -55,8 +55,8 @@ public String getName() {
return "Few Unique";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
Random random = new Random();
int l = 0, r, t = Math.min(currentLen, 8);
@@ -75,8 +75,8 @@ public String getName() {
return "No Unique";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int val = currentLen / 2;
for (int i = 0; i < currentLen; i++) {
@@ -89,8 +89,8 @@ public String getName() {
return "Random";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
Random random = new Random();
for (int i = 0; i < currentLen; i++)
@@ -102,8 +102,8 @@ public String getName() {
return "Quadratic";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
for (int i = 0; i < currentLen; i++)
array[i] = (int)(Math.pow(i, 2)/currentLen);
@@ -114,8 +114,8 @@ public String getName() {
return "Square Root";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
for (int i = 0; i < currentLen; i++)
array[i] = (int)(Math.sqrt(i)*Math.sqrt(currentLen));
@@ -126,8 +126,8 @@ public String getName() {
return "Cubic (Centered)";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int power = 3;
double mid = (currentLen-1)/2d;
@@ -140,8 +140,8 @@ public String getName() {
return "Quintic (Centered)";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int power = 5;
double mid = (currentLen-1)/2d;
@@ -154,8 +154,8 @@ public String getName() {
return "Cube Root (Centered)";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int p = 3;
double h = currentLen/2d;
@@ -172,8 +172,8 @@ public String getName() {
return "Fifth Root (Centered)";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int p = 5;
double h = currentLen/2d;
@@ -190,8 +190,8 @@ public String getName() {
return "Sine Wave";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int n = currentLen-1;
double c = 2*Math.PI/n;
@@ -204,8 +204,8 @@ public String getName() {
return "Cosine Wave";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int n = currentLen-1;
double c = 2*Math.PI/n;
@@ -218,8 +218,8 @@ public String getName() {
return "Perlin Noise";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
Random random = new Random();
int[] perlinNoise = new int[currentLen];
@@ -268,8 +268,8 @@ public String getName() {
return "Perlin Noise Curve";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
for (int i = 0; i < currentLen; i++) {
int value = 0 - (int) (PerlinNoise.returnNoise((float) i / currentLen) * currentLen);
@@ -282,8 +282,8 @@ public String getName() {
return "Bell Curve";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
double step = 8d / currentLen;
double position = -4;
int constant = 1264;
@@ -308,8 +308,8 @@ public String getName() {
return "Ruler";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int step = Math.max(1, currentLen/256);
int floorLog2 = (int)(Math.log(currentLen/step)/Math.log(2));
int lowest;
@@ -342,8 +342,8 @@ public String getName() {
return "Blancmange Curve";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int floorLog2 = (int)(Math.log(currentLen)/Math.log(2));
for (int i = 0; i < currentLen; i++) {
@@ -372,8 +372,8 @@ public String getName() {
return "Cantor Function";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
cantor(array, 0, currentLen, 0, currentLen-1);
}
@@ -401,8 +401,8 @@ public String getName() {
return "Sum of Divisors";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int[] n = new int[currentLen];
n[0] = 0;
@@ -436,8 +436,8 @@ public String getName() {
return "Fly Straight, Damnit!";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int[] fsd = new int[currentLen];
double max;
@@ -455,7 +455,7 @@ public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
public int gcd(int a, int b) {
if (b==0) return a;
- return gcd(b,a%b);
+ return gcd(b, a%b);
}
},
REVLOG {
@@ -463,8 +463,8 @@ public String getName() {
return "Decreasing Random";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
Random random = new Random();
for (int i = 0; i < currentLen; i++){
@@ -478,8 +478,8 @@ public String getName() {
return "Modulo Function";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int n = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int n = arrayVisualizer.getCurrentLength();
for (int i = 0; i < n; i++) array[i] = 2*(n%(i+1));
}
@@ -490,8 +490,8 @@ public String getName() {
return "Euler Totient Function";
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int n = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int n = arrayVisualizer.getCurrentLength();
int[] minPrimeFactors = new int[n];
List primes = new ArrayList();
@@ -526,7 +526,7 @@ public String getName() {
return "Custom";
}
@Override
- public void selectDistribution(int[] array, ArrayVisualizer ArrayVisualizer) {
+ public void selectDistribution(int[] array, ArrayVisualizer arrayVisualizer) {
LoadCustomDistributionDialog dialog = new LoadCustomDistributionDialog();
File file = dialog.getFile();
Scanner scanner;
@@ -537,7 +537,7 @@ public void selectDistribution(int[] array, ArrayVisualizer ArrayVisualizer) {
return;
}
scanner.useDelimiter("\\s+");
- this.refarray = new int[ArrayVisualizer.getMaximumLength()];
+ this.refarray = new int[arrayVisualizer.getMaximumLength()];
int current = 0;
while (scanner.hasNext()) {
this.refarray[current++] = Integer.parseInt(scanner.next());
@@ -546,8 +546,8 @@ public void selectDistribution(int[] array, ArrayVisualizer ArrayVisualizer) {
scanner.close();
}
@Override
- public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void initializeArray(int[] array, ArrayVisualizer arrayVisualizer) {
+ int currentLen = arrayVisualizer.getCurrentLength();
double scale = (double)this.length / currentLen;
for (int i = 0; i < currentLen; i++) {
array[i] = (int)(this.refarray[(int)(i * scale)] / scale);
@@ -556,7 +556,7 @@ public void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer) {
};
public abstract String getName();
- public void selectDistribution(int[] array, ArrayVisualizer ArrayVisualizer) {
+ public void selectDistribution(int[] array, ArrayVisualizer arrayVisualizer) {
}
- public abstract void initializeArray(int[] array, ArrayVisualizer ArrayVisualizer);
+ public abstract void initializeArray(int[] array, ArrayVisualizer arrayVisualizer);
}
diff --git a/src/main/java/io/github/arrayv/utils/Highlights.java b/src/main/java/io/github/arrayv/utils/Highlights.java
index 0aba07b5..551fa68e 100644
--- a/src/main/java/io/github/arrayv/utils/Highlights.java
+++ b/src/main/java/io/github/arrayv/utils/Highlights.java
@@ -55,14 +55,14 @@ public final class Highlights {
private volatile int markCount;
- private boolean FANCYFINISH;
+ private boolean showFancyFinishes;
private volatile boolean fancyFinish;
private volatile int trackFinish;
- private ArrayVisualizer ArrayVisualizer;
+ private ArrayVisualizer arrayVisualizer;
- public Highlights(ArrayVisualizer ArrayVisualizer, int maximumLength) {
- this.ArrayVisualizer = ArrayVisualizer;
+ public Highlights(ArrayVisualizer arrayVisualizer, int maximumLength) {
+ this.arrayVisualizer = arrayVisualizer;
try {
this.highlights = new int[maximumLength];
@@ -71,7 +71,7 @@ public Highlights(ArrayVisualizer ArrayVisualizer, int maximumLength) {
JErrorPane.invokeCustomErrorMessage("Failed to allocate mark arrays. The program will now exit.");
System.exit(1);
}
- this.FANCYFINISH = true;
+ this.showFancyFinishes = true;
this.maxHighlightMarked = 0;
this.markCount = 0;
@@ -80,17 +80,17 @@ public Highlights(ArrayVisualizer ArrayVisualizer, int maximumLength) {
}
public boolean fancyFinishEnabled() {
- return this.FANCYFINISH;
+ return this.showFancyFinishes;
}
- public void toggleFancyFinishes(boolean Bool) {
- this.FANCYFINISH = Bool;
+ public void toggleFancyFinishes(boolean showFancyFinishes) {
+ this.showFancyFinishes = showFancyFinishes;
}
public boolean fancyFinishActive() {
return this.fancyFinish;
}
- public void toggleFancyFinish(boolean Bool) {
- this.fancyFinish = Bool;
+ public void toggleFancyFinish(boolean fancyFinish) {
+ this.fancyFinish = fancyFinish;
}
public int getFancyFinishPosition() {
@@ -103,8 +103,8 @@ public void resetFancyFinish() {
this.trackFinish = -1; // Magic number that clears the green sweep animation
}
- public void toggleAnalysis(boolean Bool) {
- this.ArrayVisualizer.toggleAnalysis(Bool);
+ public void toggleAnalysis(boolean analysis) {
+ this.arrayVisualizer.toggleAnalysis(analysis);
}
public int getMaxHighlight() {
@@ -172,7 +172,7 @@ public synchronized void markArray(int marker, int markPosition) {
} catch (Exception e) {
e.printStackTrace();
}
- ArrayVisualizer.updateNow();
+ arrayVisualizer.updateNow();
}
public synchronized void clearMark(int marker) {
if (highlights[marker] == -1) {
@@ -187,7 +187,7 @@ public synchronized void clearMark(int marker) {
maxHighlightMarked--;
}
}
- ArrayVisualizer.updateNow();
+ arrayVisualizer.updateNow();
}
public synchronized void clearAllMarks() {
for (int i = 0; i < this.maxHighlightMarked; i++) {
@@ -198,6 +198,6 @@ public synchronized void clearAllMarks() {
Arrays.fill(this.highlights, 0, this.maxHighlightMarked, -1);
this.maxHighlightMarked = 0;
this.markCount = 0;
- ArrayVisualizer.updateNow();
+ arrayVisualizer.updateNow();
}
}
diff --git a/src/main/java/io/github/arrayv/utils/IndexedRotations.java b/src/main/java/io/github/arrayv/utils/IndexedRotations.java
index 6c44c1c0..098209f1 100644
--- a/src/main/java/io/github/arrayv/utils/IndexedRotations.java
+++ b/src/main/java/io/github/arrayv/utils/IndexedRotations.java
@@ -1,6 +1,9 @@
package io.github.arrayv.utils;
-public class IndexedRotations {
+public final class IndexedRotations {
+ private IndexedRotations() {
+ }
+
public static void griesMills(int[] array, int start, int mid, int end, double pause, boolean mark, boolean auxwrite) {
Rotations.griesMills(array, start, mid - start, end - mid, pause, mark, auxwrite);
}
diff --git a/src/main/java/io/github/arrayv/utils/MultipleScript.java b/src/main/java/io/github/arrayv/utils/MultipleScript.java
index 9b0e9069..04a5a6ca 100644
--- a/src/main/java/io/github/arrayv/utils/MultipleScript.java
+++ b/src/main/java/io/github/arrayv/utils/MultipleScript.java
@@ -13,18 +13,26 @@
public final class MultipleScript {
public static class ScriptCommand {
- public static enum CommandType {
+ public enum CommandType {
SortCall,
SetCategory
}
- public CommandType type;
- public Object argument;
+ private final CommandType type;
+ private final Object argument;
public ScriptCommand(CommandType type, Object argument) {
this.type = type;
this.argument = argument;
}
+
+ public CommandType getType() {
+ return type;
+ }
+
+ public Object getArgument() {
+ return argument;
+ }
}
public static class SortCallInfo {
diff --git a/src/main/java/io/github/arrayv/utils/PerlinNoise.java b/src/main/java/io/github/arrayv/utils/PerlinNoise.java
index 5c011fdb..d425ccd4 100644
--- a/src/main/java/io/github/arrayv/utils/PerlinNoise.java
+++ b/src/main/java/io/github/arrayv/utils/PerlinNoise.java
@@ -1,25 +1,25 @@
package io.github.arrayv.utils;
// MASSIVE thanks to https://github.com/keijiro/PerlinNoise
-public class PerlinNoise {
- final private static int[] perm = {
- 151,160,137,91,90,15,
- 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
- 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
- 88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
- 77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
- 102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
- 135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
- 5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
- 223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9,
- 129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
- 251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
- 49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254,
- 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180,
- 151
- };
+public final class PerlinNoise {
+ private static final int[] PERM = {
+ 151, 160, 137, 91, 90, 15,
+ 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23,
+ 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33,
+ 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166,
+ 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244,
+ 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196,
+ 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123,
+ 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42,
+ 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9,
+ 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228,
+ 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107,
+ 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254,
+ 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180,
+ 151
+ };
- public PerlinNoise() {
+ private PerlinNoise() {
}
private static float fade(float t) {
@@ -30,8 +30,7 @@ private static float grad(int hash, float x) {
return (hash & 1) == 0 ? x : -x;
}
- private static float lerp(float t, float a, float b)
- {
+ private static float lerp(float t, float a, float b) {
return a + t * (b - a);
}
@@ -39,11 +38,10 @@ public static float returnNoise(float x) {
int index = ((int) Math.floor(x)) & 0xff;
x -= Math.floor(x);
float u = fade(x);
- return lerp(u, grad(perm[index], x), grad(perm[index + 1], x - 1)) * 2;
+ return lerp(u, grad(PERM[index], x), grad(PERM[index + 1], x - 1)) * 2;
}
- public static float returnFracBrownNoise(float x, int octave)
- {
+ public static float returnFracBrownNoise(float x, int octave) {
float f = 0.0f;
float w = 0.5f;
for (int i = 0; i < octave; i++) {
diff --git a/src/main/java/io/github/arrayv/utils/Reads.java b/src/main/java/io/github/arrayv/utils/Reads.java
index 0bf3aa99..3ed8a064 100644
--- a/src/main/java/io/github/arrayv/utils/Reads.java
+++ b/src/main/java/io/github/arrayv/utils/Reads.java
@@ -33,9 +33,9 @@ of this software and associated documentation files (the "Software"), to deal
public final class Reads {
private volatile long comparisons;
- public volatile ArrayList networkIndices;
+ private volatile ArrayList networkIndices;
- private ArrayVisualizer ArrayVisualizer;
+ private ArrayVisualizer arrayVisualizer;
private DecimalFormat formatter;
@@ -44,16 +44,16 @@ public final class Reads {
private Timer Timer;
public Reads(ArrayVisualizer arrayVisualizer) {
- this.ArrayVisualizer = arrayVisualizer;
+ this.arrayVisualizer = arrayVisualizer;
this.comparisons = 0;
this.networkIndices = new ArrayList<>();
- this.Delays = ArrayVisualizer.getDelays();
- this.Highlights = ArrayVisualizer.getHighlights();
- this.Timer = ArrayVisualizer.getTimer();
+ this.Delays = arrayVisualizer.getDelays();
+ this.Highlights = arrayVisualizer.getHighlights();
+ this.Timer = arrayVisualizer.getTimer();
- this.formatter = ArrayVisualizer.getNumberFormat();
+ this.formatter = arrayVisualizer.getNumberFormat();
}
public void resetStatistics() {
@@ -83,12 +83,12 @@ public void setComparisons(long value) {
}
public int compareValues(int left, int right) {
- if (ArrayVisualizer.sortCanceled()) throw new StopSort();
+ if (arrayVisualizer.sortCanceled()) throw new StopSort();
this.comparisons++;
- if (ArrayVisualizer.doingStabilityCheck()) {
- left = ArrayVisualizer.getStabilityValue(left);
- right = ArrayVisualizer.getStabilityValue(right);
+ if (arrayVisualizer.doingStabilityCheck()) {
+ left = arrayVisualizer.getStabilityValue(left);
+ right = arrayVisualizer.getStabilityValue(right);
}
int cmpVal = 0;
@@ -101,18 +101,18 @@ public int compareValues(int left, int right) {
Timer.stopLap();
- if (!ArrayVisualizer.useAntiQSort()) {
- if (ArrayVisualizer.reversedComparator()) {
+ if (!arrayVisualizer.useAntiQSort()) {
+ if (arrayVisualizer.reversedComparator()) {
return -cmpVal;
}
return cmpVal;
} else {
- return ArrayVisualizer.antiqCompare(left, right);
+ return arrayVisualizer.antiqCompare(left, right);
}
}
public int compareOriginalValues(int left, int right) {
- if (ArrayVisualizer.sortCanceled()) throw new StopSort();
+ if (arrayVisualizer.sortCanceled()) throw new StopSort();
this.comparisons++;
int cmpVal = 0;
@@ -134,7 +134,7 @@ public int compareIndices(int[] array, int left, int right, double sleep, boolea
Highlights.markArray(2, right);
Delays.sleep(sleep);
}
- if (ArrayVisualizer.generateSortingNetworks()) {
+ if (arrayVisualizer.generateSortingNetworks()) {
networkIndices.add(left);
networkIndices.add(right);
}
@@ -183,17 +183,17 @@ public int compareOriginalValueIndex(int[] array, int value, int index, double s
}
public int analyzeMax(int[] array, int length, double sleep, boolean mark) {
- ArrayVisualizer.toggleAnalysis(true);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.toggleAnalysis(true);
+ arrayVisualizer.updateNow();
int max = 0;
for (int i = 0; i < length; i++) {
- if (ArrayVisualizer.sortCanceled()) throw new StopSort();
+ if (arrayVisualizer.sortCanceled()) throw new StopSort();
int val = array[i];
- if (ArrayVisualizer.doingStabilityCheck())
- val = ArrayVisualizer.getStabilityValue(val);
+ if (arrayVisualizer.doingStabilityCheck())
+ val = arrayVisualizer.getStabilityValue(val);
Timer.startLap("Analysis");
@@ -207,24 +207,24 @@ public int analyzeMax(int[] array, int length, double sleep, boolean mark) {
}
}
- ArrayVisualizer.toggleAnalysis(false);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.toggleAnalysis(false);
+ arrayVisualizer.updateNow();
return max;
}
public int analyzeMin(int[] array, int length, double sleep, boolean mark) {
- ArrayVisualizer.toggleAnalysis(true);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.toggleAnalysis(true);
+ arrayVisualizer.updateNow();
int min = 0;
for (int i = 0; i < length; i++) {
- if (ArrayVisualizer.sortCanceled()) throw new StopSort();
+ if (arrayVisualizer.sortCanceled()) throw new StopSort();
int val = array[i];
- if (ArrayVisualizer.doingStabilityCheck())
- val = ArrayVisualizer.getStabilityValue(val);
+ if (arrayVisualizer.doingStabilityCheck())
+ val = arrayVisualizer.getStabilityValue(val);
Timer.startLap("Analysis");
@@ -238,24 +238,24 @@ public int analyzeMin(int[] array, int length, double sleep, boolean mark) {
}
}
- ArrayVisualizer.toggleAnalysis(false);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.toggleAnalysis(false);
+ arrayVisualizer.updateNow();
return min;
}
public int analyzeMaxLog(int[] array, int length, int base, double sleep, boolean mark) {
- ArrayVisualizer.toggleAnalysis(true);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.toggleAnalysis(true);
+ arrayVisualizer.updateNow();
int max = 0;
for (int i = 0; i < length; i++) {
- if (ArrayVisualizer.sortCanceled()) throw new StopSort();
+ if (arrayVisualizer.sortCanceled()) throw new StopSort();
int val = array[i];
- if (ArrayVisualizer.doingStabilityCheck())
- val = ArrayVisualizer.getStabilityValue(val);
+ if (arrayVisualizer.doingStabilityCheck())
+ val = arrayVisualizer.getStabilityValue(val);
Timer.startLap("Analysis");
@@ -269,24 +269,24 @@ public int analyzeMaxLog(int[] array, int length, int base, double sleep, boolea
}
}
- ArrayVisualizer.toggleAnalysis(false);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.toggleAnalysis(false);
+ arrayVisualizer.updateNow();
return (int) (Math.log(max) / Math.log(base));
}
public int analyzeMaxCeilingLog(int[] array, int length, int base, double sleep, boolean mark) {
- ArrayVisualizer.toggleAnalysis(true);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.toggleAnalysis(true);
+ arrayVisualizer.updateNow();
int max = 0;
for (int i = 0; i < length; i++) {
- if (ArrayVisualizer.sortCanceled()) throw new StopSort();
+ if (arrayVisualizer.sortCanceled()) throw new StopSort();
int val = array[i];
- if (ArrayVisualizer.doingStabilityCheck())
- val = ArrayVisualizer.getStabilityValue(val);
+ if (arrayVisualizer.doingStabilityCheck())
+ val = arrayVisualizer.getStabilityValue(val);
Timer.startLap("Analysis");
@@ -300,25 +300,25 @@ public int analyzeMaxCeilingLog(int[] array, int length, int base, double sleep,
}
}
- ArrayVisualizer.toggleAnalysis(false);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.toggleAnalysis(false);
+ arrayVisualizer.updateNow();
return (int) (Math.log(max) / Math.log(base));
}
public int analyzeBit(int[] array, int length) {
- ArrayVisualizer.toggleAnalysis(true);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.toggleAnalysis(true);
+ arrayVisualizer.updateNow();
// Find highest bit of highest value
int max = 0;
for (int i = 0; i < length; i++) {
- if (ArrayVisualizer.sortCanceled()) throw new StopSort();
+ if (arrayVisualizer.sortCanceled()) throw new StopSort();
int val = array[i];
- if (ArrayVisualizer.doingStabilityCheck())
- val = ArrayVisualizer.getStabilityValue(val);
+ if (arrayVisualizer.doingStabilityCheck())
+ val = arrayVisualizer.getStabilityValue(val);
Timer.startLap("Analysis");
@@ -338,14 +338,14 @@ public int analyzeBit(int[] array, int length) {
Timer.stopLap();
- ArrayVisualizer.toggleAnalysis(false);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.toggleAnalysis(false);
+ arrayVisualizer.updateNow();
return analysis;
}
public int getDigit(int a, int power, int radix) {
- if (ArrayVisualizer.doingStabilityCheck())
- a = ArrayVisualizer.getStabilityValue(a);
+ if (arrayVisualizer.doingStabilityCheck())
+ a = arrayVisualizer.getStabilityValue(a);
int digit;
Timer.startLap();
@@ -355,8 +355,8 @@ public int getDigit(int a, int power, int radix) {
}
public boolean getBit(int n, int k) {
- if (ArrayVisualizer.doingStabilityCheck())
- n = ArrayVisualizer.getStabilityValue(n);
+ if (arrayVisualizer.doingStabilityCheck())
+ n = arrayVisualizer.getStabilityValue(n);
// Find boolean value of bit k in n
boolean result;
@@ -365,4 +365,8 @@ public boolean getBit(int n, int k) {
Timer.stopLap();
return result;
}
+
+ public ArrayList getNetworkIndices() {
+ return networkIndices;
+ }
}
diff --git a/src/main/java/io/github/arrayv/utils/Renderer.java b/src/main/java/io/github/arrayv/utils/Renderer.java
index 204587f1..e65f67b6 100644
--- a/src/main/java/io/github/arrayv/utils/Renderer.java
+++ b/src/main/java/io/github/arrayv/utils/Renderer.java
@@ -31,31 +31,31 @@ of this software and associated documentation files (the "Software"), to deal
// TODO: Many of these methods should exist solely in visual classes
-final class WindowState {
- private boolean windowUpdated;
- private boolean windowResized;
+public final class Renderer {
+ private static final class WindowState {
+ private boolean windowUpdated;
+ private boolean windowResized;
- public WindowState(boolean windowUpdate, boolean windowResize) {
- this.windowUpdated = windowUpdate;
- this.windowResized = windowResize;
- }
+ private WindowState(boolean windowUpdate, boolean windowResize) {
+ this.windowUpdated = windowUpdate;
+ this.windowResized = windowResize;
+ }
- public boolean updated() {
- return this.windowUpdated;
- }
+ public boolean updated() {
+ return this.windowUpdated;
+ }
- public boolean resized() {
- return this.windowResized;
+ public boolean resized() {
+ return this.windowResized;
+ }
}
-}
-public final class Renderer {
private volatile double xScale;
private volatile double yScale;
private volatile int yoffset;
private volatile int vsize;
- public volatile boolean auxActive;
+ private volatile boolean auxActive;
private volatile int length;
@@ -68,9 +68,9 @@ public final class Renderer {
private int dotw;
private int dots; //TODO: Change name to dotDims/dotDimensions
- public Renderer(ArrayVisualizer ArrayVisualizer) {
- ArrayVisualizer.setWindowHeight();
- ArrayVisualizer.setWindowWidth();
+ public Renderer(ArrayVisualizer arrayVisualizer) {
+ arrayVisualizer.setWindowHeight();
+ arrayVisualizer.setWindowWidth();
}
public double getXScale() {
@@ -120,81 +120,81 @@ public void setLineY(int y) {
this.linkedpixdrawy = y;
}
- public static void createRenders(ArrayVisualizer ArrayVisualizer) {
- ArrayVisualizer.createVolatileImage();
- ArrayVisualizer.setMainRender();
- ArrayVisualizer.setExtraRender();
+ public static void createRenders(ArrayVisualizer arrayVisualizer) {
+ arrayVisualizer.createVolatileImage();
+ arrayVisualizer.setMainRender();
+ arrayVisualizer.setExtraRender();
}
- public static void initializeVisuals(ArrayVisualizer ArrayVisualizer) {
- Renderer.createRenders(ArrayVisualizer);
- ArrayVisualizer.repositionFrames();
+ public static void initializeVisuals(ArrayVisualizer arrayVisualizer) {
+ Renderer.createRenders(arrayVisualizer);
+ arrayVisualizer.repositionFrames();
}
- public static void updateGraphics(ArrayVisualizer ArrayVisualizer) {
- Renderer.createRenders(ArrayVisualizer);
- ArrayVisualizer.updateVisuals();
+ public static void updateGraphics(ArrayVisualizer arrayVisualizer) {
+ Renderer.createRenders(arrayVisualizer);
+ arrayVisualizer.updateVisuals();
}
- private static WindowState checkWindowResizeAndReposition(ArrayVisualizer ArrayVisualizer) {
+ private static WindowState checkWindowResizeAndReposition(ArrayVisualizer arrayVisualizer) {
boolean windowUpdate = false;
boolean windowResize = false;
- if (ArrayVisualizer.currentHeight() != ArrayVisualizer.windowHeight()) {
+ if (arrayVisualizer.currentHeight() != arrayVisualizer.windowHeight()) {
windowUpdate = true;
windowResize = true;
}
- if (ArrayVisualizer.currentWidth() != ArrayVisualizer.windowWidth()) {
+ if (arrayVisualizer.currentWidth() != arrayVisualizer.windowWidth()) {
windowUpdate = true;
windowResize = true;
}
- if (ArrayVisualizer.currentX() != ArrayVisualizer.windowXCoordinate()) {
+ if (arrayVisualizer.currentX() != arrayVisualizer.windowXCoordinate()) {
windowUpdate = true;
}
- if (ArrayVisualizer.currentY() != ArrayVisualizer.windowYCoordinate()) {
+ if (arrayVisualizer.currentY() != arrayVisualizer.windowYCoordinate()) {
windowUpdate = true;
}
return new WindowState(windowUpdate, windowResize);
}
- public void updateVisualsStart(ArrayVisualizer ArrayVisualizer) {
- WindowState WindowState = checkWindowResizeAndReposition(ArrayVisualizer);
+ public void updateVisualsStart(ArrayVisualizer arrayVisualizer) {
+ WindowState windowState = checkWindowResizeAndReposition(arrayVisualizer);
- if (WindowState.updated()) {
- ArrayVisualizer.repositionFrames();
- ArrayVisualizer.updateCoordinates();
+ if (windowState.updated()) {
+ arrayVisualizer.repositionFrames();
+ arrayVisualizer.updateCoordinates();
/*
if (v != null && v.isVisible())
v.reposition();
*/
- if (WindowState.resized()) {
- ArrayVisualizer.updateDimensions();
- updateGraphics(ArrayVisualizer);
+ if (windowState.resized()) {
+ arrayVisualizer.updateDimensions();
+ updateGraphics(arrayVisualizer);
}
}
- ArrayVisualizer.renderBackground();
+ arrayVisualizer.renderBackground();
//CURRENT = WINDOW
//WINDOW = C VARIABLES
- this.yScale = (double) (this.vsize) / ArrayVisualizer.getCurrentLength();
+ this.yScale = (double) (this.vsize) / arrayVisualizer.getCurrentLength();
- this.dotw = (int) (2 * (ArrayVisualizer.currentWidth() / 640.0));
+ this.dotw = (int) (2 * (arrayVisualizer.currentWidth() / 640.0));
- this.vsize = (ArrayVisualizer.currentHeight() - 96) / (ArrayVisualizer.externalArraysEnabled() ? Math.min(ArrayVisualizer.getArrays().size(), 7) : 1);
+ this.vsize = (arrayVisualizer.currentHeight() - 96) / (arrayVisualizer.externalArraysEnabled() ? Math.min(arrayVisualizer.getArrays().size(), 7) : 1);
this.yoffset = 96;
}
- private void updateVisualsPerArray(ArrayVisualizer ArrayVisualizer, int[] array, int length) {
+ private void updateVisualsPerArray(ArrayVisualizer arrayVisualizer, int[] array, int length) {
//CURRENT = WINDOW
//WINDOW = C VARIABLES
- this.xScale = (double) (ArrayVisualizer.currentWidth() - 40) / length;
+ this.xScale = (double) (arrayVisualizer.currentWidth() - 40) / length;
this.amt = 0; //TODO: rename to barCount
@@ -206,22 +206,30 @@ private void updateVisualsPerArray(ArrayVisualizer ArrayVisualizer, int[] array,
this.length = length;
- ArrayVisualizer.resetMainStroke();
+ arrayVisualizer.resetMainStroke();
}
- public void drawVisual(VisualStyles VisualStyles, int[][] arrays, ArrayVisualizer ArrayVisualizer, Highlights Highlights) {
- if (ArrayVisualizer.externalArraysEnabled()) {
+ public void drawVisual(VisualStyles visualStyle, int[][] arrays, ArrayVisualizer arrayVisualizer, Highlights Highlights) {
+ if (arrayVisualizer.externalArraysEnabled()) {
this.auxActive = true;
for (int i = Math.min(arrays.length - 1, 6); i > 0; i--) {
if (arrays[i] != null) {
- this.updateVisualsPerArray(ArrayVisualizer, arrays[i], arrays[i].length);
- VisualStyles.drawVisual(arrays[i], ArrayVisualizer, this, Highlights);
+ this.updateVisualsPerArray(arrayVisualizer, arrays[i], arrays[i].length);
+ visualStyle.drawVisual(arrays[i], arrayVisualizer, this, Highlights);
this.yoffset += this.vsize;
}
}
this.auxActive = false;
}
- this.updateVisualsPerArray(ArrayVisualizer, arrays[0], ArrayVisualizer.getCurrentLength());
- VisualStyles.drawVisual(arrays[0], ArrayVisualizer, this, Highlights);
+ this.updateVisualsPerArray(arrayVisualizer, arrays[0], arrayVisualizer.getCurrentLength());
+ visualStyle.drawVisual(arrays[0], arrayVisualizer, this, Highlights);
+ }
+
+ public boolean isAuxActive() {
+ return auxActive;
+ }
+
+ public void setAuxActive(boolean auxActive) {
+ this.auxActive = auxActive;
}
}
diff --git a/src/main/java/io/github/arrayv/utils/Rotations.java b/src/main/java/io/github/arrayv/utils/Rotations.java
index b5812b52..c4b3384a 100644
--- a/src/main/java/io/github/arrayv/utils/Rotations.java
+++ b/src/main/java/io/github/arrayv/utils/Rotations.java
@@ -3,8 +3,13 @@
import io.github.arrayv.main.ArrayVisualizer;
public final class Rotations {
- private static Writes Writes = ArrayVisualizer.getInstance().getWrites();
- private static Highlights Highlights = ArrayVisualizer.getInstance().getHighlights();
+ // @checkstyle:off ConstantNameCheck - Unique case
+ private static final Writes Writes = ArrayVisualizer.getInstance().getWrites();
+ private static final Highlights Highlights = ArrayVisualizer.getInstance().getHighlights();
+ // @checkstyle:on ConstantNameCheck
+
+ private Rotations() {
+ }
// utility functions
private static void swapBlocksBackwards(int[] array, int a, int b, int len, double pause, boolean mark, boolean auxwrite) {
@@ -153,17 +158,18 @@ public static void juggling(int[] array, int pos, int lenA, int lenB, double pau
index = 0,
value = array[pos + index],
startIndex = index;
- cnt < length; cnt++) {
- int nextIndex = mapIndex(index, lenA, length);
+ cnt < length; cnt++
+ ) {
+ int nextIndex = mapIndex(index, lenA, length);
- value = swap(array, pos + nextIndex, value, pause, mark, auxwrite);
+ value = swap(array, pos + nextIndex, value, pause, mark, auxwrite);
- if (nextIndex == startIndex) {
- startIndex = index = mapIndex(index, 1, length);
- value = array[pos + index];
- } else {
- index = nextIndex;
- }
+ if (nextIndex == startIndex) {
+ startIndex = index = mapIndex(index, 1, length);
+ value = array[pos + index];
+ } else {
+ index = nextIndex;
+ }
}
}
diff --git a/src/main/java/io/github/arrayv/utils/ShuffleGraph.java b/src/main/java/io/github/arrayv/utils/ShuffleGraph.java
index 5958a72e..9cfac21a 100644
--- a/src/main/java/io/github/arrayv/utils/ShuffleGraph.java
+++ b/src/main/java/io/github/arrayv/utils/ShuffleGraph.java
@@ -18,14 +18,14 @@
import io.github.arrayv.utils.shuffleutils.GraphNode;
public class ShuffleGraph implements Collection {
- public List nodes;
- public List connections;
- public GraphNode selected;
- public GraphConnection dragging;
- public GraphNode dragCandidate;
- public double sleepRatio;
-
- final static int DEFAULT_TEXT_SIZE = 24;
+ private List nodes;
+ private List connections;
+ private GraphNode selected;
+ private GraphConnection dragging;
+ private GraphNode dragCandidate;
+ private double sleepRatio;
+
+ static final int DEFAULT_TEXT_SIZE = 24;
Map textSizes = new HashMap<>();
public ShuffleGraph() {
@@ -103,7 +103,7 @@ public ShuffleGraph addSingle(Distributions distribution, boolean warped) {
public Point findSafeCoordinates(int baseX, int baseY, int offsetX, int offsetY) {
Point p = new Point(baseX, baseY);
- while (this.nodes.stream().anyMatch(node -> node.x == p.x && node.y == p.y)) {
+ while (this.nodes.stream().anyMatch(node -> node.getX() == p.getX() && node.getY() == p.getY())) {
p.x += offsetX;
p.y += offsetY;
}
@@ -146,7 +146,7 @@ public void drag(Point rel) {
if (this.selected != null) {
this.selected.drag(rel);
} else if (this.dragging != null) {
- Point pos = this.dragging.currentDragPos;
+ Point pos = this.dragging.getCurrentDragPos();
pos.translate(rel.x, rel.y);
boolean foundCandidate = false;
ListIterator it = this.nodes.listIterator(this.nodes.size());
@@ -176,7 +176,7 @@ public void select(Point pos) {
int removed = 0;
for (int i = 0; i < this.connections.size(); i++) {
GraphConnection conn = this.connections.get(i - removed);
- if (conn.from == node) {
+ if (conn.getFrom() == node) {
this.connections.remove(i - removed);
conn.remove();
removed++;
@@ -184,7 +184,7 @@ public void select(Point pos) {
}
this.connections.add(newConnection);
this.dragging = newConnection;
- node.postConnection = newConnection;
+ node.setPostConnection(newConnection);
this.selected = null;
return;
}
@@ -233,32 +233,32 @@ public int size() {
GraphNode node = this.nodes.get(0);
while (node != null) {
size++;
- GraphConnection connect = node.postConnection;
+ GraphConnection connect = node.getPostConnection();
if (connect == null) {
break;
}
- node = connect.to;
+ node = connect.getTo();
}
return size - 1;
}
public void clear() {
this.nodes.subList(1, this.nodes.size()).clear();
- this.nodes.get(0).postConnection = null;
+ this.nodes.get(0).setPostConnection(null);
}
public GraphNode findLast() {
GraphNode previous = null;
GraphNode node = this.nodes.get(0);
while (node != null) {
- GraphConnection connect = node.postConnection;
+ GraphConnection connect = node.getPostConnection();
if (connect == null) {
previous = node;
node = null;
break;
}
previous = node;
- node = connect.to;
+ node = connect.getTo();
}
return previous;
}
@@ -277,17 +277,17 @@ public boolean addAll(Collection extends ShuffleInfo> c) {
}
GraphNode add(ShuffleInfo shuffle, GraphNode after) {
- GraphNode newNode = new GraphNode(shuffle, this, after.x + GraphNode.WIDTH + 15, after.y);
- if (after.postConnection == null) {
- after.postConnection = new GraphConnection(after, newNode);
- this.connections.add(after.postConnection);
+ GraphNode newNode = new GraphNode(shuffle, this, after.getX() + GraphNode.WIDTH + 15, after.getY());
+ if (after.getPostConnection() == null) {
+ after.setPostConnection(new GraphConnection(after, newNode));
+ this.connections.add(after.getPostConnection());
} else {
- if (after.postConnection.to != null) {
- after.postConnection.to.preConnection = null;
+ if (after.getPostConnection().getTo() != null) {
+ after.getPostConnection().getTo().setPreConnection(null);
}
- after.postConnection.to = newNode;
+ after.getPostConnection().setTo(newNode);
}
- newNode.preConnection = after.postConnection;
+ newNode.setPreConnection(after.getPostConnection());
this.nodes.add(newNode);
return newNode;
}
@@ -298,11 +298,11 @@ GraphNode find(Object o) {
}
GraphNode node = this.nodes.get(0);
while (node != null) {
- GraphConnection connect = node.postConnection;
+ GraphConnection connect = node.getPostConnection();
if (connect == null) {
break;
}
- node = connect.to;
+ node = connect.getTo();
if (node == null) {
break;
}
@@ -371,11 +371,11 @@ public T[] toArray(T[] a) {
int i = 0;
GraphNode node = this.nodes.get(0);
while (node != null) {
- GraphConnection connect = node.postConnection;
+ GraphConnection connect = node.getPostConnection();
if (connect == null) {
break;
}
- node = connect.to;
+ node = connect.getTo();
result[i++] = node.getValue();
}
if (i < a.length - 1) {
@@ -393,6 +393,58 @@ public Iterator iterator() {
return new GraphIterator(this);
}
+ public List getNodes() {
+ return nodes;
+ }
+
+ public void setNodes(List nodes) {
+ this.nodes = nodes;
+ }
+
+ public List getConnections() {
+ return connections;
+ }
+
+ public void setConnections(List connections) {
+ this.connections = connections;
+ }
+
+ public GraphNode getSelected() {
+ return selected;
+ }
+
+ public void setSelected(GraphNode selected) {
+ this.selected = selected;
+ }
+
+ public GraphConnection getDragging() {
+ return dragging;
+ }
+
+ public void setDragging(GraphConnection dragging) {
+ this.dragging = dragging;
+ }
+
+ public GraphNode getDragCandidate() {
+ return dragCandidate;
+ }
+
+ public void setDragCandidate(GraphNode dragCandidate) {
+ this.dragCandidate = dragCandidate;
+ }
+
+ public double getSleepRatio() {
+ return sleepRatio;
+ }
+
+ public Map getTextSizes() {
+ return textSizes;
+ }
+
+ public void setTextSizes(Map textSizes) {
+ this.textSizes = textSizes;
+ }
+
protected class GraphIterator implements Iterator {
NodeIterator it;
@@ -422,9 +474,9 @@ protected class NodeIterator implements Iterator {
}
GraphNode findNext() {
- GraphConnection connect = this.currentNode.postConnection;
+ GraphConnection connect = this.currentNode.getPostConnection();
if (connect != null) {
- GraphNode next = connect.to;
+ GraphNode next = connect.getTo();
if (next != null) {
return next;
}
diff --git a/src/main/java/io/github/arrayv/utils/Shuffles.java b/src/main/java/io/github/arrayv/utils/Shuffles.java
index f2bb3361..b1d77aaa 100644
--- a/src/main/java/io/github/arrayv/utils/Shuffles.java
+++ b/src/main/java/io/github/arrayv/utils/Shuffles.java
@@ -48,9 +48,9 @@ public String getName() {
return "Randomly";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
shuffle(array, 0, currentLen, delay ? 1 : 0, Writes);
}
},
@@ -59,9 +59,9 @@ public String getName() {
return "Backwards";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
Writes.reversal(array, 0, currentLen-1, delay ? 1 : 0, true, false);
}
},
@@ -70,14 +70,14 @@ public String getName() {
return "Slight Shuffle";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
Random random = new Random();
for (int i = 0; i < Math.max(currentLen / 20, 1); i++){
Writes.swap(array, random.nextInt(currentLen), random.nextInt(currentLen), 0, true, false);
- if (ArrayVisualizer.shuffleEnabled()) Delays.sleep(10);
+ if (arrayVisualizer.shuffleEnabled()) Delays.sleep(10);
}
}
},
@@ -86,11 +86,11 @@ public String getName() {
return "No Shuffle";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
for (int i = 0; i < currentLen; i++) {
Highlights.markArray(1, i);
- if (ArrayVisualizer.shuffleEnabled()) Delays.sleep(1);
+ if (arrayVisualizer.shuffleEnabled()) Delays.sleep(1);
}
}
},
@@ -99,9 +99,9 @@ public String getName() {
return "Sorted";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
this.sort(array, 0, currentLen, delay ? 1 : 0, Writes);
}
},
@@ -110,9 +110,9 @@ public String getName() {
return "Naive Randomly";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
Random random = new Random();
for (int i = 0; i < currentLen; i++)
@@ -124,9 +124,9 @@ public String getName() {
return "Scrambled Tail";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
Random random = new Random();
int[] aux = new int[currentLen];
@@ -147,9 +147,9 @@ public String getName() {
return "Scrambled Head";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
Random random = new Random();
int[] aux = new int[currentLen];
@@ -170,9 +170,9 @@ public String getName() {
return "Shifted Element";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
Random random = new Random();
int start = random.nextInt(currentLen);
@@ -189,9 +189,9 @@ public String getName() {
return "Noisy";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
Random random = new Random();
int i, size = Math.max(4, (int)(Math.sqrt(currentLen)/2));
@@ -205,15 +205,15 @@ public String getName() {
return "Scrambled Odds";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
Random random = new Random();
for (int i = 1; i < currentLen; i += 2){
int randomIndex = (((random.nextInt(currentLen - i) / 2)) * 2) + i;
Writes.swap(array, i, randomIndex, 0, true, false);
- if (ArrayVisualizer.shuffleEnabled()) Delays.sleep(2);
+ if (arrayVisualizer.shuffleEnabled()) Delays.sleep(2);
}
}
},
@@ -222,9 +222,9 @@ public String getName() {
return "Final Merge Pass";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
int count = 2;
int k = 0;
@@ -243,9 +243,9 @@ public String getName() {
return "Shuffled Final Merge";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
this.shuffle(array, 0, currentLen, delay ? 0.5 : 0, Writes);
Highlights.clearMark(2);
@@ -258,9 +258,9 @@ public String getName() {
return "Shuffled Half";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
this.shuffle(array, 0, currentLen, delay ? 2/3d : 0, Writes);
Highlights.clearMark(2);
@@ -272,9 +272,9 @@ public String getName() {
return "Partitioned";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
this.sort(array, 0, currentLen, delay ? 0.5 : 0, Writes);
Highlights.clearMark(2);
@@ -287,9 +287,9 @@ public String getName() {
return "Sawtooth";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
int count = 4;
int k = 0;
@@ -308,9 +308,9 @@ public String getName() {
return "Pipe Organ";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
int[] temp = new int[currentLen];
for (int i = 0, j = 0; i < currentLen; i+=2){
@@ -329,9 +329,9 @@ public String getName() {
return "Final Bitonic Pass";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
int[] temp = new int[currentLen];
Writes.reversal(array, 0, currentLen-1, delay ? 1 : 0, true, false);
@@ -352,9 +352,9 @@ public String getName() {
return "Interlaced";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
int[] referenceArray = new int[currentLen];
for (int i = 0; i < currentLen; i++) {
@@ -378,12 +378,12 @@ public String getName() {
return "Double Layered";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
for (int i = 0; i < currentLen / 2; i += 2) {
Writes.swap(array, i, currentLen - i - 1, 0, true, false);
- if (ArrayVisualizer.shuffleEnabled()) Delays.sleep(1);
+ if (arrayVisualizer.shuffleEnabled()) Delays.sleep(1);
}
}
},
@@ -392,9 +392,9 @@ public String getName() {
return "Final Radix";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
currentLen -= currentLen % 2;
int mid = currentLen/2;
@@ -414,8 +414,8 @@ public String getName() {
return "Real Final Radix";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int mask = 0;
for (int i = 0; i < currentLen; i++)
@@ -442,9 +442,9 @@ public String getName() {
return "Recursive Final Radix";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
weaveRec(array, 0, currentLen, 1, delay ? 0.5 : 0, Writes);
}
@@ -474,9 +474,9 @@ public String getName() {
return "Half Rotation";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
int a = 0, m = (currentLen + 1) / 2;
@@ -498,9 +498,9 @@ public String getName() {
return "Half Reversed";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
Writes.reversal(array, 0, currentLen-1, delay ? 1 : 0, true, false);
Writes.reversal(array, currentLen/4, (3*currentLen+3)/4-1, delay ? 1 : 0, true, false);
@@ -511,8 +511,8 @@ public String getName() {
return "BST Traversal";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int[] temp = Arrays.copyOf(array, currentLen);
// credit to sam walko/anon
@@ -535,7 +535,7 @@ class Subarray {
if (sub.start != sub.end) {
int mid = (sub.start + sub.end)/2;
Writes.write(array, i, temp[mid], 0, true, false);
- if (ArrayVisualizer.shuffleEnabled()) Delays.sleep(1);
+ if (arrayVisualizer.shuffleEnabled()) Delays.sleep(1);
i++;
q.add(new Subarray(sub.start, mid));
q.add(new Subarray(mid+1, sub.end));
@@ -548,9 +548,9 @@ public String getName() {
return "Inverted BST";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
int[] temp = new int[currentLen];
// credit to sam walko/anon
@@ -590,9 +590,9 @@ public String getName() {
return "Logarithmic Slopes";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
int[] temp = new int[currentLen];
for (int i = 0; i < currentLen; i++)
@@ -612,11 +612,11 @@ public String getName() {
return "Heapified";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
- MaxHeapSort heapSort = new MaxHeapSort(ArrayVisualizer);
+ MaxHeapSort heapSort = new MaxHeapSort(arrayVisualizer);
heapSort.makeHeap(array, 0, currentLen, delay ? 1 : 0);
}
},
@@ -625,10 +625,10 @@ public String getName() {
return "Smoothified";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
- SmoothSort smoothSort = new SmoothSort(ArrayVisualizer);
+ SmoothSort smoothSort = new SmoothSort(arrayVisualizer);
smoothSort.smoothHeapify(array, currentLen);
}
},
@@ -637,10 +637,10 @@ public String getName() {
return "Poplarified";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
- PoplarHeapSort poplarHeapSort = new PoplarHeapSort(ArrayVisualizer);
+ PoplarHeapSort poplarHeapSort = new PoplarHeapSort(arrayVisualizer);
poplarHeapSort.poplarHeapify(array, 0, currentLen);
}
},
@@ -649,14 +649,14 @@ public String getName() {
return "Triangular Heapified";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
if (delay) Delays.setSleepRatio(Delays.getSleepRatio()*10);
else Delays.changeSkipped(true);
- TriangularHeapSort triangularHeapSort = new TriangularHeapSort(ArrayVisualizer);
+ TriangularHeapSort triangularHeapSort = new TriangularHeapSort(arrayVisualizer);
triangularHeapSort.triangularHeapify(array, currentLen);
if (delay) Delays.setSleepRatio(Delays.getSleepRatio()/10);
@@ -668,10 +668,10 @@ public String getName() {
return "First Circle Pass";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
- Reads Reads = ArrayVisualizer.getReads();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
+ Reads Reads = arrayVisualizer.getReads();
shuffle(array, 0, currentLen, delay ? 0.5 : 0, Writes);
@@ -705,10 +705,10 @@ public String getName() {
return "Final Pairwise Pass";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
- Reads Reads = ArrayVisualizer.getReads();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
+ Reads Reads = arrayVisualizer.getReads();
shuffle(array, 0, currentLen, delay ? 0.5 : 0, Writes);
@@ -744,9 +744,9 @@ public String getName() {
return "Recursive Reversal";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
reversalRec(array, 0, currentLen, delay ? 1 : 0, Writes);
}
@@ -766,9 +766,9 @@ public String getName() {
return "Gray Code Fractal";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
reversalRec(array, 0, currentLen, false, delay ? 1 : 0, Writes);
}
@@ -790,8 +790,8 @@ public String getName() {
return "Sierpinski Triangle";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int[] triangle = new int[currentLen];
triangleRec(triangle, 0, currentLen);
@@ -821,9 +821,9 @@ public String getName() {
return "Triangular";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
int[] triangle = new int[currentLen];
int j = 0, k = 2;
@@ -858,9 +858,9 @@ public String getName() {
return "Quicksort Adversary";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
for (int j = currentLen-currentLen%2-2, i = j-1; i >= 0; i-=2, j--)
Writes.swap(array, i, j, delay ? 1 : 0, true, false);
@@ -881,7 +881,7 @@ final class PDQPair {
private int pivotPosition;
private boolean alreadyPartitioned;
- public PDQPair(int pivotPos, boolean presorted) {
+ private PDQPair(int pivotPos, boolean presorted) {
this.pivotPosition = pivotPos;
this.alreadyPartitioned = presorted;
}
@@ -899,11 +899,11 @@ public String getName() {
return "PDQ Adversary";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ delay = arrayVisualizer.shuffleEnabled();
sleep = delay ? 1 : 0;
- this.Reads = ArrayVisualizer.getReads();
+ this.Reads = arrayVisualizer.getReads();
this.Writes = Writes;
this.Highlights = Highlights;
@@ -960,7 +960,7 @@ protected int compare(int ap, int bp) {
return 0;
}
- protected void pdqLoop(int[] array, int begin, int end, boolean Branchless, int badAllowed) {
+ protected void pdqLoop(int[] array, int begin, int end, boolean branchless, int badAllowed) {
boolean leftmost = true;
while (true) {
@@ -989,55 +989,55 @@ protected void pdqLoop(int[] array, int begin, int end, boolean Branchless, int
PDQPair partResult = this.pdqPartRight(array, begin, end);
- int pivotPos = partResult.getPivotPosition();
- boolean alreadyParted = partResult.getPresortBool();
-
- int leftSize = pivotPos - begin;
- int rightSize = end - (pivotPos + 1);
- boolean highUnbalance = leftSize < size / 8 || rightSize < size / 8;
-
- if (highUnbalance) {
- if (--badAllowed == 0) {
- int length = end - begin;
- for (int i = length / 2; i >= 1; i--) {
- siftDown(array, i, length, begin, sleep, true);
- }
- return;
- }
-
- if (leftSize >= 24) {
- Writes.swap(array, begin, begin + leftSize / 4, sleep, true, false);
- Writes.swap(array, pivotPos-1, pivotPos - leftSize / 4, sleep, true, false);
-
- if (leftSize > 128) {
- Writes.swap(array, begin+1, begin + (leftSize / 4 + 1), sleep, true, false);
- Writes.swap(array, begin+2, begin + (leftSize / 4 + 2), sleep, true, false);
- Writes.swap(array, pivotPos-2, pivotPos - (leftSize / 4 + 1), sleep, true, false);
- Writes.swap(array, pivotPos-3, pivotPos - (leftSize / 4 + 2), sleep, true, false);
- }
- }
-
- if (rightSize >= 24) {
- Writes.swap(array, pivotPos+1, pivotPos + (1 + rightSize / 4), sleep, true, false);
- Writes.swap(array, end-1, end - rightSize / 4, sleep, true, false);
-
- if (rightSize > 128) {
- Writes.swap(array, pivotPos+2, pivotPos + (2 + rightSize / 4), sleep, true, false);
- Writes.swap(array, pivotPos+3, pivotPos + (3 + rightSize / 4), sleep, true, false);
- Writes.swap(array, end-2, end - (1 + rightSize / 4), sleep, true, false);
- Writes.swap(array, end-3, end - (2 + rightSize / 4), sleep, true, false);
- }
- }
- Highlights.clearMark(2);
- } else {
- if (alreadyParted && pdqPartialInsertSort(array, begin, pivotPos)
- && pdqPartialInsertSort(array, pivotPos + 1, end))
- return;
+ int pivotPos = partResult.getPivotPosition();
+ boolean alreadyParted = partResult.getPresortBool();
+
+ int leftSize = pivotPos - begin;
+ int rightSize = end - (pivotPos + 1);
+ boolean highUnbalance = leftSize < size / 8 || rightSize < size / 8;
+
+ if (highUnbalance) {
+ if (--badAllowed == 0) {
+ int length = end - begin;
+ for (int i = length / 2; i >= 1; i--) {
+ siftDown(array, i, length, begin, sleep, true);
+ }
+ return;
+ }
+
+ if (leftSize >= 24) {
+ Writes.swap(array, begin, begin + leftSize / 4, sleep, true, false);
+ Writes.swap(array, pivotPos-1, pivotPos - leftSize / 4, sleep, true, false);
+
+ if (leftSize > 128) {
+ Writes.swap(array, begin+1, begin + (leftSize / 4 + 1), sleep, true, false);
+ Writes.swap(array, begin+2, begin + (leftSize / 4 + 2), sleep, true, false);
+ Writes.swap(array, pivotPos-2, pivotPos - (leftSize / 4 + 1), sleep, true, false);
+ Writes.swap(array, pivotPos-3, pivotPos - (leftSize / 4 + 2), sleep, true, false);
+ }
+ }
+
+ if (rightSize >= 24) {
+ Writes.swap(array, pivotPos+1, pivotPos + (1 + rightSize / 4), sleep, true, false);
+ Writes.swap(array, end-1, end - rightSize / 4, sleep, true, false);
+
+ if (rightSize > 128) {
+ Writes.swap(array, pivotPos+2, pivotPos + (2 + rightSize / 4), sleep, true, false);
+ Writes.swap(array, pivotPos+3, pivotPos + (3 + rightSize / 4), sleep, true, false);
+ Writes.swap(array, end-2, end - (1 + rightSize / 4), sleep, true, false);
+ Writes.swap(array, end-3, end - (2 + rightSize / 4), sleep, true, false);
}
+ }
+ Highlights.clearMark(2);
+ } else {
+ if (alreadyParted && pdqPartialInsertSort(array, begin, pivotPos)
+ && pdqPartialInsertSort(array, pivotPos + 1, end))
+ return;
+ }
- this.pdqLoop(array, begin, pivotPos, Branchless, badAllowed);
- begin = pivotPos + 1;
- leftmost = false;
+ this.pdqLoop(array, begin, pivotPos, branchless, badAllowed);
+ begin = pivotPos + 1;
+ leftmost = false;
}
}
@@ -1075,7 +1075,7 @@ private PDQPair pdqPartRight(int[] array, int begin, int end) {
Highlights.markArray(2, last);
}
else
- while ( !(compare(array[--last], pivot) < 0)) {
+ while (!(compare(array[--last], pivot) < 0)) {
Highlights.markArray(2, last);
}
@@ -1139,7 +1139,7 @@ private int pdqPartLeft(int[] array, int begin, int end) {
Highlights.markArray(1, first);
}
else
- while ( !(compare(pivot, array[++first]) < 0)) {
+ while (!(compare(pivot, array[++first]) < 0)) {
Highlights.markArray(1, first);
}
@@ -1220,9 +1220,9 @@ public String getName() {
return "Grailsort Adversary";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
if (currentLen <= 16) Writes.reversal(array, 0, currentLen-1, delay ? 1 : 0, true, false);
else {
@@ -1275,9 +1275,9 @@ public String getName() {
return "Shuffle Merge Adversary";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int n = ArrayVisualizer.getCurrentLength();
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int n = arrayVisualizer.getCurrentLength();
+ boolean delay = arrayVisualizer.shuffleEnabled();
int[] tmp = new int[n];
int d = 2, end = 1 << (int)(Math.log(n-1)/Math.log(2) + 1);
@@ -1339,10 +1339,10 @@ public String getName() {
return "Bit Reversal";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
- int len = 1 << (int)(Math.log(ArrayVisualizer.getCurrentLength())/Math.log(2));
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
+ int len = 1 << (int)(Math.log(arrayVisualizer.getCurrentLength())/Math.log(2));
+ boolean delay = arrayVisualizer.shuffleEnabled();
boolean pow2 = len == currentLen;
int[] temp = Arrays.copyOf(array, currentLen);
@@ -1391,11 +1391,11 @@ public String getName() {
return "Randomly w/ Blocks";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int blockSize = pow2lte((int)Math.sqrt(currentLen));
currentLen -= currentLen%blockSize;
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ boolean delay = arrayVisualizer.shuffleEnabled();
double sleep = delay ? 1 : 0;
Random random = new Random();
@@ -1423,11 +1423,11 @@ public String getName() {
return "Block Reverse";
}
@Override
- public void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
- int currentLen = ArrayVisualizer.getCurrentLength();
+ public void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes) {
+ int currentLen = arrayVisualizer.getCurrentLength();
int blockSize = pow2lte((int)Math.sqrt(currentLen));
currentLen -= currentLen % blockSize;
- boolean delay = ArrayVisualizer.shuffleEnabled();
+ boolean delay = arrayVisualizer.shuffleEnabled();
double sleep = delay ? 1 : 0;
int i = 0, j = currentLen - blockSize;
@@ -1482,5 +1482,5 @@ public void shuffle(int[] array, int start, int end, double sleep, Writes Writes
}
public abstract String getName();
- public abstract void shuffleArray(int[] array, ArrayVisualizer ArrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes);
+ public abstract void shuffleArray(int[] array, ArrayVisualizer arrayVisualizer, Delays Delays, Highlights Highlights, Writes Writes);
}
diff --git a/src/main/java/io/github/arrayv/utils/SortingNetworkGenerator.java b/src/main/java/io/github/arrayv/utils/SortingNetworkGenerator.java
index 6d0b3aa2..6d97284b 100644
--- a/src/main/java/io/github/arrayv/utils/SortingNetworkGenerator.java
+++ b/src/main/java/io/github/arrayv/utils/SortingNetworkGenerator.java
@@ -18,7 +18,7 @@
import io.github.arrayv.main.ArrayVisualizer;
import io.github.arrayv.panes.JErrorPane;
-public class SortingNetworkGenerator {
+public final class SortingNetworkGenerator {
private static final File SORTING_NETWORKS_DIR = new File("sorting_networks");
static {
@@ -91,6 +91,9 @@ String getValue() {
private static final int OUT_BUFFER_SIZE = 8192; // 16 KB
+ private SortingNetworkGenerator() {
+ }
+
private static boolean encodeNetwork0(final Comparator[] comparators, final int n, final PrintWriter out) {
int scale = 1;
int xScale = scale * 36;
diff --git a/src/main/java/io/github/arrayv/utils/Sounds.java b/src/main/java/io/github/arrayv/utils/Sounds.java
index b8e1fe15..7bd9ea37 100644
--- a/src/main/java/io/github/arrayv/utils/Sounds.java
+++ b/src/main/java/io/github/arrayv/utils/Sounds.java
@@ -74,9 +74,9 @@ public final class Sounds {
private int[] array;
- private ArrayVisualizer ArrayVisualizer;
+ private ArrayVisualizer arrayVisualizer;
- private Thread AudioThread;
+ private Thread audioThread;
private Highlights Highlights;
@@ -87,23 +87,23 @@ public final class Sounds {
private boolean soundEnabled;
- private volatile boolean SOUND;
- private volatile boolean MIDI;
- private int NUMCHANNELS; //Number of Audio Channels
- private double PITCHMIN; //Minimum Pitch
- private double PITCHMAX; //Maximum Pitch
- private double SOUNDMUL;
- private boolean SOFTERSOUNDS;
+ private volatile boolean playSound;
+ private volatile boolean playSound2; // Yes there're really two fields that are used at different times
+ private int numChannels; //Number of Audio Channels
+ private double pitchMin; //Minimum Pitch
+ private double pitchMax; //Maximum Pitch
+ private double soundMultiplier;
+ private boolean softerSounds;
- final private int SUSTAIN_PEDAL = 64;
- final private int REVERB = 91;
+ private static final int SUSTAIN_PEDAL = 64;
+ private static final int REVERB = 91;
private String defaultSoundbank = "Default (Yamaha XG Sound Set)";
private String selectedSoundbank;
private int sineWaveIndex;
- final private int DEFAULT_SINE_WAVE_INDEX = 193;
- final private int DEFAULT_ROCK_ORGAN_INDEX = 16;
+ private static final int DEFAULT_SINE_WAVE_INDEX = 193;
+ private static final int DEFAULT_ROCK_ORGAN_INDEX = 16;
private volatile LoadingDialog infoMsg;
@@ -112,15 +112,15 @@ public final class Sounds {
public Sounds(int[] array, ArrayVisualizer arrayVisualizer) {
this.array = array;
- this.ArrayVisualizer = arrayVisualizer;
- this.Highlights = ArrayVisualizer.getHighlights();
+ this.arrayVisualizer = arrayVisualizer;
+ this.Highlights = arrayVisualizer.getHighlights();
- this.SOUND = true;
- this.MIDI = true;
- this.NUMCHANNELS = ALLOW_PERCUSSION_SOUNDS ? 16 : 15;
- this.PITCHMIN = 25d;
- this.PITCHMAX = 105d;
- this.SOUNDMUL = 1d;
+ this.playSound = true;
+ this.playSound2 = true;
+ this.numChannels = ALLOW_PERCUSSION_SOUNDS ? 16 : 15;
+ this.pitchMin = 25d;
+ this.pitchMax = 105d;
+ this.soundMultiplier = 1d;
this.noteDelay = 1;
@@ -155,14 +155,14 @@ public Sounds(int[] array, ArrayVisualizer arrayVisualizer) {
this.instrumentChoice = 0;
this.prepareDefaultSoundbank();
- this.AudioThread = new Thread("AudioThread") {
+ this.audioThread = new Thread("AudioThread") {
@Override
public void run() {
while (Sounds.this.soundEnabled) {
for (MidiChannel channel : channels) {
channel.allNotesOff();
}
- if (SOUND == false || MIDI == false || JErrorPane.errorMessageActive) {
+ if (!playSound || !playSound2 || JErrorPane.isErrorMessageActive()) {
synchronized (Sounds.this) {
try {
Sounds.this.wait();
@@ -173,12 +173,12 @@ public void run() {
continue;
}
- int noteCount = Math.min(Highlights.getMarkCount(), NUMCHANNELS);
- noteCount = noteCount < 0 ? NUMCHANNELS : noteCount;
+ int noteCount = Math.min(Highlights.getMarkCount(), numChannels);
+ noteCount = noteCount < 0 ? numChannels : noteCount;
int channel = 0;
int playNoteCount = Math.max(noteCount, 1);
- int currentLen = ArrayVisualizer.getCurrentLength();
+ int currentLen = arrayVisualizer.getCurrentLength();
for (int i : Highlights.highlightList()) {
try {
@@ -189,13 +189,13 @@ public void run() {
}
//PITCH
- double pitch = Sounds.this.array[Math.min(Math.max(i, 0), currentLen - 1)] / (double) currentLen * (PITCHMAX - PITCHMIN) + PITCHMIN;
+ double pitch = Sounds.this.array[Math.min(Math.max(i, 0), currentLen - 1)] / (double) currentLen * (pitchMax - pitchMin) + pitchMin;
int pitchmajor = (int) pitch;
int pitchminor = (int)((pitch-((int)pitch))*8192d)+8192;
- int vel = (int) (Math.pow(PITCHMAX - pitchmajor, 2d) * (Math.pow(noteCount, -0.25)) * 64d * SOUNDMUL) / 2; //I'VE SOLVED IT!!
+ int vel = (int) (Math.pow(pitchMax - pitchmajor, 2d) * (Math.pow(noteCount, -0.25)) * 64d * soundMultiplier) / 2; //I'VE SOLVED IT!!
- if (SOUNDMUL >= 1 && vel < 256) {
+ if (soundMultiplier >= 1 && vel < 256) {
vel *= vel;
}
@@ -271,7 +271,7 @@ public void selectDefaultSoundbank(SoundFrame menu) {
}
private void prepareDefaultSoundbank() {
- this.sineWaveIndex = this.DEFAULT_SINE_WAVE_INDEX;
+ this.sineWaveIndex = DEFAULT_SINE_WAVE_INDEX;
InputStream is = getClass().getResourceAsStream("/sfx.sf2");
this.loadInstruments(is);
this.selectedSoundbank = this.defaultSoundbank;
@@ -312,16 +312,16 @@ public String[] getInstrumentList() {
return new String[0];
}
- String rockOrgan = instruments[this.DEFAULT_ROCK_ORGAN_INDEX].getName();
+ String rockOrgan = instruments[DEFAULT_ROCK_ORGAN_INDEX].getName();
instrumentNames.add("a. Default Sound Effect (" + this.formatInstrumentName(rockOrgan) + ")");
this.sineWaveIndex = 0;
while (this.sineWaveIndex < instruments.length && !instruments[this.sineWaveIndex].getName().toLowerCase().trim().contains("sine")) {
this.sineWaveIndex++;
}
- if (this.sineWaveIndex >= instruments.length && this.DEFAULT_SINE_WAVE_INDEX < instruments.length) {
- this.sineWaveIndex = this.DEFAULT_SINE_WAVE_INDEX;
- } else if (this.DEFAULT_SINE_WAVE_INDEX >= instruments.length) {
+ if (this.sineWaveIndex >= instruments.length && DEFAULT_SINE_WAVE_INDEX < instruments.length) {
+ this.sineWaveIndex = DEFAULT_SINE_WAVE_INDEX;
+ } else if (DEFAULT_SINE_WAVE_INDEX >= instruments.length) {
this.sineWaveIndex = 0;
}
@@ -359,7 +359,7 @@ private void loadInstruments(InputStream stream) {
}
if (this.channels == null) {
- this.channels = new MidiChannel[this.NUMCHANNELS];
+ this.channels = new MidiChannel[this.numChannels];
}
this.assignInstruments();
}
@@ -370,12 +370,12 @@ private void assignInstruments() {
//TODO: Consider making into a method
switch(this.instrumentChoice) {
- case 0: programIndex = this.DEFAULT_ROCK_ORGAN_INDEX; break;
- case 1: programIndex = this.sineWaveIndex; break;
- default: programIndex = this.instrumentChoice - 2; break;
+ case 0: programIndex = DEFAULT_ROCK_ORGAN_INDEX; break;
+ case 1: programIndex = this.sineWaveIndex; break;
+ default: programIndex = this.instrumentChoice - 2; break;
}
- for (int i = 0; i < this.NUMCHANNELS; i++) {
+ for (int i = 0; i < this.numChannels; i++) {
this.channels[i] = this.synth.getChannels()[i];
this.channels[i].programChange(this.synth.getLoadedInstruments()[programIndex].getPatch().getProgram());
this.channels[i].setChannelPressure(1);
@@ -393,30 +393,30 @@ private void assignInstruments() {
public void testInstrument(int programIndex) {
this.testInstrumentChoice = programIndex;
- if (this.ArrayVisualizer.isActive()) {
+ if (this.arrayVisualizer.isActive()) {
new Thread("TestInstrumentThread") {
@Override
public void run() {
switch(Sounds.this.testInstrumentChoice) {
- case 0: Sounds.this.testInstrumentChoice = Sounds.this.DEFAULT_ROCK_ORGAN_INDEX; break;
- case 1: Sounds.this.testInstrumentChoice = Sounds.this.sineWaveIndex; break;
- default: Sounds.this.testInstrumentChoice -= 2; break;
+ case 0: Sounds.this.testInstrumentChoice = DEFAULT_ROCK_ORGAN_INDEX; break;
+ case 1: Sounds.this.testInstrumentChoice = Sounds.this.sineWaveIndex; break;
+ default: Sounds.this.testInstrumentChoice -= 2; break;
}
int savedInstrument;
//TODO: Consider making into a method
switch(Sounds.this.instrumentChoice) {
- case 0: savedInstrument = Sounds.this.DEFAULT_ROCK_ORGAN_INDEX; break;
- case 1: savedInstrument = Sounds.this.sineWaveIndex; break;
- default: savedInstrument = Sounds.this.instrumentChoice - 2; break;
+ case 0: savedInstrument = DEFAULT_ROCK_ORGAN_INDEX; break;
+ case 1: savedInstrument = Sounds.this.sineWaveIndex; break;
+ default: savedInstrument = Sounds.this.instrumentChoice - 2; break;
}
try {
- for (int i = 0; i < Sounds.this.NUMCHANNELS; i++) {
+ for (int i = 0; i < Sounds.this.numChannels; i++) {
Sounds.this.channels[i].programChange(Sounds.this.synth.getLoadedInstruments()[Sounds.this.testInstrumentChoice].getPatch().getProgram());
}
sleep(2000);
- for (int i = 0; i < Sounds.this.NUMCHANNELS; i++) {
+ for (int i = 0; i < Sounds.this.numChannels; i++) {
Sounds.this.channels[i].programChange(Sounds.this.synth.getLoadedInstruments()[savedInstrument].getPatch().getProgram());
}
} catch (InterruptedException e) {
@@ -429,23 +429,23 @@ public void run() {
@Override
public void run() {
switch(Sounds.this.testInstrumentChoice) {
- case 0: Sounds.this.testInstrumentChoice = Sounds.this.DEFAULT_ROCK_ORGAN_INDEX; break;
- case 1: Sounds.this.testInstrumentChoice = Sounds.this.sineWaveIndex; break;
- default: Sounds.this.testInstrumentChoice -= 2; break;
+ case 0: Sounds.this.testInstrumentChoice = DEFAULT_ROCK_ORGAN_INDEX; break;
+ case 1: Sounds.this.testInstrumentChoice = Sounds.this.sineWaveIndex; break;
+ default: Sounds.this.testInstrumentChoice -= 2; break;
}
int savedInstrument;
//TODO: Consider making into a method
switch(Sounds.this.instrumentChoice) {
- case 0: savedInstrument = Sounds.this.DEFAULT_ROCK_ORGAN_INDEX; break;
- case 1: savedInstrument = Sounds.this.sineWaveIndex; break;
- default: savedInstrument = Sounds.this.instrumentChoice - 2; break;
+ case 0: savedInstrument = DEFAULT_ROCK_ORGAN_INDEX; break;
+ case 1: savedInstrument = Sounds.this.sineWaveIndex; break;
+ default: savedInstrument = Sounds.this.instrumentChoice - 2; break;
}
try {
Sounds.this.channels[0].programChange(Sounds.this.synth.getLoadedInstruments()[Sounds.this.testInstrumentChoice].getPatch().getProgram());
- Sounds.this.channels[0].controlChange(Sounds.this.SUSTAIN_PEDAL, 64);
+ Sounds.this.channels[0].controlChange(SUSTAIN_PEDAL, 64);
Sounds.this.channels[0].noteOn(60, 100);
Sounds.this.channels[0].noteOn(64, 100);
@@ -459,7 +459,7 @@ public void run() {
Sounds.this.channels[0].noteOff(67);
Sounds.this.channels[0].noteOff(72);
- Sounds.this.channels[0].controlChange(Sounds.this.SUSTAIN_PEDAL, 0);
+ Sounds.this.channels[0].controlChange(SUSTAIN_PEDAL, 0);
/*
int eighth = 200;
@@ -548,41 +548,41 @@ public void run() {
}
public synchronized void toggleSounds(boolean val) {
- this.SOUND = val;
+ this.playSound = val;
this.notifyAll();
}
public synchronized void toggleSound(boolean val) {
- this.MIDI = val;
+ this.playSound2 = val;
this.notifyAll();
}
//Double check logic
public void toggleSofterSounds(boolean val) {
- this.SOFTERSOUNDS = val;
+ this.softerSounds = val;
- if (this.SOFTERSOUNDS) this.SOUNDMUL = 0.01;
- else this.SOUNDMUL = 1;
+ if (this.softerSounds) this.soundMultiplier = 0.01;
+ else this.soundMultiplier = 1;
}
public double getVolume() {
- return this.SOUNDMUL;
+ return this.soundMultiplier;
}
public void changeVolume(double val) {
- this.SOUNDMUL = val;
+ this.soundMultiplier = val;
}
public void changeNoteDelayAndFilter(int noteFactor) {
if (noteFactor != this.noteDelay) {
if (noteFactor > 1) {
this.noteDelay = noteFactor;
- this.SOUNDMUL = 1d / noteFactor;
+ this.soundMultiplier = 1d / noteFactor;
} else {
//Double check logic
this.noteDelay = 1;
- if (this.SOFTERSOUNDS) this.SOUNDMUL = 0.01;
- else this.SOUNDMUL = 1;
+ if (this.softerSounds) this.soundMultiplier = 0.01;
+ else this.soundMultiplier = 1;
}
}
}
@@ -591,7 +591,7 @@ public void startAudioThread() {
if (!this.soundEnabled) {
JOptionPane.showMessageDialog(null, "Sound is disabled.", "Warning", JOptionPane.WARNING_MESSAGE);
}
- AudioThread.start();
+ audioThread.start();
}
public void closeSynth() {
diff --git a/src/main/java/io/github/arrayv/utils/Statistics.java b/src/main/java/io/github/arrayv/utils/Statistics.java
index 345f97d0..4e402e1a 100644
--- a/src/main/java/io/github/arrayv/utils/Statistics.java
+++ b/src/main/java/io/github/arrayv/utils/Statistics.java
@@ -5,7 +5,7 @@
import io.github.arrayv.main.ArrayVisualizer;
public final class Statistics {
- public long frameTimeMillis;
+ private long frameTimeMillis;
private String sortCategory;
private String sortHeading;
@@ -30,9 +30,9 @@ public final class Statistics {
private DecimalFormat formatter;
- public Statistics(ArrayVisualizer ArrayVisualizer) {
- this.formatter = ArrayVisualizer.getNumberFormat();
- this.updateStats(ArrayVisualizer);
+ public Statistics(ArrayVisualizer arrayVisualizer) {
+ this.formatter = arrayVisualizer.getNumberFormat();
+ this.updateStats(arrayVisualizer);
}
public int[] findSegments(int[] array, int length, boolean reversed) {
@@ -49,38 +49,42 @@ public int[] findSegments(int[] array, int length, boolean reversed) {
return result;
}
- public void updateStats(ArrayVisualizer ArrayVisualizer) {
- this.sortCategory = ArrayVisualizer.getCategory();
- this.sortHeading = ArrayVisualizer.getHeading();
- this.sortExtraHeading = ArrayVisualizer.getExtraHeading();
- int showUnique = Math.min(ArrayVisualizer.getUniqueItems(), ArrayVisualizer.getCurrentLength());
- this.arrayLength = this.formatter.format(ArrayVisualizer.getCurrentLength()) + " Numbers"
- + ", " + this.formatter.format(showUnique) + " Unique";
+ public void updateStats(ArrayVisualizer arrayVisualizer) {
+ this.sortCategory = arrayVisualizer.getCategory();
+ this.sortHeading = arrayVisualizer.getHeading();
+ this.sortExtraHeading = arrayVisualizer.getExtraHeading();
+ int showUnique = Math.min(arrayVisualizer.getUniqueItems(), arrayVisualizer.getCurrentLength());
+ this.arrayLength = this.formatter.format(arrayVisualizer.getCurrentLength()) + " Numbers"
+ + ", " + this.formatter.format(showUnique) + " Unique";
if (frameTimeMillis == 0) {
this.framerate = ">1000 FPS";
} else {
this.framerate = (int)(1000.0 / frameTimeMillis) + " FPS";
}
- this.sortDelay = "Delay: " + ArrayVisualizer.getDelays().displayCurrentDelay();
- this.visualTime = "Visual Time: " + ArrayVisualizer.getTimer().getVisualTime();
- this.estSortTime = "Sort Time: " + ArrayVisualizer.getTimer().getRealTime();
+ this.sortDelay = "Delay: " + arrayVisualizer.getDelays().displayCurrentDelay();
+ this.visualTime = "Visual Time: " + arrayVisualizer.getTimer().getVisualTime();
+ this.estSortTime = "Sort Time: " + arrayVisualizer.getTimer().getRealTime();
- this.comparisonCount = ArrayVisualizer.getReads().getStats();
- this.swapCount = ArrayVisualizer.getWrites().getSwaps();
- this.reversalCount = ArrayVisualizer.getWrites().getReversals();
+ this.comparisonCount = arrayVisualizer.getReads().getStats();
+ this.swapCount = arrayVisualizer.getWrites().getSwaps();
+ this.reversalCount = arrayVisualizer.getWrites().getReversals();
- this.mainWriteCount = ArrayVisualizer.getWrites().getMainWrites();
- this.auxWriteCount = ArrayVisualizer.getWrites().getAuxWrites();
+ this.mainWriteCount = arrayVisualizer.getWrites().getMainWrites();
+ this.auxWriteCount = arrayVisualizer.getWrites().getAuxWrites();
- this.auxAllocAmount = ArrayVisualizer.getWrites().getAllocAmount();
+ this.auxAllocAmount = arrayVisualizer.getWrites().getAllocAmount();
- int[] shadowarray = ArrayVisualizer.getArray();
- int[] rawSegments = this.findSegments(shadowarray, ArrayVisualizer.getCurrentLength(), ArrayVisualizer.reversedComparator());
+ int[] shadowarray = arrayVisualizer.getArray();
+ int[] rawSegments = this.findSegments(shadowarray, arrayVisualizer.getCurrentLength(), arrayVisualizer.reversedComparator());
String plural = rawSegments[0] == 1 ? "" : "s";
this.segments = String.valueOf(rawSegments[1]) + "% Sorted (" + String.valueOf(rawSegments[0]) + " Segment" + plural + ")";
}
+ public void setFrameTimeMillis(long frameTimeMillis) {
+ this.frameTimeMillis = frameTimeMillis;
+ }
+
public String getSortIdentity() {
return this.sortCategory + ": " + this.sortHeading;
}
diff --git a/src/main/java/io/github/arrayv/utils/Timer.java b/src/main/java/io/github/arrayv/utils/Timer.java
index e27c1f0b..acd853e7 100644
--- a/src/main/java/io/github/arrayv/utils/Timer.java
+++ b/src/main/java/io/github/arrayv/utils/Timer.java
@@ -39,7 +39,7 @@ public final class Timer {
private volatile int elapsedTime;
private volatile double realTimer;
- private volatile boolean REALTIMER;
+ private volatile boolean useRealTimer;
private volatile double sortRunTime;
private volatile boolean timerEnabled;
@@ -49,13 +49,13 @@ public final class Timer {
private long timeStart;
private long timeStop;
- public Timer(ArrayVisualizer ArrayVisualizer) {
- this.REALTIMER = true;
+ public Timer(ArrayVisualizer arrayVisualizer) {
+ this.useRealTimer = true;
this.timeStart = 0;
this.timeStop = 0;
- this.formatter = ArrayVisualizer.getNumberFormat();
+ this.formatter = arrayVisualizer.getNumberFormat();
this.categoricalTimes = new Hashtable<>();
}
@@ -77,13 +77,12 @@ public String getVisualTime() {
public String prettifyTime(double time) {
double realTime = time * 1e-6d;
- if (!this.REALTIMER) {
+ if (!this.useRealTimer) {
return "Disabled";
} else if (realTime == 0) {
if (this.timerEnabled) return "0.000ms";
else return "---ms";
- }
- else if (realTime < 0.001) return "< 0.001ms";
+ } else if (realTime < 0.001) return "< 0.001ms";
else if (realTime >= 60000.000) return "~" + this.formatter.format((int) (realTime / 60000)) + "m" + (int) ((realTime % 60000) / 1000) + "s";
else if (realTime >= 1000.000) return "~" + this.formatter.format(realTime / 1000) + "s";
else return "~" + this.formatter.format(realTime) + "ms";
@@ -93,12 +92,12 @@ public String getRealTime() {
return prettifyTime(this.realTimer);
}
- public void toggleRealTimer(boolean Bool) {
- this.REALTIMER = Bool;
+ public void toggleRealTimer(boolean useRealTimer) {
+ this.useRealTimer = useRealTimer;
}
public void enableRealTimer() {
- if (REALTIMER) this.timerEnabled = true;
+ if (useRealTimer) this.timerEnabled = true;
this.sortRunTime = System.nanoTime();
this.realTimer = 0;
}
diff --git a/src/main/java/io/github/arrayv/utils/Writes.java b/src/main/java/io/github/arrayv/utils/Writes.java
index d7666d8c..2ffb9981 100644
--- a/src/main/java/io/github/arrayv/utils/Writes.java
+++ b/src/main/java/io/github/arrayv/utils/Writes.java
@@ -47,24 +47,24 @@ public final class Writes {
private DecimalFormat formatter;
- private ArrayVisualizer ArrayVisualizer;
+ private ArrayVisualizer arrayVisualizer;
private Delays Delays;
private Highlights Highlights;
private Timer Timer;
- public Writes(ArrayVisualizer ArrayVisualizer) {
+ public Writes(ArrayVisualizer arrayVisualizer) {
this.reversals = 0;
this.swaps = 0;
this.auxWrites = 0;
this.writes = 0;
this.allocAmount = 0;
- this.ArrayVisualizer = ArrayVisualizer;
- this.Delays = ArrayVisualizer.getDelays();
- this.Highlights = ArrayVisualizer.getHighlights();
- this.Timer = ArrayVisualizer.getTimer();
+ this.arrayVisualizer = arrayVisualizer;
+ this.Delays = arrayVisualizer.getDelays();
+ this.Highlights = arrayVisualizer.getHighlights();
+ this.Timer = arrayVisualizer.getTimer();
- this.formatter = ArrayVisualizer.getNumberFormat();
+ this.formatter = arrayVisualizer.getNumberFormat();
}
public void resetStatistics() {
@@ -157,12 +157,12 @@ private void markSwap(int a, int b) {
}
public void swap(int[] array, int a, int b, double pause, boolean mark, boolean auxwrite) {
- if (ArrayVisualizer.sortCanceled()) throw new StopSort();
- if (!auxwrite && a >= ArrayVisualizer.getCurrentLength()) {
- System.err.println("Warning: write to index " + a + ", which is out of bounds for the current length (" + ArrayVisualizer.getCurrentLength() + ")");
+ if (arrayVisualizer.sortCanceled()) throw new StopSort();
+ if (!auxwrite && a >= arrayVisualizer.getCurrentLength()) {
+ System.err.println("Warning: write to index " + a + ", which is out of bounds for the current length (" + arrayVisualizer.getCurrentLength() + ")");
}
- if (!auxwrite && b >= ArrayVisualizer.getCurrentLength()) {
- System.err.println("Warning: write to index " + b + ", which is out of bounds for the current length (" + ArrayVisualizer.getCurrentLength() + ")");
+ if (!auxwrite && b >= arrayVisualizer.getCurrentLength()) {
+ System.err.println("Warning: write to index " + b + ", which is out of bounds for the current length (" + arrayVisualizer.getCurrentLength() + ")");
}
if (mark) this.markSwap(a, b);
@@ -176,7 +176,7 @@ public void swap(int[] array, int a, int b, double pause, boolean mark, boolean
Timer.stopLap();
this.updateSwap(auxwrite);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.updateNow();
Delays.sleep(pause);
}
@@ -203,9 +203,9 @@ public void reversal(int[] array, int start, int length, double sleep, boolean m
}
public void write(int[] array, int at, int equals, double pause, boolean mark, boolean auxwrite) {
- if (ArrayVisualizer.sortCanceled()) throw new StopSort();
- if (!auxwrite && at >= ArrayVisualizer.getCurrentLength()) {
- System.err.println("Warning: write to index " + at + ", which is out of bounds for the current length (" + ArrayVisualizer.getCurrentLength() + ")");
+ if (arrayVisualizer.sortCanceled()) throw new StopSort();
+ if (!auxwrite && at >= arrayVisualizer.getCurrentLength()) {
+ System.err.println("Warning: write to index " + at + ", which is out of bounds for the current length (" + arrayVisualizer.getCurrentLength() + ")");
}
if (mark) Highlights.markArray(1, at);
@@ -219,12 +219,12 @@ public void write(int[] array, int at, int equals, double pause, boolean mark, b
Timer.stopLap();
- ArrayVisualizer.updateNow();
+ arrayVisualizer.updateNow();
Delays.sleep(pause);
}
public void write(T[] array, int at, T equals, double pause, boolean mark) {
- if (ArrayVisualizer.sortCanceled()) throw new StopSort();
+ if (arrayVisualizer.sortCanceled()) throw new StopSort();
if (mark) Highlights.markArray(1, at);
auxWrites++;
@@ -235,7 +235,7 @@ public void write(T[] array, int at, T equals, double pause, boolean mark) {
Timer.stopLap();
- ArrayVisualizer.updateNow();
+ arrayVisualizer.updateNow();
Delays.sleep(pause);
}
@@ -248,7 +248,7 @@ public void visualClear(int[] array, int index, double delay) {
}
public void multiDimWrite(int[][] array, int x, int y, int equals, double pause, boolean mark, boolean auxwrite) {
- if (ArrayVisualizer.sortCanceled()) throw new StopSort();
+ if (arrayVisualizer.sortCanceled()) throw new StopSort();
if (mark) Highlights.markArray(1, x);
if (auxwrite) auxWrites++;
@@ -260,12 +260,12 @@ public void multiDimWrite(int[][] array, int x, int y, int equals, double pause,
Timer.stopLap();
- ArrayVisualizer.updateNow();
+ arrayVisualizer.updateNow();
Delays.sleep(pause);
}
public void multiDimWrite(T[][] array, int x, int y, T equals, double pause, boolean mark) {
- if (ArrayVisualizer.sortCanceled()) throw new StopSort();
+ if (arrayVisualizer.sortCanceled()) throw new StopSort();
if (mark) Highlights.markArray(1, x);
auxWrites++;
@@ -276,13 +276,13 @@ public void multiDimWrite(T[][] array, int x, int y, T equals, double pause,
Timer.stopLap();
- ArrayVisualizer.updateNow();
+ arrayVisualizer.updateNow();
Delays.sleep(pause);
}
//Simulates a write in order to better estimate time for values being written to an ArrayList
public void mockWrite(int length, int pos, int val, double pause) {
- if (ArrayVisualizer.sortCanceled()) throw new StopSort();
+ if (arrayVisualizer.sortCanceled()) throw new StopSort();
int[] mockArray = new int[length];
this.auxWrites++;
@@ -385,16 +385,16 @@ public void arraycopy(int[] src, int srcPos, int[] dest, int destPos, int length
public int[] copyOfArray(int[] original, int newLength) {
this.allocAmount += newLength;
int[] result = Arrays.copyOf(original, newLength);
- ArrayVisualizer.getArrays().add(result);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.getArrays().add(result);
+ arrayVisualizer.updateNow();
return result;
}
public int[] copyOfRangeArray(int[] original, int from, int to) {
this.allocAmount += to - from;
int[] result = Arrays.copyOfRange(original, from, to);
- ArrayVisualizer.getArrays().add(result);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.getArrays().add(result);
+ arrayVisualizer.updateNow();
return result;
}
@@ -419,22 +419,22 @@ public ArrayVList createArrayList(int defaultCapacity) {
public int[] createExternalArray(int length) {
this.allocAmount += length;
int[] result = new int[length];
- ArrayVisualizer.getArrays().add(result);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.getArrays().add(result);
+ arrayVisualizer.updateNow();
return result;
}
public void deleteExternalArray(int[] array) {
this.allocAmount -= array.length;
- ArrayVisualizer.getArrays().remove(array);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.getArrays().remove(array);
+ arrayVisualizer.updateNow();
}
public void deleteExternalArrays(int[]... arrays) {
this.allocAmount -= Arrays.stream(arrays).reduce(0, (a, b) -> (a + b.length), (a, b) -> a + b);
- List visArrays = ArrayVisualizer.getArrays();
+ List visArrays = arrayVisualizer.getArrays();
Arrays.stream(arrays).forEach(visArrays::remove);
- ArrayVisualizer.updateNow();
+ arrayVisualizer.updateNow();
}
public void arrayListAdd(List aList, int value) {
diff --git a/src/main/java/io/github/arrayv/utils/m.java b/src/main/java/io/github/arrayv/utils/m.java
index 060359b9..fe6ff99f 100644
--- a/src/main/java/io/github/arrayv/utils/m.java
+++ b/src/main/java/io/github/arrayv/utils/m.java
@@ -1,6 +1,10 @@
package io.github.arrayv.utils;
+// @checkstyle:off TypeNameCheck
public final class m {
+// @checkstyle:on TypeNameCheck
+ private m() {
+ }
/**
* Returns the logarithm base BASE of the number X
@@ -114,7 +118,8 @@ public static int ceil(double x) {
return (int)Math.ceil(x);
}
- public final double inf = Double.POSITIVE_INFINITY;
- public final double NaN = Double.NaN;
-
+ // @checkstyle:off ConstantNameCheck
+ public static final double inf = Double.POSITIVE_INFINITY;
+ public static final double NaN = Double.NaN;
+ // @checkstyle:on ConstantNameCheck
}
diff --git a/src/main/java/io/github/arrayv/utils/shuffleutils/AWTUtils.java b/src/main/java/io/github/arrayv/utils/shuffleutils/AWTUtils.java
index 1eaa14f3..f81d320e 100644
--- a/src/main/java/io/github/arrayv/utils/shuffleutils/AWTUtils.java
+++ b/src/main/java/io/github/arrayv/utils/shuffleutils/AWTUtils.java
@@ -7,7 +7,10 @@
import java.awt.font.GlyphVector;
import java.awt.geom.Rectangle2D;
-public class AWTUtils {
+public final class AWTUtils {
+ private AWTUtils() {
+ }
+
public static void drawCircle(Graphics2D g, int x, int y, int r) {
x = x - r;
y = y - r;
diff --git a/src/main/java/io/github/arrayv/utils/shuffleutils/GraphConnection.java b/src/main/java/io/github/arrayv/utils/shuffleutils/GraphConnection.java
index 86ec0e0f..4f3d3449 100644
--- a/src/main/java/io/github/arrayv/utils/shuffleutils/GraphConnection.java
+++ b/src/main/java/io/github/arrayv/utils/shuffleutils/GraphConnection.java
@@ -8,8 +8,8 @@
import java.util.List;
public class GraphConnection {
- public GraphNode from, to;
- public Point currentDragPos;
+ private GraphNode from, to;
+ private Point currentDragPos;
public GraphConnection(GraphNode from, GraphNode to) {
this.from = from;
@@ -49,18 +49,18 @@ public void draw(Graphics2D g) {
public void remove() {
if (this.from != null) {
- this.from.postConnection = null;
+ this.from.setPostConnection(null);
}
if (this.to != null) {
- this.to.preConnection = null;
+ this.to.setPreConnection(null);
}
}
public void finishDragging(GraphNode other) {
this.to = other;
- other.preConnection = this;
+ other.setPreConnection(this);
int removed = 0;
- List connections = other.graph.connections;
+ List connections = other.getGraph().getConnections();
for (int i = 0; i < connections.size(); i++) {
GraphConnection conn = connections.get(i - removed);
if (conn == this) {
@@ -73,4 +73,28 @@ public void finishDragging(GraphNode other) {
}
}
}
+
+ public GraphNode getFrom() {
+ return from;
+ }
+
+ public void setFrom(GraphNode node) {
+ this.from = node;
+ }
+
+ public GraphNode getTo() {
+ return to;
+ }
+
+ public void setTo(GraphNode node) {
+ this.to = node;
+ }
+
+ public Point getCurrentDragPos() {
+ return currentDragPos;
+ }
+
+ public void setCurrentDragPos(Point pos) {
+ this.currentDragPos = pos;
+ }
}
diff --git a/src/main/java/io/github/arrayv/utils/shuffleutils/GraphNode.java b/src/main/java/io/github/arrayv/utils/shuffleutils/GraphNode.java
index 258ad830..38b047c6 100644
--- a/src/main/java/io/github/arrayv/utils/shuffleutils/GraphNode.java
+++ b/src/main/java/io/github/arrayv/utils/shuffleutils/GraphNode.java
@@ -12,10 +12,10 @@ public class GraphNode {
public static final int WIDTH = 250;
public static final int HEIGHT = 50;
- public ShuffleInfo shuffle;
- public int x, y;
- public ShuffleGraph graph;
- public GraphConnection preConnection, postConnection;
+ private ShuffleInfo shuffle;
+ private int x, y;
+ private ShuffleGraph graph;
+ private GraphConnection preConnection, postConnection;
public GraphNode(ShuffleInfo shuffle, ShuffleGraph graph, int x, int y) {
this.shuffle = shuffle;
@@ -55,8 +55,8 @@ protected String getShuffleName() {
}
public void draw(Graphics2D g) {
- Color borderColor = this.graph.selected == this ? new Color(128, 128, 255) : new Color(0, 0, 0);
- Color leftColor = this.graph.dragCandidate == this ? new Color(128, 128, 255) : borderColor;
+ Color borderColor = this.graph.getSelected() == this ? new Color(128, 128, 255) : new Color(0, 0, 0);
+ Color leftColor = this.graph.getDragCandidate() == this ? new Color(128, 128, 255) : borderColor;
g.setColor(leftColor);
AWTUtils.drawCircle(g, x, y + HEIGHT / 2, 10);
g.setColor(borderColor);
@@ -93,24 +93,24 @@ public boolean inStartDrag(Point pos) {
}
public void delete() {
- if (this == this.graph.selected) {
- this.graph.selected = null;
+ if (this == this.graph.getSelected()) {
+ this.graph.setSelected(null);
}
- this.graph.nodes.remove(this);
+ this.graph.getNodes().remove(this);
if (this.preConnection != null) {
if (this.postConnection == null) {
- this.graph.connections.remove(this.preConnection);
+ this.graph.getConnections().remove(this.preConnection);
this.preConnection.remove();
} else {
- this.preConnection.to = this.postConnection.to;
+ this.preConnection.setTo(this.postConnection.getTo());
}
}
if (this.postConnection != null) {
if (this.preConnection == null) {
- this.graph.connections.remove(this.postConnection);
+ this.graph.getConnections().remove(this.postConnection);
this.postConnection.remove();
} else {
- this.postConnection.from = this.preConnection.from;
+ this.postConnection.setFrom(this.preConnection.getFrom());
}
}
}
@@ -122,4 +122,44 @@ public Point getPos() {
public ShuffleInfo getValue() {
return this.shuffle;
}
+
+ public int getX() {
+ return x;
+ }
+
+ public int getY() {
+ return y;
+ }
+
+ public ShuffleGraph getGraph() {
+ return graph;
+ }
+
+ public GraphConnection getPreConnection() {
+ return preConnection;
+ }
+
+ public GraphConnection getPostConnection() {
+ return postConnection;
+ }
+
+ public void setX(int x) {
+ this.x = x;
+ }
+
+ public void setY(int y) {
+ this.y = y;
+ }
+
+ public void setGraph(ShuffleGraph graph) {
+ this.graph = graph;
+ }
+
+ public void setPreConnection(GraphConnection connection) {
+ this.preConnection = connection;
+ }
+
+ public void setPostConnection(GraphConnection connection) {
+ this.postConnection = connection;
+ }
}
diff --git a/src/main/java/io/github/arrayv/utils/shuffleutils/GraphReader.java b/src/main/java/io/github/arrayv/utils/shuffleutils/GraphReader.java
index 5da5d023..f5f6de6b 100644
--- a/src/main/java/io/github/arrayv/utils/shuffleutils/GraphReader.java
+++ b/src/main/java/io/github/arrayv/utils/shuffleutils/GraphReader.java
@@ -30,13 +30,13 @@ public MalformedGraphFileException(String message) {
private final class PartialElement {
int left, right;
- public PartialElement(int left, int right) {
+ private PartialElement(int left, int right) {
this.left = left;
this.right = right;
}
}
- public final static int[] COMPATIBLE_VERSIONS = {0, 1, 2, 3};
+ public static final int[] COMPATIBLE_VERSIONS = {0, 1, 2, 3};
static Set compatibleVersionsSet;
Scanner scanner;
@@ -101,7 +101,7 @@ private void read() throws IOException, MalformedGraphFileException {
partialNodes = new ArrayList<>();
if (version >= 2 && scanner.hasNextDouble()) {
- result.sleepRatio = scanner.nextDouble();
+ result.setSleepRatio(scanner.nextDouble());
}
while (scanner.hasNext()) {
@@ -118,27 +118,27 @@ private void read() throws IOException, MalformedGraphFileException {
}
}
- for (int i = 1; i < result.nodes.size(); i++) {
- GraphNode node = result.nodes.get(i);
+ for (int i = 1; i < result.getNodes().size(); i++) {
+ GraphNode node = result.getNodes().get(i);
PartialElement partial = partialNodes.get(i - 1);
try {
if (version < 3) {
- node.preConnection = partial.left == -1 ? null : result.connections.get(partial.left);
- node.postConnection = partial.right == -1 ? null : result.connections.get(partial.right);
+ node.setPreConnection(partial.left == -1 ? null : result.getConnections().get(partial.left));
+ node.setPostConnection(partial.right == -1 ? null : result.getConnections().get(partial.right));
} else {
- if (partial.left != -1 && node.preConnection == null) {
- GraphNode from = result.nodes.get(partial.left);
+ if (partial.left != -1 && node.getPreConnection() == null) {
+ GraphNode from = result.getNodes().get(partial.left);
GraphConnection newConnection = new GraphConnection(from, node);
- result.connections.add(newConnection);
- from.postConnection = newConnection;
- node.preConnection = newConnection;
+ result.getConnections().add(newConnection);
+ from.setPostConnection(newConnection);
+ node.setPreConnection(newConnection);
}
- if (partial.right != -1 && node.postConnection == null) {
- GraphNode to = result.nodes.get(partial.right);
+ if (partial.right != -1 && node.getPostConnection() == null) {
+ GraphNode to = result.getNodes().get(partial.right);
GraphConnection newConnection = new GraphConnection(node, to);
- result.connections.add(newConnection);
- node.postConnection = newConnection;
- to.preConnection = newConnection;
+ result.getConnections().add(newConnection);
+ node.setPostConnection(newConnection);
+ to.setPreConnection(newConnection);
}
}
} catch (IndexOutOfBoundsException e) {
@@ -151,17 +151,17 @@ private void read() throws IOException, MalformedGraphFileException {
}
if (version >= 2) {
- for (int i = 1; i < result.nodes.size(); i++) {
- GraphNode node = result.nodes.get(i);
- if (node.x == Integer.MIN_VALUE) { // coordinates not specified
- if (node.preConnection == null || node.preConnection.from == null) {
+ for (int i = 1; i < result.getNodes().size(); i++) {
+ GraphNode node = result.getNodes().get(i);
+ if (node.getX() == Integer.MIN_VALUE) { // coordinates not specified
+ if (node.getPreConnection() == null || node.getPreConnection() == null) {
Point safePos = result.findSafeCoordinates(100, 100, 20, 20);
- node.x = safePos.x;
- node.y = safePos.y;
+ node.setX(safePos.x);
+ node.setY(safePos.y);
} else {
- GraphNode previous = node.preConnection.from;
- node.x = previous.x + GraphNode.WIDTH + 15;
- node.y = previous.y;
+ GraphNode previous = node.getPreConnection().getFrom();
+ node.setX(previous.getX() + GraphNode.WIDTH + 15);
+ node.setY(previous.getY());
}
}
}
@@ -244,7 +244,7 @@ private void readNode() throws MalformedGraphFileException {
}
}
- result.nodes.add(new GraphNode(shuffleInfo, result, x, y));
+ result.getNodes().add(new GraphNode(shuffleInfo, result, x, y));
partialNodes.add(new PartialElement(preConnectionID, postConnectionID));
}
@@ -263,8 +263,8 @@ private void readConnection() throws MalformedGraphFileException {
GraphNode fromNode = null, toNode = null;
try {
- fromNode = fromNodeID == -1 ? null : result.nodes.get(fromNodeID);
- toNode = toNodeID == -1 ? null : result.nodes.get(toNodeID);
+ fromNode = fromNodeID == -1 ? null : result.getNodes().get(fromNodeID);
+ toNode = toNodeID == -1 ? null : result.getNodes().get(toNodeID);
} catch (IndexOutOfBoundsException e) {
String message = e.getMessage();
int id = Integer.parseInt(message.split(" ", 3)[1]);
@@ -273,9 +273,9 @@ private void readConnection() throws MalformedGraphFileException {
throw newError;
}
GraphConnection connection = new GraphConnection(fromNode, toNode);
- result.connections.add(connection);
+ result.getConnections().add(connection);
if (fromNodeID == 0) {
- fromNode.postConnection = connection;
+ fromNode.setPostConnection(connection);
}
}
}
diff --git a/src/main/java/io/github/arrayv/utils/shuffleutils/GraphWriter.java b/src/main/java/io/github/arrayv/utils/shuffleutils/GraphWriter.java
index f03db522..0e56053e 100644
--- a/src/main/java/io/github/arrayv/utils/shuffleutils/GraphWriter.java
+++ b/src/main/java/io/github/arrayv/utils/shuffleutils/GraphWriter.java
@@ -29,19 +29,19 @@ public void write(File file) throws IOException {
public void write(FileWriter writer) throws IOException {
Map nodeMap = new HashMap<>();
- for (int i = 0; i < graph.nodes.size(); i++) {
- GraphNode node = graph.nodes.get(i);
+ for (int i = 0; i < graph.getNodes().size(); i++) {
+ GraphNode node = graph.getNodes().get(i);
nodeMap.put(node, i);
}
nodeMap.put(null, -1);
// Metadata
writer.write(VERSION + " ");
- writer.write(graph.sleepRatio + "\n");
+ writer.write(graph.getSleepRatio() + "\n");
// Nodes
- for (int i = 1; i < graph.nodes.size(); i++) {
- GraphNode node = graph.nodes.get(i);
+ for (int i = 1; i < graph.getNodes().size(); i++) {
+ GraphNode node = graph.getNodes().get(i);
writer.write("N ");
if (node.getValue().isDistribution()) {
writer.write("true ");
@@ -51,10 +51,10 @@ public void write(FileWriter writer) throws IOException {
writer.write("false ");
writer.write(node.getValue().getShuffle().name() + " ");
}
- writer.write(node.x + " ");
- writer.write(node.y + " ");
- writer.write((node.preConnection == null ? -1 : nodeMap.get(node.preConnection.from)) + " ");
- writer.write((node.postConnection == null ? -1 : nodeMap.get(node.postConnection.to)) + "\n");
+ writer.write(node.getX() + " ");
+ writer.write(node.getY() + " ");
+ writer.write((node.getPreConnection() == null ? -1 : nodeMap.get(node.getPreConnection().getFrom())) + " ");
+ writer.write((node.getPostConnection() == null ? -1 : nodeMap.get(node.getPostConnection().getTo())) + "\n");
}
writer.close();
diff --git a/src/main/java/io/github/arrayv/visuals/Visual.java b/src/main/java/io/github/arrayv/visuals/Visual.java
index 8a35ce66..46a77cb3 100644
--- a/src/main/java/io/github/arrayv/visuals/Visual.java
+++ b/src/main/java/io/github/arrayv/visuals/Visual.java
@@ -12,13 +12,13 @@ public abstract class Visual {
protected Graphics2D mainRender;
protected Graphics2D extraRender;
- public Visual(ArrayVisualizer ArrayVisualizer) {
- this.updateRender(ArrayVisualizer);
+ public Visual(ArrayVisualizer arrayVisualizer) {
+ this.updateRender(arrayVisualizer);
}
- public void updateRender(ArrayVisualizer ArrayVisualizer) {
- this.mainRender = ArrayVisualizer.getMainRender();
- this.extraRender = ArrayVisualizer.getExtraRender();
+ public void updateRender(ArrayVisualizer arrayVisualizer) {
+ this.mainRender = arrayVisualizer.getMainRender();
+ this.extraRender = arrayVisualizer.getExtraRender();
}
public static Color getIntColor(int i, int length) {
@@ -29,9 +29,8 @@ public static void markBar(Graphics2D bar, boolean color, boolean rainbow, boole
if (color || rainbow) {
if (analysis) bar.setColor(Color.LIGHT_GRAY);
else bar.setColor(Color.WHITE);
- }
- else if (analysis) bar.setColor(Color.BLUE);
- else bar.setColor(Color.RED);
+ } else if (analysis) bar.setColor(Color.BLUE);
+ else bar.setColor(Color.RED);
}
private static void markBarFancy(Graphics2D bar, boolean color, boolean rainbow) {
if (!color && !rainbow) bar.setColor(Color.RED);
@@ -65,64 +64,70 @@ public static void setRectColor(Graphics2D rect, boolean color, boolean analysis
//The longer the array length, the more bars marked. Makes the visual easier to see when bars are thinner.
public static void colorMarkedBars(int logOfLen, int index, Highlights Highlights, Graphics2D mainRender, boolean colorEnabled, boolean rainbowEnabled, boolean analysis) {
switch(logOfLen) {
- case 15: if (Highlights.containsPosition(index - 15)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
- if (Highlights.containsPosition(index - 14)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
- if (Highlights.containsPosition(index - 13)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
- if (Highlights.containsPosition(index - 12)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
- if (Highlights.containsPosition(index - 11)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
- case 14: if (Highlights.containsPosition(index - 10)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
- if (Highlights.containsPosition(index - 9)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
- if (Highlights.containsPosition(index - 8)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
- case 13: if (Highlights.containsPosition(index - 7)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
- if (Highlights.containsPosition(index - 6)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
- if (Highlights.containsPosition(index - 5)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
- case 12: if (Highlights.containsPosition(index - 4)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
- if (Highlights.containsPosition(index - 3)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
- case 11: if (Highlights.containsPosition(index - 2)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
- case 10: if (Highlights.containsPosition(index - 1)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
- default: if (Highlights.containsPosition(index)) markBar(mainRender, colorEnabled, rainbowEnabled, analysis);
+ // @checkstyle:off LeftCurlyCheck|IndentationCheck
+ case 15: if (Highlights.containsPosition(index - 15)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
+ if (Highlights.containsPosition(index - 14)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
+ if (Highlights.containsPosition(index - 13)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
+ if (Highlights.containsPosition(index - 12)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
+ if (Highlights.containsPosition(index - 11)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
+ case 14: if (Highlights.containsPosition(index - 10)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
+ if (Highlights.containsPosition(index - 9)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
+ if (Highlights.containsPosition(index - 8)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
+ case 13: if (Highlights.containsPosition(index - 7)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
+ if (Highlights.containsPosition(index - 6)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
+ if (Highlights.containsPosition(index - 5)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
+ case 12: if (Highlights.containsPosition(index - 4)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
+ if (Highlights.containsPosition(index - 3)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
+ case 11: if (Highlights.containsPosition(index - 2)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
+ case 10: if (Highlights.containsPosition(index - 1)) { markBar(mainRender, colorEnabled, rainbowEnabled, analysis); break; }
+ default: if (Highlights.containsPosition(index)) markBar(mainRender, colorEnabled, rainbowEnabled, analysis);
+ // @checkstyle:on LeftCurlyCheck|IndentationCheck
}
}
public static void drawFancyFinish(int logOfLen, int index, int position, Graphics2D mainRender, boolean colorEnabled, boolean rainbowEnabled) {
switch(logOfLen) {
- case 15: if (index == position - 14) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
- case 14: if (index == position - 13) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
- case 13: if (index == position - 12) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
- case 12: if (index == position - 11) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
- case 11: if (index == position - 10) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
- case 10: if (index == position - 9) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
- case 9: if (index == position - 8) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
- case 8: if (index == position - 7) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
- case 7: if (index == position - 6) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
- case 6: if (index == position - 5) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
- case 5: if (index == position - 4) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
- case 4: if (index == position - 3) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
- case 3: if (index == position - 2) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
- case 2: if (index == position - 1) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
- default: if (index == position) markBarFancy(mainRender, colorEnabled, rainbowEnabled);
+ // @checkstyle:off LeftCurlyCheck
+ case 15: if (index == position - 14) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
+ case 14: if (index == position - 13) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
+ case 13: if (index == position - 12) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
+ case 12: if (index == position - 11) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
+ case 11: if (index == position - 10) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
+ case 10: if (index == position - 9) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
+ case 9: if (index == position - 8) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
+ case 8: if (index == position - 7) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
+ case 7: if (index == position - 6) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
+ case 6: if (index == position - 5) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
+ case 5: if (index == position - 4) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
+ case 4: if (index == position - 3) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
+ case 3: if (index == position - 2) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
+ case 2: if (index == position - 1) { markBarFancy(mainRender, colorEnabled, rainbowEnabled); break; }
+ default: if (index == position) markBarFancy(mainRender, colorEnabled, rainbowEnabled);
+ // @checkstyle:on LeftCurlyCheck
}
}
public static void drawFancyFinishLine(int logOfLen, int index, int position, Graphics2D mainRender, double width, boolean colorEnabled) {
switch(logOfLen) {
- case 15: if (index == position - 14) { lineMark(mainRender, width, colorEnabled, false); break; }
- case 14: if (index == position - 13) { lineMark(mainRender, width, colorEnabled, false); break; }
- case 13: if (index == position - 12) { lineMark(mainRender, width, colorEnabled, false); break; }
- case 12: if (index == position - 11) { lineMark(mainRender, width, colorEnabled, false); break; }
- case 11: if (index == position - 10) { lineMark(mainRender, width, colorEnabled, false); break; }
- case 10: if (index == position - 9) { lineMark(mainRender, width, colorEnabled, false); break; }
- case 9: if (index == position - 8) { lineMark(mainRender, width, colorEnabled, false); break; }
- case 8: if (index == position - 7) { lineMark(mainRender, width, colorEnabled, false); break; }
- case 7: if (index == position - 6) { lineMark(mainRender, width, colorEnabled, false); break; }
- case 6: if (index == position - 5) { lineMark(mainRender, width, colorEnabled, false); break; }
- case 5: if (index == position - 4) { lineMark(mainRender, width, colorEnabled, false); break; }
- case 4: if (index == position - 3) { lineMark(mainRender, width, colorEnabled, false); break; }
- case 3: if (index == position - 2) { lineMark(mainRender, width, colorEnabled, false); break; }
- case 2: if (index == position - 1) { lineMark(mainRender, width, colorEnabled, false); break; }
- default: if (index == position) lineMark(mainRender, width, colorEnabled, false);
+ // @checkstyle:off LeftCurlyCheck
+ case 15: if (index == position - 14) { lineMark(mainRender, width, colorEnabled, false); break; }
+ case 14: if (index == position - 13) { lineMark(mainRender, width, colorEnabled, false); break; }
+ case 13: if (index == position - 12) { lineMark(mainRender, width, colorEnabled, false); break; }
+ case 12: if (index == position - 11) { lineMark(mainRender, width, colorEnabled, false); break; }
+ case 11: if (index == position - 10) { lineMark(mainRender, width, colorEnabled, false); break; }
+ case 10: if (index == position - 9) { lineMark(mainRender, width, colorEnabled, false); break; }
+ case 9: if (index == position - 8) { lineMark(mainRender, width, colorEnabled, false); break; }
+ case 8: if (index == position - 7) { lineMark(mainRender, width, colorEnabled, false); break; }
+ case 7: if (index == position - 6) { lineMark(mainRender, width, colorEnabled, false); break; }
+ case 6: if (index == position - 5) { lineMark(mainRender, width, colorEnabled, false); break; }
+ case 5: if (index == position - 4) { lineMark(mainRender, width, colorEnabled, false); break; }
+ case 4: if (index == position - 3) { lineMark(mainRender, width, colorEnabled, false); break; }
+ case 3: if (index == position - 2) { lineMark(mainRender, width, colorEnabled, false); break; }
+ case 2: if (index == position - 1) { lineMark(mainRender, width, colorEnabled, false); break; }
+ default: if (index == position) lineMark(mainRender, width, colorEnabled, false);
+ // @checkstyle:on LeftCurlyCheck
}
}
- public abstract void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights);
+ public abstract void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights);
}
diff --git a/src/main/java/io/github/arrayv/visuals/VisualStyles.java b/src/main/java/io/github/arrayv/visuals/VisualStyles.java
index f7a08cfc..76630b44 100644
--- a/src/main/java/io/github/arrayv/visuals/VisualStyles.java
+++ b/src/main/java/io/github/arrayv/visuals/VisualStyles.java
@@ -33,92 +33,92 @@ of this software and associated documentation files (the "Software"), to deal
public enum VisualStyles {
BARS {
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- ArrayVisualizer.getVisuals()[0].drawVisual(array, ArrayVisualizer, Renderer, Highlights);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ arrayVisualizer.getVisuals()[0].drawVisual(array, arrayVisualizer, renderer, Highlights);
}
},
RAINBOW {
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- ArrayVisualizer.getVisuals()[1].drawVisual(array, ArrayVisualizer, Renderer, Highlights);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ arrayVisualizer.getVisuals()[1].drawVisual(array, arrayVisualizer, renderer, Highlights);
}
},
DISP_BARS {
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- ArrayVisualizer.getVisuals()[2].drawVisual(array, ArrayVisualizer, Renderer, Highlights);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ arrayVisualizer.getVisuals()[2].drawVisual(array, arrayVisualizer, renderer, Highlights);
}
},
COLOR_CIRCLE {
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- ArrayVisualizer.getVisuals()[3].drawVisual(array, ArrayVisualizer, Renderer, Highlights);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ arrayVisualizer.getVisuals()[3].drawVisual(array, arrayVisualizer, renderer, Highlights);
}
},
DISP_CIRCLE {
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- ArrayVisualizer.getVisuals()[4].drawVisual(array, ArrayVisualizer, Renderer, Highlights);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ arrayVisualizer.getVisuals()[4].drawVisual(array, arrayVisualizer, renderer, Highlights);
}
},
DISP_CHORDS {
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- ArrayVisualizer.getVisuals()[5].drawVisual(array, ArrayVisualizer, Renderer, Highlights);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ arrayVisualizer.getVisuals()[5].drawVisual(array, arrayVisualizer, renderer, Highlights);
}
},
DISP_DOTS {
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- ArrayVisualizer.getVisuals()[6].drawVisual(array, ArrayVisualizer, Renderer, Highlights);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ arrayVisualizer.getVisuals()[6].drawVisual(array, arrayVisualizer, renderer, Highlights);
}
},
DOTS {
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- ArrayVisualizer.getVisuals()[7].drawVisual(array, ArrayVisualizer, Renderer, Highlights);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ arrayVisualizer.getVisuals()[7].drawVisual(array, arrayVisualizer, renderer, Highlights);
}
},
WAVE_DOTS {
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- ArrayVisualizer.getVisuals()[8].drawVisual(array, ArrayVisualizer, Renderer, Highlights);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ arrayVisualizer.getVisuals()[8].drawVisual(array, arrayVisualizer, renderer, Highlights);
}
},
CUSTOM_IMAGE {
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- ArrayVisualizer.getVisuals()[9].drawVisual(array, ArrayVisualizer, Renderer, Highlights);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ arrayVisualizer.getVisuals()[9].drawVisual(array, arrayVisualizer, renderer, Highlights);
}
},
SINE_WAVE {
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- ArrayVisualizer.getVisuals()[10].drawVisual(array, ArrayVisualizer, Renderer, Highlights);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ arrayVisualizer.getVisuals()[10].drawVisual(array, arrayVisualizer, renderer, Highlights);
}
},
HOOP_STACK {
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- ArrayVisualizer.getVisuals()[11].drawVisual(array, ArrayVisualizer, Renderer, Highlights);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ arrayVisualizer.getVisuals()[11].drawVisual(array, arrayVisualizer, renderer, Highlights);
}
},
PIXEL_MESH {
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- ArrayVisualizer.getVisuals()[12].drawVisual(array, ArrayVisualizer, Renderer, Highlights);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ arrayVisualizer.getVisuals()[12].drawVisual(array, arrayVisualizer, renderer, Highlights);
}
},
SPIRAL {
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- ArrayVisualizer.getVisuals()[13].drawVisual(array, ArrayVisualizer, Renderer, Highlights);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ arrayVisualizer.getVisuals()[13].drawVisual(array, arrayVisualizer, renderer, Highlights);
}
},
SPIRAL_DOTS {
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- ArrayVisualizer.getVisuals()[14].drawVisual(array, ArrayVisualizer, Renderer, Highlights);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ arrayVisualizer.getVisuals()[14].drawVisual(array, arrayVisualizer, renderer, Highlights);
}
};
@@ -126,5 +126,5 @@ public VisualStyles getCurrentVisual() {
return this;
}
- public abstract void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights);
+ public abstract void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights);
}
diff --git a/src/main/java/io/github/arrayv/visuals/bars/BarGraph.java b/src/main/java/io/github/arrayv/visuals/bars/BarGraph.java
index 4ba5a169..799870c2 100644
--- a/src/main/java/io/github/arrayv/visuals/bars/BarGraph.java
+++ b/src/main/java/io/github/arrayv/visuals/bars/BarGraph.java
@@ -9,52 +9,51 @@
public final class BarGraph extends Visual {
- public BarGraph(ArrayVisualizer ArrayVisualizer) {
- super(ArrayVisualizer);
+ public BarGraph(ArrayVisualizer arrayVisualizer) {
+ super(arrayVisualizer);
}
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- for (int i = 0, j = 0; i < Renderer.getArrayLength(); i++) {
- int width = (int) (Renderer.getXScale() * (i + 1)) - j;
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ for (int i = 0, j = 0; i < renderer.getArrayLength(); i++) {
+ int width = (int) (renderer.getXScale() * (i + 1)) - j;
if (width == 0) continue;
if (Highlights.fancyFinishActive() && i < Highlights.getFancyFinishPosition())
this.mainRender.setColor(Color.GREEN);
- else if (ArrayVisualizer.colorEnabled()) {
- int val = ArrayVisualizer.doingStabilityCheck() && ArrayVisualizer.colorEnabled() ? ArrayVisualizer.getIndexValue(array[i]): array[i];
- this.mainRender.setColor(getIntColor(val, ArrayVisualizer.getCurrentLength()));
- }
- else this.mainRender.setColor(Color.WHITE);
+ else if (arrayVisualizer.colorEnabled()) {
+ int val = arrayVisualizer.doingStabilityCheck() && arrayVisualizer.colorEnabled() ? arrayVisualizer.getIndexValue(array[i]): array[i];
+ this.mainRender.setColor(getIntColor(val, arrayVisualizer.getCurrentLength()));
+ } else this.mainRender.setColor(Color.WHITE);
- int val = ArrayVisualizer.doingStabilityCheck() && ArrayVisualizer.colorEnabled() ? ArrayVisualizer.getStabilityValue(array[i]): array[i];
- int y = (int) (((Renderer.getViewSize() - 20)) - (val + 1) * Renderer.getYScale());
+ int val = arrayVisualizer.doingStabilityCheck() && arrayVisualizer.colorEnabled() ? arrayVisualizer.getStabilityValue(array[i]): array[i];
+ int y = (int) (((renderer.getViewSize() - 20)) - (val + 1) * renderer.getYScale());
- this.mainRender.fillRect(j + 20, Renderer.getYOffset() + y, width, (int) ((val + 1) * Renderer.getYScale()));
+ this.mainRender.fillRect(j + 20, renderer.getYOffset() + y, width, (int) ((val + 1) * renderer.getYScale()));
j += width;
}
- this.mainRender.setColor(ArrayVisualizer.getHighlightColor());
- int length = Math.min(Renderer.getArrayLength(), ArrayVisualizer.getCurrentLength());
+ this.mainRender.setColor(arrayVisualizer.getHighlightColor());
+ int length = Math.min(renderer.getArrayLength(), arrayVisualizer.getCurrentLength());
boolean mark = false;
for (int i = 0, j = 0; i < length; i++) {
mark = mark || Highlights.containsPosition(i);
- int width = (int) (Renderer.getXScale() * (i + 1)) - j;
+ int width = (int) (renderer.getXScale() * (i + 1)) - j;
if (width == 0) continue;
if (mark) {
- int val = ArrayVisualizer.doingStabilityCheck() && ArrayVisualizer.colorEnabled() ? ArrayVisualizer.getStabilityValue(array[i]): array[i];
- int y = (int) (((Renderer.getViewSize() - 20)) - (val + 1) * Renderer.getYScale());
+ int val = arrayVisualizer.doingStabilityCheck() && arrayVisualizer.colorEnabled() ? arrayVisualizer.getStabilityValue(array[i]): array[i];
+ int y = (int) (((renderer.getViewSize() - 20)) - (val + 1) * renderer.getYScale());
- this.mainRender.fillRect(j + 20, Renderer.getYOffset() + y, Math.max(width, 2), (int) ((val + 1) * Renderer.getYScale()));
+ this.mainRender.fillRect(j + 20, renderer.getYOffset() + y, Math.max(width, 2), (int) ((val + 1) * renderer.getYScale()));
mark = false;
}
j += width;
}
- if (ArrayVisualizer.externalArraysEnabled()) {
+ if (arrayVisualizer.externalArraysEnabled()) {
this.mainRender.setColor(Color.BLUE);
- this.mainRender.fillRect(0, Renderer.getYOffset() + Renderer.getViewSize() - 20, ArrayVisualizer.currentWidth(), 1);
+ this.mainRender.fillRect(0, renderer.getYOffset() + renderer.getViewSize() - 20, arrayVisualizer.currentWidth(), 1);
}
}
}
diff --git a/src/main/java/io/github/arrayv/visuals/bars/DisparityBarGraph.java b/src/main/java/io/github/arrayv/visuals/bars/DisparityBarGraph.java
index b2b3d219..029f8bd0 100644
--- a/src/main/java/io/github/arrayv/visuals/bars/DisparityBarGraph.java
+++ b/src/main/java/io/github/arrayv/visuals/bars/DisparityBarGraph.java
@@ -9,46 +9,46 @@
public final class DisparityBarGraph extends Visual {
- public DisparityBarGraph(ArrayVisualizer ArrayVisualizer) {
- super(ArrayVisualizer);
+ public DisparityBarGraph(ArrayVisualizer arrayVisualizer) {
+ super(arrayVisualizer);
}
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- for (int i = 0, j = 0; i < Renderer.getArrayLength(); i++) {
- int width = (int) (Renderer.getXScale() * (i + 1)) - j;
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ for (int i = 0, j = 0; i < renderer.getArrayLength(); i++) {
+ int width = (int) (renderer.getXScale() * (i + 1)) - j;
if (width == 0) continue;
if (Highlights.fancyFinishActive() && i < Highlights.getFancyFinishPosition())
this.mainRender.setColor(Color.GREEN);
- else if (ArrayVisualizer.colorEnabled())
- this.mainRender.setColor(getIntColor(array[i], ArrayVisualizer.getCurrentLength()));
+ else if (arrayVisualizer.colorEnabled())
+ this.mainRender.setColor(getIntColor(array[i], arrayVisualizer.getCurrentLength()));
else this.mainRender.setColor(Color.WHITE);
- double disp = (1 + Math.sin((Math.PI * (array[i] - i)) / ArrayVisualizer.getCurrentLength())) * 0.5;
- int y = (int) (((Renderer.getViewSize() - 20)) - disp * ArrayVisualizer.getCurrentLength() * Renderer.getYScale());
+ double disp = (1 + Math.sin((Math.PI * (array[i] - i)) / arrayVisualizer.getCurrentLength())) * 0.5;
+ int y = (int) (((renderer.getViewSize() - 20)) - disp * arrayVisualizer.getCurrentLength() * renderer.getYScale());
- this.mainRender.fillRect(j + 20, Renderer.getYOffset() + y, width, (int) (disp * ArrayVisualizer.getCurrentLength() * Renderer.getYScale()));
+ this.mainRender.fillRect(j + 20, renderer.getYOffset() + y, width, (int) (disp * arrayVisualizer.getCurrentLength() * renderer.getYScale()));
j += width;
}
- this.mainRender.setColor(ArrayVisualizer.getHighlightColor());
+ this.mainRender.setColor(arrayVisualizer.getHighlightColor());
- for (int i = 0, j = 0; i < Renderer.getArrayLength(); i++) {
- int width = (int) (Renderer.getXScale() * (i + 1)) - j;
+ for (int i = 0, j = 0; i < renderer.getArrayLength(); i++) {
+ int width = (int) (renderer.getXScale() * (i + 1)) - j;
if (Highlights.containsPosition(i)) {
- double disp = (1 + Math.sin((Math.PI * (array[i] - i)) / ArrayVisualizer.getCurrentLength())) * 0.5;
- int y = (int) (((Renderer.getViewSize() - 20)) - disp * ArrayVisualizer.getCurrentLength() * Renderer.getYScale());
+ double disp = (1 + Math.sin((Math.PI * (array[i] - i)) / arrayVisualizer.getCurrentLength())) * 0.5;
+ int y = (int) (((renderer.getViewSize() - 20)) - disp * arrayVisualizer.getCurrentLength() * renderer.getYScale());
- this.mainRender.fillRect(j + 20, Renderer.getYOffset() + y, Math.max(width, 2), (int) (disp * ArrayVisualizer.getCurrentLength() * Renderer.getYScale()));
+ this.mainRender.fillRect(j + 20, renderer.getYOffset() + y, Math.max(width, 2), (int) (disp * arrayVisualizer.getCurrentLength() * renderer.getYScale()));
}
j += width;
}
- if (ArrayVisualizer.externalArraysEnabled()) {
+ if (arrayVisualizer.externalArraysEnabled()) {
this.mainRender.setColor(Color.BLUE);
- this.mainRender.fillRect(0, Renderer.getYOffset() + Renderer.getViewSize() - 20, ArrayVisualizer.currentWidth(), 1);
+ this.mainRender.fillRect(0, renderer.getYOffset() + renderer.getViewSize() - 20, arrayVisualizer.currentWidth(), 1);
}
}
}
diff --git a/src/main/java/io/github/arrayv/visuals/bars/Rainbow.java b/src/main/java/io/github/arrayv/visuals/bars/Rainbow.java
index 9535b667..3d66aa8a 100644
--- a/src/main/java/io/github/arrayv/visuals/bars/Rainbow.java
+++ b/src/main/java/io/github/arrayv/visuals/bars/Rainbow.java
@@ -34,39 +34,39 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class Rainbow extends Visual {
- public Rainbow(ArrayVisualizer ArrayVisualizer) {
- super(ArrayVisualizer);
+ public Rainbow(ArrayVisualizer arrayVisualizer) {
+ super(arrayVisualizer);
}
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- for (int i = 0, j = 0; i < Renderer.getArrayLength(); i++) {
- int width = (int) (Renderer.getXScale() * (i + 1)) - j;
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ for (int i = 0, j = 0; i < renderer.getArrayLength(); i++) {
+ int width = (int) (renderer.getXScale() * (i + 1)) - j;
if (width == 0) continue;
if (Highlights.fancyFinishActive() && i < Highlights.getFancyFinishPosition())
this.mainRender.setColor(Color.GREEN);
- else this.mainRender.setColor(getIntColor(array[i], ArrayVisualizer.getCurrentLength()));
+ else this.mainRender.setColor(getIntColor(array[i], arrayVisualizer.getCurrentLength()));
- this.mainRender.fillRect(j + 20, Renderer.getYOffset() - 20, width, (int) (Renderer.getViewSize()));
+ this.mainRender.fillRect(j + 20, renderer.getYOffset() - 20, width, (int) (renderer.getViewSize()));
j += width;
}
- if (ArrayVisualizer.analysisEnabled()) this.mainRender.setColor(Color.LIGHT_GRAY);
+ if (arrayVisualizer.analysisEnabled()) this.mainRender.setColor(Color.LIGHT_GRAY);
else this.mainRender.setColor(Color.WHITE);
- for (int i = 0, j = 0; i < Renderer.getArrayLength(); i++) {
- int width = (int) (Renderer.getXScale() * (i + 1)) - j;
+ for (int i = 0, j = 0; i < renderer.getArrayLength(); i++) {
+ int width = (int) (renderer.getXScale() * (i + 1)) - j;
if (Highlights.containsPosition(i)) {
- this.mainRender.fillRect(j + 20, Renderer.getYOffset() - 20, Math.max(width, 2), (int) (Renderer.getViewSize()));
+ this.mainRender.fillRect(j + 20, renderer.getYOffset() - 20, Math.max(width, 2), (int) (renderer.getViewSize()));
}
j += width;
}
- if (ArrayVisualizer.externalArraysEnabled()) {
+ if (arrayVisualizer.externalArraysEnabled()) {
this.mainRender.setColor(Color.BLUE);
- this.mainRender.fillRect(0, Renderer.getYOffset() + Renderer.getViewSize() - 20, ArrayVisualizer.currentWidth(), 1);
+ this.mainRender.fillRect(0, renderer.getYOffset() + renderer.getViewSize() - 20, arrayVisualizer.currentWidth(), 1);
}
}
}
diff --git a/src/main/java/io/github/arrayv/visuals/bars/SineWave.java b/src/main/java/io/github/arrayv/visuals/bars/SineWave.java
index ad43bd85..16737f5d 100644
--- a/src/main/java/io/github/arrayv/visuals/bars/SineWave.java
+++ b/src/main/java/io/github/arrayv/visuals/bars/SineWave.java
@@ -36,42 +36,42 @@ of this software and associated documentation files (the "Software"), to deal
public final class SineWave extends Visual {
- public SineWave(ArrayVisualizer ArrayVisualizer) {
- super(ArrayVisualizer);
+ public SineWave(ArrayVisualizer arrayVisualizer) {
+ super(arrayVisualizer);
}
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- for (int i = 0, j = 0; i < Renderer.getArrayLength(); i++) {
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ for (int i = 0, j = 0; i < renderer.getArrayLength(); i++) {
if (Highlights.fancyFinishActive() && i < Highlights.getFancyFinishPosition())
this.mainRender.setColor(Color.GREEN);
- else if (ArrayVisualizer.colorEnabled())
- this.mainRender.setColor(getIntColor(array[i], ArrayVisualizer.getCurrentLength()));
+ else if (arrayVisualizer.colorEnabled())
+ this.mainRender.setColor(getIntColor(array[i], arrayVisualizer.getCurrentLength()));
else this.mainRender.setColor(Color.WHITE);
- int width = (int) (Renderer.getXScale() * (i + 1)) - j;
+ int width = (int) (renderer.getXScale() * (i + 1)) - j;
- int y = (int) (((Renderer.getViewSize() - 20) / 2.5) * Math.sin((2 * Math.PI * ((double) array[i] / Renderer.getArrayLength()))) + Renderer.halfViewSize() - 20);
- this.mainRender.fillRect(j + 20, Renderer.getYOffset() + y, Math.max(width, 1), 20);
+ int y = (int) (((renderer.getViewSize() - 20) / 2.5) * Math.sin((2 * Math.PI * ((double) array[i] / renderer.getArrayLength()))) + renderer.halfViewSize() - 20);
+ this.mainRender.fillRect(j + 20, renderer.getYOffset() + y, Math.max(width, 1), 20);
j += width;
}
- this.mainRender.setColor(ArrayVisualizer.getHighlightColor());
+ this.mainRender.setColor(arrayVisualizer.getHighlightColor());
- for (int i = 0, j = 0; i < Renderer.getArrayLength(); i++) {
- int width = (int) (Renderer.getXScale() * (i + 1)) - j;
+ for (int i = 0, j = 0; i < renderer.getArrayLength(); i++) {
+ int width = (int) (renderer.getXScale() * (i + 1)) - j;
if (Highlights.containsPosition(i)) {
- int y = (int) (((Renderer.getViewSize() - 20) / 2.5) * Math.sin((2 * Math.PI * ((double) array[i] / Renderer.getArrayLength()))) + Renderer.halfViewSize() - 20);
- this.mainRender.fillRect(j + 20, Renderer.getYOffset() + y, Math.max(width, 2), 20);
+ int y = (int) (((renderer.getViewSize() - 20) / 2.5) * Math.sin((2 * Math.PI * ((double) array[i] / renderer.getArrayLength()))) + renderer.halfViewSize() - 20);
+ this.mainRender.fillRect(j + 20, renderer.getYOffset() + y, Math.max(width, 2), 20);
}
j += width;
}
- if (ArrayVisualizer.externalArraysEnabled()) {
+ if (arrayVisualizer.externalArraysEnabled()) {
this.mainRender.setColor(Color.BLUE);
- this.mainRender.fillRect(0, Renderer.getYOffset() + Renderer.getViewSize() - 20, ArrayVisualizer.currentWidth(), 1);
+ this.mainRender.fillRect(0, renderer.getYOffset() + renderer.getViewSize() - 20, arrayVisualizer.currentWidth(), 1);
}
}
}
diff --git a/src/main/java/io/github/arrayv/visuals/circles/ColorCircle.java b/src/main/java/io/github/arrayv/visuals/circles/ColorCircle.java
index 6bbca359..aa21c120 100644
--- a/src/main/java/io/github/arrayv/visuals/circles/ColorCircle.java
+++ b/src/main/java/io/github/arrayv/visuals/circles/ColorCircle.java
@@ -36,18 +36,18 @@ of this software and associated documentation files (the "Software"), to deal
public final class ColorCircle extends Visual {
- public ColorCircle(ArrayVisualizer ArrayVisualizer) {
- super(ArrayVisualizer);
+ public ColorCircle(ArrayVisualizer arrayVisualizer) {
+ super(arrayVisualizer);
}
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- if (Renderer.auxActive) return;
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ if (renderer.isAuxActive()) return;
- int width = ArrayVisualizer.windowWidth();
- int height = ArrayVisualizer.windowHeight();
+ int width = arrayVisualizer.windowWidth();
+ int height = arrayVisualizer.windowHeight();
- int n = ArrayVisualizer.getCurrentLength();
+ int n = arrayVisualizer.getCurrentLength();
double r = Math.min(width, height)/2.75;
int p = (int)(r/12);
@@ -77,10 +77,10 @@ public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Re
this.mainRender.setColor(Color.GREEN);
else {
- this.mainRender.setColor(getIntColor(array[i], ArrayVisualizer.getCurrentLength()));
+ this.mainRender.setColor(getIntColor(array[i], arrayVisualizer.getCurrentLength()));
if (Highlights.containsPosition(i)) {
- if (ArrayVisualizer.analysisEnabled()) this.extraRender.setColor(Color.LIGHT_GRAY);
+ if (arrayVisualizer.analysisEnabled()) this.extraRender.setColor(Color.LIGHT_GRAY);
else this.extraRender.setColor(Color.WHITE);
px[0] = width/2 + (int)((r + p/4) * Math.cos(Math.PI * ((2d*i - 1) / n - 0.5)));
diff --git a/src/main/java/io/github/arrayv/visuals/circles/DisparityChords.java b/src/main/java/io/github/arrayv/visuals/circles/DisparityChords.java
index 6aebcc3e..13eb0d77 100644
--- a/src/main/java/io/github/arrayv/visuals/circles/DisparityChords.java
+++ b/src/main/java/io/github/arrayv/visuals/circles/DisparityChords.java
@@ -36,24 +36,24 @@ of this software and associated documentation files (the "Software"), to deal
public final class DisparityChords extends Visual {
- public DisparityChords(ArrayVisualizer ArrayVisualizer) {
- super(ArrayVisualizer);
+ public DisparityChords(ArrayVisualizer arrayVisualizer) {
+ super(arrayVisualizer);
}
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- if (Renderer.auxActive) return;
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ if (renderer.isAuxActive()) return;
- int width = ArrayVisualizer.windowWidth();
- int height = ArrayVisualizer.windowHeight();
+ int width = arrayVisualizer.windowWidth();
+ int height = arrayVisualizer.windowHeight();
- int n = ArrayVisualizer.getCurrentLength();
+ int n = arrayVisualizer.getCurrentLength();
double r = Math.min(width, height)/2.5;
- this.mainRender.setStroke(ArrayVisualizer.getThinStroke());
+ this.mainRender.setStroke(arrayVisualizer.getThinStroke());
for (int i = n-1; i >= 0; i--) {
- this.mainRender.setColor(getIntColor(array[i], ArrayVisualizer.getCurrentLength()));
+ this.mainRender.setColor(getIntColor(array[i], arrayVisualizer.getCurrentLength()));
int ax = width/2 + (int)(r * Math.cos(Math.PI * (2d*i / n - 0.5)));
int ay = height/2 + (int)(r * Math.sin(Math.PI * (2d*i / n - 0.5)));
@@ -62,7 +62,7 @@ public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Re
this.mainRender.drawLine(ax, ay, bx, by);
}
- this.mainRender.setStroke(ArrayVisualizer.getDefaultStroke());
+ this.mainRender.setStroke(arrayVisualizer.getDefaultStroke());
for (int i = 0; i < n; i++) {
if (Highlights.fancyFinishActive() && i < Highlights.getFancyFinishPosition()) {
@@ -75,7 +75,7 @@ public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Re
this.mainRender.drawLine(ax, ay, bx, by);
} else if (Highlights.containsPosition(i)) {
- if (ArrayVisualizer.analysisEnabled()) this.mainRender.setColor(Color.LIGHT_GRAY);
+ if (arrayVisualizer.analysisEnabled()) this.mainRender.setColor(Color.LIGHT_GRAY);
else this.mainRender.setColor(Color.WHITE);
int ax = width/2 + (int)(r * Math.cos(Math.PI * (2d*i / n - 0.5)));
diff --git a/src/main/java/io/github/arrayv/visuals/circles/DisparityCircle.java b/src/main/java/io/github/arrayv/visuals/circles/DisparityCircle.java
index 287799f5..6c7aaa31 100644
--- a/src/main/java/io/github/arrayv/visuals/circles/DisparityCircle.java
+++ b/src/main/java/io/github/arrayv/visuals/circles/DisparityCircle.java
@@ -36,27 +36,27 @@ of this software and associated documentation files (the "Software"), to deal
public final class DisparityCircle extends Visual {
- public DisparityCircle(ArrayVisualizer ArrayVisualizer) {
- super(ArrayVisualizer);
+ public DisparityCircle(ArrayVisualizer arrayVisualizer) {
+ super(arrayVisualizer);
}
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- if (Renderer.auxActive) return;
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ if (renderer.isAuxActive()) return;
- int width = ArrayVisualizer.windowWidth();
- int height = ArrayVisualizer.windowHeight();
+ int width = arrayVisualizer.windowWidth();
+ int height = arrayVisualizer.windowHeight();
- int n = ArrayVisualizer.getCurrentLength();
+ int n = arrayVisualizer.getCurrentLength();
double r = Math.min(width, height)/2.5;
- this.extraRender.setStroke(ArrayVisualizer.getThickStroke());
- this.extraRender.setColor(ArrayVisualizer.getHighlightColor());
+ this.extraRender.setStroke(arrayVisualizer.getThickStroke());
+ this.extraRender.setColor(arrayVisualizer.getHighlightColor());
int[] x = {width/2, 0, 0};
int[] y = {height/2, 0, 0};
- double disp = (1 + Math.cos((Math.PI * (array[n-1] - (n-1))) / (ArrayVisualizer.getCurrentLength() * 0.5))) * 0.5;
+ double disp = (1 + Math.cos((Math.PI * (array[n-1] - (n-1))) / (arrayVisualizer.getCurrentLength() * 0.5))) * 0.5;
x[2] = width/2 + (int)(disp * r * Math.cos(Math.PI * (2d*(n-1) / n - 0.5)));
y[2] = height/2 + (int)(disp * r * Math.sin(Math.PI * (2d*(n-1) / n - 0.5)));
@@ -64,22 +64,21 @@ public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Re
x[1] = x[2];
y[1] = y[2];
- disp = (1 + Math.cos((Math.PI * (array[i] - i)) / (ArrayVisualizer.getCurrentLength() * 0.5))) * 0.5;
+ disp = (1 + Math.cos((Math.PI * (array[i] - i)) / (arrayVisualizer.getCurrentLength() * 0.5))) * 0.5;
x[2] = width/2 + (int)(disp * r * Math.cos(Math.PI * (2d*i / n - 0.5)));
y[2] = height/2 + (int)(disp * r * Math.sin(Math.PI * (2d*i / n - 0.5)));
if (Highlights.fancyFinishActive() && i < Highlights.getFancyFinishPosition())
this.mainRender.setColor(Color.GREEN);
else if (Highlights.containsPosition(i)) {
- this.mainRender.setColor(ArrayVisualizer.getHighlightColor());
+ this.mainRender.setColor(arrayVisualizer.getHighlightColor());
this.extraRender.drawPolygon(x, y, 3);
- }
- else if (ArrayVisualizer.colorEnabled())
- this.mainRender.setColor(getIntColor(array[i], ArrayVisualizer.getCurrentLength()));
+ } else if (arrayVisualizer.colorEnabled())
+ this.mainRender.setColor(getIntColor(array[i], arrayVisualizer.getCurrentLength()));
else this.mainRender.setColor(Color.WHITE);
this.mainRender.fillPolygon(x, y, 3);
}
- this.extraRender.setStroke(ArrayVisualizer.getDefaultStroke());
+ this.extraRender.setStroke(arrayVisualizer.getDefaultStroke());
}
}
diff --git a/src/main/java/io/github/arrayv/visuals/circles/Spiral.java b/src/main/java/io/github/arrayv/visuals/circles/Spiral.java
index c62f3dd9..ae7817e7 100644
--- a/src/main/java/io/github/arrayv/visuals/circles/Spiral.java
+++ b/src/main/java/io/github/arrayv/visuals/circles/Spiral.java
@@ -36,27 +36,27 @@ of this software and associated documentation files (the "Software"), to deal
public final class Spiral extends Visual {
- public Spiral(ArrayVisualizer ArrayVisualizer) {
- super(ArrayVisualizer);
+ public Spiral(ArrayVisualizer arrayVisualizer) {
+ super(arrayVisualizer);
}
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- if (Renderer.auxActive) return;
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ if (renderer.isAuxActive()) return;
- int width = ArrayVisualizer.windowWidth();
- int height = ArrayVisualizer.windowHeight();
+ int width = arrayVisualizer.windowWidth();
+ int height = arrayVisualizer.windowHeight();
- int n = ArrayVisualizer.getCurrentLength();
+ int n = arrayVisualizer.getCurrentLength();
double r = Math.min(width, height)/2.5;
- this.extraRender.setStroke(ArrayVisualizer.getThickStroke());
- this.extraRender.setColor(ArrayVisualizer.getHighlightColor());
+ this.extraRender.setStroke(arrayVisualizer.getThickStroke());
+ this.extraRender.setColor(arrayVisualizer.getHighlightColor());
int[] x = {width/2, 0, 0};
int[] y = {height/2, 0, 0};
- double mult = (double) array[n-1] / ArrayVisualizer.getCurrentLength() - 1;
+ double mult = (double) array[n-1] / arrayVisualizer.getCurrentLength() - 1;
mult = 1 - mult*mult;
x[2] = width/2 + (int)(mult * r * Math.cos(Math.PI * (2d*(n-1) / n - 0.5)));
@@ -66,7 +66,7 @@ public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Re
x[1] = x[2];
y[1] = y[2];
- mult = (double) array[i] / ArrayVisualizer.getCurrentLength() - 1;
+ mult = (double) array[i] / arrayVisualizer.getCurrentLength() - 1;
mult = 1 - mult*mult;
x[2] = width/2 + (int)(mult * r * Math.cos(Math.PI * (2d*i / n - 0.5)));
@@ -76,16 +76,15 @@ public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Re
this.mainRender.setColor(Color.GREEN);
else if (Highlights.containsPosition(i)) {
- this.mainRender.setColor(ArrayVisualizer.getHighlightColor());
+ this.mainRender.setColor(arrayVisualizer.getHighlightColor());
this.extraRender.drawPolygon(x, y, 3);
- }
- else if (ArrayVisualizer.colorEnabled())
- this.mainRender.setColor(getIntColor(array[i], ArrayVisualizer.getCurrentLength()));
+ } else if (arrayVisualizer.colorEnabled())
+ this.mainRender.setColor(getIntColor(array[i], arrayVisualizer.getCurrentLength()));
else this.mainRender.setColor(Color.WHITE);
this.mainRender.fillPolygon(x, y, 3);
}
- this.extraRender.setStroke(ArrayVisualizer.getDefaultStroke());
+ this.extraRender.setStroke(arrayVisualizer.getDefaultStroke());
}
}
diff --git a/src/main/java/io/github/arrayv/visuals/dots/DisparityDots.java b/src/main/java/io/github/arrayv/visuals/dots/DisparityDots.java
index 690cc4a7..05b28fa1 100644
--- a/src/main/java/io/github/arrayv/visuals/dots/DisparityDots.java
+++ b/src/main/java/io/github/arrayv/visuals/dots/DisparityDots.java
@@ -36,73 +36,72 @@ of this software and associated documentation files (the "Software"), to deal
public final class DisparityDots extends Visual {
- public DisparityDots(ArrayVisualizer ArrayVisualizer) {
- super(ArrayVisualizer);
+ public DisparityDots(ArrayVisualizer arrayVisualizer) {
+ super(arrayVisualizer);
}
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- if (Renderer.auxActive) return;
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ if (renderer.isAuxActive()) return;
- int width = ArrayVisualizer.windowWidth();
- int height = ArrayVisualizer.windowHeight();
+ int width = arrayVisualizer.windowWidth();
+ int height = arrayVisualizer.windowHeight();
- int n = ArrayVisualizer.getCurrentLength();
+ int n = arrayVisualizer.getCurrentLength();
double r = Math.min(width, height)/2.5;
- if (ArrayVisualizer.linesEnabled()) {
- double disp = (1 + Math.cos((Math.PI * (array[n-1] - (n-1))) / (ArrayVisualizer.getCurrentLength() * 0.5))) * 0.5;
+ if (arrayVisualizer.linesEnabled()) {
+ double disp = (1 + Math.cos((Math.PI * (array[n-1] - (n-1))) / (arrayVisualizer.getCurrentLength() * 0.5))) * 0.5;
int lastX = width/2 + (int)(disp * r * Math.cos(Math.PI * (2d*(n-1) / n - 0.5)));
int lastY = height/2 + (int)(disp * r * Math.sin(Math.PI * (2d*(n-1) / n - 0.5)));
- this.mainRender.setStroke(ArrayVisualizer.getCustomStroke(2));
+ this.mainRender.setStroke(arrayVisualizer.getCustomStroke(2));
for (int i = 0; i < n; i++) {
if (Highlights.fancyFinishActive() && i < Highlights.getFancyFinishPosition()) {
this.mainRender.setColor(Color.GREEN);
- this.mainRender.setStroke(ArrayVisualizer.getCustomStroke(4));
+ this.mainRender.setStroke(arrayVisualizer.getCustomStroke(4));
} else if (Highlights.containsPosition(i)) {
- this.mainRender.setColor(ArrayVisualizer.getHighlightColor());
- this.mainRender.setStroke(ArrayVisualizer.getCustomStroke(4));
- }
- else if (ArrayVisualizer.colorEnabled())
- this.mainRender.setColor(getIntColor(array[i], ArrayVisualizer.getCurrentLength()));
+ this.mainRender.setColor(arrayVisualizer.getHighlightColor());
+ this.mainRender.setStroke(arrayVisualizer.getCustomStroke(4));
+ } else if (arrayVisualizer.colorEnabled())
+ this.mainRender.setColor(getIntColor(array[i], arrayVisualizer.getCurrentLength()));
else this.mainRender.setColor(Color.WHITE);
- disp = (1 + Math.cos((Math.PI * (array[i] - i)) / (ArrayVisualizer.getCurrentLength() * 0.5))) * 0.5;
+ disp = (1 + Math.cos((Math.PI * (array[i] - i)) / (arrayVisualizer.getCurrentLength() * 0.5))) * 0.5;
int x = width/2 + (int)(disp * r * Math.cos(Math.PI * (2d*i / n - 0.5)));
int y = height/2 + (int)(disp * r * Math.sin(Math.PI * (2d*i / n - 0.5)));
this.mainRender.drawLine(lastX, lastY, x, y);
- this.mainRender.setStroke(ArrayVisualizer.getCustomStroke(2));
+ this.mainRender.setStroke(arrayVisualizer.getCustomStroke(2));
lastX = x;
lastY = y;
}
- this.mainRender.setStroke(ArrayVisualizer.getDefaultStroke());
+ this.mainRender.setStroke(arrayVisualizer.getDefaultStroke());
} else {
- int dotS = Renderer.getDotDimensions();
+ int dotS = renderer.getDotDimensions();
for (int i = 0; i < n; i++) {
if (Highlights.fancyFinishActive() && i < Highlights.getFancyFinishPosition())
this.mainRender.setColor(Color.GREEN);
- else if (ArrayVisualizer.colorEnabled())
- this.mainRender.setColor(getIntColor(array[i], ArrayVisualizer.getCurrentLength()));
+ else if (arrayVisualizer.colorEnabled())
+ this.mainRender.setColor(getIntColor(array[i], arrayVisualizer.getCurrentLength()));
else this.mainRender.setColor(Color.WHITE);
- double disp = (1 + Math.cos((Math.PI * (array[i] - i)) / (ArrayVisualizer.getCurrentLength() * 0.5))) * 0.5;
+ double disp = (1 + Math.cos((Math.PI * (array[i] - i)) / (arrayVisualizer.getCurrentLength() * 0.5))) * 0.5;
int x = width/2 + (int)(disp * r * Math.cos(Math.PI * (2d*i / n - 0.5)));
int y = height/2 + (int)(disp * r * Math.sin(Math.PI * (2d*i / n - 0.5)));
this.mainRender.fillRect(x, y, dotS, dotS);
}
- this.mainRender.setColor(ArrayVisualizer.getHighlightColor());
+ this.mainRender.setColor(arrayVisualizer.getHighlightColor());
for (int i = 0; i < n; i++) {
if (Highlights.containsPosition(i)) {
- double disp = (1 + Math.cos((Math.PI * (array[i] - i)) / (ArrayVisualizer.getCurrentLength() * 0.5))) * 0.5;
+ double disp = (1 + Math.cos((Math.PI * (array[i] - i)) / (arrayVisualizer.getCurrentLength() * 0.5))) * 0.5;
int x = width/2 + (int)(disp * r * Math.cos(Math.PI * (2d*i / n - 0.5)));
int y = height/2 + (int)(disp * r * Math.sin(Math.PI * (2d*i / n - 0.5)));
diff --git a/src/main/java/io/github/arrayv/visuals/dots/ScatterPlot.java b/src/main/java/io/github/arrayv/visuals/dots/ScatterPlot.java
index b4bfce50..a3b4dce0 100644
--- a/src/main/java/io/github/arrayv/visuals/dots/ScatterPlot.java
+++ b/src/main/java/io/github/arrayv/visuals/dots/ScatterPlot.java
@@ -34,82 +34,80 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class ScatterPlot extends Visual {
- public ScatterPlot(ArrayVisualizer ArrayVisualizer) {
- super(ArrayVisualizer);
+ public ScatterPlot(ArrayVisualizer arrayVisualizer) {
+ super(arrayVisualizer);
}
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- int offset = 20 + (int) (Renderer.getXScale()/2);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ int offset = 20 + (int) (renderer.getXScale()/2);
- if (ArrayVisualizer.linesEnabled()) {
+ if (arrayVisualizer.linesEnabled()) {
int lastX = 0;
- int lastY = (int) (((Renderer.getViewSize() - 20)) - (array[0] + 1) * Renderer.getYScale());
- this.mainRender.setStroke(ArrayVisualizer.getCustomStroke(2));
+ int lastY = (int) (((renderer.getViewSize() - 20)) - (array[0] + 1) * renderer.getYScale());
+ this.mainRender.setStroke(arrayVisualizer.getCustomStroke(2));
- for (int i = 1, j = (int) Renderer.getXScale(); i < Renderer.getArrayLength(); i++) {
+ for (int i = 1, j = (int) renderer.getXScale(); i < renderer.getArrayLength(); i++) {
if (Highlights.fancyFinishActive() && i < Highlights.getFancyFinishPosition()) {
this.mainRender.setColor(Color.GREEN);
- this.mainRender.setStroke(ArrayVisualizer.getCustomStroke(4));
+ this.mainRender.setStroke(arrayVisualizer.getCustomStroke(4));
} else if (Highlights.containsPosition(i)) {
- this.mainRender.setColor(ArrayVisualizer.getHighlightColor());
- this.mainRender.setStroke(ArrayVisualizer.getCustomStroke(4));
- } else if (ArrayVisualizer.colorEnabled()) {
- int val = ArrayVisualizer.doingStabilityCheck() && ArrayVisualizer.colorEnabled() ? ArrayVisualizer.getIndexValue(array[i]): array[i];
- this.mainRender.setColor(getIntColor(val, ArrayVisualizer.getCurrentLength()));
- }
- else this.mainRender.setColor(Color.WHITE);
+ this.mainRender.setColor(arrayVisualizer.getHighlightColor());
+ this.mainRender.setStroke(arrayVisualizer.getCustomStroke(4));
+ } else if (arrayVisualizer.colorEnabled()) {
+ int val = arrayVisualizer.doingStabilityCheck() && arrayVisualizer.colorEnabled() ? arrayVisualizer.getIndexValue(array[i]): array[i];
+ this.mainRender.setColor(getIntColor(val, arrayVisualizer.getCurrentLength()));
+ } else this.mainRender.setColor(Color.WHITE);
- int val = ArrayVisualizer.doingStabilityCheck() && ArrayVisualizer.colorEnabled() ? ArrayVisualizer.getStabilityValue(array[i]): array[i];
- int y = (int) (((Renderer.getViewSize() - 20)) - (val + 1) * Renderer.getYScale());
+ int val = arrayVisualizer.doingStabilityCheck() && arrayVisualizer.colorEnabled() ? arrayVisualizer.getStabilityValue(array[i]): array[i];
+ int y = (int) (((renderer.getViewSize() - 20)) - (val + 1) * renderer.getYScale());
- this.mainRender.drawLine(lastX + offset, Renderer.getYOffset() + lastY, j + offset, Renderer.getYOffset() + y);
+ this.mainRender.drawLine(lastX + offset, renderer.getYOffset() + lastY, j + offset, renderer.getYOffset() + y);
lastX = j;
lastY = y;
- this.mainRender.setStroke(ArrayVisualizer.getCustomStroke(2));
+ this.mainRender.setStroke(arrayVisualizer.getCustomStroke(2));
- int width = (int) (Renderer.getXScale() * (i + 1)) - j;
+ int width = (int) (renderer.getXScale() * (i + 1)) - j;
j += width;
}
- this.mainRender.setStroke(ArrayVisualizer.getDefaultStroke());
+ this.mainRender.setStroke(arrayVisualizer.getDefaultStroke());
} else {
- int dotS = Renderer.getDotDimensions();
+ int dotS = renderer.getDotDimensions();
- for (int i = 0, j = 0; i < Renderer.getArrayLength(); i++) {
+ for (int i = 0, j = 0; i < renderer.getArrayLength(); i++) {
if (Highlights.fancyFinishActive() && i < Highlights.getFancyFinishPosition())
this.mainRender.setColor(Color.GREEN);
- else if (ArrayVisualizer.colorEnabled()) {
- int val = ArrayVisualizer.doingStabilityCheck() && ArrayVisualizer.colorEnabled() ? ArrayVisualizer.getIndexValue(array[i]): array[i];
- this.mainRender.setColor(getIntColor(val, ArrayVisualizer.getCurrentLength()));
- }
- else this.mainRender.setColor(Color.WHITE);
+ else if (arrayVisualizer.colorEnabled()) {
+ int val = arrayVisualizer.doingStabilityCheck() && arrayVisualizer.colorEnabled() ? arrayVisualizer.getIndexValue(array[i]): array[i];
+ this.mainRender.setColor(getIntColor(val, arrayVisualizer.getCurrentLength()));
+ } else this.mainRender.setColor(Color.WHITE);
- int val = ArrayVisualizer.doingStabilityCheck() && ArrayVisualizer.colorEnabled() ? ArrayVisualizer.getStabilityValue(array[i]): array[i];
- int y = (int) (((Renderer.getViewSize() - 20)) - (val + 1) * Renderer.getYScale());
+ int val = arrayVisualizer.doingStabilityCheck() && arrayVisualizer.colorEnabled() ? arrayVisualizer.getStabilityValue(array[i]): array[i];
+ int y = (int) (((renderer.getViewSize() - 20)) - (val + 1) * renderer.getYScale());
- this.mainRender.fillRect(j + offset, Renderer.getYOffset() + y, dotS, dotS);
+ this.mainRender.fillRect(j + offset, renderer.getYOffset() + y, dotS, dotS);
- int width = (int) (Renderer.getXScale() * (i + 1)) - j;
+ int width = (int) (renderer.getXScale() * (i + 1)) - j;
j += width;
}
- this.mainRender.setColor(ArrayVisualizer.getHighlightColor());
+ this.mainRender.setColor(arrayVisualizer.getHighlightColor());
- for (int i = 0, j = 0; i < Renderer.getArrayLength(); i++) {
+ for (int i = 0, j = 0; i < renderer.getArrayLength(); i++) {
if (Highlights.containsPosition(i)) {
- int val = ArrayVisualizer.doingStabilityCheck() && ArrayVisualizer.colorEnabled() ? ArrayVisualizer.getStabilityValue(array[i]): array[i];
- int y = (int) (((Renderer.getViewSize() - 20)) - (val + 1) * Renderer.getYScale());
+ int val = arrayVisualizer.doingStabilityCheck() && arrayVisualizer.colorEnabled() ? arrayVisualizer.getStabilityValue(array[i]): array[i];
+ int y = (int) (((renderer.getViewSize() - 20)) - (val + 1) * renderer.getYScale());
- this.mainRender.fillRect(j + offset - (int)(1.5*dotS), Renderer.getYOffset() + y - (int)(1.5*dotS), 4*dotS, 4*dotS);
+ this.mainRender.fillRect(j + offset - (int)(1.5*dotS), renderer.getYOffset() + y - (int)(1.5*dotS), 4*dotS, 4*dotS);
}
- int width = (int) (Renderer.getXScale() * (i + 1)) - j;
+ int width = (int) (renderer.getXScale() * (i + 1)) - j;
j += width;
}
}
- if (ArrayVisualizer.externalArraysEnabled()) {
+ if (arrayVisualizer.externalArraysEnabled()) {
this.mainRender.setColor(Color.BLUE);
- this.mainRender.fillRect(0, Renderer.getYOffset() + Renderer.getViewSize() - 20, ArrayVisualizer.currentWidth(), 1);
+ this.mainRender.fillRect(0, renderer.getYOffset() + renderer.getViewSize() - 20, arrayVisualizer.currentWidth(), 1);
}
}
}
diff --git a/src/main/java/io/github/arrayv/visuals/dots/SpiralDots.java b/src/main/java/io/github/arrayv/visuals/dots/SpiralDots.java
index 863cb3a9..2d72f21c 100644
--- a/src/main/java/io/github/arrayv/visuals/dots/SpiralDots.java
+++ b/src/main/java/io/github/arrayv/visuals/dots/SpiralDots.java
@@ -36,73 +36,72 @@ of this software and associated documentation files (the "Software"), to deal
public final class SpiralDots extends Visual {
- public SpiralDots(ArrayVisualizer ArrayVisualizer) {
- super(ArrayVisualizer);
+ public SpiralDots(ArrayVisualizer arrayVisualizer) {
+ super(arrayVisualizer);
}
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- if (Renderer.auxActive) return;
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ if (renderer.isAuxActive()) return;
- int width = ArrayVisualizer.windowWidth();
- int height = ArrayVisualizer.windowHeight();
+ int width = arrayVisualizer.windowWidth();
+ int height = arrayVisualizer.windowHeight();
- int n = ArrayVisualizer.getCurrentLength();
+ int n = arrayVisualizer.getCurrentLength();
double r = Math.min(width, height)/2.5;
- if (ArrayVisualizer.linesEnabled()) {
- double mult = (double) array[n-1] / ArrayVisualizer.getCurrentLength();
+ if (arrayVisualizer.linesEnabled()) {
+ double mult = (double) array[n-1] / arrayVisualizer.getCurrentLength();
int lastX = width/2 + (int)(mult * r * Math.cos(Math.PI * (2d*(n-1) / n - 0.5)));
int lastY = height/2 + (int)(mult * r * Math.sin(Math.PI * (2d*(n-1) / n - 0.5)));
- this.mainRender.setStroke(ArrayVisualizer.getCustomStroke(2));
+ this.mainRender.setStroke(arrayVisualizer.getCustomStroke(2));
for (int i = 0; i < n; i++) {
if (Highlights.fancyFinishActive() && i < Highlights.getFancyFinishPosition())
this.mainRender.setColor(Color.GREEN);
if (Highlights.containsPosition(i)) {
- this.mainRender.setColor(ArrayVisualizer.getHighlightColor());
- this.mainRender.setStroke(ArrayVisualizer.getCustomStroke(4));
- }
- else if (ArrayVisualizer.colorEnabled())
- this.mainRender.setColor(getIntColor(array[i], ArrayVisualizer.getCurrentLength()));
+ this.mainRender.setColor(arrayVisualizer.getHighlightColor());
+ this.mainRender.setStroke(arrayVisualizer.getCustomStroke(4));
+ } else if (arrayVisualizer.colorEnabled())
+ this.mainRender.setColor(getIntColor(array[i], arrayVisualizer.getCurrentLength()));
else this.mainRender.setColor(Color.WHITE);
- mult = (double) array[i] / ArrayVisualizer.getCurrentLength();
+ mult = (double) array[i] / arrayVisualizer.getCurrentLength();
int x = width/2 + (int)(mult * r * Math.cos(Math.PI * (2d*i / n - 0.5)));
int y = height/2 + (int)(mult * r * Math.sin(Math.PI * (2d*i / n - 0.5)));
this.mainRender.drawLine(lastX, lastY, x, y);
- this.mainRender.setStroke(ArrayVisualizer.getCustomStroke(2));
+ this.mainRender.setStroke(arrayVisualizer.getCustomStroke(2));
lastX = x;
lastY = y;
}
- this.mainRender.setStroke(ArrayVisualizer.getDefaultStroke());
+ this.mainRender.setStroke(arrayVisualizer.getDefaultStroke());
} else {
- int dotS = Renderer.getDotDimensions();
+ int dotS = renderer.getDotDimensions();
for (int i = 0; i < n; i++) {
if (Highlights.fancyFinishActive() && i < Highlights.getFancyFinishPosition())
this.mainRender.setColor(Color.GREEN);
- else if (ArrayVisualizer.colorEnabled())
- this.mainRender.setColor(getIntColor(array[i], ArrayVisualizer.getCurrentLength()));
+ else if (arrayVisualizer.colorEnabled())
+ this.mainRender.setColor(getIntColor(array[i], arrayVisualizer.getCurrentLength()));
else this.mainRender.setColor(Color.WHITE);
- double mult = (double) array[i] / ArrayVisualizer.getCurrentLength();
+ double mult = (double) array[i] / arrayVisualizer.getCurrentLength();
int x = width/2 + (int)(mult * r * Math.cos(Math.PI * (2d*i / n - 0.5)));
int y = height/2 + (int)(mult * r * Math.sin(Math.PI * (2d*i / n - 0.5)));
this.mainRender.fillRect(x, y, dotS, dotS);
}
- this.mainRender.setColor(ArrayVisualizer.getHighlightColor());
+ this.mainRender.setColor(arrayVisualizer.getHighlightColor());
for (int i = 0; i < n; i++) {
if (Highlights.containsPosition(i)) {
- double mult = (double) array[i] / ArrayVisualizer.getCurrentLength();
+ double mult = (double) array[i] / arrayVisualizer.getCurrentLength();
int x = width/2 + (int)(mult * r * Math.cos(Math.PI * (2d*i / n - 0.5)));
int y = height/2 + (int)(mult * r * Math.sin(Math.PI * (2d*i / n - 0.5)));
diff --git a/src/main/java/io/github/arrayv/visuals/dots/WaveDots.java b/src/main/java/io/github/arrayv/visuals/dots/WaveDots.java
index 47d89ab7..9d9f8676 100644
--- a/src/main/java/io/github/arrayv/visuals/dots/WaveDots.java
+++ b/src/main/java/io/github/arrayv/visuals/dots/WaveDots.java
@@ -36,77 +36,76 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class WaveDots extends Visual {
- public WaveDots(ArrayVisualizer ArrayVisualizer) {
- super(ArrayVisualizer);
+ public WaveDots(ArrayVisualizer arrayVisualizer) {
+ super(arrayVisualizer);
}
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- int offset = 20 + (int) (Renderer.getXScale()/2);
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ int offset = 20 + (int) (renderer.getXScale()/2);
- if (ArrayVisualizer.linesEnabled()) {
+ if (arrayVisualizer.linesEnabled()) {
int lastX = 0;
- int lastY = (int) (((Renderer.getViewSize() - 20) / 2.5) * Math.sin((2 * Math.PI * ((double) array[0] / Renderer.getArrayLength()))) + Renderer.halfViewSize() - 20);
- this.mainRender.setStroke(ArrayVisualizer.getCustomStroke(2));
+ int lastY = (int) (((renderer.getViewSize() - 20) / 2.5) * Math.sin((2 * Math.PI * ((double) array[0] / renderer.getArrayLength()))) + renderer.halfViewSize() - 20);
+ this.mainRender.setStroke(arrayVisualizer.getCustomStroke(2));
- for (int i = 1, j = (int) Renderer.getXScale(); i < Renderer.getArrayLength(); i++) {
+ for (int i = 1, j = (int) renderer.getXScale(); i < renderer.getArrayLength(); i++) {
if (Highlights.fancyFinishActive() && i < Highlights.getFancyFinishPosition()) {
this.mainRender.setColor(Color.GREEN);
- this.mainRender.setStroke(ArrayVisualizer.getCustomStroke(4));
+ this.mainRender.setStroke(arrayVisualizer.getCustomStroke(4));
} else if (Highlights.containsPosition(i)) {
- this.mainRender.setColor(ArrayVisualizer.getHighlightColor());
- this.mainRender.setStroke(ArrayVisualizer.getCustomStroke(4));
- }
- else if (ArrayVisualizer.colorEnabled())
- this.mainRender.setColor(getIntColor(array[i-1], ArrayVisualizer.getCurrentLength()));
+ this.mainRender.setColor(arrayVisualizer.getHighlightColor());
+ this.mainRender.setStroke(arrayVisualizer.getCustomStroke(4));
+ } else if (arrayVisualizer.colorEnabled())
+ this.mainRender.setColor(getIntColor(array[i-1], arrayVisualizer.getCurrentLength()));
else this.mainRender.setColor(Color.WHITE);
- int y = (int) (((Renderer.getViewSize() - 20) / 2.5) * Math.sin((2 * Math.PI * ((double) array[i] / Renderer.getArrayLength()))) + Renderer.halfViewSize() - 20);
+ int y = (int) (((renderer.getViewSize() - 20) / 2.5) * Math.sin((2 * Math.PI * ((double) array[i] / renderer.getArrayLength()))) + renderer.halfViewSize() - 20);
- this.mainRender.drawLine(lastX + offset, Renderer.getYOffset() + lastY, j + offset, Renderer.getYOffset() + y);
+ this.mainRender.drawLine(lastX + offset, renderer.getYOffset() + lastY, j + offset, renderer.getYOffset() + y);
lastX = j;
lastY = y;
- this.mainRender.setStroke(ArrayVisualizer.getCustomStroke(2));
+ this.mainRender.setStroke(arrayVisualizer.getCustomStroke(2));
- int width = (int) (Renderer.getXScale() * (i + 1)) - j;
+ int width = (int) (renderer.getXScale() * (i + 1)) - j;
j += width;
}
- this.mainRender.setStroke(ArrayVisualizer.getDefaultStroke());
+ this.mainRender.setStroke(arrayVisualizer.getDefaultStroke());
} else {
- int dotS = Renderer.getDotDimensions();
+ int dotS = renderer.getDotDimensions();
- for (int i = 0, j = 0; i < Renderer.getArrayLength(); i++) {
+ for (int i = 0, j = 0; i < renderer.getArrayLength(); i++) {
if (Highlights.fancyFinishActive() && i < Highlights.getFancyFinishPosition())
this.mainRender.setColor(Color.GREEN);
- else if (ArrayVisualizer.colorEnabled())
- this.mainRender.setColor(getIntColor(array[i], ArrayVisualizer.getCurrentLength()));
+ else if (arrayVisualizer.colorEnabled())
+ this.mainRender.setColor(getIntColor(array[i], arrayVisualizer.getCurrentLength()));
else this.mainRender.setColor(Color.WHITE);
- int y = (int) (((Renderer.getViewSize() - 20) / 2.5) * Math.sin((2 * Math.PI * ((double) array[i] / Renderer.getArrayLength()))) + Renderer.halfViewSize() - 20);
+ int y = (int) (((renderer.getViewSize() - 20) / 2.5) * Math.sin((2 * Math.PI * ((double) array[i] / renderer.getArrayLength()))) + renderer.halfViewSize() - 20);
- this.mainRender.fillRect(j + offset, Renderer.getYOffset() + y, dotS, dotS);
+ this.mainRender.fillRect(j + offset, renderer.getYOffset() + y, dotS, dotS);
- int width = (int) (Renderer.getXScale() * (i + 1)) - j;
+ int width = (int) (renderer.getXScale() * (i + 1)) - j;
j += width;
}
- this.mainRender.setColor(ArrayVisualizer.getHighlightColor());
+ this.mainRender.setColor(arrayVisualizer.getHighlightColor());
- for (int i = 0, j = 0; i < Renderer.getArrayLength(); i++) {
+ for (int i = 0, j = 0; i < renderer.getArrayLength(); i++) {
if (Highlights.containsPosition(i)) {
- int y = (int) (((Renderer.getViewSize() - 20) / 2.5) * Math.sin((2 * Math.PI * ((double) array[i] / Renderer.getArrayLength()))) + Renderer.halfViewSize() - 20);
- this.mainRender.fillRect(j + offset - (int)(1.5*dotS), Renderer.getYOffset() + y - (int)(1.5*dotS), 4*dotS, 4*dotS);
+ int y = (int) (((renderer.getViewSize() - 20) / 2.5) * Math.sin((2 * Math.PI * ((double) array[i] / renderer.getArrayLength()))) + renderer.halfViewSize() - 20);
+ this.mainRender.fillRect(j + offset - (int)(1.5*dotS), renderer.getYOffset() + y - (int)(1.5*dotS), 4*dotS, 4*dotS);
}
- int width = (int) (Renderer.getXScale() * (i + 1)) - j;
+ int width = (int) (renderer.getXScale() * (i + 1)) - j;
j += width;
}
}
- if (ArrayVisualizer.externalArraysEnabled()) {
+ if (arrayVisualizer.externalArraysEnabled()) {
this.mainRender.setColor(Color.BLUE);
- this.mainRender.fillRect(0, Renderer.getYOffset() + Renderer.getViewSize() - 20, ArrayVisualizer.currentWidth(), 1);
+ this.mainRender.fillRect(0, renderer.getYOffset() + renderer.getViewSize() - 20, arrayVisualizer.currentWidth(), 1);
}
}
}
diff --git a/src/main/java/io/github/arrayv/visuals/image/CustomImage.java b/src/main/java/io/github/arrayv/visuals/image/CustomImage.java
index 5b9dc409..8a99b39d 100644
--- a/src/main/java/io/github/arrayv/visuals/image/CustomImage.java
+++ b/src/main/java/io/github/arrayv/visuals/image/CustomImage.java
@@ -55,8 +55,6 @@ of this software and associated documentation files (the "Software"), to deal
* aphitorite (https://github.com/aphitorite/ArrayVisualizer)
*/
public final class CustomImage extends Visual {
- public static CustomImage visual;
-
private volatile BufferedImage img;
private volatile int imgHeight;
private volatile int imgWidth;
@@ -71,18 +69,17 @@ public final class CustomImage extends Visual {
private volatile ImageFrame pictureMenu;
private volatile LoadingDialog infoMsg;
- final private String defaultArtwork = "Summer Sorting by aphitorite";
+ private final String defaultArtwork = "Summer Sorting by aphitorite";
private String currentImage;
private File imageFile;
- public CustomImage(ArrayVisualizer ArrayVisualizer) {
- super(ArrayVisualizer);
- CustomImage.visual = this;
+ public CustomImage(ArrayVisualizer arrayVisualizer) {
+ super(arrayVisualizer);
this.imgImported = false; // Don't load the image unless the user selects the
// 'Custom Image' visual. Program initially boots up
// faster this way.
this.enableImgMenu();
- this.updateWindowDims(ArrayVisualizer);
+ this.updateWindowDims(arrayVisualizer);
this.currentImage = this.defaultArtwork;
}
@@ -109,9 +106,9 @@ private void updateImageDims() throws Exception {
this.imgWidth = this.img.getWidth();
}
- private void updateWindowDims(ArrayVisualizer ArrayVisualizer) {
- this.windowHeight = ArrayVisualizer.windowHeight();
- this.windowWidth = ArrayVisualizer.windowWidth();
+ private void updateWindowDims(ArrayVisualizer arrayVisualizer) {
+ this.windowHeight = arrayVisualizer.windowHeight();
+ this.windowWidth = arrayVisualizer.windowWidth();
}
private void refreshCustomImage(ImageFrame menu) {
@@ -137,7 +134,7 @@ public void loadCustomImage(File file) {
this.imageFile = file;
if (this.imageFile != null) {
this.currentImage = this.imageFile.getName();
- this.refreshCustomImage(ImageFrame.defaultFrame);
+ this.refreshCustomImage(ImageFrame.getDefaultFrame());
}
}
@@ -244,40 +241,42 @@ private boolean getScaledImage(int width, int height) throws Exception {
return success;
}
- public static void markCustomBar(ArrayVisualizer ArrayVisualizer, Graphics2D bar, Renderer Renderer, int width, boolean analysis) {
+ public static void markCustomBar(ArrayVisualizer arrayVisualizer, Graphics2D bar, Renderer renderer, int width, boolean analysis) {
if (analysis) {
bar.setColor(new Color(0, 0, 1, .5f));
} else {
bar.setColor(new Color(1, 0, 0, .5f));
}
- bar.fillRect(Renderer.getOffset() + 20, 0, width, ArrayVisualizer.windowHeight());
+ bar.fillRect(renderer.getOffset() + 20, 0, width, arrayVisualizer.windowHeight());
}
//The longer the array length, the more bars marked. Makes the visual easier to see when bars are thinner.
- public static void colorCustomBars(int logOfLen, int index, Highlights Highlights, ArrayVisualizer ArrayVisualizer, Graphics2D bar, Renderer Renderer, int width, boolean analysis) {
+ public static void colorCustomBars(int logOfLen, int index, Highlights Highlights, ArrayVisualizer arrayVisualizer, Graphics2D bar, Renderer renderer, int width, boolean analysis) {
switch(logOfLen) {
- case 15: if (Highlights.containsPosition(index - 15)) { markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis); break; }
- if (Highlights.containsPosition(index - 14)) { markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis); break; }
- if (Highlights.containsPosition(index - 13)) { markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis); break; }
- if (Highlights.containsPosition(index - 12)) { markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis); break; }
- if (Highlights.containsPosition(index - 11)) { markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis); break; }
- case 14: if (Highlights.containsPosition(index - 10)) { markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis); break; }
- if (Highlights.containsPosition(index - 9)) { markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis); break; }
- if (Highlights.containsPosition(index - 8)) { markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis); break; }
- case 13: if (Highlights.containsPosition(index - 7)) { markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis); break; }
- if (Highlights.containsPosition(index - 6)) { markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis); break; }
- if (Highlights.containsPosition(index - 5)) { markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis); break; }
- case 12: if (Highlights.containsPosition(index - 4)) { markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis); break; }
- if (Highlights.containsPosition(index - 3)) { markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis); break; }
- case 11: if (Highlights.containsPosition(index - 2)) { markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis); break; }
- case 10: if (Highlights.containsPosition(index - 1)) { markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis); break; }
- default: if (Highlights.containsPosition(index)) markCustomBar(ArrayVisualizer, bar, Renderer, width, analysis);
+ // @checkstyle:off LeftCurlyCheck|IndentationCheck
+ case 15: if (Highlights.containsPosition(index - 15)) { markCustomBar(arrayVisualizer, bar, renderer, width, analysis); break; }
+ if (Highlights.containsPosition(index - 14)) { markCustomBar(arrayVisualizer, bar, renderer, width, analysis); break; }
+ if (Highlights.containsPosition(index - 13)) { markCustomBar(arrayVisualizer, bar, renderer, width, analysis); break; }
+ if (Highlights.containsPosition(index - 12)) { markCustomBar(arrayVisualizer, bar, renderer, width, analysis); break; }
+ if (Highlights.containsPosition(index - 11)) { markCustomBar(arrayVisualizer, bar, renderer, width, analysis); break; }
+ case 14: if (Highlights.containsPosition(index - 10)) { markCustomBar(arrayVisualizer, bar, renderer, width, analysis); break; }
+ if (Highlights.containsPosition(index - 9)) { markCustomBar(arrayVisualizer, bar, renderer, width, analysis); break; }
+ if (Highlights.containsPosition(index - 8)) { markCustomBar(arrayVisualizer, bar, renderer, width, analysis); break; }
+ case 13: if (Highlights.containsPosition(index - 7)) { markCustomBar(arrayVisualizer, bar, renderer, width, analysis); break; }
+ if (Highlights.containsPosition(index - 6)) { markCustomBar(arrayVisualizer, bar, renderer, width, analysis); break; }
+ if (Highlights.containsPosition(index - 5)) { markCustomBar(arrayVisualizer, bar, renderer, width, analysis); break; }
+ case 12: if (Highlights.containsPosition(index - 4)) { markCustomBar(arrayVisualizer, bar, renderer, width, analysis); break; }
+ if (Highlights.containsPosition(index - 3)) { markCustomBar(arrayVisualizer, bar, renderer, width, analysis); break; }
+ case 11: if (Highlights.containsPosition(index - 2)) { markCustomBar(arrayVisualizer, bar, renderer, width, analysis); break; }
+ case 10: if (Highlights.containsPosition(index - 1)) { markCustomBar(arrayVisualizer, bar, renderer, width, analysis); break; }
+ default: if (Highlights.containsPosition(index)) markCustomBar(arrayVisualizer, bar, renderer, width, analysis);
+ // @checkstyle:on LeftCurlyCheck|IndentationCheck
}
}
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- if (Renderer.auxActive) return;
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ if (renderer.isAuxActive()) return;
try {
/*
@@ -286,7 +285,7 @@ public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Re
* handling exceptions whenever the user clicks the 'Custom Image' button.
*/
if (!this.imgImported) {
- if (!this.fetchBufferedImage(true, ArrayVisualizer.getMainWindow())) {
+ if (!this.fetchBufferedImage(true, arrayVisualizer.getMainWindow())) {
throw new Exception();
} else {
this.imgImported = true;
@@ -296,11 +295,11 @@ public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Re
* Use a fast image scaling method if the window was resized. If an ImagingOpException is thrown, don't continue with
* the 'Custom Image' visual.
*/
- if (this.windowHeight != ArrayVisualizer.currentHeight() || this.windowWidth != ArrayVisualizer.currentWidth()) {
- if (!this.getScaledImage(ArrayVisualizer.currentWidth(), ArrayVisualizer.currentHeight())) {
+ if (this.windowHeight != arrayVisualizer.currentHeight() || this.windowWidth != arrayVisualizer.currentWidth()) {
+ if (!this.getScaledImage(arrayVisualizer.currentWidth(), arrayVisualizer.currentHeight())) {
throw new Exception();
}
- this.updateWindowDims(ArrayVisualizer);
+ this.updateWindowDims(arrayVisualizer);
}
if (this.openImgMenu) {
@@ -311,12 +310,12 @@ public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Re
}
} catch (Exception e) {
JErrorPane.invokeErrorMessage(e);
- ArrayVisualizer.setVisual(io.github.arrayv.visuals.VisualStyles.BARS);
+ arrayVisualizer.setVisual(io.github.arrayv.visuals.VisualStyles.BARS);
return;
}
- for (int i = 0, j = 0; i < ArrayVisualizer.getCurrentLength(); i++) {
- int width = (int) (Renderer.getXScale() * (i + 1) - j);
+ for (int i = 0, j = 0; i < arrayVisualizer.getCurrentLength(); i++) {
+ int width = (int) (renderer.getXScale() * (i + 1) - j);
if (width == 0) continue;
//Cuts the image in respect to each item in the array
@@ -326,29 +325,29 @@ public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Re
j + 20,
40,
j + 20 + width,
- ArrayVisualizer.windowHeight()-10,
+ arrayVisualizer.windowHeight()-10,
- (int) ((double) this.imgWidth / ArrayVisualizer.getCurrentLength() * array[i]),
+ (int) ((double) this.imgWidth / arrayVisualizer.getCurrentLength() * array[i]),
0,
- (int) Math.ceil((double) this.imgWidth / ArrayVisualizer.getCurrentLength() * (array[i] + 1)),
+ (int) Math.ceil((double) this.imgWidth / arrayVisualizer.getCurrentLength() * (array[i] + 1)),
this.imgHeight,
null
);
j += width;
}
- for (int i = 0, j = 0; i < ArrayVisualizer.getCurrentLength(); i++) {
- int width = (int) (Renderer.getXScale() * (i + 1)) - j;
+ for (int i = 0, j = 0; i < arrayVisualizer.getCurrentLength(); i++) {
+ int width = (int) (renderer.getXScale() * (i + 1)) - j;
if (Highlights.fancyFinishActive() && i < Highlights.getFancyFinishPosition()) {
this.mainRender.setColor(new Color(0, 1, 0, .5f));
- if (width > 0) this.mainRender.fillRect(j + 20, 40, width, ArrayVisualizer.windowHeight()-10);
+ if (width > 0) this.mainRender.fillRect(j + 20, 40, width, arrayVisualizer.windowHeight()-10);
} else if (Highlights.containsPosition(i)) {
- if (ArrayVisualizer.analysisEnabled()) this.mainRender.setColor(new Color(0, 0, 1, .5f));
+ if (arrayVisualizer.analysisEnabled()) this.mainRender.setColor(new Color(0, 0, 1, .5f));
else this.mainRender.setColor(new Color(1, 0, 0, .5f));
- this.mainRender.fillRect(j + 20, 40, Math.max(width, 2), ArrayVisualizer.windowHeight()-10);
+ this.mainRender.fillRect(j + 20, 40, Math.max(width, 2), arrayVisualizer.windowHeight()-10);
}
j += width;
}
diff --git a/src/main/java/io/github/arrayv/visuals/misc/HoopStack.java b/src/main/java/io/github/arrayv/visuals/misc/HoopStack.java
index b0535cbb..d918757a 100644
--- a/src/main/java/io/github/arrayv/visuals/misc/HoopStack.java
+++ b/src/main/java/io/github/arrayv/visuals/misc/HoopStack.java
@@ -34,8 +34,8 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class HoopStack extends Visual {
- public HoopStack(ArrayVisualizer ArrayVisualizer) {
- super(ArrayVisualizer);
+ public HoopStack(ArrayVisualizer arrayVisualizer) {
+ super(arrayVisualizer);
}
private void drawEllipseFromCenter(int x, int y, int rx, int ry) {
@@ -43,17 +43,17 @@ private void drawEllipseFromCenter(int x, int y, int rx, int ry) {
}
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- if (Renderer.auxActive) return;
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ if (renderer.isAuxActive()) return;
- int width = ArrayVisualizer.windowWidth();
- int height = ArrayVisualizer.windowHeight();
- int length = ArrayVisualizer.getCurrentLength();
+ int width = arrayVisualizer.windowWidth();
+ int height = arrayVisualizer.windowHeight();
+ int length = arrayVisualizer.getCurrentLength();
int radiusX = height / 3;
int radiusY = height / 9;
- this.mainRender.setStroke(ArrayVisualizer.getThinStroke());
+ this.mainRender.setStroke(arrayVisualizer.getThinStroke());
for (int i = length - 1; i >= 0; i--) {
double scale = (array[i] + 1) / (double) (length + 1);
@@ -64,16 +64,15 @@ public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Re
this.mainRender.setColor(Color.GREEN);
else if (Highlights.containsPosition(i)) {
- if (ArrayVisualizer.analysisEnabled()) this.mainRender.setColor(Color.LIGHT_GRAY);
+ if (arrayVisualizer.analysisEnabled()) this.mainRender.setColor(Color.LIGHT_GRAY);
else this.mainRender.setColor(Color.WHITE);
- this.mainRender.setStroke(ArrayVisualizer.getDefaultStroke());
- }
- else this.mainRender.setColor(getIntColor(array[i], length));
+ this.mainRender.setStroke(arrayVisualizer.getDefaultStroke());
+ } else this.mainRender.setColor(getIntColor(array[i], length));
this.drawEllipseFromCenter(width / 2, y + radiusY * 2, (int) (scale * radiusX + 0.5), (int) (scale * radiusY + 0.5));
- this.mainRender.setStroke(ArrayVisualizer.getThinStroke());
+ this.mainRender.setStroke(arrayVisualizer.getThinStroke());
}
- this.mainRender.setStroke(ArrayVisualizer.getDefaultStroke());
+ this.mainRender.setStroke(arrayVisualizer.getDefaultStroke());
}
}
diff --git a/src/main/java/io/github/arrayv/visuals/misc/PixelMesh.java b/src/main/java/io/github/arrayv/visuals/misc/PixelMesh.java
index 3610acfd..2ba5bbbf 100644
--- a/src/main/java/io/github/arrayv/visuals/misc/PixelMesh.java
+++ b/src/main/java/io/github/arrayv/visuals/misc/PixelMesh.java
@@ -34,17 +34,17 @@ of this software and associated documentation files (the "Software"), to deal
*/
public final class PixelMesh extends Visual {
- public PixelMesh(ArrayVisualizer ArrayVisualizer) {
- super(ArrayVisualizer);
+ public PixelMesh(ArrayVisualizer arrayVisualizer) {
+ super(arrayVisualizer);
}
@Override
- public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Renderer, Highlights Highlights) {
- if (Renderer.auxActive) return;
+ public void drawVisual(int[] array, ArrayVisualizer arrayVisualizer, Renderer renderer, Highlights Highlights) {
+ if (renderer.isAuxActive()) return;
- int width = ArrayVisualizer.windowWidth()-40;
- int height = ArrayVisualizer.windowHeight()-50;
- int length = ArrayVisualizer.getCurrentLength();
+ int width = arrayVisualizer.windowWidth()-40;
+ int height = arrayVisualizer.windowHeight()-50;
+ int length = arrayVisualizer.getCurrentLength();
int sqrt = (int)Math.ceil(Math.sqrt(length));
int square = sqrt*sqrt;
@@ -62,10 +62,9 @@ public void drawVisual(int[] array, ArrayVisualizer ArrayVisualizer, Renderer Re
this.mainRender.setColor(Color.GREEN);
else if (Highlights.containsPosition(idx)) {
- if (ArrayVisualizer.analysisEnabled()) this.mainRender.setColor(Color.LIGHT_GRAY);
+ if (arrayVisualizer.analysisEnabled()) this.mainRender.setColor(Color.LIGHT_GRAY);
else this.mainRender.setColor(Color.WHITE);
- }
- else this.mainRender.setColor(getIntColor(array[idx], length));
+ } else this.mainRender.setColor(getIntColor(array[idx], length));
this.mainRender.fillRect(20 + (int)(x * xStep), 40 + (int)(y * yStep),
(int)((x+1)*xStep - x*xStep)+1, (int)((y+1)*yStep - y*yStep)+1);