Java 类org.eclipse.swt.graphics.Pattern 实例源码

项目:translationstudio8    文件:BackgroundImagePainter.java   
@Override
public void paintCell(LayerCell cell, GC gc, Rectangle rectangle, IConfigRegistry configRegistry) {
    // Save GC settings
    Color originalBackground = gc.getBackground();
    Color originalForeground = gc.getForeground();

    gc.setBackgroundPattern(new Pattern(Display.getCurrent(), bgImage));

    gc.fillRectangle(rectangle);
    gc.setBackgroundPattern(null);

    if (isNotNull(separatorColor)) {
        gc.setForeground(separatorColor);
        gc.drawLine(rectangle.x - 1, rectangle.y, rectangle.x - 1, rectangle.y + rectangle.height);
        gc.drawLine(rectangle.x - 1 + rectangle.width, rectangle.y, rectangle.x - 1 + rectangle.width, rectangle.y + rectangle.height);
    }

    // Restore original GC settings
    gc.setBackground(originalBackground);
    gc.setForeground(originalForeground);

    // Draw interior
    Rectangle interiorBounds = new Rectangle(rectangle.x + 2, rectangle.y + 2, rectangle.width - 4, rectangle.height - 4);
    super.paintCell(cell, gc, interiorBounds, configRegistry);
}
项目:translationstudio8    文件:PercentageBarDecorator.java   
@Override
public void paintCell(LayerCell cell, GC gc, Rectangle rectangle, IConfigRegistry configRegistry) {
    Color originalBackground = gc.getBackground();

    double factor = Math.min(1.0, ((Double) cell.getDataValue()).doubleValue());
    factor = Math.max(0.0, factor);

    Rectangle bar = new Rectangle(rectangle.x, rectangle.y, (int)(rectangle.width * factor), rectangle.height);
    Rectangle bounds = cell.getBounds();
    gc.setBackgroundPattern(new Pattern(Display.getCurrent(),
            bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height,
            GUIHelper.getColor(new RGB(187, 216, 254)),
            GUIHelper.getColor(new RGB(255, 255, 255))));
    gc.fillRectangle(bar);

    gc.setBackground(originalBackground);

    super.paintCell(cell, gc, rectangle, configRegistry);
}
项目:tmxeditor8    文件:BackgroundImagePainter.java   
@Override
public void paintCell(LayerCell cell, GC gc, Rectangle rectangle, IConfigRegistry configRegistry) {
    // Save GC settings
    Color originalBackground = gc.getBackground();
    Color originalForeground = gc.getForeground();

    gc.setBackgroundPattern(new Pattern(Display.getCurrent(), bgImage));

    gc.fillRectangle(rectangle);
    gc.setBackgroundPattern(null);

    if (isNotNull(separatorColor)) {
        gc.setForeground(separatorColor);
        gc.drawLine(rectangle.x - 1, rectangle.y, rectangle.x - 1, rectangle.y + rectangle.height);
        gc.drawLine(rectangle.x - 1 + rectangle.width, rectangle.y, rectangle.x - 1 + rectangle.width, rectangle.y + rectangle.height);
    }

    // Restore original GC settings
    gc.setBackground(originalBackground);
    gc.setForeground(originalForeground);

    // Draw interior
    Rectangle interiorBounds = new Rectangle(rectangle.x + 2, rectangle.y + 2, rectangle.width - 4, rectangle.height - 4);
    super.paintCell(cell, gc, interiorBounds, configRegistry);
}
项目:tmxeditor8    文件:PercentageBarDecorator.java   
@Override
public void paintCell(LayerCell cell, GC gc, Rectangle rectangle, IConfigRegistry configRegistry) {
    Color originalBackground = gc.getBackground();

    double factor = Math.min(1.0, ((Double) cell.getDataValue()).doubleValue());
    factor = Math.max(0.0, factor);

    Rectangle bar = new Rectangle(rectangle.x, rectangle.y, (int)(rectangle.width * factor), rectangle.height);
    Rectangle bounds = cell.getBounds();
    gc.setBackgroundPattern(new Pattern(Display.getCurrent(),
            bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height,
            GUIHelper.getColor(new RGB(187, 216, 254)),
            GUIHelper.getColor(new RGB(255, 255, 255))));
    gc.fillRectangle(bar);

    gc.setBackground(originalBackground);

    super.paintCell(cell, gc, rectangle, configRegistry);
}
项目:gef-gwt    文件:SWTGraphics.java   
/**
 * @see Graphics#setBackgroundPattern(Pattern)
 */
public void setBackgroundPattern(Pattern pattern) {
    currentState.graphicHints |= ADVANCED_GRAPHICS_MASK;
    if (currentState.bgPattern == pattern) {
        return;
    }
    currentState.bgPattern = pattern;

    if (pattern != null) {
        initTransform(true);
    }
    gc.setBackgroundPattern(pattern);
}
项目:gef-gwt    文件:SWTGraphics.java   
/**
 * @see Graphics#setForegroundPattern(Pattern)
 */
public void setForegroundPattern(Pattern pattern) {
    currentState.graphicHints |= ADVANCED_GRAPHICS_MASK;
    if (currentState.fgPattern == pattern) {
        return;
    }
    currentState.fgPattern = pattern;

    if (pattern != null) {
        initTransform(true);
    }
    gc.setForegroundPattern(pattern);
}
项目:birt    文件:PatternImageEditorDialog.java   
private static void drawItem( GC gc, PatternImage patternImage, int x,
        int y )
{
    int width = VIEW_WIDTH;
    int height = VIEW_HEIGHT;
    Device device = gc.getDevice( );
    Image image = createImageFromPattern( patternImage );
    Pattern pattern = new Pattern( device, image );
    gc.setBackgroundPattern( pattern );
    gc.fillRectangle( x, y, width, height );
    pattern.dispose( );
    image.dispose( );
}
项目:kettle-trunk    文件:Sleak.java   
void refreshLabel () {
    int colors = 0, cursors = 0, fonts = 0, gcs = 0, images = 0;
    int paths = 0, patterns = 0, regions = 0, textLayouts = 0, transforms= 0;
    for (int i=0; i<objects.length; i++) {
        Object object = objects [i];
        if (object instanceof Color) colors++;
        if (object instanceof Cursor) cursors++;
        if (object instanceof Font) fonts++;
        if (object instanceof GC) gcs++;
        if (object instanceof Image) images++;
        if (object instanceof Path) paths++;
        if (object instanceof Pattern) patterns++;
        if (object instanceof Region) regions++;
        if (object instanceof TextLayout) textLayouts++;
        if (object instanceof Transform) transforms++;
    }
    String string = "";
    if (colors != 0) string += colors + " Color(s)\n";
    if (cursors != 0) string += cursors + " Cursor(s)\n";
    if (fonts != 0) string += fonts + " Font(s)\n";
    if (gcs != 0) string += gcs + " GC(s)\n";
    if (images != 0) string += images + " Image(s)\n";
    if (paths != 0) string += paths + " Paths(s)\n";
    if (patterns != 0) string += patterns + " Pattern(s)\n";
    if (regions != 0) string += regions + " Region(s)\n";
    if (textLayouts != 0) string += textLayouts + " TextLayout(s)\n";
    if (transforms != 0) string += transforms + " Transform(s)\n";
    if (string.length () != 0) {
        string = string.substring (0, string.length () - 1);
    }
    label.setText (string);
}
项目:TranskribusSwtGui    文件:Sleak.java   
void refreshLabel() {
    int colors = 0, cursors = 0, fonts = 0, gcs = 0, images = 0;
    int paths = 0, patterns = 0, regions = 0, textLayouts = 0, transforms = 0;
    for (int i = 0; i < objects.length; i++) {
        Object object = objects[i];
        if (object instanceof Color)
            colors++;
        if (object instanceof Cursor)
            cursors++;
        if (object instanceof Font)
            fonts++;
        if (object instanceof GC)
            gcs++;
        if (object instanceof Image)
            images++;
        if (object instanceof Path)
            paths++;
        if (object instanceof Pattern)
            patterns++;
        if (object instanceof Region)
            regions++;
        if (object instanceof TextLayout)
            textLayouts++;
        if (object instanceof Transform)
            transforms++;
    }
    String string = "";
    if (colors != 0)
        string += colors + " Color(s)\n";
    if (cursors != 0)
        string += cursors + " Cursor(s)\n";
    if (fonts != 0)
        string += fonts + " Font(s)\n";
    if (gcs != 0)
        string += gcs + " GC(s)\n";
    if (images != 0)
        string += images + " Image(s)\n";
    if (paths != 0)
        string += paths + " Paths(s)\n";
    if (patterns != 0)
        string += patterns + " Pattern(s)\n";
    if (regions != 0)
        string += regions + " Region(s)\n";
    if (textLayouts != 0)
        string += textLayouts + " TextLayout(s)\n";
    if (transforms != 0)
        string += transforms + " Transform(s)\n";
    if (string.length() != 0) {
        string = string.substring(0, string.length() - 1);
    }
    label.setText(string);
}
项目:synergyview    文件:TimeBarSegmentIntervalRenderer.java   
public void draw(GC gc, Rectangle drawingArea, TimeBarViewerDelegate delegate, Interval interval, boolean selected, boolean printing, boolean overlap) {
_delegate = delegate;

boolean horizontal = delegate.getOrientation() == TimeBarViewerInterface.Orientation.HORIZONTAL;

drawFocus(gc, drawingArea, delegate, interval, selected, printing, overlap);

Rectangle iRect = getIRect(horizontal, drawingArea, overlap);

Color bg = gc.getBackground();
String str = interval.toString();

gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_GRAY));

Pattern pattern = new Pattern(gc.getDevice(), 0, iRect.y, 0, iRect.y + (iRect.height * 2), gc.getDevice().getSystemColor(this.gradientStartColor), gc.getDevice().getSystemColor(this.gradientEndColor));

gc.setBackgroundPattern(pattern);

if (_rounding == 0) {
    gc.fillRectangle(iRect);
    gc.drawRectangle(iRect);
} else {
    gc.fillRoundRectangle(iRect.x, iRect.y, iRect.width, iRect.height, _rounding, _rounding);
    gc.drawRoundRectangle(iRect.x, iRect.y, iRect.width, iRect.height, _rounding, _rounding);
}
if (horizontal) {
    SwtGraphicsHelper.drawStringCentered(gc, str, iRect);
} else {
    SwtGraphicsHelper.drawStringVertical(gc, str, iRect.x + 2, iRect.y + 2);
}
gc.setBackgroundPattern(null);
pattern.dispose();

if (selected && !printing) {
    gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_GREEN));
    gc.setAlpha(60);
    if (_rounding == 0) {
    gc.fillRectangle(iRect);
    } else {
    gc.fillRoundRectangle(iRect.x, iRect.y, iRect.width, iRect.height, _rounding, _rounding);
    }
    gc.setAlpha(255);
}

gc.setBackground(bg);

   }
项目:gef-gwt    文件:ScaledGraphics.java   
/** @see Graphics#setBackgroundPattern(Pattern) */
public void setBackgroundPattern(Pattern pattern) {
    graphics.setBackgroundPattern(pattern);
}
项目:gef-gwt    文件:ScaledGraphics.java   
/** @see Graphics#setForegroundPattern(Pattern) */
public void setForegroundPattern(Pattern pattern) {
    graphics.setForegroundPattern(pattern);
}
项目:birt    文件:SwtRendererImpl.java   
private final void fillPathImage( Path path,
        org.eclipse.birt.chart.model.attribute.Image g )
        throws ChartException
{
    org.eclipse.swt.graphics.Image img = null;
    if ( g instanceof EmbeddedImage )
    {
        try
        {
            String imageData = ( (EmbeddedImage) g ).getData( );
            if ( imageData != null )
            {
                ByteArrayInputStream bis = new ByteArrayInputStream( Base64.decodeBase64( ( (EmbeddedImage) g ).getData( )
                        .getBytes( ) ) );

                img = new org.eclipse.swt.graphics.Image( ( (SwtDisplayServer) _ids ).getDevice( ),
                        bis );
            }
            else
            {
                img = createEmptyImage( );
            }
        }
        catch ( Exception ilex )
        {
            throw new ChartException( ChartDeviceSwtActivator.ID,
                    ChartException.RENDERING,
                    ilex );
        }
    }
    else if ( g instanceof PatternImage )
    {
        PatternImage patternImage = (PatternImage) g;
        img = createImageFromPattern( patternImage );
    }
    else
    {
        if ( g.getSource( ) == ImageSourceType.STATIC )
        {
            final String sUrl = g.getURL( );
            try
            {
                img = (org.eclipse.swt.graphics.Image) _ids.loadImage( SecurityUtil.newURL( sUrl ) );
            }
            catch ( MalformedURLException muex )
            {
                throw new ChartException( ChartDeviceSwtActivator.ID,
                        ChartException.RENDERING,
                        muex );
            }
        }
        else
        {
            img = createEmptyImage( );
        }

    }

    Pattern pattern = new Pattern( _gc.getDevice( ), img );
    _gc.setBackgroundPattern( pattern );
    _gc.fillPath( path );

    pattern.dispose( );
    img.dispose( );
}
项目:simpledance    文件:SWTContext.java   
public void gradientPolygon(int [] newData, RGB startRGB, RGB endRGB, int angle)
{
    int minx,miny,maxx,maxy;
    int i;

       /* Find minx, miny, maxx, maxy */
    minx = maxx = newData[0];
    miny = maxy = newData[1];

    if ((newData.length & 0x02) == 0) /* even number of pairs */
    {
        if (newData[2] < minx) minx = newData[2];
        else maxx = newData[2];
        if (newData[3] < miny) miny = newData[3];
        else maxy = newData[3];
        i = 4;
    } else i = 2;

    while (i<newData.length)
    {
        if (newData[i] < newData[i+2])
        {
            if (newData[i] < minx) minx = newData[i];
            else if (newData[i+2] > maxx) maxx = newData[i+2];
        } else
        {
            if (newData[i+2] < minx) minx = newData[i+2];
            else if (newData[i] > maxx) maxx = newData[i];
        }
        i++;
        if (newData[i] < newData[i+2])
        {
            if (newData[i] < miny) miny = newData[i];
            else if (newData[i+2] > maxy) maxy = newData[i+2];
        } else
        {
            if (newData[i+2] < miny) miny = newData[i+2];
            else if (newData[i] > maxy) maxy = newData[i];
        }
        i+=3;
    }

    org.eclipse.swt.graphics.Color startColor = new org.eclipse.swt.graphics.Color(display, startRGB.r,startRGB.g,startRGB.b);
    org.eclipse.swt.graphics.Color endColor = new org.eclipse.swt.graphics.Color(display, endRGB.r,endRGB.g,endRGB.b);

    Pattern pat = new Pattern(display,minx,miny,maxx,maxy,startColor,endColor);
    Pattern oldPat = gc.getBackgroundPattern();

    gc.setBackgroundPattern(pat);
    gc.fillPolygon(newData);
    gc.setBackgroundPattern(oldPat);

    pat.dispose();
    startColor.dispose();
    endColor.dispose();
}
项目:arx    文件:DataTableBackgroundImagePainter.java   
@Override
public void paintCell(ILayerCell cell, GC gc, Rectangle rectangle, IConfigRegistry configRegistry) {

    if (this.bgImage != null) {

        // Save GC settings
        Color originalBackground = gc.getBackground();
        Color originalForeground = gc.getForeground();

        // Ugly hack
        Pattern pattern = new Pattern(Display.getCurrent(), getImage(rectangle.height));
        gc.setBackgroundPattern(pattern);

        gc.fillRectangle(rectangle);

        gc.setBackgroundPattern(null);
        pattern.dispose();

        if (isNotNull(this.separatorColor)) {
            gc.setForeground(this.separatorColor);
            gc.drawLine(
                    rectangle.x - 1,
                    rectangle.y,
                    rectangle.x - 1,
                    rectangle.y + rectangle.height);
            gc.drawLine(
                    rectangle.x - 1 + rectangle.width,
                    rectangle.y,
                    rectangle.x - 1 + rectangle.width,
                    rectangle.y + rectangle.height);
        }

        // Restore original GC settings
        gc.setBackground(originalBackground);
        gc.setForeground(originalForeground);
    }

    // Draw interior
    Rectangle interiorBounds = new Rectangle(
            rectangle.x + 2,
            rectangle.y + 2,
            rectangle.width - 4,
            rectangle.height - 4);
    super.paintCell(cell, gc, interiorBounds, configRegistry);
}
项目:pentaho-kettle    文件:Sleak.java   
void refreshLabel() {
  int colors = 0, cursors = 0, fonts = 0, gcs = 0, images = 0;
  int paths = 0, patterns = 0, regions = 0, textLayouts = 0, transforms = 0;
  for ( int i = 0; i < objects.length; i++ ) {
    Object object = objects[i];
    if ( object instanceof Color ) {
      colors++;
    }
    if ( object instanceof Cursor ) {
      cursors++;
    }
    if ( object instanceof Font ) {
      fonts++;
    }
    if ( object instanceof GC ) {
      gcs++;
    }
    if ( object instanceof Image ) {
      images++;
    }
    if ( object instanceof Path ) {
      paths++;
    }
    if ( object instanceof Pattern ) {
      patterns++;
    }
    if ( object instanceof Region ) {
      regions++;
    }
    if ( object instanceof TextLayout ) {
      textLayouts++;
    }
    if ( object instanceof Transform ) {
      transforms++;
    }
  }
  String string = "";
  if ( colors != 0 ) {
    string += colors + " Color(s)\n";
  }
  if ( cursors != 0 ) {
    string += cursors + " Cursor(s)\n";
  }
  if ( fonts != 0 ) {
    string += fonts + " Font(s)\n";
  }
  if ( gcs != 0 ) {
    string += gcs + " GC(s)\n";
  }
  if ( images != 0 ) {
    string += images + " Image(s)\n";
  }
  if ( paths != 0 ) {
    string += paths + " Paths(s)\n";
  }
  if ( patterns != 0 ) {
    string += patterns + " Pattern(s)\n";
  }
  if ( regions != 0 ) {
    string += regions + " Region(s)\n";
  }
  if ( textLayouts != 0 ) {
    string += textLayouts + " TextLayout(s)\n";
  }
  if ( transforms != 0 ) {
    string += transforms + " Transform(s)\n";
  }
  if ( string.length() != 0 ) {
    string = string.substring( 0, string.length() - 1 );
  }
  label.setText( string );
}
项目:gef-gwt    文件:Graphics.java   
/**
 * Sets the pattern used for fill-type graphics operations. The pattern must
 * not be disposed while it is being used by the graphics.
 * 
 * @param pattern
 *            the background pattern
 * @since 3.1
 */
public void setBackgroundPattern(Pattern pattern) {
    throwNotImplemented();
}
项目:gef-gwt    文件:Graphics.java   
/**
 * Sets the foreground pattern for draw and text operations. The pattern
 * must not be disposed while it is being referenced by the graphics.
 * 
 * @param pattern
 *            the foreground pattern
 * @since 3.1
 */
public void setForegroundPattern(Pattern pattern) {
    throwNotImplemented();
}