-
Notifications
You must be signed in to change notification settings - Fork 40
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
base: main
Are you sure you want to change the base?
Conversation
Closes issue #100 |
* Adding Text Suggestions * Update SearchBar.java
There was a problem hiding this 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.
//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()); | ||
} | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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/StationSelectFrame.java
Outdated
Show resolved
Hide resolved
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. |
I wanted to add a few notes:
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 :) |
Hi! 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 |
Please let me know when is a good time to resume work on this PR :) |
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 :) |
Work in progress of adding and implementing Search Bar into Select Station UI.