Java 类javafx.scene.shape.FillRule 实例源码

项目:charts    文件:Path.java   
public void draw(final GraphicsContext CTX, final boolean FILL, final boolean STROKE) {
    PathIterator pi = getPathIterator(new Affine());

    CTX.setFillRule(WindingRule.WIND_EVEN_ODD == pi.getWindingRule() ? FillRule.EVEN_ODD : FillRule.NON_ZERO);
    CTX.beginPath();

    double[] seg = new double[6];
    int      segType;

    while(!pi.isDone()) {
        segType = pi.currentSegment(seg);
        switch (segType) {
            case PathIterator.MOVE_TO  : CTX.moveTo(seg[0], seg[1]); break;
            case PathIterator.LINE_TO  : CTX.lineTo(seg[0], seg[1]); break;
            case PathIterator.QUAD_TO  : CTX.quadraticCurveTo(seg[0], seg[1], seg[2], seg[3]);break;
            case PathIterator.BEZIER_TO: CTX.bezierCurveTo(seg[0], seg[1], seg[2], seg[3], seg[4], seg[5]);break;
            case PathIterator.CLOSE    : CTX.closePath();break;
            default                    : break;
        }
        pi.next();
    }

    if (FILL)   { CTX.setFill(fill); CTX.fill(); }
    if (STROKE) { CTX.setStroke(stroke); CTX.stroke(); }
}
项目:FXImgurUploader    文件:ShapeConverter.java   
private static Path processPath(final List<String> PATH_LIST, final PathReader READER) {
    final Path PATH = new Path();
    PATH.setFillRule(FillRule.EVEN_ODD);
    while (!PATH_LIST.isEmpty()) {
        if ("M".equals(READER.read())) {
            PATH.getElements().add(new MoveTo(READER.nextX(), READER.nextY()));
        } else if ("L".equals(READER.read())) {
            PATH.getElements().add(new LineTo(READER.nextX(), READER.nextY()));
        } else if ("C".equals(READER.read())) {
            PATH.getElements().add(new CubicCurveTo(READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY()));
        } else if ("Q".equals(READER.read())) {
            PATH.getElements().add(new QuadCurveTo(READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY()));
        } else if ("H".equals(READER.read())) {
            PATH.getElements().add(new HLineTo(READER.nextX()));
        } else if ("L".equals(READER.read())) {
            PATH.getElements().add(new VLineTo(READER.nextY()));
        } else if ("A".equals(READER.read())) {
            PATH.getElements().add(new ArcTo(READER.nextX(), READER.nextY(), 0, READER.nextX(), READER.nextY(), false, false));
        } else if ("Z".equals(READER.read())) {
            PATH.getElements().add(new ClosePath());
        }
    }
    return PATH;
}
项目:Enzo    文件:ShapeConverter.java   
private static Path processPath(final List<String> PATH_LIST, final PathReader READER) {
    final Path PATH = new Path();
    PATH.setFillRule(FillRule.EVEN_ODD);
    while (!PATH_LIST.isEmpty()) {
        if ("M".equals(READER.read())) {
            PATH.getElements().add(new MoveTo(READER.nextX(), READER.nextY()));
        } else if ("L".equals(READER.read())) {
            PATH.getElements().add(new LineTo(READER.nextX(), READER.nextY()));
        } else if ("C".equals(READER.read())) {
            PATH.getElements().add(new CubicCurveTo(READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY()));
        } else if ("Q".equals(READER.read())) {
            PATH.getElements().add(new QuadCurveTo(READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY()));
        } else if ("H".equals(READER.read())) {
            PATH.getElements().add(new HLineTo(READER.nextX()));
        } else if ("L".equals(READER.read())) {
            PATH.getElements().add(new VLineTo(READER.nextY()));
        } else if ("A".equals(READER.read())) {
            PATH.getElements().add(new ArcTo(READER.nextX(), READER.nextY(), 0, READER.nextX(), READER.nextY(), false, false));
        } else if ("Z".equals(READER.read())) {
            PATH.getElements().add(new ClosePath());
        }
    }
    return PATH;
}
项目:RadialFx    文件:RadialMenuItem.java   
protected void redraw() {

    if (graphic.get() != null) {
        graphicContainer.getChildren().setAll(graphic.get());
    } else {
        graphicContainer.getChildren().clear();
    }

    path.setFill(backgroundVisible.get() ? (mouseOn
        && backgroundMouseOnFill.get() != null ? backgroundMouseOnFill
        .get() : backgroundFill.get()) : null);
    path.setStroke(strokeVisible.get() ? (mouseOn
        && strokeMouseOnFill.get() != null ? strokeMouseOnFill.get()
        : strokeFill.get()) : null);

    path.setFillRule(FillRule.EVEN_ODD);

    computeCoordinates();

    updateCoordinates();

    }
项目:Medusa    文件:BatterySkin.java   
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    batteryBackground = new Path();
    batteryBackground.setFillRule(FillRule.EVEN_ODD);
    batteryBackground.setStroke(null);

    battery = new Path();
    battery.setFillRule(FillRule.EVEN_ODD);
    battery.setStroke(null);

    valueText = new Text(String.format(locale, "%.0f%%", gauge.getCurrentValue()));
    valueText.setVisible(gauge.isValueVisible());
    valueText.setManaged(gauge.isValueVisible());

    // Add all nodes
    pane = new Pane();
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(1))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));
    pane.getChildren().setAll(batteryBackground, battery, valueText);

    getChildren().setAll(pane);
}
项目:kelvin-maps    文件:Relation.java   
/**
 * Construct a multipolygon from the ways in the relation.
 *
 * @return A multipolygon constructed from the ways of the relation.
 */
private Path multipolygon() {
  Path path = new Path();

  path.setFillRule(FillRule.EVEN_ODD);

  // Don't use antialiasing for performance reasons.
  path.setSmooth(false);

  for (Element element: this.members) {
    if (!(element instanceof Way)) {
      continue;
    }

    Way way = (Way) element;

    for (int i = 0; i < way.nodes().size(); i++) {
      Node node = way.nodes().get(i);

      if (i == 0) {
        path.getElements().add(new MoveTo(node.x(), node.y()));
      }
      else {
        path.getElements().add(new LineTo(node.x(), node.y()));
      }
    }
  }

  path.getStyleClass().add("member");

  return path;
}
项目:JavaFxNodeToSvg    文件:ShapeConverter.java   
private static Path processPath(final List<String> PATH_LIST, final PathReader READER) {
    final Path PATH = new Path();
    PATH.setFillRule(FillRule.EVEN_ODD);
    while (!PATH_LIST.isEmpty()) {
        if ("M".equals(READER.read())) {
            PATH.getElements().add(new MoveTo(READER.nextX(), READER.nextY()));
        } else if ("L".equals(READER.read())) {
            PATH.getElements().add(new LineTo(READER.nextX(), READER.nextY()));
        } else if ("C".equals(READER.read())) {
            PATH.getElements().add(new CubicCurveTo(
                    READER.nextX(),
                    READER.nextY(),
                    READER.nextX(),
                    READER.nextY(),
                    READER.nextX(),
                    READER.nextY()));
        } else if ("Q".equals(READER.read())) {
            PATH.getElements().add(new QuadCurveTo(READER.nextX(), READER.nextY(), READER.nextX(), READER.nextY()));
        } else if ("H".equals(READER.read())) {
            PATH.getElements().add(new HLineTo(READER.nextX()));
        } else if ("L".equals(READER.read())) {
            PATH.getElements().add(new VLineTo(READER.nextY()));
        } else if ("A".equals(READER.read())) {
            PATH.getElements().add(
                    new ArcTo(READER.nextX(), READER.nextY(), 0, READER.nextX(), READER.nextY(), false, false));
        } else if ("Z".equals(READER.read())) {
            PATH.getElements().add(new ClosePath());
        }
    }
    return PATH;
}
项目:HotaruFX    文件:SVGPathNode.java   
public PropertyTimeline<String> fillRuleProperty() {
    return fillRule.setIfEmptyThenGet(enumToString(FillRule.class, svgPath.fillRuleProperty()));
}
项目:Medusa    文件:DBClockSkin.java   
@Override protected void initGraphics() {
    // Set initial size
    if (Double.compare(clock.getPrefWidth(), 0.0) <= 0 || Double.compare(clock.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(clock.getWidth(), 0.0) <= 0 || Double.compare(clock.getHeight(), 0.0) <= 0) {
        if (clock.getPrefWidth() > 0 && clock.getPrefHeight() > 0) {
            clock.setPrefSize(clock.getPrefWidth(), clock.getPrefHeight());
        } else {
            clock.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    sectionsAndAreasCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    sectionsAndAreasCtx    = sectionsAndAreasCanvas.getGraphicsContext2D();

    tickCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    tickCtx    = tickCanvas.getGraphicsContext2D();

    alarmPane = new Pane();

    hour  = new Rectangle(3, 60);
    hour.setArcHeight(3);
    hour.setArcWidth(3);
    hour.setStroke(null);
    hour.setFill(clock.getHourColor());
    hour.getTransforms().setAll(hourRotate);

    minute = new Rectangle(3, 96);
    minute.setArcHeight(3);
    minute.setArcWidth(3);
    minute.setStroke(null);
    minute.setFill(clock.getMinuteColor());
    minute.getTransforms().setAll(minuteRotate);

    second = new Path();
    second.setFillRule(FillRule.EVEN_ODD);
    second.setStroke(null);
    second.setFill(clock.getSecondColor());
    second.getTransforms().setAll(secondRotate);
    enableNode(second, clock.isSecondsVisible());

    dropShadow = new DropShadow();
    dropShadow.setColor(Color.rgb(0, 0, 0, 0.25));
    dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    dropShadow.setRadius(0.015 * PREFERRED_WIDTH);
    dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH);

    knob = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, 4.5);
    knob.setStroke(null);
    knob.setFill(clock.getKnobColor());
    knob.setEffect(dropShadow);

    shadowGroupHour   = new Group(hour);
    shadowGroupMinute = new Group(minute);
    shadowGroupSecond = new Group(second);

    shadowGroupHour.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupMinute.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupSecond.setEffect(clock.getShadowsEnabled() ? dropShadow : null);

    title = new Text("");
    title.setVisible(clock.isTitleVisible());
    title.setManaged(clock.isTitleVisible());

    text = new Text("");
    text.setVisible(clock.isTextVisible());
    text.setManaged(clock.isTextVisible());

    pane = new Pane(sectionsAndAreasCanvas, tickCanvas, alarmPane, title, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond, knob);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY)));

    getChildren().setAll(pane);
}
项目:Medusa    文件:SectionSkin.java   
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    ring = new Path();
    ring.setFillRule(FillRule.EVEN_ODD);
    ring.setStroke(null);
    ring.setFill(Gauge.DARK_COLOR);
    ring.setEffect(new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.35), 1, 0, 0, 1));

    sectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    sectionsCtx    = sectionsCanvas.getGraphicsContext2D();

    mask = new Circle();
    mask.setStroke(null);
    mask.setFill(gauge.getBackgroundPaint());

    knob = new Circle();
    knob.setStroke(null);
    knob.setFill(gauge.getKnobColor());

    angleStep = ANGLE_RANGE / (gauge.getRange());
    double targetAngle = 180 - START_ANGLE + (gauge.getValue() - gauge.getMinValue()) * angleStep;

    needleRotate = new Rotate(180 - START_ANGLE);
    needleRotate.setAngle(Helper.clamp(180 - START_ANGLE, 180 - START_ANGLE + ANGLE_RANGE, targetAngle));

    needle = new Path();
    needle.setFillRule(FillRule.EVEN_ODD);
    needle.setStroke(null);
    needle.getTransforms().setAll(needleRotate);

    valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getMinValue()) + gauge.getUnit());
    valueText.setMouseTransparent(true);
    valueText.setTextOrigin(VPos.CENTER);
    valueText.setFill(gauge.getValueColor());
    Helper.enableNode(valueText, gauge.isValueVisible());

    titleText = new Text(gauge.getTitle());
    titleText.setTextOrigin(VPos.CENTER);
    titleText.setFill(gauge.getTitleColor());
    Helper.enableNode(titleText, !gauge.getTitle().isEmpty());

    // Add all nodes
    pane = new Pane(ring, sectionsCanvas, mask, knob, needle, valueText, titleText);

    getChildren().setAll(pane);
}
项目:Medusa    文件:FatClockSkin.java   
@Override protected void initGraphics() {
    // Set initial size
    if (Double.compare(clock.getPrefWidth(), 0.0) <= 0 || Double.compare(clock.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(clock.getWidth(), 0.0) <= 0 || Double.compare(clock.getHeight(), 0.0) <= 0) {
        if (clock.getPrefWidth() > 0 && clock.getPrefHeight() > 0) {
            clock.setPrefSize(clock.getPrefWidth(), clock.getPrefHeight());
        } else {
            clock.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    sectionsAndAreasCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    sectionsAndAreasCtx    = sectionsAndAreasCanvas.getGraphicsContext2D();

    tickCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    tickCtx    = tickCanvas.getGraphicsContext2D();

    alarmPane = new Pane();

    hour  = new Path();
    hour.setFillRule(FillRule.EVEN_ODD);
    hour.setStroke(null);
    hour.setFill(clock.getHourColor());
    hour.getTransforms().setAll(hourRotate);

    minute = new Path();
    minute.setFillRule(FillRule.EVEN_ODD);
    minute.setStroke(null);
    minute.setFill(clock.getMinuteColor());
    minute.getTransforms().setAll(minuteRotate);

    dropShadow = new DropShadow();
    dropShadow.setColor(Color.rgb(0, 0, 0, 0.25));
    dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    dropShadow.setRadius(0.015 * PREFERRED_WIDTH);
    dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH);

    shadowGroup = new Group(hour, minute);
    shadowGroup.setEffect(clock.getShadowsEnabled() ? dropShadow : null);

    title = new Text("");
    title.setVisible(clock.isTitleVisible());
    title.setManaged(clock.isTitleVisible());

    dateText = new Text("");
    dateText.setVisible(clock.isDateVisible());
    dateText.setManaged(clock.isDateVisible());

    text = new Text("");
    text.setVisible(clock.isTextVisible());
    text.setManaged(clock.isTextVisible());

    pane = new Pane(sectionsAndAreasCanvas, tickCanvas, alarmPane, title, dateText, text, shadowGroup);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY)));

    getChildren().setAll(pane);
}
项目:Medusa    文件:ModernSkin.java   
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();
    }
}
项目:Medusa    文件:SimpleSkin.java   
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    sectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    sectionsCtx    = sectionsCanvas.getGraphicsContext2D();

    needleRotate   = new Rotate(180 - START_ANGLE);

    angleStep          = ANGLE_RANGE / (gauge.getRange());
    double targetAngle = 180 - START_ANGLE + (gauge.getValue() - gauge.getMinValue()) * angleStep;
    needleRotate.setAngle(Helper.clamp(180 - START_ANGLE, 180 - START_ANGLE + ANGLE_RANGE, targetAngle));

    needleMoveTo1       = new MoveTo();
    needleCubicCurveTo2 = new CubicCurveTo();
    needleCubicCurveTo3 = new CubicCurveTo();
    needleCubicCurveTo4 = new CubicCurveTo();
    needleLineTo5       = new LineTo();
    needleLineTo6       = new LineTo();
    needleCubicCurveTo7 = new CubicCurveTo();
    needleClosePath8    = new ClosePath();
    needle              = new Path(needleMoveTo1, needleCubicCurveTo2, needleCubicCurveTo3, needleCubicCurveTo4, needleLineTo5, needleLineTo6, needleCubicCurveTo7, needleClosePath8);
    needle.setFillRule(FillRule.EVEN_ODD);

    needle.getTransforms().setAll(needleRotate);
    needle.setFill(gauge.getNeedleColor());
    needle.setStroke(gauge.getBorderPaint());
    needle.setStrokeLineCap(StrokeLineCap.ROUND);
    needle.setStrokeLineJoin(StrokeLineJoin.BEVEL);

    valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getMinValue()) + gauge.getUnit());
    valueText.setMouseTransparent(true);
    valueText.setTextOrigin(VPos.CENTER);
    valueText.setFill(gauge.getValueColor());
    enableNode(valueText, gauge.isValueVisible());

    titleText = new Text(gauge.getTitle());
    titleText.setTextOrigin(VPos.CENTER);
    titleText.setFill(gauge.getTitleColor());
    enableNode(titleText, !gauge.getTitle().isEmpty());

    subTitleText = new Text(gauge.getSubTitle());
    subTitleText.setTextOrigin(VPos.CENTER);
    subTitleText.setFill(gauge.getSubTitleColor());
    enableNode(subTitleText, !gauge.getSubTitle().isEmpty());

    // Add all nodes
    pane = new Pane(sectionsCanvas, needle, valueText, titleText, subTitleText);

    getChildren().setAll(pane);
}
项目:Medusa    文件:PearClockSkin.java   
@Override protected void initGraphics() {
    // Set initial size
    if (Double.compare(clock.getPrefWidth(), 0.0) <= 0 || Double.compare(clock.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(clock.getWidth(), 0.0) <= 0 || Double.compare(clock.getHeight(), 0.0) <= 0) {
        if (clock.getPrefWidth() > 0 && clock.getPrefHeight() > 0) {
            clock.setPrefSize(clock.getPrefWidth(), clock.getPrefHeight());
        } else {
            clock.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    sectionsAndAreasCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    sectionsAndAreasCtx    = sectionsAndAreasCanvas.getGraphicsContext2D();

    tickCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    tickCtx    = tickCanvas.getGraphicsContext2D();

    alarmPane = new Pane();

    hour  = new Path();
    hour.setFillRule(FillRule.EVEN_ODD);
    hour.setStroke(null);
    hour.getTransforms().setAll(hourRotate);

    minute = new Path();
    minute.setFillRule(FillRule.EVEN_ODD);
    minute.setStroke(null);
    minute.getTransforms().setAll(minuteRotate);

    second = new Path();
    second.setFillRule(FillRule.EVEN_ODD);
    second.setStroke(null);
    second.getTransforms().setAll(secondRotate);
    second.setVisible(clock.isSecondsVisible());
    second.setManaged(clock.isSecondsVisible());

    dropShadow = new DropShadow();
    dropShadow.setColor(Color.rgb(0, 0, 0, 0.25));
    dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    dropShadow.setRadius(0.015 * PREFERRED_WIDTH);
    dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH);

    shadowGroupHour   = new Group(hour);
    shadowGroupMinute = new Group(minute);
    shadowGroupSecond = new Group(second);

    shadowGroupHour.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupMinute.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupSecond.setEffect(clock.getShadowsEnabled() ? dropShadow : null);

    title = new Text("");
    title.setVisible(clock.isTitleVisible());
    title.setManaged(clock.isTitleVisible());

    dateText = new Text("");
    dateText.setVisible(clock.isDateVisible());
    dateText.setManaged(clock.isDateVisible());

    dateNumber = new Text("");
    dateNumber.setVisible(clock.isDateVisible());
    dateNumber.setManaged(clock.isDateVisible());

    text = new Text("");
    text.setVisible(clock.isTextVisible());
    text.setManaged(clock.isTextVisible());

    pane = new Pane(sectionsAndAreasCanvas, tickCanvas, alarmPane, title, dateText, dateNumber, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY)));

    getChildren().setAll(pane);
}
项目:Medusa    文件:KpiSkin.java   
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.696, PREFERRED_WIDTH * 0.275, PREFERRED_WIDTH * 0.275, angleRange * 0.5 + 90, -angleRange);
    barBackground.setType(ArcType.OPEN);
    barBackground.setStroke(gauge.getBarColor());
    barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2);
    barBackground.setStrokeLineCap(StrokeLineCap.BUTT);
    barBackground.setFill(null);

    thresholdBar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.696, PREFERRED_WIDTH * 0.275, PREFERRED_WIDTH * 0.275, -angleRange * 0.5 + 90, 0);
    thresholdBar.setType(ArcType.OPEN);
    thresholdBar.setStroke(gauge.getThresholdColor());
    thresholdBar.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2);
    thresholdBar.setStrokeLineCap(StrokeLineCap.BUTT);
    thresholdBar.setFill(null);

    needleRotate = new Rotate((gauge.getValue() - oldValue - minValue) * angleStep);

    needle = new Path();
    needle.setFillRule(FillRule.EVEN_ODD);
    needle.getTransforms().setAll(needleRotate);
    needle.setFill(gauge.getNeedleColor());
    needle.setStrokeWidth(0);
    needle.setStroke(Color.TRANSPARENT);

    titleText = new Text(gauge.getTitle());
    titleText.setFill(gauge.getTitleColor());
    Helper.enableNode(titleText, !gauge.getTitle().isEmpty());

    valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getCurrentValue()));
    valueText.setFill(gauge.getValueColor());
    Helper.enableNode(valueText, gauge.isValueVisible());

    minValueText = new Text(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getMinValue()));
    minValueText.setFill(gauge.getTitleColor());

    maxValueText = new Text(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getMaxValue()));
    maxValueText.setFill(gauge.getTitleColor());

    thresholdText = new Text(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getThreshold()));
    thresholdText.setFill(gauge.getTitleColor());
    Helper.enableNode(thresholdText, Double.compare(gauge.getThreshold(), gauge.getMinValue()) != 0 && Double.compare(gauge.getThreshold(), gauge.getMaxValue()) != 0);

    pane = new Pane(barBackground, thresholdBar, needle, titleText, valueText, minValueText, maxValueText, thresholdText);
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(gauge.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
项目:Medusa    文件:LevelSkin.java   
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    tube = new Path();
    tube.setFillRule(FillRule.EVEN_ODD);
    tube.setStroke(null);
    Tooltip.install(tube, barTooltip);

    tubeTop = new Ellipse();
    tubeTop.setStroke(Color.rgb(255, 255, 255, 0.5));
    tubeTop.setStrokeType(StrokeType.INSIDE);
    tubeTop.setStrokeWidth(1);

    tubeBottom = new Ellipse();
    tubeBottom.setStroke(null);

    fluidUpperLeft   = new CubicCurveTo(0.21794871794871795 * PREFERRED_WIDTH, 0.24444444444444444 * PREFERRED_HEIGHT,
                                        0.0, 0.18888888888888888 * PREFERRED_HEIGHT,
                                        0.0, 0.12222222222222222 * PREFERRED_HEIGHT);
    fluidUpperCenter = new CubicCurveTo(PREFERRED_WIDTH, 0.18888888888888888 * PREFERRED_HEIGHT,
                                        0.782051282051282 * PREFERRED_WIDTH, 0.24444444444444444 * PREFERRED_HEIGHT,
                                        0.5 * PREFERRED_WIDTH, 0.24444444444444444 * PREFERRED_HEIGHT);
    fluidUpperRight  = new CubicCurveTo(PREFERRED_WIDTH, 0.7111111111111111 * PREFERRED_HEIGHT,
                                        PREFERRED_WIDTH, 0.12222222222222222 * PREFERRED_HEIGHT,
                                        PREFERRED_WIDTH, 0.12222222222222222 * PREFERRED_HEIGHT);

    fluidBody = new Path();
    fluidBody.getElements().add(new MoveTo(0.0, 0.7111111111111111 * PREFERRED_HEIGHT));
    fluidBody.getElements().add(new CubicCurveTo(0.0, 0.7777777777777778 * PREFERRED_HEIGHT,
                                                 0.21794871794871795 * PREFERRED_WIDTH, 0.8333333333333334 * PREFERRED_HEIGHT,
                                                 0.5 * PREFERRED_WIDTH, 0.8333333333333334 * PREFERRED_HEIGHT));
    fluidBody.getElements().add(new CubicCurveTo(0.782051282051282 * PREFERRED_WIDTH, 0.8333333333333334 * PREFERRED_HEIGHT,
                                                 PREFERRED_WIDTH, 0.7777777777777778 * PREFERRED_HEIGHT,
                                                 PREFERRED_WIDTH, 0.7111111111111111 * PREFERRED_HEIGHT));
    fluidBody.getElements().add(fluidUpperRight);
    fluidBody.getElements().add(fluidUpperCenter);
    fluidBody.getElements().add(fluidUpperLeft);
    fluidBody.getElements().add(new CubicCurveTo(0.0, 0.12222222222222222 * PREFERRED_HEIGHT,
                                                 0.0, 0.7111111111111111 * PREFERRED_HEIGHT,
                                                 0.0, 0.7111111111111111 * PREFERRED_HEIGHT));
    fluidBody.getElements().add(new ClosePath());
    fluidBody.setFillRule(FillRule.EVEN_ODD);
    fluidBody.setStroke(null);

    fluidTop = new Ellipse();
    fluidTop.setStroke(null);

    valueText = new Text(String.format(locale, formatString, gauge.getCurrentValue()));
    valueText.setMouseTransparent(true);
    Helper.enableNode(valueText, gauge.isValueVisible());

    titleText = new Text(gauge.getTitle());

    // Add all nodes
    pane = new Pane(tubeBottom, fluidBody, fluidTop, tube, tubeTop, valueText, titleText);
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(gauge.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
项目:Medusa    文件:TinySkin.java   
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.696, PREFERRED_WIDTH * 0.275, PREFERRED_WIDTH * 0.275, ANGLE_RANGE * 0.5 + 90, -ANGLE_RANGE);
    barBackground.setType(ArcType.OPEN);
    barBackground.setStroke(gauge.getBarBackgroundColor());
    barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2);
    barBackground.setStrokeLineCap(StrokeLineCap.BUTT);
    barBackground.setFill(null);

    sectionCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    sectionCtx    = sectionCanvas.getGraphicsContext2D();

    needleRotate = new Rotate((gauge.getValue() - oldValue - minValue) * angleStep);

    needleMoveTo1        = new MoveTo();
    needleCubicCurveTo2  = new CubicCurveTo();
    needleCubicCurveTo3  = new CubicCurveTo();
    needleCubicCurveTo4  = new CubicCurveTo();
    needleCubicCurveTo5  = new CubicCurveTo();
    needleClosePath6     = new ClosePath();
    needleMoveTo7        = new MoveTo();
    needleCubicCurveTo8  = new CubicCurveTo();
    needleCubicCurveTo9  = new CubicCurveTo();
    needleCubicCurveTo10 = new CubicCurveTo();
    needleCubicCurveTo11 = new CubicCurveTo();
    needleClosePath12    = new ClosePath();
    needle = new Path(needleMoveTo1, needleCubicCurveTo2, needleCubicCurveTo3, needleCubicCurveTo4, needleCubicCurveTo5, needleClosePath6,
                      needleMoveTo7, needleCubicCurveTo8, needleCubicCurveTo9, needleCubicCurveTo10, needleCubicCurveTo11, needleClosePath12);
    needle.setFillRule(FillRule.EVEN_ODD);
    needle.getTransforms().setAll(needleRotate);
    needle.setFill(gauge.getNeedleColor());
    needle.setStrokeType(StrokeType.INSIDE);
    needle.setStrokeWidth(1);
    needle.setStroke(gauge.getBackgroundPaint());

    needleTooltip = new Tooltip(String.format(locale, formatString, gauge.getValue()));
    needleTooltip.setTextAlignment(TextAlignment.CENTER);
    Tooltip.install(needle, needleTooltip);

    pane = new Pane(barBackground, sectionCanvas, needle);
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(gauge.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY)));

    getChildren().setAll(pane);
}
项目:Medusa    文件:IndustrialClockSkin.java   
@Override protected void initGraphics() {
    // Set initial size
    if (Double.compare(clock.getPrefWidth(), 0.0) <= 0 || Double.compare(clock.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(clock.getWidth(), 0.0) <= 0 || Double.compare(clock.getHeight(), 0.0) <= 0) {
        if (clock.getPrefWidth() > 0 && clock.getPrefHeight() > 0) {
            clock.setPrefSize(clock.getPrefWidth(), clock.getPrefHeight());
        } else {
            clock.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    sectionsAndAreasCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    sectionsAndAreasCtx    = sectionsAndAreasCanvas.getGraphicsContext2D();

    tickCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    tickCtx    = tickCanvas.getGraphicsContext2D();

    alarmPane = new Pane();

    hour  = new Path();
    hour.setFillRule(FillRule.EVEN_ODD);
    hour.setStroke(null);
    hour.getTransforms().setAll(hourRotate);

    minute = new Path();
    minute.setFillRule(FillRule.EVEN_ODD);
    minute.setStroke(null);
    minute.getTransforms().setAll(minuteRotate);

    second = new Path();
    second.setFillRule(FillRule.EVEN_ODD);
    second.setStroke(null);
    second.getTransforms().setAll(secondRotate);
    second.setVisible(clock.isSecondsVisible());
    second.setManaged(clock.isSecondsVisible());

    centerDot = new Circle();
    centerDot.setFill(Color.WHITE);

    dropShadow = new DropShadow();
    dropShadow.setColor(Color.rgb(0, 0, 0, 0.25));
    dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    dropShadow.setRadius(0.015 * PREFERRED_WIDTH);
    dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH);

    shadowGroupHour   = new Group(hour);
    shadowGroupMinute = new Group(minute);
    shadowGroupSecond = new Group(second);

    shadowGroupHour.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupMinute.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupSecond.setEffect(clock.getShadowsEnabled() ? dropShadow : null);

    title = new Text("");
    title.setVisible(clock.isTitleVisible());
    title.setManaged(clock.isTitleVisible());

    dateText = new Text("");
    dateText.setVisible(clock.isDateVisible());
    dateText.setManaged(clock.isDateVisible());

    dateNumber = new Text("");
    dateNumber.setVisible(clock.isDateVisible());
    dateNumber.setManaged(clock.isDateVisible());

    text = new Text("");
    text.setVisible(clock.isTextVisible());
    text.setManaged(clock.isTextVisible());

    pane = new Pane(sectionsAndAreasCanvas, tickCanvas, alarmPane, title, dateText, dateNumber, text, shadowGroupMinute, shadowGroupHour, shadowGroupSecond, centerDot);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY)));

    getChildren().setAll(pane);
}
项目:Medusa    文件:IndicatorSkin.java   
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.696, PREFERRED_WIDTH * 0.275, PREFERRED_WIDTH * 0.275, angleRange * 0.5 + 90, -angleRange);
    barBackground.setType(ArcType.OPEN);
    barBackground.setStroke(gauge.getBarBackgroundColor());
    barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2);
    barBackground.setStrokeLineCap(StrokeLineCap.BUTT);
    barBackground.setFill(null);

    sectionLayer = new Pane();
    sectionLayer.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));

    bar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.696, PREFERRED_WIDTH * 0.275, PREFERRED_WIDTH * 0.275, angleRange * 0.5 + 90, 0);
    bar.setType(ArcType.OPEN);
    bar.setStroke(gauge.getBarColor());
    bar.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2);
    bar.setStrokeLineCap(StrokeLineCap.BUTT);
    bar.setFill(null);
    //bar.setMouseTransparent(sectionsAlwaysVisible ? true : false);
    bar.setVisible(!sectionsAlwaysVisible);

    needleRotate = new Rotate((gauge.getValue() - oldValue - minValue) * angleStep);

    needleMoveTo1       = new MoveTo();
    needleCubicCurveTo2 = new CubicCurveTo();
    needleCubicCurveTo3 = new CubicCurveTo();
    needleCubicCurveTo4 = new CubicCurveTo();
    needleCubicCurveTo5 = new CubicCurveTo();
    needleCubicCurveTo6 = new CubicCurveTo();
    needleCubicCurveTo7 = new CubicCurveTo();
    needleClosePath8    = new ClosePath();
    needle = new Path(needleMoveTo1, needleCubicCurveTo2, needleCubicCurveTo3, needleCubicCurveTo4, needleCubicCurveTo5, needleCubicCurveTo6, needleCubicCurveTo7, needleClosePath8);
    needle.setFillRule(FillRule.EVEN_ODD);
    needle.getTransforms().setAll(needleRotate);
    needle.setFill(gauge.getNeedleColor());
    needle.setPickOnBounds(false);
    needle.setStrokeType(StrokeType.INSIDE);
    needle.setStrokeWidth(1);
    needle.setStroke(gauge.getBackgroundPaint());

    needleTooltip = new Tooltip(String.format(locale, formatString, gauge.getValue()));
    needleTooltip.setTextAlignment(TextAlignment.CENTER);
    Tooltip.install(needle, needleTooltip);

    minValueText = new Text(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getMinValue()));
    minValueText.setFill(gauge.getTitleColor());
    Helper.enableNode(minValueText, gauge.getTickLabelsVisible());

    maxValueText = new Text(String.format(locale, "%." + gauge.getTickLabelDecimals() + "f", gauge.getMaxValue()));
    maxValueText.setFill(gauge.getTitleColor());
    Helper.enableNode(maxValueText, gauge.getTickLabelsVisible());

    titleText = new Text(gauge.getTitle());
    titleText.setFill(gauge.getTitleColor());
    Helper.enableNode(titleText, !gauge.getTitle().isEmpty());

    if (!sections.isEmpty() && sectionsVisible && !sectionsAlwaysVisible) {
        barTooltip = new Tooltip();
        barTooltip.setTextAlignment(TextAlignment.CENTER);
        Tooltip.install(bar, barTooltip);
    }

    pane = new Pane(barBackground, sectionLayer, bar, needle, minValueText, maxValueText, titleText);
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(gauge.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
项目:Medusa    文件:PlainClockSkin.java   
@Override protected void initGraphics() {
    // Set initial size
    if (Double.compare(clock.getPrefWidth(), 0.0) <= 0 || Double.compare(clock.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(clock.getWidth(), 0.0) <= 0 || Double.compare(clock.getHeight(), 0.0) <= 0) {
        if (clock.getPrefWidth() > 0 && clock.getPrefHeight() > 0) {
            clock.setPrefSize(clock.getPrefWidth(), clock.getPrefHeight());
        } else {
            clock.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    sectionsAndAreasCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    sectionsAndAreasCtx    = sectionsAndAreasCanvas.getGraphicsContext2D();

    tickCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    tickCtx    = tickCanvas.getGraphicsContext2D();

    alarmPane = new Pane();

    hour  = new Path();
    hour.setFillRule(FillRule.EVEN_ODD);
    hour.setStroke(null);
    hour.getTransforms().setAll(hourRotate);

    minute = new Path();
    minute.setFillRule(FillRule.EVEN_ODD);
    minute.setStroke(null);
    minute.getTransforms().setAll(minuteRotate);

    second = new Path();
    second.setFillRule(FillRule.EVEN_ODD);
    second.setStroke(null);
    second.getTransforms().setAll(secondRotate);
    second.setVisible(clock.isSecondsVisible());
    second.setManaged(clock.isSecondsVisible());

    knob = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.0148448);
    knob.setStroke(null);

    dropShadow = new DropShadow();
    dropShadow.setColor(Color.rgb(0, 0, 0, 0.25));
    dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    dropShadow.setRadius(0.015 * PREFERRED_WIDTH);
    dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH);

    shadowGroupHour   = new Group(hour);
    shadowGroupMinute = new Group(minute);
    shadowGroupSecond = new Group(second, knob);

    shadowGroupHour.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupMinute.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupSecond.setEffect(clock.getShadowsEnabled() ? dropShadow : null);

    title = new Text("");
    title.setVisible(clock.isTitleVisible());
    title.setManaged(clock.isTitleVisible());

    dateNumber = new Text("");
    dateNumber.setVisible(clock.isDateVisible());
    dateNumber.setManaged(clock.isDateVisible());

    text = new Text("");
    text.setVisible(clock.isTextVisible());
    text.setManaged(clock.isTextVisible());

    pane = new Pane(sectionsAndAreasCanvas, tickCanvas, alarmPane, title, dateNumber, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY)));

    getChildren().setAll(pane);
}
项目:Medusa    文件:TileClockSkin.java   
@Override protected void initGraphics() {
    // Set initial size
    if (Double.compare(clock.getPrefWidth(), 0.0) <= 0 || Double.compare(clock.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(clock.getWidth(), 0.0) <= 0 || Double.compare(clock.getHeight(), 0.0) <= 0) {
        if (clock.getPrefWidth() > 0 && clock.getPrefHeight() > 0) {
            clock.setPrefSize(clock.getPrefWidth(), clock.getPrefHeight());
        } else {
            clock.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    minuteTickMarks = new Path();
    minuteTickMarks.setFillRule(FillRule.EVEN_ODD);
    minuteTickMarks.setFill(null);
    minuteTickMarks.setStroke(clock.getMinuteColor());
    minuteTickMarks.setStrokeLineCap(StrokeLineCap.ROUND);

    hourTickMarks = new Path();
    hourTickMarks.setFillRule(FillRule.EVEN_ODD);
    hourTickMarks.setFill(null);
    hourTickMarks.setStroke(clock.getHourColor());
    hourTickMarks.setStrokeLineCap(StrokeLineCap.ROUND);

    hour = new Rectangle(3, 60);
    hour.setArcHeight(3);
    hour.setArcWidth(3);
    hour.setStroke(clock.getHourColor());
    hour.getTransforms().setAll(hourRotate);

    minute = new Rectangle(3, 96);
    minute.setArcHeight(3);
    minute.setArcWidth(3);
    minute.setStroke(clock.getMinuteColor());
    minute.getTransforms().setAll(minuteRotate);

    second = new Rectangle(1, 96);
    second.setArcHeight(1);
    second.setArcWidth(1);
    second.setStroke(clock.getSecondColor());
    second.getTransforms().setAll(secondRotate);
    second.setVisible(clock.isSecondsVisible());
    second.setManaged(clock.isSecondsVisible());

    knob = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, 4.5);
    knob.setStroke(Color.web("#282a3280"));

    dropShadow = new DropShadow();
    dropShadow.setColor(Color.rgb(0, 0, 0, 0.25));
    dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    dropShadow.setRadius(0.015 * PREFERRED_WIDTH);
    dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH);

    shadowGroupHour   = new Group(hour);
    shadowGroupMinute = new Group(minute);
    shadowGroupSecond = new Group(second, knob);

    shadowGroupHour.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupMinute.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupSecond.setEffect(clock.getShadowsEnabled() ? dropShadow : null);

    title = new Text("");
    title.setTextOrigin(VPos.TOP);
    Helper.enableNode(title, clock.isTitleVisible());

    amPmText = new Text(clock.getTime().get(ChronoField.AMPM_OF_DAY) == 0 ? "AM" : "PM");

    dateText = new Text("");
    Helper.enableNode(dateText, clock.isDateVisible());

    text = new Text("");
    Helper.enableNode(text, clock.isTextVisible());

    pane = new Pane(hourTickMarks, minuteTickMarks, title, amPmText, dateText, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(PREFERRED_WIDTH * 0.025), new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(PREFERRED_WIDTH * 0.025), Insets.EMPTY)));

    getChildren().setAll(pane);
}
项目:LifeTiles    文件:SunburstRingSegment.java   
/**
 * Creates a semi-circle with in the specified location.
 *
 * layer starts at 0
 *
 * @param layer
 *            The layer to place this element at, the first child of root is
 *            layer 0.
 * @param angle
 *            The start and end points of this ring
 * @param center
 *            the coordinates of the center of the circle
 * @param scale
 *            the scaling factor
 * @return a semi-circle with the specified dimensions
 */
private Shape createRing(final int layer, final DegreeRange angle,
        final Point2D center, final double scale) {

    Path result = new Path();

    result.setFill(createColor(angle.getStartAngle(), layer));
    result.setFillRule(FillRule.EVEN_ODD);

    // check if this is a large arc
    boolean largeArc = angle.angle() > AbstractSunburstNode.CIRCLEDEGREES / 2;

    // calculate the radii of the two arcs
    double innerRadius = scale * (CENTER_RADIUS + (layer * RING_WIDTH));
    double outerRadius = innerRadius + scale * RING_WIDTH;

    // convert degrees to radians for Math.sin and Math.cos
    double angleAlpha = Math.toRadians(angle.getStartAngle());
    double angleAlphaNext = Math.toRadians(angle.getEndAngle());

    // draw the semi-circle
    // first go to the start point
    double startX = center.getX() + innerRadius * Math.sin(angleAlpha);
    double startY = center.getY() - innerRadius * Math.cos(angleAlpha);
    MoveTo move1 = new MoveTo(startX, startY);

    // draw a line from point 1 to point 2
    LineTo line1To2 = createLine(outerRadius, center, angleAlpha);

    // draw an arc from point 2 to point 3
    ArcTo arc2To3 = createArc(outerRadius, center, angleAlphaNext, true,
            largeArc);

    // draw a line from point 3 to point 4
    LineTo line3To4 = createLine(innerRadius, center, angleAlphaNext);

    // draw an arc from point 4 back to point 1
    ArcTo arc4To1 = createArc(innerRadius, center, angleAlpha, false,
            largeArc);

    // add all elements to the path
    result.getElements()
            .addAll(move1, line1To2, arc2To3, line3To4, arc4To1);

    return result;
}
项目:FXImgurUploader    文件:SimpleGaugeSkin.java   
private void initGraphics() {
    Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.06 * PREFERRED_HEIGHT)); // "OpenSans"

    sectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    sectionsCtx    = sectionsCanvas.getGraphicsContext2D();

    measuredRangeCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    measuredRangeCanvas.setManaged(getSkinnable().isMeasuredRangeVisible());
    measuredRangeCanvas.setVisible(getSkinnable().isMeasuredRangeVisible());
    measuredRangeCtx    = measuredRangeCanvas.getGraphicsContext2D();        

    if (getSkinnable().getValue() < getSkinnable().getMinValue()) getSkinnable().setValue(getSkinnable().getMinValue());
    if (getSkinnable().getValue() > getSkinnable().getMaxValue()) getSkinnable().setValue(getSkinnable().getMaxValue());

    needleRotate = new Rotate(180 - getSkinnable().getStartAngle());
    if (getSkinnable().getMinValue() < 0) {
        needleRotate.setAngle(needleRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue() - getSkinnable().getMinValue()) * angleStep);
    } else {
        //needleRotate.setAngle(needleRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue() + getSkinnable().getMinValue()) * angleStep);
    }

    angleStep = getSkinnable().getAngleRange() / (getSkinnable().getMaxValue() - getSkinnable().getMinValue());
    needleRotate.setAngle(needleRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue()) * angleStep);

    needle = new Path();
    needle.setFillRule(FillRule.EVEN_ODD);
    needle.getStyleClass().setAll("needle");
    needle.getTransforms().setAll(needleRotate);       

    value = new Text(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMinValue()) + getSkinnable().getUnit());
    value.setMouseTransparent(true);
    value.setTextOrigin(VPos.CENTER);
    value.getStyleClass().setAll("value");

    title = new Text(getSkinnable().getTitle());
    title.setTextOrigin(VPos.CENTER);
    title.getStyleClass().setAll("title");

    // Add all nodes
    pane = new Pane();
    pane.getStyleClass().add("simple-gauge");
    pane.getChildren().setAll(sectionsCanvas,
                              measuredRangeCanvas,
                              needle,
                              value,
                              title);

    getChildren().setAll(pane);
    resize();
}
项目:Enzo    文件:SimpleGaugeSkin.java   
private void initGraphics() {
    Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.06 * PREFERRED_HEIGHT)); // "OpenSans"

    sectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    sectionsCtx    = sectionsCanvas.getGraphicsContext2D();

    measuredRangeCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    measuredRangeCanvas.setManaged(getSkinnable().isMeasuredRangeVisible());
    measuredRangeCanvas.setVisible(getSkinnable().isMeasuredRangeVisible());
    measuredRangeCtx    = measuredRangeCanvas.getGraphicsContext2D();        

    if (getSkinnable().getValue() < getSkinnable().getMinValue()) getSkinnable().setValue(getSkinnable().getMinValue());
    if (getSkinnable().getValue() > getSkinnable().getMaxValue()) getSkinnable().setValue(getSkinnable().getMaxValue());

    needleRotate = new Rotate(180 - getSkinnable().getStartAngle());
    if (getSkinnable().getMinValue() < 0) {
        needleRotate.setAngle(needleRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue() - getSkinnable().getMinValue()) * angleStep);
    } else {
        //needleRotate.setAngle(needleRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue() + getSkinnable().getMinValue()) * angleStep);
    }

    angleStep = getSkinnable().getAngleRange() / (getSkinnable().getMaxValue() - getSkinnable().getMinValue());
    needleRotate.setAngle(needleRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue()) * angleStep);

    needle = new Path();
    needle.setFillRule(FillRule.EVEN_ODD);
    needle.getStyleClass().setAll("needle");
    needle.getTransforms().setAll(needleRotate);       

    value = new Text(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMinValue()) + getSkinnable().getUnit());
    value.setMouseTransparent(true);
    value.setTextOrigin(VPos.CENTER);
    value.getStyleClass().setAll("value");

    title = new Text(getSkinnable().getTitle());
    title.setTextOrigin(VPos.CENTER);
    title.getStyleClass().setAll("title");

    // Add all nodes
    pane = new Pane();
    pane.getStyleClass().add("simple-gauge");
    pane.getChildren().setAll(sectionsCanvas,
                              measuredRangeCanvas,
                              needle,
                              value,
                              title);

    getChildren().setAll(pane);
    resize();
}
项目:afc    文件:AbstractMapPolygonDrawer.java   
/** Draw the polygon path.
 *
 * @param gc the graphics context that must be used for drawing.
 * @param element the map element.
 */
protected void definePath(ZoomableGraphicsContext gc, T element) {
    gc.beginPath();
    final PathIterator2afp<PathElement2d> pathIterator = element.toPath2D().getPathIterator();
    switch (pathIterator.getWindingRule()) {
    case EVEN_ODD:
        gc.setFillRule(FillRule.EVEN_ODD);
        break;
    case NON_ZERO:
        gc.setFillRule(FillRule.NON_ZERO);
        break;
    default:
        throw new IllegalStateException();
    }
    while (pathIterator.hasNext()) {
        final PathElement2d pelement = pathIterator.next();
        switch (pelement.getType()) {
        case LINE_TO:
            gc.lineTo(pelement.getToX(), pelement.getToY());
            break;
        case MOVE_TO:
            gc.moveTo(pelement.getToX(), pelement.getToY());
            break;
        case CLOSE:
            gc.closePath();
            break;
        case CURVE_TO:
            gc.bezierCurveTo(
                    pelement.getCtrlX1(), pelement.getCtrlY1(),
                    pelement.getCtrlX2(), pelement.getCtrlY2(),
                    pelement.getToX(), pelement.getToY());
            break;
        case QUAD_TO:
            gc.quadraticCurveTo(
                    pelement.getCtrlX1(), pelement.getCtrlY1(),
                    pelement.getToX(), pelement.getToY());
            break;
        case ARC_TO:
            //TODO: implements arcTo
            gc.lineTo(pelement.getToX(), pelement.getToY());
            break;
        default:
            break;
        }
    }
}
项目:afc    文件:AbstractMapPolylineDrawer.java   
/** Draw the polyline path.
 *
 * @param gc the graphics context that must be used for drawing.
 * @param element the map element.
 */
protected void definePath(ZoomableGraphicsContext gc, T element) {
    gc.beginPath();
    final PathIterator2afp<PathElement2d> pathIterator = element.toPath2D().getPathIterator();
    switch (pathIterator.getWindingRule()) {
    case EVEN_ODD:
        gc.setFillRule(FillRule.EVEN_ODD);
        break;
    case NON_ZERO:
        gc.setFillRule(FillRule.NON_ZERO);
        break;
    default:
        throw new IllegalStateException();
    }
    while (pathIterator.hasNext()) {
        final PathElement2d pelement = pathIterator.next();
        switch (pelement.getType()) {
        case LINE_TO:
            gc.lineTo(pelement.getToX(), pelement.getToY());
            break;
        case MOVE_TO:
            gc.moveTo(pelement.getToX(), pelement.getToY());
            break;
        case CLOSE:
            gc.closePath();
            break;
        case CURVE_TO:
            gc.bezierCurveTo(
                    pelement.getCtrlX1(), pelement.getCtrlY1(),
                    pelement.getCtrlX2(), pelement.getCtrlY2(),
                    pelement.getToX(), pelement.getToY());
            break;
        case QUAD_TO:
            gc.quadraticCurveTo(
                    pelement.getCtrlX1(), pelement.getCtrlY1(),
                    pelement.getToX(), pelement.getToY());
            break;
        case ARC_TO:
            //TODO: implements arcTo
            gc.lineTo(pelement.getToX(), pelement.getToY());
            break;
        default:
            break;
        }
    }
}
项目:RadialMenuFX    文件:RadialMenu.java   
/**
    * computes the circular ring segments specified by segmentCount 
    * through translation of vector coordinates into local coordinate-space at
    * application runtime <br>
    * Each segment and its associated symbol will be added to a 
    * group-node which will be put into an ObservableList of type Group: segments <br>
    * @see {@link segments}, {@link getSegments}, {@link setSegments}
    */
   private void createOuterCircleSegments()
   {
double segmentRadians = 360/segmentCount*Math.PI/180;

for(int i = 2; i <= segmentCount+1; i++)
{
    Group g = new Group();

    Path p = new Path();
    p.setFill(fillColor);
    p.setStroke(strokeColor);
    p.setFillRule(FillRule.EVEN_ODD);

    MoveTo firstPoint = new MoveTo();
    firstPoint.setX(centerX + innerRadius*Math.cos(segmentRadians*(i-1)));
    firstPoint.setY(centerY + innerRadius*Math.sin(segmentRadians*(i-1)));

    p.getElements().add(firstPoint);

    LineTo nextLine = new LineTo();
    nextLine.setX(centerX + outerRadius*Math.cos(segmentRadians*(i-1)));
    nextLine.setY(centerY + outerRadius*Math.sin(segmentRadians*(i-1)));

    ArcTo outerArc = new ArcTo();
    outerArc.setSweepFlag(true);
    outerArc.setAbsolute(true);
    outerArc.setX(centerX + outerRadius*Math.cos(2*Math.PI + segmentRadians*i));
    outerArc.setY(centerY + outerRadius*Math.sin(2*Math.PI + segmentRadians*i));
    outerArc.setRadiusX(outerRadius);
    outerArc.setRadiusY(outerRadius);

    LineTo line2 = new LineTo();
    line2.setX(centerX + innerRadius*Math.cos(segmentRadians*(i)));
    line2.setY(centerY + innerRadius*Math.sin(segmentRadians*(i)));

    ArcTo innerArc = new ArcTo();
    innerArc.setSweepFlag(false);
    innerArc.setAbsolute(true);
    innerArc.setX(centerX + innerRadius*Math.cos(2*Math.PI + segmentRadians*(i-1)));
    innerArc.setY(centerY + innerRadius*Math.sin(2*Math.PI + segmentRadians*(i-1)));
    innerArc.setRadiusX(innerRadius);
    innerArc.setRadiusY(innerRadius);

    MoveTo end = new MoveTo();
    end.setX(centerX + innerRadius*Math.cos(segmentRadians*(i)));
    end.setY(centerY + innerRadius*Math.sin(segmentRadians*(i)));

    p.getElements().add(nextLine);
    p.getElements().add(outerArc);
    p.getElements().add(line2);
    p.getElements().add(innerArc);
    p.getElements().add(end);

    g.getChildren().add(p);


    // temporary: for button layout injection
    Rectangle rect = new Rectangle();
    rect.setX(centerX-((outerRadius-innerRadius)*0.35) + (innerRadius + (outerRadius - innerRadius)/2)*Math.cos(segmentRadians*(i-.5)));
    rect.setY(centerY-((outerRadius-innerRadius)*0.35) + (innerRadius + (outerRadius - innerRadius)/2)*Math.sin(segmentRadians*(i-.5)));
    rect.setWidth(((outerRadius-innerRadius)*0.7));
    rect.setHeight(((outerRadius-innerRadius)*0.7));
    rect.setRotate(Math.toDegrees(segmentRadians*(i-.5)));
    rect.setFill(Color.RED);

    g.getChildren().add(rect);

    segments.add(g);
}

   }
项目:afc    文件:ZoomableGraphicsContext.java   
/**
 * Set the filling rule attribute for determining the interior of paths
 * in fill or clip operations.
 * The default value is {@code FillRule.NON_ZERO}.
 * A {@code null} value will be ignored and the current value will remain unchanged.
 * The fill rule is a path attribute
 * used for any of the fill or clip path methods as specified in the
 * Rendering Attributes Table of {@link GraphicsContext}.
 *
 * @param fillRule {@code FillRule} with a value of  Even_odd or Non_zero or null.
 */
public void setFillRule(FillRule fillRule) {
    this.gc.setFillRule(fillRule);
}
项目:afc    文件:ZoomableGraphicsContext.java   
/**
 * Get the filling rule attribute for determining the interior of paths
 * in fill and clip operations.
 * The default value is {@code FillRule.NON_ZERO}.
 * The fill rule is a path attribute
 * used for any of the fill or clip path methods as specified in the
 * Rendering Attributes Table of {@link GraphicsContext}.
 *
 * @return current fill rule.
 */
public FillRule getFillRule() {
    return this.gc.getFillRule();
}