mr3d.visualization
Class Graph2D

java.lang.Object
  extended bymr3d.visualization.Graph2D

public abstract class Graph2D
extends java.lang.Object

Graph2D implements some basic functionality for working with drawing graphical primitives to the device display as well as methods for working with colors.

Since:
MR3Dv1.0
Version:
10-2004
Author:
Manuel Ruelke

Field Summary
static int screenHeight
          Stores the height of the screen.
static int screenWidth
          Stores the width of the screen.
 
Constructor Summary
Graph2D()
           
 
Method Summary
static void fillTriangle(Graphics g, int colorCode, int x1, int y1, int x2, int y2, int x3, int y3)
          Draws a triangle on the specified Graphics object filled with the specified color.
static int getColor(int red, int green, int blue)
          Calculates the int-color code derived from the three specified red, green and blue components.
static int[] getColorComponents(int colorCode)
          Calculates the separate color components from a specified color code.
static int mixColors(int colorCode1, int colorCode2)
          Mixes two colors 1 to 1.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

screenHeight

public static int screenHeight
Stores the height of the screen.


screenWidth

public static int screenWidth
Stores the width of the screen.

Constructor Detail

Graph2D

public Graph2D()
Method Detail

fillTriangle

public static final void fillTriangle(Graphics g,
                                      int colorCode,
                                      int x1,
                                      int y1,
                                      int x2,
                                      int y2,
                                      int x3,
                                      int y3)
Draws a triangle on the specified Graphics object filled with the specified color.

Parameters:
g - Graphics object to draw on
colorCode - color the triangle should be drawn with
x1 - x-coordinate of point 1
y1 - y-coordinate of point 1
x2 - x-coordinate of point 2
y2 - y-coordinate of point 2
x3 - x-coordinate of point 3
y3 - y-coordinate of point 3

getColor

public static final int getColor(int red,
                                 int green,
                                 int blue)
Calculates the int-color code derived from the three specified red, green and blue components. A color code is a value between 0 (black) and 16.777.215 (white).

Parameters:
red - red component of the color to be calculated
green - green component of the color to be calculated
blue - blue component of the color to be calculated
Returns:
color code calculated from the three color components

getColorComponents

public static final int[] getColorComponents(int colorCode)
Calculates the separate color components from a specified color code. The result will be returned in an int-array with 3 components(0=red, 1=green, 2=blue).

Parameters:
colorCode - color code to extract the color componets from
Returns:
color components as int-array with 3 components

mixColors

public static final int mixColors(int colorCode1,
                                  int colorCode2)
Mixes two colors 1 to 1.

Parameters:
colorCode1 - first color code
colorCode2 - second color code
Returns:
colorCode of mix of the two colors