Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+19 votes

I'm trying to get the image in imageView to always be located at the point 0,0 in imageView.

Here's the code in our method InitializeAfterSceneCreated that pertains to the sizing

videoView.fitWidthProperty().bind(videoPane.widthProperty().subtract(sideBarPane.widthProperty()));
	videoView.fitHeightProperty().bind(videoPane.heightProperty().subtract(topBarPane.heightProperty()));
	//videoView.fitWidthProperty().addListener((obs, oldV, newV) -> repaintCanvas());
	//videoView.fitHeightProperty().addListener((obs, oldV, newV) -> repaintCanvas());
	
	videoView.fitWidthProperty().bind(videoPane.getScene().widthProperty().subtract(sideBarPane.widthProperty()));
	
	//videoView.setLayoutX(0-videoView.getLayoutX());
	//videoView.setLayoutY(0-videoView.getLayoutY());
	//videoView.setTranslateX(videoView.getLayoutX()+sideBarPane.getWidth());
	//videoView.setTranslateY(videoView.getLayoutY()+topBarPane.getHeight());
asked in CSC285_Fall2018 by (1 point)

1 Answer

+5 votes
 
Best answer

Honestly, I think it may be simplest to replace your ImageView (videoView) with another Canvas, get the GraphicsContext from that Canvas, and manually call gc.drawImage(myImage,0,0,width,height) to draw the image whenever you need it drawn.

That way the image you display will always be starting at 0,0.

You lose the auto-scaling functionality that ImageView has by using a Canvas to display the image, but in the end auto-scaling wasn't very useful for us anyway, since we need to know how much scaling is taking place anyway!

(I helped another group with this, and it took surprisingly little time to replace the ImageView with a canvas...)

answered by (3.2k points)
selected by
...