Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getViewArea is returning a useless value #324

Closed
Tdue21 opened this issue Mar 17, 2019 · 13 comments
Closed

getViewArea is returning a useless value #324

Tdue21 opened this issue Mar 17, 2019 · 13 comments
Labels
bug claimed Issue is being actively worked on. in progress Issue is actively being worked on

Comments

@Tdue21
Copy link
Contributor

Tdue21 commented Mar 17, 2019

It appears that the macro function getViewArea is return a string containing the Java object representation. If I do this:

[getViewArea(0)]

I get this returned:

java.awt.Rectangle[x=40,y=50,width=75,height=39]

Which I cannot do much with directly. I have to parse it somehow to extract the relevant values. It would be much preferable to have the method return a json object.

Edit: This is in 1.5.rc.4.

@Phergus
Copy link
Contributor

Phergus commented Mar 17, 2019

Worse than that, it doesn't have a default and so produces an error if no parameter is given.
java.lang.IndexOutOfBoundsException: Index 0 out-of-bounds for length 0 error executing expression getViewArea().

@source-knights
Copy link
Contributor

on it

@source-knights
Copy link
Contributor

setting the defaults to pixels if no parameter is given

@rkathey rkathey added bug in progress Issue is actively being worked on claimed Issue is being actively worked on. labels Mar 17, 2019
@source-knights
Copy link
Contributor

source-knights commented Mar 17, 2019

Fixed. So this:
[r: getViewArea()]
[r: getViewArea(0)]
[r: getViewArea(1)]
[r: getViewArea(0, "json")]
[r: getViewArea(1, "json")]
[r: getViewArea(0, ",")]
[r: getViewArea(1, ";")]

results now to:

offsetX=0; offsetY=0; width=886; height=616
offsetX=0; offsetY=0; width=17; height=12
offsetX=0; offsetY=0; width=886; height=616
{"offsetX":0,"offsetY":0,"width":886,"height":616}
{"offsetX":0,"offsetY":0,"width":886,"height":616}
offsetX=0, offsetY=0, width=886, height=616
offsetX=0; offsetY=0; width=886; height=616

@source-knights
Copy link
Contributor

Fix in #325

@source-knights
Copy link
Contributor

Fix is now correctly setting a default for pixels (true) if not given and allows to return Json or String property list with delimiter

@Azhrei
Copy link
Member

Azhrei commented Mar 17, 2019

Great — Good job!

@aliasmask
Copy link

Shouldn't there be an X and Y value, unless you never moved your viewport from the starting 0,0.

@source-knights
Copy link
Contributor

source-knights commented Mar 17, 2019

there is, called offsetX and offsetY?

@aliasmask
Copy link

Output Line 2 and 4 use "grid". Is the height and width in grid squares? I assumed "grid" was just for the offset and the height and width would always be in pixels. I guess grid would be okay for those too. Anyway, Line 4 seems to have pixels rather than grid values. Not sure which one is supposed to be right (2 or 4).

@source-knights
Copy link
Contributor

I did not change the calculation of the values, just the output format. But your right, some lines seem to be not using grid. Checking

source-knights added a commit to source-knights/Maptool that referenced this issue Mar 17, 2019
@aliasmask
Copy link

Re the x,y thing above. If you redo your test output I recommend moving the viewport for some x,y contrast. ie offsetX pixel 0 is the same as offsetX grid 0.

@source-knights
Copy link
Contributor

Default pixels: [r: getViewArea()]
Cells: [r: getViewArea(0)]
Pixels: [r: getViewArea(1)]
Cells as JSON: [r: getViewArea(0, "json")]
Pixels as JSON: [r: getViewArea(1, "json")]
Cells as "," separated String properties: [r: getViewArea(0, ",")]
Pixels as ";" separated String properties: [r: getViewArea(1, ";")]

Results:

Default pixels: offsetX=133; offsetY=116; width=886; height=616
Cells: offsetX=2; offsetY=2; width=17; height=12
Pixels: offsetX=133; offsetY=116; width=886; height=616
Cells as JSON: {"offsetX":2,"offsetY":2,"width":17,"height":12}
Pixels as JSON: {"offsetX":133,"offsetY":116,"width":886,"height":616}
Cells as "," separated String properties: offsetX=2, offsetY=2, width=17, height=12
Pixels as ";" separated String properties: offsetX=133; offsetY=116; width=886; height=616

cwisniew added a commit that referenced this issue Mar 22, 2019
Fix #324 getViewArea was returning an wrong formatted string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug claimed Issue is being actively worked on. in progress Issue is actively being worked on
Projects
None yet
Development

No branches or pull requests

6 participants