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

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


            calloutBoxes.put(i, box);
            chart.addSprite(box);
          }

          sprite.redraw();
          PreciseRectangle bbox = sprite.getBBox();

          List<PathCommand> commands = new ArrayList<PathCommand>();
          commands.add(new MoveTo(x + center.getX(), y + center.getY()));
          commands.add(new LineTo(calloutPoint.getX(), calloutPoint.getY()));
          commands.add(new LineTo(x > 0 ? 10 : -10, 0, true));

          PreciseRectangle rect = new PreciseRectangle(calloutPoint.getX() + (x > 0 ? 10 : -(bbox.getWidth() + 30)),
              calloutPoint.getY() + (y > 0 ? (-(bbox.getHeight() - 5)) : (-(bbox.getHeight() - 5))),
              bbox.getWidth() + 20, bbox.getHeight() + 20);

          PrecisePoint labelPoint = new PrecisePoint(calloutPoint.getX() + (x > 0 ? 20 : -(20 + bbox.getWidth())),
              calloutPoint.getY() + (y > 0 ? -bbox.getHeight() / 4.0 : -bbox.getHeight() / 4.0));

          if (chart.isAnimated() && line.size() > 0 && !Double.isNaN(box.getX()) && sprite.getTranslation() != null) {
            DrawFx.createCommandsAnimator(line, commands).run(chart.getAnimationDuration(), chart.getAnimationEasing());
            DrawFx.createRectangleAnimator(box, rect).run(chart.getAnimationDuration(), chart.getAnimationEasing());
            DrawFx.createTranslationAnimator(sprite, labelPoint.getX(), labelPoint.getY()).run(
                chart.getAnimationDuration(), chart.getAnimationEasing());
          } else {
            line.setCommands(commands);
            line.redraw();
            box.setX(rect.getX());
            box.setY(rect.getY());
            box.setWidth(rect.getWidth());
            box.setHeight(rect.getHeight());
            box.redraw();
            sprite.setTranslation(labelPoint.getX(), labelPoint.getY());
            sprite.redraw();
          }
        } else if (labelPosition == LabelPosition.END) {
View Full Code Here


    }
  }

  @Override
  public void drawAxis(boolean init) {
    PreciseRectangle bbox = chart.getBBox();
    ListStore<M> store = chart.getCurrentStore();
    double length = store.size();
    double pi2 = Math.PI * 2;
    double centerX = bbox.getX() + (bbox.getWidth() / 2);
    double centerY = bbox.getY() + (bbox.getHeight() / 2);
    double rho = Math.min(bbox.getWidth(), bbox.getHeight()) / 2;

    for (int i = 0; i < radialSteps; i++) {
      final CircleSprite circle;
      if (i < circles.size()) {
        circle = circles.get(i);
View Full Code Here

  @Override
  public void drawLabels() {
    labelNames.clear();
    fields.clear();
    PreciseRectangle bbox = chart.getBBox();
    ListStore<M> store = chart.getCurrentStore();
    double pi2 = Math.PI * 2;
    double centerX = bbox.getX() + (bbox.getWidth() / 2);
    double centerY = bbox.getY() + (bbox.getHeight() / 2);
    double rho = Math.min(bbox.getWidth(), bbox.getHeight()) / 2;
    double maxValue = 0;
    double margin = 10;

    // get all rendered fields
    for (Series<M> series : chart.getSeries()) {
View Full Code Here

   * the result us {@link #getBBox()}.
   *
   * @param gutter true if to use the series gutter in the calculation
   */
  public void calculateBBox(boolean gutter) {
    PreciseRectangle chartBBox = chart.getBBox();
    double gutterX = 0;
    double gutterY = 0;
    if (gutter) {
      gutterX = chart.getMaxGutter()[0];
      gutterY = chart.getMaxGutter()[1];
    }

    bbox = new PreciseRectangle();
    bbox.setX(chartBBox.getX() + gutterX);
    bbox.setY(chartBBox.getY() + gutterY);
    bbox.setWidth(chartBBox.getWidth());
    bbox.setHeight(chartBBox.getHeight());
  }
View Full Code Here

        MultipleColorSeries<M> multi = (MultipleColorSeries<M>) series;
        marker.setFill(multi.getColor(yFieldIndex));
      }
    }

    PreciseRectangle bbox = getBBox();
    mask = new RectangleSprite();
    mask.setX(bbox.getX());
    mask.setY(bbox.getY());
    mask.setWidth(bbox.getWidth());
    mask.setHeight(bbox.getHeight());
    mask.setOpacity(0);
    mask.setFillOpacity(0);
    mask.setStrokeOpacity(0);
    add(mask);
    chart.addSprite(mask);
View Full Code Here

   */
  public PreciseRectangle getBBox() {
    if (surface != null) {
      return surface.getBBox(this);
    } else {
      return new PreciseRectangle();
    }
  }
View Full Code Here

  private void calculateBounds() {
    ListStore<M> store = chart.getCurrentStore();
    double barWidth = getBarGirth();
    double groupGutter = this.groupGutter / 100;
    groupBarsLength = yFields.size();
    PreciseRectangle chartBBox = chart.getBBox();

    calculateBBox(false);

    // skip excluded series
    groupBarsLength -= exclude.size();
    axis = chart.getAxis(yAxisPosition);
    if (axis != null) {
      minY = axis.getFrom();
      maxY = axis.getTo();
    } else if (yFields.size() > 0) {
      NumericAxis<M> numAxis = new NumericAxis<M>();
      numAxis.setChart(chart);
      for (int i = 0; i < yFields.size(); i++) {
        numAxis.addField(yFields.get(i));
      }
      numAxis.calcEnds();
      minY = numAxis.getFrom();
      maxY = numAxis.getTo();
    }
    axis = chart.getAxis(xAxisPosition);
    if (axis != null) {
      minY = axis.getFrom();
      maxY = axis.getTo();
    }

    scale = (column ? chartBBox.getHeight() - yPadding * 2 : chartBBox.getWidth() - xPadding * 2)
        / (Math.abs(maxY - minY));
    groupBarWidth = barWidth / ((stacked ? 1 : groupBarsLength) * (groupGutter + 1) - groupGutter);
    zero = column ? chartBBox.getY() + chartBBox.getHeight() - yPadding : chartBBox.getX() + xPadding;

    List<Double> totalPositive = new ArrayList<Double>();
    List<Double> totalNegative = new ArrayList<Double>();
    if (stacked) {
      for (int i = 0; i < store.size(); i++) {
        M model = store.get(i);
        totalPositive.add(0.0);
        totalNegative.add(0.0);
        for (int j = 0; j < yFields.size(); j++) {
          if (exclude.contains(j)) {
            continue;
          }
          double value = yFields.get(j).getValue(model).doubleValue();
          if (value > 0) {
            totalPositive.set(i, totalPositive.get(i) + value);
          } else {
            totalNegative.set(i, totalNegative.get(i) + Math.abs(value));
          }
        }
      }
      if (maxY > 0) {
        totalPositive.add(maxY);
      } else {
        totalNegative.add(Math.abs(maxY));
      }
      if (minY > 0) {
        totalPositive.add(minY);
      } else {
        totalNegative.add(Math.abs(minY));
      }
      double minus = 0;
      double plus = 0;
      for (int i = 0; i < totalNegative.size(); i++) {
        minus = Math.max(minus, totalNegative.get(i));
      }
      for (int i = 0; i < totalPositive.size(); i++) {
        plus = Math.max(plus, totalPositive.get(i));
      }
      scale = (column ? bbox.getHeight() - yPadding * 2 : bbox.getWidth() - xPadding * 2) / (plus + minus);
      zero = zero + minus * scale * (column ? -1 : 1);
    } else if (minY < 0) {
      if (column) {
        zero = chartBBox.getY();
      } else {
        zero = chartBBox.getX() + chartBBox.getWidth();
      }
    }

  }
View Full Code Here

    for (; i < ln; i++) {
      labels.get(i).setHidden(true);
      labels.get(i).redraw();
    }

    bbox = new PreciseRectangle();
    bbox.setX(axisBBox.getX());
    bbox.setY(axisBBox.getY());
    bbox.setHeight(maxHeight);
    bbox.setWidth(maxWidth);
View Full Code Here

            sprite.setTranslation(bar.getX(), bar.getY());
          }
        }
        setLabelText(sprite, j);
        sprite.redraw();
        PreciseRectangle box = sprite.getBBox();
        double x = 0;
        double y = 0;
        if (column) {
          x = bar.getX() + bar.getWidth() / 2.0;
          if (labelPosition == LabelPosition.START) {
            y = bar.getY() + bar.getHeight() - box.getHeight();
          } else if (labelPosition == LabelPosition.END) {
            if (bar.getHeight() > box.getHeight()) {
              y = bar.getY();
            } else {
              y = bar.getY() - box.getHeight();
            }
          } else if (labelPosition == LabelPosition.OUTSIDE) {
            y = bar.getY() - box.getHeight();
          }
        } else {
          y = bar.getY() + bar.getHeight() / 2.0 - box.getHeight() / 2.0;
          if (labelPosition == LabelPosition.START) {
            x = bar.getX();
          } else if (labelPosition == LabelPosition.END) {
            if (bar.getWidth() > box.getWidth()) {
              x = bar.getX() + bar.getWidth() - box.getWidth();
            } else {
              x = bar.getX() + bar.getWidth();
            }
          } else if (labelPosition == LabelPosition.OUTSIDE) {
            x = bar.getX() + bar.getWidth();
View Full Code Here

   *
   * @return the height
   */
  private double drawHorizontalLabels() {
    PrecisePoint point;
    PreciseRectangle bbox = new PreciseRectangle();
    PreciseRectangle previousBBox = null;
    TextSprite textLabel = null;
    double x = 0;
    double y = 0;
    double maxHeight = height;
    boolean vertical = false;
    double furthestLabel = 0;
    int horizontalLabelPadding = textLabelPadding;
    Rotation labelRotation = labelConfig.getRotation();

    if (labelRotation != null) {
      vertical = (Math.floor((labelRotation.getDegrees() - 90) % 180) == 0);
    }

    for (int i = 0; i < ticks.size() / labelStepRatio; i++) {
      point = ticks.get(i * labelStepRatio);
      textLabel = getOrCreateLabel(i);

      bbox = textLabel.getBBox();

      maxHeight = Math.max(maxHeight, bbox.getHeight() + dashSize + horizontalLabelPadding);

      if (!vertical) {
        x = Math.floor(point.getX() - (bbox.getHeight() / 2.0));
      } else {
        x = Math.floor(point.getX() - (bbox.getWidth() / 2.0));
      }

      if (position == Position.TOP) {
        y = Math.floor(point.getY() - dashSize - horizontalLabelPadding - bbox.getHeight());
      } else {
        y = Math.floor(point.getY() + dashSize + horizontalLabelPadding);
        if (labelRotation != null) {
          y += bbox.getHeight();
        }
      }

      textLabel.setHidden(false);
      textLabel.setX(x);
      textLabel.setY(y);
      if (labelRotation != null) {
        textLabel.setRotation(new Rotation(x, y, labelRotation.getDegrees()));
      }
      textLabel.redraw();
      bbox = textLabel.getBBox();

      // Skip label if there isn't available minimum space
      if (labelOverlapHiding && previousBBox != null) {
        furthestLabel = Math.max(furthestLabel, previousBBox.getX() + previousBBox.getWidth());
        if (bbox.getX() <= furthestLabel - labelTolerance) {
          textLabel.setHidden(true);
          textLabel.redraw();
          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.