Hi,
There is an alternative to the mouse point rectangle. Create special sense
shapes with a somewhat thicker stroke and test if that sense shape contains the
mouse point. I don't know which solution is better. I changed your code to
demonstrate. (I took the liberty to set a cross hair cursor
Well, I was able to achive something that I need:
[code]
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
@SuppressWarnings(serial)
public class MouseOverShapes extends JComponent {
private Shape line;
private Shape arc;
private boolean overLine;
First, note what the API doc says about setClip(Shape clip):
[b]Not all objects that implement the Shape interface can be used to set the
clip. The only Shape objects that are guaranteed to be supported are Shape
objects that are obtained via the getClip method and via Rectangle objects.[/b]
The code below gives no indication of what could cause
intermittent problems.
If its a problem in both copying to the clipboard and
printing its seems likely to be a general bug in your code.
I guess you are drawing to an image.
Perhaps you have an inappropriate use of multiple threads
and you
jav...@javadesktop.org wrote:
First, note what the API doc says about setClip(Shape clip):
[b]Not all objects that implement the Shape interface can be used to set the clip. The only Shape objects that are guaranteed to be supported are Shape objects that are obtained via the getClip method and
The BasicStroke.createStrokedShape() is the intended method to test for
intersection with the stroked shape as you implemented in your later
example. Note that the default graphics setting for the STROKE_CONTROL
hint is STROKE_NORMALIZE which allows tweaking of lines for aesthetic
purposes
Note that, in Java 2D, a shape cannot know its outline design because
that depends on another graphics attribute - the Stroke object. The
default implementation of that interface is a BasicStroke object with a
line width of 1.0f, but that is just the default for the Graphics
objects you get