当前位置: 首页>>代码示例>>Java>>正文


Java Color.getAlpha方法代码示例

本文整理汇总了Java中java.awt.Color.getAlpha方法的典型用法代码示例。如果您正苦于以下问题:Java Color.getAlpha方法的具体用法?Java Color.getAlpha怎么用?Java Color.getAlpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Color的用法示例。


在下文中一共展示了Color.getAlpha方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: check

import java.awt.Color; //导入方法依赖的package包/类
private static void check(Color color, JSONObject json) {
    Object red = json.get("r"); // NOI18N
    int redExpected = color.getRed();
    assertEquals(redExpected, red);

    Object green = json.get("g"); // NOI18N
    int greenExpected = color.getGreen();
    assertEquals(greenExpected, green);

    Object blue = json.get("b"); // NOI18N
    int blueExpected = color.getBlue();
    assertEquals(blueExpected, blue);

    Object alpha = json.get("a"); // NOI18N
    int alphaExpected = color.getAlpha();
    if (alphaExpected == 255) {
        assertNull(alpha);
    } else {
        assertNotNull(alpha);
        assertTrue(alpha instanceof Number);
        double alphaValue = ((Number)alpha).doubleValue()*255;
        assertEquals(alphaExpected, Math.round(alphaValue));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:HighlightConfigTest.java

示例2: _formatObject

import java.awt.Color; //导入方法依赖的package包/类
private String _formatObject(
  FacesContext context,
  Color color
  )
{
  if (color != null)
  {
     boolean isTrans = isTransparentAllowed();
    if (isTrans && color.getAlpha() == 0)
      return getTransparentString(context);

    return _getFormattingColorFormat().format(color);
  }
  else
  {
    return null;
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:19,代码来源:ColorConverter.java

示例3: getClosestChatColor

import java.awt.Color; //导入方法依赖的package包/类
private static ChatColor getClosestChatColor(final Color color) {
    if (color.getAlpha() < 128) {
        return null;
    }
    for (int i = 0; i < ImageMessage.colors.length; ++i) {
        if (areIdentical(ImageMessage.colors[i], color)) {
            return ChatColor.values()[i];
        }
    }
    int index = 0;
    double best = -1.0;
    for (int j = 0; j < ImageMessage.colors.length; ++j) {
        final double distance = getDistance(color, ImageMessage.colors[j]);
        if (distance < best || best == -1.0) {
            best = distance;
            index = j;
        }
    }
    return ChatColor.values()[index];
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:21,代码来源:ImageMessage.java

示例4: instantiate

import java.awt.Color; //导入方法依赖的package包/类
@Override
protected Expression instantiate(Object oldInstance, Encoder enc) {
    Color color = (Color) oldInstance;
    return new Expression(oldInstance, oldInstance.getClass(),
            BeansUtils.NEW, new Object[] { color.getRed(),
                    color.getGreen(), color.getBlue(), color.getAlpha() });
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:8,代码来源:AwtColorPersistenceDelegate.java

示例5: ParsedColor

import java.awt.Color; //导入方法依赖的package包/类
public ParsedColor(Color color, String toString)
{
  super(color.getRed(),
        color.getGreen(),
        color.getBlue(),
        color.getAlpha());

  _toString = toString;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:10,代码来源:Coercions.java

示例6: findColorIndex

import java.awt.Color; //导入方法依赖的package包/类
protected int findColorIndex(ColorNode aNode, Color aColor) {
    if (transparency != Transparency.OPAQUE &&
        aColor.getAlpha() != 0xff)
    {
        return 0; // default transparnt pixel
    }

    if (aNode.isLeaf) {
        return aNode.paletteIndex;
    } else {
        int childIndex = getBranchIndex(aColor, aNode.level);

        return findColorIndex(aNode.children[childIndex], aColor);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:PaletteBuilder.java

示例7: colorToRGBA

import java.awt.Color; //导入方法依赖的package包/类
/**
 * Converts the given color into a JSONObject in {@code DOM.RGBA} format.
 * 
 * @param color color to convert.
 * @return color in {@code DOM.RGBA} format.
 */
static JSONObject colorToRGBA(Color color) {
    JSONObject object = new JSONObject();
    object.put("r", color.getRed()); // NOI18N
    object.put("g", color.getGreen()); // NOI18N
    object.put("b", color.getBlue()); // NOI18N
    if (color.getAlpha() != 255) {
        object.put("a", color.getAlpha()/255.0); // NOI18N
    }
    return object;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:HighlightConfig.java

示例8: getColors

import java.awt.Color; //导入方法依赖的package包/类
private List <Color> getColors (Color background)
{
  List <Color> o = backgroundColors.get (background);
  
  if (o != null) {
    return o;
  }
  
  List <Color> colors = new ArrayList <Color> (steps + 1);
  colors.add (background);
  
  int rDelta = (background.getRed () - fadeColor.getRed ()) / steps;
  int gDelta = (background.getGreen () - fadeColor.getGreen ()) / steps;
  int bDelta = (background.getBlue () - fadeColor.getBlue ()) / steps;
  int aDelta = (background.getAlpha () - fadeColor.getAlpha ()) / steps;
  
  for (int i = 1; i < steps; i++) {
    int rValue = background.getRed () - (i * rDelta);
    int gValue = background.getGreen () - (i * gDelta);
    int bValue = background.getBlue () - (i * bDelta);
    int aValue = background.getAlpha () - (i * aDelta);
    
    colors.add (new Color (rValue, gValue, bValue, aValue));
  }
  
  colors.add (fadeColor);
  backgroundColors.put (background, colors);
  
  return colors;
}
 
开发者ID:Plasmoxy,项目名称:AquamarineLake,代码行数:31,代码来源:MaterialUIMovement.java

示例9: _getInlineStyleForColor

import java.awt.Color; //导入方法依赖的package包/类
private static String _getInlineStyleForColor(
  Color color)
{
  if (color != null && color.getAlpha() > 0)
    return "background-color:" + CSSUtils.getColorValue(color);

  return null;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:9,代码来源:SimpleInputColorRenderer.java

示例10: deriveARGB

import java.awt.Color; //导入方法依赖的package包/类
/**
 * Derives the ARGB value for a color based on an offset between two
 * other colors.
 *
 * @param color1   The first color
 * @param color2   The second color
 * @param midPoint The offset between color 1 and color 2, a value of 0.0 is
 *                 color 1 and 1.0 is color 2;
 * @return the ARGB value for a new color based on this derivation
 */
static int deriveARGB(Color color1, Color color2, float midPoint) {
    int r = color1.getRed() +
            Math.round((color2.getRed() - color1.getRed()) * midPoint);
    int g = color1.getGreen() +
            Math.round((color2.getGreen() - color1.getGreen()) * midPoint);
    int b = color1.getBlue() +
            Math.round((color2.getBlue() - color1.getBlue()) * midPoint);
    int a = color1.getAlpha() +
            Math.round((color2.getAlpha() - color1.getAlpha()) * midPoint);
    return ((a & 0xFF) << 24) |
            ((r & 0xFF) << 16) |
            ((g & 0xFF) << 8) |
            (b & 0xFF);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:NimbusLookAndFeel.java

示例11: ColorBuilder

import java.awt.Color; //导入方法依赖的package包/类
public ColorBuilder(int hex) {
    Color fromHex = new Color(hex);
    this.red = fromHex.getRed();
    this.green = fromHex.getGreen();
    this.blue = fromHex.getBlue();
    this.alpha = fromHex.getAlpha();
}
 
开发者ID:Ygore,项目名称:bit-client,代码行数:8,代码来源:ColorBuilder.java

示例12: createColorTag

import java.awt.Color; //导入方法依赖的package包/类
/**
 * Returns a HTML span tag that imposes a given colour on a text.
 */
static public HTMLTag createColorTag(Color color) {
    HTMLTag result = colorTagMap.get(color);
    if (result == null) {
        StringBuffer arg = new StringBuffer();
        int red = color.getRed();
        int blue = color.getBlue();
        int green = color.getGreen();
        int alpha = color.getAlpha();
        arg.append("color: rgb(");
        arg.append(red);
        arg.append(",");
        arg.append(green);
        arg.append(",");
        arg.append(blue);
        arg.append(");");
        if (alpha != MAX_ALPHA) {
            // the following is taken from the internet; it is to make
            // sure that all html interpretations set the opacity correctly.
            double alphaFraction = ((double) alpha) / MAX_ALPHA;
            arg.append("float:left;filter:alpha(opacity=");
            arg.append((int) (100 * alphaFraction));
            arg.append(");opacity:");
            arg.append(alphaFraction);
            arg.append(";");
        }
        result = HTMLConverter.createSpanTag(arg.toString());
        colorTagMap.put(color, result);
    }
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:34,代码来源:HTMLConverter.java

示例13: CorInversa

import java.awt.Color; //导入方法依赖的package包/类
public static Color CorInversa(Color cor) {
    int A = cor.getAlpha();
    int R = 255 - cor.getRed();
    int G = 255 - cor.getGreen();
    int B = 255 - cor.getBlue();
    return new Color(R, G, B, A);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:8,代码来源:Utilidades.java

示例14: _getSurroundingColor

import java.awt.Color; //导入方法依赖的package包/类
private Color _getSurroundingColor(Color color)
{
  if ((color == null) || (color.getAlpha() == 0))
    return CacheUtils.TRANSPARENT_COLOR;

  return color;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:8,代码来源:CompositeButtonKey.java

示例15: glColor

import java.awt.Color; //导入方法依赖的package包/类
public void glColor(final Color color) {
	final float red = color.getRed() / 255F, green = color.getGreen() / 255F, blue = color.getBlue() / 255F,
			alpha = color.getAlpha() / 255F;
	glColor4f(red, green, blue, alpha);
}
 
开发者ID:Moudoux,项目名称:EMC,代码行数:6,代码来源:IFont.java


注:本文中的java.awt.Color.getAlpha方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。