Comments (5)
Thanks, I will try to reproduce the error.
from jxmapviewer2.
Sorry for the long delay. I am able to reproduce the problem and will debug it a bit. Maybe I can find something... in the
meantime, did find anything related to the problem?
from jxmapviewer2.
Yes. After some more attempts I recently found a possible problem with Graphics2D.translate(...) which is presumably called somewhere before paintWaypoint(...)
By replacing my previous sample code with this following the problem disappears:
// paints a blue circle with an internal white circle
Rectangle rect = viewer.getViewportBounds(); // added
g.translate(rect.x, rect.y); // added to undo g.translate(-rect.x, -rect.y) called elsewhere
g.setColor(Color.BLUE);
g.fillOval(x-7-rect.x, y-7-rect.y, 14, 14); // changed
g.setColor(Color.WHITE);
g.fillOval(x-4-rect.x, y-4-rect.y, 8, 8); // changed
System.out.println("zoom"+viewer.getZoom());
from jxmapviewer2.
There is
debugging
and there is
debugging
The first one refers to the process of diligently and systematically analyzing a flaw (preferably not in your own code), in order to solve the problem.
The latter refers to things of which you'd hesitate to admit publicly that you have done them (and that may be fueled by some geeky curiosity, and may not even lead to a solution).
When inserting the following debugging statements in the FancyWaypointRenderer
try {
System.out.println("graphics: "+g);
sun.java2d.SunGraphics2D sg = (SunGraphics2D) g;
sun.java2d.pipe.PixelToShapeConverter sunGraphicsFillPipe = (PixelToShapeConverter) sg.fillpipe;
System.out.println("graphics.fillPipe: "+sunGraphicsFillPipe);
Field f = Class.forName("sun.java2d.pipe.PixelToShapeConverter").getDeclaredField("outpipe");
f.setAccessible(true);
Object pixelToShapeConverterOutpipe = f.get(sunGraphicsFillPipe);
System.out.println("pixelToShapeConverter.outpipe: "+pixelToShapeConverterOutpipe);
} catch (Exception e) {
e.printStackTrace();
}
(which may not even work in the newer Java versions, with all this "module sealing" and such...), then the output may be something like
graphics: sun.java2d.SunGraphics2D[font=javax.swing.plaf.FontUIResource[family=Dialog,name=Dialog,style=plain,size=12],color=sun.swing.PrintColorUIResource[r=51,g=51,b=51]]
graphics.fillPipe: sun.java2d.pipe.PixelToParallelogramConverter@e9940ac
pixelToShapeConverter.outpipe: sun.java2d.pipe.PixelToParallelogramConverter@3429e7aa
Looking at the code of PixelToShapeConverter#fillOval
, it reveals...
public void fillOval(SunGraphics2D sg,
int x, int y, int w, int h) {
outpipe.fill(sg, new Ellipse2D.Float(x, y, w, h));
}
Now. There's that Float
. And I'm reasonably sure that this is the culprit. The translation (when fully zoomed in) is 17586168
, and in the single-precision floating-point world, adding 1
to that will yield ... 17586168
, i.e. the same value. You're hitting the limit of float
here.
The solution... might be... well, ... handwavingly: to carry this translation, in an "un-applied form", until shortly before it is supposed to be used for rendering, then do the computations (in double
) that are required to bring that into the pixel space, and draw these pixels where they should be.
An aside: I noticed that when changing
g.fillOval(x-7, y-7, 14, 14);
to
g.fill(new Ellipse2D.Double(x-7, x-7, 14, 14));
then the ellipses are drawn at the wrong place, and I haven't figured out why. It seems like it's flipped vertically or so.
An aside to the aside:
Similar pixel-artifacts still appear with Ellipse2D.Double
. I just thought that this might be an easy solution/workaround, but ... it isn't, becasue the problem is deeper.
from jxmapviewer2.
Wow, impressive research, thanks a lot!
from jxmapviewer2.
Related Issues (20)
- Cache Input Stream can leak resources HOT 1
- Add Automatic-Module-Name clause to jar manifest HOT 6
- Showing Pin on Map HOT 1
- Google Maps is not working with jxmapviewer2 HOT 2
- Can we load shape files on top of the map for jxmapviewer2? HOT 3
- Improvement suggestion HOT 4
- Is it possible to update routes? HOT 3
- Divided by zero ArithmeticException in AbstractTileFactory (v2.6) HOT 2
- JavaFX compatibility HOT 2
- AbstractTileFactory#tileMap causing OutOfMemory after long usage HOT 3
- JxMapViewer.zoomToBestFit(fitPoints, 0.4) throws exception HOT 4
- Feature: decorate tile urls with query params HOT 1
- Feature: Modern httpClient HOT 7
- OOM and cache HOT 2
- Help Needed: Using MouseEvents to create new GeoPoint HOT 5
- Newest release does not support Java Modules HOT 3
- Using a WMS with other CRS/SRS (other then WGS84 EPSG:4326): HOT 2
- Possible race condition in FileBasedLocalCache HOT 1
- New release? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jxmapviewer2.