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


Java Color.decode方法代码示例

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


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

示例1: decodeColor

import java.awt.Color; //导入方法依赖的package包/类
public static Color decodeColor(String color, Color defaultColor) {
    String colorVal = "";
    if (color.length() > 0) {
        colorVal = color.trim();
        if (colorVal.startsWith("#"))
            colorVal = colorVal.substring(1);            
        try {
            colorVal = new Integer(Integer.parseInt(colorVal, 16)).toString();
            return Color.decode(colorVal.toLowerCase());
        }
        catch (Exception ex) {
  ex.printStackTrace();
 }
    }
    else return defaultColor;
    return getColorForName(color, defaultColor);
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:18,代码来源:Util.java

示例2: main

import java.awt.Color; //导入方法依赖的package包/类
public static void main(String[] args) 
{
	JPanel header = new ColorPanel( Color.decode("#C6C6C6"), new Dimension(900, 64) ); 
	JPanel navbar = new ColorPanel( Color.decode("#444444"), new Dimension(200, 550) );
	JPanel contentPanel = new ColorPanel( Color.decode("#EEEEEE"), new Dimension(700, 550) );

	JFrame frame = new JFrame("Example App Layout");
	frame.setLayout( new SlickLayout() ); 
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 

	//first row
	frame.add( header, new SlickConstraint(0, SlickConstraint.HorizontalFill, SlickConstraint.VerticalPack) );

	//second row
	frame.add( navbar, new SlickConstraint(1, SlickConstraint.HorizontalPack, SlickConstraint.VerticalFill) );
	frame.add( contentPanel, new SlickConstraint(1, SlickConstraint.HorizontalFill, SlickConstraint.VerticalFill) );

	frame.pack();
	frame.setVisible(true);
}
 
开发者ID:jpxor,项目名称:slick,代码行数:21,代码来源:Example_AppLayout.java

示例3: hexToColor

import java.awt.Color; //导入方法依赖的package包/类
/**
  * Convert a "#FFFFFF" hex string to a Color.
  * If the color specification is bad, an attempt
  * will be made to fix it up.
  */
static final Color hexToColor(String value) {
    String digits;
    int n = value.length();
    if (value.startsWith("#")) {
        digits = value.substring(1, Math.min(value.length(), 7));
    } else {
        digits = value;
    }
    String hstr = "0x" + digits;
    Color c;
    try {
        c = Color.decode(hstr);
    } catch (NumberFormatException nfe) {
        c = null;
    }
     return c;
 }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:CSS.java

示例4: StickerDialog

import java.awt.Color; //导入方法依赖的package包/类
public StickerDialog(Frame frame, String text, String backcolor, String forecolor, int sP, int size){
	super(frame, Local.getString("Sticker"), true);
	try {
		jbInit();
		pack();
	} catch (Exception ex) {
		new ExceptionDialog(ex);
	}
	stickerText.setText(text);
	Color back = Color.decode(backcolor);
	Color front = Color.decode(forecolor);
	int i = findColorIndex(back);
	if (i > -1)
		stickerColor.setSelectedIndex(i);
	else
		stickerColor.setSelectedIndex(10);
	i = findColorIndex(front);
	if (i > -1)
		textColor.setSelectedIndex(i);
	else
		textColor.setSelectedIndex(stickerColor.getSelectedIndex()+1);
	if (sP > -1 && sP < 5)
		priorityList.setSelectedIndex(sP);
	else
		priorityList.setSelectedIndex(2);
	if(size==10)
		fontSize.setSelectedIndex(0);
	else if(size == 20)
		fontSize.setSelectedIndex(2);
	else fontSize.setSelectedIndex(1);
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:32,代码来源:StickerDialog.java

示例5: StickerExpand

import java.awt.Color; //导入方法依赖的package包/类
public StickerExpand(Frame frame,String txt, String backcolor, String fontcolor, String priority) {
	super(frame, Local.getString("Sticker")+" ["+priority+"]" , true);
	this.txt=txt;
	this.backGroundColor=Color.decode(backcolor);
	this.foreGroundColor=Color.decode(fontcolor);
	try {
		jbInit();
		pack();
	} catch (Exception ex) {
		new ExceptionDialog(ex);
	}
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:13,代码来源:StickerExpand.java

示例6: parse

import java.awt.Color; //导入方法依赖的package包/类
@Override
public Color parse(String value) {
	if (value.length() == 9) {
		int r = Integer.parseInt(value.substring(1, 3), 16);
		int g = Integer.parseInt(value.substring(3, 5), 16);
		int b = Integer.parseInt(value.substring(5, 7), 16);
		int a = Integer.parseInt(value.substring(7, 9), 16);
		return new Color(r, g, b, a);
	} else {
		return Color.decode(value);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:13,代码来源:Attributes.java

示例7: findColor

import java.awt.Color; //导入方法依赖的package包/类
/**
 * Searches for a color with a given name or key, given as a string. The
 * color is searched using the following criteria:
 * <ul>
 * <li> If the name is one of the keys in <tt>getColorMap()</tt> then the
 * corresponding key is returned;
 * <li> Otherwise, if the name is a system property (recognised by
 * <tt>Color.getColor(String)</tt>) then the corresponding color is
 * returned;
 * <li> Otherwise, if the name is a color key recognised by
 * <tt>Color.decode(String)</tt>) then the corresponding color is
 * returned;
 * <li> Otherwise, if the name is a space-separated sequence of three or
 * four byte values standing for the red, green and blue components, and
 * optionally an alpha value, then the corresponding color is returned using
 * the appropriate <tt>Color</tt> method;
 * <li> Otherwise, the color cannot be found and <tt>null</tt> is
 * returned.
 * </ul>
 * @param name the name or key under which the color is sought
 * @return the color found for <tt>name</tt>, or <tt>null</tt> if no
 *         such color is found.
 * @see #getColorMap()
 * @see Color#getColor(String)
 */
public static Color findColor(String name) {
    if (colorMap.containsKey(name)) {
        return colorMap.get(name);
    }
    Color result = Color.getColor(name);
    if (result != null) {
        return result;
    }
    try {
        return Color.decode(name);
    } catch (NumberFormatException exc) {
        // proceed
    }
    // try decompose the color as a sequence of red green blue [alpha]
    int[] val = Groove.toIntArray(name);
    if (val == null) {
        val = Groove.toIntArray(name, ",");
    }
    if (val != null) {
        if (val.length == 3) {
            return new Color(norm(val[0]), norm(val[1]), norm(val[2]));
        } else if (val.length == 4) {
            return new Color(norm(val[0]), norm(val[1]), norm(val[2]),
                norm(val[3]));
        }
    }
    return null;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:54,代码来源:Colors.java

示例8: getTransparentColor

import java.awt.Color; //导入方法依赖的package包/类
@Override
public Color getTransparentColor() {
  if (this.transparentcolor != null && !this.transparentcolor.isEmpty()) {
    return Color.decode(this.transparentcolor);
  }

  return null;
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:9,代码来源:ImageLayer.java

示例9: load

import java.awt.Color; //导入方法依赖的package包/类
@Override
public IEntity load(IMapObject mapObject) {
  if (MapObjectType.get(mapObject.getType()) != MapObjectType.LIGHTSOURCE) {
    throw new IllegalArgumentException("Cannot load a mapobject of the type " + mapObject.getType() + " with a loader of the type " + LightSourceMapObjectLoader.class);
  }

  final int brightness = mapObject.getCustomPropertyInt(MapObjectProperty.LIGHTBRIGHTNESS);
  final int intensity = mapObject.getCustomPropertyInt(MapObjectProperty.LIGHTINTENSITY);
  final String mapObjectColor = mapObject.getCustomProperty(MapObjectProperty.LIGHTCOLOR);
  final String mapObjectLightOn = mapObject.getCustomProperty(MapObjectProperty.LIGHTACTIVE);
  final String lightShape = mapObject.getCustomProperty(MapObjectProperty.LIGHTSHAPE);
  if (mapObjectColor == null || mapObjectColor.isEmpty() || lightShape == null) {
    return null;
  }

  final Color color = Color.decode(mapObjectColor);

  String lightType;
  switch (lightShape) {
  case LightSource.ELLIPSE:
    lightType = LightSource.ELLIPSE;
    break;
  case LightSource.RECTANGLE:
    lightType = LightSource.RECTANGLE;
    break;
  default:
    lightType = LightSource.ELLIPSE;
  }
  boolean lightOn = mapObjectLightOn == null || mapObjectLightOn.isEmpty() ? true : Boolean.parseBoolean(mapObjectLightOn);
  final LightSource light = new LightSource(brightness, intensity, new Color(color.getRed(), color.getGreen(), color.getBlue(), brightness), lightType, lightOn);
  light.setSize((float) mapObject.getDimension().getWidth(), (float) mapObject.getDimension().getHeight());
  light.setLocation(mapObject.getLocation());
  light.setMapId(mapObject.getId());
  light.setName(mapObject.getName());

  return light;
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:38,代码来源:LightSourceMapObjectLoader.java

示例10: buttonColorActionPerformed

import java.awt.Color; //导入方法依赖的package包/类
private void buttonColorActionPerformed(
    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonColorActionPerformed

    final JDialog di = new JDialog(this, true);
    di.setTitle(getLocaleMessage("dialog.select_color"));
    final JColorChooser cc = new JColorChooser(
        Color.decode("#" + textFieldFontColor.getText()));
    di.setSize(450, 440);
    LayoutManager l = new FlowLayout(2, 10, 10);
    di.setLayout(l);
    di.add(cc);
    final JButton but = new JButton(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            textFieldFontColor
                .setText(
                    Integer.toHexString(cc.getColor().getRGB()).substring(2).toUpperCase());
            runningLabel.setForeground(Color.decode("#" + textFieldFontColor.getText()));
            di.setVisible(false);
        }
    });
    but.setText(getLocaleMessage("dialog.select"));
    but.setSize(20, 20);
    di.add(but);
    Uses.setLocation(di);
    di.setVisible(true);

}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:30,代码来源:FBoardParams.java

示例11: execute

import java.awt.Color; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
    String title = ":information_source: Stats of **"+event.getSelfUser().getName()+"**:";
    Color color;
    String os = ManagementFactory.getPlatformMXBean(com.sun.management.OperatingSystemMXBean.class).getName();
    String arch = ManagementFactory.getPlatformMXBean(com.sun.management.OperatingSystemMXBean.class).getArch();
    String version = ManagementFactory.getPlatformMXBean(com.sun.management.OperatingSystemMXBean.class).getVersion();
    os = os+" "+arch+" "+version;
    int cpus = Runtime.getRuntime().availableProcessors();
    String processCpuLoad = new DecimalFormat("###.###%").format(ManagementFactory.getPlatformMXBean(com.sun.management.OperatingSystemMXBean.class).getProcessCpuLoad());
    String systemCpuLoad = new DecimalFormat("###.###%").format(ManagementFactory.getPlatformMXBean(com.sun.management.OperatingSystemMXBean.class).getSystemCpuLoad());
    long ramUsed = ((Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory()) / (1024 * 1024));

    if(event.isFromType(ChannelType.PRIVATE))
        color = Color.decode("#33ff00");
    else
        color = event.getGuild().getSelfMember().getColor();
    
    EmbedBuilder builder = new EmbedBuilder();
    builder.addField("<:windows:371075985996775425> OS: ", os, true);
    builder.addField(":computer: RAM usage: ", ramUsed+"MB", true);
    builder.addField(":gear: CPU usage: ", processCpuLoad+" / "+systemCpuLoad+" ("+cpus+" Cores)", true);
    builder.addField(":map: Guilds: ", ""+event.getJDA().getGuilds().size() , true);
    builder.addField(":speech_balloon: Text Channels: ", ""+event.getJDA().getTextChannels().size(), true);
    builder.addField(":speaker: Voice Channels: ", ""+event.getJDA().getVoiceChannels().size(), true);
    builder.addField(":bust_in_silhouette: Users: ", ""+event.getJDA().getUsers().size(), true);
    builder.setFooter(event.getSelfUser().getName(), event.getSelfUser().getEffectiveAvatarUrl());
    builder.setColor(color);
    event.getChannel().sendMessage(new MessageBuilder().append(title).setEmbed(builder.build()).build()).queue();
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:32,代码来源:Stats.java

示例12: StickerDialog

import java.awt.Color; //导入方法依赖的package包/类
public StickerDialog(Frame frame, String text, String backcolor, 
		             String forecolor, int sP, int size){
	super(frame, Local.getString("Sticker"), true);
	try {
		jbInit();
		pack();
	} catch (Exception ex) {
		new ExceptionDialog(ex);
	}
	stickerText.setText(text);
	Color back = Color.decode(backcolor);
	Color front = Color.decode(forecolor);
	int i = findColorIndex(back);
	if (i > -1)
		stickerColor.setSelectedIndex(i);
	else
		stickerColor.setSelectedIndex(10);
	i = findColorIndex(front);
	if (i > -1)
		textColor.setSelectedIndex(i);
	else
		textColor.setSelectedIndex(stickerColor.getSelectedIndex()+1);
	if (sP > -1 && sP < 5)
		priorityList.setSelectedIndex(sP);
	else
		priorityList.setSelectedIndex(2);
	if(size==10)
		fontSize.setSelectedIndex(0);
	else if(size == 20)
		fontSize.setSelectedIndex(2);
	else fontSize.setSelectedIndex(1);
}
 
开发者ID:ser316asu,项目名称:SER316-Munich,代码行数:33,代码来源:StickerDialog.java

示例13: parseValue

import java.awt.Color; //导入方法依赖的package包/类
@Override
public Color parseValue(String value, ClassLoader classLoader, Plugin provider) {
	return Color.decode(value.trim());
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:5,代码来源:ClassColorMap.java

示例14: sessionColor

import java.awt.Color; //导入方法依赖的package包/类
public void sessionColor(XML_Menu itemC) {
	String c = itemC.color.toString();
	Color c2 = Color.decode(c);
	sessionColor.setBackground(c2);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:6,代码来源:LayerManager.java

示例15: execute

import java.awt.Color; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
    Color color;
    Config config = null;
    
    if(event.isFromType(ChannelType.PRIVATE))
        color = Color.decode("#33ff00");
    else
        color = event.getGuild().getSelfMember().getColor();

    try
    {
        config = new Config();
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
    
   String title = ":information_source: Information about **"+event.getSelfUser().getName()+"**";
   EmbedBuilder builder = new EmbedBuilder();
   User owner = event.getJDA().getUserById(config.getOwnerId());
   String ownername = owner.getName()+"#"+owner.getDiscriminator();
   String ownerid = owner.getId();


          builder.setDescription("Hi, I'm Endless! A multipurpose bot designed to be smart.\n"
          		+ "If you found a bug please contact my dad\n"
          		+ "("+Const.DEV+")!\n");
          builder.addField(":bust_in_silhouette: Owner:", "**"+ownername+"** (**"+ownerid+"**)", false);
          builder.addField("<:jda:325395909347115008>  Library:", "Java Discord API (JDA) "+JDAInfo.VERSION+" and JDA Utilities "+JDAUtilitiesInfo.VERSION, false);
          builder.addField("<:github:326118305062584321> GitHub:", "Did you found a bug? Want improve something?\n"
          		+ "Please open an Issue or create a PR on GitHub\n"
          		+ "**https://github.com/ArtutoGamer/Endless**\n", false);
          builder.addField(":link: Support Guild:", "**[Support]("+Const.INVITE+")**\n", false);
          builder.setFooter("Version: "+Const.VERSION+" | Latest Start", null);
          builder.setColor(color);
          builder.setTimestamp(event.getClient().getStartTime());
          builder.setThumbnail(event.getSelfUser().getAvatarUrl());
          event.getChannel().sendMessage(new MessageBuilder().append(title).setEmbed(builder.build()).build()).queue();
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:43,代码来源:About.java


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