📄 qtgraphics.java
字号:
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { draw( new RoundRectangle2D.Double(x, y, width, height, arcWidth, arcHeight) ); } public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { fill( new RoundRectangle2D.Double(x, y, width, height, arcWidth, arcHeight) ); } public void drawOval(int x, int y, int width, int height) { draw( new Ellipse2D.Double((double)x, (double)y, (double)width, (double)height) ); } public void fillOval(int x, int y, int width, int height) { fill( new Ellipse2D.Double(x, y, width, height) ); } public void drawArc(int x, int y, int width, int height, int arcStart, int arcAngle) { draw( new Arc2D.Double(x, y, width, height, arcStart, arcAngle, Arc2D.OPEN) ); } public void fillArc(int x, int y, int width, int height, int arcStart, int arcAngle) { fill( new Arc2D.Double(x, y, width, height, arcStart, arcAngle, Arc2D.CHORD) ); } public void drawPolyline(int xPoints[], int yPoints[], int npoints) { for( int i = 0; i < npoints - 1; i++) drawLine(xPoints[i], yPoints[i], xPoints[i + 1], yPoints[i + 1]); } public void drawPolygon(int xPoints[], int yPoints[], int npoints) { draw( new Polygon(xPoints, yPoints, npoints) ); } public void fillPolygon(int xPoints[], int yPoints[], int npoints) { fill( new Polygon(xPoints, yPoints, npoints) ); } public native void fill3DRect(int x, int y, int width, int height, boolean raised); public native void draw3DRect(int x, int y, int width, int height, boolean raised); // *********************** Text rendering ************************* public void drawString(String string, int x, int y) { drawStringNative(string, (double)x, (double)y); } public void drawString(String string, float x, float y) { drawStringNative(string, (double)x, (double)y); } public void drawString (AttributedCharacterIterator ci, int x, int y) { // FIXME - to something more correct ? String s = ""; for(char c = ci.first(); c != CharacterIterator.DONE; c = ci.next()) s += c; drawString(s, x, y); } public void drawString(AttributedCharacterIterator ci, float x, float y) { // FIXME - to something more correct ? String s = ""; for(char c = ci.first(); c != CharacterIterator.DONE; c = ci.next()) s += c; drawString(s, x, y); } public void drawGlyphVector(GlyphVector v, float x, float y) { throw new RuntimeException("Not implemented"); } // ******************* Image drawing ****************************** public boolean drawImage(Image image, AffineTransform Tx, ImageObserver obs) { if (image instanceof QtImage) return ((QtImage)image).drawImage(this, new QMatrix( Tx ), obs); return (new QtImage(image.getSource())).drawImage(this, new QMatrix( Tx ), obs); } public boolean drawImage(Image image, int x, int y, Color bgcolor, ImageObserver observer) { if (image instanceof QtImage) return ((QtImage)image).drawImage (this, x, y, bgcolor, observer); return (new QtImage(image.getSource())).drawImage (this, x, y, bgcolor, observer); } public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) { if (image instanceof QtImage) return ((QtImage)image).drawImage(this, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer); return (new QtImage(image.getSource())).drawImage(this, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer); } public boolean drawImage(Image image, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) { if (image instanceof QtImage) return ((QtImage)image).drawImage (this, x, y, width, height, bgcolor, observer); return (new QtImage(image.getSource())).drawImage (this, x, y, width, height, bgcolor, observer); } public boolean drawImage(Image image, int x, int y, int width, int height, ImageObserver observer) { return drawImage(image, x, y, width, height, null, observer); } public boolean drawImage(Image image, int x, int y, ImageObserver observer) { return drawImage(image, x, y, null, observer); } public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) { return drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null, observer); } // *********************** Transform methods ************************* public AffineTransform getTransform() { return new AffineTransform( xform ); } public void setTransform(AffineTransform Tx) { xform = new AffineTransform( Tx ); setQtTransform( new QMatrix( xform ) ); } public void rotate(double theta) { xform.rotate( theta ); setQtTransform( new QMatrix( xform ) ); } public void rotate(double theta, double x, double y) { xform.rotate(theta, x, y); setQtTransform( new QMatrix( xform ) ); } public void scale(double sx, double sy) { xform.scale(sx, sy); setQtTransform( new QMatrix( xform ) ); } public void shear(double shx, double shy) { xform.shear(shx, shy); setQtTransform( new QMatrix( xform ) ); } public void transform(AffineTransform Tx) { xform.concatenate( Tx ); setQtTransform( new QMatrix( xform ) ); } public void translate(double tx, double ty) { xform.translate( tx, ty ); setQtTransform( new QMatrix( xform ) ); } public void translate(int x, int y) { translate((double)x, (double)y); } // *************** Stroking, Filling, Compositing ***************** public void setStroke(Stroke s) { try // ..to convert the stroke into a native one. { QPen pen = new QPen( s ); nativeStroking = true; setNativeStroke( pen ); setColor( color ); } catch (IllegalArgumentException e) { nativeStroking = false; } currentStroke = s; } public Stroke getStroke() { // FIXME: return copy? return currentStroke; } public void setComposite(Composite comp) { if( comp == null) { setNativeComposite( AlphaComposite.SRC_OVER ); return; } if( comp instanceof AlphaComposite ) { if( ((AlphaComposite)comp).getRule() != AlphaComposite.XOR ) setAlpha( ((AlphaComposite)comp).getAlpha() ); setNativeComposite( ((AlphaComposite)comp).getRule() ); composite = comp; } else throw new UnsupportedOperationException("We don't support custom"+ " composites yet."); } public Composite getComposite() { return composite; } public void setPaint(Paint p) { if( p == null ) return; // FIXME currentPaint = p; if( p instanceof GradientPaint ) { GradientPaint lg = (GradientPaint)p; setLinearGradient(lg.getColor1().getRed(), lg.getColor1().getGreen(), lg.getColor1().getBlue(), lg.getColor2().getRed(), lg.getColor2().getGreen(), lg.getColor2().getBlue(), lg.getPoint1().getX(), lg.getPoint1().getY(), lg.getPoint2().getX(), lg.getPoint2().getY(), lg.isCyclic() ); return; } if( p instanceof Color ) { setColor((Color) p); return; } throw new UnsupportedOperationException("We don't support custom"+ " paints yet."); } public Paint getPaint() { // FIXME return currentPaint; } // ********************** Rendering Hints ************************* public void addRenderingHints(Map hints) { renderingHints.putAll( hints ); } public Object getRenderingHint(RenderingHints.Key hintKey) { return renderingHints.get( hintKey ); } public RenderingHints getRenderingHints() { return new RenderingHints( renderingHints ); } public void setRenderingHints(Map hints) { renderingHints = new RenderingHints( hints ); updateRenderingHints(); } public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue) { renderingHints.put( hintKey, hintValue ); updateRenderingHints(); } private void updateRenderingHints() { // FIXME - update native settings. } ////////////////////////////// unimplemented ///////////////////// public FontRenderContext getFontRenderContext() { throw new UnsupportedOperationException("Not implemented yet"); } public void drawRenderableImage(RenderableImage image, AffineTransform xform) { throw new UnsupportedOperationException("Not implemented yet"); } public void drawRenderedImage(RenderedImage image, AffineTransform xform) { throw new UnsupportedOperationException("Not implemented yet"); } public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y) { throw new UnsupportedOperationException("Not implemented yet"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -