I know I have asked this question in the past and have gotten some answers, but I am still stumped as to how to change the XYSeries code so that it does not sort. Someone mentioned this:
Look at the line 139 of XYSeries.java.
It returns the index where the "pair" object is going to be inserted in the already sorted "data" list.
// make the change (if it's not a duplicate time period)...
int index = Collections.binarySearch(data, pair);
but I don't see how this sorts that data. I really need to change this to get my graphs to look the way the user wants them to look.
I think I could figure out how to make a jar file and compile this after it is changed, but then how can I make sure that the XYSeries.class is not used from the jfreechart*.jar? I think I need other stuff from the jfreechart*.jar so I can't just not use it. Any ideas?
Thanks.
Allyson
XYSeries and XYSeriesCollection
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: XYSeries and XYSeriesCollection
The binarySearch method either returns the index of the item, or a negative value that indicates the position that the item should take in order to maintain the sort order (refer to the JDK Javadocs for details).Allyson Gwin wrote:// make the change (if it's not a duplicate time period)...
int index = Collections.binarySearch(data, pair);
but I don't see how this sorts that data. I really need to change this to get my graphs to look the way the user wants them to look.
If you don't want sorting, then you could just ignore the index and add the item to the end of the list. You might want to scan the rest of the code to see if anything else relies on the sort order.
Regards,
Dave Gilbert
Re: XYSeries and XYSeriesCollection
I commented out the code below:
public void add(XYDataPair pair) throws SeriesException {
// check arguments...
if (pair == null) {
throw new IllegalArgumentException("XYSeries.add(...): null item not allowed.");
}
// make the change (if it's not a duplicate x-value)...
// int index = Collections.binarySearch(data, pair); commented out by ajg on mar 17, 2003
// if (index < 0) { commented out by ajg on mar 17, 2003
// data.add(-index - 1, pair); commented out by ajg on mar 17, 2003
// fireSeriesChanged(); commented out by ajg on mar 17, 2003
// } commented out by ajg on mar 17, 2003
// else { commented out by ajg on mar 17, 2003
if (allowDuplicateXValues == true) {
data.add(index, pair);
fireSeriesChanged();
}
else {
throw new SeriesException("XYSeries.add(...): x-value already exists.");
}
// } commente out by ajg on mar 17, 2003
}
I think this should work to remove the index. Now, I should compile it and put it in it's own jar file? I still need to use jfreechart-0.9.4.jar for other things so how do I get the program to ignore the XYSeries.class that is in the jfreechart-0.9.4.jar? I hope I don't need to recompile everything else and put it in another jar file. Thanks.
Allyson
public void add(XYDataPair pair) throws SeriesException {
// check arguments...
if (pair == null) {
throw new IllegalArgumentException("XYSeries.add(...): null item not allowed.");
}
// make the change (if it's not a duplicate x-value)...
// int index = Collections.binarySearch(data, pair); commented out by ajg on mar 17, 2003
// if (index < 0) { commented out by ajg on mar 17, 2003
// data.add(-index - 1, pair); commented out by ajg on mar 17, 2003
// fireSeriesChanged(); commented out by ajg on mar 17, 2003
// } commented out by ajg on mar 17, 2003
// else { commented out by ajg on mar 17, 2003
if (allowDuplicateXValues == true) {
data.add(index, pair);
fireSeriesChanged();
}
else {
throw new SeriesException("XYSeries.add(...): x-value already exists.");
}
// } commente out by ajg on mar 17, 2003
}
I think this should work to remove the index. Now, I should compile it and put it in it's own jar file? I still need to use jfreechart-0.9.4.jar for other things so how do I get the program to ignore the XYSeries.class that is in the jfreechart-0.9.4.jar? I hope I don't need to recompile everything else and put it in another jar file. Thanks.
Allyson
Re: XYSeries and XYSeriesCollection
I recompiled XYSeries and now I have XYSeries.class. How can I use this instead of the XYSeries.class that is in the jfreechart-0.9.4.jar? Thanks.
Allyson
Allyson
Re: XYSeries and XYSeriesCollection
It seems as if I often find myself experimenting with small changes to JFreeChart code. There are two things I do:ajgwin wrote:I recompiled XYSeries and now I have XYSeries.class. How can I use this instead of the XYSeries.class that is in the jfreechart-0.9.4.jar? Thanks.
Allyson
(1) always compile with javac's "-d classes" option - keeps my source directory from being cluttered up with classfiles, instead they go into a subdirectory below my source path called "classes". If you don't remove the "package" statement from "your" version of XYSseries, this will put the classfile in
classes/com/jrefinery/data/XYseries.class
(2) Arrange my CLASSPATH so that "my" paths are checked before the JFreeChart jar-files:
set CLASSPATH=./:./classes:jfreechart-0/9/6.jar:<etc...>:$CLASSPATH
In this way, "my" version(s) are found before - and instead of - those in the JFreeChart jar's.
Re: XYSeries and XYSeriesCollection
[quote="ajgwin"]I recompiled XYSeries and now I have XYSeries.class. How can I use this instead of the XYSeries.class that is in the jfreechart-0.9.4.jar? Thanks.
Allyson[/quote]
It seems as if I often find myself experimenting with small changes to JFreeChart code. There are two things I do:
(1) always compile with javac's "-d classes" option - keeps my source directory from being cluttered up with classfiles, instead they go into a subdirectory below my source path called "classes". If you don't remove the "package" statement from "your" version of XYSseries, this will put the classfile in
classes/com/jrefinery/data/XYseries.class
(2) Arrange my CLASSPATH so that "my" paths are checked before the JFreeChart jar-files:
set CLASSPATH=./:./classes:jfreechart-0/9/6.jar:<etc...>:$CLASSPATH
In this way, "my" version(s) are found before - and instead of - those in the JFreeChart jar's.
Allyson[/quote]
It seems as if I often find myself experimenting with small changes to JFreeChart code. There are two things I do:
(1) always compile with javac's "-d classes" option - keeps my source directory from being cluttered up with classfiles, instead they go into a subdirectory below my source path called "classes". If you don't remove the "package" statement from "your" version of XYSseries, this will put the classfile in
classes/com/jrefinery/data/XYseries.class
(2) Arrange my CLASSPATH so that "my" paths are checked before the JFreeChart jar-files:
set CLASSPATH=./:./classes:jfreechart-0/9/6.jar:<etc...>:$CLASSPATH
In this way, "my" version(s) are found before - and instead of - those in the JFreeChart jar's.
XYSeries and XYSeriesCollection
Alison:
It seems as if I often find myself experimenting with small changes to JFreeChart code. There are two things I do:
(1) always compile with javac's "-d classes" option - keeps my source directory from being cluttered up with classfiles, instead they go into a subdirectory below my source path called "classes". If you don't remove the "package" statement from "your" version of XYSseries, this will put the classfile in
classes/com/jrefinery/data/XYseries.class
(2) Arrange my CLASSPATH so that "my" paths are checked before the JFreeChart jar-files:
set CLASSPATH=./:./classes:jfreechart-0/9/6.jar:<etc...>:$CLASSPATH
In this way, "my" version(s) are found before - and instead of - those in the JFreeChart jar's.
It seems as if I often find myself experimenting with small changes to JFreeChart code. There are two things I do:
(1) always compile with javac's "-d classes" option - keeps my source directory from being cluttered up with classfiles, instead they go into a subdirectory below my source path called "classes". If you don't remove the "package" statement from "your" version of XYSseries, this will put the classfile in
classes/com/jrefinery/data/XYseries.class
(2) Arrange my CLASSPATH so that "my" paths are checked before the JFreeChart jar-files:
set CLASSPATH=./:./classes:jfreechart-0/9/6.jar:<etc...>:$CLASSPATH
In this way, "my" version(s) are found before - and instead of - those in the JFreeChart jar's.
Re: XYSeries and XYSeriesCollection
Thank you, thank you, thank you. I finally got it to work. I want to thank everyone for all their help. It all helped and I now have the sorting removed. Phew! Thanks again.
Allyson
Allyson