Package javafx.beans.property

Examples of javafx.beans.property.SimpleIntegerProperty


    // ******************** Initialization ************************************
    public final void init() {
        getStyleClass().setAll(DEFAULT_STYLE_CLASS);

        contents    = FXCollections.observableArrayList();
        ledWidth    = new SimpleIntegerProperty(1);
        ledHeight   = new SimpleIntegerProperty(1);
        frameDesign = new SimpleObjectProperty<>(FrameDesign.GLOSSY_METAL);
        frameBaseColor = new SimpleObjectProperty<>(Color.rgb(160, 160, 160));
        frameCustomPath = new SimpleObjectProperty<>("");
        frameVisible= new SimpleBooleanProperty(true);       
    }
View Full Code Here


    @Test
    public void simpleBindingTest() throws Exception {
        //binding an enum and a number
        Property<TestEnum> enumProperty = new SimpleObjectProperty<>(TestEnum.NEGATIVE);
        Property<Number> integerProperty = new SimpleIntegerProperty(10);
        Function<Number,TestEnum> toEnum = number -> number.intValue()>=0 ? TestEnum.POSITIVE : TestEnum.NEGATIVE;
        Function<TestEnum,Number> toNumber = testEnum -> testEnum.equals(TestEnum.POSITIVE) ? 1 : -1;
        //create the binding
        HeterogeneousBidirectionalBinder<TestEnum,Number> binder =
                new HeterogeneousBidirectionalBinder<>(enumProperty,integerProperty,toNumber,toEnum);
        //like the original double-binding, when binder is created the property1 is set to property 2
        Assert.assertEquals(TestEnum.POSITIVE, enumProperty.getValue());

        //if i change the integer property, i will see enum property change
        integerProperty.setValue(-5);
        Assert.assertEquals(TestEnum.NEGATIVE, enumProperty.getValue());
        integerProperty.setValue(5);
        Assert.assertEquals(TestEnum.POSITIVE, enumProperty.getValue());
        integerProperty.setValue(-5);
        Assert.assertEquals(TestEnum.NEGATIVE,enumProperty.getValue());

        //if I change the enum, i will change the integer
        enumProperty.setValue(TestEnum.POSITIVE);
        Assert.assertEquals(integerProperty.getValue().intValue(),1);
        enumProperty.setValue(TestEnum.NEGATIVE);
        Assert.assertEquals(integerProperty.getValue().intValue(),-1);

        //if i unbind, this stops being true
        binder.unbind(); //notice that it's not the static method that gets called
        integerProperty.setValue(5);
        Assert.assertEquals(TestEnum.NEGATIVE, enumProperty.getValue());
        enumProperty.setValue(TestEnum.POSITIVE);
        Assert.assertEquals(integerProperty.getValue().intValue(),5);


    }
View Full Code Here

    @Test
    public void conflictingBinding() throws Exception {
        //binding an enum and a number
        Property<TestEnum> enumProperty = new SimpleObjectProperty<>(TestEnum.NEGATIVE);
        Property<Number> integerProperty = new SimpleIntegerProperty(10);
        //the usual transfomers
        Function<Number, TestEnum> toEnum = number -> number.intValue() >= 0 ? TestEnum.POSITIVE : TestEnum.NEGATIVE;
        Function<TestEnum, Number> toNumber = testEnum -> testEnum.equals(TestEnum.POSITIVE) ? 1 : -1;
        //the inverse transformers: take a positive and call it negative
        Function<Number, TestEnum> toEnum2 = number -> number.intValue() < 0 ? TestEnum.POSITIVE : TestEnum.NEGATIVE;
        Function<TestEnum, Number> toNumber2 = testEnum -> testEnum.equals(TestEnum.NEGATIVE) ? 1 : -1;
        //create the binding
        HeterogeneousBidirectionalBinder<TestEnum, Number> binder =
                new HeterogeneousBidirectionalBinder<>(enumProperty, integerProperty, toNumber, toEnum);
        //like the original double-binding, when binder is created the property1 is set to property 2
        Assert.assertEquals(TestEnum.POSITIVE, enumProperty.getValue());

        //if i change the integer property, i will see enum property change
        integerProperty.setValue(-5);
        Assert.assertEquals(TestEnum.NEGATIVE, enumProperty.getValue());
        integerProperty.setValue(5);
        Assert.assertEquals(TestEnum.POSITIVE, enumProperty.getValue());
        integerProperty.setValue(-5);
        Assert.assertEquals(TestEnum.NEGATIVE, enumProperty.getValue());

        binder.unbind();
        HeterogeneousBidirectionalBinder<TestEnum, Number> binder2 =
                new HeterogeneousBidirectionalBinder<>(enumProperty, integerProperty, toNumber2, toEnum2);
        integerProperty.setValue(5);
        Assert.assertEquals(TestEnum.NEGATIVE, enumProperty.getValue());
        integerProperty.setValue(-5);
        Assert.assertEquals(TestEnum.POSITIVE, enumProperty.getValue());



        HeterogeneousBidirectionalBinder<TestEnum, Number> binder3 =
                new HeterogeneousBidirectionalBinder<>(enumProperty, integerProperty, toNumber, toEnum);
        binder2.unbind();
        binder.unbind(); //this is ignored. Notice that this is the big difference with the Bindings class since that uses
        //statics all over the place and is forced to use deep equals to unbind correctly.

        integerProperty.setValue(5);
        Assert.assertEquals(TestEnum.POSITIVE, enumProperty.getValue());
        integerProperty.setValue(-5);
        Assert.assertEquals(TestEnum.NEGATIVE, enumProperty.getValue());

        binder3.unbind();

View Full Code Here

     */
    @Test
    public void multipleConflictingBinders() throws Exception {
        //binding an enum and a number
        Property<TestEnum> enumProperty = new SimpleObjectProperty<>(TestEnum.NEGATIVE);
        Property<Number> integerProperty = new SimpleIntegerProperty(10);
        //the usual transfomers
        Function<Number, TestEnum> toEnum = number -> number.intValue() >= 0 ? TestEnum.POSITIVE : TestEnum.NEGATIVE;
        Function<TestEnum, Number> toNumber = testEnum -> testEnum.equals(TestEnum.POSITIVE) ? 1 : -1;
        //the inverse transformers: take a positive and call it negative
        Function<Number, TestEnum> toEnum2 = number -> number.intValue() < 0 ? TestEnum.POSITIVE : TestEnum.NEGATIVE;
        Function<TestEnum, Number> toNumber2 = testEnum -> testEnum.equals(TestEnum.NEGATIVE) ? 1 : -1;
        //create 3 binders: one of them uses normal transformers the other two invert
        HeterogeneousBidirectionalBinder binder1 =
                new HeterogeneousBidirectionalBinder<>(enumProperty, integerProperty, toNumber, toEnum);
        HeterogeneousBidirectionalBinder binder2 =
                new HeterogeneousBidirectionalBinder<>(enumProperty, integerProperty, toNumber2, toEnum2);
        HeterogeneousBidirectionalBinder binder3 =
                new HeterogeneousBidirectionalBinder<>(enumProperty, integerProperty, toNumber2, toEnum2);
        //like the original double-binding, when binder is created the property1 is set to property 2
        integerProperty.setValue(-5); //set the value to -5
        //the second and third binder both flip the enum twice, correctly but confusingly
        Assert.assertEquals(TestEnum.NEGATIVE, enumProperty.getValue());
        enumProperty.setValue(TestEnum.POSITIVE);
        //you get +1 by flipping 1 into -1 and then again into 1
        Assert.assertEquals(1, integerProperty.getValue());

        //now remove binder2
        binder2.unbind();
        //binder 3 is still there flipping values:
        integerProperty.setValue(-5);
        Assert.assertEquals(TestEnum.POSITIVE, enumProperty.getValue()); //only one flip.


        binder1.unbind();
        binder3.unbind();
View Full Code Here

           
            this.iContent=iContent;
            this.content=getSkinnable().getContents().get(iContent);
           
            // bind posX/posY increment (1) to allow for pause time (0) for each content
            incrPos=new SimpleIntegerProperty(1);
           
            visibleContent[iContent]=new SimpleBooleanProperty(true); // SINGLE && FIRST
            if(content!=null && content.getOrder().equals(Content.RotationOrder.SECOND)){
                visibleContent[iContent].setValue(false);
            }
View Full Code Here

                contentHeight = fullAreas.get(iContent).length;
            }
            /*
            * START LOCATION OF CONTENT
            */
            posXIni= new SimpleIntegerProperty(0);
            posYIni = new SimpleIntegerProperty(0);
            if(content!=null && !content.getEffect().equals(Content.Effect.NONE)){
                // content at its final position
                posYIni.set(0);
                if(content.getTxtAlign().equals(Content.Align.LEFT)){
                    posXIni.set(0);
                    // SCROLL_RIGHT: +cW-cW, SCROLL_LEFT: -aW+aW=0, MIRROR: -cW/2+cW/2
                    limX=0;
                } else if(content.getTxtAlign().equals(Content.Align.CENTER)){
                    posXIni.set(contentWidth/2-areaWidth/2);
                    //SCROLL_RIGHT: +cW-(aW/2+cW/2) SCROLL_LEFT: -aW+(aW/2+fW/2), MIRROR: -aW/2+cW/2
                    limX=-areaWidth/2+contentWidth/2;
                } else if(content.getTxtAlign().equals(Content.Align.RIGHT)){
                    posXIni.set(contentWidth-areaWidth);
                    //SCROLL_RIGHT: +cW-aW, SCROLL_LEFT: -aW+cW=0, MIRROR: cW/2-aW + cW/2
                    limX=contentWidth-areaWidth;
                }

                // moved first if neccessary to start the scrolling effect
                if (content.getEffect().equals(Content.Effect.SCROLL_RIGHT)){
                    // content to the left of the visible area
                    posXIni.set(contentWidth);
                } else if (content.getEffect().equals(Content.Effect.SCROLL_LEFT)){
                    // content to the right of the visible area
                    posXIni.set(-areaWidth);
                } else if (content.getEffect().equals(Content.Effect.SCROLL_UP)){
                    // content to the bottom of the visible area
                    posYIni.set(-areaHeight);
                } else if (content.getEffect().equals(Content.Effect.SCROLL_DOWN)){
                    // content to the top of the visible area
                    posYIni.set(contentHeight);
                } else if (content.getEffect().equals(Content.Effect.MIRROR)){
                    // content to the center of the visible area
                    if(content.getTxtAlign().equals(Content.Align.LEFT)){
                        posXIni.set(-contentWidth/2);
                    } else if(content.getTxtAlign().equals(Content.Align.CENTER)){
                        posXIni.set(0-areaWidth/2);
                    } else if(content.getTxtAlign().equals(Content.Align.RIGHT)){
                        posXIni.set(contentWidth/2-areaWidth);
                    }
                }
            }
            // +1,-1 to make the translation ot the content, 0 to pause it
            posX = new SimpleIntegerProperty(posXIni.get());
            posY = new SimpleIntegerProperty(posYIni.get());
           
            // speed = gap of ms to refresh the matrixPanel
            realLapse = (content!=null && content.getLapse() >= 250)?content.getLapse():250;
           
            if(content!=null && content.getLapse()>0){
View Full Code Here

        super(IntegerProperty.class, mapper);
    }

    @Override
    protected WritableValue<Number> createProperty() {
        return new SimpleIntegerProperty();
    }
View Full Code Here

        alarmOn      = new SimpleBooleanProperty(this, "alarmOn", false);
        alarm        = new SimpleObjectProperty<>(LocalTime.now().minusMinutes(1));
        dateVisible  = new SimpleBooleanProperty(this, "dateVisible", false);
        alarmVisible = new SimpleBooleanProperty(this, "alarmVisible", false);
        time         = new StringBuilder();
        hours        = new SimpleIntegerProperty(this, "hours", -1);
        minutes      = new SimpleIntegerProperty(this, "minutes", -1);
        seconds      = new SimpleIntegerProperty(this, "seconds", -1);
        init();
        initGraphics();
        registerListeners();
        scheduleClockTask();
    }
View Full Code Here

        properties.put("sectionsList", new SimpleObjectProperty<>(SECTIONS));
        return this;
    }

    public final SimpleGaugeBuilder decimals(final int DECIMALS) {
        properties.put("decimals", new SimpleIntegerProperty(DECIMALS));
        return this;
    }
View Full Code Here

        properties.put("frameVisible", new SimpleBooleanProperty(FRAME_VISIBLE));
        return this;
    }

    public final LedBuilder interval(final int INTERVAL) {
        properties.put("interval", new SimpleIntegerProperty(INTERVAL));
        return this;
    }
View Full Code Here

TOP

Related Classes of javafx.beans.property.SimpleIntegerProperty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.