示例#1
0
  /**
   * @param _parent
   * @param _flex
   */
  @Override
  public void layoutInterior(IView _parent, Flex _flex) {
    if (controller == NullListController.cNull) {
      w = _parent.getBorder().getW();
      h = _parent.getBorder().getH();
      return;
    }

    int x = (int) getBorder().getX();
    int y = (int) getBorder().getY();

    WH_F size = new WH_F(0, 0);

    if (threeD) {

      IVItem[] items = getItems();
      if (items == null) {
        w = _parent.getBorder().getW();
        h = _parent.getBorder().getH();
        return;
      }
      if (sphere.getCount() != items.length) {
        XYZ_D[] xyzs = new XYZ_D[items.length];
        for (int i = 0; i < items.length; i++) {
          XYZ_D xyz = null;
          if (items[i] instanceof IXYZ) {
            IXYZ ixyz = (IXYZ) items[i];
            xyz = new XYZ_D(ixyz.x(), ixyz.y(), ixyz.z());
          } else {
            xyz = new XYZ_D(0, 0, 0);
          }
          xyzs[i] = xyz;
        }
        if (spherical) {
          U3D.sphere(sphere, xyzs, sphereSize); // UTessellate
        } else {
          sphere.setPoints(xyzs);
        }
      }
      sphere.mapPoints(items);
      XYZ_D centerEye = eye.getCenter();
      XYZ_D centerObj = sphere.getCenter();

      // UXYZ.sort(items);

      int len = (items == null) ? 0 : items.length;
      for (int i = 0; i < len; i++) {
        IView view = items[i];
        if (view == null) {
          continue;
        }
        if (view instanceof IHideable) {
          if (((IHideable) view).isHidden()) {
            continue;
          }
        }
        IXYZ xyz = (IXYZ) items[i];

        view.setParentView(this); // ??
        view.layoutInterior(_flex);
        float _x = (float) xyz.x();
        float _y = (float) xyz.y();
        float _z = (float) xyz.z();

        double tx = _x, ty = _y;
        if (perspective) {
          tx = tunnel.getX(((_x + 1d) / 2d), ((_z + 1d) / 2d));
          ty = tunnel.getY(((_y + 1d) / 2d), ((_z + 1d) / 2d));
        } else {
          tx = tunnel.getX(((_x + 1d) / 2d), -1);
          ty = tunnel.getY(((_y + 1d) / 2d), -1);
        }

        _x = (float) tx;
        _y = (float) ty;

        float vx = view.getX();
        float vy = view.getY();
        float vw = view.getW();
        float vh = view.getH();

        view.setLocation(_x, _y);
        size.max(vx + vw, +vy + vh);
      }

      w = size.getW() - getBorder().getX(); // !!??
      h = size.getH() - getBorder().getY(); // !!?? this offset is required do to placer

      if (spherical) {
        if (w < 400) {
          w = 400 - getBorder().getX();
        }
        if (h < 400) {
          h = 400 - getBorder().getY();
        }
      }
      return;
    }

    if (rows_colums != 0) {
      IVItem[] items = controller.getItems();
      int len = (items == null) ? 0 : items.length;

      if (rows_colums > 0) {
        int columCount = len / rows_colums;
        int rowCount = rows_colums;

        maxW = new float[columCount + 1];
        maxH = new float[rowCount + 1];
        rings = new float[rowCount + 1];

        int r = 0;
        int c = 0;
        for (int i = 0; i < len; i++, r++) {
          if (r == rowCount) {
            r = 0;
            c++;
          }

          IView view = items[i];
          if (view == null) {
            continue;
          }

          view.setParentView(this);
          view.layoutInterior(_flex);

          maxW[c] = Math.max(maxW[c], view.getW());
          maxH[r] = Math.max(maxH[r], view.getH());
          rings[r] = (float) Math.max(rings[r], Math.max(view.getW(), view.getH()));
          // rings[r] =
          // (float)Math.max(rings[r],Math.sqrt(Math.pow(view.getW(),2)+Math.pow(view.getH(),2)));
        }

        if (radial) {
          float origin = (dia > 0) ? dia : rings[0];

          for (int i = 0; i < rings.length; i++) {
            origin += (dia > 0) ? dia : rings[i];
          }

          origin += pad;

          r = 0;
          c = 0;
          double _length = origin - pad;
          float _direction = 0;
          for (int i = 0; i < len; i++, r++) {
            if (r == rowCount) {
              _length = origin - pad;
              r = 0;
              c++;
              _direction = ((float) c / (float) columCount) * 360;
            }
            float rr = (dia > 0) ? dia : rings[r];
            _length -= rr;

            IView view = items[i];
            if (view == null) {
              continue;
            }

            x =
                (int) origin
                    + (int) (Math.sin(Math.toRadians(_direction + 90)) * (_length + (rr / 2)));
            y = (int) origin + (int) (Math.sin(Math.toRadians(_direction)) * (_length + (rr / 2)));

            x -= (rr / 2);
            y -= (rr / 2);

            if (view instanceof IAlignableItem) {
              ((IAlignableItem) view).justify(x, y, rr, rr);
            } else {
              view.setLocation(x, y);
            }

            size.max(view.getX() + view.getW(), view.getY() + view.getH());
          }
          size.max((float) (origin * 2), (float) (origin * 2));

        } else {
          r = 0;
          c = 0;
          for (int i = 0; i < len; i++, r++) {
            if (r == rowCount) {
              r = 0;
              y = (int) getBorder().getY();
              x += maxW[c] + xspacing;
              c++;
            }

            IView view = items[i];
            if (view == null) {
              continue;
            }

            if (view instanceof IAlignableItem) {
              ((IAlignableItem) view).justify(x, y, maxW[c], maxH[r]);
            } else {
              view.setLocation(x, y);
            }

            size.max(x + maxW[c], y + maxH[r]);
            y += maxH[r] + yspacing;
          }
        }

      } else {
        int columCount = -(rows_colums);
        int rowCount = len / columCount;

        maxW = new float[columCount + 1];
        maxH = new float[rowCount + 1];
        rings = new float[rowCount + 1];

        int r = 0;
        int c = 0;
        for (int i = 0; i < len; i++, c++) {
          if (c == columCount) {
            c = 0;
            r++;
          }

          IView view = items[i];
          if (view == null) {
            continue;
          }

          view.setParentView(this);
          view.layoutInterior(_flex);

          maxW[c] = Math.max(maxW[c], view.getW());
          maxH[r] = Math.max(maxH[r], view.getH());
          rings[r] = (float) Math.max(rings[r], Math.max(view.getW(), view.getH()));
          // rings[r] =
          // (float)Math.max(rings[r],Math.sqrt(Math.pow(view.getW(),2)+Math.pow(view.getH(),2)));
        }

        if (radial) {

          float origin = 0;
          for (int i = 0; i < rings.length; i++) {
            origin += (dia > 0) ? dia : rings[i];
          }
          origin += pad;

          r = 0;
          c = 0;
          double _length = (dia > 0) ? dia : rings[0];
          for (int i = 0; i < len; i++, r++) {
            if (r == rowCount) {
              r = 0;
              c++;
              _length += (dia > 0) ? dia : rings[c];
            }

            IView view = items[i];
            if (view == null) {
              continue;
            }

            float _direction = ((float) r / (float) rowCount) * 360;
            x = (int) origin + (int) (Math.sin(Math.toRadians(_direction + 90)) * _length);
            y = (int) origin + (int) (Math.sin(Math.toRadians(_direction)) * _length);

            x -= (maxW[c] / 2);
            y -= (maxH[r] / 2);

            if (view instanceof IAlignableItem) {
              ((IAlignableItem) view).justify(x, y, maxW[c], maxH[r]);
            } else {
              view.setLocation(x, y);
            }
            size.max(view.getX() + view.getW(), view.getY() + view.getH());
          }
          size.max((float) (origin * 2), (float) (origin * 2));

        } else {

          r = 0;
          c = 0;
          for (int i = 0; i < len; i++, c++) {
            if (c == columCount) {
              c = 0;
              x = (int) getBorder().getX();
              y += maxH[r] + yspacing;
              r++;
            }

            IView view = items[i];
            if (view == null) {
              continue;
            }

            if (view instanceof IAlignableItem) {
              ((IAlignableItem) view).justify(x, y, maxW[c], maxH[r]);
            } else {
              view.setLocation(x, y);
            }

            size.max(x + maxW[c], y + maxH[r]);
            x += maxW[c] + xspacing;
          }
        }
      }
    }

    w = size.getW() - getBorder().getX(); // !!??
    h = size.getH() - getBorder().getY(); // !!?? this offset is required do to placer
  }
示例#2
0
 /** @return */
 public float getHeight() {
   IView content = getContent();
   float _h = content.getH();
   return _h;
 }