forked from External/mage
[refactoring][minor] Replaced all tabs with four spaces.
This commit is contained in:
parent
e646e4768d
commit
239a4fb100
2891 changed files with 79411 additions and 79411 deletions
|
|
@ -29,17 +29,17 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
private static final int DIALOG_WIDTH = 440;
|
||||
private static final int DIALOG_HEIGHT = 260;
|
||||
|
||||
private transient static final Logger log = Logger.getLogger(AbilityPicker.class);
|
||||
private transient static final Logger log = Logger.getLogger(AbilityPicker.class);
|
||||
|
||||
private JList rows;
|
||||
private List<Object> choices;
|
||||
private String message = DEFAULT_MESSAGE;
|
||||
|
||||
private Session session;
|
||||
private UUID gameId;
|
||||
private UUID gameId;
|
||||
|
||||
private BackgroundPainter mwPanelPainter;
|
||||
private JScrollPane jScrollPane2;
|
||||
private JScrollPane jScrollPane2;
|
||||
private JTextField title;
|
||||
|
||||
private Image rightImage;
|
||||
|
|
@ -51,213 +51,213 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
private static Color SELECTED_COLOR = new Color(64,147,208);
|
||||
private static Color BORDER_COLOR = new Color(0,0,0,50);
|
||||
|
||||
private boolean selected = false;
|
||||
private boolean selected = false;
|
||||
|
||||
public AbilityPicker() {
|
||||
setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
initComponents();
|
||||
initComponents();
|
||||
|
||||
jScrollPane2.setOpaque(false);
|
||||
jScrollPane2.setOpaque(false);
|
||||
jScrollPane2.getViewport().setOpaque(false);
|
||||
UIManager.put( "ScrollBar.width", 17);
|
||||
jScrollPane2.getHorizontalScrollBar().setUI(new MageScrollbarUI());
|
||||
UIManager.put( "ScrollBar.width", 17);
|
||||
jScrollPane2.getHorizontalScrollBar().setUI(new MageScrollbarUI());
|
||||
jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI());
|
||||
}
|
||||
|
||||
public AbilityPicker(List<Object> choices, String message) {
|
||||
this.choices = choices;
|
||||
setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
if (message!= null) {
|
||||
this.message = message + " (single-click)";
|
||||
}
|
||||
initComponents();
|
||||
jScrollPane2.setOpaque(false);
|
||||
jScrollPane2.getViewport().setOpaque(false);
|
||||
UIManager.put( "ScrollBar.width", 17);
|
||||
jScrollPane2.getHorizontalScrollBar().setUI(new MageScrollbarUI());
|
||||
jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI());
|
||||
}
|
||||
this.choices = choices;
|
||||
setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
if (message!= null) {
|
||||
this.message = message + " (single-click)";
|
||||
}
|
||||
initComponents();
|
||||
jScrollPane2.setOpaque(false);
|
||||
jScrollPane2.getViewport().setOpaque(false);
|
||||
UIManager.put( "ScrollBar.width", 17);
|
||||
jScrollPane2.getHorizontalScrollBar().setUI(new MageScrollbarUI());
|
||||
jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI());
|
||||
}
|
||||
|
||||
public void init(Session session, UUID gameId) {
|
||||
this.session = session;
|
||||
this.gameId = gameId;
|
||||
}
|
||||
this.session = session;
|
||||
this.gameId = gameId;
|
||||
}
|
||||
|
||||
public void show(AbilityPickerView choices, Point p) {
|
||||
this.choices = new ArrayList<Object>();
|
||||
this.selected = true; // to stop previous modal
|
||||
this.selected = true; // to stop previous modal
|
||||
|
||||
for (Map.Entry<UUID, String> choice: choices.getChoices().entrySet()) {
|
||||
this.choices.add(new AbilityPickerAction(choice.getKey(), choice.getValue()));
|
||||
}
|
||||
for (Map.Entry<UUID, String> choice: choices.getChoices().entrySet()) {
|
||||
this.choices.add(new AbilityPickerAction(choice.getKey(), choice.getValue()));
|
||||
}
|
||||
this.choices.add(new AbilityPickerAction(null, "Cancel"));
|
||||
|
||||
show(this.choices);
|
||||
}
|
||||
show(this.choices);
|
||||
}
|
||||
|
||||
private void show(List<Object> choices) {
|
||||
this.choices = choices;
|
||||
this.selected = true; // to stop previous modal
|
||||
private void show(List<Object> choices) {
|
||||
this.choices = choices;
|
||||
this.selected = true; // to stop previous modal
|
||||
|
||||
rows.setListData(this.choices.toArray());
|
||||
this.rows.setSelectedIndex(0);
|
||||
this.selected = false; // back to false - waiting for selection
|
||||
setVisible(true);
|
||||
rows.setListData(this.choices.toArray());
|
||||
this.rows.setSelectedIndex(0);
|
||||
this.selected = false; // back to false - waiting for selection
|
||||
setVisible(true);
|
||||
|
||||
Point centered = SettingsManager.getInstance().getComponentPosition(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
this.setLocation(centered.x, centered.y);
|
||||
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this);
|
||||
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this);
|
||||
|
||||
//startModal();
|
||||
}
|
||||
//startModal();
|
||||
}
|
||||
|
||||
public void initComponents() {
|
||||
JLabel jLabel1;
|
||||
JLabel jLabel3;
|
||||
JLabel jLabel3;
|
||||
|
||||
Color textColor = Color.white;
|
||||
Color textColor = Color.white;
|
||||
|
||||
mwPanelPainter = new BackgroundPainter();
|
||||
jLabel1 = new JLabel();
|
||||
jLabel3 = new JLabel();
|
||||
mwPanelPainter = new BackgroundPainter();
|
||||
jLabel1 = new JLabel();
|
||||
jLabel3 = new JLabel();
|
||||
|
||||
title = new JTextField();
|
||||
jScrollPane2 = new JScrollPane();
|
||||
title = new JTextField();
|
||||
jScrollPane2 = new JScrollPane();
|
||||
|
||||
setBackground(textColor);
|
||||
setBackgroundPainter(mwPanelPainter);
|
||||
jLabel1.setFont(new Font("Times New Roman", 1, 18));
|
||||
jLabel1.setForeground(textColor);
|
||||
jLabel1.setText(message);
|
||||
setBackground(textColor);
|
||||
setBackgroundPainter(mwPanelPainter);
|
||||
jLabel1.setFont(new Font("Times New Roman", 1, 18));
|
||||
jLabel1.setForeground(textColor);
|
||||
jLabel1.setText(message);
|
||||
|
||||
jLabel3.setForeground(textColor);
|
||||
jLabel3.setHorizontalAlignment(SwingConstants.TRAILING);
|
||||
jLabel3.setText("Selected:");
|
||||
jLabel3.setForeground(textColor);
|
||||
jLabel3.setHorizontalAlignment(SwingConstants.TRAILING);
|
||||
jLabel3.setText("Selected:");
|
||||
|
||||
title.setFont(new Font("Tahoma", 1, 11));
|
||||
title.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
|
||||
title.setFont(new Font("Tahoma", 1, 11));
|
||||
title.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
|
||||
|
||||
jScrollPane2.setBorder(null);
|
||||
jScrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
jScrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
jScrollPane2.setBorder(null);
|
||||
jScrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
jScrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
|
||||
rightImage = ImageHelper.loadImage(IMAGE_RIGHT_PATH);
|
||||
rightImageHovered = ImageHelper.loadImage(IMAGE_RIGHT_HOVERED_PATH);
|
||||
rightImage = ImageHelper.loadImage(IMAGE_RIGHT_PATH);
|
||||
rightImageHovered = ImageHelper.loadImage(IMAGE_RIGHT_HOVERED_PATH);
|
||||
|
||||
setOpaque(false);
|
||||
setOpaque(false);
|
||||
|
||||
rows = new JList();
|
||||
|
||||
rows.setBackground(textColor);
|
||||
rows.setCellRenderer(new ImageRenderer());
|
||||
rows.ensureIndexIsVisible(rows.getModel().getSize());
|
||||
rows.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
rows.setLayoutOrientation(JList.VERTICAL);
|
||||
rows.setMaximumSize(new Dimension(32767, 32767));
|
||||
rows.setMinimumSize(new Dimension(67, 16));
|
||||
rows.setOpaque(false);
|
||||
rows.addMouseListener(new MouseAdapter() {
|
||||
rows.setBackground(textColor);
|
||||
rows.setCellRenderer(new ImageRenderer());
|
||||
rows.ensureIndexIsVisible(rows.getModel().getSize());
|
||||
rows.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
rows.setLayoutOrientation(JList.VERTICAL);
|
||||
rows.setMaximumSize(new Dimension(32767, 32767));
|
||||
rows.setMinimumSize(new Dimension(67, 16));
|
||||
rows.setOpaque(false);
|
||||
rows.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent evt) {
|
||||
if (evt.getButton() == MouseEvent.BUTTON1) {
|
||||
objectMouseClicked(evt);
|
||||
}
|
||||
}
|
||||
});
|
||||
rows.setSelectedIndex(0);
|
||||
rows.setFont(new Font("Times New Roman", 1, 17));
|
||||
rows.setBorder(BorderFactory.createEmptyBorder());
|
||||
rows.addMouseWheelListener(this);
|
||||
rows.setSelectedIndex(0);
|
||||
rows.setFont(new Font("Times New Roman", 1, 17));
|
||||
rows.setBorder(BorderFactory.createEmptyBorder());
|
||||
rows.addMouseWheelListener(this);
|
||||
|
||||
jScrollPane2.setViewportView(rows);
|
||||
jScrollPane2.setViewportBorder(BorderFactory.createEmptyBorder());
|
||||
jScrollPane2.setViewportView(rows);
|
||||
jScrollPane2.setViewportBorder(BorderFactory.createEmptyBorder());
|
||||
|
||||
GroupLayout layout = new GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
GroupLayout layout = new GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.LEADING).add(
|
||||
GroupLayout.TRAILING,
|
||||
layout.createSequentialGroup().addContainerGap().add(
|
||||
layout.createParallelGroup(GroupLayout.TRAILING).add(GroupLayout.LEADING, jScrollPane2, GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE).add(GroupLayout.LEADING,
|
||||
layout.createSequentialGroup().add(jLabel1).addPreferredGap(LayoutStyle.RELATED, 175, Short.MAX_VALUE).add(1, 1, 1)).add(
|
||||
GroupLayout.LEADING,
|
||||
layout.createSequentialGroup().add(layout.createParallelGroup(GroupLayout.LEADING)
|
||||
)
|
||||
.addPreferredGap(LayoutStyle.RELATED)
|
||||
.add(
|
||||
layout.createParallelGroup(GroupLayout.TRAILING)
|
||||
.add(
|
||||
GroupLayout.TRAILING,
|
||||
layout.createSequentialGroup().addContainerGap().add(
|
||||
layout.createParallelGroup(GroupLayout.TRAILING).add(GroupLayout.LEADING, jScrollPane2, GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE).add(GroupLayout.LEADING,
|
||||
layout.createSequentialGroup().add(jLabel1).addPreferredGap(LayoutStyle.RELATED, 175, Short.MAX_VALUE).add(1, 1, 1)).add(
|
||||
GroupLayout.LEADING,
|
||||
layout.createSequentialGroup().add(layout.createParallelGroup(GroupLayout.LEADING)
|
||||
)
|
||||
.addPreferredGap(LayoutStyle.RELATED)
|
||||
.add(
|
||||
layout.createParallelGroup(GroupLayout.TRAILING)
|
||||
.add(
|
||||
GroupLayout.LEADING, layout.createParallelGroup(GroupLayout.LEADING))))).add(10, 10, 10)));
|
||||
|
||||
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.LEADING).add(
|
||||
layout.createSequentialGroup().add(
|
||||
layout.createParallelGroup(GroupLayout.LEADING).add(
|
||||
layout.createSequentialGroup().add(jLabel1, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE)
|
||||
.add(5, 5, 5)
|
||||
.add(
|
||||
layout.createParallelGroup(GroupLayout.BASELINE)
|
||||
)
|
||||
).add(layout.createSequentialGroup().add(8, 8, 8)))
|
||||
.addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(
|
||||
layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.LEADING)).addPreferredGap(
|
||||
LayoutStyle.RELATED).add(jScrollPane2, GroupLayout.PREFERRED_SIZE, 180, GroupLayout.PREFERRED_SIZE).addContainerGap(23, Short.MAX_VALUE)));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.LEADING).add(
|
||||
layout.createSequentialGroup().add(
|
||||
layout.createParallelGroup(GroupLayout.LEADING).add(
|
||||
layout.createSequentialGroup().add(jLabel1, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE)
|
||||
.add(5, 5, 5)
|
||||
.add(
|
||||
layout.createParallelGroup(GroupLayout.BASELINE)
|
||||
)
|
||||
).add(layout.createSequentialGroup().add(8, 8, 8)))
|
||||
.addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(
|
||||
layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.LEADING)).addPreferredGap(
|
||||
LayoutStyle.RELATED).add(jScrollPane2, GroupLayout.PREFERRED_SIZE, 180, GroupLayout.PREFERRED_SIZE).addContainerGap(23, Short.MAX_VALUE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
int notches = e.getWheelRotation();
|
||||
int index = rows.getSelectedIndex();
|
||||
int index = rows.getSelectedIndex();
|
||||
|
||||
if (notches < 0) {
|
||||
if (index > 0) {
|
||||
rows.setSelectedIndex(index-1);
|
||||
rows.repaint();
|
||||
}
|
||||
} else {
|
||||
if (index < choices.size() - 1) {
|
||||
rows.setSelectedIndex(index+1);
|
||||
rows.repaint();
|
||||
}
|
||||
}
|
||||
if (notches < 0) {
|
||||
if (index > 0) {
|
||||
rows.setSelectedIndex(index-1);
|
||||
rows.repaint();
|
||||
}
|
||||
} else {
|
||||
if (index < choices.size() - 1) {
|
||||
rows.setSelectedIndex(index+1);
|
||||
rows.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void objectMouseClicked(MouseEvent event) {
|
||||
int index = rows.getSelectedIndex();
|
||||
AbilityPickerAction action = (AbilityPickerAction)choices.get(index);
|
||||
int index = rows.getSelectedIndex();
|
||||
AbilityPickerAction action = (AbilityPickerAction)choices.get(index);
|
||||
action.actionPerformed(null);
|
||||
}
|
||||
}
|
||||
|
||||
class ImageRenderer extends DefaultListCellRenderer {
|
||||
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
|
||||
JLabel label = ((JLabel) c);
|
||||
label.setOpaque(false);
|
||||
label.setForeground(Color.white);
|
||||
JLabel label = ((JLabel) c);
|
||||
label.setOpaque(false);
|
||||
label.setForeground(Color.white);
|
||||
|
||||
if (choices.size() <= index) return label;
|
||||
if (choices.size() <= index) return label;
|
||||
|
||||
Object object = choices.get(index);
|
||||
String name = object.toString();
|
||||
label.setText(name);
|
||||
Object object = choices.get(index);
|
||||
String name = object.toString();
|
||||
label.setText(name);
|
||||
|
||||
if (isSelected) {
|
||||
label.setIcon(new ImageIcon(rightImageHovered));
|
||||
label.setForeground(SELECTED_COLOR);
|
||||
//label.setBorder(BorderFactory.createLineBorder(BORDER_COLOR));
|
||||
label.setBorder(BorderFactory.createEmptyBorder());
|
||||
} else {
|
||||
label.setIcon(new ImageIcon(rightImage));
|
||||
}
|
||||
if (isSelected) {
|
||||
label.setIcon(new ImageIcon(rightImageHovered));
|
||||
label.setForeground(SELECTED_COLOR);
|
||||
//label.setBorder(BorderFactory.createLineBorder(BORDER_COLOR));
|
||||
label.setBorder(BorderFactory.createEmptyBorder());
|
||||
} else {
|
||||
label.setIcon(new ImageIcon(rightImage));
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 7689696087189956997L;
|
||||
}
|
||||
private static final long serialVersionUID = 7689696087189956997L;
|
||||
}
|
||||
|
||||
private synchronized void startModal() {
|
||||
try {
|
||||
private synchronized void startModal() {
|
||||
try {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
EventQueue theQueue = getToolkit().getSystemEventQueue();
|
||||
while (!selected) {
|
||||
|
|
@ -268,17 +268,17 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
/*if (event instanceof MouseEvent) {
|
||||
MouseEvent e = (MouseEvent) event;
|
||||
if (e.getID() == MouseEvent.MOUSE_PRESSED || e.getID() == MouseEvent.MOUSE_CLICKED) {
|
||||
MouseEvent m = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, this);
|
||||
if (!this.contains(m.getPoint())) {
|
||||
selected = true;
|
||||
cancel();
|
||||
setVisible(false);
|
||||
dispatch = false;
|
||||
}
|
||||
}
|
||||
MouseEvent m = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, this);
|
||||
if (!this.contains(m.getPoint())) {
|
||||
selected = true;
|
||||
cancel();
|
||||
setVisible(false);
|
||||
dispatch = false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (event instanceof MouseEvent) {
|
||||
if (event instanceof MouseEvent) {
|
||||
MouseEvent e = (MouseEvent) event;
|
||||
MouseEvent m = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, this);
|
||||
if (!this.contains(m.getPoint()) && e.getID() != MouseEvent.MOUSE_DRAGGED) {
|
||||
|
|
@ -307,72 +307,72 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
}
|
||||
|
||||
public static void main(String[] argv) {
|
||||
try {
|
||||
try {
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
|
||||
JFrame jframe = new JFrame("Test");
|
||||
JFrame jframe = new JFrame("Test");
|
||||
|
||||
List<Object> objectList = new ArrayList<Object>();
|
||||
objectList.add("T: add {R} to your mana pool. 111111111111111111111111111");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("Cancel");
|
||||
AbilityPicker panel = new AbilityPicker(objectList, "Choose ability");
|
||||
jframe.add(panel);
|
||||
panel.show(objectList);
|
||||
jframe.setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
jframe.setVisible(true);
|
||||
}
|
||||
List<Object> objectList = new ArrayList<Object>();
|
||||
objectList.add("T: add {R} to your mana pool. 111111111111111111111111111");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("Cancel");
|
||||
AbilityPicker panel = new AbilityPicker(objectList, "Choose ability");
|
||||
jframe.add(panel);
|
||||
panel.show(objectList);
|
||||
jframe.setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
jframe.setVisible(true);
|
||||
}
|
||||
|
||||
public class AbilityPickerAction extends AbstractAction {
|
||||
|
||||
private UUID id;
|
||||
private UUID id;
|
||||
|
||||
public AbilityPickerAction(UUID id, String choice) {
|
||||
this.id = id;
|
||||
putValue(Action.NAME, choice);
|
||||
}
|
||||
public AbilityPickerAction(UUID id, String choice) {
|
||||
this.id = id;
|
||||
putValue(Action.NAME, choice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// cancel
|
||||
if (id == null) {
|
||||
cancel();
|
||||
} else {
|
||||
session.sendPlayerUUID(gameId, id);
|
||||
session.sendPlayerUUID(gameId, id);
|
||||
}
|
||||
setVisible(false);
|
||||
AbilityPicker.this.selected = true;
|
||||
}
|
||||
setVisible(false);
|
||||
AbilityPicker.this.selected = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return (String)getValue(Action.NAME);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void cancel() {
|
||||
try {
|
||||
session.sendPlayerBoolean(gameId, false);
|
||||
} catch (Exception e) {
|
||||
log.error("Couldn't cancel choose dialog: " + e, e);
|
||||
}
|
||||
}
|
||||
private void cancel() {
|
||||
try {
|
||||
session.sendPlayerBoolean(gameId, false);
|
||||
} catch (Exception e) {
|
||||
log.error("Couldn't cancel choose dialog: " + e, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,60 +16,60 @@ import javax.swing.plaf.metal.MetalScrollButton;
|
|||
*/
|
||||
public class MageScrollButton extends MetalScrollButton {
|
||||
|
||||
private static ImageIcon buttonLeft;
|
||||
private static ImageIcon buttonRight;
|
||||
private static ImageIcon buttonUp;
|
||||
private static ImageIcon buttonDown;
|
||||
private static ImageIcon buttonLeft;
|
||||
private static ImageIcon buttonRight;
|
||||
private static ImageIcon buttonUp;
|
||||
private static ImageIcon buttonDown;
|
||||
|
||||
private int width;
|
||||
private int width;
|
||||
|
||||
static {
|
||||
buttonLeft = new ImageIcon(MageScrollButton.class.getResource("/buttons/left.png"));
|
||||
buttonRight = new ImageIcon(MageScrollButton.class.getResource("/buttons/right.png"));
|
||||
buttonUp = new ImageIcon(MageScrollButton.class.getResource("/buttons/up.png"));
|
||||
buttonDown = new ImageIcon(MageScrollButton.class.getResource("/buttons/down.png"));
|
||||
}
|
||||
static {
|
||||
buttonLeft = new ImageIcon(MageScrollButton.class.getResource("/buttons/left.png"));
|
||||
buttonRight = new ImageIcon(MageScrollButton.class.getResource("/buttons/right.png"));
|
||||
buttonUp = new ImageIcon(MageScrollButton.class.getResource("/buttons/up.png"));
|
||||
buttonDown = new ImageIcon(MageScrollButton.class.getResource("/buttons/down.png"));
|
||||
}
|
||||
|
||||
public MageScrollButton(int direction, int width, boolean freeStanding) {
|
||||
super(direction, width, freeStanding);
|
||||
setOpaque(false);
|
||||
this.width = width;
|
||||
buttonUp.setImage(buttonUp.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
buttonDown.setImage(buttonDown.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
buttonLeft.setImage(buttonLeft.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
buttonRight.setImage(buttonRight.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
}
|
||||
public MageScrollButton(int direction, int width, boolean freeStanding) {
|
||||
super(direction, width, freeStanding);
|
||||
setOpaque(false);
|
||||
this.width = width;
|
||||
buttonUp.setImage(buttonUp.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
buttonDown.setImage(buttonDown.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
buttonLeft.setImage(buttonLeft.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
buttonRight.setImage(buttonRight.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMaximumSize() {
|
||||
return this.getPreferredSize();
|
||||
}
|
||||
@Override
|
||||
public Dimension getMaximumSize() {
|
||||
return this.getPreferredSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return this.getPreferredSize();
|
||||
}
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return this.getPreferredSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(width, width);
|
||||
}
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(width, width);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
switch (getDirection()) {
|
||||
case BasicArrowButton.WEST:
|
||||
buttonLeft.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
case BasicArrowButton.EAST:
|
||||
buttonRight.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
case BasicArrowButton.NORTH:
|
||||
buttonUp.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
case BasicArrowButton.SOUTH:
|
||||
buttonDown.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
switch (getDirection()) {
|
||||
case BasicArrowButton.WEST:
|
||||
buttonLeft.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
case BasicArrowButton.EAST:
|
||||
buttonRight.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
case BasicArrowButton.NORTH:
|
||||
buttonUp.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
case BasicArrowButton.SOUTH:
|
||||
buttonDown.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,139 +27,139 @@ import javax.swing.plaf.metal.MetalScrollBarUI;
|
|||
*/
|
||||
public class MageScrollbarUI extends MetalScrollBarUI {
|
||||
|
||||
private static int ANTI_WIDTH = -3;
|
||||
private static int ANTI_WIDTH = -3;
|
||||
|
||||
@Override
|
||||
public void installUI(JComponent c) {
|
||||
super.installUI(c);
|
||||
c.setOpaque(false);
|
||||
}
|
||||
@Override
|
||||
public void installUI(JComponent c) {
|
||||
super.installUI(c);
|
||||
c.setOpaque(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JButton createDecreaseButton(int orientation) {
|
||||
decreaseButton = new MageScrollButton(orientation, scrollBarWidth + ANTI_WIDTH, isFreeStanding);
|
||||
return decreaseButton;
|
||||
}
|
||||
@Override
|
||||
protected JButton createDecreaseButton(int orientation) {
|
||||
decreaseButton = new MageScrollButton(orientation, scrollBarWidth + ANTI_WIDTH, isFreeStanding);
|
||||
return decreaseButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JButton createIncreaseButton(int orientation) {
|
||||
increaseButton = new MageScrollButton(orientation, scrollBarWidth + ANTI_WIDTH, isFreeStanding);
|
||||
return increaseButton;
|
||||
}
|
||||
@Override
|
||||
protected JButton createIncreaseButton(int orientation) {
|
||||
increaseButton = new MageScrollButton(orientation, scrollBarWidth + ANTI_WIDTH, isFreeStanding);
|
||||
return increaseButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
@Override
|
||||
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
|
||||
int width = trackBounds.width - 4 + ANTI_WIDTH;
|
||||
int height = trackBounds.height;
|
||||
if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
|
||||
int width = trackBounds.width - 4 + ANTI_WIDTH;
|
||||
int height = trackBounds.height;
|
||||
|
||||
g2.translate(trackBounds.x + 2, trackBounds.y);
|
||||
g2.translate(trackBounds.x + 2, trackBounds.y);
|
||||
|
||||
Rectangle2D casing = new Rectangle2D.Double(0, 0, width, height);
|
||||
g2.setColor(Color.BLACK);
|
||||
Rectangle2D casing = new Rectangle2D.Double(0, 0, width, height);
|
||||
g2.setColor(Color.BLACK);
|
||||
|
||||
float alpha = 0.5f;
|
||||
Composite composite = g2.getComposite();
|
||||
if (composite instanceof AlphaComposite) {
|
||||
alpha *= ((AlphaComposite) composite).getAlpha();
|
||||
}
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
|
||||
g2.fill(casing);
|
||||
g2.setComposite(composite);
|
||||
float alpha = 0.5f;
|
||||
Composite composite = g2.getComposite();
|
||||
if (composite instanceof AlphaComposite) {
|
||||
alpha *= ((AlphaComposite) composite).getAlpha();
|
||||
}
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
|
||||
g2.fill(casing);
|
||||
g2.setComposite(composite);
|
||||
|
||||
g2.drawLine(-1, 0, -1, height);
|
||||
g2.drawLine(-2, 0, -2, height);
|
||||
g2.drawLine(-1, 0, -1, height);
|
||||
g2.drawLine(-2, 0, -2, height);
|
||||
|
||||
g2.drawLine(width, 0, width, height);
|
||||
g2.drawLine(width + 1, 0, width + 1, height);
|
||||
g2.drawLine(width, 0, width, height);
|
||||
g2.drawLine(width + 1, 0, width + 1, height);
|
||||
|
||||
RoundRectangle2D roundCasing = new RoundRectangle2D.Double(0, 2, width, height - 4, width, width);
|
||||
Area area = new Area(casing);
|
||||
area.subtract(new Area(roundCasing));
|
||||
g2.fill(area);
|
||||
RoundRectangle2D roundCasing = new RoundRectangle2D.Double(0, 2, width, height - 4, width, width);
|
||||
Area area = new Area(casing);
|
||||
area.subtract(new Area(roundCasing));
|
||||
g2.fill(area);
|
||||
|
||||
g2.translate(-trackBounds.x - 2, -trackBounds.y);
|
||||
} else {
|
||||
int width = trackBounds.width;
|
||||
int height = trackBounds.height - 4 + ANTI_WIDTH;
|
||||
g2.translate(-trackBounds.x - 2, -trackBounds.y);
|
||||
} else {
|
||||
int width = trackBounds.width;
|
||||
int height = trackBounds.height - 4 + ANTI_WIDTH;
|
||||
|
||||
g2.translate(trackBounds.x, trackBounds.y + 2);
|
||||
g2.translate(trackBounds.x, trackBounds.y + 2);
|
||||
|
||||
Rectangle2D casing = new Rectangle2D.Double(0, 0, width, height);
|
||||
g2.setColor(Color.BLACK);
|
||||
Rectangle2D casing = new Rectangle2D.Double(0, 0, width, height);
|
||||
g2.setColor(Color.BLACK);
|
||||
|
||||
float alpha = 0.5f;
|
||||
Composite composite = g2.getComposite();
|
||||
if (composite instanceof AlphaComposite) {
|
||||
alpha *= ((AlphaComposite) composite).getAlpha();
|
||||
}
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
|
||||
g2.fill(casing);
|
||||
g2.setComposite(composite);
|
||||
float alpha = 0.5f;
|
||||
Composite composite = g2.getComposite();
|
||||
if (composite instanceof AlphaComposite) {
|
||||
alpha *= ((AlphaComposite) composite).getAlpha();
|
||||
}
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
|
||||
g2.fill(casing);
|
||||
g2.setComposite(composite);
|
||||
|
||||
g2.drawLine(0, -1, width, -1);
|
||||
g2.drawLine(0, -2, width, -2);
|
||||
g2.drawLine(0, -1, width, -1);
|
||||
g2.drawLine(0, -2, width, -2);
|
||||
|
||||
g2.drawLine(0, height, width, height);
|
||||
g2.drawLine(0, height + 1, width, height + 1);
|
||||
g2.drawLine(0, height, width, height);
|
||||
g2.drawLine(0, height + 1, width, height + 1);
|
||||
|
||||
RoundRectangle2D roundCasing = new RoundRectangle2D.Double(2, 0, width - 4, height, height, height);
|
||||
Area area = new Area(casing);
|
||||
area.subtract(new Area(roundCasing));
|
||||
g2.fill(area);
|
||||
RoundRectangle2D roundCasing = new RoundRectangle2D.Double(2, 0, width - 4, height, height, height);
|
||||
Area area = new Area(casing);
|
||||
area.subtract(new Area(roundCasing));
|
||||
g2.fill(area);
|
||||
|
||||
g2.translate(-trackBounds.x, -trackBounds.y - 2);
|
||||
}
|
||||
g2.translate(-trackBounds.x, -trackBounds.y - 2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
@Override
|
||||
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
|
||||
g2.translate(thumbBounds.x + 1, thumbBounds.y + 2);
|
||||
if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
|
||||
g2.translate(thumbBounds.x + 1, thumbBounds.y + 2);
|
||||
|
||||
int width = thumbBounds.width - 3 + ANTI_WIDTH;
|
||||
int height = thumbBounds.height - 4;
|
||||
int width = thumbBounds.width - 3 + ANTI_WIDTH;
|
||||
int height = thumbBounds.height - 4;
|
||||
|
||||
RoundRectangle2D casing = new RoundRectangle2D.Double(0, 0, width, height, width, width);
|
||||
g2.setColor(Color.BLACK);
|
||||
Paint paint = g2.getPaint();
|
||||
g2.setPaint(new GradientPaint(0, 0, new Color(0x818a9b), 0, height, new Color(0x3a4252)));
|
||||
g2.fill(casing);
|
||||
g2.setPaint(paint);
|
||||
RoundRectangle2D casing = new RoundRectangle2D.Double(0, 0, width, height, width, width);
|
||||
g2.setColor(Color.BLACK);
|
||||
Paint paint = g2.getPaint();
|
||||
g2.setPaint(new GradientPaint(0, 0, new Color(0x818a9b), 0, height, new Color(0x3a4252)));
|
||||
g2.fill(casing);
|
||||
g2.setPaint(paint);
|
||||
|
||||
Stroke stroke = g2.getStroke();
|
||||
g2.setStroke(new BasicStroke(2.0f));
|
||||
g2.draw(casing);
|
||||
g2.setStroke(stroke);
|
||||
Stroke stroke = g2.getStroke();
|
||||
g2.setStroke(new BasicStroke(2.0f));
|
||||
g2.draw(casing);
|
||||
g2.setStroke(stroke);
|
||||
|
||||
g2.translate(-thumbBounds.x - 1, -thumbBounds.y - 2);
|
||||
} else {
|
||||
g2.translate(thumbBounds.x + 2, thumbBounds.y + 1);
|
||||
g2.translate(-thumbBounds.x - 1, -thumbBounds.y - 2);
|
||||
} else {
|
||||
g2.translate(thumbBounds.x + 2, thumbBounds.y + 1);
|
||||
|
||||
int width = thumbBounds.width - 4;
|
||||
int height = thumbBounds.height - 3 + ANTI_WIDTH;
|
||||
int width = thumbBounds.width - 4;
|
||||
int height = thumbBounds.height - 3 + ANTI_WIDTH;
|
||||
|
||||
RoundRectangle2D casing = new RoundRectangle2D.Double(0, 0, width, height, height, height);
|
||||
g2.setColor(Color.BLACK);
|
||||
RoundRectangle2D casing = new RoundRectangle2D.Double(0, 0, width, height, height, height);
|
||||
g2.setColor(Color.BLACK);
|
||||
|
||||
Paint paint = g2.getPaint();
|
||||
g2.setPaint(new GradientPaint(0, 0, new Color(0x818a9b), 0, height, new Color(0x3a4252)));
|
||||
g2.fill(casing);
|
||||
g2.setPaint(paint);
|
||||
Paint paint = g2.getPaint();
|
||||
g2.setPaint(new GradientPaint(0, 0, new Color(0x818a9b), 0, height, new Color(0x3a4252)));
|
||||
g2.fill(casing);
|
||||
g2.setPaint(paint);
|
||||
|
||||
Stroke stroke = g2.getStroke();
|
||||
g2.setStroke(new BasicStroke(2.0f));
|
||||
g2.draw(casing);
|
||||
g2.setStroke(stroke);
|
||||
Stroke stroke = g2.getStroke();
|
||||
g2.setStroke(new BasicStroke(2.0f));
|
||||
g2.draw(casing);
|
||||
g2.setStroke(stroke);
|
||||
|
||||
g2.translate(-thumbBounds.x - 2, -thumbBounds.y - 1);
|
||||
}
|
||||
}
|
||||
g2.translate(-thumbBounds.x - 2, -thumbBounds.y - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue