I am working on a geometry program where I need to draw 'infinite' lines. My class Line has a method
public void draw(Graphics2D g){
//... calculate x1,y1,x2,y2 here ...
g.draw(new Line2D.Double(x1,y1, x2,y2));
}
My idea is to choose the coordinates large enough so they will be off the visible surface. But I don't know, and this is my question, how do I know the coordinates of the corners of the visible surface? Graphic's method getClip() sounded nice, but apparently it only returns a custom clip the user set before. Apparently what I need is called 'device clip' in the docs.
And before you suggest a big length, like 10000, I don't mean pixel size here. I use transforms for zooming and translating and such, so 10000 might well be visible.
edit: I just wanted to tell you what I ended up doing: I defined a reasonably large constants for maximum screen width and height (they might need adjusting in 10 years), then I apply the inverse of my current display transformation to this 'screen' to know the necessary length of my 'infinite' lines. I.e. the problem is not solved, only confined to a single spot in the code.