Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic CustomDraw box (Read 1844 times)
tronied
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: May 7th, 2008
CustomDraw box
May 7th, 2008 at 10:38am
Print Post  
Hi. I have just started out trying to use JDiagram, and am wanting to do some custom drawing on a box. I looked at the API, and I am afriad I didn't find it too helpful. I then looked in one of your samples and took the following:

Code
Select All
// ...
        //After I create the flow chart object
        newFlowChart.addFlowChartListener
        (
                new FlowChartAdapter()
                {
                        public void drawItem(ItemDrawEvent e)
                        {
                                onDrawItem(e);
                        }
                }
        );
// ...
       //New box setCustomDraw property
        box.setCustomDraw(CustomDraw.Full);
// ...

    public void onDrawItem(ItemDrawEvent e) {
        if (e.getItem() instanceof Box) {
            Graphics2D g = e.getGraphics();
            g.setColor(Color.BLACK);
           //Do something crazy just to see if its working...
            g.fillRect(0,0,1000,1000);
        }
    }
 



Unfortunately this doesn't seem to work, and I can't figure out why. I stepped through the code, and gets to the line which adds a flow chart listener, but the itemDraw() never gets called. The flow chart other than that is displaying fine though...

Any ideas? *

* Sorry if this is a frequently asked question, but I couldn't see any examples on the web.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: CustomDraw box
Reply #1 - May 7th, 2008 at 11:30am
Print Post  
Hi,

This worked for me:

Code
Select All
Box b = flowChart.createBox(10, 10, 40, 40);
b.setCustomDraw(CustomDraw.Full);

flowChart.addFlowChartListener(new FlowChartAdapter()
{
	public void drawItem(ItemDrawEvent e)
	{
		if (e.getItem() instanceof Box) {
			Graphics2D g = e.getGraphics();
			g.setColor(Color.BLACK);
			//Do something crazy just to see if its working...
			g.fillRect(0,0,1000,1000);
	}
}
 



If you created your box instance by just calling the constructor, have you also used the add() method to add it to the flowchart?

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