Page 1 of 1
Moving Annotation During run Time, and writing to it
Posted: Wed Aug 04, 2010 11:25 pm
by 15355183
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
Re: Moving Annotation During run Time, and writing to it
Posted: Thu Aug 05, 2010 12:06 am
by 15355183
Is there something similar to the .net rectangle tools in java? That seems to do everything that i need it to do.
Re: Moving Annotation During run Time, and writing to it
Posted: Thu Aug 05, 2010 4:49 pm
by yeray
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()));
}
Re: Moving Annotation During run Time, and writing to it
Posted: Thu Aug 05, 2010 5:18 pm
by 15355183
Yeray,
Thanks, that works great. I also figured out how to move the Annotation. Thank you again for assisting me!
Re: Moving Annotation During run Time, and writing to it
Posted: Thu Aug 05, 2010 7:54 pm
by yeray
Hi Turc,
You're welcome!