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


Java Section.getStop方法代码示例

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


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

示例1: drawSections

import eu.hansolo.medusa.Section; //导入方法依赖的package包/类
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;
    List<Arc> sectionBars = new ArrayList<>(sections.size());
    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);
        sectionBars.add(sectionBar);
    }
    sectionLayer.getChildren().addAll(sectionBars);
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:24,代码来源:IndicatorSkin.java

示例2: drawSections

import eu.hansolo.medusa.Section; //导入方法依赖的package包/类
private void drawSections() {
    if (sections.isEmpty()) return;
    sectionCtx.clearRect(0, 0, size, size);
    double xy       = size * 0.1875;
    double wh       = size * 0.625;
    double offset   = -ANGLE_RANGE * 0.5 - 90;
    int    listSize = sections.size();
    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 = (section.getStart() - minValue) * angleStep;
            }
            double sectionAngleExtend;
            if (Double.compare(section.getStop(), maxValue) > 0) {
                sectionAngleExtend = (maxValue - section.getStart()) * angleStep;
            } else if (Double.compare(section.getStart(), minValue) < 0) {
                sectionAngleExtend = (section.getStop() - minValue) * angleStep;
            } else {
                sectionAngleExtend = (section.getStop() - section.getStart()) * angleStep;
            }
            sectionCtx.save();
            sectionCtx.setStroke(section.getColor());
            sectionCtx.setLineWidth(size * 0.18382353);
            sectionCtx.setLineCap(StrokeLineCap.BUTT);
            sectionCtx.strokeArc(xy, xy, wh, wh, -(offset + sectionStartAngle), -sectionAngleExtend, ArcType.OPEN);
            sectionCtx.restore();
        }
    }
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:34,代码来源:TinySkin.java

示例3: drawBackground

import eu.hansolo.medusa.Section; //导入方法依赖的package包/类
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,代码行数:44,代码来源:SimpleSectionGauge.java

示例4: drawAreasAndSections

import eu.hansolo.medusa.Section; //导入方法依赖的package包/类
private void drawAreasAndSections(final GraphicsContext CTX) {
    if (areas.isEmpty() && sections.isEmpty()) return;
    double value  = getSkinnable().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,项目名称:medusademo,代码行数:79,代码来源:InteractiveGaugeSkin.java

示例5: drawSections

import eu.hansolo.medusa.Section; //导入方法依赖的package包/类
private void drawSections(final GraphicsContext CTX) {
    sectionsCanvas.setCache(false);
    CTX.clearRect(0, 0, sectionsCanvas.getWidth(), sectionsCanvas.getHeight());
    CTX.setFill(gauge.getBackgroundPaint());
    if (Orientation.VERTICAL == orientation) {
        CTX.fillRect(0, 0, 0.5 * width, 0.89 * height);
    } else {
        CTX.fillRect(0, 0, 0.79699248 * width, 0.5 * height);
    }

    double minValue = gauge.getMinValue();
    double maxValue = gauge.getMaxValue();

    int listSize = gauge.getSections().size();
    for (int i = 0 ; i < listSize ; i++) {
        final Section SECTION = gauge.getSections().get(i);
        final double SECTION_START;
        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) {
                SECTION_START = minValue * stepSize;
            } else {
                SECTION_START = (SECTION.getStart() - minValue) * stepSize;
            }
            final double SECTION_SIZE;
            if (Double.compare(SECTION.getStop(), maxValue) > 0) {
                SECTION_SIZE = (maxValue - SECTION.getStart()) * stepSize;
            } else {
                SECTION_SIZE = (SECTION.getStop() - SECTION.getStart()) * stepSize;
            }
            CTX.save();
            CTX.setFill(SECTION.getColor());
            if (Orientation.VERTICAL == orientation) {
                CTX.fillRect(0.0, 0.89 * height - SECTION_START - SECTION_SIZE, 0.5 * width, SECTION_SIZE);
            } else {
                CTX.fillRect(SECTION_START, 0.0, SECTION_SIZE, 0.5 * height);
            }
            CTX.restore();
        }
    }
    sectionsCanvas.setCache(true);
    sectionsCanvas.setCacheHint(CacheHint.QUALITY);
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:43,代码来源:BulletChartSkin.java

示例6: drawAreasAndSections

import eu.hansolo.medusa.Section; //导入方法依赖的package包/类
private void drawAreasAndSections(final GraphicsContext CTX) {
    if (areas.isEmpty() && sections.isEmpty()) return;

    double value       = gauge.getCurrentValue();
    double scaledWidth = width * 0.9;
    double offset      = 90 - startAngle;
    double offsetY     = -0.1 * height;
    double xy;
    double wh;
    int    listSize;

    // Draw areas
    if (areasVisible && !areas.isEmpty()) {
        xy       = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.1445 * scaledWidth : 0.081 * scaledWidth;
        wh       = TickLabelLocation.OUTSIDE == tickLabelLocation ? scaledWidth * 0.821 : scaledWidth * 0.9505;
        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 + offsetY, wh, wh, -(offset + areaStartAngle), - areaAngleExtend, ArcType.ROUND);
                CTX.restore();
            }
        }
    }

    // Draw sections
    if (sectionsVisible && !sections.isEmpty()) {
        xy       = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.1705 * scaledWidth : 0.107 * scaledWidth;
        wh       = TickLabelLocation.OUTSIDE == tickLabelLocation ? scaledWidth * 0.77 : scaledWidth * 0.897;
        listSize = sections.size();
        CTX.setLineWidth(scaledWidth * 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 + offsetY, wh, wh, -(offset + sectionStartAngle), -sectionAngleExtend, ArcType.OPEN);
                CTX.restore();
            }
        }
    }
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:82,代码来源:HSkin.java

示例7: drawSections

import eu.hansolo.medusa.Section; //导入方法依赖的package包/类
private void drawSections() {
    sectionsCtx.clearRect(0, 0, size, size);
    if (!sectionsVisible | sections.isEmpty()) return;
    double value               = gauge.getCurrentValue();
    boolean sectionTextVisible = gauge.isSectionTextVisible();
    boolean sectionIconVisible = gauge.getSectionIconsVisible();
    double offset              = START_ANGLE - 90;
    int listSize               = sections.size();
    double xy                  = size * 0.0325;
    double wh                  = size - (size * 0.065);
    double center              = size * 0.5;
    double textPointX;
    double textPointY;
    angleStep                  = ANGLE_RANGE / gauge.getRange();
    sectionsCtx.setFont(Fonts.robotoCondensedLight(0.05 * size));
    sectionsCtx.setTextAlign(TextAlignment.CENTER);
    sectionsCtx.setTextBaseline(VPos.CENTER);
    double sinValue;
    double cosValue;
    for (int i = 0 ; i < listSize ; i++) {
        Section section = sections.get(i);
        final double SECTION_START_ANGLE;
        if (section.getStart() > maxValue || section.getStop() < minValue) continue;

        if (section.getStart() < minValue && section.getStop() < maxValue) {
            SECTION_START_ANGLE = 0;
        } else {
            SECTION_START_ANGLE = (section.getStart() - minValue) * angleStep;
        }
        final double SECTION_ANGLE_EXTEND;
        if (Double.compare(section.getStop(), maxValue) > 0) {
            SECTION_ANGLE_EXTEND = (maxValue - section.getStart()) * angleStep;
        } else if (Double.compare(section.getStart(), minValue) < 0) {
            SECTION_ANGLE_EXTEND = (section.getStop() - minValue) * angleStep;
        } else {
            SECTION_ANGLE_EXTEND = (section.getStop() - section.getStart()) * angleStep;
        }
        sectionsCtx.save();
        if (highlightSections) {
            sectionsCtx.setFill(section.contains(value) ? section.getHighlightColor() : section.getColor());
        } else {
            sectionsCtx.setFill(section.getColor());
        }
        sectionsCtx.fillArc(xy, xy, wh, wh, (offset - SECTION_START_ANGLE), -SECTION_ANGLE_EXTEND, ArcType.ROUND);
        sectionsCtx.setStroke(Gauge.DARK_COLOR);
        sectionsCtx.setLineWidth(size * 0.005);
        sectionsCtx.strokeArc(xy, xy, wh, wh, (offset - SECTION_START_ANGLE), -SECTION_ANGLE_EXTEND, ArcType.ROUND);

        // Draw Section Text
        if (sectionTextVisible) {
            double angle = offset - 90 - SECTION_START_ANGLE - SECTION_ANGLE_EXTEND * 0.5;
            sinValue   = -Math.sin(Math.toRadians(angle));
            cosValue   = -Math.cos(Math.toRadians(angle));
            textPointX = center + size * 0.4 * sinValue;
            textPointY = center + size * 0.4 * cosValue;
            sectionsCtx.save();

            sectionsCtx.translate(textPointX, textPointY);
            sectionsCtx.rotate(-angle);
            sectionsCtx.translate(-textPointX,-textPointY);

            sectionsCtx.setFill(section.getTextColor());
            sectionsCtx.fillText(section.getText(), textPointX, textPointY, 0.2 * size);
            sectionsCtx.restore();
        } else if (size > 0 && sectionIconVisible) {
            // Draw Section Icon
            Image icon = section.getImage();
            if (null != icon) {
                sinValue = -Math.sin(Math.toRadians(offset - 90 - SECTION_START_ANGLE - SECTION_ANGLE_EXTEND * 0.5));
                cosValue = -Math.cos(Math.toRadians(offset - 90 - SECTION_START_ANGLE - SECTION_ANGLE_EXTEND * 0.5));
                Point2D iconPoint = new Point2D(center + size * 0.365 * sinValue, size * 0.5 + size * 0.365 * cosValue);
                sectionsCtx.drawImage(icon, iconPoint.getX() - size * 0.06, iconPoint.getY() - size * 0.06, size * 0.12, size * 0.12);
            }
        }
        sectionsCtx.restore();
    }
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:78,代码来源:SectionSkin.java

示例8: drawSections

import eu.hansolo.medusa.Section; //导入方法依赖的package包/类
private void drawSections(final GraphicsContext CTX) {
    final double x                         = width * 0.06;
    final double y                         = width * 0.21;
    final double w                         = width * 0.88;
    final double h                         = height * 1.05;
    final double MIN_VALUE                 = gauge.getMinValue();
    final double MAX_VALUE                 = gauge.getMaxValue();
    final double OFFSET                    = 90 - START_ANGLE;
    final ObservableList<Section> sections = gauge.getSections();
    final boolean highlightSections        = gauge.isHighlightSections();

    double value    = gauge.getCurrentValue();
    int    listSize = sections.size();
    for (int i = 0 ; i < listSize ; i++) {
        final Section SECTION = sections.get(i);
        final double  SECTION_START_ANGLE;
        if (Double.compare(SECTION.getStart(), MAX_VALUE) <= 0 && Double.compare(SECTION.getStop(), MIN_VALUE) >= 0) {
            if (SECTION.getStart() < MIN_VALUE && SECTION.getStop() < MAX_VALUE) {
                SECTION_START_ANGLE = 0;
            } else {
                SECTION_START_ANGLE = (SECTION.getStart() - MIN_VALUE) * angleStep;
            }
            final double SECTION_ANGLE_EXTEND;
            if (SECTION.getStop() > MAX_VALUE) {
                SECTION_ANGLE_EXTEND = (MAX_VALUE - SECTION.getStart()) * angleStep;
            } else {
                SECTION_ANGLE_EXTEND = (SECTION.getStop() - SECTION.getStart()) * angleStep;
            }

            CTX.save();
            if (highlightSections) {
                CTX.setStroke(SECTION.contains(value) ? SECTION.getHighlightColor() : SECTION.getColor());
            } else {
                CTX.setStroke(SECTION.getColor());
            }
            CTX.setLineWidth(height * 0.0415);
            CTX.setLineCap(StrokeLineCap.BUTT);
            CTX.strokeArc(x, y, w, h, -(OFFSET + SECTION_START_ANGLE), -SECTION_ANGLE_EXTEND, ArcType.OPEN);
            CTX.restore();
        }
    }
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:43,代码来源:AmpSkin.java

示例9: drawMainCanvas

import eu.hansolo.medusa.Section; //导入方法依赖的package包/类
private void drawMainCanvas() {
    mainCtx.clearRect(0, 0, size, size);
    mainCtx.setFillRule(FillRule.EVEN_ODD);

    // Draw sections if available
    final double sectionsXY = (size - 0.75 * size) * 0.5;
    final double sectionsWH = size * 0.75;
    double minValue         = gauge.getMinValue();
    double maxValue         = gauge.getMaxValue();
    double offset           = 90 - START_ANGLE;
    double sectionWidth     = size * 0.06;
    if (sectionsVisible) {
        int listSize = sections.size();
        for (int i = 0; i < listSize; i++) {
            final Section SECTION = sections.get(i);
            final double  SECTION_START_ANGLE;
            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) {
                    SECTION_START_ANGLE = 0;
                } else {
                    SECTION_START_ANGLE = (SECTION.getStart() - minValue) * angleStep;
                }
                final double SECTION_ANGLE_EXTEND;
                if (Double.compare(SECTION.getStop(), maxValue) > 0) {
                    SECTION_ANGLE_EXTEND = (maxValue - SECTION.getStart()) * angleStep;
                } else {
                    SECTION_ANGLE_EXTEND = (SECTION.getStop() - SECTION.getStart()) * angleStep;
                }
                mainCtx.save();
                mainCtx.setStroke(SECTION.getColor());
                mainCtx.setLineWidth(sectionWidth);
                mainCtx.setLineCap(StrokeLineCap.BUTT);
                mainCtx.strokeArc(sectionsXY, sectionsXY, sectionsWH, sectionsWH, -(offset + SECTION_START_ANGLE), -SECTION_ANGLE_EXTEND, ArcType.OPEN);
                mainCtx.restore();
            }
        }
    }

    // Draw tickmarks
    mainCtx.save();
    drawTickMarks(mainCtx);
    mainCtx.restore();

    // Draw black bar overlay
    mainCtx.save();
    mainCtx.setStroke(Color.rgb(23, 23, 23));
    mainCtx.setLineWidth(size * 0.025);
    mainCtx.setLineCap(StrokeLineCap.BUTT);
    mainCtx.strokeArc(sectionsXY, sectionsXY, sectionsWH, sectionsWH, BAR_START_ANGLE, -ANGLE_RANGE, ArcType.OPEN);
    mainCtx.restore();

    // Draw databar background
    double barXY = (size - 0.75 * size) * 0.5;
    double barWH = size * 0.75;
    mainCtx.save();
    mainCtx.setStroke(Color.rgb(57, 57, 57, 0.75));
    mainCtx.setLineWidth(size * 0.01666667);
    mainCtx.setLineCap(StrokeLineCap.BUTT);
    mainCtx.strokeArc(barXY, barXY, barWH, barWH, BAR_START_ANGLE, -ANGLE_RANGE, ArcType.OPEN);
    mainCtx.restore();

    // Draw threshold
    if (gauge.isThresholdVisible()) {
        mainCtx.save();
        mainCtx.translate(size * 0.5, size * 0.5);
        mainCtx.rotate(((gauge.getThreshold()  - minValue ) * angleStep) - 120);
        mainCtx.beginPath();
        mainCtx.moveTo(0, -size * 0.33);
        mainCtx.lineTo(-size * 0.0125, -size * 0.30833333);
        mainCtx.lineTo(size * 0.0125, -size * 0.30833333);
        mainCtx.closePath();
        mainCtx.setFill(gauge.getNeedleColor());
        mainCtx.fill();
        mainCtx.restore();
    }
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:77,代码来源:ModernSkin.java

示例10: drawSections

import eu.hansolo.medusa.Section; //导入方法依赖的package包/类
private void drawSections() {
    sectionsCtx.clearRect(0, 0, size, size);
    double value               = gauge.getCurrentValue();
    boolean sectionTextVisible = gauge.isSectionTextVisible();
    boolean sectionIconVisible = gauge.getSectionIconsVisible();
    double offset              = START_ANGLE - 90;
    int listSize               = sections.size();
    double xy                  = size * 0.015;
    double wh                  = size - (size * 0.03);
    double sectionXY           = size * 0.1375;
    double sectionWH           = size - (size * 0.275);
    angleStep                  = ANGLE_RANGE / (gauge.getRange());
    double sinValue;
    double cosValue;
    sectionsCtx.setLineWidth(size * 0.27);
    sectionsCtx.setLineCap(StrokeLineCap.BUTT);
    for (int i = 0 ; i < listSize ; i++) {
        Section section = sections.get(i);
        final double SECTION_START_ANGLE;
        if (section.getStart() > maxValue || section.getStop() < minValue) continue;

        if (section.getStart() < minValue && section.getStop() < maxValue) {
            SECTION_START_ANGLE = 0;
        } else {
            SECTION_START_ANGLE = (section.getStart() - minValue) * angleStep;
        }
        final double SECTION_ANGLE_EXTEND;
        if (Double.compare(section.getStop(), maxValue) > 0) {
            SECTION_ANGLE_EXTEND = (maxValue - section.getStart()) * angleStep;
        } else if (Double.compare(section.getStart(), minValue) < 0) {
            SECTION_ANGLE_EXTEND = (section.getStop() - minValue) * angleStep;
        } else {
            SECTION_ANGLE_EXTEND = (section.getStop() - section.getStart()) * angleStep;
        }
        sectionsCtx.save();
        if (highlightSections) {
            sectionsCtx.setStroke(section.contains(value) ? section.getHighlightColor() : section.getColor());
        } else {
            sectionsCtx.setStroke(section.getColor());
        }
        sectionsCtx.strokeArc(sectionXY, sectionXY, sectionWH, sectionWH, (offset - SECTION_START_ANGLE), -SECTION_ANGLE_EXTEND, ArcType.OPEN);

        // Draw Section Text
        if (sectionTextVisible) {
            sinValue = -Math.sin(Math.toRadians(offset - 90 - SECTION_START_ANGLE - SECTION_ANGLE_EXTEND * 0.5));
            cosValue = -Math.cos(Math.toRadians(offset - 90 - SECTION_START_ANGLE - SECTION_ANGLE_EXTEND * 0.5));
            Point2D textPoint = new Point2D(size * 0.5 + size * 0.365 * sinValue, size * 0.5 + size * 0.365 * cosValue);
            sectionsCtx.setFont(Fonts.robotoMedium(0.08 * size));
            sectionsCtx.setTextAlign(TextAlignment.CENTER);
            sectionsCtx.setTextBaseline(VPos.CENTER);
            sectionsCtx.setFill(section.getTextColor());
            sectionsCtx.fillText(section.getText(), textPoint.getX(), textPoint.getY(), 0.2 * size);
        } else if (size > 0 && sectionIconVisible) {
            // Draw Section Icon
            Image icon = section.getImage();
            if (null != icon) {
                sinValue = -Math.sin(Math.toRadians(offset - 90 - SECTION_START_ANGLE - SECTION_ANGLE_EXTEND * 0.5));
                cosValue = -Math.cos(Math.toRadians(offset - 90 - SECTION_START_ANGLE - SECTION_ANGLE_EXTEND * 0.5));
                Point2D iconPoint = new Point2D(size * 0.5 + size * 0.365 * sinValue, size * 0.5 + size * 0.365 * cosValue);
                sectionsCtx.drawImage(icon, iconPoint.getX() - size * 0.06, iconPoint.getY() - size * 0.06, size * 0.12, size * 0.12);
            }
        }
        sectionsCtx.restore();
    }
    // Draw white border around area
    sectionsCtx.setStroke(gauge.getBorderPaint());
    sectionsCtx.setLineWidth(size * 0.025);
    sectionsCtx.strokeArc(xy, xy, wh, wh, offset + 90, ANGLE_RANGE, ArcType.ROUND);

    if (gauge.getTickLabelsVisible()) {
        sectionsCtx.setFont(Fonts.robotoRegular(size * 0.1));
        sectionsCtx.setFill(gauge.getTickLabelColor());
        sectionsCtx.setTextBaseline(VPos.TOP);
        sectionsCtx.setTextAlign(TextAlignment.LEFT);
        sectionsCtx.fillText(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getMinValue()), size * 0.15075377, size * 0.86180905, size * 0.3);
        sectionsCtx.setTextAlign(TextAlignment.RIGHT);
        sectionsCtx.fillText(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getMaxValue()), size * 0.84924623, size * 0.86180905, size * 0.3);
    }
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:80,代码来源:SimpleSkin.java

示例11: drawAreasAndSections

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

示例12: drawBackground

import eu.hansolo.medusa.Section; //导入方法依赖的package包/类
private void drawBackground() {
    sectionCanvas.setCache(false);
    sectionCtx.setLineCap(StrokeLineCap.BUTT);
    sectionCtx.clearRect(0, 0, size, size);

    if (gauge.getSectionsVisible() && !sections.isEmpty()) {
        double xy        = 0.012 * size;
        double wh        = size * 0.976;
        double minValue  = gauge.getMinValue();
        double maxValue  = gauge.getMaxValue();
        double angleStep = gauge.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 == gauge.getScaleDirection() ? (section.getStart() - minValue) * angleStep : -(section.getStart() - minValue) * angleStep;
                }
                double sectionAngleExtend;
                if (Double.compare(section.getStop(), maxValue) > 0) {
                    sectionAngleExtend = ScaleDirection.CLOCKWISE == gauge.getScaleDirection() ? (maxValue - section.getStart()) * angleStep : -(maxValue - section.getStart()) * angleStep;
                } else if (Double.compare(section.getStart(), minValue) < 0) {
                    sectionAngleExtend = ScaleDirection.CLOCKWISE == gauge.getScaleDirection() ? (section.getStop() - minValue) * gauge.getAngleStep() : -(section.getStop() - minValue) * angleStep;
                } else {
                    sectionAngleExtend = ScaleDirection.CLOCKWISE == gauge.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);
    barBackground.setStroke(gauge.getBarBackgroundColor());
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:45,代码来源:SimpleSectionSkin.java


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