Package com.sencha.gxt.core.client.util

Examples of com.sencha.gxt.core.client.util.PreciseRectangle


   *
   * @param sprite the text sprite to be converted to a path
   */
  public PathSprite(TextSprite sprite) {
    super(sprite);
    PreciseRectangle bbox = sprite.getBBox();
    commands.addAll(rectangleCommands(bbox, Double.NaN));
    pathDirty = true;
  }
View Full Code Here


   *
   * @return the calculated dimensions of the path
   */
  public PreciseRectangle dimensions() {
    if (commands.size() == 0) {
      return new PreciseRectangle();
    }
    PathSprite curve = this.copy().toCurve();
    double x = 0;
    double y = 0;
    PrecisePoint min = new PrecisePoint(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
    PrecisePoint max = new PrecisePoint(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);

    for (PathCommand command : curve.getCommands()) {
      if (command instanceof MoveTo) {
        MoveTo moveto = (MoveTo) command;
        x = moveto.getX();
        y = moveto.getY();
        min.setX(Math.min(min.getX(), x));
        min.setY(Math.min(min.getY(), y));
        max.setX(Math.max(max.getX(), x));
        max.setY(Math.max(max.getY(), y));
      } else {
        CurveTo curveto = (CurveTo) command;
        PreciseRectangle bbox = this.curveDimensions(new PrecisePoint(x, y), curveto);
        min.setX(Math.min(min.getX(), bbox.getX()));
        min.setY(Math.min(min.getY(), bbox.getY()));
        max.setX(Math.max(max.getX(), bbox.getX() + bbox.getWidth()));
        max.setY(Math.max(max.getY(), bbox.getY() + bbox.getHeight()));
        x = curveto.getX();
        y = curveto.getY();
      }
    }

    return new PreciseRectangle(min.getX(), min.getY(), max.getX() - min.getX(), max.getY() - min.getY());
  }
View Full Code Here

      min.setY(Math.min(min.getY(), p.getY()));
      max.setX(Math.max(max.getX(), p.getX()));
      max.setY(Math.max(max.getY(), p.getY()));
    }

    return new PreciseRectangle(min.getX(), min.getY(), max.getX() - min.getX(), max.getY() - min.getY());
  }
View Full Code Here

    if (store == null || store.size() == 0) {
      return;
    }

    PreciseRectangle chartBBox = chart.getBBox();
    @SuppressWarnings("unchecked")
    GaugeAxis<M> axis = (GaugeAxis<M>) chart.getAxis(null);
    ArrayList<Slice> oldSlices = slices;
    slices = new ArrayList<Slice>();
    double minimum = axis.getMinimum();
    double maximum = axis.getMaximum();

    center.setX(chartBBox.getX() + (chartBBox.getWidth() / 2.0));
    center.setY(chartBBox.getY() + chartBBox.getHeight());
    radius = Math.min(center.getX() - chartBBox.getX(), center.getY() - chartBBox.getY());

    M record = store.get(0);
    value = angleField.getValue(record).doubleValue();

    double splitAngle = -180.0 * (1.0 - (value - minimum) / (maximum - minimum));
View Full Code Here

   *
   * @param sprite the sprite to be used in the calculation
   * @return bounding box of the sprite
   */
  public PreciseRectangle getBBox(Sprite sprite) {
    PreciseRectangle bbox = null;

    if (sprite instanceof TextSprite) {
      bbox = getBBoxText((TextSprite) sprite);
    } else {
      PathSprite realPath = sprite.getPathSprite();
View Full Code Here

      renderSprite(item);
    }
    if (component.isViewBox() && surfaceElement != null) {
      int temp = sprites.indexOf(backgroundSprite);
      sprites.remove(temp);
      PreciseRectangle bbox = getSprites().getBBox();
      sprites.add(temp, backgroundSprite);

      setViewBox(bbox.getX(), bbox.getY(), bbox.getWidth(), bbox.getHeight());
      backgroundSprite.setWidth(bbox.getWidth());
      backgroundSprite.setHeight(bbox.getHeight());

    }
  }
View Full Code Here

    if (border != null && !Double.isNaN(border.getStrokeWidth())) {
      strokeWidth = border.getStrokeWidth();
    } else {
      strokeWidth = 1;
    }
    return new PreciseRectangle(Math.round(x) - strokeWidth / 2.0, Math.round(y) - strokeWidth / 2.0, width, height);
  }
View Full Code Here

  /**
   * Adjusts the position of the legend to fit in its chart.
   */
  public void updatePosition() {
    double inset = chart.getDefaultInsets();
    PreciseRectangle bbox = chart.getBBox();
    double chartX = bbox.getX() + inset;
    double chartY = bbox.getY() + inset;
    double chartWidth = bbox.getWidth() - (inset * 2.0);
    double chartHeight = bbox.getHeight() - (inset * 2.0);
    if (isDisplayed()) {
      // Find the position based on the dimensions
      if (position == Position.LEFT) {
        x = inset;
        y = Math.floor(chartY + chartHeight / 2.0 - height / 2.0);
      } else if (position == Position.RIGHT) {
        x = Math.floor(chart.getSurface().getWidth() - width) - inset;
        y = Math.floor(chartY + chartHeight / 2.0 - height / 2.0);
      } else if (position == Position.TOP) {
        x = Math.floor(chartX + chartWidth / 2.0 - width / 2.0);
        y = inset;
      } else if (position == Position.BOTTOM) {
        x = Math.floor(chartX + chartWidth / 2.0 - width / 2.0);
        y = Math.floor(chart.getSurface().getHeight() - height) - inset;
      } else {
        x = Math.floor(origX) + inset;
        y = Math.floor(origY) + inset;
      }

      // Update the position of each item
      for (int i = 0; i < items.size(); i++) {
        items.get(i).updatePosition(x, y);
      }
      // Update the position of the containing box
      if (border != null) {
        PreciseRectangle rect = getBBox();
        border.setX(rect.getX());
        border.setY(rect.getY());
        border.setWidth(rect.getWidth());
        border.setHeight(rect.getHeight());
        border.redraw();
      }
    }
  }
View Full Code Here

      if (series.isShownInLegend()) {
        currentLegendTitles = series.getLegendTitles();
        for (int j = 0; j < currentLegendTitles.size(); j++) {
          LegendItem<M> item = new LegendItem<M>(this, series, j);
          items.add(item);
          PreciseRectangle bbox = item.getBBox();

          // always measure from x=0, since not all markers go all the way to
          // the left
          if (i + j == 0) {
            if (vertical) {
              spacing = padding + bbox.getHeight() / 2.0;
            } else {
              spacing = padding;
            }
          } else {
            if (vertical) {
              spacing = itemSpacing / 2.0;
            } else {
              spacing = itemSpacing;
            }
          }
          // Set the item's position relative to the legend box
          if (vertical) {
            item.setX(Math.floor(padding));
            item.setY(Math.floor(totalHeight + spacing));
          } else {
            item.setX(Math.floor(totalWidth + padding));
            item.setY(Math.floor(padding + bbox.getHeight() / 2.0));
          }

          // Collect cumulative dimensions
          totalWidth += bbox.getWidth() + spacing;
          totalHeight += bbox.getHeight() + spacing;
          maxWidth = Math.max(maxWidth, bbox.getWidth());
          maxHeight = Math.max(maxHeight, bbox.getHeight());
        }
      }
    }

    // Store the collected dimensions for later
View Full Code Here

  @Override
  public void drawSeries() {
    ListStore<M> store = chart.getCurrentStore();
    boolean first = true;
    int layers = lengthField.size() > 0 ? lengthField.size() : 1;
    PreciseRectangle chartBBox = chart.getBBox();
    Map<Integer, Slice> oldSlices = slices;
    slices = new HashMap<Integer, Slice>();
    Map<Integer, Double> layerTotals = new HashMap<Integer, Double>();
    Slice slice;
    double totalField = 0;
    double totalLength = 0;
    double maxLength = 0;
    List<PathCommand> commands = new ArrayList<PathCommand>();
    M model;

    double value = 0;
    double angle = 0;
    double middleAngle = 0;
    double endAngle = 0;
    double rhoAcum = 0;

    if (store == null || store.size() == 0) {
      return;
    }

    center.setX(chartBBox.getX() + (chartBBox.getWidth() / 2));
    center.setY(chartBBox.getY() + (chartBBox.getHeight() / 2));
    radius = Math.min(center.getX() - chartBBox.getX(), center.getY() - chartBBox.getY());

    for (int i = 0; i < store.size(); i++) {
      if (exclude.contains(i)) {
        continue;
      }
View Full Code Here

TOP

Related Classes of com.sencha.gxt.core.client.util.PreciseRectangle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.