Esempio n. 1
0
  public EditorController(String divID, int width, int height) {

    VerticalPanel vp = new VerticalPanel();
    HorizontalPanel hp = new HorizontalPanel();

    SimplePanel topToolBoxWrapper = new SimplePanel();

    ToggleButtonListener toggleButtonListener = new ToggleButtonListener();

    topToolBox = new TopToolBox(this, toggleButtonListener);
    topToolBox.setStyleName("jsmoleditor-topToolBox");

    topToolBoxWrapper.setWidget(topToolBox);
    topToolBoxWrapper.setStyleName("jsmoleditor-topTooBoxWrapper");
    topToolBoxWrapper.setWidth(width + "px");

    SimplePanel sideToolBoxWrapper = new SimplePanel();
    elementToolBox = new ElementToolBox(this, toggleButtonListener);

    sideToolBoxWrapper.setWidget(elementToolBox);
    sideToolBoxWrapper.setStyleName("jsmoleditor-elementToolBoxWrapper");
    sideToolBoxWrapper.setHeight((height - 24) + "px");

    VerticalPanel vp2 = new VerticalPanel();

    ExtendedCanvas canvas = new ExtendedCanvas(width - 24, height - 48);
    StatusBar statusBar = new StatusBar(width - 24, 24);
    statusBar.setHTML("Copyright chemhack.com");
    renderer = new CanvasRenderer(this, canvas);

    vp2.add(canvas);
    vp2.add(statusBar);

    hp.add(sideToolBoxWrapper);
    hp.add(vp2);

    vp.add(topToolBoxWrapper);
    vp.add(hp);

    RootPanel rootPanel = RootPanel.get(divID);
    rootPanel.setPixelSize(width, height);
    rootPanel.add(vp);

    KeyboardShortCutEventPreview preview =
        new KeyboardShortCutEventPreview(this); // TODO deal with multiple editor instance?

    DOM.addEventPreview(preview);

    EditorMouseListener listener = new EditorMouseListener(this);
    canvas.addMouseListener(listener);
    canvas.addMouseWheelListener(listener);
  }
Esempio n. 2
0
 public void selectRingAction(int ringSize, boolean isBenzene) {
   this.currentAction = isBenzene ? EditActions.drawBenzene : EditActions.drawRing;
   this.currentRingSize = ringSize;
   topToolBox.setSelectedAction(
       isBenzene ? EditActions.drawBenzene : EditActions.drawRing, ringSize);
 }
Esempio n. 3
0
 public void selectEditAction(EditActions action) {
   this.currentAction = action;
   topToolBox.setSelectedAction(action);
 }