示例#1
0
 private void drawSections(final GraphicsContext CTX) {
   if (sections.isEmpty()) return;
   int listSize = sections.size();
   double minValue = getSkinnable().getMinValue();
   double minPosition;
   CTX.save();
   if (Orientation.VERTICAL == orientation) {
     minPosition =
         barBackground.getLayoutY() + barBackground.getLayoutBounds().getHeight() - size * 0.0035;
     double anchorX = barBackground.getLayoutX() - 0.079 * width;
     double sectionHeight;
     for (int i = 0; i < listSize; i++) {
       Section section = sections.get(i);
       sectionHeight = (section.getStop() - section.getStart()) * stepSize;
       CTX.setFill(section.getColor());
       CTX.fillRect(
           anchorX,
           minPosition - sectionHeight - (section.getStart() - minValue) * stepSize,
           0.057 * width,
           sectionHeight);
     }
   } else {
     minPosition = barBackground.getLayoutX();
     double anchorY = barBackground.getLayoutY() + barBackground.getHeight() + 0.021 * height;
     double sectionWidth;
     for (int i = 0; i < listSize; i++) {
       Section section = sections.get(i);
       sectionWidth = (section.getStop() - section.getStart()) * stepSize;
       CTX.setFill(section.getColor());
       CTX.fillRect(
           minPosition + (section.getStart() - minValue) * stepSize,
           anchorY,
           sectionWidth,
           0.059 * height);
     }
   }
   CTX.restore();
 }
示例#2
0
  private void drawSections() {
    if (sections.isEmpty()) return;
    sectionLayer.getChildren().clear();

    double centerX = width * 0.5;
    double centerY = height * 0.85;
    double barRadius = height * 0.54210526;
    double barWidth = width * 0.28472222;

    for (Section section : sections) {
      Arc sectionBar =
          new Arc(
              centerX,
              centerY,
              barRadius,
              barRadius,
              angleRange * 0.5 + 90 - (section.getStart() * angleStep),
              -((section.getStop() - section.getStart()) - minValue) * angleStep);
      sectionBar.setType(ArcType.OPEN);
      sectionBar.setStroke(section.getColor());
      sectionBar.setStrokeWidth(barWidth);
      sectionBar.setStrokeLineCap(StrokeLineCap.BUTT);
      sectionBar.setFill(null);
      Tooltip sectionTooltip =
          new Tooltip(
              new StringBuilder(section.getText())
                  .append("\n")
                  .append(String.format(Locale.US, "%.2f", section.getStart()))
                  .append(" - ")
                  .append(String.format(Locale.US, "%.2f", section.getStop()))
                  .toString());
      sectionTooltip.setTextAlignment(TextAlignment.CENTER);
      Tooltip.install(sectionBar, sectionTooltip);
      sectionLayer.getChildren().add(sectionBar);
    }
  }