Doubts on LinearGradient#proportional=true

Pavel Safrata pavel.safrata at oracle.com
Fri Jun 8 07:44:41 PDT 2012


Hi Tom,
did you forget to attach the image or did the system strip it somewhere 
along the way? I executed your code and saw exactly what you expected - 
gradient in the left half of the rectangle, what do you see? By the way, 
the code uses proportional=false, unlike suggested in the description, 
so please try to clarify your question.
Thanks,
Pavel

On 8.6.2012 16:33, Tom Schindl wrote:
> Hi,
>
> I'm not sure if i understood proportional true wrong or I'm found a
> serious bug.
>
>> import java.util.ArrayList;
>> import java.util.List;
>>
>> import javafx.application.Application;
>> import javafx.scene.Group;
>> import javafx.scene.Scene;
>> import javafx.scene.paint.Color;
>> import javafx.scene.paint.CycleMethod;
>> import javafx.scene.paint.LinearGradient;
>> import javafx.scene.paint.Stop;
>> import javafx.scene.shape.Rectangle;
>> import javafx.stage.Stage;
>>
>> public class TestGradient extends Application {
>>
>> 	/**
>> 	 * @param args
>> 	 */
>> 	public static void main(String[] args) {
>> 		launch(args);
>> 	}
>>
>> 	@Override
>> 	public void start(Stage primaryStage) throws Exception {
>> 		Group g = new Group();
>> 		Rectangle r = new Rectangle(40,0,90,75);
>> 		List<Stop>  stops = new ArrayList<Stop>();
>> 		stops.add(new Stop(0, Color.RED));
>> 		stops.add(new Stop(1, Color.BLUE));
>> 		LinearGradient lg = new LinearGradient(0, 0, 90, 0, false, CycleMethod.NO_CYCLE, stops);
>> 		r.setFill(lg);
>> 		g.getChildren().add(r);
>> 		Scene s = new Scene(g,200,200);
>> 		primaryStage.setScene(s);
>> 		primaryStage.show();
>> 	}
>>
>> }
> Running this code gives me an UI like shown in the attached screenshot.
> Is this really the right behaviour? I'd expect red to start on the left
> of the rect and end at 1/2 of the width.
>
> Tom
>


More information about the openjfx-dev mailing list