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


Re: jfree-geo-0.2.jar
From the address mentioned above:vidyacho wrote:I cant find jfree-geo-0.2.jar
where do i download it from
http://www.xss.co.at/~martin/jfreechart/
And note that either jfreechart 1.0.4 is required or you have to modify some sources (some classes moved from experimental to the standard package).
Please read the posts before asking. Thanks.
- martin
New version jfree-geo 0.3 available
Hi!
To bring this topic up again (now that 1.0.[78] is released), I ported the jfree-geo extension to the newest versions of JFreeChart. It now runs at least with JFreeChart 1.0.7 and 1.0.8. For instructions on how to run the provided example see previous posts in this thread.
jfree-geo 0.3 is now available for download from http://www.xss.co.at/~martin/jfreechart/.
David, if this could be integrated into the next version of JFreeChart I would be really happy! If you need any help, please let me know.
Comments are welcome.
- martin
To bring this topic up again (now that 1.0.[78] is released), I ported the jfree-geo extension to the newest versions of JFreeChart. It now runs at least with JFreeChart 1.0.7 and 1.0.8. For instructions on how to run the provided example see previous posts in this thread.
jfree-geo 0.3 is now available for download from http://www.xss.co.at/~martin/jfreechart/.
David, if this could be integrated into the next version of JFreeChart I would be really happy! If you need any help, please let me know.
Comments are welcome.
- martin
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Thanks. I *almost* put it into 1.0.7, then decided to do a little more review of it. I think it should go into 1.0.9 in the next two weeks...let's try anyway!
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:
Hi Martin,matinh wrote:Hi David!
It seems this enhancement is still not in 1.0.10. Any reason for this? Could you please let us know what the status is?
many thanks in advance,
- martin
Sorry! Thanks for the reminder. The first half of this year was very disrupted for me, so I forgot a few things. Let me go through your code again right away, and try to make this the main feature in the 1.0.11 release later this month.
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:
OK, I have modified your code so that it compiles and runs on JDK 1.3 (a requirement for inclusion in JFreeChart 1.0.x. JRE 1.3 support isn't such a big deal anymore, but 1.4 is for quite a few people still). It looks good so far.
One question I have: is the map image you included redistributable? Or do you know a good source of free (as in freely redistributable) map images? I am doing some work with vector maps at the moment, so I can probably put together a demo that uses these (I have some public domain map sources I'm working with).
I'm also thinking of modifying the XYShapeRenderer so that it fills shapes using the seriesFillPaint when it meets an XYDataset, but uses the PaintScale when it meets an XYZDataset...that would make it just a little more general than the existing version.
And I'm writing some unit tests to make sure that the classes meet the usual equals, clone and serialization requirements for JFreeChart.
I will report on progress again next week...
One question I have: is the map image you included redistributable? Or do you know a good source of free (as in freely redistributable) map images? I am doing some work with vector maps at the moment, so I can probably put together a demo that uses these (I have some public domain map sources I'm working with).
I'm also thinking of modifying the XYShapeRenderer so that it fills shapes using the seriesFillPaint when it meets an XYDataset, but uses the PaintScale when it meets an XYZDataset...that would make it just a little more general than the existing version.
And I'm writing some unit tests to make sure that the classes meet the usual equals, clone and serialization requirements for JFreeChart.
I will report on progress again next week...
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Hi David!
This sounds great! Thanks a lot!
best regards,
- martin
This sounds great! Thanks a lot!
Good question. Probably not. I took it from Google, so it's available for everone but probably not free.david.gilbert wrote:One question I have: is the map image you included redistributable?
You could eventually try http://www.openstreetmap.org/.david.gilbert wrote: Or do you know a good source of free (as in freely redistributable) map images?
Good idea, this sounds rather useful to me.david.gilbert wrote:I'm also thinking of modifying the XYShapeRenderer so that it fills shapes using the seriesFillPaint when it meets an XYDataset, but uses the PaintScale when it meets an XYZDataset...that would make it just a little more general than the existing version.
Looking forward to this!david.gilbert wrote:I will report on progress again next week...
best regards,
- martin
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Aaargggghhh!!!
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:
Just so you know I am looking at this still, here is the image annotation that "fits" the image within a rectangle specified in data coordinates. You can use this to display a map in the background of a chart, and when the axis ranges are changed (a la zooming) the map adjusts. Of course, zoom in too far and you see the disadvantage of an image (pixels) versus a vector format (but I am looking at that also).
Code: Select all
/* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2008, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* --------------------------
* XYDataImageAnnotation.java
* --------------------------
* (C) Copyright 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes:
* --------
* 08-Sep-2008 : Version 1, based on XYImageAnnotation (DG);
*/
package org.jfree.chart.annotations;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import org.jfree.chart.axis.AxisLocation;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.PlotRenderingInfo;
import org.jfree.chart.plot.XYPlot;
import org.jfree.ui.RectangleEdge;
import org.jfree.util.ObjectUtilities;
import org.jfree.util.PublicCloneable;
/**
* An annotation that allows an image to be placed within a rectangle specified
* in data coordinates on an {@link XYPlot}.
*
* @since 1.0.11
*/
public class XYDataImageAnnotation extends AbstractXYAnnotation
implements Cloneable, PublicCloneable, Serializable {
/** For serialization. */
private static final long serialVersionUID = 0; // TODO: Calculate this
/** The image. */
private transient Image image;
/**
* The x-coordinate (in data space).
*/
private double x;
/**
* The y-coordinate (in data space).
*/
private double y;
private double w;
private double h;
/**
* Creates a new annotation to be displayed within the specified rectangle.
*
* @param image the image (<code>null</code> not permitted).
* @param x the x-coordinate (in data space).
* @param y the y-coordinate (in data space).
* @param w the rectangle width.
* @param h the rectangle height.
*/
public XYDataImageAnnotation(Image image, double x, double y, double w,
double h) {
if (image == null) {
throw new IllegalArgumentException("Null 'image' argument.");
}
this.image = image;
this.x = x;
this.y = y;
this.w = w;
this.h = h;
}
/**
* Returns the image for the annotation.
*
* @return The image.
*/
public Image getImage() {
return this.image;
}
/**
* Returns the x-coordinate (in data space) for the annotation.
*
* @return The x-coordinate.
*/
public double getX() {
return this.x;
}
/**
* Returns the y-coordinate (in data space) for the annotation.
*
* @return The y-coordinate.
*/
public double getY() {
return this.y;
}
/**
* Returns the width of the data rectangle into which the image will be
* drawn.
*
* @return The width.
*/
public double getWidth() {
return this.w;
}
/**
* Returns the height of the data rectangle into which the image will be
* drawn.
*
* @return The height.
*/
public double getHeight() {
return this.h;
}
/**
* Draws the annotation. This method is called by the drawing code in the
* {@link XYPlot} class, you don't normally need to call this method
* directly.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param dataArea the data area.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
* @param rendererIndex the renderer index.
* @param info if supplied, this info object will be populated with
* entity information.
*/
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
ValueAxis domainAxis, ValueAxis rangeAxis,
int rendererIndex,
PlotRenderingInfo info) {
PlotOrientation orientation = plot.getOrientation();
AxisLocation xAxisLocation = plot.getDomainAxisLocation();
AxisLocation yAxisLocation = plot.getRangeAxisLocation();
RectangleEdge xEdge = Plot.resolveDomainAxisLocation(xAxisLocation,
orientation);
RectangleEdge yEdge = Plot.resolveRangeAxisLocation(yAxisLocation,
orientation);
float j2DX0 = (float) domainAxis.valueToJava2D(this.x, dataArea, xEdge);
float j2DY0 = (float) rangeAxis.valueToJava2D(this.y, dataArea, yEdge);
float j2DX1 = (float) domainAxis.valueToJava2D(this.x + this.w,
dataArea, xEdge);
float j2DY1 = (float) rangeAxis.valueToJava2D(this.y + this.h,
dataArea, yEdge);
float xx0 = 0.0f;
float yy0 = 0.0f;
float xx1 = 0.0f;
float yy1 = 0.0f;
if (orientation == PlotOrientation.HORIZONTAL) {
xx0 = j2DY0;
xx1 = j2DY1;
yy0 = j2DX0;
yy1 = j2DX1;
}
else if (orientation == PlotOrientation.VERTICAL) {
xx0 = j2DX0;
xx1 = j2DX1;
yy0 = j2DY0;
yy1 = j2DY1;
}
// TODO: rotate the image when drawn with horizontal orientation?
g2.drawImage(this.image, (int) xx0, (int) Math.min(yy0, yy1),
(int) (xx1 - xx0), (int) Math.abs(yy1 - yy0), null);
String toolTip = getToolTipText();
String url = getURL();
if (toolTip != null || url != null) {
addEntity(info, new Rectangle2D.Float(xx0, yy0, (xx1 - xx0),
(yy1 - yy0)), rendererIndex, toolTip, url);
}
}
/**
* Tests this object for equality with an arbitrary object.
*
* @param obj the object (<code>null</code> permitted).
*
* @return A boolean.
*/
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
// now try to reject equality...
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof XYDataImageAnnotation)) {
return false;
}
XYDataImageAnnotation that = (XYDataImageAnnotation) obj;
if (this.x != that.x) {
return false;
}
if (this.y != that.y) {
return false;
}
if (this.w != that.w) {
return false;
}
if (this.h != that.h) {
return false;
}
if (!ObjectUtilities.equal(this.image, that.image)) {
return false;
}
// seems to be the same...
return true;
}
/**
* Returns a hash code for this object.
*
* @return A hash code.
*/
public int hashCode() {
return this.image.hashCode();
}
/**
* Returns a clone of the annotation.
*
* @return A clone.
*
* @throws CloneNotSupportedException if the annotation can't be cloned.
*/
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
/**
* Provides serialization support.
*
* @param stream the output stream.
*
* @throws IOException if there is an I/O error.
*/
private void writeObject(ObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
//SerialUtilities.writeImage(this.image, stream);
}
/**
* Provides serialization support.
*
* @param stream the input stream.
*
* @throws IOException if there is an I/O error.
* @throws ClassNotFoundException if there is a classpath problem.
*/
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
//this.image = SerialUtilities.readImage(stream);
}
}
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:
Thanks. Where I got to on this is that I need/want to implement a plot that supports a constant ratio between the x and y axes...while that should be easy, it turns out to be tricky. I'd be working on it right now, but I have a couple of consulting assignments that need some changes done for the 1.0.13 release, so those are getting done first. It is something that is high on my interest list, even if it doesn't appear that way from the (lack of) progress.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

