Line2D.Double line = new Line2D.Double(x1,y1,x2,y2); Ellipse2D.Double ellipse = new Ellipse2D.Double(x,y,width,height); int resolution = 1000; int x_distance = ellipse.getWidth()/2; int y_distance = ellipse.getHeight()/2; double angle = 360.0/(double)resolution; Point center = new Point(width/2,height/2); Point point = new Point(); for (int index = 0; index < resolution; index++) { int x = (center.x+x_distance)*Math.sin(Math.toRadians(angle*index))); int y = (center.y+y_distance)*Math.cos(Math.toRadians(angle*index))); Ellipse2D.Double dot = new Ellipse2D.Double(x,y,1,1); if (line.intersects(dot.getBounds())) { point.setLocation(x,y); index = resolution; } }
myEllipse.setFrame( myEllipse.getX()+1, myEllipse.getY()+1, myEllipse.getWidth(), myEllipse.getHeight()); //Move 1 x-pixel and 1 y-pixel every 50 milliseconds repaint();
rois.addElement(r); } else if (shape instanceof Ellipse2D.Double) { Roi r = new OvalRoi((int)((Ellipse2D.Double)shape).getX(), (int)((Ellipse2D.Double)shape).getY(), (int)((Ellipse2D.Double)shape).getWidth(), (int)((Ellipse2D.Double)shape).getHeight()); rois.addElement(r); } else if (shape instanceof Line2D.Double) {
rois.addElement(r); } else if (shape instanceof Ellipse2D.Double) { Roi r = new OvalRoi((int)((Ellipse2D.Double)shape).getX(), (int)((Ellipse2D.Double)shape).getY(), (int)((Ellipse2D.Double)shape).getWidth(), (int)((Ellipse2D.Double)shape).getHeight()); rois.addElement(r); } else if (shape instanceof Line2D.Double) {
public double getHeight() { return ellipse.getHeight(); }
public double getHeight() { return ellipse.getHeight(); }