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


Java Color类代码示例

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


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

示例1: paintComponent

import java.awt.Color; //导入依赖的package包/类
@Override
public void paintComponent(Graphics g)
{
	g.setColor(Color.BLACK);
	
	g.fillRect(0, 0, 800, 800);
	
	g.setColor(Color.WHITE);
	for(Vector v : desc.getNodes())
	{	
		g.fillOval((int) v.x - size/2, (int) v.y - size/2, size, size);
	}
	g.setColor(Color.GRAY);
	for(Dijkstra.Edge e : desc.getEdges())
	{	
		g.drawLine((int) e.a.x, (int) e.a.y, (int) e.b.x, (int) e.b.y);
	}
	
	g.setColor(Color.CYAN);
	
	for(int i = 1 ; i < path.size() ; i++)
	{
		g.drawLine((int)path.get(i).x, (int)path.get(i).y, (int)path.get(i - 1).x,(int) path.get(i - 1).y);
	}
}
 
开发者ID:ben-j-c,项目名称:TopDownGame,代码行数:26,代码来源:DijkstraTest.java

示例2: DetectorPanel

import java.awt.Color; //导入依赖的package包/类
public DetectorPanel(){
	setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	setPreferredSize(new Dimension(250,130));
	setBackground(Color.WHITE);

	this.detectorLabel= new JLabel("OBRAZ DETEKTORA");
	c.gridx = 0;
	c.gridy = 0;
	c.anchor=GridBagConstraints.PAGE_START;
	this.detectorLabel.setFont(this.header);
	this.add(this.detectorLabel,c);

	this.detectorImage = new DetectorImage();
	c.gridy = 1;
	c.insets = new Insets(5,0,5,0);
	this.add(this.detectorImage,c);

}
 
开发者ID:Tosbert,项目名称:FizeauExperimentSimulation,代码行数:20,代码来源:DetectorPanel.java

示例3: renderWaypoints

import java.awt.Color; //导入依赖的package包/类
/**
 * Render all waypoints (the circles in the map), data generated in createWaypointsList
 * @param gl
 * @param triangles
 */
private synchronized void renderWaypoints(GL gl, List<BlendTriangle> triangles) {
    GlColor color = new GlColor(new Color(NbPreferences.forModule(TimelinePanel.class).getInt(TimelinePanel.MapColor.WAYPOINTS_COLOR_KEY.getPrefKey(), TimelinePanel.MapColor.WAYPOINTS_COLOR_KEY.getDegaultARGB())));

    gl.glEnable(GL.GL_COLOR_MATERIAL);
    gl.glShadeModel(GL.GL_SMOOTH);

    gl.glBegin(GL.GL_TRIANGLES);
    for (BlendTriangle triangle : triangles) {
        for (BlendVertex v : triangle.getVerts()) {
            // take color according to width
            gl.glColor4d(color.r, color.g, color.b, color.a);
            gl.glVertex3d(v.getLocation().x, v.getLocation().y, v.getLocation().z + 0.1);
        }
    }
    gl.glEnd();
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:22,代码来源:MapRenderer.java

示例4: setup

import java.awt.Color; //导入依赖的package包/类
private void setup()
{
	setLayout(new FlowLayout(FlowLayout.LEFT));
	setBackground(Color.WHITE);
	setMaximumSize(new Dimension(0, 1000));
	setPreferredSize(new Dimension(0, 1000));
	setMinimumSize(new Dimension(0, 1000));

	Iterator<JImage> i = icons.iterateImages();
	while( i.hasNext() )
	{
		JImage image = i.next();
		add(image);
		image.setBorder(BorderFactory.createLineBorder(Color.WHITE, 3));
		image.addMouseListener(this);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:IconPane.java

示例5: NowPlaying

import java.awt.Color; //导入依赖的package包/类
public NowPlaying(Guild server, Music music) {
    this.music = music;
    this.server = server;
    channel = Constant.jda.getTextChannelById(Constant.getTextChannelConf().getProperty(this.server.getId()));
    musicManager = music.getGuildAudioPlayer(server);
    idMessageNowPlaying = "";
    musicManager.player.addListener(this);
    Constant.jda.addEventListener(this);
    colorList = new ArrayList<>();
    colorList.add(Color.RED);
    colorList.add(Color.ORANGE);
    colorList.add(Color.YELLOW);
    colorList.add(Color.GREEN);
    colorList.add(Color.CYAN);
    colorList.add(Color.BLUE);
    itColorList = colorList.iterator();
    trackImgUrl = Constant.lambdaMusicIconUrl;
    run();
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:20,代码来源:NowPlaying.java

示例6: adjustDisplaySettings

import java.awt.Color; //导入依赖的package包/类
private void adjustDisplaySettings( JGraph jg ) {
    jg.setPreferredSize( DEFAULT_SIZE );

    Color  c        = DEFAULT_BG_COLOR;
    String colorStr = null;

    try {
        colorStr = getParameter( "bgcolor" );
    }
     catch( Exception e ) {}

    if( colorStr != null ) {
        c = Color.decode( colorStr );
    }

    jg.setBackground( c );
}
 
开发者ID:LouisJenkinsCS,项目名称:DSL,代码行数:18,代码来源:ASTGraph.java

示例7: pointLabel

import java.awt.Color; //导入依赖的package包/类
/**
 * Print a label over every point, if the point is select
 * the label contain the coordinate too
 * @param gra The graphic object
 * @param points The vector with all points
 */
public void pointLabel(Graphics2D g, Vector<Point2D> points) {
	g.setColor(Color.BLACK);

	//Setting the Font
	int fontSize = 7 + pointSize;
	Font f = new Font("Arial", Font.PLAIN, fontSize);
	g.setFont(f);

	for (int i = 0; i < points.size(); i++) {
		DPoint p = (DPoint) points.get(i);
		if (!p.isSelect()) {
			g.drawString(p.getLabel(), tran_x + (int) (p.getX() * scale) - 15, tran_y - (int) (p.getY() * scale) - 3 - pointSize);
		} else {
			g.drawString(p.getLabel() + " (" + format2Dec.format(p.getX()) + ", " + format2Dec.format(p.getY()) + ")", tran_x
					+ (int) (p.getX() * scale) - 15, tran_y - (int) (p.getY() * scale) - 3 - pointSize);
		}
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:25,代码来源:PainterConvex2D.java

示例8: executeCommand

import java.awt.Color; //导入依赖的package包/类
@Override
public void executeCommand(Message msg) {
	EmbedBuilder em = new EmbedBuilder();
	String contents = Util.getCommandContents(msg);
	Member target;
	if(contents.isEmpty()) {
		target = msg.getGuild().getMember(msg.getAuthor());
	} else if ((target = Util.resolveMemberFromMessage(msg)) == null) {
		em.setTitle("Error", null)
		.setColor(Color.RED)
		.setDescription("No user found for " + contents);
		msg.getChannel().sendMessage(em.build()).queue();
		return;
	}
	msg.getChannel().sendMessage(target.getUser().getAvatarUrl() + "?size=256").queue();
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:17,代码来源:Avatar.java

示例9: validate

import java.awt.Color; //导入依赖的package包/类
/**
 * Restores the passed surface if it was lost, resets the lost status.
 * @param sd surface to be validated
 * @return true if surface wasn't lost or if restoration was successful,
 * false otherwise
 */
private boolean validate(D3DWindowSurfaceData sd) {
    if (sd.isSurfaceLost()) {
        try {
            sd.restoreSurface();
            // if succeeded, first fill the surface with bg color
            // note: use the non-synch method to avoid incorrect lock order
            Color bg = sd.getPeer().getBackgroundNoSync();
            SunGraphics2D sg2d = new SunGraphics2D(sd, bg, bg, null);
            sg2d.fillRect(0, 0, sd.getBounds().width, sd.getBounds().height);
            sg2d.dispose();
            // now clean the dirty status so that we don't flip it
            // next time before it gets repainted; it is safe
            // to do without the lock because we will issue a
            // repaint anyway so we will not lose any rendering
            sd.markClean();
            // since the surface was successfully restored we need to
            // repaint whole window to repopulate the back-buffer
            repaintPeerTarget(sd.getPeer());
        } catch (InvalidPipeException ipe) {
            return false;
        }
    }
    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:D3DScreenUpdateManager.java

示例10: drawRect

import java.awt.Color; //导入依赖的package包/类
/**
 * Draws the outline of the specified rectangle.
 * The left and right edges of the rectangle are at
 * <code>x</code> and <code>x&nbsp;+&nbsp;width</code>.
 * The top and bottom edges are at
 * <code>y</code> and <code>y&nbsp;+&nbsp;height</code>.
 * The rectangle is drawn using the graphics context's current color.
 * @param         x   the <i>x</i> coordinate
 *                         of the rectangle to be drawn.
 * @param         y   the <i>y</i> coordinate
 *                         of the rectangle to be drawn.
 * @param         width   the width of the rectangle to be drawn.
 * @param         height   the height of the rectangle to be drawn.
 * @see          java.awt.Graphics#fillRect
 * @see          java.awt.Graphics#clearRect
 */
public void drawRect(int x, int y, int width, int height) {

    Paint paint = getPaint();

    try {
        AffineTransform deviceTransform = getTransform();
        if (getClip() != null) {
            deviceClip(getClip().getPathIterator(deviceTransform));
        }

        deviceFrameRect(x, y, width, height, (Color) paint);

    } catch (ClassCastException e) {
        throw new IllegalArgumentException("Expected a Color instance");
    }

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:PathGraphics.java

示例11: AEChipRenderer

import java.awt.Color; //导入依赖的package包/类
public AEChipRenderer(AEChip chip) {
	super(chip);
	if (chip == null) {
		throw new Error("tried to build ChipRenderer with null chip");
	}
	setChip(chip);
	spikeSound = new SpikeSound();
	timeColors = new float[NUM_TIME_COLORS][3];
	float s = 1f / NUM_TIME_COLORS;
	for (int i = 0; i < NUM_TIME_COLORS; i++) {
		int rgb = Color.HSBtoRGB((0.66f * (NUM_TIME_COLORS - i)) / NUM_TIME_COLORS, 1f, 1f);
		Color c = new Color(rgb);
		float[] comp = c.getRGBColorComponents(null);
		timeColors[i][0] = comp[0];
		timeColors[i][2] = comp[2];
		timeColors[i][1] = comp[1];
		// System.out.println(String.format("%.2f %.2f %.2f",comp[0],comp[1],comp[2]));
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:20,代码来源:AEChipRenderer.java

示例12: fill

import java.awt.Color; //导入依赖的package包/类
private static void fill(final Image image) {
    final Graphics2D graphics = (Graphics2D) image.getGraphics();
    graphics.setComposite(AlphaComposite.Src);
    for (int i = 0; i < image.getHeight(null); ++i) {
        graphics.setColor(new Color(i, 0, 0));
        graphics.fillRect(0, i, image.getWidth(null), 1);
    }
    graphics.dispose();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:IncorrectUnmanagedImageRotatedClip.java

示例13: testEquals

import java.awt.Color; //导入依赖的package包/类
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    
    XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer();
    XYBoxAndWhiskerRenderer r2 = new XYBoxAndWhiskerRenderer();
    assertEquals(r1, r2);
    
    r1.setPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 
            3.0f, 4.0f, Color.red));
    assertFalse(r1.equals(r2));
    r2.setPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 
            3.0f, 4.0f, Color.red));
    assertEquals(r1, r2);
    
    r1.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.green, 
            3.0f, 4.0f, Color.red));
    assertFalse(r1.equals(r2));
    r2.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.green, 
            3.0f, 4.0f, Color.red));
    assertEquals(r1, r2);
    
    r1.setBoxWidth(0.55);
    assertFalse(r1.equals(r2));
    r2.setBoxWidth(0.55);
    assertEquals(r1, r2);
    
    r1.setFillBox(!r1.getFillBox());
    assertFalse(r1.equals(r2));
    r2.setFillBox(!r2.getFillBox());
    assertEquals(r1, r2);
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:35,代码来源:XYBoxAndWhiskerRendererTests.java

示例14: paint

import java.awt.Color; //导入依赖的package包/类
@Override public void paint(Graphics graphics) {
	graphics.setColor(Color.BLACK);
	graphics.drawRect(5, 0, size.width-10, size.height);
	graphics.setFont(graphics.getFont().deriveFont(14f));
	graphics.drawString("Byte", 10, 20);
	graphics.setFont(graphics.getFont().deriveFont(10f));
	graphics.drawLine(15, 35, size.width-15, 20);
	graphics.drawString("Decimal", 25, 50);
	ContactUtilities.paintSolderingJoints(graphics, contacts);
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:11,代码来源:ByteToDecimalConverter.java

示例15: getJxdatetimepickerMonthStringBackground

import java.awt.Color; //导入依赖的package包/类
public static Color getJxdatetimepickerMonthStringBackground() {
    Color managerColor = UIManager.getColor("nb.dataview.jxdatetimepicker.monthStringBackground");
    if (managerColor == null) {
        UIManager.put("nb.dataview.jxdatetimepicker.monthStringBackground", UIManager.getColor("JXMonthView.monthStringBackground")); //NOI18N
        return UIManager.getColor("nb.dataview.jxdatetimepicker.monthStringBackground"); //NOI18N
    } else {
        return managerColor;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ColorHelper.java


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