managerView.setBlinkingMode(IlvManagerView.BLINKING_DISABLED);
graphic.setBlinkingOnPeriod(1000); graphic.setBlinkingOffPeriod(2000);
java.awt.Color color = new IlvBlinkingColor(Color.green, Color.blue, 1000, 1000); IlvLine line = new IlvLine(); line.setForeground(color);
Color color = new IlvBlinkingMultiColor(1000, Color.blue, Color.red, Color.green, Color.yellow); Paint redGreen = new GradientPaint(0, 0, Color.red, 0, 100, Color.green); Paint blueYellow = new GradientPaint(0, 0, Color.blue, 100, 0, Color.yellow); Paint blackWhite = new GradientPaint(0, 0, Color.black, 0, 100, Color.white); Paint paint1 = new IlvBlinkingPaint(redGreen, blueYellow, 1000, 2000); Paint paint2 = new IlvBlinkingMultiPaint(1000, redGreen, blueYellow, blackWhite);
paint1
switches between
2 gradient paints, it stays 1 second red-green, then 2 seconds blue-yellow. paint2
switches
every second between 3 gradient paints. void registerBlinkingResource(Object oldResource, Object newResource);
import ilog.views.internal.impl.IlvUtility2D; /** * A new class. */ public class MyClass extends IlvGraphic { // the default color is not a blinking color private static Color _defaultColor = Color.black; private Color _color = _defaultColor; private Paint _paint = _defaultColor; /** * The default constructor. */ public MyClass() { super(); // the default color black does not blink, hence // no blinking resource must be registered. } /** * The copy constructor. */ public MyClass(MyClass source) { super(source); Color oldColor = _color; Paint oldPaint = _paint; _color = source._color; _paint = source._paint; registerBlinkingResource(oldColor, _color); registerBlinkingResource(oldPaint, _paint); // or alternatively // setColor(source.getColor()); // setPaint(source.getPaint()); // then omit the additional calls of registerBlinkingResource } /** * The input stream constructor. */ public MyClass(IlvInputStream stream) throws IlvReadFileException { super(stream); Color oldColor = _color; Paint oldPaint = _paint; _color = stream.readColor("color"); _paint = stream.readPaint("paint"); registerBlinkingResource(oldColor, _color); registerBlinkingResource(oldPaint, _paint); // or alternatively // setColor(stream.readColor("color")); // setPaint(IlvUtility2D.readPaint(stream, "paint", "p")); // then omit the additional calls of registerBlinkingResource } /** * Writes the object to an IVL file. */ public void write(IlvOutputStream stream) throws IOException { super.write(stream); stream.write("color", _color); stream.writePaint(_paint, "paint", _defaultColor); } /** * Sets the color. * As Bean Property, you can use the property editor * ilog.views.util.beans.editor.IlvBlinkingColorPropertyEditor * which supports blinking. */ public void setColor(Color c) { if (c == null) c = _defaultColor; Color oldColor = _color; _color = c; registerBlinkingResource(oldColor, c); } /** * Returns the color. */ public Color getColor() { return _color; } /** * Sets the color. * As Bean Property, you can use the property editor * ilog.views.util.beans.editor.IlvBlinkingPaintPropertyEditor * which supports blinking. */ public void setPaint(Paint p) { if (p == null) p = _defaultColor; Paint oldPaint = _paint; _paint = p; registerBlinkingResource(oldPaint, c); } /** * Returns the paint. */ public Paint getPaint() { return _paint; } }
IlvMarker marker = new IlvMarker(); IlvBlinkingAction action = new IlvBlinkingAction(1000,1000) { protected void changeState(IlvGraphic obj, boolean isOn) { // no applyToObject necessary because the caller does it already for us IlvMarker marker = (IlvMarker)obj; if (isOn) { marker.setType(IlvMarker.IlvMarkerCircle); } else { marker.setType(IlvMarker.IlvMarkerSquare); } } }; marker.setBlinkingAction(action);