Ignore:
Timestamp:
2010-09-15T18:54:18+02:00 (15 years ago)
Author:
stoecker
Message:

remove tabs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wms-turbo-challenge2/src/wmsturbochallenge/FakeMapView.java

    r21477 r23190  
    2626
    2727class fake_map_view extends MapView {
    28         public ProjectionBounds view_bounds;
    29         public MapView parent;
     28    public ProjectionBounds view_bounds;
     29    public MapView parent;
    3030
    31         public Graphics2D graphics;
    32         public BufferedImage ground_image;
    33         public int ground_width = -1;
    34         public int ground_height = -1;
    35         public double scale;
    36         public double max_east_west;
     31    public Graphics2D graphics;
     32    public BufferedImage ground_image;
     33    public int ground_width = -1;
     34    public int ground_height = -1;
     35    public double scale;
     36    public double max_east_west;
    3737
    38         public fake_map_view(MapView parent, double scale) {
    39                 super(null); //TODO MapView constructor contains registering listeners and other code, that probably shouldn't be called in fake map view
    40                 this.parent = parent;
    41                 this.scale = scale;
     38    public fake_map_view(MapView parent, double scale) {
     39        super(null); //TODO MapView constructor contains registering listeners and other code, that probably shouldn't be called in fake map view
     40        this.parent = parent;
     41        this.scale = scale;
    4242
    43                 ProjectionBounds parent_bounds = parent.getProjectionBounds();
    44                 max_east_west =
    45                         parent_bounds.max.east() - parent_bounds.min.east();
    46         }
     43        ProjectionBounds parent_bounds = parent.getProjectionBounds();
     44        max_east_west =
     45            parent_bounds.max.east() - parent_bounds.min.east();
     46    }
    4747
    48         public void setProjectionBounds(ProjectionBounds bounds) {
    49                 view_bounds = bounds;
     48    public void setProjectionBounds(ProjectionBounds bounds) {
     49        view_bounds = bounds;
    5050
    51                 if (bounds.max.east() - bounds.min.east() > max_east_west) {
    52                         max_east_west = bounds.max.east() - bounds.min.east();
     51        if (bounds.max.east() - bounds.min.east() > max_east_west) {
     52            max_east_west = bounds.max.east() - bounds.min.east();
    5353
    54                         /* We need to set the parent MapView's bounds (i.e.
    55                         * zoom level) to the same as ours max possible
    56                         * bounds to avoid WMSLayer thinking we're zoomed
    57                         * out more than we are or it'll pop up an annoying
    58                         * "requested area is too large" popup.
    59                         */
    60                         EastNorth parent_center = parent.getCenter();
    61                         parent.zoomTo(new ProjectionBounds(
    62                                         new EastNorth(
    63                                                 parent_center.east() -
    64                                                 max_east_west / 2,
    65                                                 parent_center.north()),
    66                                         new EastNorth(
    67                                                 parent_center.east() +
    68                                                 max_east_west / 2,
    69                                                 parent_center.north())));
     54            /* We need to set the parent MapView's bounds (i.e.
     55            * zoom level) to the same as ours max possible
     56            * bounds to avoid WMSLayer thinking we're zoomed
     57            * out more than we are or it'll pop up an annoying
     58            * "requested area is too large" popup.
     59            */
     60            EastNorth parent_center = parent.getCenter();
     61            parent.zoomTo(new ProjectionBounds(
     62                    new EastNorth(
     63                        parent_center.east() -
     64                        max_east_west / 2,
     65                        parent_center.north()),
     66                    new EastNorth(
     67                        parent_center.east() +
     68                        max_east_west / 2,
     69                        parent_center.north())));
    7070
    71                         /* Request again because NavigatableContent adds
    72                         * a border just to be sure.
    73                         */
    74                         ProjectionBounds new_bounds =
    75                                 parent.getProjectionBounds();
    76                         max_east_west =
    77                                 new_bounds.max.east() - new_bounds.min.east();
    78                 }
     71            /* Request again because NavigatableContent adds
     72            * a border just to be sure.
     73            */
     74            ProjectionBounds new_bounds =
     75                parent.getProjectionBounds();
     76            max_east_west =
     77                new_bounds.max.east() - new_bounds.min.east();
     78        }
    7979
    80                 Point vmin = getPoint(bounds.min);
    81                 Point vmax = getPoint(bounds.max);
    82                 int w = vmax.x + 1;
    83                 int h = vmin.y + 1;
     80        Point vmin = getPoint(bounds.min);
     81        Point vmax = getPoint(bounds.max);
     82        int w = vmax.x + 1;
     83        int h = vmin.y + 1;
    8484
    85                 if (w <= ground_width && h <= ground_height) {
    86                         graphics.setClip(0, 0, w, h);
    87                         return;
    88                 }
     85        if (w <= ground_width && h <= ground_height) {
     86            graphics.setClip(0, 0, w, h);
     87            return;
     88        }
    8989
    90                 if (w > ground_width)
    91                         ground_width = w;
    92                 if (h > ground_height)
    93                         ground_height = h;
     90        if (w > ground_width)
     91            ground_width = w;
     92        if (h > ground_height)
     93            ground_height = h;
    9494
    95                 ground_image = new BufferedImage(ground_width,
    96                                 ground_height,
    97                                 BufferedImage.TYPE_INT_RGB);
    98                 graphics = ground_image.createGraphics();
    99                 graphics.setClip(0, 0, w, h);
    100         }
     95        ground_image = new BufferedImage(ground_width,
     96                ground_height,
     97                BufferedImage.TYPE_INT_RGB);
     98        graphics = ground_image.createGraphics();
     99        graphics.setClip(0, 0, w, h);
     100    }
    101101
    102         public ProjectionBounds getProjectionBounds() {
    103                 return view_bounds;
    104         }
     102    public ProjectionBounds getProjectionBounds() {
     103        return view_bounds;
     104    }
    105105
    106         public Point getPoint(EastNorth p) {
    107                 double x = p.east() - view_bounds.min.east();
    108                 double y = view_bounds.max.north() - p.north();
    109                 x /= this.scale;
    110                 y /= this.scale;
     106    public Point getPoint(EastNorth p) {
     107        double x = p.east() - view_bounds.min.east();
     108        double y = view_bounds.max.north() - p.north();
     109        x /= this.scale;
     110        y /= this.scale;
    111111
    112                 return new Point((int) x, (int) y);
    113         }
     112        return new Point((int) x, (int) y);
     113    }
    114114
    115         public EastNorth getEastNorth(int x, int y) {
    116                 return new EastNorth(
    117                         view_bounds.min.east() + x * this.scale,
    118                         view_bounds.min.north() - y * this.scale);
    119         }
     115    public EastNorth getEastNorth(int x, int y) {
     116        return new EastNorth(
     117            view_bounds.min.east() + x * this.scale,
     118            view_bounds.min.north() - y * this.scale);
     119    }
    120120
    121         public boolean isVisible(int x, int y) {
    122                 return true;
    123         }
     121    public boolean isVisible(int x, int y) {
     122        return true;
     123    }
    124124
    125         public Graphics getGraphics() {
    126                 return graphics;
    127         }
     125    public Graphics getGraphics() {
     126        return graphics;
     127    }
    128128
    129         public void repaint() {
    130         }
     129    public void repaint() {
     130    }
    131131}
Note: See TracChangeset for help on using the changeset viewer.