Java Code Examples for javafx.scene.paint.PhongMaterial#getDiffuseColor()

The following examples show how to use javafx.scene.paint.PhongMaterial#getDiffuseColor() . 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: Viewer3dParserDemo.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void buildStructure_goodInputWithComment_returnNewStructure() throws Exception
{
    String inputWithComment = "sphere(10, 20, 30, 10.0, 150, 160, 170, 1.0, \"This is round.\")";
    Xform struct = Viewer3d.buildStructure(new ByteArrayInputStream(inputWithComment.getBytes()));
    Sphere sphere = (Sphere) struct.getChildren().get(0);

    /* Check that the transforms are correct. */

    assertEquals(10, sphere.getTranslateX(), 0);
    assertEquals(20, sphere.getTranslateY(), 0);
    assertEquals(30, sphere.getTranslateZ(), 0);

    /* Check that the size is correct. */

    assertEquals(10.0, sphere.getRadius(), 0);

    /* Check that the color is correct. */

    PhongMaterial material = (PhongMaterial) sphere.getMaterial();
    Color color = material.getDiffuseColor();

    assertEquals(150/255.0, color.getRed(), 0.001);
    assertEquals(160/255.0, color.getGreen(), 0.001);
    assertEquals(170/255.0, color.getBlue(), 0.001);
    assertEquals(1.0, color.getOpacity(), 0.0);
}
 
Example 2
Source File: Viewer3dParserDemo.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void buildStructure_goodInput_returnNewStructure() throws Exception
{
    String input = "sphere(25, 20, 35, 108.0, 155, 24, 43, 0.565)";
    Xform struct = Viewer3d.buildStructure(new ByteArrayInputStream(input.getBytes()));
    Sphere sphere = (Sphere) struct.getChildren().get(0);

    /* Check that the transforms are correct. */

    assertEquals(25, sphere.getTranslateX(), 0);
    assertEquals(20, sphere.getTranslateY(), 0);
    assertEquals(35, sphere.getTranslateZ(), 0);

    /* Check that the size is correct. */

    assertEquals(108.0, sphere.getRadius(), 0);

    /* Check that the color is correct. */

    PhongMaterial material = (PhongMaterial) sphere.getMaterial();
    Color color = material.getDiffuseColor();

    assertEquals(155/255.0, color.getRed(), 0.001);
    assertEquals(24/255.0, color.getGreen(), 0.001);
    assertEquals(43/255.0, color.getBlue(), 0.001);
    assertEquals(0.565, color.getOpacity(), 0.001);
}