Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Custom Properties on Item objects (Read 6447 times)
Saeven
YaBB Newbies
*
Offline


Developer

Posts: 6
Joined: Jan 2nd, 2008
Custom Properties on Item objects
Jan 2nd, 2008 at 5:49pm
Print Post  
I'd like to append custom properties to Items; specifically Arrows and Boxes.

Intuitively, I'd imagine creating a subclass of Arrow and Box that have an additional mutable java.util.Property member, and override the createBox/createArrow methods in the FlowChart object to create my subclassed objects instead...  Is this the intended usage? 

Looking forward to your likely much-enlightened recommendation on this one Smiley

Thanks in advance!
Alex
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Properties on Item objects
Reply #1 - Jan 2nd, 2008 at 7:59pm
Print Post  
You can use the FlowChart.Add() method to add instances of your custom class, without having to inherit from the FlowChart class too. JDiagram does not yet provide any easy way to let users draw items from a custom class. If you need that, you could use the standard item types, and append the custom data via their setTag() method.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Saeven
YaBB Newbies
*
Offline


Developer

Posts: 6
Joined: Jan 2nd, 2008
Re: Custom Properties on Item objects
Reply #2 - Jan 2nd, 2008 at 10:28pm
Print Post  
When a FlowChart is click-dragged to create a node or an arrow in this case, are any of the createXXX methods called?

I understand that using add() is fine, but I would need to be able to intercept the mouse-interactive creation that takes place. 

As example, if I could intercept FlowChart.createBox(), I could easily do:

[code]
chart = new FlowChart(){
     @Override
     public Box createBox(float arg0, float arg1, float arg2, float arg3) {
         // TODO Auto-generated method stub
         Box b = super.createBox(arg0, arg1, arg2, arg3);
           CustomBox c = CustomBox.valueOf( b );
           return c;
     }                  
};
[/code]

The thing is that I need to be able to let users edit custom values that are associated to the boxes.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Properties on Item objects
Reply #3 - Jan 3rd, 2008 at 5:46am
Print Post  
Currently that's not possible. Our .NET component provides CustomNodeType and CustomLinkType properties that let you specify what type of items should be created when the user draws with the mouse. We can port them to Java later this week and upload here an updated .jar for you.

Stoyan
  
Back to top
 
IP Logged
 
Saeven
YaBB Newbies
*
Offline


Developer

Posts: 6
Joined: Jan 2nd, 2008
Re: Custom Properties on Item objects
Reply #4 - Jan 3rd, 2008 at 1:21pm
Print Post  
The sooner the better.  I'd love to give you guys our business given how helpful you've been.  If I don't hear from you by Friday, I'll have to move along to a different solution; get it done before then for a guaranteed sale otherwise Wink

Thanks for the help, look forward to your response.
Alex
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Properties on Item objects
Reply #5 - Jan 4th, 2008 at 10:20am
Print Post  
https://mindfusion.org/_temp/customtypes.zip

Now there are two methods you could use to let the user draw custom items.

1. Using the CustomNodeType and CustomLinkType properties, e.g.

fc.setBehavior(BehaviorType.Custom);
fc.setCustomNodeType(MyNode.class);

2. Inherit from the NodeLinkBehavior class, implement its createLink() and createNode() methods, and call

fc.setCustomBehavior(new YourBehaviorClass());

The custom type could look like

public class MyNode extends Box
{
     public MyNode(FlowChart fc)
     {
           super(fc);
     }

     protected void draw(Graphics2D g, boolean shadow)
     {
           super.draw(g, shadow);

           if (!shadow)
           {
                 g.setFont(getFont());
                 g.drawString(test, (float)bounds.getX(), (float)bounds.getY());
           }
     }

     private String test = "test";
}

Note that in the first case the control uses the reflection API to create item instances, and in that case you should always provide a constructor that a single parameter of type FlowChart. In addition, you cannot use nested classes, since the compiler implicitly inserts an additional parameter to nested class constructors.

We haven't ported everything related to custom classes yet. For example you cannot yet derive directly from the base Node class (as possible in Flowchart.NET), but will have to derive from either Box or Table.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Saeven
YaBB Newbies
*
Offline


Developer

Posts: 6
Joined: Jan 2nd, 2008
Re: Custom Properties on Item objects
Reply #6 - Mar 26th, 2008 at 3:33am
Print Post  
Hi Stoyan,

Sorry for the delay and thanks for the work, this project got sidetracked entirely, but I'm back on it.

Has this functionality been built into the "mainstream" project yet?

Regards.
Alex
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Properties on Item objects
Reply #7 - Mar 26th, 2008 at 7:48am
Print Post  
Hi Alex,

We are just releasing a new version with this functionality included. It should be available next week.

Now you can get a newer "mainstream" version of the jar file from our ASP.NET package, where the JDiagram's applet is used to implement the client side functionality:
https://www.mindfusion.eu/NetDiagramTrial.zip

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint