mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Some minor formatting.
This commit is contained in:
parent
ca49dc7a31
commit
1ae85dc1b4
2 changed files with 51 additions and 22 deletions
|
@ -61,7 +61,7 @@ public class ChatPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
private UUID chatId;
|
private UUID chatId;
|
||||||
private Session session;
|
private Session session;
|
||||||
private List<String> players = new ArrayList<String>();
|
private final List<String> players = new ArrayList<String>();
|
||||||
private final TableModel tableModel;
|
private final TableModel tableModel;
|
||||||
/**
|
/**
|
||||||
* Chat message color for opponents.
|
* Chat message color for opponents.
|
||||||
|
@ -121,7 +121,7 @@ public class ChatPanel extends javax.swing.JPanel {
|
||||||
/**
|
/**
|
||||||
* Maps message colors to {@link Color}.
|
* Maps message colors to {@link Color}.
|
||||||
*/
|
*/
|
||||||
private static final Map<MessageColor, Color> colorMap = new EnumMap<MessageColor, Color>(MessageColor.class);
|
private static final Map<MessageColor, Color> colorMap = new EnumMap<>(MessageColor.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
colorMap.put(MessageColor.BLACK, Color.black);
|
colorMap.put(MessageColor.BLACK, Color.black);
|
||||||
|
@ -144,6 +144,7 @@ public class ChatPanel extends javax.swing.JPanel {
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Creates new form ChatPanel
|
* Creates new form ChatPanel
|
||||||
|
* @param addPlayersTab
|
||||||
*/
|
*/
|
||||||
public ChatPanel(boolean addPlayersTab) {
|
public ChatPanel(boolean addPlayersTab) {
|
||||||
tableModel = new TableModel();
|
tableModel = new TableModel();
|
||||||
|
@ -299,7 +300,7 @@ public class ChatPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
class TableModel extends AbstractTableModel {
|
class TableModel extends AbstractTableModel {
|
||||||
|
|
||||||
private String[] columnNames = new String[]{"Players", "Info", "Games"};
|
private final String[] columnNames = new String[]{"Players", "Info", "Games"};
|
||||||
private UsersView[] players = new UsersView[0];
|
private UsersView[] players = new UsersView[0];
|
||||||
|
|
||||||
public void loadData(Collection<UsersView> players) throws MageRemoteException {
|
public void loadData(Collection<UsersView> players) throws MageRemoteException {
|
||||||
|
|
|
@ -41,11 +41,12 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||||
* a thread-safe circular list
|
* a thread-safe circular list
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
* @param <E>
|
||||||
*/
|
*/
|
||||||
public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
||||||
//TODO: might have to make E extend Copyable
|
//TODO: might have to make E extend Copyable
|
||||||
|
|
||||||
protected List<E> list = new ArrayList<E>();
|
protected List<E> list = new ArrayList<>();
|
||||||
|
|
||||||
protected final ReentrantLock lock = new ReentrantLock();
|
protected final ReentrantLock lock = new ReentrantLock();
|
||||||
|
|
||||||
|
@ -63,11 +64,13 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CircularList<E> copy() {
|
public CircularList<E> copy() {
|
||||||
return new CircularList<E>(this);
|
return new CircularList<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts an element into the current position
|
* Inserts an element into the current position
|
||||||
|
* @param e
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean add(E e) {
|
public boolean add(E e) {
|
||||||
|
@ -102,6 +105,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the element at the current position
|
* Retrieves the element at the current position
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public E get() {
|
public E get() {
|
||||||
return list.get(this.index);
|
return list.get(this.index);
|
||||||
|
@ -182,8 +186,9 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
||||||
|
|
||||||
private int incrementListPointer(int index) {
|
private int incrementListPointer(int index) {
|
||||||
index++;
|
index++;
|
||||||
if (index >= list.size())
|
if (index >= list.size()) {
|
||||||
index = 0;
|
index = 0;
|
||||||
|
}
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,8 +205,9 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
||||||
|
|
||||||
private int decrementListPointer(int index) {
|
private int decrementListPointer(int index) {
|
||||||
index--;
|
index--;
|
||||||
if (index < 0)
|
if (index < 0) {
|
||||||
index = list.size() - 1;
|
index = list.size() - 1;
|
||||||
|
}
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,8 +219,9 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
||||||
if (index > list.size()) {
|
if (index > list.size()) {
|
||||||
index = list.size() - 1;
|
index = list.size() - 1;
|
||||||
}
|
}
|
||||||
else if (index < 0)
|
else if (index < 0) {
|
||||||
index = 0;
|
index = 0;
|
||||||
|
}
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,17 +350,17 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<E> iterator() {
|
public Iterator<E> iterator() {
|
||||||
return new CircularIterator<E>();
|
return new CircularIterator<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListIterator<E> listIterator() {
|
public ListIterator<E> listIterator() {
|
||||||
return new CircularListIterator<E>();
|
return new CircularListIterator<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListIterator<E> listIterator(int index) {
|
public ListIterator<E> listIterator(int index) {
|
||||||
return new CircularListIterator<E>(index);
|
return new CircularListIterator<>(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CircularIterator<E> implements Iterator<E> {
|
private class CircularIterator<E> implements Iterator<E> {
|
||||||
|
@ -371,23 +378,27 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
if (!hasMoved && size() > 0)
|
if (!hasMoved && size() > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return cursor != lastIndex;
|
return cursor != lastIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public E next() {
|
public E next() {
|
||||||
if (!this.hasNext())
|
if (!this.hasNext()) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
if (curModCount != modCount)
|
}
|
||||||
|
if (curModCount != modCount) {
|
||||||
throw new ConcurrentModificationException();
|
throw new ConcurrentModificationException();
|
||||||
|
}
|
||||||
E data = (E) list.get(cursor);
|
E data = (E) list.get(cursor);
|
||||||
cursor = incrementListPointer(cursor);
|
cursor = incrementListPointer(cursor);
|
||||||
hasMoved = true;
|
hasMoved = true;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
|
@ -412,59 +423,76 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
||||||
lastIndex = index;
|
lastIndex = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
if (!hasMoved && size() > 0)
|
if (!hasMoved && size() > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return cursor != lastIndex;
|
return cursor != lastIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public E next() {
|
public E next() {
|
||||||
if (!this.hasNext())
|
if (!this.hasNext()) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
if (curModCount != modCount)
|
}
|
||||||
|
if (curModCount != modCount) {
|
||||||
throw new ConcurrentModificationException();
|
throw new ConcurrentModificationException();
|
||||||
|
}
|
||||||
E data = (E) list.get(cursor);
|
E data = (E) list.get(cursor);
|
||||||
cursor = incrementListPointer(cursor);
|
cursor = incrementListPointer(cursor);
|
||||||
hasMoved = true;
|
hasMoved = true;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
if (!hasMoved && size() > 0)
|
if (!hasMoved && size() > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return cursor != firstIndex;
|
return cursor != firstIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public E previous() {
|
public E previous() {
|
||||||
if (!this.hasPrevious())
|
if (!this.hasPrevious()) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
if (curModCount != modCount)
|
}
|
||||||
|
if (curModCount != modCount) {
|
||||||
throw new ConcurrentModificationException();
|
throw new ConcurrentModificationException();
|
||||||
|
}
|
||||||
cursor = decrementListPointer(cursor);
|
cursor = decrementListPointer(cursor);
|
||||||
hasMoved = true;
|
hasMoved = true;
|
||||||
return (E) list.get(cursor);
|
return (E) list.get(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int nextIndex() {
|
public int nextIndex() {
|
||||||
if (this.hasNext())
|
if (this.hasNext()) {
|
||||||
return incrementListPointer(cursor);
|
return incrementListPointer(cursor);
|
||||||
|
}
|
||||||
return list.size();
|
return list.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int previousIndex() {
|
public int previousIndex() {
|
||||||
if (this.hasPrevious())
|
if (this.hasPrevious()) {
|
||||||
return decrementListPointer(cursor);
|
return decrementListPointer(cursor);
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void set(E arg0) {
|
public void set(E arg0) {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void add(E arg0) {
|
public void add(E arg0) {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue