Skip to content

Commit a9d4451

Browse files
authored
Merge pull request #33 from dlarocque/NewFeature
Changed 4k display size
2 parents dc764e4 + 57c7f30 commit a9d4451

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/com/example/algorithmvisualizer/ArrDisplay.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void paintComponent(Graphics g) {
6565
// Iterate through the array and draw every index
6666
for (int i = 0; i < arr.length; i++) {
6767
int width = (int) (frame.getArrDisplayWidth() / (double) arr.length);
68-
int height = arr[i] * (frame.getArrDisplayHeight() / arr.length);
68+
int height = arr[i] * ((int) (frame.getArrDisplayHeight() / (double) arr.length));
6969
int x = i * width;
7070
int y = frame.getArrDisplayHeight() - height;
7171
if (i == swappedIndex1 && !algVisualizer.stopSort()) {

src/com/example/algorithmvisualizer/ContentWindow.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,18 @@ public ContentWindow(AlgVisualizer algVisualizer) {
5050
*/
5151
public void initComponents() {
5252

53-
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
54-
double screenWidth = screenSize.getWidth();
55-
double screenHeight = screenSize.getHeight();
53+
double screenHeight = Toolkit.getDefaultToolkit().getScreenSize().getHeight();
5654
String[] sizeOptions;
5755

5856
if (screenHeight > 1080.0) { // 4k
59-
arrDisplayHeight = 1000;
57+
arrDisplayHeight = 2000;
6058
contentWidth = arrDisplayHeight;
6159
sizeOptions = new String[] { "10", "50", "100", "250", "500", "1000" };
6260
} else if (screenHeight < 1080.0) { // too small for original dimensions
6361
arrDisplayHeight = 500;
6462
contentWidth = arrDisplayHeight + 400;
6563
sizeOptions = new String[] { "10", "50", "100", "250", "500" };
66-
} else { // Original dimensions
64+
} else { // Original dimensions (1080p)
6765
arrDisplayHeight = 900;
6866
contentWidth = arrDisplayHeight;
6967
sizeOptions = new String[] { "10", "50", "100", "300", "450", "900" };
@@ -83,8 +81,9 @@ public void initComponents() {
8381
buttonPanel.setBackground(Color.DARK_GRAY);
8482

8583
arrPanel = new JPanel();
86-
arrPanel.setBackground(Color.DARK_GRAY);
84+
arrPanel.setBackground(Color.RED);
8785
arrPanel.add(arrDisplay);
86+
//arrPanel.setPreferredSize(new Dimension(arrDisplayWidth, arrDisplayHeight));
8887
arrDisplay.setAlignmentX(0);
8988

9089
// Initialize all components and add action listeners
@@ -174,11 +173,11 @@ public int getContentWidth() {
174173
}
175174

176175
public int getContentHeight() {
177-
return contentWidth;
176+
return contentHeight;
178177
}
179178

180179
public int getArrDisplayWidth() {
181-
return arrDisplayHeight;
180+
return arrDisplayWidth;
182181
}
183182

184183
public int getArrDisplayHeight() {

0 commit comments

Comments
 (0)