项目:openjdk-jdk10
文件:TestUnsupportedResolution.java
public int print(Graphics graphics,PageFormat pageFormat,int pageIndex) throws PrinterException
{
if (pageIndex>0)
{
return NO_SUCH_PAGE;
}
StringBuffer s=new StringBuffer();
for (int i=0;i<10;i++)
{
s.append("1234567890ABCDEFGHIJ");
}
int x=(int) pageFormat.getimageableX();
int y=(int) (pageFormat.getimageableY()+50);
graphics.drawString(s.toString(),x,y);
return PAGE_EXISTS;
}
项目:QN-ACTR-Release
文件:DefaultIcons.java
public static Image getStationIcon(String type,Rectangle bounds) {
BufferedImage bi = new BufferedImage(bounds.width,bounds.height,BufferedImage.TYPE_4BYTE_ABGR);
Graphics g = bi.getGraphics();
int qLength = bounds.width * 3 / 5,height = bounds.height,width = bounds.width;
for (int i = 0,monoChannel = 0; i < 5; i++,monoChannel = (int) ((1 - Math.exp(-i)) * 50)) {
g.setColor(new Color(230 - monoChannel,230 - monoChannel,255));
g.drawpolyline(new int[] { i,i,qLength - i },new int[] { height - i,i },3);
g.fillArc(width - height + i,height - 2 * i,45,180);
g.setColor(new Color(130 + monoChannel,130 + monoChannel,qLength - i,height - i,225,180);
}
g.fillRect(5,5,qLength - 9,height - 9);
g.filloval(width - height + 5,height - 10,height - 10);
return bi;
}
项目:incubator-netbeans
文件:TreeView.java
private void guardedPaint(Graphics g) {
if (firstPaint) {
firstPaint = false;
calcRowHeight(g);
//This will generate a repaint,so don't bother continuing with super.paint()
//but do paint the background color so it doesn't paint gray the first time
g.setColor(getBackground());
g.fillRect(0,getWidth(),getHeight());
return;
}
try {
ExplorerTree.super.paint(g);
} catch (NullPointerException ex) {
// #139696: Making this issue more acceptable by not showing a dialog
// still it deserves more investigation later
LOG.log(Level.INFO,"Problems while painting",ex); // NOI18N
}
}
项目:jdk8u-jdk
文件:MotifBorders.java
/** Draws the InternalFrameBorder's right border.
*/
protected boolean drawRightBorder(Component c,Graphics g,int x,int y,int width,int height) {
if (super.drawRightBorder(c,g,y,width,height) &&
frame.isResizable()) {
int startX = width - getBorderInsets(c).right;
g.setColor(getFrameHighlight());
int topY = y + CORNER_SIZE;
g.drawLine(startX,topY,width - 2,topY);
int bottomY = height - CORNER_SIZE;
g.drawLine(startX + 1,bottomY,startX + 3,bottomY);
g.setColor(getFrameShadow());
g.drawLine(startX + 1,topY - 1,topY - 1);
g.drawLine(startX + 1,bottomY - 1,bottomY - 1);
return true;
}
return false;
}
private Rectangle getCaretRectangle(TextHitInfo caret) {
int caretLocation = 0;
TextLayout layout = composedTextLayout;
if (layout != null) {
caretLocation = Math.round(layout.getCaretInfo(caret)[0]);
}
Graphics g = getGraphics();
FontMetrics metrics = null;
try {
metrics = g.getFontMetrics();
} finally {
g.dispose();
}
return new Rectangle(TEXT_ORIGIN_X + caretLocation,TEXT_ORIGIN_Y - metrics.getAscent(),metrics.getAscent() + metrics.getDescent());
}
项目:rapidminer
文件:DropDownButton.java
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
GeneralPath arrow = new GeneralPath();
int w,h;
h = (int) (2 * sizefactor);
w = (int) (4 * sizefactor);
arrow.moveto(getWidth() / 2 - w,getHeight() / 2);
arrow.lineto(getWidth() / 2 + w,getHeight() / 2);
arrow.lineto(getWidth() / 2,getHeight() / 2 + 2 * h);
arrow.closePath();
if (isEnabled()) {
g.setColor(Color.BLACK);
} else {
g.setColor(Color.GRAY);
}
((Graphics2D) g).fill(arrow);
}
/**
* Paints the toolbar.
*
* @param context context for the component being painted
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context,Graphics g) {
if (handleIcon != null && toolBar.isFloatable()) {
int startX = toolBar.getComponentOrientation().isLeftToRight() ?
0 : toolBar.getWidth() -
SynthIcon.getIconWidth(handleIcon,context);
SynthIcon.paintIcon(handleIcon,context,startX,SynthIcon.getIconWidth(handleIcon,context),SynthIcon.getIconHeight(handleIcon,context));
}
SynthContext subcontext = getContext(
toolBar,Region.TOOL_BAR_CONTENT,contentStyle);
paintContent(subcontext,contentRect);
subcontext.dispose();
}
项目:incubator-netbeans
文件:ComponentDocument.java
@Override
protected void paintComponent(Graphics graphics) {
Graphics2D g = Config.getDefault().getGraphics(graphics);
g.setColor(myBackgroundColor);
g.fillRect(0,myWidth,myHeight);
int y = 0;
for (int i = 0; i < myLines.size(); i++) {
ComponentLine line = myLines.get(i);
y += myCorrection[i] + myAscent[i];
line.draw(g,myMinOffset,y);
y += myDescent[i] + myLeading[i];
}
}
项目:lemon-framework
文件:VerifyCodeUtils.java
private static void shearY(Graphics g,int w1,int h1,Color color) {
int period = random.nextInt(40) + 10; // 50;
boolean borderGap = true;
int frames = 20;
int phase = 7;
for (int i = 0; i < w1; i++) {
double d = (double) (period >> 1)
* Math.sin((double) i / (double) period
+ (6.2831853071795862D * (double) phase)
/ (double) frames);
g.copyArea(i,1,h1,(int) d);
if (borderGap) {
g.setColor(color);
g.drawLine(i,(int) d,0);
g.drawLine(i,(int) d + h1,h1);
}
}
}
项目:New-Kepard
文件:JWindow.java
private void drawRocketWithBrakes(Graphics g,int startX,int startY,int rW,int rH,int bdist,int bW,int bH)
{
g.drawoval(startX - rW,startY - rH,2*rW,2*rH);
if(window.telemetry_booster_brakes[1]) //left
g.fillRect(startX - rW - bdist - 2*bH,startY - bW,2*bH,2*bW);
else g.drawRect(startX - rW - bdist - 2*bH,2*bW);
if(window.telemetry_booster_brakes[0]) //top
g.fillRect(startX - bW,startY - rH - bdist - 2*bH,2*bW,2*bH);
else g.drawRect(startX - bW,2*bH);
if(window.telemetry_booster_brakes[3]) //right
g.fillRect(startX + rW + bdist,2*bW);
else g.drawRect(startX + rW + bdist,2*bW);
if(window.telemetry_booster_brakes[2]) //bottom
g.fillRect(startX - bW,startY + rH + bdist,2*bH);
}
项目:org.alloytools.alloy
文件:OurAntiAlias.java
/**
* Constructs an antialias-capable JTextPane with a DefaultHighlighter
* associated with it.
*
* @param attributes - see {@link edu.mit.csail.sdg.alloy4.OurUtil#make
* OurUtil.make(component,attributes...)}
*/
public static JTextPane pane(Object... attributes) {
JTextPane ans = new JTextPane() {
static final long serialVersionUID = 0;
@Override
public void paint(Graphics gr) {
if (antiAlias && gr instanceof Graphics2D) {
((Graphics2D) gr).setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
}
super.paint(gr);
}
};
OurUtil.make(ans,attributes);
ans.setHighlighter(new DefaultHighlighter());
map.put(ans,Boolean.TRUE);
return ans;
}
项目:brModelo
文件:QuadroDeEdicao.java
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g); //paint background
RenderingHints renderHints
= new RenderingHints(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
renderHints.put(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);
renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
//renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
Graphics2D Canvas = (Graphics2D) g;
Canvas.addRenderingHints(renderHints);
Canvas.setstroke(new Basicstroke(
1f,Basicstroke.CAP_ROUND,Basicstroke.JOIN_ROUND));
Canvas.setPaint(Color.BLACK);
Processpaint(Canvas);
}
public void paintComponent( Graphics g ) {
if ( updateBackBuffer ) {
Dimension d = this.getSize();
isPrinting = false;
try {
drawText( g,d.width,d.height );
}
catch ( CannotDrawException e ) {
f2dt.fireChangeStatus( ERRORS[ e.id ],true );
super.paintComponent(g);
return;
}
}
else {
/// Screen refresh
g.drawImage( backBuffer,this );
}
showingError = false;
updateBackBuffer = false;
}
public void paintBorder(Component c,int height) {
JInternalFrame jif = null;
if (c instanceof JInternalFrame) {
jif = (JInternalFrame)c;
} else if (c instanceof JInternalFrame.JDesktopIcon) {
jif = ((JInternalFrame.JDesktopIcon)c).getInternalFrame();
} else {
return;
}
if (jif.isSelected()) {
// Set the line color so the line border gets the correct
// color.
lineColor = activeColor;
super.paintBorder(c,height);
} else {
lineColor = inactiveColor;
super.paintBorder(c,height);
}
}
项目:openjdk-jdk10
文件:SourceClippingBlitTest.java
static void initimage(GraphicsConfiguration gc,Image image) {
Graphics g = image.getGraphics();
g.setColor(Color.RED);
int w = image.getWidth(null);
int h = image.getHeight(null);
g.fillRect(0,w,h);
g.dispose();
// need to 'accelerate' the image
if (dstimage == null) {
dstimage =
gc.createCompatibleVolatileImage(TESTW,TESTH,Transparency.OPAQUE);
}
dstimage.validate(gc);
g = dstimage.getGraphics();
g.drawImage(image,null);
g.drawImage(image,null);
}
项目:sumo
文件:ImageConverter.java
/**
* Converts the given image to a gl compatible format if necessary and returns the data in the format GL_RGBA as GL_UNSIGNED_BYTE.
* @param awtimage the image to be converted to an byte buffer
* @return nio buffer
*/
public static ByteBuffer convert(BufferedImage awtimage)
{
if(!isGlCompatibleAwtimage(awtimage))
{
BufferedImage convertimage = createGlCompatibleAwtimage(awtimage.getWidth(),awtimage.getHeight());
// copy the source image into the produced image
Graphics g = convertimage.getGraphics();
g.setColor(new Color(0f,0f,0f));
g.fillRect(0,awtimage.getWidth(),awtimage.getHeight());
g.drawImage(awtimage,null);
awtimage = convertimage;
}
// build a byte buffer from the temporary image
// that be used by OpenGL to produce a texture.
byte[] data = ((DataBufferByte) awtimage.getRaster().getDataBuffer()).getData();
ByteBuffer imageBuffer = ByteBuffer.allocateDirect(data.length);
imageBuffer.order(ByteOrder.nativeOrder());
imageBuffer.put(data,data.length);
imageBuffer.flip();
return imageBuffer;
}
项目:incubator-netbeans
文件:HideableBarRenderer.java
public void paint(Graphics g) {
g.setColor(getBackground());
g.fillRect(location.x,location.y,size.width,size.height);
JComponent component = mainRenderer.getComponent();
int componentWidth = component.getPreferredSize().width;
int componentX = size.width - componentWidth;
mainRenderer.move(location.x + componentX,location.y);
component.setSize(componentWidth,size.height);
component.paint(g);
int freeWidth = size.width - maxRendererWidth - renderersGap();
if (freeWidth >= MIN_BAR_WIDTH) {
barRenderer.setSize(Math.min(freeWidth,MAX_BAR_WIDTH),size.height);
barRenderer.move(location.x,location.y);
barRenderer.paint(g);
}
}
项目:JuggleMasterPro
文件:PreferenceStringLocalColorJButton.java
/**
* Method description
*
* @see
* @param objPgraphics
*/
@Override final public void paintComponent(Graphics objPgraphics) {
// Draw a colored rectangle in place of the button :
final int intLjButtonWidth = this.getWidth();
final int intLjButtonHeight = this.getHeight();
final BufferedImage imgLbuffer =
Constants.objS_GRAPHICS_CONfigURATION.createCompatibleImage(intLjButtonWidth,intLjButtonHeight,Transparency.OPAQUE);
final Graphics2D objLgraphics2D = (Graphics2D) imgLbuffer.getGraphics();
objLgraphics2D.setColor(Tools.getPenGammaColor( this.objGpreferencesjdialog.strGstringLocalAA[this.bytGcolorPreferenceType][Constants.bytS_UNCLASS_TEMPORARY_CURRENT],Preferences.getGlobalBytePreference(Constants.bytS_BYTE_GLOBAL_GAMMA_CORRECTION)));
objLgraphics2D.fillRect(1,intLjButtonWidth - 2,intLjButtonHeight - 2);
objLgraphics2D.setColor(Color.BLACK);
objLgraphics2D.drawRect(0,intLjButtonWidth,intLjButtonHeight);
objLgraphics2D.dispose();
objPgraphics.drawImage(imgLbuffer,null);
}
项目:incubator-netbeans
文件:HeaderButton.java
项目:openjdk-jdk10
文件:ParsedSynthStyle.java
项目:openjdk-jdk10
文件:BufferStrategyExceptionTest.java
public void render() {
ImageCapabilities imgBackBufCap = new ImageCapabilities(true);
ImageCapabilities imgFrontBufCap = new ImageCapabilities(true);
BufferCapabilities bufCap =
new BufferCapabilities(imgFrontBufCap,imgBackBufCap,BufferCapabilities.FlipContents.copIED);
try {
createBufferStrategy(2,bufCap);
} catch (AWTException ex) {
createBufferStrategy(2);
}
BufferStrategy bs = getBufferStrategy();
do {
Graphics g = bs.getDrawGraphics();
g.setColor(Color.green);
g.fillRect(0,getHeight());
g.setColor(Color.red);
g.drawString("Rendering test",20,20);
g.drawImage(bi,50,null);
g.dispose();
bs.show();
} while (bs.contentsLost()||bs.contentsRestored());
}
项目:Logisim
文件:PainterShaped.java
static void paintOr(InstancePainter painter,int height) {
Graphics g = painter.getGraphics();
GraphicsUtil.switchToWidth(g,2);
/*
* The following,used prevIoUs to version 2.5.1,didn't use GeneralPath
* g.setColor(Color.LIGHT_GRAY); if (width < 40) {
* GraphicsUtil.drawCenteredArc(g,-30,-21,36,-90,53);
* GraphicsUtil.drawCenteredArc(g,21,90,-53); } else if (width < 60)
* { GraphicsUtil.drawCenteredArc(g,-50,-37,62,37,-53); } else {
* GraphicsUtil.drawCenteredArc(g,-70,85,-53); } paintShield(g,* -width,height);
*/
GeneralPath path;
if (width < 40) {
path = PATH_NARROW;
} else if (width < 60) {
path = PATH_MEDIUM;
} else {
path = PATH_WIDE;
}
((Graphics2D) g).draw(path);
if (height > width) {
paintShield(g,height);
}
}
项目:openjdk-jdk10
文件:Slot.java
public int getWidth() {
if (shortName == null || shortName.length() <= 1) {
return figure.SLOT_WIDTH;
} else {
BufferedImage image = new BufferedImage(1,BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setFont(figure.getDiagram().getSlotFont().deriveFont(Font.BOLD));
FontMetrics metrics = g.getFontMetrics();
return Math.max(figure.SLOT_WIDTH,metrics.stringWidth(shortName) + 6);
}
}
@Override
protected void paintText(Graphics g,int tabPlacement,Font font,FontMetrics metrics,int tabIndex,String title,boolean isSelected)
{
g.setFont(font);
View v = getTextViewForTab(tabIndex);
if( v != null )
{
// html
v.paint(g,textRect);
}
else
{
// plain text
int mnemIndex = tabPane.getdisplayedMnemonicIndexAt(tabIndex);
if( tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex) )
{
g.setColor(isSelected ? Color.white : Color.black);
BasicGraphicsUtils.drawStringUnderlineCharat(g,title,mnemIndex,textRect.x,textRect.y + metrics.getAscent());
}
else
{ // tab disabled
g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
BasicGraphicsUtils.drawStringUnderlineCharat(g,textRect.y + metrics.getAscent());
g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
BasicGraphicsUtils.drawStringUnderlineCharat(g,textRect.y + metrics.getAscent());
}
}
}
项目:geomapapp
文件:WWMap.java
public int print(Graphics g,PageFormat fmt,int pageNo) {
if( pageNo>0 ) return NO_SUCH_PAGE;
Graphics2D g2 = (Graphics2D)g;
Dimension dim = wwd.getPreferredSize();
Rectangle r = wwd.getBounds();
if(r.width>dim.width) r.width = dim.width;
if(r.height>dim.height) r.height = dim.height;
org.geomapapp.util.DateFmt df = new org.geomapapp.util.DateFmt();
int secs = (int)(System.currentTimeMillis()/1000L);
String date = df.format(secs);
Font font = new Font("SansSerif",Font.PLAIN,8);
g.setFont( font );
Rectangle2D r2d = font.getStringBounds(date,g2.getFontRenderContext());
// g2.translate( r.getWidth()-20.-r2d.getWidth(),r.getHeight()+18. );
g2.setColor( Color.black);
// g.setClip( new Rectangle( 0,r.width,r.height) );
double w = fmt.getimageableWidth();
double h = fmt.getimageableHeight();
double x = fmt.getimageableX();
double y = fmt.getimageableY();
g2.translate(x,y);
double scale = Math.min( w / r.getWidth(),h / r.getHeight());
int xd = (int)(scale*r.getWidth()-10.-r2d.getWidth());
int yd = (int)(scale*r.getHeight()+18.);
g2.drawString( date,xd,yd);
g2.translate( -r.getX()*scale,-r.getY()*scale );
g2.scale( scale,scale);
wwd.getContext().makeCurrent();
BufferedImage image = Screenshot.readToBufferedImage(r.width,r.height);
g2.drawImage(image,this);
return PAGE_EXISTS;
}
项目:kettle_support_kettle8.0
文件:Captcha.java
/**
* 绘制干扰线
*/
private void drowLine(Graphics g) {
int x = random.nextInt(width);
int y = random.nextInt(height);
int x0 = random.nextInt(16);
int y0 = random.nextInt(16);
g.drawLine(x,x + x0,y + y0);
}
项目:gitplex-mit
文件:AvatarGenerator.java
public static BufferedImage generate(int width,int height,String message,String fontFamily,Color background,Color foreground) {
BufferedImage bi = new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB);
Graphics ig2 = null;
try {
ig2 = bi.getGraphics();
ig2.setColor(background);
ig2.fillRect(0,height);
int fontSize = new Double(height * 0.5d).intValue();
Font font = new Font(fontFamily,fontSize);
Map<TextAttribute,Object> map = new Hashtable<TextAttribute,Object>();
map.put(TextAttribute.WEIGHT,TextAttribute.WEIGHT_BOLD);
font = font.deriveFont(map);
ig2.setFont(font);
ig2.setColor(foreground);
drawCenteredString(message.toupperCase(),ig2);
} finally {
if (ig2 != null)
ig2.dispose();
}
return bi;
}
/**
* creates a JFrame and a background Thread managing the rendering and the Frame itself.
*/
public static void create(){
if(!running){
running = true;
GFrame = new JFrame();
GFrame.setVisible(true);
RefreshWindow();
RegisterInputDevices();
BStrategy = GFrame.getBufferStrategy();
setCurrentscreen(new EmptyScreen());
PhySIX = new Thread(new Runnable(){
@Override
public void run() {
try {
while(GFrame.isVisible()){
Graphics g = BStrategy.getDrawGraphics();
clearScreen(g);
updateDHs(g);
renderDHs(g);
drawDHs(g);
drawmodels(g);
UpdateStrat(g);
Sync();
}
} catch (LessthanZeroException e) {
e.printstacktrace();
}
}
},"display-Loop-Thread.");
PhySIX.start();
}
}
项目:oscm
文件:ImageProducer.java
protected BufferedImage createImage(Color bgColor) {
BufferedImage bufferedImage = new BufferedImage(END_X,END_Y,BufferedImage.TYPE_INT_RGB);
// create graphics and graphics2d
final Graphics graphics = bufferedImage.getGraphics();
final Graphics2D g2d = (Graphics2D) graphics;
// set the background color
g2d.setBackground(bgColor == null ? Color.gray : bgColor);
g2d.clearRect(START_X,START_Y,END_X,END_Y);
// create a pattern for the background
createPattern(g2d);
// set the fonts and font rendering hints
Font font = new Font("Helvetica",Font.ITALIC,30);
g2d.setFont(font);
FontRenderContext frc = g2d.getFontRenderContext();
g2d.translate(10,24);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setstroke(new Basicstroke(3));
// sets the foreground color
g2d.setPaint(Color.DARK_GRAY);
GlyphVector gv = font.createGlyphVector(frc,message);
int numGlyphs = gv.getNumGlyphs();
for (int ii = 0; ii < numGlyphs; ii++) {
AffineTransform at;
Point2D p = gv.getGlyPHPosition(ii);
at = AffineTransform.getTranslateInstance(p.getX(),p.getY());
at.rotate(Math.PI / 8);
Shape shape = gv.getGlyphOutline(ii);
Shape sss = at.createTransformedShape(shape);
g2d.fill(sss);
}
return blurImage(bufferedImage);
}
项目:PengueeBot
文件:GrabPanel.java
public void paint(Graphics g) {
g.setColor(new Color(192,192,192));
Insets insets = getInsets();
if (orientation == HORIZONTAL)
g.drawLine(insets.left,insets.top,getWidth() - insets.right,insets.top);
else
g.drawLine(insets.left,insets.left,getHeight() - insets.bottom);
}
项目:jdk8u-jdk
文件:ParsedSynthStyle.java
public void paintSliderTrackBackground(SynthContext context,int h,int orientation) {
for (SynthPainter painter: painters) {
painter.paintSliderTrackBackground(context,h,orientation);
}
}
项目:Logisim
文件:TableTab.java
private void computePreferredSize() {
int inputs = table.getInputColumnCount();
int outputs = table.getoutputColumnCount();
if (inputs == 0 && outputs == 0) {
setPreferredSize(new Dimension(0,0));
return;
}
Graphics g = getGraphics();
if (g == null) {
cellHeight = 16;
cellWidth = 24;
} else {
FontMetrics fm = g.getFontMetrics(HEAD_FONT);
cellHeight = fm.getHeight();
cellWidth = 24;
if (inputs == 0 || outputs == 0) {
cellWidth = Math.max(cellWidth,fm.stringWidth(Strings.get("tableNullHeader")));
}
for (int i = 0; i < inputs + outputs; i++) {
String header = i < inputs ? table.getInputHeader(i) : table.getoutputHeader(i - inputs);
cellWidth = Math.max(cellWidth,fm.stringWidth(header));
}
}
if (inputs == 0)
inputs = 1;
if (outputs == 0)
outputs = 1;
tableWidth = (cellWidth + COLUMN_SEP) * (inputs + outputs) - COLUMN_SEP;
tableHeight = cellHeight * (1 + table.getRowCount()) + HEADER_SEP;
setPreferredSize(new Dimension(tableWidth,tableHeight));
revalidate();
repaint();
}
项目:VASSAL-src
文件:Embellishment.java
public void draw(Graphics g,Component obs,double zoom) {
final boolean drawUnder = drawUnderneathWhenSelected && Boolean.TRUE.equals(getProperty(Properties.SELECTED));
if (!drawUnder) {
piece.draw(g,obs,zoom);
}
checkPropertyLevel();
if (!isActive()) {
if (drawUnder) {
piece.draw(g,zoom);
}
return;
}
final int i = value - 1;
if (i < imagePainter.length && imagePainter[i] != null) {
final Rectangle r = getCurrentimageBounds();
imagePainter[i].draw(g,x + (int)(zoom*r.x),y + (int)(zoom*r.y),zoom,obs);
}
if (drawUnder) {
piece.draw(g,zoom);
}
}
public void runTest(Object ctx,int numReps) {
RenderTests.Context rctx = (RenderTests.Context) ctx;
int size = rctx.size;
int x = rctx.initX;
int y = rctx.initY;
Graphics g = rctx.graphics;
g.translate(rctx.orgX,rctx.orgY);
Color rCArray[] = rctx.colorlist;
int ci = rctx.colorindex;
if (rctx.animate) {
do {
if (rCArray != null) {
g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
}
g.filloval(x,size,size);
if ((x -= 3) < 0) x += rctx.maxX;
if ((y -= 1) < 0) y += rctx.maxY;
} while (--numReps > 0);
} else {
do {
if (rCArray != null) {
g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
}
g.filloval(x,size);
} while (--numReps > 0);
}
rctx.colorindex = ci;
g.translate(-rctx.orgX,-rctx.orgY);
}
项目:incubator-netbeans
文件:AxisComponent.java
protected void paintVerticalTick(Graphics g,AxisMark mark,Rectangle clip,Rectangle chartMask) {
g.setColor(getForeground());
if (location == SwingConstants.WEST) {
g.drawLine(getWidth() - 2 - getAxisBasisExtent(),getWidth() - 2,y);
} else {
g.drawLine(1,1 + getAxisBasisExtent(),y);
}
}
项目:openjdk-jdk10
文件:CaretFloatingPointAPITest.java
@Override
public void paint(Graphics g) {
if (component == null) {
return;
}
int dot = getDot();
Rectangle2D r = null;
try {
r = component.modelToView2D(dot);
} catch (BadLocationException e) {
return;
}
if (r == null) {
return;
}
Rectangle2D cr = getCaretRectangle(r);
repaint(cr.getBounds());
g.setColor(component.getCaretColor());
float cx = (float) cr.getX();
float cy = (float) cr.getY();
float cw = (float) cr.getWidth();
float ch = (float) cr.getHeight();
float c = cx + cw / 2;
Graphics2D g2d = (Graphics2D) g;
g2d.draw(new Line2D.Float(c,cy,c,cy + ch));
g2d.draw(new Line2D.Float(cx,cx + cw,cy));
g2d.draw(new Line2D.Float(cx,cy + ch,cy + ch));
}
项目:defense-solutions-proofs-of-concept
文件:EquipmentListJPanel.java
/**
* Sets the names of the equipment for which buttons should display.
* @param equipmentNames the names of the equipment for which buttons should display.
*/
public void setEquipmentNames(List<String> equipmentNames) {
removeAll();
for (final String name : equipmentNames) {
JButton button = new JButton(name) {
@Override
public void paint(Graphics g) {
if (null == getIcon()) {
//Doing this here because it's expensive,so only
//do it when we actually need it.
setIcon(new ImageIcon(mil2525CSymbolController.getSymbolImage(name)));
}
super.paint(g);
}
};
button.setFont(BUTTON_FONT);
button.setHorizontalAlignment(SwingConstants.LEFT);
button.setFocusable(false);
button.setMaximumSize(new Dimension(Integer.MAX_VALUE,60));
button.setMinimumSize(new Dimension(0,60));
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
for (ActionListener listener : listeners) {
listener.actionPerformed(e);
}
}
});
add(button);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。