Does Sierra change how java displays graphics?

Discussion in 'Mac Programming' started by jerwin, Sep 22, 2016.

Tags:
  1. jerwin macrumors 65816

    Joined:
    Jun 13, 2015
    #1
    For the past couple of years, I've been developing a Java Swing application-- basically a vector graphics program.

    I've been working on it both before and after installing MacOSX Sierra, and I've noticed that some of the behavior is a bit strange. The code I use to detect a mouse press on a shape doesn't seem that reliable anymore. The handling of image compositing seems different. Maybe I've been coding against a buggy JVM and have been expecting certain behavior, but it's driving me nuts.
     
  2. Sciuriware macrumors regular

    Sciuriware

    Joined:
    Jan 4, 2014
    Location:
    Gelderland
    #2
    Can you be more specific? Some remarks can hardly be related to Sierra, because it is a utility release, not a
    system update (although, that's what I read).
    ;JOOP!
     
  3. Sciuriware macrumors regular

    Sciuriware

    Joined:
    Jan 4, 2014
    Location:
    Gelderland
    #3
    I upgraded one of my iMacs to Sierra: no problems with JAVA 8-102 w.r.t Swing.
    Some other problems, but NOT JAVA-related.
    ;JOOP!
     
  4. jerwin thread starter macrumors 65816

    Joined:
    Jun 13, 2015
    #4
    Hmm.

    Let me see what I had to change.

    Here's my original code:

    The code is supposed to iterate through various shapes (all subclasses of class BasicPoint, which implements the Shape interface) that I've drawn on screen and add them to tree selection model, if the mouse is clicked on them.


    Code:
    public void mousePressed(MouseEvent e)
            {
               /* .... */
                    Graphics2D g2=(Graphics2D) getGraphics();
    
                    g2.setTransform(AffineTransform.getScaleInstance(scale, scale));
                   Point2D p=e.getPoint();
                    AffineTransform at=g2.getTransform();
                    try
                    {
                        at.inverseTransform(p, p);
                    } catch (NoninvertibleTransformException e1)
    
                    {
                    
                        e1.printStackTrace();
                    }
                    int x=(int) Math.round(p.getX());
                    int y=(int) Math.round(p.getY());
                    Rectangle r=new Rectangle(x-1,y-1, 3,3);
                    for(BasicPoint bp:pm)
                    {  
    if(g2.hit(r,bp,false))
      {      setSelectedPoint(bp);}
     }
    
    
    To get it to work, I had to change the "if(g2.hit(r,bp,false))" condition to "if(bp.intersects(r))"
     
  5. Sciuriware macrumors regular

    Sciuriware

    Joined:
    Jan 4, 2014
    Location:
    Gelderland
    #5
    I'm using Swing and several of my programs use the same library classes and methods as yours,
    and those work as before. In my opinion this has nothing to do with Sierra.
    ;JOOP!
     
  6. okieiam macrumors newbie

    okieiam

    Joined:
    Dec 17, 2016
    #6
    I found thread management in osx is different than in windows and linux. If I put a thread in JavaFx scene like this thread.join(). Then that thread will not self terminate when close app, then app not terminate too
     
  7. Sciuriware macrumors regular

    Sciuriware

    Joined:
    Jan 4, 2014
    Location:
    Gelderland
    #7
    You should report this to ORACLE (bug): thread management should be transparently the same.

    Other observation: I switched from USB (wire) mouse to Magic Mouse 2 (accu, no batteries).
    Since then JAVA has intermittent trouble with double clicks and clicks into components other than buttons.
    ;JOOP!
     

Share This Page