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


Java Shape类代码示例

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


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

示例1: generateMecanumDriveBase

import javafx.scene.shape.Shape; //导入依赖的package包/类
/**
 * Generates a mecanum drive base.
 *
 * @param wheelWidth  the width (or thickness) of the wheels
 * @param wheelHeight the height (or diameter) of the wheels
 * @param frameWidth  the width of the robot frame
 * @param frameHeight the height of the robot frame
 */
private static Shape generateMecanumDriveBase(double wheelWidth,
                                              double wheelHeight,
                                              double frameWidth,
                                              double frameHeight) {
  Rectangle frame = new Rectangle(wheelWidth, 0, frameWidth, frameHeight);
  frame.setFill(null);
  frame.setStroke(Color.WHITE);

  final Shape fl = mecanumWheel(wheelWidth, wheelHeight, MecanumWheelPos.FRONT_LEFT);
  final Shape fr = mecanumWheel(wheelWidth, wheelHeight, MecanumWheelPos.FRONT_RIGHT);
  final Shape rl = mecanumWheel(wheelWidth, wheelHeight, MecanumWheelPos.REAR_LEFT);
  final Shape rr = mecanumWheel(wheelWidth, wheelHeight, MecanumWheelPos.REAR_RIGHT);
  fr.setTranslateX(frameWidth + wheelWidth);
  rl.setTranslateY(frameHeight - wheelHeight);
  rr.setTranslateX(frameWidth + wheelWidth);
  rr.setTranslateY(frameHeight - wheelHeight);

  Shape combined = union(frame, fl, fr, rl, rr);
  combined.getStyleClass().addAll("robot-drive", "mecanum-drive");
  return combined;
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:30,代码来源:MecanumDriveWidget.java

示例2: adjust

import javafx.scene.shape.Shape; //导入依赖的package包/类
@Override
public Node adjust(Node node, double scale) {
	requireNonNull(node);
	requireValidScale(scale);
	
	if (node instanceof Shape) {
		Shape shape = (Shape) node;
		shape.strokeDashOffsetProperty().set(shape.strokeDashOffsetProperty().multiply(scale).get());
		shape.strokeWidthProperty().set(shape.strokeWidthProperty().multiply(scale).get());
		shape.strokeMiterLimitProperty().set(shape.strokeMiterLimitProperty().multiply(scale).get());
		shape.translateXProperty().set(shape.translateXProperty().multiply(scale).get());
		shape.translateYProperty().set(shape.translateYProperty().multiply(scale).get());
		shape.translateZProperty().set(shape.translateZProperty().multiply(scale).get());
	}
	return super.adjust(node, scale);
}
 
开发者ID:yumix,项目名称:javafx-dpi-scaling,代码行数:17,代码来源:ShapeAdjuster.java

示例3: testManyProviders

import javafx.scene.shape.Shape; //导入依赖的package包/类
/**
 * Test several enabled+registered providers at the same time. They should
 * all paint their own events.
 */
@Test
public void testManyProviders() {
    TimeGraphDrawnEventProvider provider1 = new StubDrawnEventProvider1();
    TimeGraphDrawnEventProvider provider2 = new StubDrawnEventProvider2();
    MANAGER.getRegisteredProviders().add(provider1);
    MANAGER.getRegisteredProviders().add(provider2);
    provider1.enabledProperty().set(true);
    provider2.enabledProperty().set(true);

    repaint();

    Collection<Shape> events = getRenderedEvents();
    assertEquals(StubDrawnEventProvider1.NB_SYMBOLS + StubDrawnEventProvider2.NB_SYMBOLS,
            events.size());
}
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:20,代码来源:TimeGraphWidgetDrawnEventsTest.java

示例4: testEnabling

import javafx.scene.shape.Shape; //导入依赖的package包/类
/**
 * Test changing the 'enabled' property of a provider from false to true.
 * This should result in new events being painted.
 */
@Test
public void testEnabling() {
    TimeGraphDrawnEventProvider provider = new StubDrawnEventProvider1();
    MANAGER.getRegisteredProviders().add(provider);
    provider.enabledProperty().set(false);
    repaint();

    Collection<Shape> events = getRenderedEvents();
    assertTrue(events.isEmpty());

    provider.enabledProperty().set(true);
    repaint();

    events = getRenderedEvents();
    assertEquals(StubDrawnEventProvider1.NB_SYMBOLS, events.size());
}
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:21,代码来源:TimeGraphWidgetDrawnEventsTest.java

示例5: testDisabling

import javafx.scene.shape.Shape; //导入依赖的package包/类
/**
 * Test changing the 'enabled' property of a provider from true to false.
 * This should remove its events from the view.
 */
@Test
public void testDisabling() {
    TimeGraphDrawnEventProvider provider = new StubDrawnEventProvider1();
    MANAGER.getRegisteredProviders().add(provider);

    provider.enabledProperty().set(true);
    repaint();

    Collection<Shape> events = getRenderedEvents();
    assertEquals(StubDrawnEventProvider1.NB_SYMBOLS, events.size());

    provider.enabledProperty().set(false);
    repaint();

    events = getRenderedEvents();
    assertTrue(events.isEmpty());
}
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:22,代码来源:TimeGraphWidgetDrawnEventsTest.java

示例6: strokePattern

import javafx.scene.shape.Shape; //导入依赖的package包/类
private static Function strokePattern(Context context) {
    return args -> {
        val validator = Validator.with(args);
        validator.checkOrOr(1, 2);
        if (args[0].type() != Types.NODE || !(args[0].raw() instanceof ShapeNode)) {
            throw new TypeException("Shape required at first argument");
        }
        val shape = (Shape) ((ShapeNode) args[0].raw()).getFxNode();
        if (args.length == 2) {
            val array = validator.requireArrayAt(1);
            val dashList = array.stream()
                    .map(Value::asDouble)
                    .collect(Collectors.toList());
            shape.getStrokeDashArray().setAll(dashList);
            return NumberValue.ZERO;
        } else {
            return ArrayValue.from(shape.getStrokeDashArray(), NumberValue::of);
        }
    };
}
 
开发者ID:aNNiMON,项目名称:HotaruFX,代码行数:21,代码来源:NodeUtilsBundle.java

示例7: scaleShape

import javafx.scene.shape.Shape; //导入依赖的package包/类
private static void scaleShape(Scene scene, Shape shape) {
    double sceneWidth = scene.getWidth();
    double sceneHeight = scene.getHeight();
    ChangeListener<Number> widthResizer = (arg0, oldValue, newValue) -> shape.setScaleX(newValue.doubleValue() / sceneWidth);
    scene.widthProperty().addListener(widthResizer);
    ChangeListener<Number> heightResizer = (arg0, oldValue, newValue) -> shape.setScaleY(newValue.doubleValue() / sceneHeight);
    scene.heightProperty().addListener(heightResizer);

}
 
开发者ID:ciphertechsolutions,项目名称:IO,代码行数:10,代码来源:BaseController.java

示例8: create

import javafx.scene.shape.Shape; //导入依赖的package包/类
/**
 * Creates a new curved arrow.
 *
 * @param startAngle the starting angle of the arc, in radians
 * @param radius     the radius of the arrow. Must be non-negative.
 * @param length     the length of the arrow, in the same units as {@code radius}
 * @param xOffset    how much to offset the arc along the X-axis
 * @param headSize   the length of the head of the arrow
 *
 * @return a curved arrow shape
 *
 * @throws IllegalArgumentException if {@code radius} or {@code headSize} are negative
 */
public static Shape create(double startAngle,
                           double radius,
                           double length,
                           double xOffset,
                           double headSize) {
  if (radius < 0) {
    throw new IllegalArgumentException("Radius cannot be negative. Given: " + radius);
  }
  if (headSize < 0) {
    throw new IllegalArgumentException("The size of the arrowhead cannot be negative. Given: " + headSize);
  }
  if (radius == Double.POSITIVE_INFINITY) {
    // infinite radius = straight
    return createStraight(length, startAngle, xOffset, headSize);
  }
  return Shape.union(
      makeBody(startAngle, radius, length, xOffset),
      curvedHead(startAngle, headSize, radius, xOffset, length)
  );
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:34,代码来源:CurvedArrow.java

示例9: registerListeners

import javafx.scene.shape.Shape; //导入依赖的package包/类
private void registerListeners() {
    widthProperty().addListener(o -> resize());
    heightProperty().addListener(o -> resize());
    sceneProperty().addListener(o -> {
        if (!locations.isEmpty()) { addShapesToScene(locations.values()); }
        if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); }

        locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> {
            if (CHANGE.wasAdded()) {
                addShapesToScene(CHANGE.getValueAdded());
            } else if(CHANGE.wasRemoved()) {
                Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved()));
            }
        });
    });
}
 
开发者ID:HanSolo,项目名称:worldheatmap,代码行数:17,代码来源:World.java

示例10: generateOutline

import javafx.scene.shape.Shape; //导入依赖的package包/类
/**
 * Once we have drawn the path, we call this method to generate two paths 
 * (outer and inner paths) and get a SVGPath with them that can be exported
 * @param drawPath The original path
 * @param svg
 * @return the content string of the SVGPath with two paths
 */
public boolean generateOutline(Path drawPath, SVGPath svg) {
    Pane pane = (Pane) drawPath.getParent();
    final double width = pane.getWidth() * WIDTH_FACTOR; 
    
    Path outterPath = new Path(drawPath.getElements());
    outterPath.setStroke(drawPath.getStroke());
    outterPath.setStrokeLineJoin(drawPath.getStrokeLineJoin());
    outterPath.setStrokeLineCap(drawPath.getStrokeLineCap());
    outterPath.setStrokeWidth(width);
    Path s1 = (Path) Shape.subtract(outterPath, new Rectangle(0, 0));

    Path innerPath = new Path(drawPath.getElements());
    innerPath.setStrokeWidth(0);
    innerPath.setStroke(drawPath.getStroke());
    innerPath.setStrokeLineJoin(drawPath.getStrokeLineJoin());
    innerPath.setStrokeLineCap(drawPath.getStrokeLineCap());
    Path s2 = (Path) Shape.subtract(innerPath, new Rectangle(0, 0));
    
    Path result = (Path) Shape.subtract(s1, s2);
    clearSmallPolygons(result);
    svg.setContent(pathsToSVGPath());
    return validPaths.size() == 2;
}
 
开发者ID:gluonhq,项目名称:javaone2016,代码行数:31,代码来源:BadgeOutline.java

示例11: addPropertyChangedListener

import javafx.scene.shape.Shape; //导入依赖的package包/类
public void addPropertyChangedListener(Node object) {
    if (object instanceof Shape) {
        Shape shape = (Shape) object;

        shape.fillProperty().addListener((observable, oldValue, newValue) -> {
            HistoryController.getInstance(mainController).createHistoryPoint();
        });

        shape.strokeProperty().addListener((observable, oldValue, newValue) -> {
            HistoryController.getInstance(mainController).createHistoryPoint();
        });

        shape.strokeWidthProperty().addListener((observable, oldValue, newValue) -> {
            HistoryController.getInstance(mainController).createHistoryPoint();
        });
    }
}
 
开发者ID:pfolta,项目名称:Shapify,代码行数:18,代码来源:Document.java

示例12: register

import javafx.scene.shape.Shape; //导入依赖的package包/类
private void register(final ShapeFactory content, final int slotsize) {
    final PageWithSlots page = new PageWithSlots(content.name, height, width);
    page.setSlotSize(slotsize, slotsize);
    for (final AbstractEffect effect : effects) {
                Pane slot = new Pane();//Region();
                Shape shape = content.createShape();
                shape.setTranslateX(10);
                shape.setTranslateY(10);
                effect.setEffect(shape, slot); // will add shape to scene at the appropriate moment
        page.add(new TestNodeLeaf(effect.name(), slot));
    }

    Shape customShape = content.createCustomShape();
    if (null != customShape) {
        customShape.setTranslateX(10);
        customShape.setTranslateY(10);
        page.add(new TestNodeLeaf("customShape", customShape));
    }
    rootTestNode.add(page);
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:21,代码来源:Shapes2App.java

示例13: register

import javafx.scene.shape.Shape; //导入依赖的package包/类
private void register(final ShapeFactory content, final int slotsize) {
    addPage(content.name, new Runnable() {
        public void run() {
            SLOTSIZEX = slotsize;
            SLOTSIZEY = slotsize;

            for (Effects effect : Effects.values()) {
                //Region slot = new Region();
                Pane slot = new Pane();
                Shape shape = content.createShape();
                effect.setEffect(shape, slot); // will add shape to scene at the appropriate moment
                addSlot(effect.name(), slot);
            }

            content.addCustomShapes(getPageContent(), shiftX, shiftY);
        }
    });
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:19,代码来源:ShapePathElementsApp.java

示例14: before

import javafx.scene.shape.Shape; //导入依赖的package包/类
@Before
@Override
public void before()
{
    super.before();
    circleOneWrap = byID(getScene(), "circle_one", Shape.class);
    circleTwoWrap = byID(getScene(), "circle_two", Shape.class);
    circleThreeWrap = byID(getScene(), "circle_three", Shape.class);
    circleFourWrap = byID(getScene(), "circle_four", Shape.class);
    realTranform.setMxx(1);
    realTranform.setMxy(0);
    realTranform.setMxz(0);
    realTranform.setMyx(0);
    realTranform.setMyy(1);
    realTranform.setMyz(0);
    realTranform.setMzx(0);
    realTranform.setMzy(0);
    realTranform.setMzz(1);
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:20,代码来源:LocalTo_TransformsTest.java

示例15: before

import javafx.scene.shape.Shape; //导入依赖的package包/类
@Override
@Before
public void before()
{
    super.before();
    System.out.println("fx: " + VersionInfo.getRuntimeVersion());
    firstDTest = byID(getScene(), "first_depth_test", ComboBox.class).as(ComboBoxWrap.class);
    secondDTest = byID(getScene(), "second_depth_test", ComboBox.class).as(ComboBoxWrap.class);
    parentDTest = byID(getScene(), "parent_depth_test", ComboBox.class).as(ComboBoxWrap.class);
    firstNodeCombo = byID(getScene(), "first_node_combo", ComboBox.class).as(ComboBoxWrap.class);
    secondNodeCombo = byID(getScene(), "second_node_combo", ComboBox.class).as(ComboBoxWrap.class);
    firstToFront = byID(getScene(), "first_node_to_front", RadioButton.class).as(ToggleButtonWrap.class);
    secondToFront = byID(getScene(), "second_node_to_front", RadioButton.class).as(ToggleButtonWrap.class);
    indicator = byID(getScene(), "indicator", Shape.class);
    referenceGreen = byID(getScene(), "reference_green", Shape.class);
    referenceRed = byID(getScene(), "reference_red", Shape.class);
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:18,代码来源:DepthTestTest.java


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