Scrub that - I see at the top of this thread you already showed something useful.david.gilbert wrote:I'm not sure what I'd use it for, so if you could put together a realistic demo, that would be helpful.
new chart type "geographical chart"
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Ok, I'll try to fix this.david.gilbert wrote:I tried the renderer. By accident, I noticed that it doesn't work when the plot orientation is horizontal. Otherwise it seems fine.
Did you fix this already in XYBlockRenderer? If you did we probably just need to copy the clone() method from there. Or even better, share this code via some abstract base class.david.gilbert wrote:I think there may be a problem in the clone() method in XYBlockRenderer (the paint scale needs to be cloned too) which you've carried across to the XYShapeRenderer. That's easy to fix though.
- martin
Hi!
Fixed the PlotOrientation problem in XYShapeRenderer. Didn't fix the clone() bug. The thing that changed to the version posted earlier is only the drawItem() method. Here is the fixed version:
Fixed the PlotOrientation problem in XYShapeRenderer. Didn't fix the clone() bug. The thing that changed to the version posted earlier is only the drawItem() method. Here is the fixed version:
Code: Select all
public void drawItem(Graphics2D g2, XYItemRendererState state,
Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot,
ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset,
int series, int item, CrosshairState crosshairState, int pass)
{
Shape entityArea = null;
EntityCollection entities = null;
if (info != null) {
entities = info.getOwner().getEntityCollection();
}
if (dataset.getX(series, item) == null || dataset.getY(series, item) == null)
// cannot draw anything.
return;
double x = dataset.getXValue(series, item);
double y = dataset.getYValue(series, item);
double z = 0.0;
if (dataset instanceof XYZDataset) {
z = ((XYZDataset) dataset).getZValue(series, item);
}
Paint p = this.paintScale.getPaint(z);
Double xx0 = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge());
Double yy0 = rangeAxis.valueToJava2D(y, dataArea, plot.getRangeAxisEdge());
Shape drawShape;
Rectangle2D bounds = getSeriesShape(series).getBounds2D();
if (plot.getOrientation().equals(PlotOrientation.HORIZONTAL)) {
drawShape = ShapeUtilities.createTranslatedShape(getSeriesShape(series), yy0 - bounds.getWidth() / 2, xx0 - bounds.getHeight() / 2);
drawShape = ShapeUtilities.rotateShape(drawShape, Math.PI / 2, yy0.floatValue(), xx0.floatValue());
}
else {
drawShape = ShapeUtilities.createTranslatedShape(getSeriesShape(series), xx0 - bounds.getWidth() / 2, yy0 - bounds.getHeight() / 2);
}
entityArea = drawShape;
g2.setPaint(p);
g2.fill(drawShape);
g2.setStroke(new BasicStroke());
g2.setPaint(Color.gray);
g2.draw(drawShape);
// add an entity for the item...
if (entities != null) {
addEntity(entities, entityArea, dataset, series, item, xx0, yy0);
}
}
-
- Posts: 3
- Joined: Tue Sep 11, 2007 10:18 pm
- Location: Portland, OR
- Contact:
Has anyone tried this out?
I recently implemented a historical flight performance reporting tool using Jasper, JFreeChart, and OpenReports. I would like to add a new Geographic chart type which will display flight delays at airports around the globe. I have latitude/longitude for all the airports that I want to map. From reading this thread, it sounds like this is all still very new. I am wondering if anyone has tried it for a similar need and how it worked?
Thanks!
-Carl
Thanks!
-Carl
Some time ago I posted some code to this forum but it seems it didn't make into JFreeChart till now 
You can have a look at what we achieved with JFreeChart and the new geo-charts at http://www.numbis.at/messwerte/ (sorry, the page is only available in German).
If you are interessted I can make the latest version of our added JFreeChart classes available. Let me know.
hth,
- martin

You can have a look at what we achieved with JFreeChart and the new geo-charts at http://www.numbis.at/messwerte/ (sorry, the page is only available in German).
If you are interessted I can make the latest version of our added JFreeChart classes available. Let me know.
hth,
- martin
-
- Posts: 3
- Joined: Tue Sep 11, 2007 10:18 pm
- Location: Portland, OR
- Contact:
Yes...
Please make available your latest code - I would like to spend a day or two giving it a try. I wonder how well it will work with a much larger map (i.e. all of North America, or all of Europe). Thanks Martin!
Geochart Extension 0.2 available
Hi all!
The source code and a packaged version of the geochart extension are available for download at http://www.xss.co.at/~martin/jfreechart/
(use the 0.2 version!)
For a simple test call
and make sure the following JARs are in your classpath:
Feedback is welcome!
hth,
- martin
The source code and a packaged version of the geochart extension are available for download at http://www.xss.co.at/~martin/jfreechart/
(use the 0.2 version!)
For a simple test call
Code: Select all
java at.co.xss.jfree.sample.Example
- jfreechart-1.0.4.jar
jfreechart-experimental-1.0.4.jar
jcommon-1.0.8.jar
jfree-geo-0.2.jar
Feedback is welcome!
hth,
- martin
-
- Posts: 3
- Joined: Tue Sep 11, 2007 10:18 pm
- Location: Portland, OR
- Contact:
Implemented with large-scale maps
Thanks Martin, Dave, and all who contributed!
I would like to share with you the charts I have created using this code, modified slightly to accomodate large-scale maps.
As expected, the linear calculations of 2D points in XYShapeRenderer.drawItem() did not work well with a map of the entire United States. Latitude and longitude are 3-dimensional coordinates (earth is round), and 2D maps are stretched flat using complex mathematical equations known as "projections". The most common projection is the Mercator Projection. These 2D maps tend to exaggerate the size of objects closer to the poles. As a result, the linear calculations caused my plotted points to become increasingly distorted as they got further away from the equator (in this case North).
I found a way to correct this problem by using JH Labs' Java Map Projection Library (a partial java port of the PROJ.4 library). It can be found here: http://www.jhlabs.com/java/maps/proj/
Once I hooked up the code to call the Mercator projection transformation in PROJ.4, everything worked great. I transformed the top left & bottom right boundaries as well as all the points I wished to plot. Then ran the original linear calculations to get the exact plot coordinates.
Here is a snippet from my modified XYShapeRenderer.java -> drawItem():
double minLat = 22.86;
double maxLat = 50.8;
double minLong = -128.4;
double maxLong = -59.7;
Projection proj = new MercatorProjection();
proj.setMinLatitude(minLat);
proj.setMaxLatitude(maxLat);
proj.setMinLongitude(minLong);
proj.setMaxLongitude(maxLong);
proj.setEllipsoid(Ellipsoid.WGS_1984);
proj.initialize();
Point2D.Double t = new Point2D.Double();
t = proj.transform(new Point2D.Double(x, y), t);
Double xx0 = domainAxis.valueToJava2D(t.getX(), dataArea,
plot.getDomainAxisEdge());
Double yy0 = rangeAxis.valueToJava2D(t.getY(), dataArea,
plot.getRangeAxisEdge());
I have 2 images I would like to post here to show you my results. One is before I ran the PROJ.4 conversions and one is after. I don't have a web server to throw these up on. If someone could let me know the best way to post these images here that would be great.
Thanks again for everyone's contributions. I think this would make a great addition to a future version of JFreeChart.
-Carl Goebel
Portland, OR
[/img]
I would like to share with you the charts I have created using this code, modified slightly to accomodate large-scale maps.
As expected, the linear calculations of 2D points in XYShapeRenderer.drawItem() did not work well with a map of the entire United States. Latitude and longitude are 3-dimensional coordinates (earth is round), and 2D maps are stretched flat using complex mathematical equations known as "projections". The most common projection is the Mercator Projection. These 2D maps tend to exaggerate the size of objects closer to the poles. As a result, the linear calculations caused my plotted points to become increasingly distorted as they got further away from the equator (in this case North).
I found a way to correct this problem by using JH Labs' Java Map Projection Library (a partial java port of the PROJ.4 library). It can be found here: http://www.jhlabs.com/java/maps/proj/
Once I hooked up the code to call the Mercator projection transformation in PROJ.4, everything worked great. I transformed the top left & bottom right boundaries as well as all the points I wished to plot. Then ran the original linear calculations to get the exact plot coordinates.
Here is a snippet from my modified XYShapeRenderer.java -> drawItem():
double minLat = 22.86;
double maxLat = 50.8;
double minLong = -128.4;
double maxLong = -59.7;
Projection proj = new MercatorProjection();
proj.setMinLatitude(minLat);
proj.setMaxLatitude(maxLat);
proj.setMinLongitude(minLong);
proj.setMaxLongitude(maxLong);
proj.setEllipsoid(Ellipsoid.WGS_1984);
proj.initialize();
Point2D.Double t = new Point2D.Double();
t = proj.transform(new Point2D.Double(x, y), t);
Double xx0 = domainAxis.valueToJava2D(t.getX(), dataArea,
plot.getDomainAxisEdge());
Double yy0 = rangeAxis.valueToJava2D(t.getY(), dataArea,
plot.getRangeAxisEdge());
I have 2 images I would like to post here to show you my results. One is before I ran the PROJ.4 conversions and one is after. I don't have a web server to throw these up on. If someone could let me know the best way to post these images here that would be great.
Thanks again for everyone's contributions. I think this would make a great addition to a future version of JFreeChart.
-Carl Goebel
Portland, OR
[/img]
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
If you e-mail me the images (david.gilbert@object-refinery.com) I'll upload them to jfree.org and display them here.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Here's the images:
BEFORE PROJECTION:

AFTER PROJECTION:

BEFORE PROJECTION:
AFTER PROJECTION:
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Nice charts, by the way! I'm trying really hard to get 1.0.7 out the door, but lets try to schedule this stuff for inclusion in 1.0.8 before the end of the year.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- Posts: 36
- Joined: Thu Apr 12, 2007 6:54 am
Geo plotting
Martin,
have you continued progress on this? I started a simliar tack, extending an XYDataset, I really only need 2D for starters to do lat/longs, as either decimal or minutes/seconds and draw a simple XYPlot over a chart image background w/ an anchor value lat/long. The plot has no axes and I was using the XYLineAndShapeRenderer and XYImageAnnotations to put up icons, shapes or lines at various locations.
If this is similar to what you've already done, maybe we could put it together?
thanks,
andrew
have you continued progress on this? I started a simliar tack, extending an XYDataset, I really only need 2D for starters to do lat/longs, as either decimal or minutes/seconds and draw a simple XYPlot over a chart image background w/ an anchor value lat/long. The plot has no axes and I was using the XYLineAndShapeRenderer and XYImageAnnotations to put up icons, shapes or lines at various locations.
If this is similar to what you've already done, maybe we could put it together?
thanks,
andrew
Hi Andrew!
What I've done so far on this topic is documented in this thread and the code is available for download. You can also see some charts at http://www.numbis.at/. See previous posts for more details.
David wrote in a post that he has plans to integrate some of this work after the release of 1.0.7. If help is needed for this I'll do what I can. But for the moment my enhancement fulfills my requirements and I don't have the time to investigate any further, sorry.
best regards and good luck,
- martin
What I've done so far on this topic is documented in this thread and the code is available for download. You can also see some charts at http://www.numbis.at/. See previous posts for more details.
David wrote in a post that he has plans to integrate some of this work after the release of 1.0.7. If help is needed for this I'll do what I can. But for the moment my enhancement fulfills my requirements and I don't have the time to investigate any further, sorry.
best regards and good luck,
- martin
jfree-geo-0.2.jar
I cant find jfree-geo-0.2.jar
where do i download it from
where do i download it from