Moving Annotation During run Time, and writing to it

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
Turc
Newbie
Newbie
Posts: 34
Joined: Wed Feb 03, 2010 12:00 am

Moving Annotation During run Time, and writing to it

Post by Turc » Wed Aug 04, 2010 11:25 pm

Few issues regarding the Annotation Tool.

1. How do you move an Annotation during runtime on a chart?
2. I can set the text in an Annotation during runtime, but if i write something into the annotation again, it throws multiple errors.

Code: Select all

annotation.setText(JOptionPane.showInputDialog((Annotation)e.getSource()).toString());


Thank you

Turc
Newbie
Newbie
Posts: 34
Joined: Wed Feb 03, 2010 12:00 am

Re: Moving Annotation During run Time, and writing to it

Post by Turc » Thu Aug 05, 2010 12:06 am

Is there something similar to the .net rectangle tools in java? That seems to do everything that i need it to do.

Yeray
Site Admin
Site Admin
Posts: 9617
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Moving Annotation During run Time, and writing to it

Post by Yeray » Thu Aug 05, 2010 4:49 pm

Hi Turc,

I have a Chart and a Button in a NetBeans project. The clicked Action is executed when I press the button.
It seems to work as expected here. Doesn't it for you?

Code: Select all

    private com.steema.teechart.styles.Line line1;
    private com.steema.teechart.tools.Annotation annotation1;
    private void initChart() {
        tChart1.getAspect().setView3D(false);

        line1 = new com.steema.teechart.styles.Line(tChart1.getChart());
        line1.getPointer().setVisible(true);
        line1.fillSampleValues(25);

        annotation1 = new com.steema.teechart.tools.Annotation(tChart1.getChart());
        annotation1.setActive(false);
    }

    @Action
    public void clicked() {
        java.util.Random rnd = new java.util.Random();
        int ValueIndex = rnd.nextInt(line1.getCount());

        annotation1.setActive(true);
        annotation1.setLeft(tChart1.getSeries(0).calcXPos(ValueIndex) + 25);
        annotation1.setTop(tChart1.getSeries(0).calcYPos(ValueIndex) - 25);
        annotation1.setText("P(" + Double.toString(tChart1.getSeries(0).getXValues().getValue(ValueIndex)) + ";" + Double.toString(tChart1.getSeries(0).getYValues().getValue(ValueIndex)) + ")");
        annotation1.getCallout().getArrow().setVisible(true);
        annotation1.getCallout().setXPosition(tChart1.getSeries(0).calcXPos(ValueIndex));
        annotation1.getCallout().setYPosition(tChart1.getSeries(0).calcYPos(ValueIndex));

        annotation1.setText(javax.swing.JOptionPane.showInputDialog(annotation1.getText()));
    }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Turc
Newbie
Newbie
Posts: 34
Joined: Wed Feb 03, 2010 12:00 am

Re: Moving Annotation During run Time, and writing to it

Post by Turc » Thu Aug 05, 2010 5:18 pm

Yeray,
Thanks, that works great. I also figured out how to move the Annotation. Thank you again for assisting me!

Yeray
Site Admin
Site Admin
Posts: 9617
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Moving Annotation During run Time, and writing to it

Post by Yeray » Thu Aug 05, 2010 7:54 pm

Hi Turc,

You're welcome!
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply