Пример #1
0
  private void setOutput() {
    if (points == null) return;

    // if init points have no labels, all the points and segments
    // of the polygon don't get labels either: in this case we only
    // have the polygon itself as output object
    if (!labelPointsAndSegments) {
      output = new GeoElement[1];
      output[0] = poly;
    }
    // otherwise: points and segments are also output objects
    else {
      // size = poly + points + segments
      GeoSegmentND[] segments = poly.getSegments();
      GeoPoint[] points = poly.getPoints();
      int size = 1 + segments.length + points.length;

      output = new GeoElement[size];
      int k = 0;
      output[k] = poly;

      for (int i = 0; i < segments.length; i++) {
        output[++k] = (GeoElement) segments[i];
      }

      for (int i = 0; i < points.length; i++) {
        output[++k] = points[i];
      }
    }
  }
Пример #2
0
  private void updateSegmentsAndPointsLabels(int oldPointNumber) {
    if (labelsNeedIniting) return;

    // set labels only when points have labels
    /*
    labelPointsAndSegments = labelPointsAndSegments || A.isLabelSet() || B.isLabelSet();


    boolean pointsSegmentsShowLabel = labelPointsAndSegments &&
    		(A.isEuclidianVisible() && A.isLabelVisible() ||
    		 B.isEuclidianVisible() && B.isLabelVisible());

     */

    boolean pointsSegmentsShowLabel = true;

    // set labels for points only if the original points had labels
    if (labelPointsAndSegments) {
      for (int i = 0; i < points.length; i++) {
        if (!points[i].isLabelSet()) {
          points[i].setLabel(null);
          points[i].setLabelVisible(pointsSegmentsShowLabel);
        }
      }
    }

    // update all segments and set labels for new segments
    GeoSegmentND[] segments = poly.getSegments();
    for (int i = 0; i < segments.length; i++) {
      GeoElement seg = (GeoElement) segments[i];
      if (labelPointsAndSegments) {
        if (!seg.isLabelSet()) {
          seg.setLabel(null);
          seg.setAuxiliaryObject(true);
          seg.setLabelVisible(pointsSegmentsShowLabel);
        } else {
          pointsSegmentsShowLabel = pointsSegmentsShowLabel || seg.isLabelVisible();
        }
      }

      seg.getParentAlgorithm().update();
    }
  }