Changeset 9784 in osm for applications/viewer


Ignore:
Timestamp:
2008-08-13T16:04:30+02:00 (16 years ago)
Author:
stotz
Message:

Outer map border added

Location:
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java

    r9780 r9784  
    103103                setLayout(null);
    104104                initializeZoomSlider();
    105                 setMinimumSize(new Dimension(Tile.WIDTH, Tile.HEIGHT));
     105                setMinimumSize(new Dimension(Tile.SIZE, Tile.SIZE));
    106106                setPreferredSize(new Dimension(400, 400));
    107107                try {
     
    302302                int iMove = 0;
    303303
    304                 int tilex = center.x / Tile.WIDTH;
    305                 int tiley = center.y / Tile.HEIGHT;
    306                 int off_x = (center.x % Tile.WIDTH);
    307                 int off_y = (center.y % Tile.HEIGHT);
    308 
    309                 int posx = getWidth() / 2 - off_x;
    310                 int posy = getHeight() / 2 - off_y;
     304                int tilex = center.x / Tile.SIZE;
     305                int tiley = center.y / Tile.SIZE;
     306                int off_x = (center.x % Tile.SIZE);
     307                int off_y = (center.y % Tile.SIZE);
     308
     309                int w2 = getWidth() / 2;
     310                int h2 = getHeight() / 2;
     311                int posx = w2 - off_x;
     312                int posy = h2 - off_y;
    311313
    312314                int diff_left = off_x;
    313                 int diff_right = Tile.WIDTH - off_x;
     315                int diff_right = Tile.SIZE - off_x;
    314316                int diff_top = off_y;
    315                 int diff_bottom = Tile.HEIGHT - off_y;
     317                int diff_bottom = Tile.SIZE - off_y;
    316318
    317319                boolean start_left = diff_left < diff_right;
     
    329331                                iMove = 0;
    330332                } // calculate the visibility borders
    331                 int x_min = -Tile.WIDTH;
    332                 int y_min = -Tile.HEIGHT;
     333                int x_min = -Tile.SIZE;
     334                int y_min = -Tile.SIZE;
    333335                int x_max = getWidth();
    334336                int y_max = getHeight();
     
    350352                                                        tile.paint(g, posx, posy);
    351353                                                        if (tileGridVisible)
    352                                                                 g.drawRect(posx, posy, Tile.WIDTH, Tile.HEIGHT);
     354                                                                g.drawRect(posx, posy, Tile.SIZE, Tile.SIZE);
    353355                                                }
    354356                                        }
    355357                                        Point p = move[iMove];
    356                                         posx += p.x * Tile.WIDTH;
    357                                         posy += p.y * Tile.HEIGHT;
     358                                        posx += p.x * Tile.SIZE;
     359                                        posy += p.y * Tile.SIZE;
    358360                                        tilex += p.x;
    359361                                        tiley += p.y;
     
    371373                                marker.paint(g, p);
    372374                }
     375                // outer border of the map
     376                int mapSize = Tile.SIZE << zoom;
     377                g.drawRect(w2 - center.x, h2 - center.y, mapSize, mapSize);
    373378        }
    374379
     
    445450         *         was not found in the cache.
    446451         */
    447         protected Tile getTile(final int tilex, final int tiley, final int zoom) {
     452        protected Tile getTile(int tilex, int tiley, int zoom) {
    448453                int max = (1 << zoom);
    449454                if (tilex < 0 || tilex >= max || tiley < 0 || tiley >= max)
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Tile.java

    r9780 r9784  
    3131        protected boolean loaded = false;
    3232        protected boolean loading = false;
    33         public static final int WIDTH = 256;
    34         public static final int HEIGHT = 256;
     33        public static final int SIZE = 256;
    3534
    3635        /**
     
    6362         */
    6463        public void loadPlaceholderFromCache(TileCache cache) {
    65                 BufferedImage tmpImage = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
     64                BufferedImage tmpImage = new BufferedImage(SIZE, SIZE, BufferedImage.TYPE_INT_RGB);
    6665                Graphics2D g = (Graphics2D) tmpImage.getGraphics();
    6766                // g.drawImage(image, 0, 0, null);
     
    8382                                                if (tile != null && tile.isLoaded()) {
    8483                                                        paintedTileCount++;
    85                                                         tile.paint(g, x * WIDTH, y * HEIGHT);
     84                                                        tile.paint(g, x * SIZE, y * SIZE);
    8685                                                }
    8786                                        }
     
    10099                                double scale = (double) factor;
    101100                                AffineTransform at = new AffineTransform();
    102                                 int translate_x = (xtile % factor) * WIDTH;
    103                                 int translate_y = (ytile % factor) * HEIGHT;
     101                                int translate_x = (xtile % factor) * SIZE;
     102                                int translate_y = (ytile % factor) * SIZE;
    104103                                at.setTransform(scale, 0, 0, scale, -translate_x, -translate_y);
    105104                                g.setTransform(at);
Note: See TracChangeset for help on using the changeset viewer.