Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

ArrayList to Area

Featured Replies

I'm currently working on a area plotter.

Simply, you click on the screen.. it adds the location (X, Y, Z) into an ArrayList..

 

	ArrayList<Position> areaList = new ArrayList<>();

But to visually see the area.. you have to convert the arraylist into an Area

Example:

	Area chickenArea = new Area(new Position[] { new Position(3171, 3289, 0), new Position(3169, 3291, 0),
			new Position(3169, 3294, 0), new Position(3170, 3295, 0), new Position(3170, 3298, 0),
			new Position(3169, 3299, 0), new Position(3173, 3303, 0), new Position(3173, 3307, 0),
			new Position(3179, 3307, 0), new Position(3180, 3303, 0), new Position(3182, 3303, 0),
			new Position(3184, 3302, 0), new Position(3185, 3300, 0), new Position(3186, 3298, 0),
			new Position(3186, 3295, 0), new Position(3185, 3290, 0), new Position(3183, 3289, 0),
			new Position(3178, 3289, 0), new Position(3177, 3288, 0), new Position(3174, 3288, 0), });

If you just use the arraylist to draw a tile, it only plots those specific locations.

Any and all help is greatly appreciated :)

I'm currently working on a area plotter.

Simply, you click on the screen.. it adds the location (X, Y, Z) into an ArrayList..

 

	ArrayList<Position> areaList = new ArrayList<>();

But to visually see the area.. you have to convert the arraylist into an Area

Any and all help is greatly appreciated smile.png

List<Position> posList = new ArrayList<>();
Position[] positions = posList.toArray(new Position[posList.size()]);

Or

List<Position> posList = new ArrayList<>();
Position[] positions = posList.stream().toArray(Position[]::new);

Edited by Explv

  • Author
List<Position> posList = new ArrayList<>();
Position[] positions = posList.toArray(new Position[posList.size()]);

Or

List<Position> posList = new ArrayList<>();
Position[] positions = posList.stream().toArray(Position[]::new);

For some reason I get this result :|

 

d28098daca004fc2aa9d77ba66112ddd.png

For some reason I get this result :|

 

d28098daca004fc2aa9d77ba66112ddd.png

 

If you just want to create a rectangular area then you should use the:

Area(int x1, int y1, int x2, int y2)
Constructs a rectangular area using x and y coordinates from two separate positions.

Or

Area(Position southWest, Position northEast)
Constructs a rectangular area using two positions 

Constructors.

  • Author

Got it! Thank you very much!



 

			Position[] positions = posList.stream().toArray(Position[]::new);

			Area test = new Area(positions);
			
			for (Position p : test.getPositions()) {
				drawTile(this, g, p, Color.GREEN, Color.WHITE, "");
			}

Edited by Iwin

Every time you add or remove a position from that area, you should be reconstructing that Area using the new positions in the list (after converting to an array). Or is your issue converting from a list to an array?

  • Author

Every time you add or remove a position from that area, you should be reconstructing that Area using the new positions in the list (after converting to an array). Or is your issue converting from a list to an array?

My issue was converting:

 

ArrayList<Position> posList = new ArrayList<>();

To an Area.

but as posted above, my issue was solved. Unless this can be make more efficient (which is more than welcome)

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.