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

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


   * Renders the title of the axis.
   */
  private void drawTitle(double maxWidth, double maxHeight) {
    double x = this.x;
    double y = this.y;
    PreciseRectangle bbox = new PreciseRectangle();
    boolean rotate = (position == Position.LEFT || position == Position.RIGHT);
    if (titleSprite == null) {
      titleSprite = titleConfig.copy();
      if (rotate) {
        titleSprite.setRotation(270);
      }
      chart.addSprite(titleSprite);
    }
    bbox = titleSprite.getBBox();

    int pad = dashSize + Math.abs(textLabelPadding);
    if (rotate) {
      y -= this.length / 2.0 - bbox.getHeight() / 2.0;
      if (position == Position.LEFT) {
        x -= (maxWidth + textLabelPadding + bbox.getWidth());
      } else {
        x += (maxWidth + textLabelPadding - (bbox.getWidth() / 2.0));
      }
      this.bbox.setWidth(this.bbox.getWidth() + bbox.getWidth());
      this.bbox.setHeight(chart.getBBox().getHeight());
    } else {
      x += (this.length / 2.0) - (bbox.getWidth() / 2.0);
      if (position == Position.TOP) {
        y -= (maxHeight + pad + bbox.getHeight());
      } else {
        y += (maxHeight + pad - (bbox.getHeight() / 2.0));
      }
      this.bbox.setHeight(this.bbox.getHeight() + bbox.getHeight());
      this.bbox.setWidth(chart.getBBox().getWidth());
    }
    titleSprite.setTranslation(x, y);
    titleSprite.redraw();
  }
View Full Code Here


   *
   * @return the width
   */
  private double drawVerticalLabels() {
    PrecisePoint point;
    PreciseRectangle bbox = new PreciseRectangle();
    PreciseRectangle previousBBox = null;
    TextSprite textLabel = null;
    double x = 0;
    double y = 0;
    double maxWidth = width;
    double furthestLabel = chart.getBBox().getHeight();
    for (int i = 0; i < ticks.size() / labelStepRatio; i++) {

      point = ticks.get(i * labelStepRatio);
      textLabel = getOrCreateLabel(i);

      bbox = textLabel.getBBox();
      maxWidth = Math.max(maxWidth, bbox.getWidth() + dashSize + textLabelPadding);

      y = point.getY() - (bbox.getHeight() / 2.0);
      if (position == Position.LEFT) {
        x = point.getX() - bbox.getWidth() - dashSize - textLabelPadding;
      } else {
        x = point.getX() + dashSize + textLabelPadding;
      }

      textLabel.setHidden(false);
      textLabel.setX(x);
      textLabel.setY(y);
      textLabel.redraw();
      bbox = textLabel.getBBox();

      // Skip label if there isn't available minimum space
      if (labelOverlapHiding) {
        if (previousBBox != null) {
          furthestLabel = Math.min(furthestLabel, previousBBox.getY());
          if (bbox.getY() + bbox.getHeight() >= furthestLabel + labelTolerance) {
            textLabel.setHidden(true);
            textLabel.redraw();
            continue;
          }
View Full Code Here

        }
        PrecisePoint point = getPointFromCommand(lineCommands.get(i));
        double x = point.getX();
        double y = point.getY();
        if (showMarkers) {
          PreciseRectangle textBox = sprite.getBBox();

          y -= textBox.getHeight() / 2.0;
        }
        if (chart.isAnimated() && sprite.getTranslation() != null) {
          DrawFx.createTranslationAnimator(sprite, x, y).run(chart.getAnimationDuration(), chart.getAnimationEasing());
        } else {
          sprite.setTranslation(x, y);
View Full Code Here

  @Override
  protected PreciseRectangle getBBoxText(TextSprite sprite) {
    XElement element = getElement(sprite);
    if (element == null) {
      return new PreciseRectangle();
    }
    PreciseRectangle bbox = textBBoxCache.get(sprite);
    if (bbox == null) {
      Element textPath = element.childElement("textPath").cast();
      if (textPath != null) {
        TextMetrics.get().bind(textPath);
      }

      SplitResult split = newLineRegExp.split(sprite.getText());
      bbox = new PreciseRectangle();

      for (int i = 0; i < split.length(); i++) {
        double width = TextMetrics.get().getWidth(split.get(i));
        bbox.setWidth(Math.max(bbox.getWidth(), width));
      }
      bbox.setHeight(sprite.getFontSize() * split.length());

      PrecisePoint point = textRenderedPoints.get(sprite);
      TextBaseline baseline = textRenderedBaseline.get(sprite);
      bbox.setX(point.getX());
      bbox.setY(point.getY());
      if (baseline == TextBaseline.MIDDLE) {
        bbox.setY(point.getY() - (bbox.getHeight() / 2.0));
      } else if (baseline == TextBaseline.BOTTOM) {
        bbox.setY(point.getY() - bbox.getHeight());
      }
      textBBoxCache.put(sprite, bbox);
    }
    return bbox;
  }
View Full Code Here

    if (clipElement == null) {
      clipElement = this.surfaceElement.insertFirst(Document.get().createDivElement()).cast();
      clipElement.addClassName(spriteVMLClass);
      setClipElement(sprite, clipElement);
    }
    PreciseRectangle rect = sprite.getClipRectangle();
    double width = rect.getX() + rect.getWidth();
    double height = rect.getY() + rect.getHeight();
    clipElement.getStyle().setProperty(
        "clip",
        new StringBuilder().append("rect(").append(rect.getY()).append("px ").append(width + "px ").append(height).append(
            "px ").append(rect.getX() + "px").toString());
  }
View Full Code Here

    circle.setZIndex(11);
    markerConfig = circle;
  }

  public void calculateBounds() {
    PreciseRectangle chartBBox = chart.getBBox();
    ListStore<M> store = chart.getCurrentStore();
    min = new PrecisePoint(Double.NaN, Double.NaN);
    max = new PrecisePoint(Double.NaN, Double.NaN);
    scale = new PrecisePoint();

    bbox.setX(chartBBox.getX() + chart.getMaxGutter()[0]);
    bbox.setY(chartBBox.getY() + chart.getMaxGutter()[1]);
    bbox.setWidth(chartBBox.getWidth() - (chart.getMaxGutter()[0] * 2));
    bbox.setHeight(chartBBox.getHeight() - (chart.getMaxGutter()[1] * 2));

    Axis<M, ?> axis = chart.getAxis(yAxisPosition);
    if (axis != null) {
      if (axis.getPosition() == Position.TOP || axis.getPosition() == Position.BOTTOM) {
        min.setX(axis.getFrom());
View Full Code Here

            });
          } else {
            setLabelContrast(sprite, labelConfig, back);
          }
        }
        PreciseRectangle textBox = sprite.getBBox();
        PrecisePoint point = coordinates.get(i);
        if (point != null) {
          double x = coordinates.get(i).getX();
          double y = coordinates.get(i).getY();

          y -= textBox.getHeight() / 2.0;

          if (chart.isAnimated() && sprite.getTranslation() != null) {
            DrawFx.createTranslationAnimator(sprite, x, y).run(chart.getAnimationDuration(), chart.getAnimationEasing());
          } else {
            sprite.setTranslation(x, y);
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.