It is possible to drop annotations on a graph using the class com.jinsight.jetchart.Note.
A Note object can be dragged and can have its opacity switched on/off, either by double-clicking
the Note box or using the method Note.setOpacityEnabled(boolean isOpacityEnabled).
There are methods to configure diverse properties, like text alignment, the dimension of the
note box, foreground and background colors, etc. For a complete list of all properties available
please refer to the api documentation of the Note object.
The following example displays two Note objects, one opaque and the other transparent. To drag a Note
object, click within the annotation box and drag mouse. A double click on a Note object alternates its opacity.
import javax.swing.*; import java.awt.*; import com.jinsight.jetchart.*; public class Main extends JFrame { public Main() { Graph graph=new Graph(); graph.setTitle(new String[]{"The JetChart Library","Annotations"}); Grid grid=graph.getGraphSet(0).getGrid(); grid.setEnabled(true); grid.setColor(Color.gray); double[] values={100,200,150,300,90}; BarSerie bs=new BarSerie(values,"Bar series"); bs.setColor(Color.green); graph.addSerie(bs); Note note1=new Note(); note1.setBackground(Color.blue); note1.setForeground(Color.yellow); note1.setText(new String[]{"This is an opaque","annotation"}); note1.setLocation(60,40); Note note2=new Note(); note2.setOpacityEnabled(false); note2.setBackground(Color.yellow); note2.setText(new String[]{"This is a transparent","annotation"}); note2.setLocation(150,100); graph.addNote(note1); graph.addNote(note2); Container ct=getContentPane(); ct.add("Center",graph); setSize(400,300); setVisible(true); } public static void main(String[] args) { new Main(); } }