@Override
  protected void fillShape(Graphics graphics) {
    if (!fill) return;

    double highestAngle1 = Integer.MAX_VALUE;
    double highestAngle2 = Integer.MIN_VALUE;

    Rectangle r = calculateRectangle();

    Point center = r.getCenter();
    if (this instanceof LegendRelationDecoration) {
      highestAngle2 = HALF_ARC ? 360 : calculateAngle(center, getFeatureLocation());
      highestAngle1 = HALF_ARC ? 180 : calculateAngle(center, referencePoint);
      graphics.fillArc(r, (int) highestAngle1, (int) (highestAngle2 - highestAngle1));
    } else {

      if (children != null) {
        for (int i = 0; i < children.size(); i++) {
          Feature temp;
          temp = this.lastChild;
          this.lastChild = children.get(i);
          if (!(this.lastChild.isHidden() && !FeatureUIHelper.showHiddenFeatures(featureModel))) {
            double angle2 = HALF_ARC ? 360 : calculateAngle(center, getFeatureLocation());
            double angle1 = HALF_ARC ? 180 : calculateAngle(center, getFeatureLocation());
            if (angle2 > 450 && !vertical) {
              highestAngle1 = 180;
            } else {
              if (angle1 < highestAngle1) {
                highestAngle1 = angle1;
              }
              if (angle2 > highestAngle2) {
                highestAngle2 = angle2;
              } else {
                this.lastChild = temp;
              }
            }
          }
        }
      } else {
        highestAngle2 = HALF_ARC ? 360 : calculateAngle(center, getFeatureLocation());
      }

      r.shrink(7, 7);

      if (vertical) {
        r.shrink(1, 1);
        if (highestAngle2 < 270)
          graphics.fillArc(r.x - 20, r.y + 10, r.width, r.height, 270, (180));
        else
          graphics.fillArc(
              r.x - 20,
              r.y + 10,
              r.width,
              r.height,
              (int) highestAngle1,
              (int) (highestAngle2 - highestAngle1));
      } else {
        if (highestAngle1 > 360) graphics.fillArc(r, 180, 180);
        //				if(highestAngle2>450)
        graphics.fillArc(r, (int) highestAngle1, (int) (highestAngle2 - highestAngle1));
        //				else
        //					graphics.fillArc(r,(int) highestAngle1, (int)(highestAngle2 - highestAngle1));
      }
    }
  }
Ejemplo n.º 2
0
  @Override
  protected void paintClientArea(Graphics graphics) {
    updateThresholdPosition();
    graphics.setAntialias(SWT.ON);
    graphics.setLineWidth(rampWidth);
    graphics.pushState();
    int overlap = 0;
    Pattern pattern = null;
    boolean support3D = GraphicsUtil.testPatternSupported(graphics);
    // draw lolo part
    if (lolo.visible) {
      graphics.setBackgroundColor(lolo.color);
      graphics.fillArc(bounds, lolo.absolutePosition, min.relativePosition - lolo.relativePosition);
    }
    // draw lo part
    if (lo.visible) {
      if (support3D && gradient && lolo.visible) {
        try {
          pattern =
              new Pattern(
                  Display.getCurrent(),
                  lolo.leftPoint.x,
                  lolo.leftPoint.y,
                  lo.rightPoint.x,
                  lo.rightPoint.y,
                  lolo.color,
                  lo.color);
          graphics.setBackgroundPattern(pattern);
          overlap = OVERLAP_DEGREE / 2;
        } catch (Exception e) {
          support3D = false;
          pattern.dispose();
          graphics.setBackgroundColor(lo.color);
          overlap = 0;
        }
      } else {
        graphics.setBackgroundColor(lo.color);
        overlap = 0;
      }

      if (lolo.visible)
        graphics.fillArc(
            bounds, lo.absolutePosition, lolo.relativePosition - lo.relativePosition + overlap);
      else
        graphics.fillArc(bounds, lo.absolutePosition, min.relativePosition - lo.relativePosition);
      if (gradient && lolo.visible && support3D) pattern.dispose();
    }

    // draw left normal part
    // get the left marker
    boolean leftMarkerVisible = false;
    ThresholdMarker leftMarker = null;
    if (lo.visible) {
      leftMarkerVisible = true;
      leftMarker = lo;
    } else if (lolo.visible) {
      leftMarkerVisible = true;
      leftMarker = lolo;
    } else leftMarkerVisible = false;

    if (gradient && leftMarkerVisible && support3D) {
      pattern =
          new Pattern(
              Display.getCurrent(),
              leftMarker.leftPoint.x,
              leftMarker.leftPoint.y,
              normal.rightPoint.x,
              normal.rightPoint.y,
              leftMarker.color,
              normal.color);
      graphics.setBackgroundPattern(pattern);
      overlap = OVERLAP_DEGREE / 2;
    } else {
      graphics.setBackgroundColor(normal.color);
      overlap = 0;
    }

    if (leftMarkerVisible)
      graphics.fillArc(
          bounds,
          normal.absolutePosition,
          leftMarker.relativePosition - normal.relativePosition + overlap);
    else
      graphics.fillArc(
          bounds, normal.absolutePosition, min.relativePosition - normal.relativePosition);

    if (gradient && leftMarkerVisible && support3D) pattern.dispose();

    // draw right normal part
    // get the right marker
    boolean rightMarkerVisible = false;
    ThresholdMarker rightMarker = null;
    if (hi.visible) {
      rightMarkerVisible = true;
      rightMarker = hi;
    } else if (hihi.visible) {
      rightMarkerVisible = true;
      rightMarker = hihi;
    } else rightMarkerVisible = false;

    if (gradient && rightMarkerVisible && support3D) {
      pattern =
          new Pattern(
              Display.getCurrent(),
              rightMarker.rightPoint.x,
              rightMarker.rightPoint.y,
              normal.leftPoint.x,
              normal.leftPoint.y,
              rightMarker.color,
              normal.color);
      graphics.setBackgroundPattern(pattern);
      overlap = OVERLAP_DEGREE / 2;
    } else {
      graphics.setBackgroundColor(normal.color);
      overlap = 0;
    }

    if (rightMarkerVisible)
      graphics.fillArc(
          bounds,
          rightMarker.absolutePosition,
          normal.relativePosition - rightMarker.relativePosition + overlap + 1);
    else
      graphics.fillArc(
          bounds, max.absolutePosition, normal.relativePosition - max.relativePosition + 1);

    if (gradient && rightMarkerVisible && support3D) pattern.dispose();

    // draw hi part
    if (hi.visible) {
      if (hihi.visible) {
        rightMarkerVisible = true;
        rightMarker = hihi;
      } else rightMarkerVisible = false;

      if (gradient && rightMarkerVisible && support3D) {
        pattern =
            new Pattern(
                Display.getCurrent(),
                rightMarker.rightPoint.x,
                rightMarker.rightPoint.y,
                hi.leftPoint.x,
                hi.leftPoint.y,
                rightMarker.color,
                hi.color);
        graphics.setBackgroundPattern(pattern);
        overlap = OVERLAP_DEGREE / 2;
      } else {
        graphics.setBackgroundColor(hi.color);
        overlap = 0;
      }

      if (rightMarkerVisible)
        graphics.fillArc(
            bounds,
            rightMarker.absolutePosition,
            hi.relativePosition - rightMarker.relativePosition + overlap);
      else
        graphics.fillArc(bounds, max.absolutePosition, hi.relativePosition - max.relativePosition);

      if (gradient && rightMarkerVisible && support3D) pattern.dispose();
    }

    // draw hihi part
    if (hihi.visible) {
      if (gradient && support3D) overlap = OVERLAP_DEGREE / 2;
      else overlap = 0;
      graphics.setBackgroundColor(hihi.color);
      graphics.fillArc(
          bounds, max.absolutePosition, hihi.relativePosition - max.relativePosition + overlap);
    }

    graphics.popState();
    graphics.fillOval(
        bounds.x + rampWidth,
        bounds.y + rampWidth,
        bounds.width - 2 * rampWidth,
        bounds.height - 2 * rampWidth);

    super.paintClientArea(graphics);
  }