| From | Sent On | Attachments |
|---|---|---|
| Curtis Stanford | Feb 26, 2008 11:59 am | |
| Chris Campbell | Mar 10, 2008 11:39 am |
| Subject: | Re: Bug with translation | |
|---|---|---|
| From: | Chris Campbell (Chri...@Sun.COM) | |
| Date: | Mar 10, 2008 11:39:30 am | |
| List: | net.java.dev.scenegraph.users | |
Hi Curtis,
Are you able to reproduce this bug with the latest sources from trunk (and if so, which platform and JDK version)? I'm not able to reproduce, and I'm thinking it may have been fixed recently as part of some changes to the way we accumulate stroke bounds.
Thanks, Chris
On Feb 26, 2008, at 11:59 AM, Curtis Stanford wrote:
I think I'm seeing a bug when I create a simple shape and drag it with the mouse. If the stroke width is set to 2, it leaves turds behind as it's moving. If I change the stroke width to something higher or lower than 2, it works OK.
Sample code:
package scenegraph;
import java.awt.*; import java.awt.event.*; import java.awt.geom.*;
import javax.swing.*;
import com.sun.scenario.animation.Clip; import com.sun.scenario.scenegraph.*; import com.sun.scenario.scenegraph.SGAbstractShape.Mode; import com.sun.scenario.scenegraph.event.SGMouseListener;
public class test1 extends JFrame implements SGMouseListener { private static final long serialVersionUID = 1L;
private Point save;
public test1() { super("SG Test"); Panel p0 = new Panel(new BorderLayout()); JButton b = new JButton("DOIT"); p0.add(b, BorderLayout.NORTH); final JSGPanel p = new JSGPanel(); p.setBackground(Color.white); final SGGroup g = new SGGroup(); SGShape s = new SGShape(); final Rectangle2D r = new Rectangle2D.Double(0, 0, 100, 100); s.setShape(r); s.setAntialiasingHint(RenderingHints.VALUE_ANTIALIAS_ON); s.setDrawPaint(Color.blue); s.setDrawStroke(new BasicStroke(2f)); s.setFillPaint(Color.red); s.setMode(Mode.STROKE_FILL); final Ellipse2D e = new Ellipse2D.Double(0, 0, 100, 100); SGShape s2 = new SGShape(); s2.setShape(e); s2.setAntialiasingHint(RenderingHints.VALUE_ANTIALIAS_ON); s2.setDrawPaint(Color.green); s2.setDrawStroke(new BasicStroke(2f)); s2.setFillPaint(Color.blue); s2.setMode(Mode.STROKE_FILL); final SGComposite c2 = new SGComposite(); c2.setOpacity(1f); SGTransform t = SGTransform.createTranslation(0, 0, s); t.addMouseListener(this); c2.setChild(t); final SGComposite c1 = new SGComposite(); c1.setOpacity(1f); SGTransform t2 = SGTransform.createTranslation(0, 0, s2); t2.addMouseListener(this); c1.setChild(t2); g.add(c2); g.add(c1); p.setScene(g); JScrollPane sp = new JScrollPane(p); p0.add(sp, BorderLayout.CENTER); setContentPane(p0); pack(); setLocationRelativeTo(null); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Clip.create(2000, c1, "opacity", 1f, 0.5f).start(); Clip.create(2000, c2, "opacity", 0.2f, 1f).start(); } }); }
public void mouseEntered(MouseEvent e, SGNode node) { }
public void mouseExited(MouseEvent e, SGNode node) { }
public void mouseMoved(MouseEvent e, SGNode node) { }
public void mouseReleased(MouseEvent e, SGNode node) { }
public void mouseWheelMoved(MouseWheelEvent e, SGNode node) { }
public void mouseClicked(MouseEvent e, SGNode node) { // node.getParent().remove(node); // g.add(node); }
public void mouseDragged(MouseEvent e, SGNode node) { if (node instanceof SGTransform.Translate) { SGTransform.Translate st = (SGTransform.Translate)node; st.translateBy(e.getX() - save.x, e.getY() - save.y); save = e.getPoint(); } }
public void mousePressed(MouseEvent e, SGNode node) { save = e.getPoint(); }
public static void main(String[] args) { test1 t1 = new test1(); t1.setVisible(true); } }





