Mostly code format fixes.

This commit is contained in:
vraskulin 2017-02-09 18:30:31 +03:00
parent 7cf4ca3cae
commit f99cd21275
37 changed files with 226 additions and 189 deletions

View file

@ -574,12 +574,12 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
int cx = getCardX() - component.x;
int cy = getCardY() - component.y;
int cw = getCardWidth();
int ch = getCardHeight();
int cw = cardWidth;
int ch = cardHeight;
if (isTapped()) {
cy = ch - cw + cx;
ch = cw;
cw = getCardHeight();
cw = cardHeight;
}
return x >= cx && x <= cx + cw && y >= cy && y <= cy + ch;

View file

@ -290,7 +290,7 @@ public abstract class CardRenderer {
g2.setColor(Color.black);
g2.drawPolygon(p);
g2.setFont(new Font("Arial", Font.BOLD, 7));
String cstr = "" + v.getCount();
String cstr = String.valueOf(v.getCount());
int strW = g2.getFontMetrics().stringWidth(cstr);
g2.drawString(cstr, 5 - strW / 2, 8);
g2.dispose();

View file

@ -707,7 +707,7 @@ public class ModernCardRenderer extends CardRenderer {
if ((cardView instanceof PermanentView) && ((PermanentView) cardView).getDamage() > 0) {
int x = cardWidth - partWidth - borderWidth;
int y = curY - boxHeight;
String damage = "" + ((PermanentView) cardView).getDamage();
String damage = String.valueOf(((PermanentView) cardView).getDamage());
g.setFont(ptTextFont);
int txWidth = g.getFontMetrics().stringWidth(damage);
g.setColor(Color.red);
@ -986,7 +986,7 @@ public class ModernCardRenderer extends CardRenderer {
g.setColor(Color.black);
g.fillOval(borderWidth + 1, totalContentInset + 1, boxHeight - 2, boxHeight - 2);
g.setColor(Color.white);
if (isNightCard()) {
if (isTransformed) {
g.fillArc(borderWidth + 3, totalContentInset + 3, boxHeight - 6, boxHeight - 6, 90, 270);
g.setColor(Color.black);
g.fillArc(borderWidth + 3 + 3, totalContentInset + 3, boxHeight - 6 - 3, boxHeight - 6, 90, 270);
@ -1012,7 +1012,7 @@ public class ModernCardRenderer extends CardRenderer {
// Determine the color of the name / type line text
protected Color getBoxTextColor() {
if (isNightCard()) {
if (isTransformed) {
return Color.white;
} else if (cardView.isAbility()) {
return Color.white;

View file

@ -22,7 +22,7 @@ public class TextboxLoyaltyRule extends TextboxRule {
} else if (loyaltyChange > 0) {
return "+" + loyaltyChange;
} else {
return "" + loyaltyChange;
return String.valueOf(loyaltyChange);
}
}

View file

@ -186,10 +186,10 @@ public class TextboxRuleParser {
if (levelMatch.find()) {
try {
levelFrom = Integer.parseInt(levelMatch.group(1));
if (!levelMatch.group(2).equals("")) {
if (!levelMatch.group(2).isEmpty()) {
levelTo = Integer.parseInt(levelMatch.group(2));
}
if (!levelMatch.group(3).equals("")) {
if (!levelMatch.group(3).isEmpty()) {
levelTo = TextboxLevelRule.AND_HIGHER;
}
isLeveler = true;

View file

@ -53,7 +53,9 @@ public class DownloadGui extends JPanel {
p.setBorder(BorderFactory.createTitledBorder("Progress:"));
p.add(progress);
JButton b = new JButton("X");
b.addActionListener(e -> getDownloader().dispose());
b.addActionListener(e -> {
d.dispose();
});
p.add(b, BorderLayout.EAST);
add(p, BorderLayout.NORTH);
@ -154,10 +156,10 @@ public class DownloadGui extends JPanel {
add(bar = new JProgressBar(job.getProgress()));
JButton b = new JButton("X");
b.addActionListener(e -> {
switch(getJob().getState()) {
switch(this.job.getState()) {
case NEW:
case WORKING:
getJob().setState(State.ABORTED);
this.job.setState(State.ABORTED);
}
});
add(b, BorderLayout.EAST);

View file

@ -90,7 +90,7 @@ public class DownloadJob extends AbstractLaternaBean {
public void setError(String message, Exception error) {
if (message == null) {
message = "Download of " + this.getName() + "from " + this.getSource().toString() + " caused error: " + error.toString();
message = "Download of " + name + "from " + source.toString() + " caused error: " + error.toString();
}
// log.warn(message, error);
log.warn(message);
@ -167,7 +167,7 @@ public class DownloadJob extends AbstractLaternaBean {
@Override
public String toString() {
return proxy != null ? proxy.type().toString() + ' ' : "" + url;
return proxy != null ? proxy.type().toString() + ' ' : url;
}
};
@ -196,7 +196,7 @@ public class DownloadJob extends AbstractLaternaBean {
@Override
public String toString() {
return proxy != null ? proxy.type().toString() + ' ' : "" + url;
return proxy != null ? proxy.type().toString() + ' ' : String.valueOf(url);
}
};
}

View file

@ -57,7 +57,7 @@ public class Downloader extends AbstractLaternaBean implements Disposable {
@Override
public void dispose() {
for (DownloadJob j : getJobs()) {
for (DownloadJob j : jobs) {
switch (j.getState()) {
case NEW:
case WORKING:

View file

@ -59,7 +59,7 @@ public class GathererSymbols implements Iterable<DownloadJob> {
if (symIndex < symbols.length) {
sym = symbols[symIndex++];
} else if (numeric <= maxNumeric) {
sym = "" + (numeric++);
sym = String.valueOf(numeric++);
} else {
sizeIndex++;
if (sizeIndex == sizes.length) {

View file

@ -71,7 +71,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
JDialog dlg = download.getDlg(frame);
dlg.setVisible(true);
dlg.dispose();
download.setCancel(true);
download.cancel = true;
}
public JDialog getDlg(JFrame frame) {

View file

@ -124,7 +124,7 @@ public class ThemePluginImpl implements ThemePlugin {
private BufferedImage loadbuffer_selected() throws IOException {
BufferedImage res;
String path = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE, "");
if (path != null && !path.equals("")) {
if (path != null && !path.isEmpty()) {
try {
res = ImageIO.read(new File(path));
return res;
@ -162,7 +162,7 @@ public class ThemePluginImpl implements ThemePlugin {
background = ImageIO.read(is);
} else {
String path = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BACKGROUND_IMAGE, "");
if (path != null && !path.equals("")) {
if (path != null && !path.isEmpty()) {
try {
File f = new File(path);
if (f != null) {