Package com.ms.fx Previous
Previous
Contents
Contents
Index
Index
Next
Next

Class FxTexture

Constructors , Methods , Fields

public class FxTexture extends FxFill implements ImageObserver 
{
  // Fields
  public final static int STRETCH_NONE;
  public final static int STRETCH_MIDDLE;
  public final static int STRETCH_OUTER;
  public final static int STRETCH_ALL;
  public final static int REPEAT_PIN;
  public final static int SNAP_EDGES;

  // Constructors
  public FxTexture(Image i, int s, int l, int t, int r, int b, boolean p, int red, int green, int blue);
  public FxTexture(Image i, int s, int l, int t, int r, int b, boolean p);
  public FxTexture(Image i, int s, int l, int t, int r, int b, boolean p, FxFill f);

  // Methods
  public boolean fillRectCallback(FxGraphics g, int xStart, int yStart, int width, int height);
  public Dimension size();
  public Rectangle getInner();
  public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height);
  public int getStretch();
  public void setStretch(int s);
  public Image getImage();
  public boolean drawScanLinesCallback(FxGraphics g, boolean xChanging, int points[], int offset, int nPoints);
  public void setPinOrigin(boolean b);
  public boolean getPinOrigin();
  public void setSnapDraw(boolean b);
  public boolean getSnapDraw();
  public boolean fillRoundRectCallback(FxGraphics g, int x, int y, int width,
							 int height, int arcWidth, int arcHeight);
  public boolean fillPolygonCallback(FxGraphics g, int xPoints[], int yPoints[], int nPoints);
  public boolean fillArcCallback(FxGraphics g, int x, int y, int width,
							 int height, int startAngle, int arcAngle);
  public boolean fillOvalCallback(FxGraphics g, int x, int y, int width, int height);
}

A class that encapsulates an extended fill method, using an image to fill a shape.

The Microsoft com.ms.fx Java package is more powerful and more flexible than other graphics packages because it uses extensible objects.


Constructors


FxTexture

public FxTexture(Image i, int s, int l, int t, int r, int b, boolean p, int red, int green, int blue);

Constructs a texture with a specific default color.

ParameterDescription
i The image object.
s The value that handles image stretching.
l The left boundary.
t The top boundary.
r The right boundary.
b The bottom boundary.
p The value that determines if the image should be pinned.
red The amount of red in the color.
green The amount of green in the color.
blue The amount of blue in the color.


FxTexture

public FxTexture(Image i, int s, int l, int t, int r, int b, boolean p);

Constructs a texture.

ParameterDescription
i The image object.
s The value that handles image stretching.
l The left boundary.
t The top boundary.
r The right boundary.
b The bottom boundary.
p The value that determines if the image should be pinned.


FxTexture

public FxTexture(Image i, int s, int l, int t, int r, int b, boolean p, FxFill f);

Constructs a texture.

ParameterDescription
i The image object.
s The value that handles image stretching.
l The left boundary.
t The top boundary.
r The right boundary.
b The bottom boundary.
p The value that determines if the image should be pinned.
f The fill object to use.


Methods


fillRectCallback

public boolean fillRectCallback(FxGraphics g, int xStart, int yStart, int width, int height);

This method is used by an FxGraphics object to draw a filled rectangle.

Return Value:

Returns true if successful; otherwise, returns false.

ParameterDescription
g The graphics object to use.
xStart The x coordinate of the starting position.
yStart The y coordinate of the starting position.
width The width of the rectangle.
height The height of the rectangle.

Remarks:

This method is used by an FxGraphics object if the current color of the object is a texture. It is not intended to be called by applications. It is made public so that derived classes may extend the callback functionality.


size

public Dimension size();

Retrieves the size of the image that is associated with the texture.

Return Value:

Returns the Dimension of the image.


getInner

public Rectangle getInner();

Retrieves the bounds of the inner rectangle of the texture.

Return Value:

Returns the inner Rectangle of the texture.


imageUpdate

public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height);

Determines when an image may be drawn.

Return Value:

Returns true if the image can be drawn; otherwise, returns false.

ParameterDescription
img The image object.
infoflags The flags controlling the method.
x The x coordinate of the image's starting point.
y The y coordinate of the image's starting point.
width The width of the image.
height The height of the image.

Remarks:

Method from ImageObserver.


getStretch

public int getStretch();

Checks if the image is stretched across the surface, instead of being repeated.

Return Value:

Returns a value that determines if the image can be stretched.


setStretch

public void setStretch(int s);

Sets the stretch or the repeat value.

Return Value:

No return value.

ParameterDescription
s The value that determines if the image is stretched or repeated.


getImage

public Image getImage();

Retrieves the image.

Return Value:

Returns the image if there is one.


drawScanLinesCallback

public boolean drawScanLinesCallback(FxGraphics g, boolean xChanging, int points[], int offset, int nPoints);

This method is called by an FxGraphics object to draw a set of scan lines using this texture.

Return Value:

Returns true if successful; otherwise, returns false.

ParameterDescription
g The graphics object to use.
xChanging The direction the line should be drawn, either horizontally or vertically.
points An array of points.
offset The offset to use.
nPoints The number of points in the array.

Remarks:

This method is used by an FxGraphics object if the current color of the object is a texture. It is not intended to be called by applications. It is made public so that derived classes may extend the callback functionality.


setPinOrigin

public void setPinOrigin(boolean b);

Sets whether the image should be pinned.

Return Value:

No return value.

ParameterDescription
b The boolean value that determines whether the image should be pinned.


getPinOrigin

public boolean getPinOrigin();

Checks whether the image is pinned.

Return Value:

Returns a true if the image is pinned; otherwise, returns false.


setSnapDraw

public void setSnapDraw(boolean b);

Determines whether partial images should be repeated.

Return Value:

No return value.

ParameterDescription
b The Boolean value that determines whether partial images should be repeated.


getSnapDraw

public boolean getSnapDraw();

Checks whether partial images should be repeated.

Return Value:

Returns true if partial images should be repeated; otherwise, returns false.


fillRoundRectCallback

public boolean fillRoundRectCallback(FxGraphics g, int x, int y, int width, int height, int arcWidth, int arcHeight);

This method is called by an FxGraphics object to draw a filled, rounded rectangle.

Return Value:

Currently returns false.

Remarks:

This method is used internally and is not intended to be called by applications. It is made public so that derived classes may extend the callback functionality.


fillPolygonCallback

public boolean fillPolygonCallback(FxGraphics g, int xPoints[], int yPoints[], int nPoints);

This method is called by an FxGraphics object to draw a filled polygon.

Return Value:

Currently returns false.

Remarks:

This method is used by an FxGraphics object if the current color of the object is a texture. It is not intended to be called by applications. It is made public so that derived classes may extend the callback functionality.


fillArcCallback

public boolean fillArcCallback(FxGraphics g, int x, int y, int width, int height, int startAngle, int arcAngle);

This method is called by an FxGraphics object to draw a filled arc. The result is a pie-shaped object.

Return Value:

Currently returns false.

Remarks:

This method is used by an FxGraphics object if the current color of the object is a texture. It is not intended to be called by applications. It is made public so that derived classes may extend the callback functionality.


fillOvalCallback

public boolean fillOvalCallback(FxGraphics g, int x, int y, int width, int height);

This method is called by an FxGraphics object to draw a filled oval.

Return Value:

Currently returns false.

Remarks:

This method is used by an FxGraphics object if the current color of the object is a texture. It is not intended to be called by applications. It is made public so that derived classes may extend the callback functionality.


Fields

STRETCH_NONE
There will be no stretching done to fill the required area on the target surface. The image contained within the texture will be repeated to fill the space. If this flag is set, any guidelines will be ignored.
STRETCH_MIDDLE
When filling onto a surface, only the middle area will be stretched to fit. The border areas will retain their original dimensions.
STRETCH_OUTER
When filling onto a surface, only the middle area will be repeated to fit. The border areas will be stretched to fit the surface.
STRETCH_ALL
When filling onto a surface, the texture will be stretched to fit.
REPEAT_PIN
When repeating, tie the bitmap to the logical (0,0) instead of the upper left corner of the requested area.
SNAP_EDGES
When repeating, if the draw would result in a partial drawing of one of the edges, shrink the drawing to fix exactly.


Top© 1997 Microsoft Corporation. All rights reserved. Legal Notices.