javafx.scene.shape.ArcType Java Examples

The following examples show how to use javafx.scene.shape.ArcType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleGaugeSkin.java    From Enzo with Apache License 2.0 6 votes vote down vote up
private final void drawMeasuredRange() {        
    final double MIN_VALUE    = getSkinnable().getMinValue();        
    final double OFFSET       = getSkinnable().getStartAngle() - 90;
    final double START_ANGLE  = (getSkinnable().getMinMeasuredValue() - MIN_VALUE) * angleStep;
    final double ANGLE_EXTEND = (getSkinnable().getMaxMeasuredValue() - getSkinnable().getMinMeasuredValue()) * angleStep;
    final double RANGE_OFFSET = size * 0.015;
    final double RANGE_SIZE   = size - (size * 0.03);        
    
    measuredRangeCtx.save();
    measuredRangeCtx.clearRect(0, 0, size, size);
    measuredRangeCtx.setFill(getSkinnable().getRangeFill());
    measuredRangeCtx.fillArc(RANGE_OFFSET, RANGE_OFFSET, RANGE_SIZE, RANGE_SIZE, (OFFSET - START_ANGLE), -ANGLE_EXTEND, ArcType.ROUND);
    measuredRangeCtx.setStroke(Color.WHITE);
    measuredRangeCtx.setLineWidth(size * 0.032);
    measuredRangeCtx.strokeArc(RANGE_OFFSET, RANGE_OFFSET, RANGE_SIZE, RANGE_SIZE, (OFFSET - START_ANGLE), -ANGLE_EXTEND, ArcType.ROUND);
    measuredRangeCtx.restore();
}
 
Example #2
Source File: TinySkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
private void drawGradientBar() {
    double             xy           = size * 0.1875;
    double             wh           = size * 0.625;
    double             offset       = -ANGLE_RANGE * 0.5 - 90;
    double             startAngle   = 315;
    List<Stop>         stops        = gauge.getGradientBarStops();
    Map<Double, Color> stopAngleMap = new HashMap<>(stops.size());
    for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * ANGLE_RANGE, stop.getColor()); }
    double               offsetFactor = startAngle - 90;
    AngleConicalGradient gradient     = new AngleConicalGradient(size * 0.5, size * 0.5, offsetFactor, stopAngleMap, ScaleDirection.CLOCKWISE);

    double barStartAngle  = 0;
    double barAngleExtend = 270;
    sectionCtx.save();
    sectionCtx.setStroke(gradient.getImagePattern(new Rectangle(xy - 0.09191176 * size, xy - 0.09191176 * size, wh + 0.18382353 * size, wh + 0.18382353 * size)));
    sectionCtx.setLineWidth(size * 0.18382353);
    sectionCtx.setLineCap(StrokeLineCap.BUTT);
    sectionCtx.strokeArc(xy, xy, wh, wh, -(offset + barStartAngle), -barAngleExtend, ArcType.OPEN);
    sectionCtx.restore();    
}
 
Example #3
Source File: IndicatorSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: VSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
private void drawGradientBar() {
    TickLabelLocation  tickLabelLocation     = gauge.getTickLabelLocation();
    double             scaledHeight          = height * 0.9;
    double             xy                    = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.1705 * scaledHeight : 0.107 * scaledHeight;
    double             wh                    = TickLabelLocation.OUTSIDE == tickLabelLocation ? scaledHeight * 0.77 : scaledHeight * 0.897;
    double             offset                = 90 - startAngle;
    double             offsetX               = -0.1 * width;
    double             knobPositionOffsetCW  = Pos.CENTER_LEFT == gauge.getKnobPosition() ? 90 : 270;
    double             knobPositionOffsetCCW = Pos.CENTER_LEFT == gauge.getKnobPosition() ? 180 : 0;
    ScaleDirection     scaleDirection        = gauge.getScaleDirection();
    List<Stop>         stops                 = gauge.getGradientBarStops();
    Map<Double, Color> stopAngleMap          = new HashMap<>(stops.size());
    for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * angleRange, stop.getColor()); }
    double               offsetFactor = ScaleDirection.CLOCKWISE == scaleDirection ? knobPositionOffsetCW - angleRange * 0.5 : angleRange - (angleRange / 180 * angleRange) + knobPositionOffsetCCW;
    AngleConicalGradient gradient     = new AngleConicalGradient(width * 0.5, width * 0.5, offsetFactor, stopAngleMap, gauge.getScaleDirection());

    double barStartAngle  = ScaleDirection.CLOCKWISE == scaleDirection ? -minValue * angleStep : minValue * angleStep;
    double barAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? gauge.getRange() * angleStep : -gauge.getRange() * angleStep;
    tickMarkCtx.save();
    tickMarkCtx.setStroke(gradient.getImagePattern(new Rectangle(xy - 0.026 * height + offsetX, xy - 0.026 * height, wh + 0.052 * height, wh + 0.052 * height)));
    tickMarkCtx.setLineWidth(scaledHeight * 0.052);
    tickMarkCtx.setLineCap(StrokeLineCap.BUTT);
    tickMarkCtx.strokeArc(xy + offsetX, xy, wh, wh, -(offset + barStartAngle), -barAngleExtend, ArcType.OPEN);
    tickMarkCtx.restore();
}
 
Example #5
Source File: RoundLcdClockSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
private void drawSeconds(final ZonedDateTime TIME) {
    int secCounter  = 1;
    double strokeWidth = size * 0.06;
    secondsCtx.setLineCap(StrokeLineCap.BUTT);
    secondsCtx.clearRect(0, 0, size, size);
    for (int i = 450 ; i >= 90 ; i--) {
        secondsCtx.save();
        if (i % 6 == 0) {
            // draw seconds
            if (secCounter <= TIME.getSecond() + 1) {
                secondsCtx.setStroke(secondColor);
                secondsCtx.setLineWidth(strokeWidth * 0.25);
                secondsCtx.strokeArc(strokeWidth * 0.5 + strokeWidth * 1.8, strokeWidth * 0.5 + strokeWidth * 1.8, size - strokeWidth - strokeWidth * 3.6, size - strokeWidth - strokeWidth * 3.6, i + 1 - 6, 4, ArcType.OPEN);
                secCounter++;
            }
        }
        secondsCtx.restore();
    }
}
 
Example #6
Source File: RoundLcdClockSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
private void drawMinutes(final ZonedDateTime TIME) {
    int minCounter  = 1;
    double strokeWidth = size * 0.06;
    minutesCtx.clearRect(0, 0, size, size);
    minutesCtx.setLineCap(StrokeLineCap.BUTT);
    for (int i = 450 ; i >= 90 ; i--) {
        minutesCtx.save();
        if (i % 6 == 0) {
            // draw minutes
            if (minCounter <= TIME.getMinute()) {
                minutesCtx.setStroke(minCounter % 5 == 0 ? fiveMinuteColor : minuteColor);
                minutesCtx.setLineWidth(strokeWidth);
                minutesCtx.strokeArc(strokeWidth * 0.5 + strokeWidth * 1.1, strokeWidth * 0.5 + strokeWidth * 1.1, size - strokeWidth - strokeWidth * 2.2, size - strokeWidth - strokeWidth * 2.2, i + 1 - 6, 4, ArcType.OPEN);
                minCounter++;
            }
        }
        minutesCtx.restore();
    }
}
 
Example #7
Source File: HSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
private void drawGradientBar() {
    double     scaledWidth = width * 0.9;
    double     xy          = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.1705 * scaledWidth : 0.107 * scaledWidth;
    double     wh          = TickLabelLocation.OUTSIDE == tickLabelLocation ? scaledWidth * 0.77 : scaledWidth * 0.897;
    double     offsetY     = -0.1 * height;
    double     offset      = 90 - startAngle;
    List<Stop> stops       = gauge.getGradientBarStops();
    Map<Double, Color> stopAngleMap = new HashMap<>(stops.size());
    for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * angleRange, stop.getColor()); }
    double               offsetFactor = ScaleDirection.CLOCKWISE == scaleDirection ? startAngle - angleRange + 180 : (startAngle + 180);
    AngleConicalGradient gradient     = new AngleConicalGradient(width * 0.5, width * 0.5, offsetFactor, stopAngleMap, gauge.getScaleDirection());

    double barStartAngle  = ScaleDirection.CLOCKWISE == scaleDirection ? -minValue * angleStep : minValue * angleStep;
    double barAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? gauge.getRange() * angleStep : -gauge.getRange() * angleStep;
    tickMarkCtx.save();
    tickMarkCtx.setStroke(gradient.getImagePattern(new Rectangle(xy - 0.026 * width, xy - 0.026 * width + offsetY, wh + 0.052 * width, wh + 0.052 * width)));
    tickMarkCtx.setLineWidth(scaledWidth * 0.052);
    tickMarkCtx.setLineCap(StrokeLineCap.BUTT);
    tickMarkCtx.strokeArc(xy, xy + offsetY, wh, wh, -(offset + barStartAngle), -barAngleExtend, ArcType.OPEN);
    tickMarkCtx.restore();
}
 
Example #8
Source File: ImagePanel.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
private void drawGraphics() {
    graphics.clearRect(0, 0, canvas.getWidth(), canvas.getHeight());
    graphics.drawImage(image, 0, 0);
    if (annotations.size() > 0) {
        for (int i = 0; i < annotations.size(); i++) {
            Annotation annotationFX = annotations.get(i);
            double x = annotationFX.getX();
            double y = annotationFX.getY();
            graphics.setFill(ANNOTATION_COLOR);
            graphics.fillRect(x, y, annotationFX.getWidth(), annotationFX.getHeight());
            graphics.setFill(Color.RED);
            graphics.fillArc(x - 25, y - 25, 50, 50, 270, 90, ArcType.ROUND);
            graphics.setFill(Color.WHITE);
            graphics.setFont(Font.font(null, FontWeight.EXTRA_BOLD, 14));
            if (i > 8) {
                graphics.fillText(Integer.toString(i + 1), x + 5, y + 15);
            } else {
                graphics.fillText(Integer.toString(i + 1), x + 5, y + 15);
            }
        }
    }
}
 
Example #9
Source File: CenterArc.java    From CrazyAlpha with GNU General Public License v2.0 6 votes vote down vote up
public CenterArc() {
    fillColor = Color.color(Math.random(), Math.random(), Math.random());
    strokeColor = Color.YELLOW;
    width = 120;
    height = 120;
    x = (Game.getInstance().getRender().getWidth() - width) / 2;
    y = (Game.getInstance().getRender().getHeight() - height) / 2;
    for (int i = 0; i < 4; i++) {
        Arc arc = new Arc(x, y, width, height, i * 90, 30);
        arc.setType(ArcType.ROUND);
        shapes.add(arc);
    }
    effect = new GaussianBlur();

    start();
}
 
Example #10
Source File: StateTransitionEdgeViewer.java    From JetUML with GNU General Public License v3.0 6 votes vote down vote up
private Shape getSelfEdgeShape(Edge pEdge)
{
	Line line = getSelfEdgeConnectionPoints(pEdge);
	Arc arc = new Arc();
	arc.setRadiusX(SELF_EDGE_OFFSET*2);
	arc.setRadiusY(SELF_EDGE_OFFSET*2);
	arc.setLength(DEGREES_270);
	arc.setType(ArcType.OPEN);
	if( getPosition(pEdge) == 1 )
	{
		arc.setCenterX(line.getX1());
		arc.setCenterY(line.getY1()-SELF_EDGE_OFFSET);
		arc.setStartAngle(DEGREES_270);
	}
	else
	{		
		arc.setCenterX(line.getX1()-SELF_EDGE_OFFSET);
		arc.setCenterY(line.getY1()-SELF_EDGE_OFFSET*2);
		arc.setStartAngle(1);
	}
	return arc;
}
 
Example #11
Source File: FanPane.java    From Intro-to-Java-Programming with MIT License 6 votes vote down vote up
/** Add four arcs to a pane and place them in a stack pane */
private void getBlades() {
	double angle = 0;
	for (int i = 0; i < 4; i++) {
		arc = new Arc(); 
		arc.centerXProperty().bind(widthProperty().divide(2));
		arc.centerYProperty().bind(heightProperty().divide(2));
		arc.radiusXProperty().bind(circle.radiusProperty().multiply(.90));
		arc.radiusYProperty().bind(circle.radiusProperty().multiply(.90));
		arc.setStartAngle(angle + 90);
		arc.setLength(50);
		arc.setFill(Color.BLACK);
		arc.setType(ArcType.ROUND);
		paneForBlades.getChildren().add(arc);
		angle += 90;
	}
}
 
Example #12
Source File: RotationEffect.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
private void redraw() {
    ctx.clearRect(0, 0, width, height);
    boolean toggle = true;
    double x = -width - width * 0.5 + width * getCenterX();
    double y = -height - height * 0.5 + height * getCenterY();
    double w = 3 * width;
    double h = 3 * height;
    for (int i = 0 ; i < 360 ; i += 15) {
        ctx.setFill(toggle ? gradient : Color.TRANSPARENT);
        ctx.fillArc(x, y, w, h, -(i + angle), 15, ArcType.ROUND);
        toggle ^= true;
    }
    angle += 2;
    if (angle > 360) {
        angle = 0;
    }
}
 
Example #13
Source File: XorGatePeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void paintGate(GraphicsContext graphics, CircuitState circuitState) {
	int x = getScreenX();
	int y = getScreenY();
	int width = 4 * GuiUtils.BLOCK_SIZE;
	int height = 4 * GuiUtils.BLOCK_SIZE;
	
	graphics.beginPath();
	graphics.moveTo(x + width * 0.1, y + height);
	graphics.arc(x + width * 0.1, y + height * 0.5, width * 0.25, height * 0.5, 270, 180);
	graphics.arcTo(x + width * 0.66, y, x + width * 1.25, y + height, width);
	graphics.arcTo(x + width * 0.66, y + height, x + width * 0.1, y + height, width);
	graphics.closePath();
	
	graphics.setFill(Color.WHITE);
	graphics.setStroke(Color.BLACK);
	graphics.fill();
	graphics.stroke();
	
	graphics.strokeArc(x - width * 0.3, y, width * 0.5, height, 270, 180, ArcType.OPEN);
}
 
Example #14
Source File: InteractiveGaugeSkin.java    From medusademo with Apache License 2.0 6 votes vote down vote up
private void drawGradientBar() {
    double     xy     = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.115 * size : 0.0515 * size;
    double     wh     = TickLabelLocation.OUTSIDE == tickLabelLocation ? size * 0.77 : size * 0.897;
    double     offset = 90 - startAngle;
    List<Stop> stops  = getSkinnable().getGradientBarStops();
    Map<Double, Color> stopAngleMap     = new HashMap<>(stops.size());
    for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * angleRange, stop.getColor()); }
    double                  offsetFactor        = ScaleDirection.CLOCKWISE == scaleDirection ? (startAngle - 90) : (startAngle + 180);
    AngleConicalGradient    gradient            = new AngleConicalGradient(size * 0.5, size * 0.5, offsetFactor, stopAngleMap, getSkinnable().getScaleDirection());

    double barStartAngle  = ScaleDirection.CLOCKWISE == scaleDirection ? -minValue * angleStep : minValue * angleStep;
    double barAngleExtend = ScaleDirection.CLOCKWISE == scaleDirection ? getSkinnable().getRange() * angleStep : -getSkinnable().getRange() * angleStep;
    tickMarkCtx.save();
    tickMarkCtx.setStroke(gradient.getImagePattern(new Rectangle(xy - 0.026 * size, xy - 0.026 * size, wh + 0.052 * size, wh + 0.052 * size)));
    tickMarkCtx.setLineWidth(size * 0.052);
    tickMarkCtx.setLineCap(StrokeLineCap.BUTT);
    tickMarkCtx.strokeArc(xy, xy, wh, wh, -(offset + barStartAngle), -barAngleExtend, ArcType.OPEN);
    tickMarkCtx.restore();
}
 
Example #15
Source File: PieSkin.java    From WorkbenchFX with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeParts() {
  double center = ARTBOARD_HEIGHT * 0.5;
  border = new Circle(center, center, center);
  border.getStyleClass().add("border");

  pieSlice = new Arc(center, center, center - 1, center - 1, 90, 0);
  pieSlice.getStyleClass().add("pieSlice");
  pieSlice.setType(ArcType.ROUND);

  valueField = new TextField();
  valueField.relocate(ARTBOARD_HEIGHT + 5, 2);
  valueField.setPrefWidth(ARTBOARD_WIDTH - ARTBOARD_HEIGHT - 5);
  valueField.getStyleClass().add("valueField");

  // always needed
  drawingPane = new Pane();
  drawingPane.setMaxSize(ARTBOARD_WIDTH, ARTBOARD_HEIGHT);
  drawingPane.setMinSize(ARTBOARD_WIDTH, ARTBOARD_HEIGHT);
  drawingPane.setPrefSize(ARTBOARD_WIDTH, ARTBOARD_HEIGHT);
}
 
Example #16
Source File: Helper.java    From Medusa with Apache License 2.0 5 votes vote down vote up
public static final void drawTimeAreas(final Clock CLOCK, final GraphicsContext CTX, final List<TimeSection> AREAS, final double SIZE,
                                       final double XY_INSIDE, final double XY_OUTSIDE, final double WH_INSIDE, final double WH_OUTSIDE) {
    if (AREAS.isEmpty()) return;
    TickLabelLocation tickLabelLocation = CLOCK.getTickLabelLocation();
    ZonedDateTime     time              = CLOCK.getTime();
    boolean           isAM              = time.get(ChronoField.AMPM_OF_DAY) == 0;
    double            xy                = TickLabelLocation.OUTSIDE == tickLabelLocation ? XY_OUTSIDE * SIZE : XY_INSIDE * SIZE;
    double            wh                = TickLabelLocation.OUTSIDE == tickLabelLocation ? WH_OUTSIDE * SIZE : WH_INSIDE * SIZE;
    double            offset            = 90;
    double            angleStep         = 360.0 / 60.0;
    int               listSize          = AREAS.size();
    boolean           highlightAreas    = CLOCK.isHighlightAreas();
    for (int i = 0; i < listSize ; i++) {
        TimeSection area      = AREAS.get(i);
        LocalTime   start     = area.getStart();
        LocalTime   stop      = area.getStop();
        boolean     isStartAM = start.get(ChronoField.AMPM_OF_DAY) == 0;
        boolean     isStopAM  = stop.get(ChronoField.AMPM_OF_DAY) == 0;
        boolean     draw      = isAM ? (isStartAM || isStopAM) :(!isStartAM || !isStopAM);
        if (draw) {
            double areaStartAngle  = (start.getHour() % 12 * 5.0 + start.getMinute() / 12.0 + start.getSecond() / 300.0) * angleStep + 180;;
            double areaAngleExtend = ((stop.getHour() - start.getHour()) % 12 * 5.0 + (stop.getMinute() - start.getMinute()) / 12.0 + (stop.getSecond() - start.getSecond()) / 300.0) * angleStep;
            //TODO: Add an indicator to the area like -1 or similar
            // check if start was already yesterday
            if (start.getHour() > stop.getHour()) { areaAngleExtend = (360.0 - Math.abs(areaAngleExtend)); }
            CTX.save();
            if (highlightAreas) {
                CTX.setFill(area.contains(time.toLocalTime()) ? area.getHighlightColor() : area.getColor());
            } else {
                CTX.setFill(area.getColor());
            }
            CTX.fillArc(xy, xy, wh, wh, -(offset + areaStartAngle), -areaAngleExtend, ArcType.ROUND);
            CTX.restore();
        }
    }
}
 
Example #17
Source File: RadialBargraphSkin.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private final void drawSections(final GraphicsContext CTX) {
    final double xy        = (size - 0.87 * size) * 0.5;
    final double wh        = size * 0.87;
    final double MIN_VALUE = getSkinnable().getMinValue();
    final double OFFSET = 90 - getSkinnable().getStartAngle();
    for (int i = 0 ; i < getSkinnable().getSections().size() ; i++) {
        final Section SECTION      = getSkinnable().getSections().get(i);
        final double  ANGLE_START  = (SECTION.getStart() - MIN_VALUE) * angleStep;
        final double  ANGLE_EXTEND = (SECTION.getStop() - SECTION.getStart()) * angleStep;
        CTX.save();
        switch(i) {
            case 0: CTX.setStroke(getSkinnable().getSectionFill0()); break;
            case 1: CTX.setStroke(getSkinnable().getSectionFill1()); break;
            case 2: CTX.setStroke(getSkinnable().getSectionFill2()); break;
            case 3: CTX.setStroke(getSkinnable().getSectionFill3()); break;
            case 4: CTX.setStroke(getSkinnable().getSectionFill4()); break;
            case 5: CTX.setStroke(getSkinnable().getSectionFill5()); break;
            case 6: CTX.setStroke(getSkinnable().getSectionFill6()); break;
            case 7: CTX.setStroke(getSkinnable().getSectionFill7()); break;
            case 8: CTX.setStroke(getSkinnable().getSectionFill8()); break;
            case 9: CTX.setStroke(getSkinnable().getSectionFill9()); break;
        }
        CTX.setLineWidth(size * 0.1);
        CTX.setLineCap(StrokeLineCap.BUTT);
        CTX.strokeArc(xy, xy, wh, wh, -(OFFSET + ANGLE_START), -ANGLE_EXTEND, ArcType.OPEN);
        CTX.restore();
    }
}
 
Example #18
Source File: FXGraphics2D.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
private ArcType intToArcType(int t) {
    if (t == Arc2D.CHORD) {
        return ArcType.CHORD;
    } else if (t == Arc2D.OPEN) {
        return ArcType.OPEN;
    } else if (t == Arc2D.PIE) {
        return ArcType.ROUND;
    }
    throw new IllegalArgumentException("Unrecognised t: " + t);
}
 
Example #19
Source File: GaugeSparkLineTileSkin.java    From OEE-Designer with MIT License 5 votes vote down vote up
private void drawHighLightSections(final double VALUE) {
    highlightSectionCtx.setLineCap(StrokeLineCap.BUTT);
    highlightSectionCtx.clearRect(0, 0, width, height);

    if (tile.getSectionsVisible() && !sections.isEmpty()) {
        double  x         = (width - size * 0.7) * 0.5;
        double  y         = (height - size * 0.7) * 0.5;
        double  wh        = size * 0.7;
        double  minValue  = tile.getMinValue();
        double  maxValue  = tile.getMaxValue();
        double  angleStep = tile.getAngleStep();
        highlightSectionCtx.setLineWidth(size * 0.01);
        highlightSectionCtx.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 = 15;
                } else {
                    sectionStartAngle = (section.getStart() - minValue) * angleStep + 15;
                }
                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) * tile.getAngleStep();
                } else {
                    sectionAngleExtend = (section.getStop() - section.getStart()) * angleStep;
                }
                highlightSectionCtx.save();
                highlightSectionCtx.setStroke(section.contains(VALUE) ? section.getColor() : section.getColor().darker().darker());
                highlightSectionCtx.strokeArc(x, y, wh, wh, -(120 + sectionStartAngle), -sectionAngleExtend, ArcType.OPEN);
                highlightSectionCtx.restore();
            }
        }
    }
}
 
Example #20
Source File: TinySkin.java    From Medusa with Apache License 2.0 5 votes vote down vote up
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();
        }
    }
}
 
Example #21
Source File: Helper.java    From Medusa with Apache License 2.0 5 votes vote down vote up
public static final void drawTimeSections(final Clock CLOCK, final GraphicsContext CTX, final List<TimeSection> SECTIONS, final double SIZE,
                                          final double XY_INSIDE, final double XY_OUTSIDE, final double WH_INSIDE, final double WH_OUTSIDE,
                                          final double LINE_WIDTH) {
    if (SECTIONS.isEmpty()) return;
    TickLabelLocation tickLabelLocation = CLOCK.getTickLabelLocation();
    ZonedDateTime     time              = CLOCK.getTime();
    boolean           isAM              = time.get(ChronoField.AMPM_OF_DAY) == 0;
    double            xy                = TickLabelLocation.INSIDE == tickLabelLocation ? XY_INSIDE * SIZE : XY_OUTSIDE * SIZE;
    double            wh                = TickLabelLocation.INSIDE == tickLabelLocation ? WH_INSIDE * SIZE : WH_OUTSIDE * SIZE;
    double            offset            = 90;
    int               listSize          = SECTIONS.size();
    double            angleStep         = 360.0 / 60.0;
    boolean           highlightSections = CLOCK.isHighlightSections();
    for (int i = 0 ; i < listSize ; i++) {
        TimeSection section   = SECTIONS.get(i);
        LocalTime   start     = section.getStart();
        LocalTime   stop      = section.getStop();
        boolean     isStartAM = start.get(ChronoField.AMPM_OF_DAY) == 0;
        boolean     isStopAM  = stop.get(ChronoField.AMPM_OF_DAY) == 0;
        boolean     draw      = isAM ? (isStartAM || isStopAM) :(!isStartAM || !isStopAM);
        if (draw) {
            double sectionStartAngle = (start.getHour() % 12 * 5.0 + start.getMinute() / 12.0 + start.getSecond() / 300.0) * angleStep + 180;
            double sectionAngleExtend = ((stop.getHour() - start.getHour()) % 12 * 5.0 + (stop.getMinute() - start.getMinute()) / 12.0 + (stop.getSecond() - start.getSecond()) / 300.0) * angleStep;
            //TODO: Add an indicator to the section like -1 or similar
            // check if start was already yesterday
            if (start.getHour() > stop.getHour()) { sectionAngleExtend = (360.0 - Math.abs(sectionAngleExtend)); }
            CTX.save();
            if (highlightSections) {
                CTX.setStroke(section.contains(time.toLocalTime()) ? section.getHighlightColor() : section.getColor());
            } else {
                CTX.setStroke(section.getColor());
            }
            CTX.setLineWidth(SIZE * LINE_WIDTH);
            CTX.setLineCap(StrokeLineCap.BUTT);
            CTX.strokeArc(xy, xy, wh, wh, -(offset + sectionStartAngle), -sectionAngleExtend, ArcType.OPEN);
            CTX.restore();
        }
    }
}
 
Example #22
Source File: FridayFunSkin.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
@Override
public void initializeParts() {
  double center = ARTBOARD_SIZE * 0.5;
  int width = 15;
  double radius = center - width;

  backgroundCircle = new Circle(center, center, radius);
  backgroundCircle.getStyleClass().add("backgroundCircle");

  bar = new Arc(center, center, radius, radius, 90.0, 0.0);
  bar.getStyleClass().add("bar");
  bar.setType(ArcType.OPEN);

  thumb = new Circle(center, center + center - width, 13);
  thumb.getStyleClass().add("thumb");

  valueDisplay = createCenteredText(center, center, "valueDisplay");

  ticks = createTicks(center, center, 60, 360.0, 6, 33, 0, "tick");

  tickLabels = new ArrayList<>();

  int labelCount = 8;
  for (int i = 0; i < labelCount; i++) {
    double r = 95;
    double nextAngle = i * 360.0 / labelCount;

    Point2D p = pointOnCircle(center, center, r, nextAngle);
    Text tickLabel = createCenteredText(p.getX(), p.getY(), "tickLabel");

    tickLabels.add(tickLabel);
  }
  updateTickLabels();

  drawingPane = new Pane();
  drawingPane.getStyleClass().add("numberRange");
  drawingPane.setMaxSize(ARTBOARD_SIZE, ARTBOARD_SIZE);
  drawingPane.setMinSize(ARTBOARD_SIZE, ARTBOARD_SIZE);
  drawingPane.setPrefSize(ARTBOARD_SIZE, ARTBOARD_SIZE);
}
 
Example #23
Source File: ButtonFXControlAdapterSnippet.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Scene createScene() {
	HBox hbox = new HBox();
	VBox col1 = new VBox();
	VBox col2 = new VBox();
	HBox.setMargin(col1, new Insets(10.0));
	HBox.setMargin(col2, new Insets(10.0));
	hbox.getChildren().addAll(col1, col2);
	HBox.setHgrow(col1, Priority.ALWAYS);
	HBox.setHgrow(col2, Priority.ALWAYS);

	col1.getChildren().addAll(new Button("JavaFX Button 1"),
			shape(new Arc(0, 0, 50, 50, 15, 120) {
				{
					setType(ArcType.ROUND);
				}
			}, 0.52, 0.49, 0.15), createButtonAdapter("SWT Button 1"));

	col2.getChildren().addAll(
			shape(new Rectangle(0, 0, 100, 50), 0.49, 0.36, 0.20),
			createButtonAdapter("SWT Button 2"),
			shape(new Rectangle(0, 0, 100, 100) {
				{
					setArcHeight(20);
					setArcWidth(20);
				}
			}, 0.87, 0.83, 0.49), new Button("JavaFX Button 2"));

	return new Scene(hbox, 400, 300);
}
 
Example #24
Source File: FXGraphics2D.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
private ArcType intToArcType(int t) {
    if (t == Arc2D.CHORD) {
        return ArcType.CHORD;
    } else if (t == Arc2D.OPEN) {
        return ArcType.OPEN;
    } else if (t == Arc2D.PIE) {
        return ArcType.ROUND;
    }
    throw new IllegalArgumentException("Unrecognised t: " + t);
}
 
Example #25
Source File: FXGraphics2D.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
private ArcType intToArcType(int t) {
    if (t == Arc2D.CHORD) {
        return ArcType.CHORD;
    } else if (t == Arc2D.OPEN) {
        return ArcType.OPEN;
    } else if (t == Arc2D.PIE) {
        return ArcType.ROUND;
    }
    throw new IllegalArgumentException("Unrecognised t: " + t);
}
 
Example #26
Source File: ShapeConverter.java    From Enzo with Apache License 2.0 5 votes vote down vote up
public static String convertArc(final Arc ARC) {
    StringBuilder fxPath = new StringBuilder();
    double centerX    = ARC.getCenterX();
    double centerY    = ARC.getCenterY();
    double radiusX    = ARC.getRadiusX();
    double radiusY    = ARC.getRadiusY();
    double startAngle = Math.toRadians(-ARC.getStartAngle());
    double endAngle   = Math.toRadians(-ARC.getStartAngle() - ARC.getLength());
    double length     = ARC.getLength();

    double startX = radiusX * Math.cos(startAngle);
    double startY = radiusY * Math.sin(startAngle);

    double endX   = centerX + radiusX * Math.cos(endAngle);
    double endY   = centerY + radiusY * Math.sin(endAngle);

    int xAxisRot  = 0;
    int largeArc  = (length > 180) ? 1 : 0;
    int sweep     = (length < 0) ? 1 : 0;

    fxPath.append("M ").append(centerX).append(" ").append(centerY).append(" ");

    if (ArcType.ROUND == ARC.getType()) {
        fxPath.append("l ").append(startX).append(" ").append(startY).append(" ");
    }

    fxPath.append("A ").append(radiusX).append(" ").append(radiusY).append(" ")
          .append(xAxisRot).append(" ").append(largeArc).append(" ").append(sweep).append(" ")
          .append(endX).append(" ").append(endY).append(" ");
    if (ArcType.CHORD == ARC.getType() || ArcType.ROUND == ARC.getType()) {
        fxPath.append("Z");
    }
    return fxPath.toString();
}
 
Example #27
Source File: FanPane.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
/** Add four arcs to a pane and place them in a stack pane */
private Pane getBlades() {
	Pane pane = new Pane();
	double angle = 0;
	for (int i = 0; i < 4; i++) {
		Arc arc = new Arc(125, 115, 90, 90, angle + 90, 50);
		arc.setFill(Color.BLACK);
		arc.setType(ArcType.ROUND);
		pane.getChildren().add(arc);
		angle += 90;
	}
	return pane;
}
 
Example #28
Source File: Exercise_14_09.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
/** Add four arcs to a pane and place them in a stack pane */
private void getArcs(StackPane stackPane) {
	double angle = 30; // Start angle
	for (int i = 0; i < 4; i++) {
		Pane pane = new Pane();
		Arc arc = new Arc(100, 100, 80, 80, angle + 90, 35);
		arc.setFill(Color.BLACK);
		arc.setType(ArcType.ROUND);
		pane.getChildren().add(arc);
		stackPane.getChildren().add(pane);
		angle += 90;
	}
}
 
Example #29
Source File: Exercise_14_11.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
/** Return a Arc of specified properties */
private Arc getArc(Circle c) {
	Arc a = new Arc(c.getRadius(), c.getRadius() * 1.30, 
		c.getRadius() / 2, c.getRadius() / 4, 0, -180);
	a.setType(ArcType.OPEN);
	a.setFill(Color.WHITE);
	a.setStroke(Color.BLACK);
	return a;
}
 
Example #30
Source File: TaskProgressIndicatorSkin.java    From archivo with GNU General Public License v3.0 5 votes vote down vote up
public DeterminateIndicator(ProgressIndicator control, Paint fillOverride) {

            getStyleClass().add("determinate-indicator");

            degProgress = (int) (360 * control.getProgress());

            getChildren().clear();

            // The circular background for the progress pie piece
            indicator = new StackPane();
            indicator.setScaleShape(false);
            indicator.setCenterShape(false);
            indicator.getStyleClass().setAll("indicator");
            indicatorCircle = new Circle();
            indicator.setShape(indicatorCircle);

            // The shape for our progress pie piece
            arcShape = new Arc();
            arcShape.setType(ArcType.ROUND);
            arcShape.setStartAngle(90.0F);

            // Our progress pie piece
            progress = new StackPane();
            progress.getStyleClass().setAll("progress");
            progress.setScaleShape(false);
            progress.setCenterShape(false);
            progress.setShape(arcShape);
            progress.getChildren().clear();
            setFillOverride(fillOverride);

            // The check mark that's drawn at 100%
            tick = new StackPane();
            tick.getStyleClass().setAll("tick");

            getChildren().setAll(indicator, progress, tick);
            updateProgress(control.getProgress());
        }