当前位置: 首页>>代码示例>>Java>>正文


Java ScaleDirection.CLOCKWISE属性代码示例

本文整理汇总了Java中eu.hansolo.medusa.Gauge.ScaleDirection.CLOCKWISE属性的典型用法代码示例。如果您正苦于以下问题:Java ScaleDirection.CLOCKWISE属性的具体用法?Java ScaleDirection.CLOCKWISE怎么用?Java ScaleDirection.CLOCKWISE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在eu.hansolo.medusa.Gauge.ScaleDirection的用法示例。


在下文中一共展示了ScaleDirection.CLOCKWISE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rotateNeedle

private void rotateNeedle(final double VALUE) {
    double startOffsetAngle = 180 - startAngle;
    double targetAngle;
    if (ScaleDirection.CLOCKWISE == gauge.getScaleDirection()) {
        targetAngle = startOffsetAngle + (VALUE - minValue) * angleStep;
        targetAngle = Helper.clamp(startOffsetAngle, startOffsetAngle + angleRange, targetAngle);
    } else {
        targetAngle = startOffsetAngle - (VALUE - minValue) * angleStep;
        targetAngle = Helper.clamp(startOffsetAngle - angleRange, startOffsetAngle, targetAngle);
    }
    needleRotate.setAngle(targetAngle);
    valueText.setText(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), VALUE));
    if (gauge.isLcdVisible()) {
        valueText.setTranslateX((0.675 * width - valueText.getLayoutBounds().getWidth()));
    } else {
        valueText.setTranslateX((width - valueText.getLayoutBounds().getWidth()) * 0.5);
    }
    if (gauge.isAverageVisible()) drawAverage();
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:19,代码来源:HSkin.java

示例2: drawGradientBar

private void drawGradientBar() {
    double     scaledWidth = width * 0.9;
    double     xy          = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.1705 * scaledWidth : 0.107 * scaledWidth;
    double     wh          = TickLabelLocation.OUTSIDE == tickLabelLocation ? scaledWidth * 0.77 : scaledWidth * 0.897;
    double     offsetY     = -0.1 * height;
    double     offset      = 90 - startAngle;
    List<Stop> stops       = gauge.getGradientBarStops();
    Map<Double, Color> stopAngleMap = new HashMap<>(stops.size());
    for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * angleRange, stop.getColor()); }
    double               offsetFactor = ScaleDirection.CLOCKWISE == scaleDirection ? startAngle - angleRange + 180 : (startAngle + 180);
    AngleConicalGradient gradient     = new AngleConicalGradient(width * 0.5, width * 0.5, offsetFactor, stopAngleMap, gauge.getScaleDirection());

    double barStartAngle  = ScaleDirection.CLOCKWISE == scaleDirection ? -minValue * angleStep : minValue * angleStep;
    double barAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? gauge.getRange() * angleStep : -gauge.getRange() * angleStep;
    tickMarkCtx.save();
    tickMarkCtx.setStroke(gradient.getImagePattern(new Rectangle(xy - 0.026 * width, xy - 0.026 * width + offsetY, wh + 0.052 * width, wh + 0.052 * width)));
    tickMarkCtx.setLineWidth(scaledWidth * 0.052);
    tickMarkCtx.setLineCap(StrokeLineCap.BUTT);
    tickMarkCtx.strokeArc(xy, xy + offsetY, wh, wh, -(offset + barStartAngle), -barAngleExtend, ArcType.OPEN);
    tickMarkCtx.restore();
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:21,代码来源:HSkin.java

示例3: drawGradientBar

private void drawGradientBar() {
    double             xy           = size * 0.1875;
    double             wh           = size * 0.625;
    double             offset       = -ANGLE_RANGE * 0.5 - 90;
    double             startAngle   = 315;
    List<Stop>         stops        = gauge.getGradientBarStops();
    Map<Double, Color> stopAngleMap = new HashMap<>(stops.size());
    for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * ANGLE_RANGE, stop.getColor()); }
    double               offsetFactor = startAngle - 90;
    AngleConicalGradient gradient     = new AngleConicalGradient(size * 0.5, size * 0.5, offsetFactor, stopAngleMap, ScaleDirection.CLOCKWISE);

    double barStartAngle  = 0;
    double barAngleExtend = 270;
    sectionCtx.save();
    sectionCtx.setStroke(gradient.getImagePattern(new Rectangle(xy - 0.09191176 * size, xy - 0.09191176 * size, wh + 0.18382353 * size, wh + 0.18382353 * size)));
    sectionCtx.setLineWidth(size * 0.18382353);
    sectionCtx.setLineCap(StrokeLineCap.BUTT);
    sectionCtx.strokeArc(xy, xy, wh, wh, -(offset + barStartAngle), -barAngleExtend, ArcType.OPEN);
    sectionCtx.restore();    
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:20,代码来源:TinySkin.java

示例4: drawGradientBar

private void drawGradientBar() {
    Pos                knobPosition      = gauge.getKnobPosition();
    TickLabelLocation  tickLabelLocation = gauge.getTickLabelLocation();
    double             scaledSize        = size * 1.9;
    double             xy                = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.105 * scaledSize : 0.03875 * scaledSize;
    double             wh                = TickLabelLocation.OUTSIDE == tickLabelLocation ? scaledSize * 0.79 : scaledSize * 0.925;
    double             offsetX           = Pos.TOP_LEFT == knobPosition || Pos.BOTTOM_LEFT == knobPosition ? -scaledSize * 0.475 : 0;
    double             offsetY           = Pos.TOP_LEFT == knobPosition || Pos.TOP_RIGHT == knobPosition ? -scaledSize * 0.475 : 0;
    double             offset            = 90 - startAngle;
    ScaleDirection     scaleDirection    = gauge.getScaleDirection();
    List<Stop>         stops             = gauge.getGradientBarStops();
    Map<Double, Color> stopAngleMap      = new HashMap<>(stops.size());
    for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * ANGLE_RANGE, stop.getColor()); }
    double               offsetFactor = ScaleDirection.CLOCKWISE == scaleDirection ? (Pos.TOP_LEFT == knobPosition || Pos.BOTTOM_RIGHT == knobPosition ? startAngle : 180 - startAngle) : (startAngle + 180);
    AngleConicalGradient gradient     = new AngleConicalGradient(scaledSize * 0.5, scaledSize * 0.5, offsetFactor, stopAngleMap, gauge.getScaleDirection());

    double barStartAngle  = ScaleDirection.CLOCKWISE == scaleDirection ? -minValue * angleStep : minValue * angleStep;
    double barAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? gauge.getRange() * angleStep : -gauge.getRange() * angleStep;
    tickMarkCtx.save();
    tickMarkCtx.setStroke(gradient.getImagePattern(new Rectangle(xy - 0.026 * scaledSize + offsetX, xy - 0.026 * scaledSize + offsetY, wh + 0.052 * scaledSize, wh + 0.052 * scaledSize)));
    tickMarkCtx.setLineWidth(scaledSize * 0.052);
    tickMarkCtx.setLineCap(StrokeLineCap.BUTT);
    tickMarkCtx.strokeArc(xy + offsetX, xy + offsetY, wh, wh, -(offset + barStartAngle), -barAngleExtend, ArcType.OPEN);
    tickMarkCtx.restore();
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:25,代码来源:QuarterSkin.java

示例5: rotateNeedle

private void rotateNeedle(final double VALUE) {
    double startOffsetAngle = 180 - startAngle;
    double targetAngle;
    if (ScaleDirection.CLOCKWISE == gauge.getScaleDirection()) {
        targetAngle = startOffsetAngle + (VALUE - minValue) * angleStep;
        targetAngle = Helper.clamp(startOffsetAngle, startOffsetAngle + angleRange, targetAngle);
    } else {
        targetAngle = startOffsetAngle - (VALUE - minValue) * angleStep;
        targetAngle = Helper.clamp(startOffsetAngle - angleRange, startOffsetAngle, targetAngle);
    }
    needleRotate.setAngle(targetAngle);
    valueText.setText(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), VALUE));
    valueText.setTranslateX(Pos.CENTER_LEFT == gauge.getKnobPosition() ?
                            width * 0.6 - valueText.getLayoutBounds().getWidth() :
                            width * 0.9 - valueText.getLayoutBounds().getWidth());
    if (gauge.isAverageVisible()) drawAverage();
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:17,代码来源:VSkin.java

示例6: drawGradientBar

private void drawGradientBar() {
    double     xy     = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.115 * size : 0.0515 * size;
    double     wh     = TickLabelLocation.OUTSIDE == tickLabelLocation ? size * 0.77 : size * 0.897;
    double     offset = 90 - startAngle;
    List<Stop> stops  = gauge.getGradientBarStops();
    Map<Double, Color> stopAngleMap     = new HashMap<>(stops.size());
    for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * angleRange, stop.getColor()); }
    double                  offsetFactor        = ScaleDirection.CLOCKWISE == scaleDirection ? (startAngle - 90) : (startAngle + 180);
    AngleConicalGradient    gradient            = new AngleConicalGradient(size * 0.5, size * 0.5, offsetFactor, stopAngleMap, gauge.getScaleDirection());

    double barStartAngle  = ScaleDirection.CLOCKWISE == scaleDirection ? -minValue * angleStep : minValue * angleStep;
    double barAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? gauge.getRange() * angleStep : -gauge.getRange() * angleStep;
    tickMarkCtx.save();
    tickMarkCtx.setStroke(gradient.getImagePattern(new Rectangle(xy - 0.026 * size, xy - 0.026 * size, wh + 0.052 * size, wh + 0.052 * size)));
    tickMarkCtx.setLineWidth(size * 0.052);
    tickMarkCtx.setLineCap(StrokeLineCap.BUTT);
    tickMarkCtx.strokeArc(xy, xy, wh, wh, -(offset + barStartAngle), -barAngleExtend, ArcType.OPEN);
    tickMarkCtx.restore();
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:19,代码来源:GaugeSkin.java

示例7: rotateNeedle

private void rotateNeedle(double value) {
    double startOffsetAngle = 180 - startAngle;
    double targetAngle;
    if (NeedleBehavior.STANDARD == needleBehavior) {
        if (ScaleDirection.CLOCKWISE == getSkinnable().getScaleDirection()) {
            targetAngle = startOffsetAngle + (value - minValue) * angleStep;
            targetAngle = Helper.clamp(startOffsetAngle, startOffsetAngle + angleRange, targetAngle);
        } else {
            targetAngle = startOffsetAngle - (value - minValue) * angleStep;
            targetAngle = Helper.clamp(startOffsetAngle - angleRange, startOffsetAngle, targetAngle);
        }
    } else {
        if (value < minValue) value = maxValue - minValue + value;
        if (value > maxValue) value = value - maxValue + minValue;
        if (ScaleDirection.CLOCKWISE == getSkinnable().getScaleDirection()) {
            targetAngle = startOffsetAngle + (value - minValue) * angleStep;
            targetAngle = Helper.clamp(startOffsetAngle, startOffsetAngle + angleRange, targetAngle);
        } else {
            targetAngle = startOffsetAngle - (value - minValue) * angleStep;
            targetAngle = Helper.clamp(startOffsetAngle - angleRange, startOffsetAngle, targetAngle);
        }
    }

    needleRotate.setAngle(targetAngle);
    valueText.setText(String.format(locale, formatString, value));
    if (getSkinnable().isLcdVisible()) {
        valueText.setTranslateX((0.691 * size - valueText.getLayoutBounds().getWidth()));
    } else {
        valueText.setTranslateX((size - valueText.getLayoutBounds().getWidth()) * 0.5);
    }

    if (getSkinnable().isAverageVisible()) drawAverage();
}
 
开发者ID:HanSolo,项目名称:medusademo,代码行数:33,代码来源:InteractiveGaugeSkin.java

示例8: drawAverage

private void drawAverage() {
    double centerX = size * 0.5;
    double centerY = size * 0.5;
    // Draw average
    average.getElements().clear();
    double averageAngle;
    if (ScaleDirection.CLOCKWISE == scaleDirection) {
        averageAngle = startAngle - (getSkinnable().getAverage() - minValue) * angleStep;
    } else {
        averageAngle = startAngle + (getSkinnable().getAverage() - minValue) * angleStep;
    }
    double averageSize = Helper.clamp(3.0, 3.5, 0.01 * size);
    double sinValue      = Math.sin(Math.toRadians(averageAngle));
    double cosValue      = Math.cos(Math.toRadians(averageAngle));
    switch (tickLabelLocation) {
        case OUTSIDE:
            average.getElements().add(new MoveTo(centerX + size * 0.38 * sinValue, centerY + size * 0.38 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + size * 0.34 * sinValue, centerY + size * 0.34 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + size * 0.34 * sinValue, centerY + size * 0.34 * cosValue));
            average.getElements().add(new ClosePath());
            break;
        case INSIDE:
        default:
            average.getElements().add(new MoveTo(centerX + size * 0.465 * sinValue, centerY + size * 0.465 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + size * 0.425 * sinValue, centerY + size * 0.425 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + size * 0.425 * sinValue, centerY + size * 0.425 * cosValue));
            average.getElements().add(new ClosePath());
            break;
    }
    average.setFill(getSkinnable().getAverageColor());
    average.setStroke(getSkinnable().getTickMarkColor());
}
 
开发者ID:HanSolo,项目名称:medusademo,代码行数:40,代码来源:InteractiveGaugeSkin.java

示例9: rotateNeedle

private void rotateNeedle(final double VALUE) {
    double startOffsetAngle  = 180 - startAngle;
    double targetAngle;
    if (ScaleDirection.CLOCKWISE == gauge.getScaleDirection()) {
        targetAngle = startOffsetAngle + (VALUE - minValue) * angleStep;
        targetAngle = Helper.clamp(startOffsetAngle, startOffsetAngle + ANGLE_RANGE, targetAngle);
    } else {
        targetAngle = startOffsetAngle - (VALUE - minValue) * angleStep;
        targetAngle = Helper.clamp(startOffsetAngle - ANGLE_RANGE, startOffsetAngle, targetAngle);
    }
    needleRotate.setAngle(targetAngle);
    valueText.setText(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), VALUE));
    resizeValueText();
    if (gauge.isAverageVisible()) drawAverage();
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:15,代码来源:QuarterSkin.java

示例10: drawAverage

private void drawAverage() {
    double scaledSize = size * 1.95;
    // Draw average
    average.getElements().clear();
    double averageAngle;
    if (ScaleDirection.CLOCKWISE == scaleDirection) {
        averageAngle = startAngle - (gauge.getAverage() - minValue) * angleStep;
    } else {
        averageAngle = startAngle + (gauge.getAverage() - minValue) * angleStep;
    }
    double averageSize = Helper.clamp(3.0, 3.5, 0.01 * size);
    double sinValue      = Math.sin(Math.toRadians(averageAngle));
    double cosValue      = Math.cos(Math.toRadians(averageAngle));
    switch (tickLabelLocation) {
        case OUTSIDE:
            average.getElements().add(new MoveTo(centerX + scaledSize * 0.38 * sinValue, centerY + scaledSize * 0.38 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + scaledSize * 0.34 * sinValue, centerY + scaledSize * 0.34 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + scaledSize * 0.34 * sinValue, centerY + scaledSize * 0.34 * cosValue));
            average.getElements().add(new ClosePath());
            break;
        case INSIDE:
        default:
            average.getElements().add(new MoveTo(centerX + scaledSize * 0.465 * sinValue, centerY + scaledSize * 0.465 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle - averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle - averageSize));
            average.getElements().add(new LineTo(centerX + scaledSize * 0.425 * sinValue, centerY + scaledSize * 0.425 * cosValue));
            sinValue = Math.sin(Math.toRadians(averageAngle + averageSize));
            cosValue = Math.cos(Math.toRadians(averageAngle + averageSize));
            average.getElements().add(new LineTo(centerX + scaledSize * 0.425 * sinValue, centerY + scaledSize * 0.425 * cosValue));
            average.getElements().add(new ClosePath());
            break;
    }
    average.setFill(gauge.getAverageColor());
    average.setStroke(gauge.getTickMarkColor());
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:39,代码来源:QuarterSkin.java

示例11: getStartAngle

private double getStartAngle() {
    ScaleDirection scaleDirection = gauge.getScaleDirection();
    Pos            knobPosition   = gauge.getKnobPosition();
    switch(knobPosition) {
        case CENTER_LEFT : return ScaleDirection.CLOCKWISE == scaleDirection ? angleRange * 0.5 + 90 : 90 - angleRange * 0.5;
        case CENTER_RIGHT:
        default          : return ScaleDirection.CLOCKWISE == scaleDirection ? angleRange * 0.5 - 90 : 270 -  angleRange * 0.5;
    }
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:9,代码来源:VSkin.java

示例12: rotateNeedle

private void rotateNeedle(double value) {
    double startOffsetAngle = 180 - startAngle;
    double targetAngle;
    if (NeedleBehavior.STANDARD == needleBehavior) {
        if (ScaleDirection.CLOCKWISE == gauge.getScaleDirection()) {
            targetAngle = startOffsetAngle + (value - minValue) * angleStep;
            targetAngle = Helper.clamp(startOffsetAngle, startOffsetAngle + angleRange, targetAngle);
        } else {
            targetAngle = startOffsetAngle - (value - minValue) * angleStep;
            targetAngle = Helper.clamp(startOffsetAngle - angleRange, startOffsetAngle, targetAngle);
        }
    } else {
        if (value < minValue) value = maxValue - minValue + value;
        if (value > maxValue) value = value - maxValue + minValue;
        if (ScaleDirection.CLOCKWISE == gauge.getScaleDirection()) {
            targetAngle = startOffsetAngle + (value - minValue) * angleStep;
            targetAngle = Helper.clamp(startOffsetAngle, startOffsetAngle + angleRange, targetAngle);
        } else {
            targetAngle = startOffsetAngle - (value - minValue) * angleStep;
            targetAngle = Helper.clamp(startOffsetAngle - angleRange, startOffsetAngle, targetAngle);
        }
    }

    needleRotate.setAngle(targetAngle);
    valueText.setText(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), value));
    if (gauge.isLcdVisible()) {
        valueText.setTranslateX((0.691 * size - valueText.getLayoutBounds().getWidth()));
    } else {
        valueText.setTranslateX((size - valueText.getLayoutBounds().getWidth()) * 0.5);
    }

    if (gauge.isAverageVisible()) drawAverage();
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:33,代码来源:GaugeSkin.java

示例13: drawBackground

private void drawBackground() {
    sectionCanvas.setCache(false);
    sectionCtx.setLineCap(StrokeLineCap.BUTT);
    sectionCtx.clearRect(0, 0, size, size);

    if (sectionsVisible && !sections.isEmpty()) {
        double xy        = 0.012 * size;
        double wh        = size * 0.976;
        double minValue  = model.getMinValue();
        double maxValue  = model.getMaxValue();
        double angleStep = model.getAngleStep();

        sectionCtx.setLineWidth(size * 0.025);
        sectionCtx.setLineCap(StrokeLineCap.BUTT);
        for (int i = 0; i < sections.size(); i++) {
            Section section = sections.get(i);
            double  sectionStartAngle;
            if (Double.compare(section.getStart(), maxValue) <= 0 && Double.compare(section.getStop(), minValue) >= 0) {
                if (Double.compare(section.getStart(), minValue) < 0 && Double.compare(section.getStop(), maxValue) < 0) {
                    sectionStartAngle = 0;
                } else {
                    sectionStartAngle = ScaleDirection.CLOCKWISE == model.getScaleDirection() ? (section.getStart() - minValue) * angleStep : -(section.getStart() - minValue) * angleStep;
                }
                double sectionAngleExtend;
                if (Double.compare(section.getStop(), maxValue) > 0) {
                    sectionAngleExtend = ScaleDirection.CLOCKWISE == model.getScaleDirection() ? (maxValue - section.getStart()) * angleStep : -(maxValue - section.getStart()) * angleStep;
                } else if (Double.compare(section.getStart(), minValue) < 0) {
                    sectionAngleExtend = ScaleDirection.CLOCKWISE == model.getScaleDirection() ? (section.getStop() - minValue) * model.getAngleStep() : -(section.getStop() - minValue) * angleStep;
                } else {
                    sectionAngleExtend = ScaleDirection.CLOCKWISE == model.getScaleDirection() ? (section.getStop() - section.getStart()) * angleStep : -(section.getStop() - section.getStart()) * angleStep;
                }
                sectionCtx.save();

                sectionCtx.setStroke(section.getColor());
                sectionCtx.strokeArc(xy, xy, wh, wh, -(120 + sectionStartAngle), -sectionAngleExtend, ArcType.OPEN);
                sectionCtx.restore();
            }
        }
    }

    sectionCanvas.setCache(true);
    sectionCanvas.setCacheHint(CacheHint.QUALITY);
}
 
开发者ID:HanSolo,项目名称:SimpleSectionGauge,代码行数:43,代码来源:SimpleSectionGauge.java

示例14: resize

@Override protected void resize() {
    double width  = gauge.getWidth() - gauge.getInsets().getLeft() - gauge.getInsets().getRight();
    double height = gauge.getHeight() - gauge.getInsets().getTop() - gauge.getInsets().getBottom();
    size          = width < height ? width : height;

    if (width > 0 && height > 0) {
        pane.setMaxSize(size, size);
        pane.setPrefSize(size, size);
        pane.relocate((width - size) * 0.5, (height - size) * 0.5);

        center = size * 0.5;

        circle.setCenterX(center);
        circle.setCenterY(center);
        circle.setRadius(size * 0.44);
        circle.setStrokeWidth(size * 0.11);

        arc.setCenterX(center);
        arc.setCenterY(center);
        arc.setRadiusX(size * 0.44);
        arc.setRadiusY(size * 0.44);
        arc.setStrokeWidth(size * 0.11);

        shadow.setRadius(0.03 * size);
        shadow.setOffsetX(0.03 * size);

        Color      barColor         = gauge.getBarColor();
        double     currentValue     = gauge.getCurrentValue();
        List<Stop> gradientBarStops = gauge.getGradientBarStops();

        circle.setStroke(Color.color(barColor.getRed(), barColor.getGreen(), barColor.getBlue(), 0.13));

        Rectangle bounds = new Rectangle(0, 0, size, size);

        gradient = new ConicalGradient(center, center, ScaleDirection.CLOCKWISE, gradientBarStops);
        arc.setStroke(gradient.getImagePattern(bounds));
        arc.setLength(currentValue * angleStep);

        fakeDot.setRadius(size * 0.055);
        fakeDot.setFill(gradientBarStops.get(0).getColor());

        dot.setRadius(size * 0.055);
        dot.setFill(gradientBarStops.get(3).getColor());

        dot.setCenterX(center + arc.getRadiusX() * Math.sin(Math.toRadians(180 - currentValue * angleStep)));
        dot.setCenterY(center + arc.getRadiusY() * Math.cos(Math.toRadians(180 - currentValue * angleStep)));

        titleText.setFill(barColor);

        resizeTitleText();
        resizeValueText();
        resizeUnitText();

        redraw();
    }
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:56,代码来源:BarSkin.java

示例15: drawAreasAndSections

private void drawAreasAndSections(final GraphicsContext CTX) {
    if (areas.isEmpty() && sections.isEmpty()) return;
    double value  = gauge.getCurrentValue();
    double offset = 90 - startAngle;
    double xy;
    double wh;
    int    listSize;

    // Draw Areas
    if (areasVisible && !areas.isEmpty()) {
        xy       = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.0895 * size : 0.025 * size;
        wh       = TickLabelLocation.OUTSIDE == tickLabelLocation ? size * 0.821 : size * 0.95;
        listSize = areas.size();
        for (int i = 0; i < listSize ; i++) {
            Section area = areas.get(i);
            double areaStartAngle;
            if (Double.compare(area.getStart(), maxValue) <= 0 && Double.compare(area.getStop(), minValue) >= 0) {
                if (area.getStart() < minValue && area.getStop() < maxValue) {
                    areaStartAngle = 0;
                } else {
                    areaStartAngle = ScaleDirection.CLOCKWISE == scaleDirection ? (area.getStart() - minValue) * angleStep : -(area.getStart() - minValue) * angleStep;
                }
                double areaAngleExtend;
                if (area.getStop() > maxValue) {
                    areaAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? (maxValue - area.getStart()) * angleStep : -(maxValue - area.getStart()) * angleStep;
                } else if (Double.compare(area.getStart(), minValue) < 0) {
                    areaAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? (area.getStop() - minValue) * angleStep : -(area.getStop() - minValue) * angleStep;
                } else {
                    areaAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? (area.getStop() - area.getStart()) * angleStep : -(area.getStop() - area.getStart()) * angleStep;
                }
                CTX.save();
                if (highlightAreas) {
                    CTX.setFill(area.contains(value) ? area.getHighlightColor() : area.getColor());
                } else {
                    CTX.setFill(area.getColor());
                }
                CTX.fillArc(xy, xy, wh, wh, -(offset + areaStartAngle), - areaAngleExtend, ArcType.ROUND);
                CTX.restore();
            }
        }
    }

    // Draw Sections
    if (sectionsVisible && !sections.isEmpty()) {
        xy       = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.115 * size : 0.0515 * size;
        wh       = TickLabelLocation.OUTSIDE == tickLabelLocation ? size * 0.77 : size * 0.897;
        listSize = sections.size();
        CTX.setLineWidth(size * 0.052);
        CTX.setLineCap(StrokeLineCap.BUTT);
        for (int i = 0; i < listSize; i++) {
            Section section = sections.get(i);
            double  sectionStartAngle;
            if (Double.compare(section.getStart(), maxValue) <= 0 && Double.compare(section.getStop(), minValue) >= 0) {
                if (Double.compare(section.getStart(), minValue) < 0 && Double.compare(section.getStop(), maxValue) < 0) {
                    sectionStartAngle = 0;
                } else {
                    sectionStartAngle = ScaleDirection.CLOCKWISE == scaleDirection ? (section.getStart() - minValue) * angleStep : -(section.getStart() - minValue) * angleStep;
                }
                double sectionAngleExtend;
                if (Double.compare(section.getStop(), maxValue) > 0) {
                    sectionAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? (maxValue - section.getStart()) * angleStep : -(maxValue - section.getStart()) * angleStep;
                } else if (Double.compare(section.getStart(), minValue) < 0) {
                    sectionAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? (section.getStop() - minValue) * angleStep : -(section.getStop() - minValue) * angleStep;
                } else {
                    sectionAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? (section.getStop() - section.getStart()) * angleStep : -(section.getStop() - section.getStart()) * angleStep;
                }
                CTX.save();
                if (highlightSections) {
                    CTX.setStroke(section.contains(value) ? section.getHighlightColor() : section.getColor());
                } else {
                    CTX.setStroke(section.getColor());
                }
                CTX.strokeArc(xy, xy, wh, wh, -(offset + sectionStartAngle), -sectionAngleExtend, ArcType.OPEN);
                CTX.restore();
            }
        }
    }
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:78,代码来源:GaugeSkin.java


注:本文中的eu.hansolo.medusa.Gauge.ScaleDirection.CLOCKWISE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。