/**
  * Binds this manipulator to the specified SVG rect.
  *
  * @param element The SVG rect this manipulator is applied to.
  * @return The root element of the manipulator
  */
 @Override
 public OMSVGElement bind(Record record) {
   this.record = record;
   SVGViewBoxElementModel model = (SVGViewBoxElementModel) record.getModel();
   mode = Mode.PASSIVE;
   // Create the graphical representations for the manipulator
   // The manipulator has the following SVG structure
   // <g>
   //  <rect/>    position
   //  <g>
   //   <rect/>   top-left corner
   //   <rect/>   bottom-right corner
   //  </g>
   // </g>
   OMSVGRectElement rect = (OMSVGRectElement) model.getElementWrapper();
   svg = rect.getOwnerSVGElement();
   OMSVGDocument document = (OMSVGDocument) svg.getOwnerDocument();
   g = document.createSVGGElement();
   g.setClassNameBaseVal(AppBundle.INSTANCE.css().rectGeometryManipulator());
   posHandle = document.createSVGRectElement();
   OMSVGGElement handleGroup = document.createSVGGElement();
   topLeftHandle = document.createSVGRectElement();
   bottomRightHandle = document.createSVGRectElement();
   g.appendChild(posHandle);
   g.appendChild(handleGroup);
   handleGroup.appendChild(topLeftHandle);
   handleGroup.appendChild(bottomRightHandle);
   monitorModel = true;
   model.addChangeListener(this);
   scheduleInit();
   return g;
 }
Пример #2
0
  public void onModuleLoad() {
    instance = this;
    GWT.setUncaughtExceptionHandler(
        new GWT.UncaughtExceptionHandler() {
          public void onUncaughtException(Throwable throwable) {
            GWT.log("Uncaught exception", throwable);
            if (!GWT.isScript()) {
              String text = "Uncaught exception: ";
              while (throwable != null) {
                StackTraceElement[] stackTraceElements = throwable.getStackTrace();
                text += throwable.toString() + "\n";
                for (int i = 0; i < stackTraceElements.length; i++) {
                  text += "    at " + stackTraceElements[i] + "\n";
                }
                throwable = throwable.getCause();
                if (throwable != null) {
                  text += "Caused by: ";
                }
              }
              DialogBox dialogBox = new DialogBox(true);
              DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF");
              System.err.print(text);
              text = text.replaceAll(" ", "&nbsp;");
              dialogBox.setHTML("<pre>" + text + "</pre>");
              dialogBox.center();
            }
          }
        });
    AppBundle.INSTANCE.css().ensureInjected();

    // Create graphical context
    OMSVGDocument doc = OMSVGParser.currentDocument();
    SVGElement element = doc.createSVGPathElement().getElement().cast();
    element
        .getStyle()
        .setProperty(SVGConstants.CSS_FILL_PROPERTY, SVGConstants.CSS_LIGHTBLUE_VALUE);
    element.getStyle().setProperty(SVGConstants.CSS_STROKE_PROPERTY, SVGConstants.CSS_BLACK_VALUE);
    SVGNamedElementModel.createTitleDesc(element, AppConstants.INSTANCE.graphicalContext());
    cssContext = new CssContextModel(element);

    svgWindows = new ArrayList<SVGWindow>();
    viewport = new ViewportExt();

    viewport.setLayout(new BorderLayout());
    viewport.add(createMenuBar(), new BorderLayoutData(LayoutRegion.NORTH, getWindowBarHeight()));
    viewport.setStyleAttribute("background-color", SVGConstants.CSS_BEIGE_VALUE);

    commandToolBar =
        new CommandFactoryToolBar(
            CommandFactories.getAllFactoriesStore(), getCommandFactorySelector());
    ContentPanel commandPanel = new ContentPanel();
    commandPanel.setHeaderVisible(false);
    commandPanel.setBottomComponent(commandToolBar);
    viewport.add(commandPanel, new BorderLayoutData(LayoutRegion.SOUTH, getWindowBarHeight()));

    new InternalLoadRequest(AppBundle.INSTANCE.fish(), "fish.svg").load();
    new InternalLoadRequest(AppBundle.INSTANCE.fries(), "fries.svg").load();
    new InternalLoadRequest(AppBundle.INSTANCE.sample(), "sample.svg").load();

    update();

    fileUpload = new FileUploadExt();
    Style style = fileUpload.getElement().getStyle();
    style.setVisibility(Visibility.HIDDEN);
    style.setWidth(0, Unit.PX);
    style.setHeight(0, Unit.PX);
    fileUpload.addChangeHandler(
        new ChangeHandler() {

          @Override
          public void onChange(ChangeEvent event) {
            processFiles(fileUpload.getFiles());
          }
        });

    RootPanel.get().add(viewport);
    RootPanel.get().add(fileUpload);
  }