![]() |
|
Модераторы: LSD, AntonSaburov |
![]()
|
|
| mole_84 |
|
|||
|
Новичок Профиль Группа: Участник Сообщений: 9 Регистрация: 19.4.2007 Репутация: нет Всего: нет |
If someone has already written a chart that listens to mouse events and enables mouse drag please show your code.
Thanks in advance |
|||
|
||||
| powerOn |
|
|||
![]() software saboteur ![]() ![]() ![]() ![]() Профиль Группа: Участник Сообщений: 4367 Регистрация: 7.10.2005 Репутация: 31 Всего: 159 |
If I understand you correctly, you can draw your chart directly on JPanel and add listeners to it. For example:
|
|||
|
||||
| mole_84 |
|
|||
|
Новичок Профиль Группа: Участник Сообщений: 9 Регистрация: 19.4.2007 Репутация: нет Всего: нет |
||||
|
||||
| mole_84 |
|
|||
|
Новичок Профиль Группа: Участник Сообщений: 9 Регистрация: 19.4.2007 Репутация: нет Всего: нет |
Oh. I see. I had just to delete it:)
But still one question. How should I make a chart ineractive? I want to redraw a chart according to the mouse motion. For example to add new point or move a point or make one of the columns higher. Could you please spend a bit more time? Thanks in advance. |
|||
|
||||
| mole_84 |
|
|||
|
Новичок Профиль Группа: Участник Сообщений: 9 Регистрация: 19.4.2007 Репутация: нет Всего: нет |
powerOn, I've done in this way:
getX() return coordinate in pixels. Is it possible to convert it coordinate of a chart? And one more question: Is it possible to find out whether a chart was clicked? I mean to distinguish clicking on a chart and clicking on other part of a frame? Thanks |
|||
|
||||
| powerOn |
|
|||
![]() software saboteur ![]() ![]() ![]() ![]() Профиль Группа: Участник Сообщений: 4367 Регистрация: 7.10.2005 Репутация: 31 Всего: 159 |
This is my mistake. I took this code from one of my projects and forgot to clean up a package name (compressor). That's right. I think, this is not trivial work. For a start, you should look a demo from official JFreeChart web site. I hope you find where something interesting. Otherwise, you need create own component (it means writing a lot of code). I think, it's very difficult, but possible. |
|||
|
||||
| mole_84 |
|
|||
|
Новичок Профиль Группа: Участник Сообщений: 9 Регистрация: 19.4.2007 Репутация: нет Всего: нет |
This code maybe useful if you want to translate event coordinates to your axis coordinates:
|
|||
|
||||
| mole_84 |
|
|||
|
Новичок Профиль Группа: Участник Сообщений: 9 Регистрация: 19.4.2007 Репутация: нет Всего: нет |
In this code points can be moved along a vertical line:
|
|||
|
||||
| mole_84 |
|
|||
|
Новичок Профиль Группа: Участник Сообщений: 9 Регистрация: 19.4.2007 Репутация: нет Всего: нет |
This is a final version. Now plot is redrawn while a point is dragged. powerOn thanks again. You gave an initial push.
Это сообщение отредактировал(а) powerOn - 27.4.2007, 20:16 |
|||
|
||||
| powerOn |
|
|||
![]() software saboteur ![]() ![]() ![]() ![]() Профиль Группа: Участник Сообщений: 4367 Регистрация: 7.10.2005 Репутация: 31 Всего: 159 |
||||
|
||||
![]()
|
| Правила форума "Java" | |
|
|
Если Вам помогли, и атмосфера форума Вам понравилась, то заходите к нам чаще! С уважением, LSD, AntonSaburov, powerOn, jk1. |
| 0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей) | |
| 0 Пользователей: | |
| « Предыдущая тема | Java: GUI и Java FX приложения | Следующая тема » |
|
|
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности Powered by Invision Power Board(R) 1.3 © 2003 IPS, Inc. |