ImageDisplay

org.scalafx.extras.image.ImageDisplay
class ImageDisplay

Displays an image view with the ability to zoom in, zoom out, zoom to fit. It can be also automatically resized to the parent's size. When zoomToFit is set to true, the image is sized to fit the parent scroll pane.

Sample usage (full detains in ImageDisplayDemoApp)

object ImageDisplayDemoApp extends JFXApp3 {

 override def start(): Unit = {

   private val imageDisplay = new ImageDisplay()

   stage = new PrimaryStage {
     scene = new Scene(640, 480) {
       title = "ImageDisplay Demo"
       root = new BorderPane {
         top = new ToolBar {
           items = Seq(
             new Button("Open...") {
               onAction = () => onFileOpen()
             },
             new Button("Zoom In") {
               onAction = () => imageDisplay.zoomIn()
               disable <== imageDisplay.zoomToFit
             },
             new Button("Zoom Out") {
               onAction = () => imageDisplay.zoomOut()
               disable <== imageDisplay.zoomToFit
             },
             new ToggleButton("Zoom to fit") {
               selected <==> imageDisplay.zoomToFit
             }
           )
         }
         center = imageDisplay.view
       }
     }
   }
 }
}

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

Image rotation in degrees. The default value is 0 (no rotation). This is done after applying flip operations.

Image rotation in degrees. The default value is 0 (no rotation). This is done after applying flip operations.

Attributes

def setImage(newImage: Image): Unit
def zoomIn(): Unit

Zoom in the view.

Zoom in the view.

Attributes

def zoomOut(): Unit

Zoom out the view.

Zoom out the view.

Attributes

Concrete fields

val actualZoom: ReadOnlyDoubleProperty

Actual zoom value. It should be the same as zoom when zoomToFit==false, it may be different if zoomToFit==true

Actual zoom value. It should be the same as zoom when zoomToFit==false, it may be different if zoomToFit==true

Attributes

val flipX: BooleanProperty

Flip image on X axis, this is done before applying rotation

Flip image on X axis, this is done before applying rotation

Attributes

val flipY: BooleanProperty

Flip image on Y axis, this is done before applying rotation

Flip image on Y axis, this is done before applying rotation

Attributes

val image: ObjectProperty[Option[Image]]

Property containing image to be displayed. If null, the display will be blank (following JavaFX convention)

Property containing image to be displayed. If null, the display will be blank (following JavaFX convention)

Attributes

val overlays: ObjectProperty[Seq[Rectangle]]

Overlays displayed on the image. Changes in individual members of the overlay collection, like size or location, are not being observed. To force an update, you need to assign a new collection.

Overlays displayed on the image. Changes in individual members of the overlay collection, like size or location, are not being observed. To force an update, you need to assign a new collection.

Each rectangle represents individual overlay. Rectangle properties used to draw the overlay:

  • stroke - color/paint of the outline. If null, no outline will be drawn.
  • strokeWidth - width of the line in screen pixels. The width is maintained constant to the display, regardless of zoom.
  • fill - fill color/paint. If null, no outline will be drawn.

Note that the opacity of is controlled by opacity of the stroke and fill paint.

Attributes

val view: Node

ScalaFX node in containing this image display UI.

ScalaFX node in containing this image display UI.

Attributes

val zoom: ObjectProperty[ZoomScale]

Controls image zoom when zoomToFit is off. The value of 1 means no scaling. Values larger than 1 make image larger. Values smaller than 1 make image smaller.

Controls image zoom when zoomToFit is off. The value of 1 means no scaling. Values larger than 1 make image larger. Values smaller than 1 make image smaller.

Attributes

val zoomToFit: BooleanProperty

When set to true, the image fits to the size of the available view, maintaining its aspect ratio.

When set to true, the image fits to the size of the available view, maintaining its aspect ratio.

Attributes