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

Add outline to unit count and damage counts #3488

Merged
merged 2 commits into from Jul 1, 2018

Conversation

ron-murhammer
Copy link
Member

}
}

private static void drawOutlinedText(final Graphics2D graphics, final String s, final int x, final int y,
Copy link
Member Author

Choose a reason for hiding this comment

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

This method is the core change. Everything else is pretty boiler plate.

@codecov-io
Copy link

codecov-io commented Jun 29, 2018

Codecov Report

Merging #3488 into master will decrease coverage by 0.15%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3488      +/-   ##
============================================
- Coverage     21.96%   21.81%   -0.16%     
- Complexity     5920     5952      +32     
============================================
  Files           836      836              
  Lines         72017    73224    +1207     
  Branches      11596    11955     +359     
============================================
+ Hits          15821    15976     +155     
- Misses        54107    55161    +1054     
+ Partials       2089     2087       -2
Impacted Files Coverage Δ Complexity Δ
.../games/strategy/triplea/ui/screen/UnitsDrawer.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...va/games/strategy/triplea/ui/menubar/ViewMenu.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...in/java/games/strategy/triplea/image/MapImage.java 0% <0%> (ø) 0 <0> (ø) ⬇️
.../java/games/strategy/engine/data/DefaultNamed.java 69.56% <0%> (-2.66%) 7% <0%> (ø)
...y/engine/framework/startup/mc/SetupPanelModel.java 0% <0%> (ø) 0% <0%> (ø) ⬇️
...n/java/games/strategy/triplea/ui/TripleAFrame.java 0% <0%> (ø) 0% <0%> (ø) ⬇️
...mes/strategy/triplea/ui/MapUnitTooltipManager.java 0% <0%> (ø) 0% <0%> (ø) ⬇️
...va/games/strategy/engine/framework/GameRunner.java 0% <0%> (ø) 0% <0%> (ø) ⬇️
...java/games/strategy/ui/ImageScrollerLargeView.java 0% <0%> (ø) 0% <0%> (ø) ⬇️
...ategy/engine/framework/startup/mc/ServerModel.java 0% <0%> (ø) 0% <0%> (ø) ⬇️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 782d2d3...5cec85b. Read the comment docs.

@Heppisorus
Copy link
Contributor

Looks good Red. Well done as usual.

Copy link
Member

@RoiEXLab RoiEXLab left a comment

Choose a reason for hiding this comment

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

CodeChanges look good, however I'm seeing a lot of pretty similar code being repeated an repeated again.
I'm not sure if there's a good way to solve this though.
In any case I'll try to review your current PRs in detail tomorrow (getting pretty late for me here)

@ron-murhammer
Copy link
Member Author

@RoiEXLab Yeah, a lot of it is setter/getter/reset properties boiler plate code. Probably could create some sort of utility to try to simplify them a bit but didn't really spend time digging into them just followed the existing pattern as the main change updating how counts are draw and the properties were kind of just a customization add-on for outlines.


public static void resetPropertyUnitHitDamageOutline() {
final Preferences pref = Preferences.userNodeForPackage(MapImage.class);
pref.remove(PROPERTY_UNIT_HIT_DAMAGE_OUTLINE_STRING);
Copy link
Member

Choose a reason for hiding this comment

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

I think it really wouldn't hurt to just create a static helper method for all of those reset methods that accepts a string it then removes.
This helper could then be tested in a simple unit test and would increase coverage a little bit

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, added a reset helper method.

public static Color getPropertyUnitHitDamageColor() {
if (propertyUnitHitDamageColor == null) {
final Preferences pref = Preferences.userNodeForPackage(MapImage.class);
propertyUnitHitDamageColor =
new Color(pref.getInt(PROPERTY_UNIT_HIT_DAMAGE_COLOR_STRING, Color.black.getRGB()));
new Color(pref.getInt(PROPERTY_UNIT_HIT_DAMAGE_COLOR_STRING, UNIT_HIT_DAMAGE_COLOR_DEFAULT.getRGB()));
}
return propertyUnitHitDamageColor;
}

Copy link
Member

Choose a reason for hiding this comment

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

Similarly, because the setters and getters vary too much, you could just create a getPrefs method that simply returns a Preferences object which can be chained with a set or get call directly.
Makes the code shorter, and again allows those methods to be a little bit more tested

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really sure much can be done for get/set as the variation is too high without doing significant refactoring or only covering a portion of them. Only thing is literally creating a 1 line helper method for Preferences.userNodeForPackage(MapImage.class). Which maybe makes each method a bit shorter but adds indirection. Not sure that's even worth it.

Copy link
Member

@RoiEXLab RoiEXLab left a comment

Choose a reason for hiding this comment

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

👍
Feel free to merge once the build completes

@ron-murhammer ron-murhammer merged commit 842f191 into master Jul 1, 2018
@RoiEXLab RoiEXLab deleted the Improve_Unit_Count_Display branch July 6, 2018 22:54
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

4 participants