互联网络

e666. 创建缓冲图像

Abufferedimageisatypeofimagewhosepixelscanbemodified.Forexample,youcandrawonabufferedimageandthendrawtheresultingbufferedimageonthescreenorsaveittoafile.Abuffer...
代码星球·2021-02-11

e680. 使三元色图像变明变暗

ThisexampledemonstrateshowtobrightenordarkenanRGBbufferedimagebyscalingthered,green,andbluevaluesintheimage.//Tocreateabufferedimage,seee666创建缓冲图像//Brightenthei...

e656. 创建基本图形

Shapeline=newLine2D.Float(x1,y1,x2,y2);Shapearc=newArc2D.Float(x,y,w,h,start,extent,type);Shapeoval=newEllipse2D.Float(x,y,w,h);Shaperectangle=newRectangle2D.Fl...
代码星球·2021-02-11

e659. 缩放,剪取,移动,翻转图形

AffineTransformtx=newAffineTransform();tx.scale(scalex,scaley);tx.shear(shiftx,shifty);tx.translate(x,y);tx.rotate(radians);ShapenewShape=tx.createTransformedSh...

e657. 用直线和曲线绘制图形

GeneralPathshape=newGeneralPath();shape.moveTo(x,y);shape.lineTo(x,y);shape.quadTo(controlPointX,controlPointY,x,y);shape.curveTo(controlPointX1,controlPointY1,...

e655. 混合风格的文本

Thisexampleappliesanewfontandbackgroundcolortoapartofthetext.Youcanapplystylestoasmanypartsofthetextasyouneed.SeeTextAttributesforavailablestyles.//Applystylest...
代码星球·2021-02-11

e658. 组合图形

Areashape=newArea(shape1);shape.add(newArea(shape2));shape.subtract(newArea(shape3));shape.intersect(newArea(shape4));shape.exclusiveOr(newArea(shape5)); R...
代码星球·2021-02-11

e654. 获得文本的缩略图

ShapegetTextShape(Graphics2Dg2d,Stringstr,Fontfont){FontRenderContextfrc=g2d.getFontRenderContext();TextLayouttl=newTextLayout(str,font,frc);returntl.getOutline...
代码星球·2021-02-11

e651. 列出所有可用字体

Afontfamilyreferstoasetoffontfaceswitharelatedtypographicdesign.Forexample,thefontfacesinthefamilyLucidaSansTypewritermightbeLucidaSansTypewriterBold,andLucidaS...

e653. 写入段落文本

Inordertochangethefontofthetext,youneedtosupplyanattributedstringtotheLineBreakMeasurer.Seee655混合风格的文本foranexample.publicvoiddrawParagraph(Graphics2Dg,Stringpar...
代码星球·2021-02-11

e647. 处理鼠标移动事件

component.addMouseMotionListener(newMyMouseMotionListener());publicclassMyMouseMotionListenerextendsMouseMotionAdapter{publicvoidmouseMoved(MouseEventevt){//Pro...

e648. 双击和三击事件

component.addMouseListener(newMyMouseListener());publicclassMyMouseListenerextendsMouseAdapter{publicvoidmouseClicked(MouseEventevt){if(evt.getClickCount()==3){...
代码星球·2021-02-11

e646. 处理鼠标点击事件

component.addMouseListener(newMyMouseListener());publicclassMyMouseListenerextendsMouseAdapter{publicvoidmouseClicked(MouseEventevt){if((evt.getModifiers()&...

e645. 处理键盘事件

Youcangetthekeythatwaspressedeitherasakeycharacter(whichisaUnicodecharacter)orasakeycode(aspecialvaluerepresentingaparticularkeyonthekeyboard).component.addKeyL...
代码星球·2021-02-11

e650. 激活事件

AnobjectwishingtofireitemeventsmustimplementItemSelectable.Thisexampleshowstypicalcodethatanobjectmustimplementtofireitemevents.Whenanitemeventistobefired,fireI...
代码星球·2021-02-11