Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kuronekochomusuke committed Nov 12, 2024
1 parent 306ac8e commit 49d0538
Showing 1 changed file with 24 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class BoardTableModel extends AbstractTableModel {
private List<Integer> width;
private List<Integer> height;


public BoardTableModel() {
data = new ArrayList<>();
}
Expand All @@ -56,43 +55,11 @@ public int getRowCount() {
return data.size();
}

public void clearData() {
data = new ArrayList<>();
tags = new ArrayList<>();
width = new ArrayList<>();
height = new ArrayList<>();
fireTableDataChanged();
}

@Override
public int getColumnCount() {
return N_COL;
}

public int getPreferredWidth(int col) {
return switch (col) {
case COL_NAME -> 200;
case COL_SIZE -> 20;
default -> 10;
};
}

public void setData(BoardClassifier bc) {
data = bc.getBoardPaths().values().stream().toList();;
tags = new ArrayList<>();
width = new ArrayList<>();
height = new ArrayList<>();

for (String path : data) {
String key = Configuration.boardsDir() + path;
tags.add(bc.getBoardTags().get(key));
width.add(bc.getBoardWidth().get(key));
height.add(bc.getBoardHeigth().get(key));
}

fireTableDataChanged();
}

@Override
public String getColumnName(int column) {
switch (column) {
Expand Down Expand Up @@ -137,6 +104,30 @@ public Object getValueAt(int row, int col) {
return value;
}

public int getPreferredWidth(int col) {
return switch (col) {
case COL_NAME -> 200;
case COL_SIZE -> 20;
default -> 10;
};
}

public void setData(BoardClassifier bc) {
data = bc.getBoardPaths().values().stream().toList();;
tags = new ArrayList<>();
width = new ArrayList<>();
height = new ArrayList<>();

for (String path : data) {
String key = Configuration.boardsDir() + path;
tags.add(bc.getBoardTags().get(key));
width.add(bc.getBoardWidth().get(key));
height.add(bc.getBoardHeigth().get(key));
}

fireTableDataChanged();
}

public String getPathAt(int row) {
if (data.size() <= row) {
return null;
Expand All @@ -161,10 +152,6 @@ public Integer getHeightAt(int row) {
return height.get(row);
}

public List<String> getAllPaths() {
return data;
}

public ImageIcon getIconAt(int row, int height) {
String path = getPathAt(row);
Board board = new Board(16, 17);
Expand Down

0 comments on commit 49d0538

Please sign in to comment.