ilog.util
Class IlGraphicPrim

java.lang.Object
  extended by ilog.util.IlGraphicPrim
Direct Known Subclasses:
IltGraphicPrim

public class IlGraphicPrim
extends Object

This class contains some primitive utility functions for drawing.

Since:
JTGO 3.0

Constructor Summary
protected IlGraphicPrim()
          Default constructor
 
Method Summary
static void _FillRect(Graphics g, int x1, int y1, int x2, int y2)
          Deprecated. Please use Graphics#fillRect instead.
static Image createImage(ImageProducer p)
          Creates a new image given the image producer.
static Image CreateServerSideImage(int width, int height)
          Creates an off-screen image on the server side.
static void DrawCloud(Graphics2D g, int x, int y, int width, int height)
          Draws the outline of a cloud with a line width of 1.
static void DrawDiamond(Graphics g, int x1, int y1, int x2, int y2)
          Draws the border of a diamond with thickness 1 in the current color.
static void DrawEllipse(Graphics2D g, int x, int y, int width, int height)
          Draws the outline of an ellipse with a line width of 1.
static void DrawLine(Graphics g, int x1, int y1, int x2, int y2)
          Draws a line of thickness 1 in the current color.
static void DrawLineClipX(Graphics g, int x1, int y1, int x2, int y2, int xmin, int xmax)
          Draws a line of thickness 1 in the current color, restricted to x in the range xmin <= x <= xmax.
static void DrawLineClipY(Graphics g, int x1, int y1, int x2, int y2, int ymin, int ymax)
          Draws a line of thickness 1 in the current color, restricted to y in the range ymin <= y <= ymax.
static void DrawPoint(Graphics g, int x1, int y1)
          Deprecated. Please use java.awt.Graphics#drawLine instead.
static void DrawRect(Graphics g, int x1, int y1, int x2, int y2)
          Draws a rectangle boundary with thickness 1 in the current color.
static void DrawRect(Graphics g, int x1, int y1, int x2, int y2, float thickness, int cap)
          Draws a rectangle outline with a given thickness in the current color.
static void DrawRoundRect(Graphics g, int x1, int y1, int x2, int y2, int xradius, int yradius)
          Draws an outlined rounded corner rectangle with a line width of 1.
static void FillCloud(Graphics2D g, int x, int y, int width, int height)
          Fills a cloud bounded by the specified rectangle with the current color.
static void FillEllipse(Graphics2D g, int x, int y, int width, int height)
          Fills an ellipse bounded by the specified rectangle with the current color.
static void FillRect(Graphics g, int x1, int y1, int x2, int y2)
          Draws a filled rectangle with thickness 1 in the current color.
static void FillRect(Graphics g, int x1, int y1, int x2, int y2, float thickness, int cap)
          Draws a filled rectangle with a given thickness in the current color.
static void FillRoundRect(Graphics g, int x1, int y1, int x2, int y2, int xradius, int yradius)
          Fills a rounded corner rectangle in the current color.
static Area getCloudArea(int width, int height)
          Returns an Area for a cloud with given dimensions.
static Dimension GetSize(Image image)
          Returns the size of the given Image.
static int[] GrabImage(Image image, int width, int height)
          Grabs the pixels belonging to an off-screen image into an array.
static boolean InsideRoundRect(int x, int y, int x1, int y1, int x2, int y2, int xradius, int yradius)
          Tests for containment in a rounded rectangle, including its border.
static void XORDrawRect(Graphics g, int x1, int y1, int x2, int y2)
          Draws a rectangle boundary with thickness 1 in the current color in XOR mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlGraphicPrim

protected IlGraphicPrim()
Default constructor

Method Detail

CreateServerSideImage

public static Image CreateServerSideImage(int width,
                                          int height)
Creates an off-screen image on the server side. You can then use createGraphics() to get a graphics context for drawing into the image.

Note: The resulting image is initially filled with a background color, and will not be transparent.

Parameters:
width - Must be greater than 0.
height - Must be greater than 0.

GetSize

public static Dimension GetSize(Image image)
Returns the size of the given Image.

Note that if the Image is not yet loaded, this method waits for the Image to be loaded and then returns its size.

Parameters:
image - Image being queried

GrabImage

public static int[] GrabImage(Image image,
                              int width,
                              int height)
Grabs the pixels belonging to an off-screen image into an array.

Parameters:
image - a server side image
width - must be > 0
height - must be > 0
Returns:
an array of pixel values, pixel[y*width+x] denotes the pixel (x,y), for 0 <= x < width, 0 <= y < height.

DrawPoint

public static void DrawPoint(Graphics g,
                             int x1,
                             int y1)
Deprecated. Please use java.awt.Graphics#drawLine instead.

Draws a single pixel in the current color.

Deprecated Since:
JTGO 4.0

DrawLine

public static void DrawLine(Graphics g,
                            int x1,
                            int y1,
                            int x2,
                            int y2)
Draws a line of thickness 1 in the current color.


DrawLineClipX

public static void DrawLineClipX(Graphics g,
                                 int x1,
                                 int y1,
                                 int x2,
                                 int y2,
                                 int xmin,
                                 int xmax)
Draws a line of thickness 1 in the current color, restricted to x in the range xmin <= x <= xmax. It is known that x1 <= xmin <= xmax <= x2 or x2 <= xmin <= xmax <= x1, and abs(y2-y1) <= abs(x2-x1).

Internal method or field: do not use!

DrawLineClipY

public static void DrawLineClipY(Graphics g,
                                 int x1,
                                 int y1,
                                 int x2,
                                 int y2,
                                 int ymin,
                                 int ymax)
Draws a line of thickness 1 in the current color, restricted to y in the range ymin <= y <= ymax. It is known that y1 <= ymin <= ymax <= y2 or y2 <= ymin <= ymax <= y1, and abs(x2-x1) <= abs(y2-y1).

Internal method or field: do not use!

DrawRect

public static void DrawRect(Graphics g,
                            int x1,
                            int y1,
                            int x2,
                            int y2)
Draws a rectangle boundary with thickness 1 in the current color. (x1,y1) and (x2,y2) are two opposite corners of the rectangle.


XORDrawRect

public static void XORDrawRect(Graphics g,
                               int x1,
                               int y1,
                               int x2,
                               int y2)
Draws a rectangle boundary with thickness 1 in the current color in XOR mode.

Parameters:
g -
x1 -
y1 -
x2 -
y2 -
Internal method or field: do not use!

_FillRect

public static void _FillRect(Graphics g,
                             int x1,
                             int y1,
                             int x2,
                             int y2)
Deprecated. Please use Graphics#fillRect instead.

Draws a filled rectangle with thickness 1 in the current color. (x1,y1) and (x2,y2) are two opposite corners of the rectangle. Draw nothing unless x1 <= x2 and y1 <= y2.

Deprecated Since:
JTGO 4.0

FillRect

public static void FillRect(Graphics g,
                            int x1,
                            int y1,
                            int x2,
                            int y2)
Draws a filled rectangle with thickness 1 in the current color. (x1,y1) and (x2,y2) are two opposite corners of the rectangle.


DrawRect

public static void DrawRect(Graphics g,
                            int x1,
                            int y1,
                            int x2,
                            int y2,
                            float thickness,
                            int cap)
Draws a rectangle outline with a given thickness in the current color. (x1,y1) and (x2,y2) are two opposite corners of the rectangle.


FillRect

public static void FillRect(Graphics g,
                            int x1,
                            int y1,
                            int x2,
                            int y2,
                            float thickness,
                            int cap)
Draws a filled rectangle with a given thickness in the current color. (x1,y1) and (x2,y2) are two opposite corners of the rectangle.


DrawRoundRect

public static void DrawRoundRect(Graphics g,
                                 int x1,
                                 int y1,
                                 int x2,
                                 int y2,
                                 int xradius,
                                 int yradius)
Draws an outlined rounded corner rectangle with a line width of 1. The outline is drawn using this graphics context's current color. The rectangle is defined by two opposite corners (x1,y1) and (x2,y2).

This method works around the JDK bug 4151279 for Graphics.drawRoundRect(int, int, int, int, int, int)

Parameters:
g - The graphic context.
x1 - Coordinate of the first corner defining the rectangle.
y1 - Coordinate of the first corner defining the rectangle.
x2 - Coordinate of the second corner defining the rectangle.
y2 - Coordinate of the second corner defining the rectangle.
xradius - Radius of the corners on the x axis. Must be positive.
yradius - Radius of the corners on the y axis. Must be positive.

FillRoundRect

public static void FillRoundRect(Graphics g,
                                 int x1,
                                 int y1,
                                 int x2,
                                 int y2,
                                 int xradius,
                                 int yradius)
Fills a rounded corner rectangle in the current color. The rectandle is defined by two opposite corners (x1,y1) and (x2,y2). The rounding is made by quarters of ellipses.

Note: The border is not predictable. To have a predictable border, call DrawRoundRect with the same arguments afterwards (in the same color, on in another color if you want).

Parameters:
g - The graphic context.
x1 - Coordinate of the first corner defining the rectangle.
y1 - Coordinate of the first corner defining the rectangle.
x2 - Coordinate of the second corner defining the rectangle.
y2 - Coordinate of the second corner defining the rectangle.
xradius - Radius of the corners on the x axis. Must be positive.
yradius - Radius of the corners on the y axis. Must be positive.

InsideRoundRect

public static boolean InsideRoundRect(int x,
                                      int y,
                                      int x1,
                                      int y1,
                                      int x2,
                                      int y2,
                                      int xradius,
                                      int yradius)
Tests for containment in a rounded rectangle, including its border.

Parameters:
x - Coordinate of the point being tested.
y - Coordinate of the point being tested.
x1 - Coordinate of the first corner defining the rectangle.
y1 - Coordinate of the first corner defining the rectangle.
x2 - Coordinate of the second corner defining the rectangle.
y2 - Coordinate of the second corner defining the rectangle.
xradius - Radius of the corners on the x axis. Must be positive.
yradius - Radius of the corners on the y axis. Must be positive.

DrawEllipse

public static void DrawEllipse(Graphics2D g,
                               int x,
                               int y,
                               int width,
                               int height)
Draws the outline of an ellipse with a line width of 1. The result is a circle or ellipse that fits within the rectangle specified by the x, y, width, and height arguments.

The oval covers an area that is width pixels wide and height pixels tall.

This method works around the JDK bug 4151279 for Graphics.drawOval(int, int, int, int)

Parameters:
g - the graphic context.
x - the x coordinate of the upper left corner of the oval to be drawn.
y - the y coordinate of the upper left corner of the oval to be drawn.
width - the width of the oval to be drawn.
height - the height of the oval to be drawn.
Since:
JTGO 4.5

FillEllipse

public static void FillEllipse(Graphics2D g,
                               int x,
                               int y,
                               int width,
                               int height)
Fills an ellipse bounded by the specified rectangle with the current color.

This method works around the JDK bug 4151279 for Graphics.drawOval(int, int, int, int)

Parameters:
g - the graphic context.
x - the x coordinate of the upper left corner of the oval to be filled.
y - the y coordinate of the upper left corner of the oval to be filled.
width - the width of the oval to be filled.
height - the height of the oval to be filled.
Since:
JTGO 4.5

DrawCloud

public static void DrawCloud(Graphics2D g,
                             int x,
                             int y,
                             int width,
                             int height)
Draws the outline of a cloud with a line width of 1. The result is a cloud that fits within the rectangle specified by the x, y, width, and height arguments.

This method works around the JDK bug 4151279.

Parameters:
g - the graphic context.
x - the x coordinate of the upper left corner of the cloud to be drawn.
y - the y coordinate of the upper left corner of the cloud to be drawn.
width - the width of the cloud to be drawn.
height - the height of the cloud to be drawn.
Internal method or field: do not use!

FillCloud

public static void FillCloud(Graphics2D g,
                             int x,
                             int y,
                             int width,
                             int height)
Fills a cloud bounded by the specified rectangle with the current color.

This method works around the JDK bug 4151279

Parameters:
g - the graphic context.
x - the x coordinate of the upper left corner of the cloud to be filled.
y - the y coordinate of the upper left corner of the cloud to be filled.
width - the width of the cloud to be filled.
height - the height of the cloud to be filled.
Internal method or field: do not use!

getCloudArea

public static Area getCloudArea(int width,
                                int height)
Returns an Area for a cloud with given dimensions.

Parameters:
width - The width of the cloud
height - The height of the cloud
Returns:
An Area describing a cloud with the given dimensions.
Internal method or field: do not use!

DrawDiamond

public static void DrawDiamond(Graphics g,
                               int x1,
                               int y1,
                               int x2,
                               int y2)
Draws the border of a diamond with thickness 1 in the current color. (x1,y1) and (x2,y2) are two opposite corners of the bounding rectangle of the diamond. For best results, the differences x2-x1 and y2-y1 should be even integers.


createImage

public static Image createImage(ImageProducer p)
Creates a new image given the image producer.

Parameters:
p - Image producer
Returns:
Image
Since:
JViews 7.5


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.