Ejemplo n.º 1
0
  public void init() {
    if (updateNotifier == null) {
      throw new NullPointerException("No update notifier set for " + this);
    }
    if (rootView == null) {
      throw new NullPointerException("No root view set for " + this);
    }

    insets = new Insets(0, 0, 0, 0);

    spy = new InteractionSpy(new SpyWindow());

    keyboardManager = new KeyboardManager(this);
    final InteractionHandler interactionHandler =
        new InteractionHandler(this, feedbackManager, keyboardManager, spy);
    renderingArea.addMouseMotionListener(interactionHandler);
    renderingArea.addMouseListener(interactionHandler);
    renderingArea.addKeyListener(interactionHandler);

    if (IsisContext.getConfiguration()
        .getBoolean(Properties.PROPERTY_BASE + "show-mouse-spy", false)) {
      spy.open();
    }

    setKeyboardFocus(rootView);

    APPLICATION_OPTIONS = new ApplicationOptions(listener);
  }
Ejemplo n.º 2
0
 public Bounds getOverlayBounds() {
   final Bounds bounds = new Bounds(createSize(renderingArea.getSize()));
   final Insets in = renderingArea.getInsets();
   bounds.contract(in.left + in.right, in.top + in.bottom);
   bounds.contract(0, statusBarHeight);
   return bounds;
 }
Ejemplo n.º 3
0
  private Canvas createCanvas(final Graphics graphic, final Rectangle paintArea) {
    final int w = internalDisplaySize.getWidth();
    final int h = internalDisplaySize.getHeight();
    if (doubleBuffering) {
      if ((doubleBuffer == null)
          || (bufferGraphics == null)
          || (doubleBuffer.getWidth(null) < w)
          || (doubleBuffer.getHeight(null) < h)) {
        doubleBuffer = renderingArea.createImage(w, h);
        LOG.debug(
            "buffer sized to " + doubleBuffer.getWidth(null) + "x" + doubleBuffer.getHeight(null));
      }
      bufferGraphics = doubleBuffer.getGraphics().create();
    } else {
      bufferGraphics = graphic;
    }

    bufferGraphics.clearRect(paintArea.x, paintArea.y, paintArea.width, paintArea.height);
    bufferGraphics.clearRect(0, 0, w, h);

    bufferGraphics.setClip(paintArea.x, paintArea.y, paintArea.width, paintArea.height);
    final Canvas c =
        new AwtCanvas(
            bufferGraphics,
            renderingArea,
            paintArea.x,
            paintArea.y,
            paintArea.width,
            paintArea.height);
    // Canvas c = new Canvas(bufferGraphics, 0, 0, w, h);
    return c;
  }
Ejemplo n.º 4
0
  public void initSize() {
    internalDisplaySize = createSize(renderingArea.getSize());
    insets = renderingArea.getInsets();
    LOG.debug("  insets " + insets);
    internalDisplaySize.contract(insets.left + insets.right, insets.top + insets.bottom);
    LOG.debug("  internal " + internalDisplaySize);

    final Size rootViewSize = new Size(internalDisplaySize);
    final Text text = Toolkit.getText(ColorsAndFonts.TEXT_STATUS);
    statusBarHeight = text.getLineHeight() + text.getDescent();
    rootViewSize.contractHeight(statusBarHeight);
    statusBarArea =
        new Bounds(
            insets.left,
            insets.top + rootViewSize.getHeight(),
            rootViewSize.getWidth(),
            statusBarHeight);
    rootView.setSize(rootViewSize);
  }
Ejemplo n.º 5
0
 /** Force a repaint of the damaged area of the viewer. */
 @Override
 public void scheduleRepaint() {
   updateNotifier.invalidateViewsForChangedObjects();
   synchronized (redrawArea) {
     if (!redrawArea.equals(NO_REDRAW) || refreshStatus) {
       UI_LOG.debug("repaint viewer " + redrawArea);
       final Bounds area = new Bounds(redrawArea);
       area.translate(insets.left, insets.top);
       renderingArea.repaint(area.getX(), area.getY(), area.getWidth(), area.getHeight());
       redrawArea.setBounds(NO_REDRAW);
     }
   }
 }
Ejemplo n.º 6
0
 public void close() {
   renderingArea.dispose();
 }
Ejemplo n.º 7
0
 void setCursor(final Cursor cursor) {
   renderingArea.setCursor(cursor);
 }
Ejemplo n.º 8
0
 @Override
 public String selectFilePath(final String title, final String directory) {
   return renderingArea.selectFilePath(title, directory);
 }