⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdkgraphics2d.java

📁 gcc的JAVA模块的源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    if (cm == null)      cm = ColorModel.getRGBdefault ();    double[] i2u = new double[6];    if (imageToUser != null)      imageToUser.getMatrix(i2u);    else      {        i2u[0] = 1; i2u[1] = 0;        i2u[2] = 0; i2u[3] = 1;        i2u[2] = 0; i2u[3] = 0;      }    int pixels[] = null;    if (sm.getDataType () == DataBuffer.TYPE_INT &&        db instanceof DataBufferInt &&        db.getNumBanks () == 1)      {        // single bank, ARGB-ints buffer in sRGB space        DataBufferInt dbi = (DataBufferInt)db;        pixels = dbi.getData ();      }    else      pixels = r.getPixels (0, 0, r.getWidth (), r.getHeight (), pixels);        ColorSpace cs = cm.getColorSpace ();    if (cs != null &&         cs.getType () != ColorSpace.CS_sRGB)      {        int pixels2[] = new int[pixels.length];                for (int i = 0; i < pixels2.length; i++)          pixels2[i] = cm.getRGB (pixels[i]);                pixels = pixels2;      }        stateSave ();    translate (x, y);    drawPixels (pixels, r.getWidth (), r.getHeight (), r.getWidth (), i2u);    stateRestore ();        return true;  }  public void drawRenderedImage(RenderedImage image,                                AffineTransform xform)  {    drawRaster (image.getColorModel(), image.getData(), xform);  }    public void drawRenderableImage(RenderableImage image,                                  AffineTransform xform)  {    drawRenderedImage (image.createRendering (new RenderContext (xform)), xform);  }    public boolean drawImage(Image img,                            AffineTransform xform,                           ImageObserver obs)  {    if (img instanceof GtkOffScreenImage &&        img.getGraphics () instanceof GdkGraphics2D &&                    (xform == null          || xform.getType () == AffineTransform.TYPE_IDENTITY          || xform.getType () == AffineTransform.TYPE_TRANSLATION)        )       {        // we are being asked to flush a double buffer from Gdk        GdkGraphics2D g2 = (GdkGraphics2D) img.getGraphics ();        gdkDrawDrawable (g2, (int)xform.getTranslateX(), (int)xform.getTranslateY());        return true;      }    else      {        if (img instanceof BufferedImage)          {            // draw an image which has actually been loaded into memory fully            BufferedImage b = (BufferedImage) img;            return drawRaster (b.getColorModel (), b.getData (), xform);          }                else          {            // begin progressive loading in a separate thread            new PainterThread (this, img, xform);            return false;          }      }  }  public void drawImage(BufferedImage image,                        BufferedImageOp op,                        int x,                        int y)  {    Image filtered = op.filter(image, null);    drawImage(filtered, new AffineTransform(1f,0f,0f,1f,x,y), null);  }  public boolean drawImage (Image img, int x, int y,                             ImageObserver observer)  {    return drawImage(img, new AffineTransform(1f,0f,0f,1f,x,y), observer);      }  ////////////////////////////////////////  ////// Supporting Private Classes //////  ////////////////////////////////////////    private class PainterThread implements Runnable, ImageConsumer  {    // this is a helper which is spun off when someone tries to do    // Graphics2D.drawImage on an image we cannot determine to be either    // one of our own offscreen images or a BufferedImage; that is, when    // someone wants to draw an image which is possibly still loading over    // a network or something. you run it in a separate thread and it    // writes through to the underlying Graphics2D as pixels becomg    // available.    GdkGraphics2D gr;    Image image;    ColorModel defaultModel;    AffineTransform xform;    public PainterThread (GdkGraphics2D g, Image im, AffineTransform xf)    {      image = im;      xform = xf;      this.gr = (GdkGraphics2D) g.create ();      new Thread (this).start ();    }        public void imageComplete (int status)    {    }        public void setColorModel (ColorModel model)     {      defaultModel = model;    }        public void setDimensions (int width, int height)    {    }        public void setHints (int hintflags)    {    }        public void setPixels (int x, int y, int w, int h, ColorModel model,                            byte[] pixels, int off, int scansize)    {    }        public void setPixels (int x, int y, int w, int h, ColorModel model,                            int[] pixels, int off, int scansize)      {        gr.stateSave ();        gr.translate (x, y);        if (model == null)          model = defaultModel;        int pixels2[];        if (model != null)          {            pixels2 = new int[pixels.length];            for (int yy = 0; yy < h; yy++)              for (int xx = 0; xx < w; xx++)                {                  int i = yy * scansize + xx;                  pixels2[i] = model.getRGB (pixels[i]);                }          }        else          pixels2 = pixels;        double[] xf = new double[6];        xform.getMatrix(xf);                gr.drawPixels (pixels2, w, h, scansize, xf);        gr.stateRestore ();      }    public void setProperties (java.util.Hashtable props)    {    }        public void run ()    {      image.getSource ().startProduction (this);      gr.dispose ();    }  }  ///////////////////////////////////////////////  ////// Unimplemented Stubs and Overloads //////  ///////////////////////////////////////////////        public boolean hit(Rectangle rect, Shape text,                     boolean onStroke)  {    throw new java.lang.UnsupportedOperationException ();  }  public GraphicsConfiguration getDeviceConfiguration()  {    throw new java.lang.UnsupportedOperationException ();  }  public void setComposite(Composite comp)  {    throw new java.lang.UnsupportedOperationException ();  }  public void setRenderingHint(RenderingHints.Key hintKey,                               Object hintValue)  {    hints.put (hintKey, hintValue);      }  public Object getRenderingHint(RenderingHints.Key hintKey)  {    return hints.get (hintKey);  }    public void setRenderingHints(Map hints)  {    this.hints = new RenderingHints (getDefaultHints ());    this.hints.add (new RenderingHints (hints));  }  public void addRenderingHints(Map hints)  {    this.hints.add (new RenderingHints (hints));  }  public RenderingHints getRenderingHints()  {    return hints;  }  public Composite getComposite()  {    throw new java.lang.UnsupportedOperationException ();  }  public FontRenderContext getFontRenderContext ()  {    return new FontRenderContext (transform, true, true);  }  public void drawGlyphVector (GlyphVector g, float x, float y)  {        stateSave ();    setFont (g.getFont ());    translate ((double)x, (double)y);    cairoMoveTo (0, 0);    int nglyphs = g.getNumGlyphs ();    int codes[] = g.getGlyphCodes (0, nglyphs, (int []) null);    float posns[] = g.getGlyphPositions (0, nglyphs, (float []) null);    cairoShowGlyphs (codes, posns);    stateRestore ();  }  public void copyArea (int x, int y, int width, int height, int dx, int dy)  {    throw new java.lang.UnsupportedOperationException ();  }  public void drawArc (int x, int y, int width, int height,                       int startAngle, int arcAngle)  {    draw (new Arc2D.Double((double)x, (double)y,                            (double)width, (double)height,                           (double)startAngle, (double)arcAngle,                           Arc2D.OPEN));  }  public boolean drawImage (Image img, int x, int y, Color bgcolor,                             ImageObserver observer)  {    throw new java.lang.UnsupportedOperationException ();  }  public boolean drawImage (Image img, int x, int y, int width, int height,                             Color bgcolor, ImageObserver observer)  {    throw new java.lang.UnsupportedOperationException ();  }  public boolean drawImage (Image img, int x, int y, int width, int height,                             ImageObserver observer)  {    throw new java.lang.UnsupportedOperationException ();  }  public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2,                             int sx1, int sy1, int sx2, int sy2,                             Color bgcolor, ImageObserver observer)  {    throw new java.lang.UnsupportedOperationException ();  }  public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2,                             int sx1, int sy1, int sx2, int sy2,                             ImageObserver observer)   {    throw new java.lang.UnsupportedOperationException ();  }  public void drawOval(int x, int y, int width, int height)  {    drawArc (x, y, width, height, 0, 360);  }  public void drawRoundRect(int x, int y, int width, int height,                             int arcWidth, int arcHeight)  {    int x1 = x + arcWidth, x2 = x + width - arcWidth;    int y1 = y + arcHeight, y2 = y + height - arcHeight;    fillRect (x1, y, x2 - x1, height);    fillRect (x, y1, width, y2 - y1);    fillArc (x, y, arcWidth, arcHeight, 90, 90);    fillArc (x1, y, arcWidth, arcHeight, 0, 90);    fillArc (x2, y2, arcWidth, arcHeight, 270, 90);    fillArc (x, y2, arcWidth, arcHeight, 180, 90);  }  public void drawString (String str, int x, int y)  {    drawString (str, (float)x, (float)y);  }  public void drawString (String str, float x, float y)  {    GlyphVector gv = font.createGlyphVector (getFontRenderContext(), str);    drawGlyphVector (gv, x, y);  }  public void drawString (AttributedCharacterIterator ci, int x, int y)  {    drawString (ci, (float)x, (float)y);  }  public void drawString (AttributedCharacterIterator ci, float x, float y)  {    GlyphVector gv = font.createGlyphVector (getFontRenderContext(), ci);    drawGlyphVector (gv, x, y);  }  public void fillArc (int x, int y, int width, int height,                        int startAngle, int arcAngle)  {    fill (new Arc2D.Double((double)x, (double)y,                            (double)width, (double)height,                           (double)startAngle, (double)arcAngle,                           Arc2D.OPEN));  }  public void fillOval(int x, int y, int width, int height)  {    fillArc (x, y, width, height, 0, 360);  }  public void fillRoundRect (int x, int y, int width, int height,                              int arcWidth, int arcHeight)  {    int x1 = x + arcWidth, x2 = x + width - arcWidth;    int y1 = y + arcHeight, y2 = y + height - arcHeight;    fillRect (x1, y, x2 - x1, height);    fillRect (x, y1, width, y2 - y1);    fillArc (x, y, arcWidth, arcHeight, 90, 90);    fillArc (x1, y, arcWidth, arcHeight, 0, 90);    fillArc (x2, y2, arcWidth, arcHeight, 270, 90);    fillArc (x, y2, arcWidth, arcHeight, 180, 90);  }  public Font getFont ()  {    return font;  }  public FontMetrics getFontMetrics ()  {    return Toolkit.getDefaultToolkit ().getFontMetrics (font);  }  public FontMetrics getFontMetrics (Font f)  {    return Toolkit.getDefaultToolkit ().getFontMetrics (f);  }  public void setFont (Font f)  {    if (f.getPeer() instanceof GdkClasspathFontPeer)      font = f;    else      font =         ((ClasspathToolkit)(Toolkit.getDefaultToolkit ()))        .getFont (f.getName(), f.getAttributes ());    if (f != null &&         f.getPeer() instanceof GdkClasspathFontPeer)      cairoSetFont ((GdkClasspathFontPeer) f.getPeer());  }  public String toString()  {    throw new java.lang.UnsupportedOperationException ();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -