Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Java
 QCChart2D for Java
 How do I change the color of an active plot?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

javaman

22 Posts

Posted - 24 Apr 2009 :  11:12:10  Show Profile  Reply with Quote
Hi,

I've got a graph with up to 10 plot lines at a time. I've enabled the legend items to be mouse enabled so that I can change the color of the plot according to which legend item is entered. What I do is the following:


   public void mouseEntered(MouseEvent e) {
        setBackground(Color.WHITE);
        plot.setLineColor(Color.red.brighter());
        plot.setUpdateFlag(true);
    }
    
    public void mouseExited(MouseEvent e) {
        setBackground(BACKGROUND_COLOR);
        plot.setLineColor(this.textColor);
        plot.setUpdateFlag(true);
    }



where plot is:

private SimplePlot plot;

Unfortunately, this doesn't work. I want the item to turn red so as to be highlighted when the mouse is over the legend item. I thought that turning the lineColor to the newly desired color would make the plot in the graph change. No go...

Can you tell me what else I need to do to affect the change? Do I need to call something in the graph or what?

many thanx.

Thanx - Joe!

quinncurtis

1164 Posts

Posted - 24 Apr 2009 :  11:44:01  Show Profile  Reply with Quote
We don't know what you mean by enabling the legend items to be mouse enabled, since we have no explicit support for any mouse events in the legend items. But assuming you some how are generating a mouse event the way you want, any time you change a displayable attribute of a single or a group of chart objects, you must call the ChartView.updateDraw method for it to update on the screen. So you might try, the following code, assuming that "chartvu." references the graphs ChartView.

public void mouseEntered(MouseEvent e) {
setBackground(Color.WHITE);
plot.setLineColor(Color.red.brighter());
chartvu.updateDraw();
}

public void mouseExited(MouseEvent e) {
setBackground(BACKGROUND_COLOR);
plot.setLineColor(this.textColor);
chartvu.updateDraw();
}
Go to Top of Page

javaman

22 Posts

Posted - 03 May 2009 :  00:00:46  Show Profile  Reply with Quote
Thanx - that's what I needed.

As for enabling the legend items - I do it myself - it's my own custom legend that I attach in - since yours doesn't have the capabilities that I need...



Thanx - Joe!
Go to Top of Page

javaman

22 Posts

Posted - 05 May 2009 :  14:48:28  Show Profile  Reply with Quote
Hey - I implemented this - and it didn't work. Plot never changed color. Do you have any other suggestions?

Thanx - Joe!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07