diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/constants/CSSName.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/constants/CSSName.java index b5d3597e6..5423f51bf 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/constants/CSSName.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/constants/CSSName.java @@ -59,22 +59,22 @@ public final class CSSName implements Comparable { /** * marker var, used for initialization */ - private static final Integer PRIMITIVE = new Integer(0); + private static final Integer PRIMITIVE = 0; /** * marker var, used for initialization */ - private static final Integer SHORTHAND = new Integer(1); + private static final Integer SHORTHAND = 1; /** * marker var, used for initialization */ - private static final Integer INHERITS = new Integer(2); + private static final Integer INHERITS = 2; /** * marker var, used for initialization */ - private static final Integer NOT_INHERITED = new Integer(3); + private static final Integer NOT_INHERITED = 3; /** * Used to assing unique int id values to new CSSNames created in this class diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/constants/ValueConstants.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/constants/ValueConstants.java index 8c9f39eb0..a5906ea14 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/constants/ValueConstants.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/constants/ValueConstants.java @@ -108,7 +108,7 @@ public static short sacPrimitiveTypeForString(String type) { * @return Returns */ public static String stringForSACPrimitiveType(short type) { - return (String) sacTypesStrings.get(new Short(type)); + return (String) sacTypesStrings.get(type); } /** @@ -122,7 +122,7 @@ public static String stringForSACPrimitiveType(short type) { */ //TODO: method may be unnecessary (tobe) public static boolean isAbsoluteUnit(CSSPrimitiveValue primitive) { - short type = ((CSSPrimitiveValue) primitive).getPrimitiveType(); + short type = primitive.getPrimitiveType(); return isAbsoluteUnit(type); } @@ -289,15 +289,15 @@ public static boolean isNumber(short cssPrimitiveType) { // HACK: this is a quick way to perform the lookup, but dumb if the short assigned are > 100; but the compiler will tell us that (PWW 21-01-05) sacTypesStrings = new HashMap(25); - sacTypesStrings.put(new Short(CSSPrimitiveValue.CSS_EMS), "em"); - sacTypesStrings.put(new Short(CSSPrimitiveValue.CSS_EXS), "ex"); - sacTypesStrings.put(new Short(CSSPrimitiveValue.CSS_PX), "px"); - sacTypesStrings.put(new Short(CSSPrimitiveValue.CSS_PERCENTAGE), "%"); - sacTypesStrings.put(new Short(CSSPrimitiveValue.CSS_IN), "in"); - sacTypesStrings.put(new Short(CSSPrimitiveValue.CSS_CM), "cm"); - sacTypesStrings.put(new Short(CSSPrimitiveValue.CSS_MM), "mm"); - sacTypesStrings.put(new Short(CSSPrimitiveValue.CSS_PT), "pt"); - sacTypesStrings.put(new Short(CSSPrimitiveValue.CSS_PC), "pc"); + sacTypesStrings.put(CSSPrimitiveValue.CSS_EMS, "em"); + sacTypesStrings.put(CSSPrimitiveValue.CSS_EXS, "ex"); + sacTypesStrings.put(CSSPrimitiveValue.CSS_PX, "px"); + sacTypesStrings.put(CSSPrimitiveValue.CSS_PERCENTAGE, "%"); + sacTypesStrings.put(CSSPrimitiveValue.CSS_IN, "in"); + sacTypesStrings.put(CSSPrimitiveValue.CSS_CM, "cm"); + sacTypesStrings.put(CSSPrimitiveValue.CSS_MM, "mm"); + sacTypesStrings.put(CSSPrimitiveValue.CSS_PT, "pt"); + sacTypesStrings.put(CSSPrimitiveValue.CSS_PC, "pc"); } /** diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/parser/property/Conversions.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/parser/property/Conversions.java index 83a8fd491..c773949ef 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/parser/property/Conversions.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/css/parser/property/Conversions.java @@ -176,15 +176,15 @@ public class Conversions { } static { - NUMERIC_FONT_WEIGHTS.put(new Float(100f), IdentValue.FONT_WEIGHT_100); - NUMERIC_FONT_WEIGHTS.put(new Float(200f), IdentValue.FONT_WEIGHT_200); - NUMERIC_FONT_WEIGHTS.put(new Float(300f), IdentValue.FONT_WEIGHT_300); - NUMERIC_FONT_WEIGHTS.put(new Float(400f), IdentValue.FONT_WEIGHT_400); - NUMERIC_FONT_WEIGHTS.put(new Float(500f), IdentValue.FONT_WEIGHT_500); - NUMERIC_FONT_WEIGHTS.put(new Float(600f), IdentValue.FONT_WEIGHT_600); - NUMERIC_FONT_WEIGHTS.put(new Float(700f), IdentValue.FONT_WEIGHT_700); - NUMERIC_FONT_WEIGHTS.put(new Float(800f), IdentValue.FONT_WEIGHT_800); - NUMERIC_FONT_WEIGHTS.put(new Float(900f), IdentValue.FONT_WEIGHT_900); + NUMERIC_FONT_WEIGHTS.put(100f, IdentValue.FONT_WEIGHT_100); + NUMERIC_FONT_WEIGHTS.put(200f, IdentValue.FONT_WEIGHT_200); + NUMERIC_FONT_WEIGHTS.put(300f, IdentValue.FONT_WEIGHT_300); + NUMERIC_FONT_WEIGHTS.put(400f, IdentValue.FONT_WEIGHT_400); + NUMERIC_FONT_WEIGHTS.put(500f, IdentValue.FONT_WEIGHT_500); + NUMERIC_FONT_WEIGHTS.put(600f, IdentValue.FONT_WEIGHT_600); + NUMERIC_FONT_WEIGHTS.put(700f, IdentValue.FONT_WEIGHT_700); + NUMERIC_FONT_WEIGHTS.put(800f, IdentValue.FONT_WEIGHT_800); + NUMERIC_FONT_WEIGHTS.put(900f, IdentValue.FONT_WEIGHT_900); } static { @@ -198,7 +198,7 @@ public static FSRGBColor getColor(String ident) { } public static IdentValue getNumericFontWeight(float weight) { - return (IdentValue)NUMERIC_FONT_WEIGHTS.get(new Float(weight)); + return (IdentValue)NUMERIC_FONT_WEIGHTS.get(weight); } public static PropertyValue getBorderWidth(String ident) { diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/layout/BoxBuilder.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/layout/BoxBuilder.java index 534cd8e56..8db977d0a 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/layout/BoxBuilder.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/layout/BoxBuilder.java @@ -1103,7 +1103,7 @@ private static void createChildren( Node startAttribute = working.getAttributes().getNamedItem("start"); if (startAttribute != null) { try { - start = new Integer(Integer.parseInt(startAttribute.getNodeValue()) - 1); + start = Integer.parseInt(startAttribute.getNodeValue()) - 1; } catch (NumberFormatException e) { // ignore } @@ -1112,7 +1112,7 @@ private static void createChildren( Node valueAttribute = working.getAttributes().getNamedItem("value"); if (valueAttribute != null) { try { - start = new Integer(Integer.parseInt(valueAttribute.getNodeValue()) - 1); + start = Integer.parseInt(valueAttribute.getNodeValue()) - 1; } catch (NumberFormatException e) { // ignore } diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/layout/LayoutContext.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/layout/LayoutContext.java index 86c36ff6a..55e4e0d40 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/layout/LayoutContext.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/layout/LayoutContext.java @@ -54,7 +54,7 @@ * {@link SharedContext}. */ public class LayoutContext implements CssContext { - private SharedContext _sharedContext; + private final SharedContext _sharedContext; private Layer _rootLayer; @@ -67,12 +67,12 @@ public class LayoutContext implements CssContext { private FontContext _fontContext; - private ContentFunctionFactory _contentFunctionFactory = new ContentFunctionFactory(); + private final ContentFunctionFactory _contentFunctionFactory = new ContentFunctionFactory(); private int _extraSpaceTop; private int _extraSpaceBottom; - private Map _counterContextMap = new HashMap(); + private final Map _counterContextMap = new HashMap(); private String _pendingPageName; private String _pageName; @@ -419,7 +419,7 @@ private boolean incrementCounter(CounterData cd) { if (_parent == null) return false; return _parent.incrementCounter(cd); } else { - _counters.put(cd.getName(), new Integer(currentValue.intValue() + cd.getValue())); + _counters.put(cd.getName(), currentValue + cd.getValue()); return true; } } @@ -428,13 +428,13 @@ private boolean incrementCounter(CounterData cd) { private void incrementListItemCounter(int increment) { Integer currentValue = (Integer) _counters.get("list-item"); if (currentValue == null) { - currentValue = new Integer(0); + currentValue = 0; } - _counters.put("list-item", new Integer(currentValue.intValue() + increment)); + _counters.put("list-item", currentValue + increment); } private void resetCounter(CounterData cd) { - _counters.put(cd.getName(), new Integer(cd.getValue())); + _counters.put(cd.getName(), cd.getValue()); } public int getCurrentCounterValue(String name) { @@ -445,7 +445,7 @@ public int getCurrentCounterValue(String name) { _parent.resetCounter(new CounterData(name, 0)); return 0; } else { - return value.intValue(); + return value; } } @@ -463,7 +463,7 @@ public List getCurrentCounterValues(String name) { _parent.getCounterValues(name, values); if (values.size() == 0) { _parent.resetCounter(new CounterData(name, 0)); - values.add(new Integer(0)); + values.add(0); } return values; } diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/AbstractButtonField.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/AbstractButtonField.java index b60986270..6ae43e924 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/AbstractButtonField.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/AbstractButtonField.java @@ -72,10 +72,10 @@ protected void applyComponentStyle(JButton button) { FSDerivedValue widthValue = style.valueByName(CSSName.WIDTH); if (widthValue instanceof LengthValue) - intrinsicWidth = new Integer(getBox().getContentWidth()); + intrinsicWidth = getBox().getContentWidth(); FSDerivedValue heightValue = style.valueByName(CSSName.HEIGHT); if (heightValue instanceof LengthValue) - intrinsicHeight = new Integer(getBox().getHeight()); + intrinsicHeight = getBox().getHeight(); } } diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/FormField.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/FormField.java index 218034d2e..f02d1d0fa 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/FormField.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/FormField.java @@ -39,12 +39,12 @@ import java.awt.*; public abstract class FormField { - private XhtmlForm _parentForm; - private Element _element; + private final XhtmlForm _parentForm; + private final Element _element; private FormFieldState _originalState; private JComponent _component; - private LayoutContext context; - private BlockBox box; + private final LayoutContext context; + private final BlockBox box; protected Integer intrinsicWidth; protected Integer intrinsicHeight; @@ -108,9 +108,9 @@ private void initialize() { if (_component != null) { if (intrinsicWidth == null) - intrinsicWidth = new Integer(_component.getPreferredSize().width); + intrinsicWidth = _component.getPreferredSize().width; if (intrinsicHeight == null) - intrinsicHeight = new Integer(_component.getPreferredSize().height); + intrinsicHeight = _component.getPreferredSize().height; _component.setSize(getIntrinsicSize()); @@ -219,7 +219,7 @@ public Font getFont() { protected static Integer getLengthValue(CalculatedStyle style, CSSName cssName) { FSDerivedValue widthValue = style.valueByName(cssName); if (widthValue instanceof LengthValue) { - return new Integer((int)widthValue.asFloat()); + return (int) widthValue.asFloat(); } return null; diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/ImageField.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/ImageField.java index 04da7afed..bb070f4f1 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/ImageField.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/ImageField.java @@ -20,13 +20,8 @@ package org.xhtmlrenderer.simple.extend.form; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.BorderFactory; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JComponent; +import javax.swing.*; import javax.swing.plaf.basic.BasicButtonUI; import org.w3c.dom.Element; @@ -83,20 +78,17 @@ public Dimension getPreferredSize() { FSDerivedValue widthValue = style.valueByName(CSSName.WIDTH); if (widthValue instanceof LengthValue) { - intrinsicWidth = new Integer(getBox().getContentWidth()); + intrinsicWidth = getBox().getContentWidth(); } FSDerivedValue heightValue = style.valueByName(CSSName.HEIGHT); if (heightValue instanceof LengthValue) { - intrinsicHeight = new Integer(getBox().getHeight()); + intrinsicHeight = getBox().getHeight(); } - button.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - XRLog.layout("Image pressed: Submit"); - - getParentForm().submit(getComponent()); - } + button.addActionListener(event -> { + XRLog.layout("Image pressed: Submit"); + getParentForm().submit(getComponent()); }); return button; diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/SelectField.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/SelectField.java index f93b396c3..03e27b8a9 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/SelectField.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/SelectField.java @@ -100,7 +100,7 @@ protected FormFieldState loadOriginalState() { Element option = (Element) options.item(i); if (option.hasAttribute("selected") && option.getAttribute("selected").equalsIgnoreCase("selected")) { - list.add(new Integer(i)); + list.add(i); } } diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/TextAreaField.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/TextAreaField.java index c21f41c3c..9cf78c28a 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/TextAreaField.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/TextAreaField.java @@ -19,10 +19,9 @@ */ package org.xhtmlrenderer.simple.extend.form; -import javax.swing.JComponent; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import javax.swing.ScrollPaneConstants; +import java.awt.*; + +import javax.swing.*; import javax.swing.plaf.basic.BasicTextAreaUI; import javax.swing.plaf.basic.BasicTextUI; @@ -38,8 +37,6 @@ import org.xhtmlrenderer.simple.extend.XhtmlForm; import org.xhtmlrenderer.util.GeneralUtil; -import java.awt.*; - class TextAreaField extends FormField { private TextAreaFieldJTextArea _textarea; @@ -95,10 +92,10 @@ protected void applyComponentStyle(TextAreaFieldJTextArea textArea, JScrollPane Integer paddingBottom = getLengthValue(style, CSSName.PADDING_BOTTOM); Integer paddingRight = getLengthValue(style, CSSName.PADDING_RIGHT); - int top = paddingTop == null ? 2 : Math.max(2, paddingTop.intValue()); - int left = paddingLeft == null ? 3 : Math.max(3, paddingLeft.intValue()); - int bottom = paddingBottom == null ? 2 : Math.max(2, paddingBottom.intValue()); - int right = paddingRight == null ? 3 : Math.max(3, paddingRight.intValue()); + int top = paddingTop == null ? 2 : Math.max(2, paddingTop); + int left = paddingLeft == null ? 3 : Math.max(3, paddingLeft); + int bottom = paddingBottom == null ? 2 : Math.max(2, paddingBottom); + int right = paddingRight == null ? 3 : Math.max(3, paddingRight); //if a border is set or a background color is set, then use a special JButton with the BasicButtonUI. if (disableOSBorder) { @@ -117,12 +114,12 @@ protected void applyComponentStyle(TextAreaFieldJTextArea textArea, JScrollPane FSDerivedValue widthValue = style.valueByName(CSSName.WIDTH); if (widthValue instanceof LengthValue) { - intrinsicWidth = new Integer(getBox().getContentWidth() + left + right); + intrinsicWidth = getBox().getContentWidth() + left + right; } FSDerivedValue heightValue = style.valueByName(CSSName.HEIGHT); if (heightValue instanceof LengthValue) { - intrinsicHeight = new Integer(getBox().getHeight() + top + bottom); + intrinsicHeight = getBox().getHeight() + top + bottom; } } @@ -145,7 +142,7 @@ protected String[] getFieldValues() { } - private class TextAreaFieldJTextArea extends JTextArea { + private static class TextAreaFieldJTextArea extends JTextArea { int columnWidth = 0; public TextAreaFieldJTextArea(int rows, int columns) { diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/TextField.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/TextField.java index 811a89a44..a84f15e56 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/TextField.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/simple/extend/form/TextField.java @@ -92,10 +92,10 @@ protected void applyComponentStyle(JComponent component) { Integer paddingRight = getLengthValue(style, CSSName.PADDING_RIGHT); - int top = paddingTop == null ? 2 : Math.max(2, paddingTop.intValue()); - int left = paddingLeft == null ? 3 : Math.max(3, paddingLeft.intValue()); - int bottom = paddingBottom == null ? 2 : Math.max(2, paddingBottom.intValue()); - int right = paddingRight == null ? 3 : Math.max(3, paddingRight.intValue()); + int top = paddingTop == null ? 2 : Math.max(2, paddingTop); + int left = paddingLeft == null ? 3 : Math.max(3, paddingLeft); + int bottom = paddingBottom == null ? 2 : Math.max(2, paddingBottom); + int right = paddingRight == null ? 3 : Math.max(3, paddingRight); //if a border is set or a background color is set, then use a special JButton with the BasicButtonUI. if (disableOSBorder) { @@ -116,12 +116,12 @@ protected void applyComponentStyle(JComponent component) { FSDerivedValue widthValue = style.valueByName(CSSName.WIDTH); if (widthValue instanceof LengthValue) { - intrinsicWidth = new Integer(getBox().getContentWidth() + left + right); + intrinsicWidth = getBox().getContentWidth() + left + right; } FSDerivedValue heightValue = style.valueByName(CSSName.HEIGHT); if (heightValue instanceof LengthValue) { - intrinsicHeight = new Integer(getBox().getHeight() + top + bottom); + intrinsicHeight = getBox().getHeight() + top + bottom; } } diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/swing/DOMInspector.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/swing/DOMInspector.java index daf2ebe34..0adbd3783 100755 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/swing/DOMInspector.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/swing/DOMInspector.java @@ -431,7 +431,7 @@ public Object getValueAt(int row, int col) { break; case 2: if (ValueConstants.isNumber(cpv.getPrimitiveType())) { - val = new Float(cpv.getFloatValue(cpv.getPrimitiveType())); + val = cpv.getFloatValue(cpv.getPrimitiveType()); } else { val = "";//actual.cssValue().getCssText(); } @@ -471,13 +471,9 @@ class DOMSelectionListener implements TreeSelectionListener { /** * Description of the Field */ - private JTree _tree; - /** Description of the Field */ + private final JTree _tree; //private StyleReference _sr; - /** - * Description of the Field - */ - private ElementPropertiesPanel _elemPropPanel; + private final ElementPropertiesPanel _elemPropPanel; /** * Constructor for the DOMSelectionListener object @@ -525,17 +521,17 @@ class DOMTreeModel implements TreeModel { /** * Our root for display */ - Node root; + private Node root; /** * Description of the Field */ - HashMap displayableNodes; + private final HashMap displayableNodes; /** * Description of the Field */ - List listeners = new ArrayList(); + private final List listeners = new ArrayList(); /** * Constructor for the DOMTreeModel object @@ -569,9 +565,7 @@ private void setRoot(String rootNodeName) { * @param l Contains the TreeModelListener for TreeModelEvent data. */ public void addTreeModelListener(TreeModelListener l) { - this.listeners.add(l); - } @@ -625,7 +619,7 @@ public Object getChild(Object parent, int index) { children = addDisplayable(node); } - return (Node) children.get(index); + return children.get(index); } diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/swing/HTMLTest.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/swing/HTMLTest.java index d634b83ee..5c03b6914 100755 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/swing/HTMLTest.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/swing/HTMLTest.java @@ -19,18 +19,18 @@ */ package org.xhtmlrenderer.swing; -import org.xhtmlrenderer.extend.TextRenderer; -import org.xhtmlrenderer.simple.XHTMLPanel; -import org.xhtmlrenderer.util.Uu; -import org.xhtmlrenderer.util.XRLog; - -import javax.swing.*; -import java.awt.Dimension; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.io.File; import java.net.URL; +import javax.swing.*; + +import org.xhtmlrenderer.simple.XHTMLPanel; +import org.xhtmlrenderer.util.Uu; +import org.xhtmlrenderer.util.XRLog; + /** * Description of the Class @@ -201,7 +201,7 @@ static class QuitAction extends AbstractAction { */ QuitAction() { super("Quit"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_Q)); + putValue(MNEMONIC_KEY, KeyEvent.VK_Q); } /** @@ -227,7 +227,7 @@ class BoxOutlinesAction extends AbstractAction { */ BoxOutlinesAction() { super("Show Box Outlines"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_B)); + putValue(MNEMONIC_KEY, KeyEvent.VK_B); } /** @@ -254,7 +254,7 @@ class LineBoxOutlinesAction extends AbstractAction { */ LineBoxOutlinesAction() { super("Show Line Box Outlines"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_L)); + putValue(MNEMONIC_KEY, KeyEvent.VK_L); } /** @@ -281,7 +281,7 @@ class InlineBoxesAction extends AbstractAction { */ InlineBoxesAction() { super("Show Inline Boxes"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_I)); + putValue(MNEMONIC_KEY, KeyEvent.VK_I); } /** @@ -303,7 +303,7 @@ class FontMetricsAction extends AbstractAction { */ FontMetricsAction() { super("Show Font Metrics"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_F)); + putValue(MNEMONIC_KEY, KeyEvent.VK_F); } /** @@ -355,7 +355,7 @@ class ShowDOMInspectorAction extends AbstractAction { */ ShowDOMInspectorAction() { super("DOM Tree Inspector"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); + putValue(MNEMONIC_KEY, KeyEvent.VK_D); } /** @@ -397,7 +397,7 @@ static class RefreshPageAction extends AbstractAction { */ RefreshPageAction() { super("Refresh Page"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_R)); + putValue(MNEMONIC_KEY, KeyEvent.VK_R); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("F5")); } @@ -426,7 +426,7 @@ static class ReloadPageAction extends AbstractAction { */ ReloadPageAction() { super("Reload Page"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_P)); + putValue(MNEMONIC_KEY, KeyEvent.VK_P); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F5, ActionEvent.CTRL_MASK)); diff --git a/flying-saucer-core/src/main/java/org/xhtmlrenderer/util/JDKXRLogger.java b/flying-saucer-core/src/main/java/org/xhtmlrenderer/util/JDKXRLogger.java index a49fbb615..5f9df3ed1 100644 --- a/flying-saucer-core/src/main/java/org/xhtmlrenderer/util/JDKXRLogger.java +++ b/flying-saucer-core/src/main/java/org/xhtmlrenderer/util/JDKXRLogger.java @@ -21,6 +21,8 @@ */ package org.xhtmlrenderer.util; +import static java.lang.Boolean.parseBoolean; + import java.io.IOException; import java.util.ArrayList; import java.util.Enumeration; @@ -41,9 +43,7 @@ public class JDKXRLogger implements XRLogger { private static boolean initPending = true; - /** - * {@inheritdoc} - */ + @Override public void log(String where, Level level, String msg) { if (initPending) { init(); @@ -52,9 +52,7 @@ public void log(String where, Level level, String msg) { getLogger(where).log(level, msg); } - /** - * {@inheritdoc} - */ + @Override public void log(String where, Level level, String msg, Throwable th) { if (initPending) { init(); @@ -63,9 +61,7 @@ public void log(String where, Level level, String msg, Throwable th) { getLogger(where).log(level, msg, th); } - /** - * {@inheritdoc} - */ + @Override public void setLevel(String logger, Level level) { getLogger(logger).setLevel(level); } @@ -156,7 +152,7 @@ private static void initializeJDKLogManager(final Properties fsLoggingProperties private static void configureLoggerHandlerForwarding(Properties fsLoggingProperties, List loggers) { String val = fsLoggingProperties.getProperty("use-parent-handler"); - boolean flag = val != null && Boolean.valueOf(val); + boolean flag = parseBoolean(val); for (Logger logger : loggers) { logger.setUseParentHandlers(flag); } @@ -189,7 +185,7 @@ private static void assignFormatter(Map handlers, String handle */ private static List retrieveLoggers() { List loggerNames = XRLog.listRegisteredLoggers(); - List loggers = new ArrayList(loggerNames.size()); + List loggers = new ArrayList<>(loggerNames.size()); for (String loggerName : loggerNames) { loggers.add(Logger.getLogger(loggerName)); @@ -209,7 +205,7 @@ private static List retrieveLoggers() { */ private static Map configureLogHandlers(List loggers, final String handlerClassList) { final String[] names = handlerClassList.split(" "); - final Map handlers = new HashMap(names.length); + final Map handlers = new HashMap<>(names.length); for (final String name : names) { try { diff --git a/flying-saucer-core/src/test/java/eeze/Eeze.java b/flying-saucer-core/src/test/java/eeze/Eeze.java index 3bbd09cd3..5647a6941 100644 --- a/flying-saucer-core/src/test/java/eeze/Eeze.java +++ b/flying-saucer-core/src/test/java/eeze/Eeze.java @@ -99,15 +99,11 @@ public class Eeze { /** * Description of the Field */ - private final static FileFilter HTML_FILE_FILTER = - new FileFilter() { - public boolean accept(File f) { - return f.getName().endsWith(".html") || - f.getName().endsWith(".htm") || - f.getName().endsWith(".xhtml") || - f.getName().endsWith(".xml"); - } - }; + private final static FileFilter HTML_FILE_FILTER = f -> + f.getName().endsWith(".html") || + f.getName().endsWith(".htm") || + f.getName().endsWith(".xhtml") || + f.getName().endsWith(".xml"); private ReloadPageAction reloadPageAction; private ReloadFileListAction reloadFileList; @@ -120,32 +116,25 @@ private Eeze() { /** * Main processing method for the Eeze object * - * @param args PARAM */ - private void run(String args[]) { + private void run() { buildFrame(); - SwingUtilities.invokeLater(new Runnable() { - public void run() { - try { - File fontFile = new File(directory + "/support/AHEM____.TTF"); - if (fontFile.exists()) { - html.getSharedContext().setFontMapping("Ahem", - Font.createFont(Font.TRUETYPE_FONT, fontFile.toURL().openStream())); - } - } catch (FontFormatException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } catch (IOException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + SwingUtilities.invokeLater(() -> { + try { + File fontFile = new File(directory + "/support/AHEM____.TTF"); + if (fontFile.exists()) { + html.getSharedContext().setFontMapping("Ahem", + Font.createFont(Font.TRUETYPE_FONT, fontFile.toURL().openStream())); } + } catch (FontFormatException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } catch (IOException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } }); testFiles = buildFileList(); try { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - showHelpPage(); - } - }); + SwingUtilities.invokeLater(this::showHelpPage); } catch (Exception ex) { ex.printStackTrace(); } @@ -158,16 +147,16 @@ private void parseArgs(String[] args) { File f = new File(arg); if (!f.exists()) { - showUsageAndExit("Does not exist: " + arg, -1); + showUsageAndExit("Does not exist: " + arg); } if (!f.isDirectory()) { - showUsageAndExit("You specified a file, not a directory: " + arg, -1); + showUsageAndExit("You specified a file, not a directory: " + arg); } this.directory = f; } if ( this.directory == null ) { - showUsageAndExit("Please specify a directory", -1); + showUsageAndExit("Please specify a directory"); } } @@ -197,55 +186,53 @@ private void buildFrame() { frame.setExtendedState(JFrame.NORMAL); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - SwingUtilities.invokeLater(new Runnable() { - public void run() { - html = new XHTMLPanel(); - scroll = new FSScrollPane(html); - frame.getContentPane().add(scroll); - frame.pack(); - frame.setSize(1024, 768); - frame.setVisible(true); - - frame.addComponentListener(new ComponentAdapter() { - public void componentResized(ComponentEvent e) { - html.relayout(); - } - }); - - nextDemoAction = new NextDemoAction(); - reloadPageAction = new ReloadPageAction(); - chooseDemoAction = new ChooseDemoAction(); - growAction = new GrowAction(); - shrinkAction = new ShrinkAction(); - - increase_font = new FontSizeAction(FontSizeAction.INCREMENT, KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_MASK)); - reset_font = new FontSizeAction(FontSizeAction.RESET, KeyStroke.getKeyStroke(KeyEvent.VK_0, InputEvent.CTRL_MASK)); - decrease_font = new FontSizeAction(FontSizeAction.DECREMENT, KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK)); - - reloadFileList = new ReloadFileListAction(); - showGrid = new ShowGridAction(); - showHelp = new ShowHelpAction(); - saveAsImg = new SaveAsImageAction(); - overlayImage = new CompareImageAction(); - - frame.setJMenuBar(new JMenuBar()); - JMenu doMenu = new JMenu("Do"); - doMenu.add(reloadPageAction); - doMenu.add(nextDemoAction); - doMenu.add(chooseDemoAction); - doMenu.add(growAction); - doMenu.add(shrinkAction); - doMenu.add(increase_font); - doMenu.add(reset_font); - doMenu.add(decrease_font); - doMenu.add(showGrid); - doMenu.add(saveAsImg); - doMenu.add(overlayImage); - doMenu.add(reloadFileList); - doMenu.add(showHelp); - doMenu.setVisible(false); - frame.getJMenuBar().add(doMenu); - } + SwingUtilities.invokeLater(() -> { + html = new XHTMLPanel(); + scroll = new FSScrollPane(html); + frame.getContentPane().add(scroll); + frame.pack(); + frame.setSize(1024, 768); + frame.setVisible(true); + + frame.addComponentListener(new ComponentAdapter() { + public void componentResized(ComponentEvent e) { + html.relayout(); + } + }); + + nextDemoAction = new NextDemoAction(); + reloadPageAction = new ReloadPageAction(); + chooseDemoAction = new ChooseDemoAction(); + growAction = new GrowAction(); + shrinkAction = new ShrinkAction(); + + increase_font = new FontSizeAction(FontSizeAction.INCREMENT, KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_MASK)); + reset_font = new FontSizeAction(FontSizeAction.RESET, KeyStroke.getKeyStroke(KeyEvent.VK_0, InputEvent.CTRL_MASK)); + decrease_font = new FontSizeAction(FontSizeAction.DECREMENT, KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK)); + + reloadFileList = new ReloadFileListAction(); + showGrid = new ShowGridAction(); + showHelp = new ShowHelpAction(); + saveAsImg = new SaveAsImageAction(); + overlayImage = new CompareImageAction(); + + frame.setJMenuBar(new JMenuBar()); + JMenu doMenu = new JMenu("Do"); + doMenu.add(reloadPageAction); + doMenu.add(nextDemoAction); + doMenu.add(chooseDemoAction); + doMenu.add(growAction); + doMenu.add(shrinkAction); + doMenu.add(increase_font); + doMenu.add(reset_font); + doMenu.add(decrease_font); + doMenu.add(showGrid); + doMenu.add(saveAsImg); + doMenu.add(overlayImage); + doMenu.add(reloadFileList); + doMenu.add(showHelp); + doMenu.setVisible(false); + frame.getJMenuBar().add(doMenu); }); } catch (Exception ex) { @@ -270,11 +257,9 @@ private void switchPage(File file, boolean reload) { } currentDisplayed = file; changeTitle(file.toURL().toString()); - SwingUtilities.invokeLater(new Runnable() { - public void run() { - imagePanel.imageWasLoaded(); - imagePanel.repaint(); - } + SwingUtilities.invokeLater(() -> { + imagePanel.imageWasLoaded(); + imagePanel.repaint(); }); } catch (Exception ex) { ex.printStackTrace(); @@ -334,26 +319,21 @@ private URL eezeHelp() { * * @param args PARAM */ - public static void main(String args[]) { - try { - if (args.length == 0) { - showUsageAndExit("Eeze needs some information to work.", -1); - } - Eeze eeze = new Eeze(); - eeze.parseArgs(args); - eeze.run(args); - } catch (Exception ex) { - ex.printStackTrace(); + public static void main(String[] args) { + if (args.length == 0) { + showUsageAndExit("Eeze needs some information to work."); } + Eeze eeze = new Eeze(); + eeze.parseArgs(args); + eeze.run(); } /** * Description of the Method * * @param error PARAM - * @param i */ - private static void showUsageAndExit(String error, int i) { + private static void showUsageAndExit(String error) { StringBuffer sb = new StringBuffer(); sb.append("Oops! " + error + " \n") @@ -370,7 +350,7 @@ private static void showUsageAndExit(String error, int i) { .append(" order. The first is rendered. Use Alt-h to show keyboard navigation \n") .append(" shortcuts.\n") .append(" \n"); - System.out.println(sb.toString()); + System.out.println(sb); System.exit(-1); } @@ -404,7 +384,7 @@ public void setImage(Image i) { } public boolean imageWasLoaded() { - if ( Eeze.this.comparingWithImage == false ) + if (!Eeze.this.comparingWithImage) return false; currentPageImg = loadImageForPage(); @@ -579,14 +559,14 @@ class GrowAction extends AbstractAction { /** * Description of the Field */ - private float increment = 1.1F; + private final float increment = 1.1F; /** * Constructor for the GrowAction object */ public GrowAction() { super("Grow Page"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_G)); + putValue(MNEMONIC_KEY, KeyEvent.VK_G); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_L, KeyEvent.ALT_MASK)); } @@ -610,16 +590,15 @@ class ShowGridAction extends AbstractAction { private boolean on; private Component originalGlassPane; - private GridGlassPane gridGlassPane; + private final GridGlassPane gridGlassPane = new GridGlassPane(); /** * Constructor for the ShowGridAction object */ public ShowGridAction() { super("Show Grid"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_G)); + putValue(MNEMONIC_KEY, KeyEvent.VK_G); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_G, KeyEvent.ALT_MASK)); - gridGlassPane = new GridGlassPane(); } /** @@ -653,7 +632,7 @@ class CompareImageAction extends AbstractAction { */ public CompareImageAction() { super("Compare to Reference Image"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_C)); + putValue(MNEMONIC_KEY, KeyEvent.VK_C); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK)); imagePanel = new ImagePanel(); } @@ -683,12 +662,10 @@ public void actionPerformed(ActionEvent e) { // HACK: content pane is not repainting unless frame is resized once // split is added. This workaround causes a flicker, but only when image // is first loaded - SwingUtilities.invokeLater(new Runnable() { - public void run() { - Dimension d = eezeFrame.getSize(); - eezeFrame.setSize((int) d.getWidth(), (int) d.getHeight() + 1); - eezeFrame.setSize(d); - } + SwingUtilities.invokeLater(() -> { + Dimension d = eezeFrame.getSize(); + eezeFrame.setSize((int) d.getWidth(), (int) d.getHeight() + 1); + eezeFrame.setSize(d); }); } else { eezeFrame.getContentPane().remove(split); @@ -708,14 +685,14 @@ class ShrinkAction extends AbstractAction { /** * Description of the Field */ - private float increment = 1 / 1.1F; + private final float increment = 1 / 1.1F; /** * Constructor for the ShrinkAction object */ public ShrinkAction() { super("Shrink Page"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_S)); + putValue(MNEMONIC_KEY, KeyEvent.VK_S); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.ALT_MASK)); } @@ -742,7 +719,7 @@ class ShowHelpAction extends AbstractAction { */ public ShowHelpAction() { super("Show Help Page"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_H)); + putValue(MNEMONIC_KEY, KeyEvent.VK_H); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.ALT_MASK)); } @@ -769,7 +746,7 @@ class NextDemoAction extends AbstractAction { */ public NextDemoAction() { super("Next Demo Page"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_N)); + putValue(MNEMONIC_KEY, KeyEvent.VK_N); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.ALT_MASK)); } @@ -811,7 +788,7 @@ class SaveAsImageAction extends AbstractAction { */ public SaveAsImageAction() { super("Save Page as PNG Image"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_S)); + putValue(MNEMONIC_KEY, KeyEvent.VK_S); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK)); } @@ -882,7 +859,7 @@ class ReloadPageAction extends AbstractAction { */ public ReloadPageAction() { super("Reload Page"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_R)); + putValue(MNEMONIC_KEY, KeyEvent.VK_R); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.ALT_MASK)); } @@ -913,7 +890,7 @@ class ChooseDemoAction extends AbstractAction { */ public ChooseDemoAction() { super("Choose Demo Page"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_C)); + putValue(MNEMONIC_KEY, KeyEvent.VK_C); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.ALT_MASK)); } @@ -944,7 +921,7 @@ class ReloadFileListAction extends AbstractAction { public ReloadFileListAction() { super("Reload File List Page"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_F)); + putValue(MNEMONIC_KEY, KeyEvent.VK_F); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F, KeyEvent.ALT_MASK)); } @@ -966,7 +943,7 @@ class FontSizeAction extends AbstractAction { /** * Description of the Field */ - private int whichDirection; + private final int whichDirection; /** * Description of the Field diff --git a/flying-saucer-examples/src/main/java/org/xhtmlrenderer/demo/browser/BrowserActions.java b/flying-saucer-examples/src/main/java/org/xhtmlrenderer/demo/browser/BrowserActions.java index 46169d1e9..be863795d 100755 --- a/flying-saucer-examples/src/main/java/org/xhtmlrenderer/demo/browser/BrowserActions.java +++ b/flying-saucer-examples/src/main/java/org/xhtmlrenderer/demo/browser/BrowserActions.java @@ -19,23 +19,22 @@ */ package org.xhtmlrenderer.demo.browser; -import org.xhtmlrenderer.demo.browser.actions.CopySelectionAction; -import org.xhtmlrenderer.demo.browser.actions.FontSizeAction; -import org.xhtmlrenderer.demo.browser.actions.GenerateDiffAction; -import org.xhtmlrenderer.layout.SharedContext; -import org.xhtmlrenderer.simple.XHTMLPanel; -import org.xhtmlrenderer.util.Uu; - -import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.io.File; -import java.net.MalformedURLException; import java.net.URL; import java.util.logging.Logger; +import javax.swing.*; + +import org.xhtmlrenderer.demo.browser.actions.FontSizeAction; +import org.xhtmlrenderer.demo.browser.actions.GenerateDiffAction; +import org.xhtmlrenderer.layout.SharedContext; +import org.xhtmlrenderer.simple.XHTMLPanel; +import org.xhtmlrenderer.util.Uu; + /** * Description of the Class * @@ -89,7 +88,7 @@ public void actionPerformed(ActionEvent evt) { }; // TODO: need right API call for ESC //stop.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE)); - stop.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_S)); + stop.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_S); open_file = new AbstractAction() { @@ -99,7 +98,7 @@ public void actionPerformed(ActionEvent evt) { }; open_file.putValue(Action.NAME, "Open File..."); setAccel(open_file, KeyEvent.VK_O); - setMnemonic(open_file, new Integer(KeyEvent.VK_O)); + setMnemonic(open_file, KeyEvent.VK_O); export_pdf = @@ -136,7 +135,7 @@ public void actionPerformed(ActionEvent evt) { setName(quit, "Quit"); setAccel(quit, KeyEvent.VK_Q); - setMnemonic(quit, new Integer(KeyEvent.VK_Q)); + setMnemonic(quit, KeyEvent.VK_Q); url = getImageUrl("images/go-previous.png"); backward = new EmptyAction("Back", "Go back one page", new ImageIcon(url)) { @@ -200,14 +199,14 @@ public void actionPerformed(ActionEvent evt) { reload.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F5, InputEvent.SHIFT_MASK)); - reload.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_R)); + reload.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_R); print_preview = new EmptyAction("Print Preview", "Print preview mode", null) { public void actionPerformed(ActionEvent evt) { togglePrintPreview(); } }; - print_preview.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_V)); + print_preview.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_V); load = new AbstractAction("Load") { public void actionPerformed(ActionEvent evt) { @@ -273,19 +272,19 @@ public void actionPerformed(ActionEvent evt) { increase_font.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); - increase_font.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_I)); + increase_font.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_I); reset_font = new FontSizeAction(root, FontSizeAction.RESET); reset_font.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_0, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); - reset_font.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_N)); + reset_font.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_N); decrease_font = new FontSizeAction(root, FontSizeAction.DECREMENT); decrease_font.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); - decrease_font.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); + decrease_font.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_D); setName(increase_font, "Increase"); setName(reset_font, "Normal"); @@ -310,11 +309,7 @@ public void actionPerformed(ActionEvent e) { aboutDlg.dispose(); } }); - SwingUtilities.invokeLater(new Runnable() { - public void run() { - btn.requestFocusInWindow(); - } - }); + SwingUtilities.invokeLater(btn::requestFocusInWindow); JPanel control = new JPanel(new FlowLayout(FlowLayout.RIGHT)); control.add(btn); outer.add(control, BorderLayout.SOUTH); diff --git a/flying-saucer-examples/src/main/java/org/xhtmlrenderer/demo/browser/BrowserMenuBar.java b/flying-saucer-examples/src/main/java/org/xhtmlrenderer/demo/browser/BrowserMenuBar.java index 042c1edaf..d857abef9 100755 --- a/flying-saucer-examples/src/main/java/org/xhtmlrenderer/demo/browser/BrowserMenuBar.java +++ b/flying-saucer-examples/src/main/java/org/xhtmlrenderer/demo/browser/BrowserMenuBar.java @@ -366,7 +366,7 @@ class ShowDOMInspectorAction extends AbstractAction { */ ShowDOMInspectorAction() { super("DOM Tree Inspector"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); + putValue(MNEMONIC_KEY, KeyEvent.VK_D); } /** @@ -404,7 +404,7 @@ class BoxOutlinesAction extends AbstractAction { */ BoxOutlinesAction() { super("Show Box Outlines"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_B)); + putValue(MNEMONIC_KEY, KeyEvent.VK_B); } /** @@ -429,7 +429,7 @@ class LineBoxOutlinesAction extends AbstractAction { */ LineBoxOutlinesAction() { super("Show Line Box Outlines"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_L)); + putValue(MNEMONIC_KEY, KeyEvent.VK_L); } /** @@ -454,7 +454,7 @@ class InlineBoxesAction extends AbstractAction { */ InlineBoxesAction() { super("Show Inline Boxes"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_I)); + putValue(MNEMONIC_KEY, KeyEvent.VK_I); } /** @@ -474,7 +474,7 @@ class FontMetricsAction extends AbstractAction { */ FontMetricsAction() { super("Show Font Metrics"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_F)); + putValue(MNEMONIC_KEY, KeyEvent.VK_F); } /** @@ -492,7 +492,7 @@ class NextDemoAction extends AbstractAction { public NextDemoAction() { super("Next Demo Page"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_N)); + putValue(MNEMONIC_KEY, KeyEvent.VK_N); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); } @@ -533,7 +533,7 @@ class PriorDemoAction extends AbstractAction { public PriorDemoAction() { super("Prior Demo Page"); - putValue(MNEMONIC_KEY, new Integer(KeyEvent.VK_P)); + putValue(MNEMONIC_KEY, KeyEvent.VK_P); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); } diff --git a/flying-saucer-examples/src/main/java/org/xhtmlrenderer/demo/browser/ScaleFactor.java b/flying-saucer-examples/src/main/java/org/xhtmlrenderer/demo/browser/ScaleFactor.java index c25ce5d16..3505e6d6c 100644 --- a/flying-saucer-examples/src/main/java/org/xhtmlrenderer/demo/browser/ScaleFactor.java +++ b/flying-saucer-examples/src/main/java/org/xhtmlrenderer/demo/browser/ScaleFactor.java @@ -10,17 +10,17 @@ public class ScaleFactor { public static final double PAGE_WIDTH = -2.0d; public static final double PAGE_HEIGHT = -3.0d; public static final double PAGE_WHOLE = -4.0d; - private Double factor; - private String zoomLabel; + private final double factor; + private final String zoomLabel; public ScaleFactor(double factor, String zoomLabel) { super(); - this.factor = new Double(factor); + this.factor = factor; this.zoomLabel = zoomLabel; } public double getFactor() { - return factor.doubleValue(); + return factor; } public String getZoomLabel() { diff --git a/flying-saucer-pdf-itext5/src/main/java/org/xhtmlrenderer/pdf/ITextRenderer.java b/flying-saucer-pdf-itext5/src/main/java/org/xhtmlrenderer/pdf/ITextRenderer.java index 074fc1637..0f1a717e6 100644 --- a/flying-saucer-pdf-itext5/src/main/java/org/xhtmlrenderer/pdf/ITextRenderer.java +++ b/flying-saucer-pdf-itext5/src/main/java/org/xhtmlrenderer/pdf/ITextRenderer.java @@ -19,9 +19,7 @@ */ package org.xhtmlrenderer.pdf; -import java.awt.Dimension; -import java.awt.Rectangle; -import java.awt.Shape; +import java.awt.*; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.File; @@ -198,7 +196,7 @@ public void setPDFEncryption(PDFEncryption pdfEncryption) { public void setPDFVersion(char _v) { for (int i = 0; i < validPdfVersions.length; i++) { if (_v == validPdfVersions[i]) { - _pdfVersion = new Character(_v); + _pdfVersion = _v; return; } } diff --git a/flying-saucer-pdf-itext5/src/main/java/org/xhtmlrenderer/simple/PDFRenderer.java b/flying-saucer-pdf-itext5/src/main/java/org/xhtmlrenderer/simple/PDFRenderer.java index ec1387911..c9a986cc7 100644 --- a/flying-saucer-pdf-itext5/src/main/java/org/xhtmlrenderer/simple/PDFRenderer.java +++ b/flying-saucer-pdf-itext5/src/main/java/org/xhtmlrenderer/simple/PDFRenderer.java @@ -32,12 +32,12 @@ public class PDFRenderer { private static final Map versionMap = new HashMap(); static { - versionMap.put("1.2", new Character(PdfWriter.VERSION_1_2)); - versionMap.put("1.3", new Character(PdfWriter.VERSION_1_3)); - versionMap.put("1.4", new Character(PdfWriter.VERSION_1_4)); - versionMap.put("1.5", new Character(PdfWriter.VERSION_1_5)); - versionMap.put("1.6", new Character(PdfWriter.VERSION_1_6)); - versionMap.put("1.7", new Character(PdfWriter.VERSION_1_7)); + versionMap.put("1.2", PdfWriter.VERSION_1_2); + versionMap.put("1.3", PdfWriter.VERSION_1_3); + versionMap.put("1.4", PdfWriter.VERSION_1_4); + versionMap.put("1.5", PdfWriter.VERSION_1_5); + versionMap.put("1.6", PdfWriter.VERSION_1_6); + versionMap.put("1.7", PdfWriter.VERSION_1_7); } /** * Renders the XML file at the given URL as a PDF file diff --git a/flying-saucer-pdf/src/main/java/org/xhtmlrenderer/pdf/ITextRenderer.java b/flying-saucer-pdf/src/main/java/org/xhtmlrenderer/pdf/ITextRenderer.java index e0eb72930..68912ce0b 100644 --- a/flying-saucer-pdf/src/main/java/org/xhtmlrenderer/pdf/ITextRenderer.java +++ b/flying-saucer-pdf/src/main/java/org/xhtmlrenderer/pdf/ITextRenderer.java @@ -201,7 +201,7 @@ public void setPDFEncryption(PDFEncryption pdfEncryption) { public void setPDFVersion(char _v) { for (int i = 0; i < validPdfVersions.length; i++) { if (_v == validPdfVersions[i]) { - _pdfVersion = new Character(_v); + _pdfVersion = _v; return; } } @@ -214,7 +214,7 @@ public char getPDFVersion() { } public void setPDFXConformance(int pdfXConformance){ - _pdfXConformance = new Integer(pdfXConformance); + _pdfXConformance = pdfXConformance; } public int getPDFXConformance(){ diff --git a/flying-saucer-pdf/src/main/java/org/xhtmlrenderer/simple/PDFRenderer.java b/flying-saucer-pdf/src/main/java/org/xhtmlrenderer/simple/PDFRenderer.java index 25ae8b08d..ffe3a711a 100644 --- a/flying-saucer-pdf/src/main/java/org/xhtmlrenderer/simple/PDFRenderer.java +++ b/flying-saucer-pdf/src/main/java/org/xhtmlrenderer/simple/PDFRenderer.java @@ -31,12 +31,12 @@ public class PDFRenderer { private static final Map versionMap = new HashMap(); static { - versionMap.put("1.2", new Character(PdfWriter.VERSION_1_2)); - versionMap.put("1.3", new Character(PdfWriter.VERSION_1_3)); - versionMap.put("1.4", new Character(PdfWriter.VERSION_1_4)); - versionMap.put("1.5", new Character(PdfWriter.VERSION_1_5)); - versionMap.put("1.6", new Character(PdfWriter.VERSION_1_6)); - versionMap.put("1.7", new Character(PdfWriter.VERSION_1_7)); + versionMap.put("1.2", PdfWriter.VERSION_1_2); + versionMap.put("1.3", PdfWriter.VERSION_1_3); + versionMap.put("1.4", PdfWriter.VERSION_1_4); + versionMap.put("1.5", PdfWriter.VERSION_1_5); + versionMap.put("1.6", PdfWriter.VERSION_1_6); + versionMap.put("1.7", PdfWriter.VERSION_1_7); } /** * Renders the XML file at the given URL as a PDF file