Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Error when updating diagram with 'large' labels on Links (Read 4032 times)
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Error when updating diagram with 'large' labels on Links
Jun 8th, 2022 at 3:08pm
Print Post  
When we have labels on Links that have lots of text in them (say 10 lines of 78 characters each!) we are getting multiple errors like the one attached. They vary only in the reported index and length.

I believe we are currently using 4.1.3.

Would this problem be fixed by updating to a newer version?
  

DiagramError.txt ( 3 KB | 117 Downloads )
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Error when updating diagram with 'large' labels on Links
Reply #1 - Jun 9th, 2022 at 5:41am
Print Post  
Please attach diagram file and our developer will check that.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: Error when updating diagram with 'large' labels on Links
Reply #2 - Jun 13th, 2022 at 1:12pm
Print Post  
When you ask for the 'diagram file' do you mean the XML the diagram is saved as in the database or something else?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Error when updating diagram with 'large' labels on Links
Reply #3 - Jun 13th, 2022 at 5:16pm
Print Post  
I mean a file created by calling diagram.saveToXml method. If the forum software won't allow you to attach with xml extension, please zip the file or rename to txt.
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: Error when updating diagram with 'large' labels on Links
Reply #4 - Jun 14th, 2022 at 11:04am
Print Post  
Diagram XML attached, in zip archive.

Some sensitive data has been replaced with nonsense, but retains the same number of characters.
  

Diagram.zip ( 10 KB | 92 Downloads )
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Error when updating diagram with 'large' labels on Links
Reply #5 - Jun 14th, 2022 at 3:20pm
Print Post  
We could not reproduce neither on current 4.6.1 version nor 4.1.3. We can't load your custom nodes, but leaving only the ShapeNode you use as link's label and moving it around is not showing exceptions in the console. Does attached file throw error for you if you load it in the demo sample project? What OS and Java versions are you using?
  

ShapeNode.zip ( 2 KB | 154 Downloads )
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: Error when updating diagram with 'large' labels on Links
Reply #6 - Jun 14th, 2022 at 5:00pm
Print Post  
OS: Windows Server 2016 Standard
Java: 1.8.0_291

Your sample loads fine in the demo - can move 'label' without errors.

Obviously can't load mine due to custom class.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Error when updating diagram with 'large' labels on Links
Reply #7 - Jun 15th, 2022 at 6:34am
Print Post  
Does it throw errors if you load it into your application instead of demo (in case it's related to diagram settings that are not saved in file)?

Quote:
OS: Windows Server 2016 Standard

Is the application a desktop one, or using the diagram on server side to render bitmaps and HTML?
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: Error when updating diagram with 'large' labels on Links
Reply #8 - Jun 15th, 2022 at 6:27pm
Print Post  
No errors if I load your 'ShapeNode' into our application.

I only get the errors intermittently within our application, but often enough that I need to try and fix the problem.

I think I probably need to try debugging with the source code we got when we bought JDiagram (years ago so had forgotten we had it!)

Unfortunately it says 'Library source does not match bytecode for class ShapeNode' (for example) when I open the source file in my IDE to allow debugging - any idea how I can get around this?

It's standard Java application, displaying the diagram within the application in response to a user request.

Server OS is simply due to licensing costs I believe. It's a VM I use as my development machine, not as a server for anything.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Error when updating diagram with 'large' labels on Links
Reply #9 - Jun 16th, 2022 at 10:51am
Print Post  
Can you reproduce from ShapeNode.xml file if you replace the nonsense text with original one?

Bytecode not matching could be due to obfuscation. I guess you could either build debug jar yourself, or just copy the diagram code to your project instead of using jar.
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: Error when updating diagram with 'large' labels on Links
Reply #10 - Aug 10th, 2022 at 4:57pm
Print Post  
I removed 'standard' JDiagram jar file and built one from the code we got when we bought JDiagram to try to debug this further, so I now know where the problem is occurring, within the draw() method of TextLayout:

Code (Java)
Select All
// We now have the starting line and the number
        // of total lines to layout the text in. Go for it
        int iword = 0;
        int startChar = 0;
        _refStartChar = 0;
        for (int i = _startLine; i < _startLine + _totalLines; i++)
        {
            PointList hLine = getHLines(_totalLines).get(i);

            for (int j = 0; j < hLine.size(); j += 2)
            {
                Point2D.Float pt1 = hLine.get(j);
                Point2D.Float pt2 = hLine.get(j + 1);
                Rectangle2D rc = new Rectangle2D.Double( 



The problem occurs on the first line within the outer loop, setting the value of hLine. [I hope this gives you enough info on the problem without publishing too much of your code]

I'm struggling to understand why the problem is occurring tho' - Can you give me any pointers as to what to look for now we know where the problem occurs?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Error when updating diagram with 'large' labels on Links
Reply #11 - Aug 12th, 2022 at 6:18am
Print Post  
In what situation are you seeing this exception - e.g. when moving / resizing interactively, or after changing some properties of the node? Text layout has changed a lot since v4.1.3 anyway, and we don't care enough to dig into a decade old code. Maybe try that with current 4.6.1 version - if exceptions stop, we'll send you the latest TextLayout.java, otherwise please give us more details how to reproduce.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: Error when updating diagram with 'large' labels on Links
Reply #12 - Sep 28th, 2022 at 4:23pm
Print Post  
I have upgraded my development environment to 4.6.2 trial, and still get the same error:
Quote:
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index 3 out of bounds for length 3
     at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
     at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.ja
va:70)
     at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
     at java.base/java.util.Objects.checkIndex(Objects.java:372)
     at java.base/java.util.ArrayList.get(ArrayList.java:459)
     at com.mindfusion.drawing.TextLayout.draw(Unknown Source)
     at com.mindfusion.diagramming.ShapeNode.a(Unknown Source)
     at com.mindfusion.diagramming.ShapeNode.a(Unknown Source)
     at com.mindfusion.diagramming.ShapeNode.drawLocal(Unknown Source)
     at com.mindfusion.diagramming.DiagramNode.draw(Unknown Source)
     at com.mindfusion.diagramming.Diagram.a(Unknown Source)
     at com.mindfusion.diagramming.Diagram.b(Unknown Source)
     at com.mindfusion.diagramming.Diagram.a(Unknown Source)
     at com.mindfusion.diagramming.DiagramView.a(Unknown Source)
     at com.mindfusion.diagramming.DiagramView.paintComponent(Unknown Source)
     at java.desktop/javax.swing.JComponent.paint(JComponent.java:1074)
     at java.desktop/javax.swing.JComponent.paintToOffscreen(JComponent.java:5255)
     at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBufferedImpl(Rep
aintManager.java:1643)
     at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Repaint
Manager.java:1618)
     at java.desktop/javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1
556)
     at java.desktop/javax.swing.RepaintManager.paint(RepaintManager.java:1323)
     at java.desktop/javax.swing.JComponent._paintImmediately(JComponent.java:5203)
     at java.desktop/javax.swing.JComponent.paintImmediately(JComponent.java:5013)
     at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:865)
     at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:848)
     at java.base/java.security.AccessController.doPrivileged(Native Method)
     at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPr
ivilege(ProtectionDomain.java:85)
     at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:84
8)
     at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:82
3)
     at java.desktop/javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java
:772)
     at java.desktop/javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.ja
va:1890)
     at java.desktop/java.awt.event.InvocationEvent.dispatch$$$capture(InvocationEvent.j
ava:313)
     at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java)
     at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
     at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
     at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
     at java.base/java.security.AccessController.doPrivileged(Native Method)
     at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPr
ivilege(ProtectionDomain.java:85)
     at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
     at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchTh
read.java:203)
     at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThrea
d.java:124)
     at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchTh
read.java:113)
     at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:10
9)
     at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:10
1)
     at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)


It seems to occur when a link with lots of text in it's label is moved so that the text overlaps a node box.

Are you able to determine what might be the problem or do I need to use the source code to get more explicit details in the stack trace?

This is with a new diagram, created using the updated library.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Error when updating diagram with 'large' labels on Links
Reply #13 - Sep 29th, 2022 at 7:56am
Print Post  
Since you have the code, you could modify the loop you posted above to exit when index reaches PointList's size. That might still draw the text at incorrect positions if layout is out of sync, but at least won't throw exceptions.

We should be able to determine exact reason if you give us node coordinates and text with which you are seeing the exception. Re sensitive data, maybe try reproducing it by replacing words with ones having similar length (as characters' total point width on screen, and not just number of characters).

Quote:
occur when a link with lots of text in it's label is moved so that the text overlaps a node box.


Does your application do anything in response to nodes overlapping, e.g. from nodeModifying / nodeModifed event handlers?

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint