Changeset 32675 in osm for applications/editors


Ignore:
Timestamp:
2016-07-18T23:45:04+02:00 (8 years ago)
Author:
donvip
Message:

checkstyle

Location:
applications/editors/josm/plugins/piclayer
Files:
2 added
27 edited

Legend:

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

    r32286 r32675  
    1616                        </arguments>
    1717                </buildCommand>
     18                <buildCommand>
     19                        <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
     20                        <arguments>
     21                        </arguments>
     22                </buildCommand>
    1823        </buildSpec>
    1924        <natures>
    2025                <nature>org.eclipse.jdt.core.javanature</nature>
     26                <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
    2127        </natures>
    2228</projectDescription>
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java

    r32495 r32675  
    7474
    7575        // Create menu entry
    76        
     76
    7777        // Add menu items
    7878        MainMenu.add(Main.main.menu.imagerySubMenu, newLayerFromFileAction);
     
    8989    @Override
    9090    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
    91         if(newFrame != null) {
     91        if (newFrame != null) {
    9292            // Create plugin map modes
    9393            MovePictureAction movePictureAction = new MovePictureAction(newFrame);
     
    114114            buttonList.add(picLayerActionButtonFactory(shearPictureAction));
    115115
    116             for(IconToggleButton btn : buttonList) {
     116            for (IconToggleButton btn : buttonList) {
    117117                newFrame.addMapMode(btn);
    118118            }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/GenericPicTransformAction.java

    r32329 r32675  
    5757    public void mousePressed(MouseEvent e) {
    5858        // Start action
    59         if ( Main.getLayerManager().getActiveLayer() instanceof PicLayerAbstract ) {
    60             currentLayer = (PicLayerAbstract)Main.getLayerManager().getActiveLayer();
     59        if (Main.getLayerManager().getActiveLayer() instanceof PicLayerAbstract) {
     60            currentLayer = (PicLayerAbstract) Main.getLayerManager().getActiveLayer();
    6161
    62             if ( currentLayer != null && e.getButton() == MouseEvent.BUTTON1 ) {
     62            if (currentLayer != null && e.getButton() == MouseEvent.BUTTON1) {
    6363                requestFocusInMapView();
    6464                isDragging = true;
    6565                prevMousePoint = new Point(e.getPoint());
    66                 prevEastNorth = Main.map.mapView.getEastNorth(e.getX(),e.getY());
     66                prevEastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY());
    6767                // try to find and fill selected point if possible
    6868                selectedPoint = currentLayer.findSelectedPoint(e.getPoint());
     
    7575    public void mouseDragged(MouseEvent e) {
    7676        // Call action performing
    77         if(isDragging && currentLayer != null) {
     77        if (isDragging && currentLayer != null) {
    7878            doAction(e);
    7979            prevMousePoint = new Point(e.getPoint());
    80             prevEastNorth = Main.map.mapView.getEastNorth(e.getX(),e.getY());
     80            prevEastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY());
    8181            Main.map.mapView.repaint();
    8282        }
     
    101101        Layer active = Main.getLayerManager().getActiveLayer();
    102102        if (active instanceof PicLayerAbstract) {
    103             ((PicLayerAbstract)active).setDrawPoints(value);
     103            ((PicLayerAbstract) active).setDrawPoints(value);
    104104        }
    105105        Main.map.mapView.repaint();
    106106    }
    107 
    108107}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/LoadPictureCalibrationAction.java

    r31729 r32675  
    5151     * Constructor
    5252     */
    53     public LoadPictureCalibrationAction( PicLayerAbstract owner ) {
     53    public LoadPictureCalibrationAction(PicLayerAbstract owner) {
    5454        super(tr("Load Picture Calibration..."), null, tr("Loads calibration data from a file"), null, false);
    5555        // Remember the owner...
     
    6464        // Save dialog
    6565        JFileChooser fc = new JFileChooser();
    66         fc.setAcceptAllFileFilterUsed( true );
    67         fc.setFileFilter( new CalibrationFileFilter() );
    68         fc.setSelectedFile( new File(m_owner.getPicLayerName() + CalibrationFileFilter.EXTENSION));
    69         int result = fc.showOpenDialog(Main.parent );
     66        fc.setAcceptAllFileFilterUsed(true);
     67        fc.setFileFilter(new CalibrationFileFilter());
     68        fc.setSelectedFile(new File(m_owner.getPicLayerName() + CalibrationFileFilter.EXTENSION));
     69        int result = fc.showOpenDialog(Main.parent);
    7070
    71         if ( result == JFileChooser.APPROVE_OPTION ) {
     71        if (result == JFileChooser.APPROVE_OPTION) {
    7272
    7373            // Load
     
    7777                // Error
    7878                e.printStackTrace();
    79                 JOptionPane.showMessageDialog(Main.parent , tr("Loading file failed: {0}", e.getMessage()), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE);
     79                JOptionPane.showMessageDialog(Main.parent,
     80                        tr("Loading file failed: {0}", e.getMessage()), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE);
    8081            }
    8182        }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/LoadPictureCalibrationFromWorldAction.java

    r31729 r32675  
    2828
    2929        JFileChooser fc = new JFileChooser();
    30         fc.setAcceptAllFileFilterUsed( true );
    31         int result = fc.showOpenDialog(Main.parent );
     30        fc.setAcceptAllFileFilterUsed(true);
     31        int result = fc.showOpenDialog(Main.parent);
    3232
    33         if ( result == JFileChooser.APPROVE_OPTION ) {
     33        if (result == JFileChooser.APPROVE_OPTION) {
    3434
    3535            // Load
     
    3939                // Error
    4040                ex.printStackTrace();
    41                 JOptionPane.showMessageDialog(Main.parent , tr("Loading file failed: {0}", ex.getMessage()), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE);
     41                JOptionPane.showMessageDialog(Main.parent,
     42                        tr("Loading file failed: {0}", ex.getMessage()), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE);
    4243            }
    4344        }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/SavePictureCalibrationAction.java

    r31729 r32675  
    5050     * Constructor
    5151     */
    52     public SavePictureCalibrationAction( PicLayerAbstract owner ) {
     52    public SavePictureCalibrationAction(PicLayerAbstract owner) {
    5353        super(tr("Save Picture Calibration..."), null, tr("Saves calibration data to a file"), null, false);
    5454        // Remember the owner...
     
    6363        // Save dialog
    6464        final JFileChooser fc = new JFileChooser();
    65         fc.setAcceptAllFileFilterUsed( true );
    66         fc.setFileFilter( new CalibrationFileFilter() );
    67         fc.setSelectedFile( new File(m_owner.getPicLayerName() + CalibrationFileFilter.EXTENSION));
    68         int result = fc.showSaveDialog( Main.parent );
     65        fc.setAcceptAllFileFilterUsed(true);
     66        fc.setFileFilter(new CalibrationFileFilter());
     67        fc.setSelectedFile(new File(m_owner.getPicLayerName() + CalibrationFileFilter.EXTENSION));
     68        int result = fc.showSaveDialog(Main.parent);
    6969
    70         if ( result == JFileChooser.APPROVE_OPTION ) {
     70        if (result == JFileChooser.APPROVE_OPTION) {
    7171            // Check file extension and force it to be valid
    7272            File file = fc.getSelectedFile();
    7373            String path = file.getAbsolutePath();
    74             if ( path.length() < CalibrationFileFilter.EXTENSION.length()
    75                 || !path.substring( path.length() - 4 ).equals(CalibrationFileFilter.EXTENSION)) {
    76                 file = new File( path + CalibrationFileFilter.EXTENSION );
     74            if (path.length() < CalibrationFileFilter.EXTENSION.length()
     75                || !path.substring(path.length() - 4).equals(CalibrationFileFilter.EXTENSION)) {
     76                file = new File(path + CalibrationFileFilter.EXTENSION);
    7777            }
    7878
     
    8585                // Error
    8686                e.printStackTrace();
    87                 JOptionPane.showMessageDialog(Main.parent , tr("Saving file failed: {0}", e.getMessage()), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE);
     87                JOptionPane.showMessageDialog(Main.parent,
     88                        tr("Saving file failed: {0}", e.getMessage()), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE);
    8889            }
    8990        }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/newlayer/NewLayerFromClipboardAction.java

    r32495 r32675  
    5656        try {
    5757            layer.initialize();
    58         }
    59         catch (IOException e) {
     58        } catch (IOException e) {
    6059            // Failed
    61             System.out.println( "NewLayerFromClipboardAction::actionPerformed - " + e.getMessage() );
     60            System.out.println("NewLayerFromClipboardAction::actionPerformed - " + e.getMessage());
    6261            JOptionPane.showMessageDialog(null, e.getMessage(), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE);
    6362            return;
    6463        }
    6564        // Add layer
    66         Main.getLayerManager().addLayer( layer );
     65        Main.getLayerManager().addLayer(layer);
    6766    }
    6867}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/newlayer/NewLayerFromFileAction.java

    r32495 r32675  
    5959        private String[] supportedExtensions;
    6060
    61         public ImageFileFilter() {
     61        ImageFileFilter() {
    6262            List<String> extensions = new ArrayList<>();
    6363            extensions.add("zip");
    6464            extensions.add("kml");
    65             for (String ext : ImageIO.getReaderFormatNames())
     65            for (String ext : ImageIO.getReaderFormatNames()) {
    6666                extensions.add(ext);
     67            }
    6768            supportedExtensions = extensions.toArray(new String[0]);
    6869        }
     
    7071        @Override
    7172        public boolean accept(File f) {
    72             if ( f.isDirectory() )
     73            if (f.isDirectory())
    7374                return true;
    7475
     
    7778            // Unfortunately, getReaderFormatNames does not always return ALL extensions in
    7879            // both lower and upper case, so we can not do a search in the array
    79             for (String e: supportedExtensions)
    80                 if ( e.equalsIgnoreCase(fileExtension) ) {
     80            for (String e: supportedExtensions) {
     81                if (e.equalsIgnoreCase(fileExtension)) {
    8182                    return true;
    8283                }
     84            }
    8385
    8486            return false;
    8587        }
    86 
    8788
    8889        @Override
     
    9091            return tr("Supported image files, *.zip, *.kml");
    9192        }
    92 
    9393    }
    9494
     
    108108        // Choose a file
    109109        JFileChooser fc = new JFileChooser(Main.pref.get(m_lastdirprefname));
    110         fc.setAcceptAllFileFilterUsed( true );
    111         fc.setFileFilter( new ImageFileFilter() );
     110        fc.setAcceptAllFileFilterUsed(true);
     111        fc.setFileFilter(new ImageFileFilter());
    112112
    113113        fc.setMultiSelectionEnabled(true);
    114         int result = fc.showOpenDialog( Main.parent );
     114        int result = fc.showOpenDialog(Main.parent);
    115115
    116116        // Create a layer?
    117         if ( result == JFileChooser.APPROVE_OPTION ) {
     117        if (result == JFileChooser.APPROVE_OPTION) {
    118118            // The first loaded layer will be placed at the top of any other layer of the same class,
    119119            // or at the bottom of the stack if there is no such layer yet
    120120            // The next layers we load will be placed one after the other after this first layer
    121121            int newLayerPos = Main.getLayerManager().getLayers().size();
    122             for(Layer l : Main.getLayerManager().getLayersOfType(PicLayerAbstract.class)) {
     122            for (Layer l : Main.getLayerManager().getLayersOfType(PicLayerAbstract.class)) {
    123123                int pos = Main.getLayerManager().getLayers().indexOf(l);
    124124                if (pos < newLayerPos) newLayerPos = pos;
    125125            }
    126126
    127             for(File file : fc.getSelectedFiles() ) {
     127            for (File file : fc.getSelectedFiles()) {
    128128                // TODO: we need a progress bar here, it can take quite some time
    129129
     
    150150    private void addNewLayerFromFile(File file, int newLayerPos, boolean isZoomToLayer) {
    151151        try {
    152             PicLayerFromFile layer = new PicLayerFromFile( file );
     152            PicLayerFromFile layer = new PicLayerFromFile(file);
    153153            layer.initialize();
    154154
    155155            placeLayer(layer, newLayerPos, isZoomToLayer);
    156         }
    157         catch (IOException e) {
     156        } catch (IOException e) {
    158157            // Failed
    159             System.out.println( "NewLayerFromFileAction::actionPerformed - " + e.getMessage() );
     158            System.out.println("NewLayerFromFileAction::actionPerformed - " + e.getMessage());
    160159            JOptionPane.showMessageDialog(null, e.getMessage(), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE);
    161160        }
     
    168167        Main.map.mapView.moveLayer(layer, newLayerPos++);
    169168
    170         if ( isZoomToLayer && Main.pref.getInteger("piclayer.zoom-on-load", 1) != 0 ) {
     169        if (isZoomToLayer && Main.pref.getInteger("piclayer.zoom-on-load", 1) != 0) {
    171170            // if we are loading a single picture file, zoom on it, so that the user can see something
    172171            BoundingXYVisitor v = new BoundingXYVisitor();
     
    175174        }
    176175    }
     176
    177177    private void addNewLayerFromKML(File root, KMLGroundOverlay overlay, int newLayerPos) {
    178178        try {
     
    183183        } catch (IOException e) {
    184184            // Failed
    185             System.out.println( "NewLayerFromFileAction::actionPerformed - " + e.getMessage() );
     185            System.out.println("NewLayerFromFileAction::actionPerformed - " + e.getMessage());
    186186            JOptionPane.showMessageDialog(null, e.getMessage(), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE);
    187187        }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/MovePictureAction.java

    r30356 r32675  
    4646    @Override
    4747    protected void doAction(MouseEvent e) {
    48         EastNorth eastNorth = Main.map.mapView.getEastNorth(e.getX(),e.getY());
     48        EastNorth eastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY());
    4949        currentLayer.movePictureBy(
    5050            eastNorth.east() - prevEastNorth.east(),
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/RotatePictureAction.java

    r30356 r32675  
    4141     */
    4242    public RotatePictureAction(MapFrame frame) {
    43         super(tr("PicLayer rotate"), tr("Rotated"), "rotate", tr("Drag to rotate the picture"), frame, ImageProvider.getCursor("crosshair", null));
     43        super(tr("PicLayer rotate"), tr("Rotated"), "rotate", tr("Drag to rotate the picture"),
     44                frame, ImageProvider.getCursor("crosshair", null));
    4445    }
    4546
     
    4748    protected void doAction(MouseEvent e) {
    4849        double factor;
    49         if ( ( e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK ) != 0 ) {
     50        if ((e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0) {
    5051            factor = Main.pref.getDouble("piclayer.rotatefactors.high_precision", 100.0);
     52        } else {
     53            factor = Main.pref.getDouble("piclayer.rotatefactors.low_precision", 10.0);
    5154        }
    52         else {
    53             factor = Main.pref.getDouble("piclayer.rotatefactors.low_precision", 10.0 );
    54         }
    55         currentLayer.rotatePictureBy( ( e.getY() - prevMousePoint.getY() ) / factor );
     55        currentLayer.rotatePictureBy((e.getY() - prevMousePoint.getY()) / factor);
    5656    }
    5757}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/ScalePictureActionAbstract.java

    r30356 r32675  
    3838     * Constructor
    3939     */
    40     public ScalePictureActionAbstract (String name, String actionName, String icon, String tooltip, MapFrame frame) {
     40    public ScalePictureActionAbstract(String name, String actionName, String icon, String tooltip, MapFrame frame) {
    4141        super(name, actionName, icon, tooltip, frame, ImageProvider.getCursor("crosshair", null));
    4242    }
     
    4545    protected void doAction(MouseEvent e) {
    4646        double factor;
    47         if ( ( e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK ) != 0 ) {
     47        if ((e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0) {
    4848            factor = Main.pref.getDouble("piclayer.scalefactors.high_precision", 1.0005);
    49         }
    50         else {
     49        } else {
    5150            factor = Main.pref.getDouble("piclayer.scalefactors.low_precision", 1.015);
    5251        }
    53         doTheScale( Math.pow(factor, prevMousePoint.getY() - e.getY() ) );
     52        doTheScale(Math.pow(factor, prevMousePoint.getY() - e.getY()));
    5453    }
    5554
     
    5756     * Does the actual scaling in the inherited class.
    5857     */
    59      protected abstract void doTheScale( double scale );
     58     protected abstract void doTheScale(double scale);
    6059
    6160}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/ScaleXPictureAction.java

    r27403 r32675  
    2929 */
    3030@SuppressWarnings("serial")
    31 public class ScaleXPictureAction extends ScalePictureActionAbstract
    32 {
    33     /*
     31public class ScaleXPictureAction extends ScalePictureActionAbstract {
     32
     33    /**
    3434     * Constructor
    3535     */
     
    3939
    4040    @Override
    41     public void doTheScale( double scale ) {
    42             currentLayer.scalePictureBy( scale, 1.0 );
    43         }
     41    public void doTheScale(double scale) {
     42        currentLayer.scalePictureBy(scale, 1.0);
     43    }
    4444}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/ScaleXYPictureAction.java

    r27403 r32675  
    2929 */
    3030@SuppressWarnings("serial")
    31 public class ScaleXYPictureAction extends ScalePictureActionAbstract
    32 {
    33     /*
     31public class ScaleXYPictureAction extends ScalePictureActionAbstract {
     32
     33    /**
    3434     * Constructor
    3535     */
     
    3939
    4040    @Override
    41     public void doTheScale( double scale ) {
    42             currentLayer.scalePictureBy( scale, scale );
    43         }
     41    public void doTheScale(double scale) {
     42        currentLayer.scalePictureBy(scale, scale);
     43    }
    4444}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/ScaleYPictureAction.java

    r27403 r32675  
    2929 */
    3030@SuppressWarnings("serial")
    31 public class ScaleYPictureAction extends ScalePictureActionAbstract
    32 {
    33     /*
     31public class ScaleYPictureAction extends ScalePictureActionAbstract {
     32
     33    /**
    3434     * Constructor
    3535     */
     
    3939
    4040    @Override
    41     public void doTheScale( double scale ) {
    42         currentLayer.scalePictureBy( 1.0, scale );
     41    public void doTheScale(double scale) {
     42        currentLayer.scalePictureBy(1.0, scale);
    4343    }
    4444}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/ShearPictureAction.java

    r30356 r32675  
    4848    @Override
    4949    protected void doAction(MouseEvent e) {
    50         EastNorth eastNorth = Main.map.mapView.getEastNorth(e.getX(),e.getY());
     50        EastNorth eastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY());
    5151        currentLayer.shearPictureBy(
    5252            1000* (eastNorth.east() - prevEastNorth.east()),
     
    5454        );
    5555    }
    56 
    5756}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/affine/RemovePointAction.java

    r27662 r32675  
    4444        updateDrawPoints(false);
    4545    }
    46 
    47 
    4846}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/affine/TransformPointAction.java

    r30356 r32675  
    2626                    JOptionPane.showMessageDialog(null, tr("You should have 3 checkpoints to transform the image!"), tr("PicLayer"), JOptionPane.ERROR_MESSAGE, null);
    2727                else*/
    28                 {
     28                //{
    2929                    currentLayer.getTransformer().updatePair(selectedPoint, pressed);
    30                 }
     30                //}
    3131            }
    3232
     
    3636        }
    3737    }
     38
    3839    @Override
    3940    public void enterMode() {
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/command/TransformCommand.java

    r27883 r32675  
    2727        beforeTransform = extractTransform();
    2828    }
    29 
    3029
    3130    @Override
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/CalibrationFileFilter.java

    r27120 r32675  
    3636    @Override
    3737    public boolean accept(File f) {
    38         String ext3 = ( f.getName().length() > 4 ) ?  f.getName().substring( f.getName().length() - 4 ).toLowerCase() : "";
     38        String ext3 = (f.getName().length() > 4) ? f.getName().substring(f.getName().length() - 4).toLowerCase() : "";
    3939
    4040        // TODO: check what is supported by Java :)
    41         return ( f.isDirectory()
    42             ||  ext3.equals( EXTENSION )
    43             );
     41        return (f.isDirectory() || ext3.equals(EXTENSION));
    4442    }
    4543
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/PicLayerAbstract.java

    r32495 r32675  
    2727import java.awt.Image;
    2828import java.awt.Point;
     29import java.awt.RenderingHints;
    2930import java.awt.Toolkit;
    30 import java.awt.RenderingHints;
    3131import java.awt.geom.AffineTransform;
    3232import java.awt.geom.NoninvertibleTransformException;
     
    155155
    156156        // If the map does not exist - we're screwed. We should not get into this situation in the first place!
    157         if ( Main.map != null && Main.map.mapView != null ) {
     157        if (Main.map != null && Main.map.mapView != null) {
    158158
    159159            EastNorth center = Main.map.mapView.getCenter();
     
    170170        // Create image
    171171        image = createImage();
    172         if ( image == null ) {
     172        if (image == null) {
    173173            throw new IOException(tr("PicLayer failed to load or import the image."));
    174174        }
     
    188188
    189189    protected abstract void lookForCalibration() throws IOException;
     190
    190191    /**
    191192     * To be overridden by subclasses. Returns the user readable name of the layer.
     
    194195
    195196    @Override
    196     public Icon getIcon() { return layerIcon; }
    197 
    198     @Override
    199     public Object getInfoComponent() { return null; }
     197    public Icon getIcon() {
     198        return layerIcon;
     199    }
     200
     201    @Override
     202    public Object getInfoComponent() {
     203        return null;
     204    }
    200205
    201206    @Override
     
    209214                new LoadPictureCalibrationFromWorldAction(this),
    210215                SeparatorLayerAction.INSTANCE,
    211                 new RenameLayerAction(null,this),
     216                new RenameLayerAction(null, this),
    212217        };
    213218    }
     
    229234    public void paint(Graphics2D g2, MapView mv, Bounds bounds) {
    230235
    231         if ( image != null) {
     236        if (image != null) {
    232237
    233238            // Position image at the right graphical place
    234239            EastNorth center = mv.getCenter();
    235             EastNorth leftop = mv.getEastNorth( 0, 0 );
     240            EastNorth leftop = mv.getEastNorth(0, 0);
    236241            // Number of pixels for one unit in east north space.
    237242            // This is the same in x- and y- direction.
    238             double pixel_per_en = ( mv.getWidth() / 2.0 ) / ( center.east() - leftop.east() );
     243            double pixel_per_en = (mv.getWidth() / 2.0) / (center.east() - leftop.east());
    239244
    240245            //     This is now the offset in screen pixels
    241246            EastNorth imagePosition = transformer.getImagePosition();
    242             double pic_offset_x = (( imagePosition.east() - leftop.east() ) * pixel_per_en);
    243             double pic_offset_y = (( leftop.north() - imagePosition.north() ) * pixel_per_en);
    244 
    245             Graphics2D g = (Graphics2D)g2.create();
     247            double pic_offset_x = ((imagePosition.east() - leftop.east()) * pixel_per_en);
     248            double pic_offset_y = ((leftop.north() - imagePosition.north()) * pixel_per_en);
     249
     250            Graphics2D g = (Graphics2D) g2.create();
    246251            // Move
    247             g.translate( pic_offset_x, pic_offset_y );
     252            g.translate(pic_offset_x, pic_offset_y);
    248253
    249254            // Scale
    250255            double scalex = initialImageScale * pixel_per_en / getMetersPerEasting(imagePosition) / 100;
    251256            double scaley = initialImageScale * pixel_per_en / getMetersPerNorthing(imagePosition) / 100;
    252             g.scale( scalex, scaley );
     257            g.scale(scalex, scaley);
    253258
    254259            g.transform(transformer.getTransform());
     
    257262
    258263            // Draw picture
    259             g.drawImage( image, -image.getWidth(null) / 2, -image.getHeight(null) / 2, null );
     264            g.drawImage(image, -image.getWidth(null) / 2, -image.getHeight(null) / 2, null);
    260265
    261266            // Draw additional rectangle for the active pic layer
    262267            if (mv.getLayerManager().getActiveLayer() == this) {
    263                 g.setColor( new Color( 0xFF0000 ) );
     268                g.setColor(new Color(0xFF0000));
    264269                g.drawRect(
    265270                    -image.getWidth(null) / 2,
     
    269274                );
    270275            }
    271             if (drawMarkers ) {
     276            if (drawMarkers) {
    272277                // draw markers for selection
    273                 Graphics2D gPoints = (Graphics2D)g2.create();
     278                Graphics2D gPoints = (Graphics2D) g2.create();
    274279
    275280                gPoints.translate(pic_offset_x, pic_offset_y);
     
    282287                for (int i = 0; i < transformer.getOriginPoints().size(); i++) {
    283288                   Point2D trP = tr.transform(transformer.getOriginPoints().get(i), null);
    284                    int x = (int)trP.getX(), y = (int)trP.getY();
     289                   int x = (int) trP.getX(), y = (int) trP.getY();
    285290
    286291                   int dstx = x-pinAnchorX;
    287292                   int dsty = y-pinAnchorY;
    288                    gPoints.drawImage(pinTiledImage, dstx, dsty, dstx+pinWidth, dsty+pinHeight, pinTileOffsetX[i], pinTileOffsetY[i], pinTileOffsetX[i]+pinWidth, pinTileOffsetY[i]+pinHeight, null);
     293                   gPoints.drawImage(pinTiledImage, dstx, dsty, dstx+pinWidth, dsty+pinHeight,
     294                           pinTileOffsetX[i], pinTileOffsetY[i], pinTileOffsetX[i]+pinWidth, pinTileOffsetY[i]+pinHeight, null);
    289295                }
    290296            }
    291297        } else {
    292298            // TODO: proper logging
    293             System.out.println( "PicLayerAbstract::paint - general drawing error (image is null or Graphics not 2D" );
     299            System.out.println("PicLayerAbstract::paint - general drawing error (image is null or Graphics not 2D");
    294300        }
    295301    }
     
    344350     */
    345351    public void visitBoundingBox(BoundingXYVisitor arg0) {
    346         if ( image == null )
     352        if (image == null)
    347353            return;
    348354        String projcode = projection.toCode();
     
    354360        // initial scale is in m/100pix
    355361        // So for now, we support the bounding box only when everything is in meters
    356         if (projcode.equals("EPSG:4326") )
     362        if (projcode.equals("EPSG:4326"))
    357363            return;
    358364
     
    380386     * @param props Properties to save to
    381387     */
    382     public void saveCalibration( Properties props ) {
     388    public void saveCalibration(Properties props) {
    383389        // Save
    384390        double[] matrix = new double[6];
     
    401407     * Loads calibration data from file
    402408     * @param file The file to read from
    403      * @return
    404409     */
    405410    public void loadCalibration(InputStream is) throws IOException {
     
    412417     * Loads calibration data from properties structure
    413418     * @param props Properties to load from
    414      * @return
    415      */
    416     public void loadCalibration( Properties props ) {
     419     */
     420    public void loadCalibration(Properties props) {
    417421        // Load
    418422
     
    426430
    427431        initialImageScale = Double.valueOf(props.getProperty(INITIAL_SCALE, "1")); //in_scale
    428         if (props.containsKey(SCALEX)) {// old format
     432        if (props.containsKey(SCALEX)) { // old format
    429433            //double in_pos_x = Double.valueOf(props.getProperty(INITIAL_POS_X, "0"));
    430434            //double in_pos_y = Double.valueOf(props.getProperty(INITIAL_POS_Y, "0"));
     
    459463
    460464    public void loadWorldfile(InputStream is) throws IOException {
    461        
     465
    462466        try (
    463467            Reader reader = new InputStreamReader(is);
    464468            BufferedReader br = new BufferedReader(reader)
    465469        ) {
    466             double e[] = new double[6];
    467             for (int i=0; i<6; ++i) {
     470            double[] e = new double[6];
     471            for (int i = 0; i < 6; ++i) {
    468472                String line = br.readLine();
    469473                e[i] = Double.parseDouble(line);
    470474            }
    471             double sx=e[0], ry=e[1], rx=e[2], sy=e[3], dx=e[4], dy=e[5];
     475            double sx = e[0], ry = e[1], rx = e[2], sy = e[3], dx = e[4], dy = e[5];
    472476            int w = image.getWidth(null);
    473477            int h = image.getHeight(null);
     
    498502
    499503        EastNorth center = Main.map.mapView.getCenter();
    500         EastNorth leftop = Main.map.mapView.getEastNorth( 0, 0 );
     504        EastNorth leftop = Main.map.mapView.getEastNorth(0, 0);
    501505        // Number of pixels for one unit in east north space.
    502506        // This is the same in x- and y- direction.
    503         double pixel_per_en = ( Main.map.mapView.getWidth() / 2.0 ) / ( center.east() - leftop.east() );
     507        double pixel_per_en = (Main.map.mapView.getWidth() / 2.0) / (center.east() - leftop.east());
    504508
    505509        EastNorth imageCenter = transformer.getImagePosition();
    506510        //     This is now the offset in screen pixels
    507         double pic_offset_x = (( imageCenter.east() - leftop.east() ) * pixel_per_en);
    508         double pic_offset_y = (( leftop.north() - imageCenter.north() ) * pixel_per_en); // something bad...
     511        double pic_offset_x = ((imageCenter.east() - leftop.east()) * pixel_per_en);
     512        double pic_offset_y = ((leftop.north() - imageCenter.north()) * pixel_per_en); // something bad...
    509513
    510514        AffineTransform pointTrans = AffineTransform.getTranslateInstance(pic_offset_x, pic_offset_y);
     
    527531        transformer.setImagePosition(transformer.getImagePosition().add(x, y));
    528532    }
    529 
    530533
    531534    public void rotatePictureBy(double angle) {
     
    572575            Point2D pressed = transformPoint(point);
    573576            double mindist = 10;
    574             for (Point2D p : transformer.getOriginPoints())
     577            for (Point2D p : transformer.getOriginPoints()) {
    575578                if (p.distance(pressed) < mindist) { // if user clicked to select some of origin point
    576579                    selected = p;
    577580                    mindist = p.distance(pressed);
    578581                }
     582            }
    579583            return selected;
    580584        } catch (NoninvertibleTransformException e) {
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/PicLayerFromClipboard.java

    r27120 r32675  
    4242        Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
    4343        // Check result
    44         if ( t == null ) {
     44        if (t == null) {
    4545            throw new IOException(tr("Nothing in clipboard"));
    4646        }
     
    5050        try {
    5151            if (t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
    52                 image = (Image)t.getTransferData(DataFlavor.imageFlavor);
     52                image = (Image) t.getTransferData(DataFlavor.imageFlavor);
    5353            } else {
    5454                throw new IOException(tr("The clipboard data is not an image"));
    5555            }
    5656        } catch (UnsupportedFlavorException e) {
    57             throw new IOException( e.getMessage() );
     57            throw new IOException(e.getMessage());
    5858        }
    5959
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/PicLayerFromFile.java

    r31729 r32675  
    5353    private String m_tooltiptext;
    5454
    55     public PicLayerFromFile( File file ) {
     55    public PicLayerFromFile(File file) {
    5656        // Remember the file
    5757        m_file = file;
     
    102102            }
    103103        } else {
    104             image = ImageIO.read( m_file );
     104            image = ImageIO.read(m_file);
    105105            return image;
    106106        }
     
    126126
    127127        String[][] imgExtensions = new String[][] {
    128             { ".jpg", ".jpeg" },
    129             { ".png" },
    130             { ".tif", ".tiff" },
    131             { ".bmp" },
     128            {".jpg", ".jpeg"},
     129            {".png"},
     130            {".tif", ".tiff"},
     131            {".bmp"},
    132132        };
    133133        String[][] wldExtensions = new String[][] {
    134             { ".wld", ".jgw", ".jpgw" },
    135             { ".wld", ".pgw", ".pngw" },
    136             { ".wld", ".tfw", ".tifw" },
    137             { ".wld", ".bmpw", ".bpw"},
     134            {".wld", ".jgw", ".jpgw"},
     135            {".wld", ".pgw", ".pngw"},
     136            {".wld", ".tfw", ".tifw"},
     137            {".wld", ".bmpw", ".bpw"},
    138138        };
    139139
     
    153153                    String extension = imgNameInZip.substring(dotIdx);
    154154                    String namepart = imgNameInZip.substring(0, dotIdx);
    155                     for (int i=0; i<imgExtensions.length; ++i) {
     155                    for (int i = 0; i < imgExtensions.length; ++i) {
    156156                        if (Arrays.asList(imgExtensions[i]).contains(extension.toLowerCase())) {
    157157                            for (String wldExtension : wldExtensions[i]) {
     
    184184                String extension = m_file.getName().substring(dotIdx);
    185185                String namepart = m_file.getName().substring(0, dotIdx);
    186                 for (int i=0; i<imgExtensions.length; ++i) {
     186                for (int i = 0; i < imgExtensions.length; ++i) {
    187187                    if (Arrays.asList(imgExtensions[i]).contains(extension.toLowerCase())) {
    188188                        for (String wldExtension : wldExtensions[i]) {
     
    206206
    207207        String msg = tr("A calibration file associated to the picture file was found: {0}\n", fileName);
    208         if ( policy.equals("yes") ) {
     208        if (policy.equals("yes")) {
    209209            loadcal = true;
    210         }
    211         else if ( policy.equals("no") ) {
     210        } else if (policy.equals("no")) {
    212211            loadcal = false;
    213         }
    214         else if ( policy.equals("ask") ) {
     212        } else if (policy.equals("ask")) {
    215213            msg += "\n" + tr("Set \"{0}\" to yes/no/ask in the preferences\n"+
    216214                            "to control the autoloading of calibration files.", prefkey);
     
    220218                loadcal = true;
    221219            }
    222         }
    223         else {
     220        } else {
    224221            msg += "\n" + tr("It will be applied automatically.");
    225222            msg += "\n" + tr("Also, from now on, calibration files will always be loaded automatically.");
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/PicLayerFromKML.java

    r28559 r32675  
    2828        setName(picture.getName());
    2929    }
     30
    3031    @Override
    3132    protected Image createImage() throws IOException {
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/kml/KMLGroundOverlay.java

    r27231 r32675  
    11package org.openstreetmap.josm.plugins.piclayer.layer.kml;
    2 
    32
    43public class KMLGroundOverlay {
     
    1514        return filename;
    1615    }
     16
    1717    public void setFileName(String file) {
    1818        this.filename = file;
    1919    }
     20
    2021    public double getNorth() {
    2122        return north;
    2223    }
     24
    2325    public void setNorth(double north) {
    2426        this.north = north;
    2527    }
     28
    2629    public double getSouth() {
    2730        return south;
    2831    }
     32
    2933    public void setSouth(double south) {
    3034        this.south = south;
    3135    }
     36
    3237    public double getEast() {
    3338        return east;
    3439    }
     40
    3541    public void setEast(double east) {
    3642        this.east = east;
    3743    }
     44
    3845    public double getWest() {
    3946        return west;
    4047    }
     48
    4149    public void setWest(double west) {
    4250        this.west = west;
    4351    }
     52
    4453    public double getRotate() {
    4554        return rotate;
    4655    }
     56
    4757    public void setRotate(double rotate) {
    4858        this.rotate = rotate;
    4959    }
     60
    5061    public String getName() {
    5162        return name;
    5263    }
     64
    5365    public void setName(String name) {
    5466        this.name = name;
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/kml/KMLReader.java

    r30737 r32675  
    5151    private KMLGroundOverlay overlay;
    5252
    53     public KMLHandler() {
     53    KMLHandler() {
    5454        result = new ArrayList<>();
    5555    }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/transform/Matrix3D.java

    r30356 r32675  
    55import java.util.List;
    66
    7 
    87class Matrix3D {
    98    double[][] a;
    10    
    11     public Matrix3D() {
     9
     10    Matrix3D() {
    1211        a = new double[3][]; a[0] = new double[3]; a[1] = new double[3]; a[2] = new double[3];
    1312    }
    14    
    15     public Matrix3D(PictureTransform pictureTransform, double b11, double b12, double b13, double b21, double b22, double b23, double b31, double b32, double b33) {
     13
     14    Matrix3D(PictureTransform pictureTransform, double b11, double b12, double b13, double b21, double b22, double b23, double b31, double b32, double b33) {
    1615        this();
    17        
     16
    1817        a[0][0] = b11; a[0][1] = b12; a[0][2] = b13;
    1918        a[1][0] = b21; a[1][1] = b22; a[1][2] = b23;
    2019        a[2][0] = b31; a[2][1] = b32; a[2][2] = b33;
    2120    }
    22    
    23     public Matrix3D(List<? extends Point2D> list) {
     21
     22    Matrix3D(List<? extends Point2D> list) {
    2423        this();
    25        
    26         for(int i=0; i<3; i++) {
     24
     25        for (int i = 0; i < 3; i++) {
    2726            Point2D p = list.get(i);
    2827            a[0][i] = p.getX();
     
    3433    public Matrix3D multiply(Matrix3D m) {
    3534        Matrix3D result = new Matrix3D();
    36         for(int i=0; i<3; i++)
    37             for (int j=0; j<3; j++) {
     35        for (int i = 0; i < 3; i++) {
     36            for (int j = 0; j < 3; j++) {
    3837                double sum = 0;
    39                 for (int k=0; k<3; k++)
     38                for (int k = 0; k < 3; k++) {
    4039                    sum += a[i][k]*m.a[k][j];
     40                }
    4141                result.a[i][j] = sum;
    42             }               
     42            }
     43        }
    4344        return result;
    4445    }
    45    
     46
    4647    private double determinant() {
    4748        return a[0][0]*(a[1][1]*a[2][2]-a[1][2]*a[2][1])-a[0][1]*(a[1][0]*a[2][2]-a[1][2]*a[2][0])
    4849               +a[0][2]*(a[1][0]*a[2][1]-a[1][1]*a[2][0]);
    4950    }
    50    
     51
    5152    public Matrix3D inverse() throws NoSolutionException {
    5253        Matrix3D invert = new Matrix3D();
     
    5455        if (Math.abs(det) <= Double.MIN_VALUE)
    5556            throw new NoSolutionException("Determinant = 0");
    56        
     57
    5758        double s = 1/det;
    58        
     59
    5960        invert.a[0][0] = (s) * (a[1][1] * a[2][2] - a[1][2] * a[2][1]);
    6061        invert.a[1][0] = (s) * (a[1][2] * a[2][0] - a[1][0] * a[2][2]);
     
    6667        invert.a[1][2] = (s) * (a[0][2] * a[1][0] - a[0][0] * a[1][2]);
    6768        invert.a[2][2] = (s) * (a[0][0] * a[1][1] - a[0][1] * a[1][0]);
    68        
     69
    6970        return invert;
    7071    }
    71    
     72
    7273    public AffineTransform toAffineTransform() throws NoSolutionException {
    7374        if (!(Math.abs(a[2][0]) <= 1e-2 && Math.abs(a[2][1]) <= 1e-2 && Math.abs(a[2][2]-1) <= 1e-2))
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/transform/NoSolutionException.java

    r30356 r32675  
    22
    33class NoSolutionException extends Exception {
    4    
    5     public NoSolutionException(String message) {
     4
     5    NoSolutionException(String message) {
    66        super(message);
    77    }
Note: See TracChangeset for help on using the changeset viewer.