Created
April 16, 2013 04:25
-
-
Save Bradsta/5393333 to your computer and use it in GitHub Desktop.
WorldMapTool - originally created in 2009/2010
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.BorderLayout; | |
import java.net.URL; | |
import javax.swing.JFrame; | |
import javax.swing.JScrollPane; | |
/** | |
* | |
* @author Bradsta | |
*/ | |
public class WorldMapTool { | |
public String iURL = "http://runescape.com/img/main/downloads_and_media/downloads_and_wallpapers/rs_map/rsmap-26november2012-en.png"; | |
private double DimensionW = 3713; | |
private double DimensionH = 3329; | |
private double OriginX = 2047.5; | |
private double OriginY = 2494.5; | |
private double NorthX = 2047.5; | |
private double NorthY = 4159.0; | |
private double EastX = 3904.0; | |
private double EastY = 2494.5; | |
PicInfo pi; | |
JFrame j; | |
MapLabel p; | |
public WorldMapTool() { | |
try { | |
pi = new PicInfo(new XY(OriginX, OriginY), new XY(NorthX, NorthY), | |
new XY(EastX, EastY), new XY(DimensionW, DimensionH), iURL); | |
j = new JFrame("Map graph - Please wait until image is loaded!"); | |
p = new MapLabel(new URL(iURL)); | |
JScrollPane pane = new JScrollPane(); | |
pane.getViewport().add(p); | |
j.add(pane, BorderLayout.CENTER); | |
j.setSize(500 + 12, 500 + 31); | |
j.setResizable(true); | |
j.setVisible(true); | |
p.setIcon(); | |
while (j.isVisible()) { | |
try { | |
if (p.getMousePosition() != null | |
&& p.getMousePosition().x > 0 | |
&& p.getMousePosition().y > 0) { | |
j.setTitle("Made by Bradsta - Tile = (" | |
+ (int) p.getHoveringTile(pi).x + "," | |
+ (int) p.getHoveringTile(pi).y + ")" | |
+ " Click a tile to copy to clipboard"); | |
} else | |
j.setTitle("Made by Bradsta - Tile = (0,0)"); | |
} catch (Exception e) { | |
j.setTitle("Made by Bradsta - Tile = (0,0)"); | |
} | |
Thread.sleep(50); | |
} | |
j.dispose(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
public class XY { | |
public final double x; | |
public final double y; | |
public XY(double x, double y) { | |
this.x = x; | |
this.y = y; | |
} | |
} | |
public class PicInfo { | |
public final XY originTile; | |
public final XY northTile; | |
public final XY eastTile; | |
public final XY dimensions; | |
public final String pictureURL; | |
public PicInfo(XY originTile, XY northTile, XY eastTile, XY dimensions, | |
String pictureURL) { | |
this.originTile = originTile; | |
this.northTile = northTile; | |
this.eastTile = eastTile; | |
this.dimensions = dimensions; | |
this.pictureURL = pictureURL; | |
} | |
} | |
public static void main(String args[]) { | |
new WorldMapTool(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment