本文整理汇总了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);
}
}
示例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);
}
示例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();
}
示例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);
}
}
示例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();
}
示例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 );
}
示例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);
}
}
}
示例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();
}
示例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;
}
示例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 + width</code>.
* The top and bottom edges are at
* <code>y</code> and <code>y + 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");
}
}
示例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]));
}
}
示例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();
}
示例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);
}
示例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);
}
示例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;
}
}