Changeset 32167 in osm for applications/editors/josm


Ignore:
Timestamp:
2016-05-11T23:57:23+02:00 (8 years ago)
Author:
donvip
Message:

fix NPE, add SonarLint configuration, cleanup

Location:
applications/editors/josm/plugins/print
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/print/.project

    r29529 r32167  
    1111                        </arguments>
    1212                </buildCommand>
     13                <buildCommand>
     14                        <name>org.sonarlint.eclipse.core.sonarlintBuilder</name>
     15                        <arguments>
     16                        </arguments>
     17                </buildCommand>
    1318        </buildSpec>
    1419        <natures>
  • applications/editors/josm/plugins/print/src/org/openstreetmap/josm/plugins/print/PrintPreview.java

    r29848 r32167  
    4040import javax.swing.JPanel;
    4141import javax.swing.RepaintManager;
     42
     43import org.openstreetmap.josm.Main;
    4244
    4345/**
     
    5860     * The PageFormat chosen for printing (and preview)
    5961     */
    60     protected PageFormat format = null;
     62    protected transient PageFormat format = null;
    6163   
    6264    /**
     
    7981     * the printable object for rendering preview contents
    8082     */
    81     protected Printable printable = null;
     83    protected transient Printable printable = null;
    8284   
    8385    /**
     
    134136     */
    135137    public void zoomIn() {
    136         double zoom = getZoom();
    137         if (zoom < 5.0) {
    138             setZoom(2.0 * zoom);
     138        double z = getZoom();
     139        if (z < 5.0) {
     140            setZoom(2.0 * z);
    139141        }
    140142    }
     
    146148     */
    147149    public void zoomOut() {
    148         double zoom = getZoom();
    149         if (zoom > 0.1) {
    150             setZoom(0.5 * zoom);
     150        double z = getZoom();
     151        if (z > 0.1) {
     152            setZoom(0.5 * z);
    151153        }
    152154    }
     
    216218     */
    217219    public double getZoom() {
    218         if (zoomToPage || zoom < 0.01) {
     220        if (format != null && (zoomToPage || zoom < 0.01)) {
    219221            // actually this is zoom-to-page
    220222            Dimension dim = getParent().getSize();
     
    234236    public Dimension getZoomedPageDimension() {
    235237        int resolution = Toolkit.getDefaultToolkit().getScreenResolution();
    236         double zoom = getZoom();
    237         int width = (int)(zoom * resolution * format.getWidth() / 72.0);
    238         int height = (int)(zoom * resolution * format.getHeight() / 72.0);
     238        double z = getZoom();
     239        int width = (int)(z * resolution * format.getWidth() / 72.0);
     240        int height = (int)(z * resolution * format.getHeight() / 72.0);
    239241        return new Dimension(width, height);
    240242    }
     
    248250    @Override
    249251    public Dimension getPreferredSize() {
    250         if (format == null || zoomToPage == true || zoom < 0.01) {
     252        if (format == null || zoomToPage || zoom < 0.01) {
    251253            return new Dimension(0,0);
    252254        }
     
    295297            catch (PrinterException e) {
    296298                // should never happen since we are not printing
     299                Main.error(e);
    297300            }
    298301        }
     
    304307        g2d.setTransform(at);
    305308    }
    306 
    307309}
Note: See TracChangeset for help on using the changeset viewer.