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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/com/example/algorithmvisualizer/ArrDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void paintComponent(Graphics g) {
// Iterate through the array and drawn every index
for (int i = 0; i < arr.length; i++) {
int width = (int) (frame.getArrDisplayWidth() / (double) arr.length);
int height = arr[i] * (frame.getArrDisplayHeight() / arr.length);
int height = arr[i] * ((int) (frame.getArrDisplayHeight() / (double) arr.length));
int x = i * width;
int y = frame.getArrDisplayHeight() - height;
if (i == swappedIndex1 && !algVisualizer.stopSort()) {
Expand Down
15 changes: 7 additions & 8 deletions src/com/example/algorithmvisualizer/ContentWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,18 @@ public ContentWindow(AlgVisualizer algVisualizer) {
*/
public void initComponents() {

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
double screenWidth = screenSize.getWidth();
double screenHeight = screenSize.getHeight();
double screenHeight = Toolkit.getDefaultToolkit().getScreenSize().getHeight();
String[] sizeOptions;

if (screenHeight > 1080.0) { // 4k
arrDisplayHeight = 1000;
arrDisplayHeight = 2000;
contentWidth = arrDisplayHeight;
sizeOptions = new String[] { "10", "50", "100", "250", "500", "1000" };
} else if (screenHeight < 1080.0) { // too small for original dimensions
arrDisplayHeight = 500;
contentWidth = arrDisplayHeight + 400;
sizeOptions = new String[] { "10", "50", "100", "250", "500" };
} else { // Original dimensions
} else { // Original dimensions (1080p)
arrDisplayHeight = 900;
contentWidth = arrDisplayHeight;
sizeOptions = new String[] { "10", "50", "100", "300", "450", "900" };
Expand All @@ -83,8 +81,9 @@ public void initComponents() {
buttonPanel.setBackground(Color.DARK_GRAY);

arrPanel = new JPanel();
arrPanel.setBackground(Color.DARK_GRAY);
arrPanel.setBackground(Color.RED);
arrPanel.add(arrDisplay);
//arrPanel.setPreferredSize(new Dimension(arrDisplayWidth, arrDisplayHeight));
arrDisplay.setAlignmentX(0);

// Initialize all components and add action listeners
Expand Down Expand Up @@ -174,11 +173,11 @@ public int getContentWidth() {
}

public int getContentHeight() {
return contentWidth;
return contentHeight;
}

public int getArrDisplayWidth() {
return arrDisplayHeight;
return arrDisplayWidth;
}

public int getArrDisplayHeight() {
Expand Down