Skip to content

Commit 79dbef7

Browse files
committed
Minor code changes
1 parent 06bfa45 commit 79dbef7

File tree

7 files changed

+19
-17
lines changed

7 files changed

+19
-17
lines changed

core/src/main/java/org/pushingpixels/flamingo/api/svg/IndentingPrintWriter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
*/
2525
class IndentingPrintWriter extends PrintWriter {
2626

27-
private String indentation = " ";
27+
private static final String INDENTATION = " ";
2828

2929
public IndentingPrintWriter(PrintWriter out) {
3030
super(out);
3131
}
3232

3333
@Override
3434
public void println(String s) {
35-
super.println(indentation + s);
35+
super.println(INDENTATION + s);
3636
}
3737
}

core/src/main/java/org/pushingpixels/flamingo/api/svg/SvgBatchConverter.java

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.io.PrintWriter;
66

77
public class SvgBatchConverter {
8+
89
/**
910
* Main method for testing.
1011
*

core/src/main/java/org/pushingpixels/flamingo/api/svg/SvgTranscoder.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ public class SvgTranscoder {
115115

116116
/** The current paint, as a Java declaration. */
117117
private String currentPaint;
118-
118+
119119
/** The current stroke, as a Java declaration. */
120120
private String currentStroke;
121121

122122
/** The current shape. */
123123
private Shape currentShape;
124-
124+
125125
/**
126126
* Creates a new transcoder.
127127
*
@@ -241,7 +241,7 @@ public void transcode(BridgeContext context) throws IOException {
241241
bounds = new Rectangle2D.Double(0, 0, context.getDocumentSize().getWidth(), context.getDocumentSize().getHeight());
242242
}
243243

244-
Map<Template.Token, Object> params = new HashMap<Template.Token, Object>();
244+
Map<Template.Token, Object> params = new HashMap<>();
245245
params.put(Template.Token.PACKAGE, javaPackageName != null ? "package " + javaPackageName + ";" : "");
246246
params.put(Template.Token.CLASSNAME, javaClassName);
247247
params.put(Template.Token.X, (int) Math.ceil(bounds.getX()));
@@ -304,7 +304,7 @@ private void transcodeCompositeShapePainter(CompositeShapePainter painter) {
304304
* @param painter Fill shape painter.
305305
*/
306306
private void transcodeFillShapePainter(FillShapePainter painter) {
307-
Paint paint = (Paint) painter.getPaint();
307+
Paint paint = painter.getPaint();
308308
if (paint == null) {
309309
return;
310310
}
@@ -328,7 +328,7 @@ private void transcodePaintChange(Paint paint) {
328328
* @param painter Stroke shape painter.
329329
*/
330330
private void transcodeStrokeShapePainter(StrokeShapePainter painter) {
331-
Paint paint = (Paint) painter.getPaint();
331+
Paint paint = painter.getPaint();
332332
if (paint == null) {
333333
return;
334334
}

core/src/main/java/org/pushingpixels/flamingo/api/svg/Template.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
public class Template {
3434

35-
public static enum Token {
35+
public enum Token {
3636
PACKAGE, CLASSNAME, PAINTING_CODE, X, Y, WIDTH, HEIGHT
3737
}
3838

core/src/main/java/org/pushingpixels/flamingo/api/svg/TextSplitter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ static String insert(String content, String separator, int limit) {
5959
}
6060

6161
static List<Chunk> getChunks(String content) {
62-
List<Chunk> chunks = new LinkedList<Chunk>();
62+
List<Chunk> chunks = new LinkedList<>();
6363

6464
Chunk chunk = new Chunk();
6565
chunks.add(chunk);
6666

6767
try {
6868
LineNumberReader reader = new LineNumberReader(new StringReader(content));
69-
String line = null;
69+
String line;
7070
while ((line = reader.readLine()) != null) {
7171
if (line.trim().length() == 0) {
7272
chunk = new Chunk();

gui/src/main/java/org/pushingpixels/flamingo/api/svg/gui/BasicListCellRenderer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
*
2828
* @author Emmanuel Bourg
2929
*/
30-
abstract class BasicListCellRenderer implements ListCellRenderer {
30+
abstract class BasicListCellRenderer<E> implements ListCellRenderer<E> {
3131
private ListCellRenderer delegate;
3232
private Class uiClass;
3333

3434
@Override
35-
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
35+
public Component getListCellRendererComponent(JList<? extends E> list, E value, int index, boolean isSelected, boolean cellHasFocus) {
3636
if (list.getUI().getClass() != uiClass) {
3737
uiClass = list.getUI().getClass();
3838
if ("ComboBox.list".equals(list.getName())) {

gui/src/main/java/org/pushingpixels/flamingo/api/svg/gui/SVGApplication.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import javax.swing.SwingUtilities;
4949
import javax.swing.SwingWorker;
5050
import javax.swing.UIManager;
51+
import javax.swing.WindowConstants;
5152
import javax.swing.filechooser.FileNameExtensionFilter;
5253

5354
import net.miginfocom.swing.MigLayout;
@@ -76,7 +77,7 @@ public static void main(String[] args) throws Exception {
7677
JFrame frame = new JFrame(APPNAME);
7778
SVGApplication app = new SVGApplication(frame);
7879
frame.getContentPane().add(app.createComponents());
79-
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
80+
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
8081
frame.setSize(640, 480);
8182
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
8283
frame.setLocation((int) (screen.getWidth() - frame.getWidth()) / 2, (int) (screen.getHeight() - frame.getHeight()) / 2);
@@ -100,8 +101,8 @@ private static List<Image> getApplicationIcons() {
100101
private JLabel label = new JLabel();
101102
private JSVGCanvas svgCanvas = new JSVGCanvas();
102103
private String lastDir;
103-
private JComboBox<Template> comboTemplates = new JComboBox<Template>();
104-
private JComboBox<NamingStrategy> comboNaming = new JComboBox<NamingStrategy>();
104+
private JComboBox<Template> comboTemplates = new JComboBox<>();
105+
private JComboBox<NamingStrategy> comboNaming = new JComboBox<>();
105106

106107
public SVGApplication(JFrame frame) {
107108
this.frame = frame;
@@ -124,13 +125,13 @@ public JComponent createToolbar() {
124125
new Template("plain.template"),
125126
new Template("resizable.template")
126127
};
127-
comboTemplates.setModel(new DefaultComboBoxModel<Template>(templates));
128+
comboTemplates.setModel(new DefaultComboBoxModel<>(templates));
128129
} catch (IOException e) {
129130
e.printStackTrace();
130131
}
131132
comboTemplates.setRenderer(new TemplateListCellRenderer());
132133

133-
comboNaming.setModel(new DefaultComboBoxModel<NamingStrategy>(new NamingStrategy[] {
134+
comboNaming.setModel(new DefaultComboBoxModel<>(new NamingStrategy[] {
134135
new CamelCaseNamingStrategy(),
135136
new IconSuffixNamingStrategy(new CamelCaseNamingStrategy()),
136137
new DefaultNamingStrategy()

0 commit comments

Comments
 (0)