1 23 package org.objectweb.clif.scenario.util.isac.loadprofile.gui; 24 25 import java.util.Enumeration ; 26 import java.util.Hashtable ; 27 import java.util.Vector ; 28 29 import org.apache.log4j.Category; 30 import org.eclipse.jface.dialogs.MessageDialog; 31 import org.eclipse.jface.wizard.WizardDialog; 32 import org.eclipse.swt.SWT; 33 import org.eclipse.swt.custom.ScrolledComposite; 34 import org.eclipse.swt.events.ModifyEvent; 35 import org.eclipse.swt.events.ModifyListener; 36 import org.eclipse.swt.events.MouseEvent; 37 import org.eclipse.swt.events.MouseListener; 38 import org.eclipse.swt.events.MouseMoveListener; 39 import org.eclipse.swt.events.PaintEvent; 40 import org.eclipse.swt.events.PaintListener; 41 import org.eclipse.swt.events.SelectionEvent; 42 import org.eclipse.swt.events.SelectionListener; 43 import org.eclipse.swt.graphics.Color; 44 import org.eclipse.swt.graphics.Cursor; 45 import org.eclipse.swt.graphics.GC; 46 import org.eclipse.swt.graphics.Image; 47 import org.eclipse.swt.graphics.Rectangle; 48 import org.eclipse.swt.layout.FillLayout; 49 import org.eclipse.swt.layout.GridData; 50 import org.eclipse.swt.layout.GridLayout; 51 import org.eclipse.swt.widgets.Composite; 52 import org.eclipse.swt.widgets.Event; 53 import org.eclipse.swt.widgets.Label; 54 import org.eclipse.swt.widgets.Listener; 55 import org.eclipse.swt.widgets.Menu; 56 import org.eclipse.swt.widgets.MenuItem; 57 import org.eclipse.swt.widgets.Text; 58 import org.eclipse.swt.widgets.ToolBar; 59 import org.eclipse.swt.widgets.ToolItem; 60 import org.objectweb.clif.scenario.util.isac.FileName; 61 import org.objectweb.clif.scenario.util.isac.gui.Icons; 62 import org.objectweb.clif.scenario.util.isac.gui.ScenarioGUIEditor; 63 import org.objectweb.clif.scenario.util.isac.loadprofile.GroupDescription; 64 import org.objectweb.clif.scenario.util.isac.loadprofile.LoadProfileManager; 65 import org.objectweb.clif.scenario.util.isac.loadprofile.Point; 66 import org.objectweb.clif.scenario.util.isac.loadprofile.RampDescription; 67 import org.objectweb.clif.scenario.util.isac.util.tree.TreeManager; 68 69 75 public class LoadDrawingEditor 76 implements 77 MouseListener, 78 MouseMoveListener, 79 SelectionListener, 80 Listener, 81 PaintListener, 82 ModifyListener { 83 private static final boolean SHOW_WARNING_DIALOGS = true; 85 86 private ScenarioGUIEditor window; 87 private Composite parent; 88 private Composite content; 89 private Composite toolBarComposite; 90 private Composite drawBarComposite; 91 private ScrolledComposite main; 92 private DrawableCanvas drawableCanvas; 93 private Composite canvasComposite; 94 private Point first; 96 private Point last; 97 private ToolBar toolBar; 99 private MenuItem showTextPopupItem; 100 private ToolItem createGroupToolBarItem; 101 private ToolItem selectionToolBarItem; 102 private Menu selectionMenu; 103 private Hashtable selectionMenuItems; 104 private ToolItem editDescriptionToolBarItem; 105 private ToolItem deleteSelectionToolBarItem; 106 private ToolItem changeScaleToolBarItem; 107 private ToolBar drawBarLeft; 109 private ToolBar drawBarRight; 110 private ToolItem addPointDrawBarItem ; 111 private ToolItem deletePointDrawBarItem ; 112 private ToolItem selectionPointDrawBarItem; 113 private ToolItem drawNothingDrawBarItem; 114 private ToolItem drawLineDrawBarItem; 115 private ToolItem drawCrenelHVDrawBarItem; 116 private ToolItem drawCrenelVHDrawBarItem; 117 private MenuItem showTextDrawPopupItem; 118 private ToolItem normalViewBarItem; 119 private ToolItem maximizedViewBarItem; 120 private Text xAxisText; 121 private Text yAxisText; 122 private LoadProfileManager loadManager; 124 private Image selectionImg; 126 static Category cat = Category.getInstance(LoadDrawingEditor.class 128 .getName()); 129 private static final int DRAW_NOTHING = 0; 131 private static final int DRAW_LINE = 1; 132 private static final int CHANGE_POINT = 2; 133 private static final int SELECTION_POINT = 3; 134 private static final int DRAW_CRENEL_HV = 4; 135 private static final int DRAW_CRENEL_VH = 5; 136 private static final int ADD_POINT_MODE = 6 ; 137 private static final int DELETE_POINT_MODE = 7 ; 138 139 private int currentMode; 141 private GroupDescription groupDescriptionSelected; 145 private Point pointSelected = null; 146 private ScaleConvertor scaleConvertor; 148 private static final String deletePointText = "Delete point" ; 150 private static final String deletePointToolTip = "This mode permit to delete a selected point" ; 151 private static final String addPointText = "Add point" ; 152 private static final String addPointToolTip = "Add a new point" ; 153 private static final String drawCrenelHVText = "Draw Crenel"; 154 private static final String drawCrenelVHText = "Draw Crenel"; 155 private static final String drawCrenelHVToolTipText = "Draw a Crenel composed by two lines, the first one is horizontal and the second one vertical"; 156 private static final String drawCrenelVHToolTipText = "Draw a Crenel composed by two lines, the first one is vertical and the second one horizontal"; 157 private static final String drawNothingText = "Normal Mode"; 158 private static final String drawNothingToolTipText = "This is the default mode, it draw nothing..."; 159 private static final String drawLineText = "Draw Line"; 160 private static final String drawLineEmptyRampToolTipText = "Draw a new line for this ramp"; 161 private static final String drawLineToolTipText = drawLineText + "\n" 162 + "The starting point of the new line is the last point \n" 163 + "of the existing ramp curve"; 164 private static final String maximizedViewText = "Maximize View"; 165 private static final String normalViewText = "Normal View"; 166 private static final String maximizedViewToolTipText = "Set the maximize the current view"; 167 private static final String normalViewToolItemText = "Set the normal view"; 168 private static final String xAxisLabel = "X : "; 170 private static final String yAxisLabel = "Y : "; 171 private static final String axisEditorsToolTipText = "Click with the middle mouse button on a selectable point to edit it coordinates..."; 172 private static final String changeScaleText = "Change scale"; 173 private static final String changeScaleToolTipText = "Change the scale of the drawable editor"; 174 private static final String showTextPopupText = "Show Text"; 175 private static final String createGroupToolBarText = "Create Group.."; 176 private static final String deleteSelectionText = "Delete Selection"; 177 private static final String deleteSelectionToolTipText = "Delete the group description selected"; 178 private static final String selectionText = "Select Group"; 179 private static final String editDescriptionText = "Edit Properties"; 180 private static final String editDescriptionToolTipText = "Edit the description of the selected element"; 181 private static final String createRampInformationTitle = "Create Ramp First"; 183 private static final String createRampInformationContent = "There is no ramp description created\n" 184 + "Create a ramp description first !\n"; 185 private static final String createBehaviorInformationTitle = "Create Behavior First"; 186 private static final String createBehaviorInformationContent = "There is no behavior created\n" 187 + "Create a behavior first !\n"; 188 189 public static Color defaultColor = null; 191 192 198 public LoadDrawingEditor(Composite parent, ScenarioGUIEditor w) { 199 cat.debug("-> constructor"); 200 defaultColor = parent.getDisplay().getSystemColor(SWT.COLOR_BLACK); 202 203 this.window = w; 205 this.loadManager = LoadProfileManager.getInstance(); 207 this.loadManager.setDrawablePart(this); 208 this.scaleConvertor = new ScaleConvertor(); 210 this.parent = new Composite(parent, SWT.FLAT); 212 GridLayout gridLayout = new GridLayout(); 214 gridLayout.numColumns = 1; 215 gridLayout.marginHeight = 0; 216 gridLayout.marginWidth = 0; 217 gridLayout.verticalSpacing = 4; 218 this.parent.setLayout(gridLayout); 219 this.toolBarComposite = new Composite(this.parent, SWT.BORDER); 221 GridData gridDataToolBar = new GridData(); 223 gridDataToolBar.grabExcessHorizontalSpace = true; 224 gridDataToolBar.horizontalAlignment = GridData.FILL; 225 this.toolBarComposite.setLayoutData(gridDataToolBar); 226 this.initToolBar(); 228 this.content = new Composite(this.parent, SWT.FLAT); 230 GridLayout gridContent = new GridLayout(); 231 gridContent.marginHeight = 0; 232 gridContent.marginWidth = 0; 233 gridContent.horizontalSpacing = 4; 234 gridContent.numColumns = 2; 235 content.setLayout(gridContent); 236 GridData dataContent = new GridData(); 237 dataContent.grabExcessHorizontalSpace = true; 238 dataContent.grabExcessVerticalSpace = true; 239 dataContent.verticalAlignment = GridData.FILL; 240 dataContent.horizontalAlignment = GridData.FILL; 241 content.setLayoutData(dataContent); 242 243 this.drawBarComposite = new Composite(content, SWT.BORDER); 245 GridData gridDataDrawBar = new GridData(); 246 gridDataDrawBar.verticalAlignment = GridData.FILL; 247 gridDataDrawBar.grabExcessVerticalSpace = true; 248 this.drawBarComposite.setLayoutData(gridDataDrawBar); 249 250 this.main = new ScrolledComposite(content, SWT.BORDER | SWT.H_SCROLL 252 | SWT.V_SCROLL); 253 this.main.setAlwaysShowScrollBars(false); 254 GridData gridDataContents = new GridData(); 255 gridDataContents.horizontalAlignment = GridData.FILL; 256 gridDataContents.verticalAlignment = GridData.FILL; 257 gridDataContents.grabExcessHorizontalSpace = true; 258 gridDataContents.grabExcessVerticalSpace = true; 259 this.main.setLayoutData(gridDataContents); 260 this.main.setExpandHorizontal(true); 261 this.main.setExpandVertical(true); 262 263 this.initDrawBar(); 265 266 this.initDrawablePart(); 268 269 this.parent.layout(); 270 this.first = new Point(-1, -1); 272 this.last = new Point(-1, -1); 273 274 this.currentMode = DRAW_NOTHING; 276 } 277 278 281 private void initDrawBar() { 282 cat.debug("-> initDrawBar"); 283 GridLayout gridDrawBarComposite = new GridLayout(); 285 gridDrawBarComposite.numColumns = 2; 286 this.drawBarComposite.setLayout(gridDrawBarComposite); 287 this.drawBarLeft = new ToolBar(this.drawBarComposite, SWT.VERTICAL 289 | SWT.FLAT); 290 GridData gridDrawBarLeftData = new GridData(); 292 gridDrawBarLeftData.horizontalAlignment = GridData.FILL; 293 gridDrawBarLeftData.verticalAlignment = GridData.FILL; 294 gridDrawBarLeftData.grabExcessVerticalSpace = true ; 295 this.drawBarLeft.setLayoutData(gridDrawBarLeftData); 296 this.drawBarRight = new ToolBar(this.drawBarComposite, SWT.VERTICAL 298 | SWT.FLAT); 299 GridData gridDrawBarRightData = new GridData(); 301 gridDrawBarRightData.horizontalAlignment = GridData.FILL; 302 gridDrawBarRightData.verticalAlignment = GridData.FILL; 303 gridDrawBarRightData.grabExcessVerticalSpace = true ; 304 this.drawBarRight.setLayoutData(gridDrawBarRightData); 305 306 309 drawNothingDrawBarItem = new ToolItem(drawBarLeft, SWT.RADIO); 311 drawNothingDrawBarItem.setToolTipText(drawNothingToolTipText); 312 drawNothingDrawBarItem.setImage(Icons.getImageRegistry().get(FileName.DRAW_NOTHING_ICON)); 313 drawLineDrawBarItem = new ToolItem(drawBarLeft, SWT.RADIO); 315 drawLineDrawBarItem.setToolTipText(drawLineToolTipText); 316 Image img = new Image(this.parent.getDisplay(), new Rectangle(15, 15, 318 15, 15)); 319 img.setBackground(this.parent.getDisplay().getSystemColor( 320 SWT.COLOR_WHITE)); 321 drawLineDrawBarItem.setImage(img); 322 GC gc = new GC(img); 323 gc.setBackground(this.parent.getDisplay().getSystemColor( 324 SWT.COLOR_WHITE)); 325 gc.setForeground(this.parent.getDisplay().getSystemColor( 326 SWT.COLOR_BLACK)); 327 gc.drawLine(0, 0, 15, 15); 328 gc.dispose(); 329 addPointDrawBarItem = new ToolItem(drawBarLeft, SWT.RADIO) ; 331 addPointDrawBarItem.setToolTipText(addPointToolTip) ; 332 addPointDrawBarItem.setImage(Icons.getImageRegistry().get(FileName.ADDPOINT_ICON)) ; 333 334 new ToolItem(drawBarLeft, SWT.SEPARATOR); 337 maximizedViewBarItem = new ToolItem(drawBarLeft, SWT.PUSH); 339 maximizedViewBarItem.setToolTipText(maximizedViewToolTipText); 340 maximizedViewBarItem.setImage(Icons.getImageRegistry().get(FileName.MAXIMIZEVIEW_ICON)); 341 342 Image imgTemp2 = new Image(this.parent.getDisplay(), new Rectangle(15, 344 15, 15, 15)); 345 GC gc2 = new GC(imgTemp2); 346 gc2.setForeground(this.parent.getDisplay().getSystemColor( 347 SWT.COLOR_BLACK)); 348 gc2.drawLine(4, 4, 11, 4); 349 gc2.drawLine(11, 4, 11, 11); 350 gc2.dispose(); 351 drawCrenelHVDrawBarItem = new ToolItem(drawBarRight, SWT.RADIO); 353 drawCrenelHVDrawBarItem.setToolTipText(drawCrenelHVToolTipText); 354 drawCrenelHVDrawBarItem.setImage(imgTemp2); 355 Image imgTemp3 = new Image(this.parent.getDisplay(), new Rectangle(15, 357 15, 15, 15)); 358 GC gc3 = new GC(imgTemp3); 359 gc3.setForeground(this.parent.getDisplay().getSystemColor( 360 SWT.COLOR_BLACK)); 361 gc3.drawLine(4, 11, 4, 4); 362 gc3.drawLine(4, 4, 11, 4); 363 gc3.dispose(); 364 drawCrenelVHDrawBarItem = new ToolItem(drawBarRight, SWT.RADIO); 365 drawCrenelVHDrawBarItem.setToolTipText(drawCrenelVHToolTipText); 366 drawCrenelVHDrawBarItem.setImage(imgTemp3); 367 368 deletePointDrawBarItem = new ToolItem(drawBarRight, SWT.RADIO) ; 370 deletePointDrawBarItem.setToolTipText(deletePointToolTip) ; 371 deletePointDrawBarItem.setImage(Icons.getImageRegistry().get(FileName.DELPOINT_ICON)) ; 372 new ToolItem(drawBarRight, SWT.SEPARATOR) ; 374 normalViewBarItem = new ToolItem(drawBarRight, SWT.PUSH); 375 normalViewBarItem.setToolTipText(normalViewToolItemText); 376 normalViewBarItem.setImage(Icons.getImageRegistry().get(FileName.NORMALVIEW_ICON)); 377 378 379 drawNothingDrawBarItem.addSelectionListener(this); 382 drawLineDrawBarItem.addSelectionListener(this); 383 maximizedViewBarItem.addSelectionListener(this); 384 normalViewBarItem.addSelectionListener(this); 385 drawCrenelHVDrawBarItem.addSelectionListener(this); 386 drawCrenelVHDrawBarItem.addSelectionListener(this); 387 addPointDrawBarItem.addSelectionListener(this) ; 388 deletePointDrawBarItem.addSelectionListener(this) ; 389 390 Menu popup = new Menu(this.drawBarLeft); 393 this.showTextDrawPopupItem = new MenuItem(popup, SWT.CHECK); 394 this.showTextDrawPopupItem.setSelection(false); 395 this.showTextDrawPopupItem.setText(showTextPopupText); 396 this.showTextDrawPopupItem.addSelectionListener(this); 398 this.drawBarLeft.setMenu(popup); 400 this.drawBarRight.setMenu(popup) ; 401 402 this.disableDrawBarItems(); 404 } 405 406 409 private void initToolBar() { 410 cat.debug("-> initToolBar"); 411 GridLayout toolBarLayout = new GridLayout(); 413 toolBarLayout.numColumns = 5; 414 this.toolBarComposite.setLayout(toolBarLayout); 415 this.toolBar = new ToolBar(this.toolBarComposite, SWT.HORIZONTAL 416 | SWT.FLAT); 417 GridData toolBarData = new GridData(); 419 toolBarData.grabExcessHorizontalSpace = true; 420 toolBarData.horizontalAlignment = GridData.FILL; 421 this.toolBar.setLayoutData(toolBarData); 422 423 426 createGroupToolBarItem = new ToolItem(toolBar, SWT.PUSH); 428 createGroupToolBarItem.setImage(Icons.getImageRegistry().get( 429 FileName.NEW_ICON)); 430 createGroupToolBarItem 431 .setToolTipText("Create a new ramp description for a behavior"); 432 433 selectionToolBarItem = new ToolItem(toolBar, SWT.DROP_DOWN); 435 selectionMenu = new Menu(this.parent.getShell(), SWT.POP_UP); 437 this.selectionMenuItems = new Hashtable (); 438 this.selectionToolBarItem.setText(selectionText); 439 this.selectionImg = new Image(this.parent.getDisplay(), new Rectangle( 440 15, 15, 15, 15)); 441 selectionToolBarItem.setImage(this.selectionImg); 442 this.initSelectGroupItems(); 444 445 this.editDescriptionToolBarItem = new ToolItem(toolBar, SWT.PUSH); 447 this.editDescriptionToolBarItem.setImage(Icons.getImageRegistry().get( 448 FileName.PASTE_ICON)); 449 this.editDescriptionToolBarItem 450 .setToolTipText(editDescriptionToolTipText); 451 452 this.deleteSelectionToolBarItem = new ToolItem(toolBar, SWT.PUSH); 454 this.deleteSelectionToolBarItem.setImage(Icons.getImageRegistry().get( 455 FileName.DELETE_ICON)); 456 this.deleteSelectionToolBarItem 457 .setToolTipText(deleteSelectionToolTipText); 458 new ToolItem(toolBar, SWT.SEPARATOR); 460 this.changeScaleToolBarItem = new ToolItem(toolBar, SWT.PUSH); 462 this.changeScaleToolBarItem.setText(changeScaleText); 463 this.changeScaleToolBarItem.setToolTipText(changeScaleToolTipText); 464 Image imgChangeScale = new Image(this.parent.getDisplay(), 465 new Rectangle(15, 15, 15, 15)); 466 GC gc = new GC(imgChangeScale); 467 gc.drawLine(3, 3, 12, 12); 468 gc.drawLine(3, 12, 12, 3); 469 gc.dispose(); 470 this.changeScaleToolBarItem.setImage(imgChangeScale); 471 472 this.addToolBarItemText(); 475 476 479 this.createGroupToolBarItem.addSelectionListener(this); 481 this.selectionToolBarItem.addSelectionListener(this); 483 this.editDescriptionToolBarItem.addSelectionListener(this); 485 this.deleteSelectionToolBarItem.addSelectionListener(this); 487 this.changeScaleToolBarItem.addSelectionListener(this); 489 490 Menu popup = new Menu(this.toolBar); 493 this.showTextPopupItem = new MenuItem(popup, SWT.CHECK); 494 this.showTextPopupItem.setSelection(true); 495 this.showTextPopupItem.setText(showTextPopupText); 496 this.showTextPopupItem.addSelectionListener(this); 498 this.toolBar.setMenu(popup); 500 501 this.deleteSelectionToolBarItem.setEnabled(false); 504 this.editDescriptionToolBarItem.setEnabled(false); 505 506 509 new Label(this.toolBarComposite, SWT.FLAT).setText(xAxisLabel); 511 this.xAxisText = new Text(this.toolBarComposite, SWT.BORDER); 512 GridData gridXAxis = new GridData(); 513 gridXAxis.horizontalAlignment = GridData.FILL; 514 this.xAxisText.setLayoutData(gridXAxis); 516 518 new Label(this.toolBarComposite, SWT.FLAT).setText(yAxisLabel); 520 this.yAxisText = new Text(this.toolBarComposite, SWT.BORDER); 521 GridData gridYAxis = new GridData(); 522 gridYAxis.horizontalAlignment = GridData.FILL; 523 this.yAxisText.setLayoutData(gridYAxis); 525 527 this.disableCoordinateEdition(); 529 } 530 531 534 private void enableCoordinateEdition() { 535 this.xAxisText.setEditable(true); 536 this.yAxisText.setEditable(true); 537 this.xAxisText.addModifyListener(this); 538 this.yAxisText.addModifyListener(this); 539 } 540 541 544 private void disableCoordinateEdition() { 545 this.xAxisText.setEditable(false); 546 this.yAxisText.setEditable(false); 547 this.xAxisText.removeModifyListener(this); 548 this.yAxisText.removeModifyListener(this); 549 } 550 551 557 private void setCoordinateEditionPoint(Point current) { 558 this.xAxisText.setText(Integer.toString(current.x)); 560 this.yAxisText.setText(Integer.toString(current.y)); 561 } 562 563 566 private void disableDrawBarItems() { 567 ToolItem[] childrenLeft = this.drawBarLeft.getItems(); 568 ToolItem[] childrenRight = this.drawBarRight.getItems(); 569 for (int i = 0; i < childrenLeft.length; i++) { 571 childrenLeft[i].setEnabled(false); 572 } 573 for (int i = 0; i < childrenRight.length; i++) { 574 childrenRight[i].setEnabled(false); 575 } 576 } 577 578 581 private void enableDrawBarItems() { 582 ToolItem[] childrenLeft = this.drawBarLeft.getItems(); 583 for (int i = 0; i < childrenLeft.length; i++) { 585 childrenLeft[i].setEnabled(true); 586 } 587 ToolItem[] childrenRight = this.drawBarRight.getItems(); 588 for (int i = 0; i < childrenRight.length; i++) { 590 childrenRight[i].setEnabled(true); 591 } 592 this.setNormalViewMode(); 594 this.drawCrenelHVDrawBarItem.setSelection(false); 596 this.drawCrenelVHDrawBarItem.setSelection(false); 597 this.drawNothingDrawBarItem.setSelection(true); 598 this.drawLineDrawBarItem.setSelection(false); 599 } 600 601 604 private void removeDrawBarItemText() { 605 cat.debug("-> removeDrawBarItemText"); 606 this.drawNothingDrawBarItem.setText(""); 607 this.drawLineDrawBarItem.setText(""); 608 this.maximizedViewBarItem.setText(""); 609 this.normalViewBarItem.setText(""); 610 this.drawCrenelHVDrawBarItem.setText("") ; 611 this.drawCrenelVHDrawBarItem.setText("") ; 612 this.addPointDrawBarItem.setText("") ; 613 this.deletePointDrawBarItem.setText("") ; 614 this.content.layout(); 616 } 617 618 621 private void addDrawBarItemText() { 622 cat.debug("-> addDrawBarItemText"); 623 this.drawNothingDrawBarItem.setText(drawNothingText); 624 this.drawLineDrawBarItem.setText(drawLineText); 625 this.maximizedViewBarItem.setText(maximizedViewText); 626 this.normalViewBarItem.setText(normalViewText); 627 this.drawCrenelHVDrawBarItem.setText(drawCrenelHVText) ; 628 this.drawCrenelVHDrawBarItem.setText(drawCrenelVHText) ; 629 this.addPointDrawBarItem.setText(addPointText) ; 630 this.deletePointDrawBarItem.setText(deletePointText) ; 631 this.content.layout(); 633 } 634 635 638 private void removeTooBarItemText() { 639 cat.debug("-> removeToolBarItemText"); 640 this.createGroupToolBarItem.setText(""); 641 this.selectionToolBarItem.setText(""); 642 this.editDescriptionToolBarItem.setText(""); 643 this.deleteSelectionToolBarItem.setText(""); 644 this.changeScaleToolBarItem.setText(""); 645 this.parent.layout(); 647 } 648 649 private void addToolBarItemText() { 650 cat.debug("-> addToolBarItemText"); 651 this.createGroupToolBarItem.setText(createGroupToolBarText); 652 this.selectionToolBarItem.setText(selectionText); 653 this.editDescriptionToolBarItem.setText(editDescriptionText); 654 this.deleteSelectionToolBarItem.setText(deleteSelectionText); 655 this.changeScaleToolBarItem.setText(changeScaleText); 656 this.parent.layout(); 658 } 659 660 667 private boolean switchSelectedGroup(Object source) { 668 cat.debug("-> switchSelectedRamp"); 669 Enumeration items = this.selectionMenuItems.keys(); 670 while (items.hasMoreElements()) { 672 Object item = items.nextElement(); 673 if (item == source) { 675 this 677 .setSelectedGroup((GroupDescription) this.selectionMenuItems 678 .get(item)); 679 return true; 680 } 681 } 682 return false; 683 } 684 685 692 public void setSelectedGroup(GroupDescription gd) { 693 cat.debug("-> setSelectedGroup"); 694 if (gd == null) { 697 GC gc = new GC(this.selectionImg); 699 gc.setBackground(this.parent.getDisplay().getSystemColor( 700 SWT.COLOR_WHITE)); 701 gc.fillRectangle(0, 0, 15, 15); 702 gc.dispose(); 703 this.selectionToolBarItem.setText(selectionText); 705 this.parent.layout(); 706 this.groupDescriptionSelected = null; 708 this.disableDrawBarItems(); 710 this.drawableCanvas.redraw(); 712 this.deleteSelectionToolBarItem.setEnabled(false); 714 this.editDescriptionToolBarItem.setEnabled(false); 715 716 return; 717 } 718 this.groupDescriptionSelected = gd; 720 GC gc = new GC(this.selectionImg); 722 gc.setBackground(this.groupDescriptionSelected.getCurveColor()); 723 gc.fillRectangle(0, 0, 15, 15); 724 gc.dispose(); 725 this.selectionToolBarItem.setText("Group " + gd.getGroupId() + " (" 727 + gd.getBehaviorId() + ")"); 728 this.parent.layout(); 729 this.enableDrawBarItems(); 731 this.drawableCanvas.redraw(); 733 this.deleteSelectionToolBarItem.setEnabled(true); 735 this.editDescriptionToolBarItem.setEnabled(true); 736 } 737 738 741 public GroupDescription getGroupDescriptionSelected() { 742 return groupDescriptionSelected; 743 } 744 745 748 public Composite getParent() { 749 return parent; 750 } 751 752 755 private void disposeSelectionItems() { 756 cat.debug("-> disposeSelectionItems"); 757 Enumeration items = this.selectionMenuItems.keys(); 758 while (items.hasMoreElements()) 760 ((MenuItem) items.nextElement()).dispose(); 761 } 762 763 766 private void initSelectGroupItems() { 767 cat.debug("-> initSelectRampItems"); 768 this.disposeSelectionItems(); 770 this.selectionMenuItems.clear(); 772 773 Enumeration elements = this.loadManager.getElements(); 774 while (elements.hasMoreElements()) { 776 GroupDescription gd = (GroupDescription) elements.nextElement(); 777 MenuItem item = new MenuItem(this.selectionMenu, SWT.PUSH); 779 item.setText("Group " + gd.getGroupId() + "(" + gd.getBehaviorId() 780 + ")"); 781 Image img = new Image(this.parent.getDisplay(), new Rectangle(10, 783 10, 10, 10)); 784 item.setImage(img); 786 GC gc = new GC(img); 788 gc.setBackground(gd.getCurveColor()); 789 gc.fillRectangle(0, 0, 10, 10); 790 gc.dispose(); 791 item.addSelectionListener(this); 793 this.selectionMenuItems.put(item, gd); 795 } 796 } 797 798 801 private void initDrawablePart() { 802 cat.debug("-> initDrawablePart"); 803 this.canvasComposite = new Composite(this.main, SWT.FLAT); 805 this.canvasComposite.setLayout(new FillLayout()); 807 this.main.setContent(this.canvasComposite); 809 this.drawableCanvas = new DrawableCanvas(this.canvasComposite, SWT.FLAT); 811 this.drawableCanvas.addMouseListener(this); 813 this.drawableCanvas.addMouseMoveListener(this); 814 this.drawableCanvas.addListener(SWT.RESIZE, this); 815 this.drawableCanvas.addPaintListener(this); 816 817 this.setDrawablePartSize(new Point( 819 ScaleConvertor.DEFAULT_MIN_CANVAS_SIZE.getWidth(), 820 ScaleConvertor.DEFAULT_MIN_CANVAS_SIZE.getHeight())); 821 } 822 823 829 private void setDrawablePartSize(Point p) { 830 cat.debug("-> setDrawablePartSize"); 831 this.main.setMinSize(p.toEclipsePoint()); 832 } 833 834 839 private Size getDrawableCanvasSize() { 840 Rectangle size = this.drawableCanvas.getBounds(); 842 return new Size(size.width, size.height); 843 } 844 845 849 852 private void drawAll() { 853 Rectangle size = this.drawableCanvas.getBounds(); 855 this.scaleConvertor.setCanvasSize(new Size(size.width, size.height)); 857 858 Enumeration e = this.loadManager.getElements() ; 860 while (e.hasMoreElements()) 861 this.drawGroup((GroupDescription)e.nextElement()) ; 862 863 if (this.groupDescriptionSelected == null) 864 return; 865 if (this.pointSelected != null) { 867 this.drawableCanvas.selectPoint(this.scaleConvertor 868 .realPointToEditorPoint(this.pointSelected), true); 869 } 870 if (this.groupDescriptionSelected != null) 873 this.drawGroupSelection(groupDescriptionSelected); 874 } 875 876 882 private void drawGroupSelection(GroupDescription rd) { 883 Rectangle size = this.drawableCanvas.getBounds(); 885 this.scaleConvertor.setCanvasSize(new Size(size.width, size.height)); 887 GroupDescription groupWithEditorPoints = this.scaleConvertor 888 .realGroupToEditorGroup(rd); 889 this.drawableCanvas.selectGroup(groupWithEditorPoints); 890 } 891 892 898 private void drawGroup(GroupDescription gd) { 899 Enumeration e = gd.getElements(); 900 while (e.hasMoreElements()) 902 drawRamp((RampDescription) e.nextElement(), gd.getCurveColor()); 903 } 904 905 913 private void drawRamp(RampDescription rd, Color c) { 914 RampDescription rampWithEditorPoints = this.scaleConvertor 915 .realRampToEditorRamp(rd); 916 this.drawableCanvas.drawRamp(rampWithEditorPoints, c); 917 } 918 919 922 private void drawMark() { 923 Size canvasSize = this.getDrawableCanvasSize(); 925 Color c = this.parent.getDisplay().getSystemColor(SWT.COLOR_BLACK); 927 928 int w = canvasSize.getWidth(); 929 int h = canvasSize.getHeight(); 930 931 this.scaleConvertor.setCanvasSize(canvasSize); 933 Color color = this.parent.getDisplay().getSystemColor(SWT.COLOR_BLACK); 935 936 this.drawableCanvas.drawRamp(this.scaleConvertor 938 .realRampToEditorRamp(new RampDescription("temp", 939 RampDescription.LINE, new Point(0, 0), new Point( 940 this.scaleConvertor.getScale().getWidth(), 0), 941 new Point(-1, -1))), color); 942 this.drawableCanvas.drawRamp(this.scaleConvertor 943 .realRampToEditorRamp(new RampDescription("temp", 944 RampDescription.LINE, new Point(0, 0), new Point(0, 945 this.scaleConvertor.getScale().getHeight()), 946 new Point(-1, -1))), color); 947 this.drawableCanvas.drawArrow(new Point(ScaleConvertor.MARGIN_LEFT, 949 ScaleConvertor.MARGIN_TOP), 8, 0, c); 950 this.drawableCanvas.drawArrow( 951 new Point(w - ScaleConvertor.MARGIN_RIGHT, h 952 - ScaleConvertor.MARGIN_BACK), 8, 1, c); 953 this.drawableCanvas.drawString(new Point(5, 2), "Nb Behaviors", c); 955 this.drawableCanvas.drawString(new Point(w - 90, h - 20), "Nb Seconds", 956 c); 957 } 958 959 962 private void drawGrad() { 963 Size canvasScale = this.scaleConvertor.getScale() ; 965 Color c = this.parent.getDisplay().getSystemColor(SWT.COLOR_BLACK); 967 968 int w = canvasScale.getWidth(); 969 int h = canvasScale.getHeight(); 970 int logw = ScaleConvertor.logTen(w); 972 int logh = ScaleConvertor.logTen(h); 973 int unitw = 1 ; 975 int unith = 1 ; 976 for (int i=0;i<logw-1;i++) unitw = unitw*10; 977 for (int i=0;i<logh-1;i++) unith = unith*10; 978 boolean subh = false; 980 boolean subw = false; 981 if (h/unith < 5) subh = true; 982 if (w/unitw < 5) subw = true; 983 int countw = 0 ; 985 while (countw < w) { 986 Point editorGrad = this.scaleConvertor.realPointToEditorPoint(new Point(countw,0)) ; 988 this.drawableCanvas.drawLine(editorGrad 990 ,new Point(editorGrad.x, editorGrad.y+ScaleConvertor.GRAD_SIZE) 991 ,c); 992 this.drawableCanvas.drawString(new Point(editorGrad.x-3,editorGrad.y+10),Integer.toString(countw),c); 993 if (subw) 994 countw += (unitw/2); 995 else 996 countw += unitw ; 997 } 998 999 int counth = 0 ; 1001 while (counth < h) { 1002 Point editorGrad = this.scaleConvertor.realPointToEditorPoint(new Point(0,counth)) ; 1004 this.drawableCanvas.drawLine(editorGrad 1006 ,new Point(editorGrad.x-ScaleConvertor.GRAD_SIZE,editorGrad.y) 1007 ,c); 1008 this.drawableCanvas.drawString(new Point(editorGrad.x-ScaleConvertor.MARGIN_LEFT,editorGrad.y-8),Integer.toString(counth),c); 1009 if (subh) 1010 counth += (unith/2); 1011 else 1012 counth += unith ; 1013 } 1014 } 1015 1016 1020 1026 private void initChangePointMode(Point selected) { 1027 cat.warn("-> initChangePointMode : " + selected); 1028 this.currentMode = CHANGE_POINT; 1030 this.drawableCanvas.setCursor(new Cursor(this.parent.getDisplay(), 1032 SWT.CURSOR_SIZEALL)); 1033 this.first = this.scaleConvertor.realPointToEditorPoint(new Point( 1036 selected.x, selected.y)); 1037 this.last = new Point(selected.x, selected.y); 1038 1039 this.drawableCanvas.eraseSelectionPoint(this.first); 1041 } 1042 1043 1050 private void initSelectionPointMode(Point selected) { 1051 cat.warn("-> initSelectionPointMode : " + selected); 1052 this.currentMode = SELECTION_POINT; 1054 this.pointSelected = selected; 1056 this.drawableCanvas.redraw(); 1058 this.enableCoordinateEdition(); 1060 this.setCoordinateEditionPoint(selected); 1062 this.drawableCanvas.setCursor(new Cursor(this.parent.getDisplay(), 1064 SWT.CURSOR_ARROW)); 1065 } 1066 1067 1070 private void initDrawCrenelHVMode() { 1071 cat.debug("-> initDrawCrenelHVMode"); 1072 this.currentMode = DRAW_CRENEL_HV; 1074 this.deletePointDrawBarItem.setSelection(false) ; 1076 this.drawCrenelHVDrawBarItem.setSelection(true); 1077 this.drawCrenelVHDrawBarItem.setSelection(false); 1078 this.drawNothingDrawBarItem.setSelection(false); 1079 this.drawLineDrawBarItem.setSelection(false); 1080 this.addPointDrawBarItem.setSelection(false) ; 1081 this.drawableCanvas.setCursor(new Cursor(this.parent.getDisplay(), 1083 SWT.CURSOR_CROSS)); 1084 if (this.groupDescriptionSelected.getRamps().size() != 0) { 1086 Point lastDrawed = ((RampDescription) this.groupDescriptionSelected 1088 .getRamps() 1089 .elementAt( 1090 this.groupDescriptionSelected.getRamps().size() - 1)) 1091 .getEnd(); 1092 this.first = new Point(lastDrawed.x, lastDrawed.y); 1094 } else { 1095 this.first = new Point(-1, -1); 1097 } 1098 this.last = new Point(-1, -1); 1099 } 1100 1101 1104 private void initDrawCrenelVHMode() { 1105 cat.debug("-> initDrawCrenelVHMode"); 1106 this.currentMode = DRAW_CRENEL_VH; 1108 this.drawCrenelHVDrawBarItem.setSelection(false); 1110 this.drawCrenelVHDrawBarItem.setSelection(true); 1111 this.drawNothingDrawBarItem.setSelection(false); 1112 this.addPointDrawBarItem.setSelection(false) ; 1113 this.deletePointDrawBarItem.setSelection(false) ; 1114 this.drawLineDrawBarItem.setSelection(false); 1115 this.drawableCanvas.setCursor(new Cursor(this.parent.getDisplay(), 1117 SWT.CURSOR_CROSS)); 1118 if (this.groupDescriptionSelected.getRamps().size() != 0) { 1120 Point lastDrawed = ((RampDescription) this.groupDescriptionSelected 1122 .getRamps() 1123 .elementAt( 1124 this.groupDescriptionSelected.getRamps().size() - 1)) 1125 .getEnd(); 1126 this.first = new Point(lastDrawed.x, lastDrawed.y); 1128 } else { 1129 this.first = new Point(-1, -1); 1131 } 1132 this.last = new Point(-1, -1); 1133 } 1134 1135 1138 private void initLineMode() { 1139 cat.debug("-> initLineMode"); 1140 this.currentMode = DRAW_LINE; 1142 this.drawCrenelHVDrawBarItem.setSelection(false); 1144 this.drawCrenelVHDrawBarItem.setSelection(false); 1145 this.drawNothingDrawBarItem.setSelection(false); 1146 this.drawLineDrawBarItem.setSelection(true); 1147 this.deletePointDrawBarItem.setSelection(false) ; 1148 this.addPointDrawBarItem.setSelection(false) ; 1149 this.drawableCanvas.setCursor(new Cursor(this.parent.getDisplay(), 1151 SWT.CURSOR_CROSS)); 1152 if (this.groupDescriptionSelected.getRamps().size() != 0) { 1154 Point lastDrawed = ((RampDescription) this.groupDescriptionSelected 1156 .getRamps() 1157 .elementAt( 1158 this.groupDescriptionSelected.getRamps().size() - 1)) 1159 .getEnd(); 1160 this.first = new Point( 1162 lastDrawed.x, lastDrawed.y); 1163 } else { 1164 this.first = new Point(-1, -1); 1166 } 1167 this.last = new Point(-1, -1); 1168 } 1169 1170 1173 private void initAddPointMode() { 1174 cat.debug("-> initAddPointMode") ; 1175 this.currentMode = ADD_POINT_MODE ; 1177 this.drawCrenelHVDrawBarItem.setSelection(false); 1179 this.drawCrenelVHDrawBarItem.setSelection(false); 1180 this.drawNothingDrawBarItem.setSelection(false); 1181 this.drawLineDrawBarItem.setSelection(false); 1182 this.addPointDrawBarItem.setSelection(true) ; 1183 this.deletePointDrawBarItem.setSelection(false) ; 1184 this.drawableCanvas.setCursor(new Cursor(this.parent.getDisplay(), 1186 SWT.CURSOR_CROSS)); 1187 } 1188 1189 1192 private void initDeletePointMode() { 1193 cat.debug("-> initDeletePointMode") ; 1194 this.currentMode = DELETE_POINT_MODE ; 1196 this.drawCrenelHVDrawBarItem.setSelection(false); 1198 this.drawCrenelVHDrawBarItem.setSelection(false); 1199 this.drawNothingDrawBarItem.setSelection(false); 1200 this.drawLineDrawBarItem.setSelection(false); 1201 this.addPointDrawBarItem.setSelection(false) ; 1202 this.deletePointDrawBarItem.setSelection(true) ; 1203 this.drawableCanvas.setCursor(new Cursor(this.parent.getDisplay(), 1205 SWT.CURSOR_CROSS)); 1206 } 1207 1208 1211 private void finishDrawCrenelXXMode() { 1212 cat.debug("-> finishDrawCrenelXXMode") ; 1213 if (this.first.x != -1) { 1215 this.drawableCanvas.redraw(); 1217 } 1218 this.drawableCanvas.setCursor(new Cursor(this.parent.getDisplay(), 1220 SWT.CURSOR_ARROW)); 1221 } 1222 1223 1226 private void finishChangePointMode() { 1227 cat.debug("-> finish change point mode"); 1228 this.drawableCanvas.redraw(); 1230 this.currentMode = DRAW_NOTHING; 1232 } 1233 1234 private void finishAddPointMode() { 1235 cat.debug("-> finishAddPointMode") ; 1236 this.drawableCanvas.redraw() ; 1238 this.drawableCanvas.setCursor(new Cursor(this.parent.getDisplay(), 1240 SWT.CURSOR_ARROW)); 1241 } 1242 1243 private void finishDeletePointMode() { 1244 cat.debug("-> finishDeletePointMode") ; 1245 this.drawableCanvas.redraw() ; 1247 this.drawableCanvas.setCursor(new Cursor(this.parent.getDisplay(), 1249 SWT.CURSOR_ARROW)); 1250 } 1251 1252 1255 private void finishLineMode() { 1256 cat.warn("-> finishLineMode"); 1257 if (this.first.x != -1) { 1259 this.drawableCanvas.redraw(); 1261 } 1262 this.drawableCanvas.setCursor(new Cursor(this.parent.getDisplay(), 1264 SWT.CURSOR_ARROW)); 1265 } 1266 1267 1270 private void finishSelectionPointMode() { 1271 cat.warn("-> finishSelectionPointMode"); 1272 this.disableCoordinateEdition(); 1274 this.pointSelected = null; 1276 this.drawableCanvas.redraw(); 1278 } 1279 1280 1283 private void finishMode() { 1284 cat.debug("-> finishMode"); 1285 switch (this.currentMode) { 1287 case DELETE_POINT_MODE : 1288 finishDeletePointMode() ; 1289 break ; 1290 case ADD_POINT_MODE : 1291 finishAddPointMode() ; 1292 break ; 1293 case DRAW_LINE : 1294 finishLineMode(); 1295 break; 1296 case DRAW_NOTHING : 1297 break; 1299 case CHANGE_POINT : 1300 finishChangePointMode(); 1301 break; 1302 case SELECTION_POINT : 1303 finishSelectionPointMode(); 1304 break; 1305 case DRAW_CRENEL_HV : 1307 case DRAW_CRENEL_VH : 1308 finishDrawCrenelXXMode() ; 1309 break ; 1310 default : 1311 cat.warn("This draw mode is UNKNOW"); 1312 } 1313 this.drawCrenelHVDrawBarItem.setSelection(false); 1315 this.drawCrenelVHDrawBarItem.setSelection(false); 1316 this.addPointDrawBarItem.setSelection(false) ; 1317 this.drawNothingDrawBarItem.setSelection(true); 1318 this.deletePointDrawBarItem.setSelection(false) ; 1319 this.drawLineDrawBarItem.setSelection(false); 1320 this.currentMode = DRAW_NOTHING; 1322 } 1323 1324 1328 1337 private boolean isCorrectDrawablePoint(Point p, boolean showWarning) { 1338 if (this.scaleConvertor.isInMarginPoint(p)) { 1340 if (showWarning) 1341 MessageDialog.openWarning(this.parent.getShell(), "Warning", 1342 "The selecting point is outside the drawable area..."); 1343 return false; 1344 } 1345 if ((this.first.x != -1) && (this.first.y != -1)) { 1347 Point firstEditor = this.scaleConvertor.realPointToEditorPoint(this.first) ; 1350 if (p.x <= firstEditor.x) { 1351 if (showWarning) 1352 MessageDialog 1353 .openWarning(this.parent.getShell(), "Warning", 1354 "The selected point must be after the first point of the ramp... " + p.x + ", " + firstEditor.x) ; 1355 return false; 1356 } 1357 } 1358 return true; 1360 } 1361 1362 1369 private boolean isCorrectDrawableRamp(RampDescription rd, boolean showWarning) { 1370 if (this.scaleConvertor.isInMarginPoint(this.scaleConvertor 1372 .realPointToEditorPoint(rd.getStart()))) { 1373 if (showWarning) 1374 MessageDialog.openWarning(this.parent.getShell(), "Warning", 1375 "The selecting point is outside the drawable area..."); 1376 return false; 1377 } 1378 if (this.scaleConvertor.isInMarginPoint(this.scaleConvertor 1380 .realPointToEditorPoint(rd.getEnd()))) { 1381 if (showWarning) 1382 MessageDialog.openWarning(this.parent.getShell(), "Warning", 1383 "The selecting point is outside the drawable area..."); 1384 return false; 1385 } 1386 if (rd.getStart().x > rd.getEnd().x) { 1388 if (showWarning) 1389 MessageDialog 1390 .openWarning(this.parent.getShell(), "Warning", 1391 "The selected point must be after the first point of the ramp..."); 1392 return false; 1393 } 1394 return true; 1396 } 1397 1398 1403 private void clickCrenelHVMode(MouseEvent e) { 1404 cat.debug("-> clickCrenelHVMode") ; 1405 Point real = this.scaleConvertor.editorPointToRealPoint(new Point(e.x, 1407 e.y)); 1408 this.setCoordinateEditionPoint(real); 1410 if (e.button == 2) { 1412 this.finishMode() ; 1414 this.initDrawCrenelVHMode() ; 1416 this.moveCrenelVHMode(e) ; 1417 return ; 1418 } 1419 if (!this.isCorrectDrawablePoint(new Point(e.x, e.y), SHOW_WARNING_DIALOGS)) { 1421 return; 1423 } 1424 if (this.first.x == -1 && this.first.y == -1) { 1426 this.first = real ; 1428 return ; 1430 } 1431 1432 String rampId = this.loadManager.rampIdGenerator() ; 1434 1435 RampDescription tempToAdd = new RampDescription(rampId, RampDescription.CRENEL_HV) ; 1437 tempToAdd.setStart(new Point(this.first.x, this.first.y)) ; 1438 tempToAdd.setEnd(new Point(real.x, real.y)) ; 1439 1440 this.groupDescriptionSelected.addRamp(tempToAdd) ; 1442 this.drawableCanvas.redraw() ; 1444 this.first = new Point(real.x, real.y) ; 1446 1447 } 1448 1449 1454 private void clickCrenelVHMode(MouseEvent e) { 1455 cat.debug("-> clickCrenelVHMode") ; 1456 Point real = this.scaleConvertor.editorPointToRealPoint(new Point(e.x, 1458 e.y)); 1459 this.setCoordinateEditionPoint(real); 1461 if (e.button == 2) { 1463 this.finishMode() ; 1465 this.initDrawCrenelHVMode() ; 1467 this.moveCrenelHVMode(e) ; 1468 return ; 1469 } 1470 if (!this.isCorrectDrawablePoint(new Point(e.x, e.y), SHOW_WARNING_DIALOGS)) { 1472 return; 1474 } 1475 if (this.first.x == -1 && this.first.y == -1) { 1477 this.first = real ; 1479 return ; 1481 } 1482 this.last = real ; 1484 1485 String rampId = this.loadManager.rampIdGenerator() ; 1487 1488 RampDescription tempToAdd = new RampDescription(rampId, RampDescription.CRENEL_VH) ; 1490 tempToAdd.setStart(new Point(this.first.x, this.first.y)) ; 1491 tempToAdd.setEnd(new Point(this.last.x, this.last.y)) ; 1492 1493 this.groupDescriptionSelected.addRamp(tempToAdd) ; 1495 this.drawableCanvas.redraw() ; 1497 this.first = new Point(real.x, real.y) ; 1499 } 1500 1501 1505 private void clickLineMode(MouseEvent e) { 1506 if (!this.isCorrectDrawablePoint(new Point(e.x, e.y), SHOW_WARNING_DIALOGS)) { 1508 return; 1510 } 1511 if ((this.first.x == -1) && (this.first.y == -1)) { 1513 this.first = this.scaleConvertor.editorPointToRealPoint(new Point(e.x, e.y)) ; 1515 return; 1517 } 1518 1519 this.last = this.scaleConvertor.editorPointToRealPoint(new Point(e.x, e.y)) ; 1522 1523 if (this.groupDescriptionSelected != null) { 1525 String tempID = this.loadManager.rampIdGenerator(); 1527 RampDescription curveWithRealPoints = new RampDescription(tempID, RampDescription.LINE, this.first, this.last, new Point(-1,-1)) ; 1528 this.groupDescriptionSelected.addRamp(curveWithRealPoints); 1529 this.drawableCanvas.redraw(); 1531 } else { 1532 cat 1534 .warn("There is no group description selected, so we can't save the current ramp drawed"); 1535 ; 1536 } 1537 this.first.x = this.last.x; 1540 this.first.y = this.last.y; 1541 } 1542 1543 1550 private void clickNothingMode(MouseEvent e) { 1551 if (this.groupDescriptionSelected == null) { 1553 return; 1555 } 1556 Point temp = this.scaleConvertor.editorPointIsSelectableRealGroupPoint( 1558 new Point(e.x, e.y), this.groupDescriptionSelected); 1559 if (!temp.equals(new Point(-1, -1))) { 1560 if (e.button == 1) { 1563 this.initChangePointMode(temp); 1565 } 1566 if (e.button == 2) { 1567 this.initSelectionPointMode(temp); 1569 } 1570 return; 1572 } 1573 } 1574 1575 1582 private void clickChangePointMode(MouseEvent e) { 1583 1584 Point real = this.scaleConvertor.editorPointToRealPoint(new Point(e.x, 1586 e.y)); 1587 Point curvesNumbers = this.groupDescriptionSelected 1589 .rampsWhichContains(this.last); 1590 1591 RampDescription c1 = null; 1592 RampDescription c2 = null; 1593 RampDescription clone1 = null; 1594 RampDescription clone2 = null; 1595 if (curvesNumbers.x != -1) { 1596 c1 = (RampDescription) this.groupDescriptionSelected.getRamps() 1597 .elementAt((int) curvesNumbers.x); 1598 clone1 = (RampDescription) c1.clone(); 1600 clone1.getEnd().x = real.x; 1601 clone1.getEnd().y = real.y; 1602 } 1603 if (curvesNumbers.y != -1) { 1604 c2 = (RampDescription) this.groupDescriptionSelected.getRamps() 1605 .elementAt((int) curvesNumbers.y); 1606 clone2 = (RampDescription) c2.clone(); 1608 clone2.getStart().x = real.x; 1609 clone2.getStart().y = real.y; 1610 } 1611 if ((c1 != null) && (c2 != null)) { 1613 if (isCorrectDrawableRamp(clone1, SHOW_WARNING_DIALOGS) && isCorrectDrawableRamp(clone2, SHOW_WARNING_DIALOGS)) { 1615 c1.getEnd().x = real.x; 1616 c1.getEnd().y = real.y; 1617 c2.getStart().x = real.x; 1618 c2.getStart().y = real.y; 1619 } else { 1620 return; 1621 } 1622 } 1623 else if (c1 != null) { 1625 if (isCorrectDrawableRamp(clone1, SHOW_WARNING_DIALOGS)) { 1626 c1.getEnd().x = real.x; 1627 c1.getEnd().y = real.y; 1628 } else 1629 return; 1630 } 1631 else if (c2 != null) { 1633 if (isCorrectDrawableRamp(clone2, SHOW_WARNING_DIALOGS)) { 1634 c2.getStart().x = real.x; 1635 c2.getStart().y = real.y; 1636 } else 1637 return; 1638 } 1639 1640 this.currentMode = DRAW_NOTHING; 1642 this.drawableCanvas.redraw(); 1644 } 1645 1646 1650 private void clickAddPointMode(MouseEvent e) { 1651 cat.debug("-> clickAddPointMode") ; 1652 if (this.scaleConvertor.isInMarginPoint(new Point(e.x,e.y))) { 1654 if (SHOW_WARNING_DIALOGS) 1655 MessageDialog.openWarning(this.parent.getShell(), "Warning", 1656 "The selecting point is outside the drawable area..."); 1657 return; 1658 } 1659 if (this.groupDescriptionSelected == null) { 1661 return ; 1663 } 1664 Point realPoint = this.scaleConvertor.editorPointToRealPoint(new Point(e.x,e.y)) ; 1666 this.groupDescriptionSelected.addPoint(realPoint) ; 1668 1669 this.drawableCanvas.redraw(); 1671 } 1672 1673 1677 private void clickDeletePointMode(MouseEvent e) { 1678 cat.debug("-> clickDeletePointMode") ; 1679 if (this.scaleConvertor.isInMarginPoint(new Point(e.x,e.y))) { 1681 if (SHOW_WARNING_DIALOGS) 1682 MessageDialog.openWarning(this.parent.getShell(), "Warning", 1683 "The selecting point is outside the drawable area..."); 1684 return; 1685 } 1686 if (this.groupDescriptionSelected == null) { 1688 return ; 1690 } 1691 Point temp = this.scaleConvertor.editorPointIsSelectableRealGroupPoint( 1692 new Point(e.x, e.y), this.groupDescriptionSelected); 1693 if (temp.x != -1 && temp.y != -1) { 1695 this.groupDescriptionSelected.deletePoint(temp) ; 1697 } 1698 this.drawableCanvas.redraw(); 1700 } 1701 1702 1706 private void moveCrenelHVMode(MouseEvent e) { 1707 cat.debug("-> moveCrenelHVMode") ; 1708 Point real = this.scaleConvertor.editorPointToRealPoint(new Point(e.x, 1710 e.y)); 1711 this.setCoordinateEditionPoint(real); 1713 if (this.first.x == -1 && this.first.y == -1) { 1715 return ; 1717 } 1718 if (this.last.x != -1 && this.last.y != -1) { 1720 RampDescription tempToErase = new RampDescription("temp", RampDescription.CRENEL_HV) ; 1721 tempToErase.setStart(new Point(this.first.x, this.first.y)) ; 1722 tempToErase.setEnd(new Point(this.last.x, this.last.y)) ; 1723 this.drawableCanvas.drawRamp(this.scaleConvertor.realRampToEditorRamp(tempToErase), this.parent.getDisplay().getSystemColor(DrawableCanvas.BACK_COLOR)) ; 1724 } 1725 this.last = real ; 1727 1728 RampDescription tempToDraw = new RampDescription("temp", RampDescription.CRENEL_HV) ; 1730 tempToDraw.setStart(new Point(this.first.x, this.first.y)) ; 1731 tempToDraw.setEnd(new Point(this.last.x, this.last.y)) ; 1732 this.drawableCanvas.drawRamp(this.scaleConvertor.realRampToEditorRamp(tempToDraw), this.groupDescriptionSelected.getCurveColor()) ; 1733 } 1734 1735 1739 private void moveCrenelVHMode(MouseEvent e) { 1740 cat.debug("-> moveCrenelVHMode") ; 1741 Point real = this.scaleConvertor.editorPointToRealPoint(new Point(e.x, 1743 e.y)); 1744 this.setCoordinateEditionPoint(real); 1746 if (this.first.x == -1 && this.first.y == -1) { 1748 return ; 1750 } 1751 if (this.last.x != -1 && this.last.y != -1) { 1753 RampDescription tempToErase = new RampDescription("temp", RampDescription.CRENEL_VH) ; 1754 tempToErase.setStart(new Point(this.first.x, this.first.y)) ; 1755 tempToErase.setEnd(new Point(this.last.x, this.last.y)) ; 1756 this.drawableCanvas.drawRamp(this.scaleConvertor.realRampToEditorRamp(tempToErase), this.parent.getDisplay().getSystemColor(DrawableCanvas.BACK_COLOR)) ; 1757 } 1758 this.last = real ; 1760 1761 RampDescription tempToDraw = new RampDescription("temp", RampDescription.CRENEL_VH) ; 1763 tempToDraw.setStart(new Point(this.first.x, this.first.y)) ; 1764 tempToDraw.setEnd(new Point(this.last.x, this.last.y)) ; 1765 this.drawableCanvas.drawRamp(this.scaleConvertor.realRampToEditorRamp(tempToDraw), this.groupDescriptionSelected.getCurveColor()) ; 1766 } 1767 1768 1774 private void moveChangePointMode(MouseEvent e) { 1775 cat.warn("-> moveChangePointMode"); 1776 Point real = this.scaleConvertor.editorPointToRealPoint(new Point(e.x, 1778 e.y)); 1779 this.setCoordinateEditionPoint(real); 1781 1782 Point curvesParentNumber = this.groupDescriptionSelected 1785 .rampsWhichContains(this.last); 1786 1787 if (curvesParentNumber.x != -1) { 1791 RampDescription tempDesc = (RampDescription) this.groupDescriptionSelected 1792 .getRamps().elementAt((int) curvesParentNumber.x); 1793 RampDescription editorCurve = this.scaleConvertor 1794 .realRampToEditorRamp(tempDesc); 1795 this.drawableCanvas.drawRamp(new RampDescription("temp", 1797 editorCurve.getType(), editorCurve.getStart(), this.first, 1798 editorCurve.getAngle()), this.parent.getDisplay() 1799 .getSystemColor(DrawableCanvas.BACK_COLOR)); 1800 this.drawableCanvas.drawRamp(new RampDescription("temp", 1802 editorCurve.getType(), editorCurve.getStart(), new Point( 1803 e.x, e.y), editorCurve.getAngle()), 1804 this.groupDescriptionSelected.getCurveColor()); 1805 } 1806 if (curvesParentNumber.y != -1) { 1808 RampDescription tempDesc = (RampDescription) this.groupDescriptionSelected 1810 .getRamps().elementAt((int) curvesParentNumber.y); 1811 RampDescription editorCurve = this.scaleConvertor 1814 .realRampToEditorRamp(tempDesc); 1815 this.drawableCanvas.drawRamp(new RampDescription("temp", 1817 editorCurve.getType(), this.first, editorCurve.getEnd(), 1818 editorCurve.getAngle()), this.parent.getDisplay() 1819 .getSystemColor(DrawableCanvas.BACK_COLOR)); 1820 this.drawableCanvas.drawRamp(new RampDescription("temp", 1822 editorCurve.getType(), new Point(e.x, e.y), editorCurve 1823 .getEnd(), editorCurve.getAngle()), 1824 this.groupDescriptionSelected.getCurveColor()); 1825 } 1826 this.first.x = e.x; 1828 this.first.y = e.y; 1829 } 1830 1831 1837 private void moveNothingMode(MouseEvent e) { 1838 Point real = this.scaleConvertor.editorPointToRealPoint(new Point(e.x, 1840 e.y)); 1841 this.setCoordinateEditionPoint(real); 1843 if (this.groupDescriptionSelected == null) { 1845 return; 1847 } 1848 Point temp = this.scaleConvertor.editorPointIsSelectableRealGroupPoint( 1849 new Point(e.x, e.y), this.groupDescriptionSelected); 1850 if (!temp.equals(new Point(-1, -1))) { 1851 this.drawableCanvas.setCursor(new Cursor(this.parent.getDisplay(), 1853 SWT.CURSOR_SIZEALL)); 1854 return; 1856 } 1857 this.drawableCanvas.setCursor(new Cursor(this.parent.getDisplay(), 1859 SWT.CURSOR_ARROW)); 1860 } 1861 1862 1869 private void moveLineMode(MouseEvent e) { 1870 Point real = this.scaleConvertor.editorPointToRealPoint(new Point(e.x, 1872 e.y)); 1873 this.setCoordinateEditionPoint(real); 1875 if (this.first.x == -1) { 1877 return; 1879 } 1880 1881 Point firstEditor = this.scaleConvertor.realPointToEditorPoint(this.first) ; 1883 1884 if (this.last.x != -1 && this.last.y != -1) { 1886 this.drawableCanvas.eraseLine(firstEditor, this.last) ; 1887 } 1888 1889 this.drawableCanvas.drawLine(firstEditor, new Point(e.x, e.y), 1891 this.groupDescriptionSelected.getCurveColor()); 1892 this.last = new Point(e.x, e.y) ; 1894 } 1895 1896 1900 private void moveAddPointMode(MouseEvent e) { 1901 Point real = this.scaleConvertor.editorPointToRealPoint(new Point(e.x, 1903 e.y)); 1904 this.setCoordinateEditionPoint(real); 1906 if (this.last.x != -1 && this.last.y != -1) 1908 this.drawableCanvas.eraseSelectionPoint(this.last) ; 1909 this.last = new Point(e.x,e.y) ; 1911 this.drawableCanvas.selectPoint(this.last, false) ; 1913 } 1914 1915 1920 private void moveDeletePointMode(MouseEvent e) { 1921 cat.warn("-> moveDeletePointMode"); 1922 Point real = this.scaleConvertor.editorPointToRealPoint(new Point(e.x, 1924 e.y)); 1925 this.setCoordinateEditionPoint(real); 1927 1928 if (this.groupDescriptionSelected == null) { 1930 return; 1932 } 1933 Point temp = this.scaleConvertor.editorPointIsSelectableRealGroupPoint( 1934 new Point(e.x, e.y), this.groupDescriptionSelected); 1935 if (!temp.equals(new Point(-1, -1))) { 1936 this.drawableCanvas.setCursor(new Cursor(this.parent.getDisplay(), 1938 SWT.CURSOR_HAND)); 1939 return; 1941 } 1942 this.drawableCanvas.setCursor(new Cursor(this.parent.getDisplay(), 1944 SWT.CURSOR_CROSS)); 1945 } 1946 1947 1951 1954 private void setMaximizedViewMode() { 1955 this.normalViewBarItem.setEnabled(true); 1957 this.maximizedViewBarItem.setEnabled(false); 1958 Size scale = this.scaleConvertor.getScale(); 1960 Size toSet = new Size(scale.getWidth() + ScaleConvertor.MARGIN_LEFT 1962 + ScaleConvertor.MARGIN_RIGHT, scale.getHeight() 1963 + ScaleConvertor.MARGIN_TOP + ScaleConvertor.MARGIN_BACK); 1964 this.setDrawablePartSize(toSet.toPoint()); 1966 } 1967 1968 1971 private void setNormalViewMode() { 1972 this.normalViewBarItem.setEnabled(false); 1974 this.maximizedViewBarItem.setEnabled(true); 1975 Size scale = ScaleConvertor.DEFAULT_MIN_CANVAS_SIZE; 1977 this.setDrawablePartSize(scale.toPoint()); 1979 } 1980 1981 1985 public void setScale(Size newScale) { 1986 if (newScale != null) { 1987 this.scaleConvertor.setScale(newScale); 1988 this.drawableCanvas.redraw(); 1989 } 1990 } 1991 1992 1996 1999 public void mouseDoubleClick(MouseEvent event) { 2000 cat.debug("-> mouseDoubleClick"); 2001 } 2002 2003 2006 public void mouseDown(MouseEvent event) { 2007 cat.debug("-> mouseDown"); 2008 } 2009 2010 2013 public void mouseUp(MouseEvent event) { 2014 cat.debug("-> MOUSE UP - " + event.button); 2015 Rectangle size = this.drawableCanvas.getBounds(); 2017 this.scaleConvertor.setCanvasSize(new Size(size.width, size.height)); 2019 if (event.button == 3) { 2022 cat 2023 .warn("The button PRESSED is THE RIGHT ONE !!! End the current mode"); 2024 this.finishMode(); 2025 return; 2027 } 2028 switch (this.currentMode) { 2031 case DELETE_POINT_MODE : 2032 this.clickDeletePointMode(event) ; 2033 break ; 2034 case ADD_POINT_MODE : 2035 this.clickAddPointMode(event) ; 2036 break ; 2037 case DRAW_NOTHING : 2038 this.clickNothingMode(event); 2039 break; 2040 case DRAW_LINE : 2041 this.clickLineMode(event); 2042 break; 2043 case CHANGE_POINT : 2044 this.clickChangePointMode(event); 2045 break; 2046 case SELECTION_POINT : 2047 this.finishMode(); 2048 this.clickNothingMode(event); 2049 break; 2050 case DRAW_CRENEL_HV : 2051 this.clickCrenelHVMode(event) ; 2052 break ; 2053 case DRAW_CRENEL_VH : 2054 this.clickCrenelVHMode(event) ; 2055 break ; 2056 default : 2057 cat.warn("UNKNOW DRAWING MODE : " + this.currentMode); 2059 } 2060 } 2061 2062 2065 public void mouseMove(MouseEvent event) { 2066 switch (this.currentMode) { 2068 case DELETE_POINT_MODE : 2069 this.moveDeletePointMode(event) ; 2070 break ; 2071 case ADD_POINT_MODE : 2072 this.moveAddPointMode(event) ; 2073 break ; 2074 case DRAW_NOTHING : 2075 this.moveNothingMode(event); 2076 break; 2077 case DRAW_LINE : 2078 this.moveLineMode(event); 2079 break; 2080 case CHANGE_POINT : 2081 this.moveChangePointMode(event); 2082 break; 2083 case DRAW_CRENEL_HV : 2084 this.moveCrenelHVMode(event) ; 2085 break ; 2086 case DRAW_CRENEL_VH : 2087 this.moveCrenelVHMode(event) ; 2088 break ; 2089 case SELECTION_POINT : 2090 break; 2092 default : 2093 cat.warn("UNKNOW DRAW MODE : " + this.currentMode); 2094 } 2095 } 2096 2097 2100 public void widgetDefaultSelected(SelectionEvent event) { 2101 cat.debug("-> widgetDefaultSelected"); 2102 } 2103 2106 public void widgetSelected(SelectionEvent event) { 2107 cat.warn("-> WidgetSelected"); 2108 2111 if (event.getSource() == this.createGroupToolBarItem) { 2113 Vector ids = (TreeManager.getTreeManager(null)).getBehaviorsIds(); 2115 if (ids.size() == 0) { 2117 if (SHOW_WARNING_DIALOGS) 2118 MessageDialog.openInformation(this.parent.getShell(), 2119 createBehaviorInformationTitle, 2120 createBehaviorInformationContent); 2121 return; 2122 } 2123 GroupDescription lpd = new GroupDescription(this.loadManager 2125 .groupIdGenerator()); 2126 GroupDescriptionWizard wizard = new GroupDescriptionWizard(lpd, ids); 2128 WizardDialog dialog = new WizardDialog(this.parent.getShell(), 2129 wizard); 2130 int erno = dialog.open(); 2131 if (erno == 0) { 2133 String id = null; 2134 this.loadManager.addGroupDescription(lpd); 2136 this.setSelectedGroup(lpd); 2138 } 2139 return; 2140 } 2141 2142 if (event.getSource() == this.selectionToolBarItem) { 2144 this.initSelectGroupItems(); 2146 if (this.selectionMenuItems.size() == 0) { 2148 if (SHOW_WARNING_DIALOGS) 2149 MessageDialog.openInformation(this.parent.getShell(), 2150 createRampInformationTitle, 2151 createRampInformationContent); 2152 return; 2153 } 2154 Rectangle rect = this.selectionToolBarItem.getBounds(); 2156 org.eclipse.swt.graphics.Point pt = new org.eclipse.swt.graphics.Point( 2157 rect.x, rect.y + rect.height); 2158 pt = this.toolBar.toDisplay(pt); 2159 this.selectionMenu.setLocation(pt.x, pt.y); 2160 this.selectionMenu.setVisible(true); 2161 return; 2162 } 2163 2164 if (event.getSource() == this.deleteSelectionToolBarItem) { 2166 if (this.groupDescriptionSelected != null) { 2167 this.loadManager 2169 .removeGroupDescription(this.groupDescriptionSelected); 2170 this.setSelectedGroup(null); 2172 this.window.setScenarioSavedState(false); 2174 } 2175 return; 2176 } 2177 2178 if (event.getSource() == this.editDescriptionToolBarItem) { 2180 if (this.groupDescriptionSelected != null) { 2181 Vector ids = TreeManager.getTreeManager(null).getBehaviorsIds(); 2183 GroupDescriptionWizard wizard = new GroupDescriptionWizard( 2185 this.groupDescriptionSelected, ids); 2186 WizardDialog dialog = new WizardDialog(this.parent.getShell(), 2187 wizard); 2188 int erno = dialog.open(); 2189 this.setSelectedGroup(this.groupDescriptionSelected); 2191 this.window.setScenarioSavedState(false); 2193 } 2194 return; 2195 } 2196 2197 if (event.getSource() == this.changeScaleToolBarItem) { 2199 ChangeScaleDialog dialog = new ChangeScaleDialog(this.toolBar 2201 .getShell(), this.scaleConvertor.getScale()); 2202 Size newScale = dialog.open(); 2203 this.setScale(newScale) ; 2204 return; 2205 } 2206 2207 2210 if (event.getSource() == this.showTextPopupItem) { 2212 if (!this.showTextPopupItem.getSelection()) { 2214 this.removeTooBarItemText(); 2216 this.showTextPopupItem.setSelection(false); 2217 return; 2218 } 2219 this.addToolBarItemText(); 2221 this.showTextPopupItem.setSelection(true); 2222 return; 2223 } 2224 2225 if (event.getSource() == this.showTextDrawPopupItem) { 2227 if (!this.showTextDrawPopupItem.getSelection()) { 2229 this.removeDrawBarItemText(); 2231 this.showTextDrawPopupItem.setSelection(false); 2232 return; 2233 } 2234 this.addDrawBarItemText(); 2236 this.showTextDrawPopupItem.setSelection(true); 2237 return; 2238 } 2239 2240 2243 boolean tempSavedState = this.window.getScenarioSavedState() ; 2244 if (tempSavedState) 2245 this.window.setScenarioSavedState(false); 2246 2247 if (event.getSource() == this.deletePointDrawBarItem) { 2249 this.finishMode() ; 2251 this.initDeletePointMode() ; 2253 } 2254 2255 if (event.getSource() == this.addPointDrawBarItem) { 2257 this.finishMode() ; 2259 this.initAddPointMode() ; 2261 } 2262 2263 if (event.getSource() == this.drawNothingDrawBarItem) { 2265 this.finishMode(); 2267 return; 2270 } 2271 2272 if (event.getSource() == this.drawLineDrawBarItem) { 2274 this.finishMode(); 2276 this.initLineMode(); 2278 return; 2279 } 2280 2281 if (event.getSource() == this.drawCrenelHVDrawBarItem) { 2283 this.finishMode(); 2285 this.initDrawCrenelHVMode() ; 2287 return; 2288 } 2289 2290 if (event.getSource() == this.drawCrenelVHDrawBarItem) { 2292 this.finishMode(); 2294 this.initDrawCrenelVHMode() ; 2296 return; 2297 } 2298 2299 if (event.getSource() == this.maximizedViewBarItem) { 2301 this.setMaximizedViewMode(); 2303 return; 2304 } 2305 2306 if (event.getSource() == this.normalViewBarItem) { 2308 this.setNormalViewMode(); 2310 return; 2311 } 2312 2313 this.window.setScenarioSavedState(tempSavedState); 2316 2317 if (this.switchSelectedGroup(event.getSource())) { 2320 this.loadManager 2321 .notifySelectionChangedInDrawable(this.groupDescriptionSelected); 2322 return; 2323 } 2324 } 2325 2326 2331 public void handleEvent(Event e) { 2332 cat.warn("CANVAS RESIZED !!! resize event = " + (e.type == SWT.RESIZE)); 2333 Rectangle size = this.drawableCanvas.getBounds(); 2335 cat.warn("New SIZE : " + new Size(size.width, size.height)); 2337 this.scaleConvertor.setCanvasSize(new Size(size.width, size.height)); 2338 } 2339 2340 2343 public void paintControl(PaintEvent arg0) { 2344 cat.warn("PAINT LISTENER : REDRAW !!!!"); 2345 this.drawMark(); 2347 this.drawGrad(); 2349 this.drawAll(); 2351 } 2352 2353 2356 public void modifyText(ModifyEvent event) { 2357 if (this.pointSelected == null) { 2358 cat.warn("There is no point selected..."); 2359 return; 2360 } 2361 2362 int XAxisValue = 0; 2365 try { 2366 XAxisValue = (new Integer (this.xAxisText.getText())).intValue(); 2367 } catch (NumberFormatException nfe) { 2368 cat.warn("The coordinate X edited is not a valid number format..."); 2369 return; 2370 } 2371 int YAxisValue = 0; 2372 try { 2373 YAxisValue = (new Integer (this.yAxisText.getText())).intValue(); 2374 } catch (NumberFormatException nfe) { 2375 cat.warn("The coordinate Y edited is not a valid number format..."); 2376 return; 2377 } 2378 if (this.pointSelected.equals(new Point(XAxisValue, YAxisValue))) { 2380 cat.warn("The point has not been modified, so do nothing"); 2381 return; 2382 } 2383 2384 if (event.getSource() == this.xAxisText) { 2387 cat.warn("MODIFY XAXIS..."); 2388 Point curvesNumbers = this.groupDescriptionSelected 2390 .rampsWhichContains(this.pointSelected); 2391 2392 RampDescription c1 = null; 2393 RampDescription c2 = null; 2394 RampDescription clone1 = null; 2395 RampDescription clone2 = null; 2396 if (curvesNumbers.x != -1) { 2397 c1 = (RampDescription) this.groupDescriptionSelected.getRamps() 2398 .elementAt((int) curvesNumbers.x); 2399 clone1 = (RampDescription) c1.clone(); 2401 clone1.getEnd().x = XAxisValue; 2402 } 2403 if (curvesNumbers.y != -1) { 2404 c2 = (RampDescription) this.groupDescriptionSelected.getRamps() 2405 .elementAt((int) curvesNumbers.y); 2406 clone2 = (RampDescription) c2.clone(); 2408 clone2.getStart().x = XAxisValue; 2409 } 2410 if ((c1 != null) && (c2 != null)) { 2412 if (isCorrectDrawableRamp(clone1, false) 2414 && isCorrectDrawableRamp(clone2, false)) { 2415 c1.getEnd().x = XAxisValue; 2416 c2.getStart().x = XAxisValue; 2417 } else { 2418 return; 2420 } 2421 } 2422 else if (c1 != null) { 2424 if (isCorrectDrawableRamp(clone1, false)) { 2425 c1.getEnd().x = XAxisValue; 2426 } else { 2427 return; 2429 } 2430 } 2431 else if (c2 != null) { 2433 if (isCorrectDrawableRamp(clone2, false)) { 2434 c2.getStart().x = XAxisValue; 2435 } else { 2436 return; 2438 } 2439 } 2440 this.pointSelected.x = XAxisValue; 2441 } 2442 if (event.getSource() == this.yAxisText) { 2444 cat.warn("MODIFY YAXIS..."); 2445 Point curvesNumbers = this.groupDescriptionSelected 2447 .rampsWhichContains(this.pointSelected); 2448 2449 RampDescription c1 = null; 2450 RampDescription c2 = null; 2451 RampDescription clone1 = null; 2452 RampDescription clone2 = null; 2453 if (curvesNumbers.x != -1) { 2454 c1 = (RampDescription) this.groupDescriptionSelected.getRamps() 2455 .elementAt((int) curvesNumbers.x); 2456 clone1 = (RampDescription) c1.clone(); 2458 clone1.getEnd().y = YAxisValue; 2459 } 2460 if (curvesNumbers.y != -1) { 2461 c2 = (RampDescription) this.groupDescriptionSelected.getRamps() 2462 .elementAt((int) curvesNumbers.y); 2463 clone2 = (RampDescription) c2.clone(); 2465 clone2.getStart().y = YAxisValue; 2466 if (isCorrectDrawableRamp(clone2, false)) { 2467 c2.getStart().y = YAxisValue; 2468 } else { 2469 return; 2471 } 2472 } 2473 if ((c1 != null) && (c2 != null)) { 2475 if (isCorrectDrawableRamp(clone1, false) 2477 && isCorrectDrawableRamp(clone2, false)) { 2478 c1.getEnd().y = YAxisValue; 2479 c2.getStart().y = YAxisValue; 2480 } else { 2481 return; 2483 } 2484 } 2485 else if (c1 != null) { 2487 if (isCorrectDrawableRamp(clone1, false)) { 2488 c1.getEnd().y = YAxisValue; 2489 } else { 2490 return; 2492 } 2493 } 2494 else if (c2 != null) { 2496 if (isCorrectDrawableRamp(clone2, false)) { 2497 c2.getStart().y = YAxisValue; 2498 } else { 2499 return; 2501 } 2502 } 2503 this.pointSelected.y = YAxisValue; 2504 } 2505 this.drawableCanvas.redraw(); 2507 } 2508} | Popular Tags |