Ignore:
Timestamp:
2016-05-12T00:08:52+02:00 (9 years ago)
Author:
donvip
Message:

fix NPE, sonar warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/print/src/org/openstreetmap/josm/plugins/print/PrintPreview.java

    r32167 r32169  
    6060     * The PageFormat chosen for printing (and preview)
    6161     */
    62     protected transient PageFormat format = null;
     62    protected transient PageFormat format;
    6363   
    6464    /**
     
    7676     * When this flag is true, no painting operations will be performed.
    7777     */
    78     protected boolean paintingDisabled = false;
     78    protected boolean paintingDisabled;
    7979   
    8080    /**
    8181     * the printable object for rendering preview contents
    8282     */
    83     protected transient Printable printable = null;
     83    protected transient Printable printable;
    8484   
    8585    /**
     
    157157     * Zoom to fit the page size
    158158     *
    159      * Set the zoom factor such that the whole page fits into the
    160      * preview area.
     159     * Set the zoom factor such that the whole page fits into the preview area.
    161160     */
    162161    public void zoomToPage() {
     162        if (format == null)
     163            return;
    163164        Container parent = getParent();
    164165        Dimension dim;
    165166        if (parent instanceof JViewport) {
    166167            dim = getParent().getSize(); // could get rid of scrollbars
    167         }
    168         else {
     168        } else {
    169169            dim = getVisibleRect().getSize();
    170170        }
     
    290290
    291291        g2d.scale(scale, scale);
    292         g2d.clip(new Rectangle2D.Double(format.getImageableX(), format.getImageableY(), format.getImageableWidth(), format.getImageableHeight()));
     292        g2d.clip(new Rectangle2D.Double(
     293                format.getImageableX(),
     294                format.getImageableY(),
     295                format.getImageableWidth(),
     296                format.getImageableHeight()));
    293297        if (printable != null) {
    294298            try {
    295299                printable.print(g2d, format, 0);
    296             }
    297             catch (PrinterException e) {
     300            } catch (PrinterException e) {
    298301                // should never happen since we are not printing
    299302                Main.error(e);
    300303            }
    301         }
    302         else {
     304        } else {
    303305            g2d.setColor(Color.gray);
    304306            g2d.fillRect(0, 0, (int)format.getWidth(), (int)format.getHeight());
Note: See TracChangeset for help on using the changeset viewer.