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


Java Stop类代码示例

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


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

示例1: ladder

import javafx.scene.paint.Stop; //导入依赖的package包/类
/**
 * Get the color at the give {@code position} in the ladder of color stops
 */
private static Color ladder(final double position, final Stop[] stops) {
    Stop prevStop = null;
    for (int i=0; i<stops.length; i++) {
        Stop stop = stops[i];
        if(position <= stop.getOffset()){
            if (prevStop == null) {
                return stop.getColor();
            } else {
                return interpolateLinear((position-prevStop.getOffset())/(stop.getOffset()-prevStop.getOffset()), prevStop.getColor(), stop.getColor());
            }
        }
        prevStop = stop;
    }
    // position is greater than biggest stop, so will we biggest stop's color
    return prevStop.getColor();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:HeatTabController.java

示例2: RadialGradientSample

import javafx.scene.paint.Stop; //导入依赖的package包/类
public RadialGradientSample() {
    //create simple radial gradient
    RadialGradient gradient1 = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop[] {
        new Stop(0, Color.DODGERBLUE),
        new Stop(1, Color.BLACK)
    });
    Circle circle1 = new Circle(45, 45, 40, gradient1);

    //create complex radial gradient
    RadialGradient gradient2 = new RadialGradient(20, 1, 0.5, 0.5, 0.6, true, CycleMethod.NO_CYCLE, new Stop[] {
        new Stop(0,  Color.TRANSPARENT),
        new Stop(0.5,  Color.DARKGRAY),
        new Stop(0.64, Color.WHITESMOKE),
        new Stop(0.65, Color.YELLOW),
        new Stop(1, Color.GOLD)
    });
    Circle circle2 = new Circle(145, 45, 40, gradient2);

    HBox hb = new HBox(10);
    hb.getChildren().addAll(circle1, circle2);
    
    // show the circles
    getChildren().addAll(hb);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:25,代码来源:RadialGradientSample.java

示例3: getColor

import javafx.scene.paint.Stop; //导入依赖的package包/类
private Color getColor(double t) {
    if (t < 0 || t > 1) {
        throw new IllegalArgumentException("t = " + t);
    }

    for (int i = 1; i < colorStops.size(); i++) {
        Stop s = colorStops.get(i);
        Stop p = colorStops.get(i-1);
        if (t <= s.getOffset()) {
            double start = p.getOffset();
            double end = s.getOffset();

            return p.getColor().interpolate(s.getColor(), (t-start) / (end-start));
        }
    }

    throw new IllegalArgumentException("t > last stop's offset: t="+t+", offset="+colorStops.get(colorStops.size()-1));
}
 
开发者ID:lsinfo3,项目名称:mo-vnfcp,代码行数:19,代码来源:GuiApp.java

示例4: getColorAt

import javafx.scene.paint.Stop; //导入依赖的package包/类
public Color getColorAt(final double POSITION_OF_COLOR) {
    if (stops.isEmpty()) return Color.BLACK;

    final double POSITION = Helper.clamp(0.0, 1.0, POSITION_OF_COLOR);
    final Color COLOR;
    if (stops.size() == 1) {
        final Map<Double, Color> ONE_ENTRY = (Map<Double, Color>) stops.entrySet().iterator().next();
        COLOR = stops.get(ONE_ENTRY.keySet().iterator().next()).getColor();
    } else {
        Stop lowerBound = stops.get(0.0);
        Stop upperBound = stops.get(1.0);
        for (Double fraction : stops.keySet()) {
            if (Double.compare(fraction,POSITION) < 0) {
                lowerBound = stops.get(fraction);
            }
            if (Double.compare(fraction, POSITION) > 0) {
                upperBound = stops.get(fraction);
                break;
            }
        }
        COLOR = interpolateColor(lowerBound, upperBound, POSITION);
    }
    return COLOR;
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:25,代码来源:GradientLookup.java

示例5: draw

import javafx.scene.paint.Stop; //导入依赖的package包/类
private void draw(final int LIMIT, final double RESOLUTION) {
    int limit        = LIMIT > points.size() ? points.size() : LIMIT + 1;
    double pixelSize = 2 * RESOLUTION;

    ctx.clearRect(0, 0, width, height);

    for (double y = 0 ; y < height ; y += RESOLUTION) {
        for (double x = 0 ; x < width ; x += RESOLUTION) {
            double value = getValueAt(limit, x, y);
            if (value != -255) {
                Color          color    = getUseColorMapping() ? getColorForValue(value) : getColorForValue(value, isDiscreteColors());
                RadialGradient gradient = new RadialGradient(0, 0, x, y, RESOLUTION,
                                                             false, CycleMethod.NO_CYCLE,
                                                             new Stop(0, Color.color(color.getRed(), color.getGreen(), color.getBlue(), getHeatMapOpacity())),
                                                             new Stop(1, Color.color(color.getRed(), color.getGreen(), color.getBlue(), 0.0)));
                ctx.setFill(gradient);
                ctx.fillOval(x - RESOLUTION, y - RESOLUTION, pixelSize, pixelSize);
            }
        }
    }
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:22,代码来源:AreaHeatMap.java

示例6: RadarChart

import javafx.scene.paint.Stop; //导入依赖的package包/类
public RadarChart(final List<ChartData> DATA) {
    _minValue             = 0;
    _maxValue             = 100;
    _range                = 100;
    _threshold            = 100;
    _noOfSectors          = MIN_NO_OF_SECTORS;
    _unit                 = "";
    _legendVisible        = false;
    _thresholdVisible     = false;
    _mode                 = Mode.POLYGON;
    gradientStops         = FXCollections.observableArrayList();
    decimals              = 0;
    formatString          = new StringBuilder("%.").append(decimals).append("f").toString();
    data                  = FXCollections.observableArrayList();
    legendScaleFactor     = 1.0;
    _smoothing            = false;
    _chartBackgroundColor = Color.TRANSPARENT;
    _chartForegroundColor = Tile.FOREGROUND;
    _chartTextColor       = Tile.FOREGROUND;
    _gridColor            = Tile.GRAY;
    _chartFill            = Tile.BLUE;
    _thresholdColor       = Tile.LIGHT_RED;
    resizeListener        = o -> resize();
    gradientListener      = change -> {
        stops.clear();
        for (Stop stop : getGradientStops()) {
            if (Double.compare(stop.getOffset(), 0.0) == 0) { stops.add(new Stop(0, stop.getColor())); }
            stops.add(new Stop(stop.getOffset() * 0.69924 + 0.285, stop.getColor()));
        }
        redraw();
    };

    init();
    initGraphics();
    initData(DATA);
    registerListeners();
}
 
开发者ID:HanSolo,项目名称:tilesfx,代码行数:38,代码来源:RadarChart.java

示例7: Bullet

import javafx.scene.paint.Stop; //导入依赖的package包/类
/**
* The constructor for a bullet.
* 
* @param radius - the radius of the bullet
* @param fill - the color of the bullet highlight
*/
  public Bullet(double radius, Color fill) {
      sphere = CircleBuilder.create()
              .centerX(radius)
              .centerY(radius)
              .radius(radius)
              .cache(true)
              .build();
 
      RadialGradient rgrad = RadialGradientBuilder.create()
                  .centerX(sphere.getCenterX() - sphere.getRadius() / 3)
                  .centerY(sphere.getCenterY() - sphere.getRadius() / 3)
                  .radius(sphere.getRadius())
                  .proportional(false)
                  .stops(new Stop(0.0, fill), new Stop(1.0, Settings.BULLET_PRIMARY_COLOR))
                  .build();
 
      sphere.setFill(rgrad);
  }
 
开发者ID:adisrini,项目名称:enders_game,代码行数:25,代码来源:Bullet.java

示例8: initBackground

import javafx.scene.paint.Stop; //导入依赖的package包/类
private void initBackground() {
    Rectangle bg0 = new Rectangle(getWidth(), getHeight(),
            new LinearGradient(getWidth() / 2, 0, getWidth() / 2, getHeight(),
                    false, CycleMethod.NO_CYCLE,
                    new Stop(0.2, Color.AQUA), new Stop(0.8, Color.BLACK)));

    Rectangle bg1 = new Rectangle(getWidth(), getHeight(), Color.color(0, 0, 0, 0.2));
    bg1.setBlendMode(BlendMode.DARKEN);

    EntityView bg = new EntityView(RenderLayer.BACKGROUND);
    bg.addNode(bg0);
    bg.addNode(bg1);

    // we add IrremovableComponent because regardless of the level
    // the background and screen bounds stay in the game world
    Entities.builder()
            .viewFromNode(bg)
            .with(new IrremovableComponent())
            .buildAndAttach(getGameWorld());

    Entity screenBounds = Entities.makeScreenBounds(40);
    screenBounds.addComponent(new IrremovableComponent());

    getGameWorld().addEntity(screenBounds);
}
 
开发者ID:AlmasB,项目名称:FXGLGames,代码行数:26,代码来源:BreakoutApp.java

示例9: getColorAt

import javafx.scene.paint.Stop; //导入依赖的package包/类
public Color getColorAt(final double POSITION_OF_COLOR) {
    if (stops.isEmpty()) return Color.BLACK;

    final double POSITION = clamp(0d, 1d, POSITION_OF_COLOR);
    final Color COLOR;
    if (stops.size() == 1) {
        final Map<Double, Color> ONE_ENTRY = (Map<Double, Color>) stops.entrySet().iterator().next();
        COLOR = stops.get(ONE_ENTRY.keySet().iterator().next()).getColor();
    } else {
        Stop lowerBound = stops.get(0.0);
        Stop upperBound = stops.get(1.0);
        for (Double fraction : stops.keySet()) {
            if (Double.compare(fraction,POSITION) < 0) {
                lowerBound = stops.get(fraction);
            }
            if (Double.compare(fraction, POSITION) > 0) {
                upperBound = stops.get(fraction);
                break;
            }
        }
        COLOR = interpolateColor(lowerBound, upperBound, POSITION);
    }
    return COLOR;
}
 
开发者ID:HanSolo,项目名称:ColorSelector,代码行数:25,代码来源:GradientLookup.java

示例10: drawGradientBar

import javafx.scene.paint.Stop; //导入依赖的package包/类
private void drawGradientBar() {
    double     xy     = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.115 * size : 0.0515 * size;
    double     wh     = TickLabelLocation.OUTSIDE == tickLabelLocation ? size * 0.77 : size * 0.897;
    double     offset = 90 - startAngle;
    List<Stop> stops  = getSkinnable().getGradientBarStops();
    Map<Double, Color> stopAngleMap     = new HashMap<>(stops.size());
    for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * angleRange, stop.getColor()); }
    double                  offsetFactor        = ScaleDirection.CLOCKWISE == scaleDirection ? (startAngle - 90) : (startAngle + 180);
    AngleConicalGradient    gradient            = new AngleConicalGradient(size * 0.5, size * 0.5, offsetFactor, stopAngleMap, getSkinnable().getScaleDirection());

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

示例11: normalizeStops

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

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

示例12: drawNode

import javafx.scene.paint.Stop; //导入依赖的package包/类
@Override
public Node drawNode() {

    Group group = new Group();
    final Canvas canvas = new Canvas(120, 120);
    GraphicsContext gc = canvas.getGraphicsContext2D();
    group.getChildren().add(canvas);

    gc.setFill(Color.GREEN);
    gc.fillRect(10,10, 70, 70);

    ColorInput effect = new ColorInput();
    effect.setPaint(new LinearGradient(0, 0, 0.5f, 0.1f, true, CycleMethod.REPEAT, new Stop[] {
                    new Stop(0, Color.RED),
                    new Stop(1, Color.GREEN),
                }));
    effect.setX(15);
    effect.setY(15);
    effect.setWidth(70);
    effect.setHeight(70);

    gc.applyEffect(effect);
    return group;

}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:26,代码来源:CanvasEffects2App.java

示例13: drawGradientBar

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

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

示例14: drawGradientBar

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

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

示例15: drawGradientBar

import javafx.scene.paint.Stop; //导入依赖的package包/类
private void drawGradientBar() {
    TickLabelLocation  tickLabelLocation     = gauge.getTickLabelLocation();
    double             scaledHeight          = height * 0.9;
    double             xy                    = TickLabelLocation.OUTSIDE == tickLabelLocation ? 0.1705 * scaledHeight : 0.107 * scaledHeight;
    double             wh                    = TickLabelLocation.OUTSIDE == tickLabelLocation ? scaledHeight * 0.77 : scaledHeight * 0.897;
    double             offset                = 90 - startAngle;
    double             offsetX               = -0.1 * width;
    double             knobPositionOffsetCW  = Pos.CENTER_LEFT == gauge.getKnobPosition() ? 90 : 270;
    double             knobPositionOffsetCCW = Pos.CENTER_LEFT == gauge.getKnobPosition() ? 180 : 0;
    ScaleDirection     scaleDirection        = gauge.getScaleDirection();
    List<Stop>         stops                 = gauge.getGradientBarStops();
    Map<Double, Color> stopAngleMap          = new HashMap<>(stops.size());
    for (Stop stop : stops) { stopAngleMap.put(stop.getOffset() * angleRange, stop.getColor()); }
    double               offsetFactor = ScaleDirection.CLOCKWISE == scaleDirection ? knobPositionOffsetCW - angleRange * 0.5 : angleRange - (angleRange / 180 * angleRange) + knobPositionOffsetCCW;
    AngleConicalGradient gradient     = new AngleConicalGradient(width * 0.5, width * 0.5, offsetFactor, stopAngleMap, gauge.getScaleDirection());

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


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