Java 类java.awt.Color 实例源码
项目:TopDownGame
文件:DijkstraTest.java
@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);
}
}
项目:FizeauExperimentSimulation
文件:DetectorPanel.java
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);
}
项目:jaer
文件:AEChipRenderer.java
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]));
}
}
项目:Pogamut3
文件:MapRenderer.java
/**
* 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();
}
项目:Equella
文件:IconPane.java
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);
}
}
项目:GoupilBot
文件:NowPlaying.java
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();
}
项目:DSL
文件:ASTGraph.java
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 );
}
项目:jmt
文件:PainterConvex2D.java
/**
* 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);
}
}
}
项目:momo-2
文件:Avatar.java
@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();
}
项目:OpenJSharp
文件:D3DScreenUpdateManager.java
/**
* 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;
}
项目:jdk8u-jdk
文件:PathGraphics.java
/**
* 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");
}
}
项目:incubator-netbeans
文件:XhtmlElHighlighting.java
XhtmlElHighlighting(Document document) {
this.document = document;
// load the background color for the embedding token
AttributeSet elAttribs = null;
String mimeType = (String) document.getProperty("mimeType"); //NOI18N
FontColorSettings fcs = MimeLookup.getLookup(mimeType).lookup(FontColorSettings.class);
if (fcs != null) {
Color elBC = getColoring(fcs, XhtmlElTokenId.EL.primaryCategory());
if (elBC != null) {
elAttribs = AttributesUtilities.createImmutable(
StyleConstants.Background, elBC,
ATTR_EXTENDS_EOL, Boolean.TRUE);
}
}
expressionLanguageBackground = elAttribs;
}
项目:rapidminer
文件:ChartConfigurationPanel.java
@Override
public void dragEnded() {
if (SwingUtilities.isEventDispatchThread()) {
plotConfigurationTreeScrollPane.setBorder(DROP_ENDED_BORDER);
plotConfigurationTree.setBackground(Color.WHITE);
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
plotConfigurationTreeScrollPane.setBorder(DROP_ENDED_BORDER);
plotConfigurationTree.setBackground(Color.WHITE);
}
});
}
}
项目:defense-solutions-proofs-of-concept
文件:RoundedJPanel.java
@Override
protected void paintComponent(Graphics g) {
int borderWidth = 3;
int x = borderWidth;
int y = borderWidth;
int w = getWidth() - (2 * borderWidth);
int h = getHeight() - (2 * borderWidth);
int arc = 30;
Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setColor(Color.WHITE);
g2.fillRoundRect(x, y, w, h, arc, arc);
g2.setStroke(new BasicStroke(borderWidth));
g2.setColor(new Color(40, 40, 40));
g2.drawRoundRect(x, y, w, h, arc, arc);
g2.dispose();
}
项目:missile-defense
文件:GamePane.java
private void drawLabelHelper(){
this.roundTime = new GLabel(this.ROUND_TIME_LABEL,10, 20);
this.score = new GLabel("0",875, 20);
this.roundTime.setColor(Color.white);
this.roundTime.setFont(LABEL_FONT);
this.score.setColor(Color.white);
this.score.setFont(LABEL_FONT);
this.ammoQ = new GLabel(String.valueOf(lvl.getTurrets()[0].getMissileCount()), 15, 550);
this.ammoW = new GLabel(String.valueOf(lvl.getTurrets()[1].getMissileCount()), 150, 600);
this.ammoE = new GLabel(String.valueOf(lvl.getTurrets()[2].getMissileCount()), 870, 600);
this.ammoR = new GLabel(String.valueOf(lvl.getTurrets()[3].getMissileCount()), 995, 550);
this.ammoQ.setFont(AMMO_LABEL_FONT);
this.ammoW.setFont(AMMO_LABEL_FONT);
this.ammoE.setFont(AMMO_LABEL_FONT);
this.ammoR.setFont(AMMO_LABEL_FONT);
this.ammoQ.setColor(Color.white);
this.ammoW.setColor(Color.white);
this.ammoE.setColor(Color.white);
this.ammoR.setColor(Color.white);
}
项目:AgentWorkbench
文件:SystemLoadPanel.java
/**
* Sets to do the load recording now.
* @param doRecording the new do load recording
*/
public void setDoLoadRecording(boolean doRecording) {
// --- Prevent to repeat an action if already -----
if (doRecording!=isRecording) {
if (doRecording==true) {
this.isRecording = true;
this.myAgent.setMonitorSaveLoad(true);
this.jButtonMeasureRecord.setEnabled(false);
this.jButtonMeasureRecordStop.setEnabled(true);
this.jLabelRecord.setForeground(Color.red);
} else {
this.isRecording = false;
this.myAgent.setMonitorSaveLoad(false);
this.jButtonMeasureRecord.setEnabled(true);
this.jButtonMeasureRecordStop.setEnabled(false);
this.jLabelRecord.setForeground(Color.gray);
}
}
}
项目:Logisim
文件:ZoomControl.java
@Override
protected void paintComponent(Graphics g) {
if (AppPreferences.ANTI_ALIASING.getBoolean()) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
}
int width = getWidth();
int height = getHeight();
g.setColor(state ? Color.black : getBackground().darker());
int dim = (Math.min(width, height) - 4) / 3 * 3 + 1;
int xoff = (width - dim) / 2;
int yoff = (height - dim) / 2;
for (int x = 0; x < dim; x += 3) {
for (int y = 0; y < dim; y += 3) {
g.drawLine(x + xoff, y + yoff, x + xoff, y + yoff);
}
}
}
项目:geomapapp
文件:WWXMCS.java
protected void updateSelectedTrack() {
if (currentCruise == null) return;
XMLine[] lines = currentCruise.getLines();
int i = 0;
for (Polyline line : cruiseLines) {
if (currentLine == lines[i++]) {
line.setColor( Color.white );
makeFenceDiagram(line);
}
else
line.setColor( Color.black );
}
FenceDiagram fd = fdS.get(currentLine);
if (fd != null)
opacitySlider.setValue((int) (fd.getOpacity() * 100));
layerSet.firePropertyChange(AVKey.LAYER, null, layerSet);
}
项目:knime-activelearning
文件:ToggleButtonList.java
@Override
public void paint(final Graphics g) {
super.paint(g);
if (isSelected()) {
g.setColor(new Color(65, 128, 64));
final int x = getWidth() - 14;
final int y = (getHeight() / 2) - 4;
g.fillRect(x, y, 8, 8);
}
}
项目:Logisim
文件:SvgReader.java
private static Color getColor(String hue, String opacity) {
int r;
int g;
int b;
if (hue == null || hue.equals("")) {
r = 0;
g = 0;
b = 0;
} else {
r = Integer.parseInt(hue.substring(1, 3), 16);
g = Integer.parseInt(hue.substring(3, 5), 16);
b = Integer.parseInt(hue.substring(5, 7), 16);
}
int a;
if (opacity == null || opacity.equals("")) {
a = 255;
} else {
double x;
try {
x = Double.parseDouble(opacity);
} catch (NumberFormatException e) {
// some localizations use commas for decimal points
int comma = opacity.lastIndexOf(',');
if (comma >= 0) {
try {
String repl = opacity.substring(0, comma) + "." + opacity.substring(comma + 1);
x = Double.parseDouble(repl);
} catch (Throwable t) {
throw e;
}
} else {
throw e;
}
}
a = (int) Math.round(x * 255);
}
return new Color(r, g, b, a);
}
项目:smile_1.5.0_java7
文件:GeometricDistributionDemo.java
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == probSlider) {
prob = probSlider.getValue() / 10.0;
GeometricDistribution dist = new GeometricDistribution(prob);
double[][] p = new double[11][2];
double[][] q = new double[11][2];
for (int i = 0; i < p.length; i++) {
p[i][0] = i;
p[i][1] = dist.p(p[i][0]);
q[i][0] = i;
q[i][1] = dist.cdf(p[i][0]);
}
pdf.clear();
pdf.add(new BarPlot(p));
cdf.clear();
cdf.staircase(q, Color.BLACK);
double[] data = new double[500];
for (int i = 0; i < data.length; i++) {
data[i] = dist.rand();
}
histogram.clear();
histogram.histogram(data, 10, Color.BLUE);
}
}
项目:thornsec-core
文件:FullFrame.java
private JPanel getNewPanel() {
GridBagLayout layout = new GridBagLayout();
JPanel ripInPepperoniTheIncredibleMrHong = new JPanel(layout);
ripInPepperoniTheIncredibleMrHong.setBackground(Color.WHITE);
return ripInPepperoniTheIncredibleMrHong;
}
项目:faitic-checker
文件:ScheduleEvent.java
public void modify(String eventName, int minuteStart, int minuteEnd, int day, Color color, String assocSubject, String eventDescription){
iEventName=eventName;
iMinuteStart=minuteStart; iMinuteEnd=minuteEnd; iDay=day;
iColor=color;
iAssocSubject=assocSubject;
iEventDescription=eventDescription;
}
项目:rapidminer
文件:ProcessDrawer.java
/**
* Draws the operator background (white round rectangle).
*
* @param operator
* the operator to draw the background for
* @param g2
* the graphics context to draw upon
*/
private void renderOperatorBackground(final Operator operator, final Graphics2D g2) {
Rectangle2D frame = model.getOperatorRect(operator);
// the first paint can come before any of the operator register listeners fire
// thus we need to check the rect for null and set it here once
// all subsequent calls will then have a valid rect
if (frame == null) {
return;
}
RoundRectangle2D background = new RoundRectangle2D.Double(frame.getX() - 7, frame.getY() - 3, frame.getWidth() + 14,
frame.getHeight() + 11, OPERATOR_BG_CORNER, OPERATOR_BG_CORNER);
g2.setColor(Color.WHITE);
g2.fill(background);
// if name is wider than operator, extend white background for header
Rectangle2D nameBounds = OPERATOR_FONT.getStringBounds(operator.getName(), g2.getFontRenderContext());
if (nameBounds.getWidth() > frame.getWidth()) {
double relevantWidth = Math.min(nameBounds.getWidth(), frame.getWidth() * MAX_HEADER_RATIO);
double offset = (frame.getWidth() - relevantWidth) / 2;
int x = (int) (frame.getX() + offset);
int padding = 5;
RoundRectangle2D nameBackground = new RoundRectangle2D.Double(
(int) Math.min(frame.getX() - padding, x - padding), frame.getY() - 3, relevantWidth + 2 * padding,
ProcessRendererModel.HEADER_HEIGHT + 3, OPERATOR_BG_CORNER, OPERATOR_BG_CORNER);
g2.fill(nameBackground);
}
// render ports
renderPortsBackground(operator.getInputPorts(), g2);
renderPortsBackground(operator.getOutputPorts(), g2);
}
项目:OpenJSharp
文件:CSS.java
/**
* Converts a type Color to a hex string
* in the format "#RRGGBB"
*/
static String colorToHex(Color color) {
String colorstr = "#";
// Red
String str = Integer.toHexString(color.getRed());
if (str.length() > 2)
str = str.substring(0, 2);
else if (str.length() < 2)
colorstr += "0" + str;
else
colorstr += str;
// Green
str = Integer.toHexString(color.getGreen());
if (str.length() > 2)
str = str.substring(0, 2);
else if (str.length() < 2)
colorstr += "0" + str;
else
colorstr += str;
// Blue
str = Integer.toHexString(color.getBlue());
if (str.length() > 2)
str = str.substring(0, 2);
else if (str.length() < 2)
colorstr += "0" + str;
else
colorstr += str;
return colorstr;
}
项目:Reinickendorf_SER316
文件:FontDialog.java
void colorB_actionPerformed(ActionEvent e) {
// Fix until Sun's JVM supports more locales...
UIManager.put(
"ColorChooser.swatchesNameText",
Local.getString("Swatches"));
UIManager.put("ColorChooser.hsbNameText", Local.getString("HSB"));
UIManager.put("ColorChooser.rgbNameText", Local.getString("RGB"));
UIManager.put(
"ColorChooser.swatchesRecentText",
Local.getString("Recent:"));
UIManager.put("ColorChooser.previewText", Local.getString("Preview"));
UIManager.put(
"ColorChooser.sampleText",
Local.getString("Sample Text")
+ " "
+ Local.getString("Sample Text"));
UIManager.put("ColorChooser.okText", Local.getString("OK"));
UIManager.put("ColorChooser.cancelText", Local.getString("Cancel"));
UIManager.put("ColorChooser.resetText", Local.getString("Reset"));
UIManager.put("ColorChooser.hsbHueText", Local.getString("H"));
UIManager.put("ColorChooser.hsbSaturationText", Local.getString("S"));
UIManager.put("ColorChooser.hsbBrightnessText", Local.getString("B"));
UIManager.put("ColorChooser.hsbRedText", Local.getString("R"));
UIManager.put("ColorChooser.hsbGreenText", Local.getString("G"));
UIManager.put("ColorChooser.hsbBlueText", Local.getString("B2"));
UIManager.put("ColorChooser.rgbRedText", Local.getString("Red"));
UIManager.put("ColorChooser.rgbGreenText", Local.getString("Green"));
UIManager.put("ColorChooser.rgbBlueText", Local.getString("Blue"));
Color c = JColorChooser.showDialog(this, Local.getString("Font color"),
Util.decodeColor(colorField.getText()));
if (c == null) return;
colorField.setText(Util.encodeColor(c));
Util.setColorField(colorField);
sample.setForeground(c);
}
项目:incubator-netbeans
文件:ColorsManager.java
private static AttributeSet getParameterAttributes () {
if (parameterAttributeSet == null) {
SimpleAttributeSet sas = new SimpleAttributeSet ();
StyleConstants.setForeground (sas, new Color (160, 96, 1));
parameterAttributeSet = sas;
}
return parameterAttributeSet;
}
项目:Progetto-A
文件:PartitaOfflineGuiView.java
private void stampaMessaggioFineRound(Giocatore giocatore) {
Giocatore mazziere = model.getMazziere();
String msg = "";
if(!giocatore.isMazziere()) {
if(mazziere.getStatoMano() == StatoMano.Sballato) {
if(giocatore.getStatoMano() == StatoMano.Sballato)
msg = giocatore.getNome() + " paga " + giocatore.getPuntata() + " al mazziere";
else if ((giocatore.getStatoMano() == StatoMano.OK) || (giocatore.getStatoMano() == StatoMano.SetteeMezzo))
msg = giocatore.getNome() + " riceve " + giocatore.getPuntata() + " dal mazziere";
else if(giocatore.getStatoMano() == StatoMano.SetteeMezzoReale)
msg = giocatore.getNome() + " riceve " + 2*giocatore.getPuntata() + " dal mazziere";
} else {
if((giocatore.getStatoMano() == StatoMano.Sballato) || (giocatore.getValoreMano() <= mazziere.getValoreMano()))
msg = giocatore.getNome() + " paga " + giocatore.getPuntata() + " al mazziere";
else if (giocatore.getValoreMano() > mazziere.getValoreMano())
msg = giocatore.getNome() + " riceve " + giocatore.getPuntata() + " dal mazziere";
else if ((giocatore.getStatoMano() == StatoMano.SetteeMezzoReale) && (giocatore.getValoreMano() > mazziere.getValoreMano()))
msg = giocatore.getNome() + " riceve " + 2*giocatore.getPuntata() + " dal mazziere";
else if(mazziere.getStatoMano() == StatoMano.SetteeMezzoReale)
msg = giocatore.getNome() + " paga " + 2*giocatore.getPuntata() + " al mazziere";
}
} else
msg = "Il mazziere regola i suoi conti";
Font font = new Font("MsgFineRound", Font.BOLD, 70);
JLabel msgFineRound = new JLabel(msg);
msgFineRound.setFont(font);
msgFineRound.setForeground(Color.black);
int strWidth = msgFineRound.getFontMetrics(font).stringWidth(msg);
msgFineRound.setBounds(this.getWidth()/2 - strWidth/2, this.getHeight()/2 - 60, strWidth, 90);
sfondo.add(msgFineRound);
sfondo.repaint();
pausa(pausa_lunga);
sfondo.remove(msgFineRound);
}
项目:BasicsProject
文件:GifCaptcha.java
@Override
public void out(OutputStream os)
{
try
{
GifEncoder gifEncoder = new GifEncoder(); // gif编码类,这个利用了洋人写的编码类,所有类都在附件中
//生成字符
gifEncoder.start(os);
gifEncoder.setQuality(180);
gifEncoder.setDelay(100);
gifEncoder.setRepeat(0);
BufferedImage frame;
char[] rands =alphas();
Color fontcolor[]=new Color[len];
for(int i=0;i<len;i++)
{
fontcolor[i]=new Color(20 + num(110), 20 + num(110), 20 + num(110));
}
for(int i=0;i<len;i++)
{
frame=graphicsImage(fontcolor, rands, i);
gifEncoder.addFrame(frame);
frame.flush();
}
gifEncoder.finish();
}finally
{
try {
os.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
项目:LogiGSK
文件:IOOperations.java
public static Color getGrayColourFromHexString(String colourHex) {
int grayscale = (int)(
0.3 * Integer.valueOf(colourHex.substring(0, 2), 16) +
0.59 * Integer.valueOf(colourHex.substring(2, 4), 16) +
0.11 * Integer.valueOf(colourHex.substring(4, 6), 16));
return new Color(grayscale, grayscale, grayscale);
}
项目:restaurant-app
文件:Card.java
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents()
{
setBackground(new java.awt.Color(153, 0, 0));
setLayout(new java.awt.BorderLayout());
}
项目:openjdk-jdk10
文件:IncorrectUnmanagedImageRotatedClip.java
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();
}
项目:parabuild-ci
文件:XYBoxAndWhiskerRendererTests.java
/**
* 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);
}
项目:JDigitalSimulator
文件:ByteToDecimalConverter.java
@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);
}
项目:incubator-netbeans
文件:ColorHelper.java
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;
}
}
项目:PackagePlugin
文件:ProgressDialog.java
/**
* 启动定时任务,绘制鼠标路径
*/
public void initTimer() {
timer = new Timer();
timer.schedule(new TimerTask() {
int x, y;
int flag = random.nextInt(5);
@Override
public void run() {
Graphics g = getGraphics();
if (g != null) {
if (count == 0) {//遮罩背景只绘制一次
paintMask(g);
count++;
}
Point p = MouseInfo.getPointerInfo().getLocation();
g.setColor(Color.red);
if (x != 0 && y != 0) {
switch (flag) {
case 0:
g.drawLine(x - 123, y - 10, p.x - 123, p.y - 10);
case 1:
g.drawLine(x - 123, y - 5, p.x - 123, p.y - 5);
case 2:
g.drawLine(x - 123, y, p.x - 123, p.y);
case 3:
g.drawLine(x - 123, y + 5, p.x - 123, p.y + 5);
case 4:
g.drawLine(x - 123, y + 10, p.x - 123, p.y + 10);
}
}
x = p.x;
y = p.y;
}
}
}, 0, 50);
}
项目:SER316-Munich
文件:StickerExpand.java
void jbInit() throws Exception {
border1 =
BorderFactory.createCompoundBorder(
BorderFactory.createEtchedBorder(
Color.white,
new Color(156, 156, 158)),
BorderFactory.createEmptyBorder(5, 5, 5, 5));
border2 = BorderFactory.createEmptyBorder(5, 0, 5, 0);
panel1.setLayout(borderLayout1);
this.getContentPane().setLayout(borderLayout2);
bottomPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
topPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
topPanel.setBorder(new EmptyBorder(new Insets(0, 5, 0, 5)));
topPanel.setBackground(Color.WHITE);
jPanel1.setLayout(borderLayout3);
panel1.setBorder(border1);
jPanel1.setBorder(border2);
getContentPane().add(panel1, BorderLayout.CENTER);
panel1.add(jScrollPane1, BorderLayout.CENTER);
jScrollPane1.getViewport().add(stickerText, null);
panel1.add(jPanel1, BorderLayout.SOUTH);
this.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
this.getContentPane().add(topPanel, BorderLayout.NORTH);
stickerText.setText(txt);
stickerText.setOpaque(true);
stickerText.setBackground(backGroundColor);
stickerText.setForeground(foreGroundColor);
}
项目:incubator-netbeans
文件:DebuggingViewComponent.java
private static Color getTreeBackgroundColor() {
Color c = null;
if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N
c = UIManager.getColor("NbExplorerView.background"); //NOI18N
}
if (c == null) {
c = UIManager.getColor("Tree.textBackground"); // NOI18N
}
return c;
}
项目:litiengine
文件:GuiComponent.java
@Override
public void render(final Graphics2D g) {
if (this.isSuspended() || !this.isVisible()) {
return;
}
Appearance currentAppearance = this.getAppearance();
if (this.isHovered()) {
currentAppearance = this.getAppearanceHovered();
}
if (!this.isEnabled()) {
currentAppearance = this.getAppearanceDisabled();
}
if (!currentAppearance.isTransparentBackground()) {
g.setPaint(currentAppearance.getBackgroundPaint(this.getWidth(), this.getHeight()));
g.fill(this.getBoundingBox());
}
g.setColor(currentAppearance.getForeColor());
g.setFont(currentAppearance.getFont());
this.renderText(g);
for (final GuiComponent component : this.getComponents()) {
if (!component.isVisible() || component.isSuspended()) {
continue;
}
component.render(g);
}
if (Game.getConfiguration().debug().renderGuiComponentBoundingBoxes()) {
g.setColor(Color.RED);
g.draw(this.getBoundingBox());
}
}
项目:openjdk-jdk10
文件:LineBorder.java
/**
* Convenience method for getting the Color.gray LineBorder of thickness 1.
*
* @return a {@code LineBorder} with {@code Color.gray} and thickness of 1
*/
public static Border createGrayLineBorder() {
if (grayLine == null) {
grayLine = new LineBorder(Color.gray, 1);
}
return grayLine;
}