ilog.views.util.java2d
Class IlvContrastingColor

ilog.views.util.java2d.IlvContrastingColor

public class IlvContrastingColor

This class denotes a color that depends on the background. It can take two different colors. When the background is bright, it presents itself as a dark color. When the background is dark, it behaves like a bright color.

Note: This class can only be used in graphic objects and renderers that have explicit support for it. Most graphic objects and renderers in JViews do not support it.

Note: In order to add support for IlvContrastingColor to a drawing routine with a background filled entirely with a known color, the following code template can be used:

    Color backgroundColor = ...;
    Graphics2D g = ...;
    Color oldPaint = g.getPaint();
    try {
      g.setPaint(contrastingColor.chooseColor(backgroundColor);
      ...
    } finally {
      g.setPaint(oldPaint);
    }
  

Note: In order to add support for IlvContrastingColor to a drawing routine with an unknown background, the following code template can be used:

    Color backgroundColor = ...;
    Graphics2D g = ...;
    Color oldPaint = g.getPaint();
    Composite oldComposite = g.getComposite();
    try {
      g.setPaint(Color.black);
      g.setComposite(contrastingColor);
      ...
    } finally {
      g.setPaint(oldPaint);
      g.setComposite(oldComposite);
    }
  

Note: IlvContrastingColor is a custom implementation of Composite. Due to Sun JRE bug #4833528, custom Composites work only when rendering into a BufferedImage. This is the case


CSS example:

ilvContrastingColor {
    class : "ilog.views.util.java2d.IlvContrastingColor(darkColor,brightColor,threshold)";
    brightColor : "green";
    darkColor : "green";
    threshold : "2.0";
}


Property Summary
 java.awt.Color brightColor
          
Sets the color used in front of dark background.
 java.lang.String class
          
Creates a contrasting color with the given dark and bright color.
 java.awt.Color darkColor
          
Sets the color used in front of bright background.
 float threshold
          
Sets the brightness limit used to distinguish whether the background is considered as bright or dark.
 

Property Detail

class

public java.lang.String class

Creates a contrasting color with the given dark and bright color.

CSS example:     class : "ilog.views.util.java2d.IlvContrastingColor(darkColor,brightColor,threshold)";


brightColor

public java.awt.Color brightColor

Sets the color used in front of dark background.

CSS example:     brightColor : "green";

A color can either be a string representing a color or else an octal or hexadecimal string that starts with the character "#" or else a comma separated "RGB" value where the integer values are in the range 0..255.


darkColor

public java.awt.Color darkColor

Sets the color used in front of bright background.

CSS example:     darkColor : "green";

A color can either be a string representing a color or else an octal or hexadecimal string that starts with the character "#" or else a comma separated "RGB" value where the integer values are in the range 0..255.


threshold

public float threshold

Sets the brightness limit used to distinguish whether the background is considered as bright or dark.

CSS example:     threshold : "2.0";



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