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

Adding Search Bar to Station Select UI #115

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

lab596
Copy link
Contributor

@lab596 lab596 commented Sep 1, 2023

Work in progress of adding and implementing Search Bar into Select Station UI.

@lab596 lab596 changed the title Lab596 patch 1 Adding Search Bar to Station Select UI Sep 1, 2023
@lab596 lab596 marked this pull request as draft September 1, 2023 19:01
@lab596
Copy link
Contributor Author

lab596 commented Sep 2, 2023

Closes issue #100

@lab596 lab596 marked this pull request as ready for review September 4, 2023 06:30
Copy link
Contributor Author

@lab596 lab596 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I wanted to make this PR ready for review as I believe I am in a spot where I could use some assistance to wrap up this feature. In this review I have highlighted some of the main features left to fix/add. Please feal free to add any more suggestions/ optimization ideas.

Comment on lines +196 to +227
//Attempting to change the color of the country borders
if (countryFound && foundCoordinates != null) {
g2.setColor(Color.GREEN);
g2.setStroke(new BasicStroke(2));
ArrayList<Polygon> paths = new ArrayList<>();

if(foundCoordinates instanceof org.geojson.Polygon){
Polygon pol = (org.geojson.Polygon) foundCoordinates;
paths.add(pol);
}
else if(foundCoordinates instanceof org.geojson.MultiPolygon){

MultiPolygon mp = (org.geojson.MultiPolygon) foundCoordinates;
List<List<List<org.geojson.LngLatAlt>>> polygons = mp.getCoordinates();
for (List<List<org.geojson.LngLatAlt>> polygon : polygons) {
org.geojson.Polygon pol = new org.geojson.Polygon(polygon.get(0));
paths.add(pol);
}
}
g2.setColor(Color.GREEN);
for (Polygon polygon : paths) {
List<org.geojson.LngLatAlt> coordinates = polygon.getExteriorRing();
int[] xPoints = new int[coordinates.size()];
int[] yPoints = new int[coordinates.size()];
for (int i = 0; i < coordinates.size(); i++) {
org.geojson.LngLatAlt point = coordinates.get(i);
xPoints[i] = (int) point.getLongitude();
yPoints[i] = (int) point.getLatitude();
}
g2.fillPolygon(xPoints, yPoints, coordinates.size());
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I am attempting to redraw the nation that has been searched with a different color in order to highlight that nation. The goal is to make the searched country more easily identifiable. While this code runs without errors, it does not change the nation's color and I need help debugging. I believe the reason behind the color not changing is that some classes (I believe GlobeRenderer.java) needs to be refreshed or revalidated in some manner.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually, the goal is to also automatically take users to the country on the globe.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you are trying to achieve, but this filling method will definitely not work, because the raw geojson polygon coordinates are saved as latitude/longitude and in order to calculate the actual screen coordinates, the polygon has to go trough 3D projection matrix etc...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest working improving the UI/other things now before I modify the rendering engine a bit to allow setting properties to the individual render entities. My idea is that each render entity would have a map of properties, and you can for example create a property called isHighlighted and use it while rendering to set maybe different colors/thicker line.

Also I want to work soon on the events zooming / cinema mode, so your country zooming might use the same API.

src/main/java/globalquake/ui/stationselect/SearchBar.java Outdated Show resolved Hide resolved
@xspanger3770
Copy link
Owner

Hi again! I see there is some great work being done! I tested the search bar and for the first attempt, it looks promising! Of course there is still a lot of improvements to done and I will try to lead you what can be done in my comments.

@lab596
Copy link
Contributor Author

lab596 commented Sep 5, 2023

I wanted to add a few notes:

  1. Upon updating the countries.txt, 2 nations had special characters which I added to the file. However, as seen by the commit previous, this caused a build error, specifically a Error: Can't use 'tar -xzf' extract archive file. This shouldn't be a big deal, but it's just something I noticed.
  2. Just as a note, the code as marked in the first review that attempted to highlight the nation may cause the shape of the nation to appear in the search bar. This is not intended and should eventually be fixed when the highlight feature is added correctly. If you wish to see this, I especially noticed it clearly when I searched "India" in the search bar.

Also, I was wondering if you had any UI features for the search bar that you wish to implement. If so, please provide an example as well as an image if possible so I can try to recreate it as best I can :)

@xspanger3770
Copy link
Owner

Hi!
Sorry that I haven't looked at your PR in the past few days, I was pretty busy with all the other stuff and also the search bar feature feels pretty difficult to implement in a nice way for me at this moment and I didn't know how to help. Also, I knew I would be changing the polygon files in the near future that contain the country names and later I added more region borders. The new polygons could also be used for the search bar. Actually, you won't probably need the search suggestions.txt file, but you can create the list from already loaded polygons in Regions.java. There is for example regionsHD list, that contains all countries together with the polygons that you can use to fetch the coordinates that the globe would then zoom into using my new smoothTransition API.

Tell me what you think :) You can maybe have a look inside the Regions.java file to see how I handle the polygons, but overall this feature will require quite lot of work and I have dozens of other features that are requested by many people every day :D

@lab596
Copy link
Contributor Author

lab596 commented Sep 28, 2023

Please let me know when is a good time to resume work on this PR :)

@xspanger3770
Copy link
Owner

I sure will :) Not yet though as we want to add more regions soon that can be used for the search bar, and I'm pretty busy with university. Also there is absolutely nothing wrong about if you try to implement some other smaller feature in the meantime :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants