@DefaultProperty(value="image") public class ImageView extends Node
ImageView
は、Image
クラスでロードされたイメージを描画するために使用するNode
です。
このクラスでは、表示されるイメージのサイズ変更(元の縦横比を維持することも、しないことも可能)と、このImageView
で表示されるピクセルを制限するためのソース・イメージに対するビューポートの指定が可能です。
イメージを表示するためのコードの例
import javafx.application.Application;
import javafx.geometry.Rectangle2D;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class HelloMenu extends Application {
@Override public void start(Stage stage) {
// load the image
Image image = new Image("flower.png");
// simple displays ImageView the image as is
ImageView iv1 = new ImageView();
iv1.setImage(image);
// resizes the image to have width of 100 while preserving the ratio and using
// higher quality filtering method; this ImageView is also cached to
// improve performance
ImageView iv2 = new ImageView();
iv2.setImage(image);
iv2.setFitWidth(100);
iv2.setPreserveRatio(true);
iv2.setSmooth(true);
iv2.setCache(true);
// defines a viewport into the source image (achieving a "zoom" effect) and
// displays it rotated
ImageView iv3 = new ImageView();
iv3.setImage(image);
Rectangle2D viewportRect = new Rectangle2D(40, 35, 110, 110);
iv3.setViewport(viewportRect);
iv3.setRotate(90);
Group root = new Group();
Scene scene = new Scene(root);
scene.setFill(Color.BLACK);
HBox box = new HBox();
box.getChildren().add(iv1);
box.getChildren().add(iv2);
box.getChildren().add(iv3);
root.getChildren().add(box);
stage.setTitle("ImageView");
stage.setWidth(415);
stage.setHeight(200);
stage.setScene(scene);
stage.sizeToScene();
stage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}
前述のコードにより、次の出力が生成されます。
Type | プロパティと説明 |
---|---|
DoubleProperty |
fitHeight
境界ボックスの高さ(これに合せて必要なだけソース・イメージのサイズを変更)。
|
DoubleProperty |
fitWidth
境界ボックスの幅(これに合せて必要なだけソース・イメージのサイズを変更)。
|
ObjectProperty<Image> |
image
この
ImageView によって描画されるImage 。 |
BooleanProperty |
preserveRatio
調整境界ボックス内でイメージが適合するようにスケーリングするときに、ソース・イメージの縦横比を維持するかどうかを示します。
|
BooleanProperty |
smooth
fitWidth とfitHeight で指定した境界ボックス内に収まるようにソース・イメージを変換する際またはスケーリングする際に、より高品質なフィルタリング・アルゴリズムまたは高速なアルゴリズムを使用するかどうかを示します。 |
ObjectProperty<Rectangle2D> |
viewport
イメージに対する矩形ビューポート。
|
DoubleProperty |
x
ImageView の原点の現在のx座標。 |
DoubleProperty |
y
ImageView の原点の現在のy座標。 |
accessibleHelp、accessibleRoleDescription、accessibleRole、accessibleText、blendMode、boundsInLocal、boundsInParent、cacheHint、cache、clip、cursor、depthTest、disabled、disable、effectiveNodeOrientation、effect、eventDispatcher、focused、focusTraversable、hover、id、inputMethodRequests、layoutBounds、layoutX、layoutY、localToParentTransform、localToSceneTransform、managed、mouseTransparent、nodeOrientation、onContextMenuRequested、onDragDetected、onDragDone、onDragDropped、onDragEntered、onDragExited、onDragOver、onInputMethodTextChanged、onKeyPressed、onKeyReleased、onKeyTyped、onMouseClicked、onMouseDragEntered、onMouseDragExited、onMouseDragged、onMouseDragOver、onMouseDragReleased、onMouseEntered、onMouseExited、onMouseMoved、onMousePressed、onMouseReleased、onRotate、onRotationFinished、onRotationStarted、onScrollFinished、onScroll、onScrollStarted、onSwipeDown、onSwipeLeft、onSwipeRight、onSwipeUp、onTouchMoved、onTouchPressed、onTouchReleased、onTouchStationary、onZoomFinished、onZoom、onZoomStarted、opacity、parent、pickOnBounds、pressed、rotate、rotationAxis、scaleX、scaleY、scaleZ、scene、style、translateX、translateY、translateZ、visible
修飾子と型 | フィールドと説明 |
---|---|
static boolean |
SMOOTH_DEFAULT
smooth プロパティのプラットフォームに依存するデフォルト値。 |
BASELINE_OFFSET_SAME_AS_HEIGHT
コンストラクタと説明 |
---|
ImageView()
新しいImageViewオブジェクトを割り当てます。
|
ImageView(Image image)
指定されたイメージを使用して新しいImageViewオブジェクトを割り当てます。
|
ImageView(String url)
指定されたURLからロードされるイメージを使用して新しいImageViewオブジェクトを割り当てます。
|
修飾子と型 | メソッドと説明 |
---|---|
DoubleProperty |
fitHeightProperty()
境界ボックスの高さ(これに合せて必要なだけソース・イメージのサイズを変更)。
|
DoubleProperty |
fitWidthProperty()
境界ボックスの幅(これに合せて必要なだけソース・イメージのサイズを変更)。
|
static List<CssMetaData<? extends Styleable,?>> |
getClassCssMetaData() |
List<CssMetaData<? extends Styleable,?>> |
getCssMetaData()
NodeのCssMetaDataがリフレクションなしでアクセス可能になるように、このメソッドは
Node.getClassCssMetaData() に委任する必要があります。 |
double |
getFitHeight()
プロパティfitHeightの値を取得します。
|
double |
getFitWidth()
プロパティfitWidthの値を取得します。
|
Image |
getImage()
プロパティimageの値を取得します。
|
Rectangle2D |
getViewport()
プロパティviewportの値を取得します。
|
double |
getX()
プロパティxの値を取得します。
|
double |
getY()
プロパティyの値を取得します。
|
ObjectProperty<Image> |
imageProperty()
この
ImageView によって描画されるImage 。 |
boolean |
isPreserveRatio()
プロパティpreserveRatioの値を取得します。
|
boolean |
isSmooth()
プロパティsmoothの値を取得します。
|
BooleanProperty |
preserveRatioProperty()
調整境界ボックス内でイメージが適合するようにスケーリングするときに、ソース・イメージの縦横比を維持するかどうかを示します。
|
void |
setFitHeight(double value)
プロパティfitHeightの値を設定します。
|
void |
setFitWidth(double value)
プロパティfitWidthの値を設定します。
|
void |
setImage(Image value)
プロパティimageの値を設定します。
|
void |
setPreserveRatio(boolean value)
プロパティpreserveRatioの値を設定します。
|
void |
setSmooth(boolean value)
プロパティsmoothの値を設定します。
|
void |
setViewport(Rectangle2D value)
プロパティviewportの値を設定します。
|
void |
setX(double value)
プロパティxの値を設定します。
|
void |
setY(double value)
プロパティyの値を設定します。
|
BooleanProperty |
smoothProperty()
fitWidth とfitHeight で指定した境界ボックス内に収まるようにソース・イメージを変換する際またはスケーリングする際に、より高品質なフィルタリング・アルゴリズムまたは高速なアルゴリズムを使用するかどうかを示します。 |
ObjectProperty<Rectangle2D> |
viewportProperty()
イメージに対する矩形ビューポート。
|
DoubleProperty |
xProperty()
ImageView の原点の現在のx座標。 |
DoubleProperty |
yProperty()
ImageView の原点の現在のy座標。 |
accessibleHelpProperty、accessibleRoleDescriptionProperty、accessibleRoleProperty、accessibleTextProperty、addEventFilter、addEventHandler、applyCss、autosize、blendModeProperty、boundsInLocalProperty、boundsInParentProperty、buildEventDispatchChain、cacheHintProperty、cacheProperty、clipProperty、computeAreaInScreen、contains、contains、cursorProperty、depthTestProperty、disabledProperty、disableProperty、effectiveNodeOrientationProperty、effectProperty、eventDispatcherProperty、executeAccessibleAction、fireEvent、focusedProperty、focusTraversableProperty、getAccessibleHelp、getAccessibleRole、getAccessibleRoleDescription、getAccessibleText、getBaselineOffset、getBlendMode、getBoundsInLocal、getBoundsInParent、getCacheHint、getClip、getContentBias、getCursor、getDepthTest、getEffect、getEffectiveNodeOrientation、getEventDispatcher、getId、getInputMethodRequests、getLayoutBounds、getLayoutX、getLayoutY、getLocalToParentTransform、getLocalToSceneTransform、getNodeOrientation、getOnContextMenuRequested、getOnDragDetected、getOnDragDone、getOnDragDropped、getOnDragEntered、getOnDragExited、getOnDragOver、getOnInputMethodTextChanged、getOnKeyPressed、getOnKeyReleased、getOnKeyTyped、getOnMouseClicked、getOnMouseDragEntered、getOnMouseDragExited、getOnMouseDragged、getOnMouseDragOver、getOnMouseDragReleased、getOnMouseEntered、getOnMouseExited、getOnMouseMoved、getOnMousePressed、getOnMouseReleased、getOnRotate、getOnRotationFinished、getOnRotationStarted、getOnScroll、getOnScrollFinished、getOnScrollStarted、getOnSwipeDown、getOnSwipeLeft、getOnSwipeRight、getOnSwipeUp、getOnTouchMoved、getOnTouchPressed、getOnTouchReleased、getOnTouchStationary、getOnZoom、getOnZoomFinished、getOnZoomStarted、getOpacity、getParent、getProperties、getPseudoClassStates、getRotate、getRotationAxis、getScaleX、getScaleY、getScaleZ、getScene、getStyle、getStyleableParent、getStyleClass、getTransforms、getTranslateX、getTranslateY、getTranslateZ、getTypeSelector、getUserData、hasProperties、hoverProperty、idProperty、inputMethodRequestsProperty、intersects、intersects、isCache、isDisable、isDisabled、isFocused、isFocusTraversable、isHover、isManaged、isMouseTransparent、isPickOnBounds、isPressed、isResizable、isVisible、layoutBoundsProperty、layoutXProperty、layoutYProperty、localToParent、localToParent、localToParent、localToParent、localToParent、localToParentTransformProperty、localToScene、localToScene、localToScene、localToScene、localToScene、localToScene、localToScene、localToScene、localToScene、localToScene、localToSceneTransformProperty、localToScreen、localToScreen、localToScreen、localToScreen、localToScreen、lookup、lookupAll、managedProperty、maxHeight、maxWidth、minHeight、minWidth、mouseTransparentProperty、nodeOrientationProperty、notifyAccessibleAttributeChanged、onContextMenuRequestedProperty、onDragDetectedProperty、onDragDoneProperty、onDragDroppedProperty、onDragEnteredProperty、onDragExitedProperty、onDragOverProperty、onInputMethodTextChangedProperty、onKeyPressedProperty、onKeyReleasedProperty、onKeyTypedProperty、onMouseClickedProperty、onMouseDragEnteredProperty、onMouseDragExitedProperty、onMouseDraggedProperty、onMouseDragOverProperty、onMouseDragReleasedProperty、onMouseEnteredProperty、onMouseExitedProperty、onMouseMovedProperty、onMousePressedProperty、onMouseReleasedProperty、onRotateProperty、onRotationFinishedProperty、onRotationStartedProperty、onScrollFinishedProperty、onScrollProperty、onScrollStartedProperty、onSwipeDownProperty、onSwipeLeftProperty、onSwipeRightProperty、onSwipeUpProperty、onTouchMovedProperty、onTouchPressedProperty、onTouchReleasedProperty、onTouchStationaryProperty、onZoomFinishedProperty、onZoomProperty、onZoomStartedProperty、opacityProperty、parentProperty、parentToLocal、parentToLocal、parentToLocal、parentToLocal、parentToLocal、pickOnBoundsProperty、prefHeight、prefWidth、pressedProperty、pseudoClassStateChanged、queryAccessibleAttribute、relocate、removeEventFilter、removeEventHandler、requestFocus、resize、resizeRelocate、rotateProperty、rotationAxisProperty、scaleXProperty、scaleYProperty、scaleZProperty、sceneProperty、sceneToLocal、sceneToLocal、sceneToLocal、sceneToLocal、sceneToLocal、sceneToLocal、sceneToLocal、sceneToLocal、screenToLocal、screenToLocal、screenToLocal、setAccessibleHelp、setAccessibleRole、setAccessibleRoleDescription、setAccessibleText、setBlendMode、setCache、setCacheHint、setClip、setCursor、setDepthTest、setDisable、setDisabled、setEffect、setEventDispatcher、setEventHandler、setFocused、setFocusTraversable、setHover、setId、setInputMethodRequests、setLayoutX、setLayoutY、setManaged、setMouseTransparent、setNodeOrientation、setOnContextMenuRequested、setOnDragDetected、setOnDragDone、setOnDragDropped、setOnDragEntered、setOnDragExited、setOnDragOver、setOnInputMethodTextChanged、setOnKeyPressed、setOnKeyReleased、setOnKeyTyped、setOnMouseClicked、setOnMouseDragEntered、setOnMouseDragExited、setOnMouseDragged、setOnMouseDragOver、setOnMouseDragReleased、setOnMouseEntered、setOnMouseExited、setOnMouseMoved、setOnMousePressed、setOnMouseReleased、setOnRotate、setOnRotationFinished、setOnRotationStarted、setOnScroll、setOnScrollFinished、setOnScrollStarted、setOnSwipeDown、setOnSwipeLeft、setOnSwipeRight、setOnSwipeUp、setOnTouchMoved、setOnTouchPressed、setOnTouchReleased、setOnTouchStationary、setOnZoom、setOnZoomFinished、setOnZoomStarted、setOpacity、setPickOnBounds、setPressed、setRotate、setRotationAxis、setScaleX、setScaleY、setScaleZ、setStyle、setTranslateX、setTranslateY、setTranslateZ、setUserData、setVisible、snapshot、snapshot、startDragAndDrop、startFullDrag、styleProperty、toBack、toFront、toString、translateXProperty、translateYProperty、translateZProperty、usesMirroring、visibleProperty
public final ObjectProperty<Image> imageProperty
ImageView
によって描画されるImage
。getImage()
、setImage(Image)
public final DoubleProperty xProperty
ImageView
の原点の現在のx座標。getX()
、setX(double)
public final DoubleProperty yProperty
ImageView
の原点の現在のy座標。getY()
、setY(double)
public final DoubleProperty fitWidthProperty
fitWidth
としてイメージの固有の幅が使用されます。
イメージ・ビューのfitWidth
、fitHeight
およびpreserveRatio
属性の間の通信の詳細は、preserveRatio
を参照してください。getFitWidth()
、setFitWidth(double)
public final DoubleProperty fitHeightProperty
fitHeight
としてイメージの固有の高さが使用されます。
イメージ・ビューのfitWidth
、fitHeight
およびpreserveRatio
属性の間の通信の詳細は、preserveRatio
を参照してください。
getFitHeight()
、setFitHeight(double)
public final BooleanProperty preserveRatioProperty
true
に設定されている場合は、このImageView
のディメンションに、次のように影響します。*
fitWidth
のみが設定されている場合、比率を維持するように高さがスケーリングされます。
fitHeight
のみが設定されている場合、比率を維持するように幅がスケーリングされます。
false
に設定されている場合は、このImageView
のディメンションに、次のように影響します。*
fitWidth
のみが設定されている場合、イメージのビューの幅が一致するようにスケーリングされ、高さは変更されません。
fitHeight
のみが設定されている場合、イメージのビューの高さが一致するようにスケーリングされ、高さは変更されません。
fitWidth x fitHeight
境界ボックス内に含まれることが保証されます。isPreserveRatio()
、setPreserveRatio(boolean)
public final BooleanProperty smoothProperty
fitWidth
とfitHeight
で指定した境界ボックス内に収まるようにソース・イメージを変換する際またはスケーリングする際に、より高品質なフィルタリング・アルゴリズムまたは高速なアルゴリズムを使用するかどうかを示します。
true
に設定されている場合は、より高品質なフィルタリングが使用され、false
に設定されている場合は、より高速ですが比較的低品質なフィルタリングが使用されます。
デフォルト値はプラットフォーム構成によって異なります。
isSmooth()
、setSmooth(boolean)
public final ObjectProperty<Rectangle2D> viewportProperty
viewport
がnull
の場合は、イメージ全体が表示されます。viewport
がnull
以外の場合は、ビューポート内に収まるイメージの一部のみが表示されます。イメージがビューポートを完全にカバーしていない場合は、ビューポートの残りの領域が空になります。
getViewport()
、setViewport(Rectangle2D)
public static final boolean SMOOTH_DEFAULT
smooth
プロパティのプラットフォームに依存するデフォルト値。public ImageView()
public ImageView(String url)
new ImageView(url)
は、new ImageView(new Image(url))
と同じ効果を持ちます。
url
- イメージのロード元のURLを表す文字列NullPointerException
- URLがnullの場合IllegalArgumentException
- URLが無効かサポートされていない場合public ImageView(Image image)
image
- このImageViewが使用するイメージpublic final void setImage(Image value)
ImageView
によって描画されるImage
。public final Image getImage()
ImageView
によって描画されるImage
。public final ObjectProperty<Image> imageProperty()
ImageView
によって描画されるImage
。getImage()
、setImage(Image)
public final void setX(double value)
ImageView
の原点の現在のx座標。public final double getX()
ImageView
の原点の現在のx座標。public final DoubleProperty xProperty()
ImageView
の原点の現在のx座標。getX()
、setX(double)
public final void setY(double value)
ImageView
の原点の現在のy座標。public final double getY()
ImageView
の原点の現在のy座標。public final DoubleProperty yProperty()
ImageView
の原点の現在のy座標。getY()
、setY(double)
public final void setFitWidth(double value)
fitWidth
としてイメージの固有の幅が使用されます。
イメージ・ビューのfitWidth
、fitHeight
およびpreserveRatio
属性の間の通信の詳細は、preserveRatio
を参照してください。public final double getFitWidth()
fitWidth
としてイメージの固有の幅が使用されます。
イメージ・ビューのfitWidth
、fitHeight
およびpreserveRatio
属性の間の通信の詳細は、preserveRatio
を参照してください。public final DoubleProperty fitWidthProperty()
fitWidth
としてイメージの固有の幅が使用されます。
イメージ・ビューのfitWidth
、fitHeight
およびpreserveRatio
属性の間の通信の詳細は、preserveRatio
を参照してください。getFitWidth()
、setFitWidth(double)
public final void setFitHeight(double value)
fitHeight
としてイメージの固有の高さが使用されます。
イメージ・ビューのfitWidth
、fitHeight
およびpreserveRatio
属性の間の通信の詳細は、preserveRatio
を参照してください。
public final double getFitHeight()
fitHeight
としてイメージの固有の高さが使用されます。
イメージ・ビューのfitWidth
、fitHeight
およびpreserveRatio
属性の間の通信の詳細は、preserveRatio
を参照してください。
public final DoubleProperty fitHeightProperty()
fitHeight
としてイメージの固有の高さが使用されます。
イメージ・ビューのfitWidth
、fitHeight
およびpreserveRatio
属性の間の通信の詳細は、preserveRatio
を参照してください。
getFitHeight()
、setFitHeight(double)
public final void setPreserveRatio(boolean value)
true
に設定されている場合は、このImageView
のディメンションに、次のように影響します。*
fitWidth
のみが設定されている場合、比率を維持するように高さがスケーリングされます。
fitHeight
のみが設定されている場合、比率を維持するように幅がスケーリングされます。
false
に設定されている場合は、このImageView
のディメンションに、次のように影響します。*
fitWidth
のみが設定されている場合、イメージのビューの幅が一致するようにスケーリングされ、高さは変更されません。
fitHeight
のみが設定されている場合、イメージのビューの高さが一致するようにスケーリングされ、高さは変更されません。
fitWidth x fitHeight
境界ボックス内に含まれることが保証されます。public final boolean isPreserveRatio()
true
に設定されている場合は、このImageView
のディメンションに、次のように影響します。*
fitWidth
のみが設定されている場合、比率を維持するように高さがスケーリングされます。
fitHeight
のみが設定されている場合、比率を維持するように幅がスケーリングされます。
false
に設定されている場合は、このImageView
のディメンションに、次のように影響します。*
fitWidth
のみが設定されている場合、イメージのビューの幅が一致するようにスケーリングされ、高さは変更されません。
fitHeight
のみが設定されている場合、イメージのビューの高さが一致するようにスケーリングされ、高さは変更されません。
fitWidth x fitHeight
境界ボックス内に含まれることが保証されます。public final BooleanProperty preserveRatioProperty()
true
に設定されている場合は、このImageView
のディメンションに、次のように影響します。*
fitWidth
のみが設定されている場合、比率を維持するように高さがスケーリングされます。
fitHeight
のみが設定されている場合、比率を維持するように幅がスケーリングされます。
false
に設定されている場合は、このImageView
のディメンションに、次のように影響します。*
fitWidth
のみが設定されている場合、イメージのビューの幅が一致するようにスケーリングされ、高さは変更されません。
fitHeight
のみが設定されている場合、イメージのビューの高さが一致するようにスケーリングされ、高さは変更されません。
fitWidth x fitHeight
境界ボックス内に含まれることが保証されます。isPreserveRatio()
、setPreserveRatio(boolean)
public final void setSmooth(boolean value)
fitWidth
とfitHeight
で指定した境界ボックス内に収まるようにソース・イメージを変換する際またはスケーリングする際に、より高品質なフィルタリング・アルゴリズムまたは高速なアルゴリズムを使用するかどうかを示します。
true
に設定されている場合は、より高品質なフィルタリングが使用され、false
に設定されている場合は、より高速ですが比較的低品質なフィルタリングが使用されます。
デフォルト値はプラットフォーム構成によって異なります。
public final boolean isSmooth()
fitWidth
とfitHeight
で指定した境界ボックス内に収まるようにソース・イメージを変換する際またはスケーリングする際に、より高品質なフィルタリング・アルゴリズムまたは高速なアルゴリズムを使用するかどうかを示します。
true
に設定されている場合は、より高品質なフィルタリングが使用され、false
に設定されている場合は、より高速ですが比較的低品質なフィルタリングが使用されます。
デフォルト値はプラットフォーム構成によって異なります。
public final BooleanProperty smoothProperty()
fitWidth
とfitHeight
で指定した境界ボックス内に収まるようにソース・イメージを変換する際またはスケーリングする際に、より高品質なフィルタリング・アルゴリズムまたは高速なアルゴリズムを使用するかどうかを示します。
true
に設定されている場合は、より高品質なフィルタリングが使用され、false
に設定されている場合は、より高速ですが比較的低品質なフィルタリングが使用されます。
デフォルト値はプラットフォーム構成によって異なります。
isSmooth()
、setSmooth(boolean)
public final void setViewport(Rectangle2D value)
viewport
がnull
の場合は、イメージ全体が表示されます。viewport
がnull
以外の場合は、ビューポート内に収まるイメージの一部のみが表示されます。イメージがビューポートを完全にカバーしていない場合は、ビューポートの残りの領域が空になります。
public final Rectangle2D getViewport()
viewport
がnull
の場合は、イメージ全体が表示されます。viewport
がnull
以外の場合は、ビューポート内に収まるイメージの一部のみが表示されます。イメージがビューポートを完全にカバーしていない場合は、ビューポートの残りの領域が空になります。
public final ObjectProperty<Rectangle2D> viewportProperty()
viewport
がnull
の場合は、イメージ全体が表示されます。viewport
がnull
以外の場合は、ビューポート内に収まるイメージの一部のみが表示されます。イメージがビューポートを完全にカバーしていない場合は、ビューポートの残りの領域が空になります。
getViewport()
、setViewport(Rectangle2D)
public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
public List<CssMetaData<? extends Styleable,?>> getCssMetaData()
Node.getClassCssMetaData()
に委任する必要があります。getCssMetaData
、インタフェース: Styleable
getCssMetaData
、クラス: Node
Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.