public class

Background

extends Object
implements Anchor ScaleType
java.lang.Object
   ↳ com.neomades.graphics.Background

Class Overview

A background represents a non focusable rectangular region contained within a view.

It cannot be instantiated directly. Different types of backgrounds can be created by calling the following methods in this class.

Summary

[Expand]
Inherited Constants
From interface com.neomades.graphics.Anchor
From interface com.neomades.graphics.ScaleType
Public Methods
static Background createWithImage(int resImage, int scaleType)
Create a background with an image.
static Background createWithImage(Image resImage, int scaleType)
Create a background with an image.
static Background createWithLinearGradient(int startAnchor, int endAnchor, Color startColor, Color endColor)
Create a linear gradient background.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Background createWithImage (int resImage, int scaleType)

Create a background with an image. The image will occupy the space available as defined by the scale type parameter.

Parameters
resImage the image to display in background
scaleType the scale type to apply: STRETCH, SCALE_ASPECT_FILL or SCALE_ASPECT_FIT
Returns
  • a background with an image

public static Background createWithImage (Image resImage, int scaleType)

Create a background with an image. The image will occupy the space available as defined by the scale type parameter.

Background can be created with null as image. In that case, if applied, it will remove the current background of the component.

Parameters
resImage the image to display in background
scaleType the scale type to apply: STRETCH, SCALE_ASPECT_FILL or SCALE_ASPECT_FIT
Returns
  • a background with an image

public static Background createWithLinearGradient (int startAnchor, int endAnchor, Color startColor, Color endColor)

Create a linear gradient background. Colors could be only opaque.

To parameterize linear gradient, two points of color should be provided. Each point is located in the edge of the background. The linear gradient will be computed thanks to both points.

Parameters
startAnchor first point location (e.g. TOP or TOP|LEFT)
endAnchor second point location (e.g. BOTTOM or BOTTOM|RIGHT)
startColor first point color (only opaque)
endColor second point color (only opaque)
Returns
  • a background with 2 colors linear gradient
See Also