Example usage for java.awt Component getGraphics

List of usage examples for java.awt Component getGraphics

Introduction

In this page you can find the example usage for java.awt Component getGraphics.

Prototype

public Graphics getGraphics() 

Source Link

Document

Creates a graphics context for this component.

Usage

From source file:self.philbrown.javaQuery.$.java

/**
 * For each selected view, if its alpha is less than 0.5, it will fade in. Otherwise, it will
 * fade out.// w w  w . j  a v a 2s  . c  o  m
 * @param duration the length of time the animation should last
 * @param complete the function to call when the animation has completed
 */
public void fadeToggle(long duration, final Function complete) {
    List<Component> zeros = new ArrayList<Component>();
    List<Component> ones = new ArrayList<Component>();
    for (Component view : this.views) {
        if (view.getGraphics().getColor().getAlpha() < 0.5)
            zeros.add(view);
        else
            ones.add(view);
    }
    $.with(zeros).fadeIn(duration, complete);
    $.with(ones).fadeOut(duration, complete);
}

From source file:self.philbrown.javaQuery.$.java

/**
 * If this {@link #view} has an alpha of less than 0.5, it will fade in. Otherwise, it will
 * fade out./* ww w.  j a va 2s  .  c o m*/
 * @param options use to modify the behavior of the animation
 */
public void fadeToggle(AnimationOptions options) {
    List<Component> zeros = new ArrayList<Component>();
    List<Component> ones = new ArrayList<Component>();
    for (Component view : this.views) {
        if (view.getGraphics().getColor().getAlpha() < 0.5)
            zeros.add(view);
        else
            ones.add(view);
    }
    $.with(zeros).fadeIn(options);
    $.with(ones).fadeOut(options);
}