more string builders 1

This commit is contained in:
2015-05-20 15:01:58 +02:00
parent 0670f0e36f
commit 18592b7a72
21 changed files with 357 additions and 294 deletions
@@ -157,20 +157,20 @@ public class ExportDialog extends AppDialog {
}
private void saveConfig() {
String cfg = "";
StringBuilder cfg = new StringBuilder();
for (int i = 0; i < optionNames.length; i++) {
int selIndex = combos[i].getSelectedIndex();
Class c = optionClasses[i];
Object vals[] = c.getEnumConstants();
String key = optionNames[i] + "." + vals[selIndex].toString().toLowerCase();
if (i > 0) {
cfg += ",";
cfg.append(",");
}
cfg += key;
cfg.append(key);
}
Configuration.lastSelectedExportZoom.set(Double.parseDouble(zoomTextField.getText()) / 100);
Configuration.lastSelectedExportFormats.set(cfg);
Configuration.lastSelectedExportFormats.set(cfg.toString());
}
public ExportDialog(List<TreeItem> exportables) {
@@ -28,8 +28,6 @@ import java.awt.FontFormatException;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
@@ -49,6 +47,8 @@ import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.filechooser.FileFilter;
/**
@@ -278,17 +278,24 @@ public class FontEmbedDialog extends AppDialog {
updateCheckboxes();
}
});
faceSelection.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
updateCheckboxes();
}
faceSelection.addItemListener((ItemEvent e) -> {
updateCheckboxes();
});
updateCheckboxes();
individualCharsField.addKeyListener(new KeyAdapter() {
individualCharsField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void keyTyped(KeyEvent e) {
public void insertUpdate(DocumentEvent e) {
updateIndividual();
}
@Override
public void removeUpdate(DocumentEvent e) {
updateIndividual();
}
@Override
public void changedUpdate(DocumentEvent e) {
updateIndividual();
}
});
@@ -297,13 +304,13 @@ public class FontEmbedDialog extends AppDialog {
private void updateIndividual() {
String chars = individualCharsField.getText();
Font f = getSelectedFont();
String visibleChars = "";
StringBuilder visibleChars = new StringBuilder();
for (int i = 0; i < chars.length(); i++) {
if (f.canDisplay(chars.codePointAt(i))) {
visibleChars += "" + chars.charAt(i);
visibleChars.append(chars.charAt(i));
}
}
individialSample.setText(visibleChars);
individialSample.setText(visibleChars.toString());
}
private void updateCheckboxes() {
@@ -220,8 +220,8 @@ public class FontPanel extends JPanel {
selectedFont = swf.sourceFontNamesMap.get(ft.getFontId());
} else if (Configuration.getFontToNameMap().containsKey(key)) {
selectedFont = Configuration.getFontToNameMap().get(key);
} else if (Configuration.getFontToNameMap().containsKey(ft.getFontName())) {
selectedFont = Configuration.getFontToNameMap().get(ft.getFontName());
} else if (Configuration.getFontToNameMap().containsKey(ft.getFontNameIntag())) {
selectedFont = Configuration.getFontToNameMap().get(ft.getFontNameIntag());
} else {
selectedFont = FontTag.findInstalledFontName(ft.getFontName());
}
@@ -280,7 +280,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
Point p = lastMouseEvent == null ? null : lastMouseEvent.getPoint();
List<DepthState> objs = new ArrayList<>();
String ret = "";
StringBuilder ret = new StringBuilder();
synchronized (ImagePanel.class) {
if (timer == thisTimer) {
@@ -290,7 +290,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
int y = p.y;
objs = iconPanel.getObjectsUnderPoint(p);
ret += " [" + x + "," + y + "] : ";
ret.append(" [").append(x).append(",").append(y).append("] : ");
}
}
}
@@ -299,7 +299,7 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
for (int i = 0; i < objs.size(); i++) {
DepthState ds = objs.get(i);
if (!first) {
ret += ", ";
ret.append(", ");
}
first = false;
CharacterTag c = tim.swf.getCharacter(ds.characterId);
@@ -307,18 +307,18 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
newStateUnderCursor = ds;
handCursor = true;
}
ret += c.toString();
ret.append(c.toString());
if (timelined instanceof ButtonTag) {
handCursor = true;
}
}
if (first) {
ret += " - ";
ret.append(" - ");
}
synchronized (ImagePanel.class) {
if (timer == thisTimer) {
debugLabel.setText(ret);
debugLabel.setText(ret.toString());
if (handCursor) {
iconPanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
@@ -54,7 +54,6 @@ public class NewVersionDialog extends AppDialog {
JEditorPane changesText = new JEditorPane();
changesText.setEditable(false);
changesText.setFont(UIManager.getFont("TextField.font"));
String changesStr = "";
SimpleDateFormat serverFormatter = new SimpleDateFormat("MM/dd/yyyy");
DateFormat formatter;
String customFormat = translate("customDateFormat");
@@ -63,13 +62,17 @@ public class NewVersionDialog extends AppDialog {
} else {
formatter = new SimpleDateFormat(customFormat);
}
StringBuilder changesStr = new StringBuilder();
changesStr.append("<html>");
boolean first = true;
for (Version v : versions) {
if (!first) {
changesStr += "<hr />";
changesStr.append("<hr />");
}
first = false;
changesStr += "<b>" + translate("version") + " " + v.versionName + "</b><br />";
changesStr.append("<b>").append(translate("version")).append(" ").append(v.versionName).append("</b><br />");
String releaseDate = v.releaseDate;
try {
Date date = serverFormatter.parse(releaseDate);
@@ -77,25 +80,27 @@ public class NewVersionDialog extends AppDialog {
} catch (ParseException ex) {
Logger.getLogger(NewVersionDialog.class.getName()).log(Level.SEVERE, null, ex);
}
changesStr += translate("releasedate") + " " + releaseDate;
changesStr.append(translate("releasedate")).append(" ").append(releaseDate);
if (!v.changes.isEmpty()) {
changesStr += "<br />";
changesStr += "<pre>";
changesStr.append("<br />");
changesStr.append("<pre>");
for (String type : v.changes.keySet()) {
changesStr += type + ":" + "<br />";
changesStr.append(type).append(":" + "<br />");
for (String ch : v.changes.get(type)) {
changesStr += " - " + ch + "<br />";
changesStr.append(" - ").append(ch).append("<br />");
}
}
changesStr += "</pre>";
changesStr.append("</pre>");
}
}
changesStr.append("</html>");
latestVersion = null;
if (!versions.isEmpty()) {
latestVersion = versions.get(0);
}
changesText.setContentType("text/html");
changesText.setText("<html>" + changesStr + "</html>");
changesText.setText(changesStr.toString());
if (latestVersion != null) {
JLabel newAvailableLabel = new JLabel("<html><b><center>" + translate("newversionavailable") + " " + latestVersion.appName + " " + translate("version") + " " + latestVersion.versionName + "</center></b></html>", SwingConstants.CENTER);
newAvailableLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
@@ -124,11 +124,12 @@ public class DumpViewPanel extends JPanel {
if (address != -1) {
int b2 = b & 0xff;
selectedByteInfo.setText("Addr: " + Helper.padZeros(address, 8)
+ " Hex: " + Helper.padZeros(Integer.toHexString(b2), 2)
selectedByteInfo.setText("Addr: " + String.format("%08X", address)
+ " Hex: " + String.format("%02X", b)
+ " Dec: " + b2
+ " Bin: " + Helper.padZeros(Integer.toBinaryString(b2), 8)
+ " Ascii: " + (char) b2);
+ " Ascii: " + (char) b2
);
} else {
selectedByteInfo.setText("-");
}