Hi,

both implementations are identical.  But both require an overlap.
(the current implementation is horrible though)

If touching suffices for intersection, then try this:
public  boolean intersects(double bLo, double bHi) {
    return (bLo <= bHi && bLo <= this.upper && bHi >= this.lower);
}

(The essential difference being the addition of 2 "=" signs)

Best regards,
DaveLaw

P.S. "wrong" is an adjective or noun.
Unless your name is Beckham, you need an adverb:
"Intersections of ranges are calculated incorrectly"

On 11/06/2012 21:45, SourceForge.net wrote:
Bugs item #3500396, was opened at 2012-03-09 03:16
Message generated for change (Comment added) made by matinh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=115494&aid=3500396&group_id=15494

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General
Group: None
Status: Closed
Resolution: Works For Me
Priority: 5
Private: No
Submitted By: Jimmy Merrild Krag (beruic)
Assigned to: Nobody/Anonymous (nobody)
Summary: Intersections of ranges are calculated wrong.

Initial Comment:
During excercises in a course in testing and veriication I discovered that intersections of ranges are checked wrongly in JFreeChart.
This working set, we are working with can be found at http://ge.tt/6FORJmE/v/0?c
I browsed your current trunk code online, and asserted that
 - The unit tests are still the same (trunk/tests/org/jfree/data/junit/RangeTests.java)
 - The implementation is still the same (trunk/source/org/jfree/data/Range.java)
I also checked out the current code, and tried to run the unittest

In org/jfree/data/Range.java, the implementation of the "intersects" function is currently:

    public boolean intersects(double b0, double b1) {
        if (b0 <= this.lower) {
            return (b1 > this.lower);
        }
        else {
            return (b0 < this.upper && b1 >= b0);
        }
    }

But should rather be 

    public boolean intersects(double b0, double b1) {
        return (b0 <= b1 && this.lower < b1 && b0 < this.upper);
    }

I made this implementation according to the unit tests in trunk/tests/org/jfree/data/junit/RangeTests.java, as well as some additional ones in src/org/jfree/data/RangeTests.java in the aforementioned working set.


----------------------------------------------------------------------

Comment By: Martin Höller (matinh)
Date: 2012-06-11 12:45

Message:
Hi again and sorry for the delay.

Just had a look at your modified method and the additional tests. I can't
see any problem with the existing implementation (and neither with your
implementation). All tests run fine, the test coverage should be 100% and
the tests look ok to me.

If you still feel the current implementation is broken please provide a
failing unit test.

Thanks,
- martin

----------------------------------------------------------------------

Comment By: Jimmy Merrild Krag (beruic)
Date: 2012-03-20 17:17

Message:
I'm not usually programming Java, and I'm not sure I opened the checked out
code the right way, and I have no idea of what you mean by 'a locale of
"C"'.

----------------------------------------------------------------------

Comment By: Martin Höller (matinh)
Date: 2012-03-12 14:35

Message:
Thanks for the report. I'll have a look at it soon.
What was your problem with the unit tests? They should run fine with a
locale of "C".


----------------------------------------------------------------------

Comment By: Jimmy Merrild Krag (beruic)
Date: 2012-03-09 03:20

Message:
Addition:
The line "I also checked out the current code, and tried to run the
unittest" should read "I also checked out the current code, and tried to
run the unit test here to be sure, but was unable to."

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=115494&aid=3500396&group_id=15494

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
jfreechart-developers mailing list
jfreechart-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jfreechart-developers