Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet chartMouseClicked(ChartMouseEvent event)
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


latha
chartMouseClicked(ChartMouseEvent event)
1 Answer(s)      3 years and 8 months ago
Posted in : JSP-Servlet


Hi deepak ihave draw a piechart using jfreechart with tooltip.Now i need click event (chartMouseClicked(ChartMouseEvent event)) in this chart. can u help me plz....


Advertisement
View Answers

February 18, 2011 at 3:40 PM


Java JFreechart MouseEvent

import java.awt.*;
import javax.swing.*;
import org.jfree.ui.*;
import org.jfree.chart.*;
import org.jfree.chart.plot.*;
import org.jfree.data.general.*;
import org.jfree.chart.entity.*;

public class PieChart extends ApplicationFrame implements ChartMouseListener {
private JFreeChart chart; 
private PiePlot plot;
private int angle=270;
private static double explodePercent = 0.99;
private static long count=0;

public PieChart(String title){
    super(title);
        this.chart = ChartFactory.createPieChart("Pie Chart Demo",createDataset(),  true,  true, false);
        this.plot = (PiePlot) chart.getPlot();
        this.plot.setSectionOutlinesVisible(false);
        this.plot.setNoDataMessage("No data available");
        this.plot.setBackgroundAlpha(0.2f);
        this.plot.setBackgroundPaint(Color.WHITE); 
        this.angle=270;
        ChartPanel chartpanel = new ChartPanel(chart, false, false, false, false, false);   
        chartpanel.setVisible(true);
        chartpanel.addChartMouseListener(this);
        chartpanel.setPreferredSize(new Dimension(500, 270));
        setContentPane(chartpanel);
}
private static PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("One", new Double(10.0));
    dataset.setValue("Two", new Double(20.0));
    dataset.setValue("Three", new Double(30.0));
    dataset.setValue("Four", new Double(40.0));
    dataset.setValue("Five", new Double(10.0));
    return dataset;
}
private static JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart3D("Pie Chart Demo",dataset, true, true,false);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setNoDataMessage("No data available");
    plot.setBackgroundAlpha(0.2f);
    return chart;
}
public static JPanel createDemoPanel() {
    JFreeChart chart = createChart(createDataset());
    ChartPanel chartpanel = new ChartPanel(chart, false, false, false, false, false);   
    chartpanel.setVisible(true);      
    chartpanel.setPreferredSize(new Dimension(500, 270));
    return new JPanel();
}
public static void main(String[] args) {
    PieChart demo = new PieChart("Pie Chart");
    demo.pack();
    RefineryUtilities.centerFrameOnScreen(demo);
    demo.setVisible(true);
}
public void chartMouseClicked(ChartMouseEvent chartmouseevent){
ChartEntity chartentity = chartmouseevent.getEntity();
if (chartentity != null){
   System.out.println("Mouse clicked: " + chartentity.toString());
}
else
System.out.println("Mouse clicked: null entity.");
}

public void chartMouseMoved(ChartMouseEvent chartmouseevent){
}
}


Related Tutorials/Questions & Answers:
chartMouseClicked(ChartMouseEvent event)
chartMouseClicked(ChartMouseEvent event)  Hi deepak ihave draw a piechart using jfreechart with tooltip.Now i need click event (chartMouseClicked(ChartMouseEvent event)) in this chart. can u help me plz
event handling
event handling  diff btwn event handling in ASP.net and in HTML
Advertisements
Event Listeners
Event Listeners  I want to learn the Event Listeners in Java. Any... is the good tutorial and example of Event Listeners in Java. Please check the tutorial Java - Event Listeners Example in Java Applet. Thanks
Event management
Event management   Hi, I want event management application like maintaining email notifications while task creation and update in broader way using spring java
Event in flex
Event in flex  Hi..... can you tell me about that How do you make component participate in event mechanism? Thanks   Ans: Extend EventDispatcher or any subclass of it or implement IEventDispatcher
Flex event
Flex event  Hi.... please tell me about How does Flex event system works? Thanks  Ans: When event are triggered there are three...: In the capturing phase, Flex examines an event target?s ancestors in the display list to see
Event in flex
Event in flex  Hi..... I want to know about What does calling preventDefault() on an event do? How is this enforced? please give me an example for that Thanks   Ans: The methods of the Event class can be used
Flex event
Flex event  Hi.... Please tell me about How to create your own event in flex? Thanks
Flex event
Flex event  hi...... How to capture and event if the component is disabled? please give an example..... Thanks in advance
Flex event
Flex event  Hi... please give me the answer with example What is event Bubbling? Thanks in advance  Event Bubbling: In the bubbling phase, Flex examines an event?s ancestors for event listeners. Flex starts
Click event
Click event  hi............ how to put a click event on a particular image, so that it can allow to open another form or allow to display result in tabular form????????/ can u tell me how to do that????????/ using java swings
Event helpers
Event helpers       Event helpers As we all know events are actions or occurrences detected by a program. And event handlers are methods which handles
handling Button Event in iphone
handling Button Event in iphone  handling Button Event in iphone
How to Handle Event Handlers?
How to Handle Event Handlers?  How to Handle Event Handlers
Java event handling
Java event handling  What event results from the clicking of a button
Java event delegation model
Java event delegation model  What is the highest-level event class of the event-delegation model
Java event-listener
Java event-listener  What is the relationship between an event-listener interface and an event-adapter class
Event listener in JavaScript with example
Event listener in JavaScript with example  What is event listener in JavaScript? Can anyone please post an example of Event listener?? Thanks in Advance
Event handling on an image
Event handling on an image  I want to divide an image into frames and want to do event handling on the frames
Java event handling
Java event handling  Which java.util classes and interfaces support event handling
Java event-delegation model
Java event-delegation model  What is the advantage of the event-delegation model over the earlier eventinheritance model
delegation event model
delegation event model  What is delegation event model?   delegation event model In the event-delegation model, specific objects are designated as event handlers for GUI components. These objects implement event
event calendar sample
event calendar sample  creating a event calendar for my small app in PHP.. can any one explain about it's design with example php event calendar script
Java AWT event hierarchy
Java AWT event hierarchy  What class is the top of the AWT event hierarchy?  The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy
Java event handling
Java event handling  What is the purpose of the enableEvents() method
event tracking code
event tracking code  a javascript written that will help us to track sitewide, even tracking in Google Analytics
Event listeners in mxml
Event listeners in mxml  hi.. just tell me about How do you add event listeners in mxml components. Now AS3 components? Please give... for add a event listner in flex using action script. 1. addEventListener(type:String
javascript event handling examples
javascript event handling examples  javascript event handling examples   var handleClick = function(e) { // Older IEs set the `event... event listeners. document.attachEvent('onclick', handleClick); } else
KEY EVENT HANDLING
KEY EVENT HANDLING  I am trying to write a program that receives every key stroke even when the window is not active or it's minimized. Is there anyway to do
jquery href onclick event
jquery href onclick event  jquery href onclick event   $('a').click(function (event) { event.preventDefault(); //here you can also do all sort of things });   <script type="text/javascript
onmouseover event in jsf
onmouseover event in jsf  hello friends, I am in the middle of the project, I have a requirement in my project. I am using jsf ,spring, hibernate... want to dispaly the list of some documents by using onmouseover event in jsf
 

 

 

DMCA.com