コード例 #1
0
ファイル: UIImageIcon.java プロジェクト: appnativa/rare
  @Override
  public void paint(
      View c, Canvas g, float x, float y, float width, float height, int orientation) {
    if ((image != null) && loaded) {
      iPlatformComponent pc = com.appnativa.rare.ui.Component.fromView(c);

      if (pc != null) {
        iPlatformGraphics pg = pc.graphicsWrap(g);

        super.paint(pg, x, y, width, height);
        pc.graphicsUnwrap(pg);
      } else {
        if (backgroundColor != null) {
          if (paint == null) {
            paint = new Paint();
            paint.setStyle(Paint.Style.FILL);
          }

          paint.setColor(backgroundColor.getColor());
          g.drawRect(x, y, x + image.getWidth(), y + image.getHeight(), paint);
        }

        Bitmap bmp = image.getBitmap();

        if (bmp != null) {
          g.drawBitmap(bmp, x, y, null);
        }
      }
    }
  }
コード例 #2
0
ファイル: JViewportEx.java プロジェクト: appnativa/rare
  @Override
  public Dimension getViewSize() {
    Component view = getView();

    if (view == null) {
      return new Dimension(0, 0);
    }

    Dimension d;

    if (isViewSizeSet) {
      d = view.getSize();
    } else {
      iPlatformComponent pc = com.appnativa.rare.ui.Component.fromView((JComponent) view);
      UIDimension size = pc.getPreferredSize(null, getWidth());

      d = new Dimension(size.intWidth(), size.intHeight());
    }

    return d;
  }
コード例 #3
0
ファイル: JViewportEx.java プロジェクト: appnativa/rare
  @Override
  public void setViewSize(Dimension d) {
    if (forceSizeMatch) {
      int w = getWidth();
      int h = getHeight();

      if (w > d.width) {
        d.width = w;
      }

      if (h > d.height) {
        d.height = h;
      }
    }

    Component view = getView();

    if (view != null) {
      iPlatformComponent pc = com.appnativa.rare.ui.Component.fromView((JComponent) view);
      Dimension oldSize = view.getSize();

      if (!d.equals(oldSize)) {
        // scrollUnderway will be true if this is invoked as the
        // result of a validate and setViewPosition was previously
        // invoked.
        scrollUnderway = false;

        if (pc == null) {
          view.setSize(d);
        } else {
          pc.setBounds(view.getX(), view.getY(), d.width, d.height);
        }

        isViewSizeSet = true;
        fireStateChanged();
      }
    }

    super.setViewSize(d);
  }