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


Java ScaleDirection类代码示例

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


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

示例1: drawGradientBar

import eu.hansolo.medusa.Gauge.ScaleDirection; //导入依赖的package包/类
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  = getSkinnable().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, getSkinnable().getScaleDirection());

    double barStartAngle  = ScaleDirection.CLOCKWISE == scaleDirection ? -minValue * angleStep : minValue * angleStep;
    double barAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? getSkinnable().getRange() * angleStep : -getSkinnable().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,项目名称:medusademo,代码行数:20,代码来源:InteractiveGaugeSkin.java

示例2: rotateNeedle

import eu.hansolo.medusa.Gauge.ScaleDirection; //导入依赖的package包/类
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,代码行数:20,代码来源:HSkin.java

示例3: drawGradientBar

import eu.hansolo.medusa.Gauge.ScaleDirection; //导入依赖的package包/类
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,代码行数:22,代码来源:HSkin.java

示例4: drawGradientBar

import eu.hansolo.medusa.Gauge.ScaleDirection; //导入依赖的package包/类
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,代码行数:26,代码来源:QuarterSkin.java

示例5: rotateNeedle

import eu.hansolo.medusa.Gauge.ScaleDirection; //导入依赖的package包/类
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,代码行数:18,代码来源:VSkin.java

示例6: drawGradientBar

import eu.hansolo.medusa.Gauge.ScaleDirection; //导入依赖的package包/类
private void drawGradientBar() {
    TickLabelLocation  tickLabelLocation     = gauge.getTickLabelLocation();
    double             scaledHeight          = height * 0.9;
    double             xy                    = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.1705 * scaledHeight : 0.107 * scaledHeight;
    double             wh                    = TickLabelLocation.OUTSIDE == tickLabelLocation ? scaledHeight * 0.77 : scaledHeight * 0.897;
    double             offset                = 90 - startAngle;
    double             offsetX               = -0.1 * width;
    double             knobPositionOffsetCW  = Pos.CENTER_LEFT == gauge.getKnobPosition() ? 90 : 270;
    double             knobPositionOffsetCCW = Pos.CENTER_LEFT == gauge.getKnobPosition() ? 180 : 0;
    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() * angleRange, stop.getColor()); }
    double               offsetFactor = ScaleDirection.CLOCKWISE == scaleDirection ? knobPositionOffsetCW - angleRange * 0.5 : angleRange - (angleRange / 180 * angleRange) + knobPositionOffsetCCW;
    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 * height + offsetX, xy - 0.026 * height, wh + 0.052 * height, wh + 0.052 * height)));
    tickMarkCtx.setLineWidth(scaledHeight * 0.052);
    tickMarkCtx.setLineCap(StrokeLineCap.BUTT);
    tickMarkCtx.strokeArc(xy + offsetX, xy, wh, wh, -(offset + barStartAngle), -barAngleExtend, ArcType.OPEN);
    tickMarkCtx.restore();
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:26,代码来源:VSkin.java

示例7: drawGradientBar

import eu.hansolo.medusa.Gauge.ScaleDirection; //导入依赖的package包/类
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,代码行数:20,代码来源:GaugeSkin.java

示例8: drawGradientBar

import eu.hansolo.medusa.Gauge.ScaleDirection; //导入依赖的package包/类
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,代码行数:21,代码来源:TinySkin.java

示例9: normalizeStops

import eu.hansolo.medusa.Gauge.ScaleDirection; //导入依赖的package包/类
private List<Stop> normalizeStops(final double OFFSET, final List<Stop> STOPS) {
    double offset = Helper.clamp(0.0, 1.0, OFFSET);
    List<Stop> stops;
    if (null == STOPS || STOPS.isEmpty()) {
        stops = new ArrayList<>();
        stops.add(new Stop(0.0, Color.TRANSPARENT));
        stops.add(new Stop(1.0, Color.TRANSPARENT));
    } else {
        stops = STOPS;
    }
    List<Stop> sortedStops = calculate(stops, offset);

    // Reverse the Stops for CCW direction
    if (ScaleDirection.COUNTER_CLOCKWISE == scaleDirection) {
        List<Stop> sortedStops3 = new ArrayList<>();
        Collections.reverse(sortedStops);
        for (Stop stop : sortedStops) { sortedStops3.add(new Stop(1.0 - stop.getOffset(), stop.getColor())); }
        sortedStops = sortedStops3;
    }
    return sortedStops;
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:22,代码来源:ConicalGradient.java

示例10: rotateNeedle

import eu.hansolo.medusa.Gauge.ScaleDirection; //导入依赖的package包/类
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,代码行数:34,代码来源:InteractiveGaugeSkin.java

示例11: drawAverage

import eu.hansolo.medusa.Gauge.ScaleDirection; //导入依赖的package包/类
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,代码行数:41,代码来源:InteractiveGaugeSkin.java

示例12: getStartAngle

import eu.hansolo.medusa.Gauge.ScaleDirection; //导入依赖的package包/类
private double getStartAngle() {
    ScaleDirection scaleDirection = gauge.getScaleDirection();
    Pos            knobPosition   = gauge.getKnobPosition();
    switch(knobPosition) {
        case TOP_CENTER   : return ScaleDirection.CLOCKWISE == scaleDirection ? angleRange * 0.5 : -angleRange * 0.5;
        case BOTTOM_CENTER:
        default           : return ScaleDirection.CLOCKWISE == scaleDirection ? 180 + angleRange * 0.5 : 180 - angleRange * 0.5;
    }
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:10,代码来源:HSkin.java

示例13: getStartAngle

import eu.hansolo.medusa.Gauge.ScaleDirection; //导入依赖的package包/类
private double getStartAngle() {
    ScaleDirection scaleDirection = gauge.getScaleDirection();
    Pos            knobPosition   = gauge.getKnobPosition();
    switch(knobPosition) {
        case BOTTOM_LEFT : return ScaleDirection.CLOCKWISE == scaleDirection ? 180 : 90;
        case TOP_LEFT    : return ScaleDirection.CLOCKWISE == scaleDirection ?  90 : 0;
        case TOP_RIGHT   : return ScaleDirection.CLOCKWISE == scaleDirection ?   0 : 270;
        case BOTTOM_RIGHT:
        default          : return ScaleDirection.CLOCKWISE == scaleDirection ? 270 : 180;
    }
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:12,代码来源:QuarterSkin.java

示例14: rotateNeedle

import eu.hansolo.medusa.Gauge.ScaleDirection; //导入依赖的package包/类
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,代码行数:16,代码来源:QuarterSkin.java

示例15: drawAverage

import eu.hansolo.medusa.Gauge.ScaleDirection; //导入依赖的package包/类
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,代码行数:40,代码来源:QuarterSkin.java


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