sub_arctic.output
Class linear_gradient

java.lang.Object
  |
  +--sub_arctic.output.gradient
        |
        +--sub_arctic.output.linear_gradient

public class linear_gradient
extends gradient

A class to representing a linear gradient object. This gradient operates along an orientation line and produces an image which is semetric with respect to that line.


Field Summary
protected  float _fx1
          Cache of x1 as a float.
protected  float _fx2
          Cache of x2 as a float.
protected  float _fy1
          Cache of y1 as a float.
protected  float _fy2
          Cache of y2 as a float.
protected  int _x1
          X coordinate of first end point of orientation line.
protected  int _x2
          X coordinate of second end point of orientation line.
protected  int _y1
          Y coordinate of first end point of orientation line.
protected  int _y2
          Y coordinate of second end point of orientation line.
 
Fields inherited from class sub_arctic.output.gradient
_color_values, alpha_shift, blue_shift, green_shift, MASK_A_EQ, MASK_A_GT, MASK_A_LT, MASK_B_EQ, MASK_B_GT, MASK_B_LT, MASK_EQ, red_shift
 
Constructor Summary
linear_gradient(int[] colors, int x2_loc, int y2_loc)
          Constructor which defaults to a reference line starting at 0,0 and ending at a given point (broken out coordinate form).
linear_gradient(int[] colors, int x1_loc, int y1_loc, int x2_loc, int y2_loc)
          Constructor with broken out coordinate values.
linear_gradient(int[] colors, java.awt.Point pt2_val)
          Constructor which defaults to a reference line starting at 0,0 and ending at a given point (Point form).
linear_gradient(int[] colors, java.awt.Point pt1_val, java.awt.Point pt2_val)
          Constructor with Point values. The reference line given here establishes a coordinate system for the gradient.
linear_gradient(linear_gradient prototype, int x2_loc, int y2_loc)
          Construct from another linear_gradient defaulting to a reference line starting at 0,0 and ending at a given point (broken out coord form).
linear_gradient(linear_gradient prototype, int x1_loc, int y1_loc, int x2_loc, int y2_loc)
          Construct from another linear_gradient and broken out values.
linear_gradient(linear_gradient prototype, java.awt.Point pt2_val)
          Construct from another linear_gradient defaulting to a reference line starting at 0,0 and ending at a given point (Point form).
linear_gradient(linear_gradient prototype, java.awt.Point pt1_val, java.awt.Point pt2_val)
          Construct from another linear_gradient and Point values.
 
Method Summary
 float map_point_to_index(int ptx, int pty)
          Map the given point (expressed in the coordinate system used for the orientation line) to an index within the linear gradient color value array.
 java.awt.Point pt1()
          First end point of orientation line.
 java.awt.Point pt2()
          Second end point of orientation line.
 loaded_image render_image(int x, int y, int w, int h, int x1, int y1, int x2, int y2)
          Produce an in-memory loaded_image containing the drawing of a gradient with the same color sequence, but using a different orientation line.
 loaded_image render_image(int x, int y, int w, int h, int x1, int y1, int x2, int y2, loaded_image mask, int test_code, boolean invert, int ref_color, int outside_mask_color)
          Produce an in-memory loaded_image containing the drawing of a masked gradient with the same color sequence, but using a different orientation line.
 loaded_image render_image(int x, int y, int w, int h, java.awt.Point pt1, java.awt.Point pt2)
          Produce an in-memory loaded_image containing the drawing of a gradient with the same color sequence, but using a different orientation line.
 loaded_image render_image(int x, int y, int w, int h, java.awt.Point pt1, java.awt.Point pt2, loaded_image mask, int test_code, boolean invert, int ref_color, int outside_mask_color)
          Produce an in-memory loaded_image containing the drawing of a masked gradient with the same color sequence, but using a different orientation line.
 int[] render_to_data(int x, int y, int w, int h, int x1, int y1, int x2, int y2)
          Produce an in-memory data array (suitable for constructing an image) containing the drawing of a gradient with the same color sequence, but using a different orientation line.
 int[] render_to_data(int x, int y, int w, int h, int x1, int y1, int x2, int y2, loaded_image mask, int test_code, boolean invert, int ref_color, int outside_mask_color)
          Produce an in-memory data array (suitable for constructing an image) containing the drawing of a masked gradient with the same color sequence, but using a different orientation line.
 int[] render_to_data(int x, int y, int w, int h, java.awt.Point pt1, java.awt.Point pt2)
          Produce an in-memory data array (suitable for constructing an image) containing the drawing of a gradient with the same color sequence, but using a different orientation line.
 int[] render_to_data(int x, int y, int w, int h, java.awt.Point pt1, java.awt.Point pt2, loaded_image mask, int test_code, boolean invert, int ref_color, int outside_mask_color)
          Produce an in-memory data array (suitable for constructing an image) containing the drawing of a masked gradient with the same color sequence, but using a different orientation line.
 void set_points(int x1_val, int y1_val, int x2_val, int y2_val)
          Set both end points of orientation line.
 void set_points(java.awt.Point pnt1, java.awt.Point pnt2)
          Set both end points of orientation line.
 void set_pt1(java.awt.Point val)
          Set the first end point of orientation line.
 void set_pt2(java.awt.Point val)
          Set the second end point of orientation line.
 void set_x1(int val)
          Set the X coordinate of first end point of orientation line.
 void set_x2(int val)
          Set the X coordinate of second end point of orientation line.
 void set_y1(int val)
          Set the Y coordinate of first end point of orientation line.
 void set_y2(int val)
          Set the Y coordinate of second end point of orientation line.
 int x1()
          X coordinate of first end point of orientation line.
 int x2()
          X coordinate of second end point of orientation line.
 int y1()
          Y coordinate of first end point of orientation line.
 int y2()
          Y coordinate of second end point of orientation line.
 
Methods inherited from class sub_arctic.output.gradient
average_of_range, color_for_pixel, color_values, render_image, render_image, render_to_data, render_to_data, set_color_values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_x1

protected int _x1
X coordinate of first end point of orientation line.

_y1

protected int _y1
Y coordinate of first end point of orientation line.

_x2

protected int _x2
X coordinate of second end point of orientation line.

_y2

protected int _y2
Y coordinate of second end point of orientation line.

_fx1

protected float _fx1
Cache of x1 as a float.

_fy1

protected float _fy1
Cache of y1 as a float.

_fx2

protected float _fx2
Cache of x2 as a float.

_fy2

protected float _fy2
Cache of y2 as a float.
Constructor Detail

linear_gradient

public linear_gradient(int[] colors,
                       java.awt.Point pt1_val,
                       java.awt.Point pt2_val)
Constructor with Point values.

The reference line given here establishes a coordinate system for the gradient. Drawing of the gradient will be done with respect to these coordinates.

Parameters:
int[] - colors array of color values encoded as integers using the standard aarrggbb encoding (i.e., alpha value in the high byte, red value in the next, etc.). This array must have at least 2 values or an error will be thrown.
Point - pt1_val first point of orientation line
Point - pt2_val first point of orientation line

linear_gradient

public linear_gradient(int[] colors,
                       int x1_loc,
                       int y1_loc,
                       int x2_loc,
                       int y2_loc)
Constructor with broken out coordinate values.

The reference line given here establishes a coordinate system for the gradient. Drawing of the gradient will be done with respect to these coordinates.

Parameters:
int[] - colors array of color values encoded as integers using the standard aarrggbb encoding (i.e., alpha value in the high byte, red value in the next, etc.). This array must have at least 2 values or an error will be thrown.
int - x1_loc x coordinate of first point of orientation line
int - y1_loc y coordinate of first point of orientation line
int - x2_loc x coordinate of second point of orientation line
int - y2_loc y coordinate of second point of orientation line

linear_gradient

public linear_gradient(int[] colors,
                       java.awt.Point pt2_val)
Constructor which defaults to a reference line starting at 0,0 and ending at a given point (Point form). The reference line given here establishes a coordinate system for the gradient. Drawing of the gradient will be done with respect to these coordinates.
Parameters:
int[] - colors array of color values encoded as integers using the standard aarrggbb encoding (i.e., alpha value in the high byte, red value in the next, etc.). This array must have at least 2 values or an error will be thrown.
Point - pt2_val second point of orientation line

linear_gradient

public linear_gradient(int[] colors,
                       int x2_loc,
                       int y2_loc)
Constructor which defaults to a reference line starting at 0,0 and ending at a given point (broken out coordinate form). The reference line given here establishes a coordinate system for the gradient. Drawing of the gradient will be done with respect to these coordinates.
Parameters:
int[] - colors array of color values encoded as integers using the standard aarrggbb encoding (i.e., alpha value in the high byte, red value in the next, etc.). This array must have at least 2 values or an error will be thrown.
int - x2_loc x coordinate of second point of orientation line
int - y2_loc y coordinate of second point of orientation line

linear_gradient

public linear_gradient(linear_gradient prototype,
                       java.awt.Point pt1_val,
                       java.awt.Point pt2_val)
Construct from another linear_gradient and Point values. This constructs a new gradient with the same color sequence, but a different orientation

The reference line given here establishes a coordinate system for the gradient. Drawing of the gradient will be done with respect to these coordinates.

Parameters:
linear_gradient - prototype object that we get a color sequence from. Note: we share (not copy) the color sequence array.
Point - pt1_val first point of orientation line
Point - pt2_val first point of orientation line

linear_gradient

public linear_gradient(linear_gradient prototype,
                       int x1_loc,
                       int y1_loc,
                       int x2_loc,
                       int y2_loc)
Construct from another linear_gradient and broken out values. This constructs a new gradient with the same color sequence, but a different orientation

The reference line given here establishes a coordinate system for the gradient. Drawing of the gradient will be done with respect to these coordinates.

Parameters:
linear_gradient - prototype object that we get a color sequence from. Note: we share (not copy) the color sequence array.
int - x1_loc x coordinate of first point of orientation line
int - y1_loc y coordinate of first point of orientation line
int - x2_loc x coordinate of second point of orientation line
int - y2_loc y coordinate of second point of orientation line

linear_gradient

public linear_gradient(linear_gradient prototype,
                       java.awt.Point pt2_val)
Construct from another linear_gradient defaulting to a reference line starting at 0,0 and ending at a given point (Point form). This constructs a new gradient with the same color sequence, but a different orientation

The reference line given here establishes a coordinate system for the gradient. Drawing of the gradient will be done with respect to these coordinates.

Parameters:
linear_gradient - prototype object that we get a color sequence from. Note: we share (not copy) the color sequence array.
Point - pt2_val second point of orientation line

linear_gradient

public linear_gradient(linear_gradient prototype,
                       int x2_loc,
                       int y2_loc)
Construct from another linear_gradient defaulting to a reference line starting at 0,0 and ending at a given point (broken out coord form). This constructs a new gradient with the same color sequence, but a different orientation

The reference line given here establishes a coordinate system for the gradient. Drawing of the gradient will be done with respect to these coordinates.

Parameters:
linear_gradient - prototype object that we get a color sequence from. Note: we share (not copy) the color sequence array.
int - x2_loc x coordinate of second point of orientation line
int - y2_loc y coordinate of second point of orientation line
Method Detail

x1

public int x1()
X coordinate of first end point of orientation line.
Returns:
int the coordinate value

y1

public int y1()
Y coordinate of first end point of orientation line.
Returns:
int the coordinate value

pt1

public java.awt.Point pt1()
First end point of orientation line.
Returns:
Point the first end point

x2

public int x2()
X coordinate of second end point of orientation line.
Returns:
int the coordinate value

y2

public int y2()
Y coordinate of second end point of orientation line.
Returns:
int the coordinate value

pt2

public java.awt.Point pt2()
Second end point of orientation line.
Returns:
Point the first end point

set_x1

public void set_x1(int val)
Set the X coordinate of first end point of orientation line.
Parameters:
int - val the new coordinate value

set_y1

public void set_y1(int val)
Set the Y coordinate of first end point of orientation line.
Parameters:
int - val the new coordinate value

set_pt1

public void set_pt1(java.awt.Point val)
Set the first end point of orientation line.
Parameters:
Point - val the new endpoint value

set_x2

public void set_x2(int val)
Set the X coordinate of second end point of orientation line.
Parameters:
int - val the new coordinate value

set_y2

public void set_y2(int val)
Set the Y coordinate of second end point of orientation line.
Parameters:
int - val the new coordinate value

set_pt2

public void set_pt2(java.awt.Point val)
Set the second end point of orientation line.
Parameters:
Point - val the new endpoint value

set_points

public void set_points(int x1_val,
                       int y1_val,
                       int x2_val,
                       int y2_val)
Set both end points of orientation line.
Parameters:
int - x1_val x coordinate of the new first endpoint value
int - y1_val y coordinate of the new first endpoint value
int - x2_val x coordinate of the new second endpoint value
int - y2_val y coordinate of the new second endpoint value

set_points

public void set_points(java.awt.Point pnt1,
                       java.awt.Point pnt2)
Set both end points of orientation line.
Parameters:
Point - pnt1 the new first endpoint value
Point - pnt2 the new first endpoint value

map_point_to_index

public float map_point_to_index(int ptx,
                                int pty)
Map the given point (expressed in the coordinate system used for the orientation line) to an index within the linear gradient color value array. This finds the point on the orientation line with the closest perpendicular distance, then uses the percentage distance of that point along the orientation line to determine the index into the color value array.
Parameters:
int - ptx x coordinate of the point to be mapped
int - pty y coordinate of the point to be mapped
float - the index position (possibly fractional) that the point maps to.
Overrides:
map_point_to_index in class gradient

render_to_data

public int[] render_to_data(int x,
                            int y,
                            int w,
                            int h,
                            int x1,
                            int y1,
                            int x2,
                            int y2)
Produce an in-memory data array (suitable for constructing an image) containing the drawing of a gradient with the same color sequence, but using a different orientation line. The image will cover the indicated rectangle of the resulting gradient.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
int - x1 x coordinate of first point of orientation line
int - y1 y coordinate of first point of orientation line
int - x2 x coordinate of second point of orientation line
int - y2 y coordinate of second point of orientation line
Returns:
int[] data array holding result

render_to_data

public int[] render_to_data(int x,
                            int y,
                            int w,
                            int h,
                            java.awt.Point pt1,
                            java.awt.Point pt2)
Produce an in-memory data array (suitable for constructing an image) containing the drawing of a gradient with the same color sequence, but using a different orientation line. The image will cover the indicated rectangle of the resulting gradient.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
Point - pt1 first point of orientation line
Point - pt2 second point of orientation line
Returns:
int[] data array holding result

render_image

public loaded_image render_image(int x,
                                 int y,
                                 int w,
                                 int h,
                                 int x1,
                                 int y1,
                                 int x2,
                                 int y2)
Produce an in-memory loaded_image containing the drawing of a gradient with the same color sequence, but using a different orientation line. The image will cover the indicated rectangle of the resulting gradient.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
int - x1 x coordinate of first point of orientation line
int - y1 y coordinate of first point of orientation line
int - x2 x coordinate of second point of orientation line
int - y2 y coordinate of second point of orientation line
Returns:
loaded_image image holding result

render_image

public loaded_image render_image(int x,
                                 int y,
                                 int w,
                                 int h,
                                 java.awt.Point pt1,
                                 java.awt.Point pt2)
Produce an in-memory loaded_image containing the drawing of a gradient with the same color sequence, but using a different orientation line. The image will cover the indicated rectangle of the resulting gradient.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
Point - pt1 first point of orientation line
Point - pt2 second point of orientation line
Returns:
loaded_image image holding result

render_to_data

public int[] render_to_data(int x,
                            int y,
                            int w,
                            int h,
                            int x1,
                            int y1,
                            int x2,
                            int y2,
                            loaded_image mask,
                            int test_code,
                            boolean invert,
                            int ref_color,
                            int outside_mask_color)
Produce an in-memory data array (suitable for constructing an image) containing the drawing of a masked gradient with the same color sequence, but using a different orientation line. The image will cover the indicated rectangle of the resulting gradient.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
int - x1 x coordinate of first point of orientation line
int - y1 y coordinate of first point of orientation line
int - x2 x coordinate of second point of orientation line
int - y2 y coordinate of second point of orientation line
loaded_image - mask the mask to draw through. This must be of size w, h, or an error will be thrown.
int - test_code test done on mask pixels. Must have one of the values MASK_EQ, MASK_A_{EQ,LT,GT}, or MASK_B_{EQ,LT,GT}.
boolean - invert indicating if we should invert sense of test
int - ref_color reference color for mask test
int - outside_mask_color color to draw pixels that fall outside the mask
Returns:
int[] data array holding result

render_to_data

public int[] render_to_data(int x,
                            int y,
                            int w,
                            int h,
                            java.awt.Point pt1,
                            java.awt.Point pt2,
                            loaded_image mask,
                            int test_code,
                            boolean invert,
                            int ref_color,
                            int outside_mask_color)
Produce an in-memory data array (suitable for constructing an image) containing the drawing of a masked gradient with the same color sequence, but using a different orientation line. The image will cover the indicated rectangle of the resulting gradient.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
Point - pt1 first point of orientation line
Point - pt2 second point of orientation line
loaded_image - mask the mask to draw through. This must be of size w, h, or an error will be thrown.
int - test_code test done on mask pixels. Must have one of the values MASK_EQ, MASK_A_{EQ,LT,GT}, or MASK_B_{EQ,LT,GT}.
boolean - invert indicating if we should invert sense of test
int - ref_color reference color for mask test
int - outside_mask_color color to draw pixels that fall outside the mask
Returns:
int[] data array holding result

render_image

public loaded_image render_image(int x,
                                 int y,
                                 int w,
                                 int h,
                                 int x1,
                                 int y1,
                                 int x2,
                                 int y2,
                                 loaded_image mask,
                                 int test_code,
                                 boolean invert,
                                 int ref_color,
                                 int outside_mask_color)
Produce an in-memory loaded_image containing the drawing of a masked gradient with the same color sequence, but using a different orientation line. The image will cover the indicated rectangle of the resulting gradient.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
int - x1 x coordinate of first point of orientation line
int - y1 y coordinate of first point of orientation line
int - x2 x coordinate of second point of orientation line
int - y2 y coordinate of second point of orientation line
Point - pt1 first point of orientation line
Point - pt2 second point of orientation line
loaded_image - mask the mask to draw through. This must be of size w, h, or an error will be thrown.
int - test_code test done on mask pixels. Must have one of the values MASK_EQ, MASK_A_{EQ,LT,GT}, or MASK_B_{EQ,LT,GT}.
boolean - invert indicating if we should invert sense of test
int - ref_color reference color for mask test
int - outside_mask_color color to draw pixels that fall outside the mask
Returns:
loaded_image image holding result

render_image

public loaded_image render_image(int x,
                                 int y,
                                 int w,
                                 int h,
                                 java.awt.Point pt1,
                                 java.awt.Point pt2,
                                 loaded_image mask,
                                 int test_code,
                                 boolean invert,
                                 int ref_color,
                                 int outside_mask_color)
Produce an in-memory loaded_image containing the drawing of a masked gradient with the same color sequence, but using a different orientation line. The image will cover the indicated rectangle of the resulting gradient.
Parameters:
int - x left of result rectangle
int - y top of result rectangle
int - w width of result rectangle
int - h height of result rectangle
Point - pt1 first point of orientation line
Point - pt2 second point of orientation line
loaded_image - mask the mask to draw through. This must be of size w, h, or an error will be thrown.
int - test_code test done on mask pixels. Must have one of the values MASK_EQ, MASK_A_{EQ,LT,GT}, or MASK_B_{EQ,LT,GT}.
boolean - invert indicating if we should invert sense of test
int - ref_color reference color for mask test
int - outside_mask_color color to draw pixels that fall outside the mask
Returns:
loaded_image image holding result