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

项目:AppleCommander    文件:Sleak.java   
void refreshLabel () {
    int colors = 0, cursors = 0, fonts = 0, gcs = 0, images = 0, regions = 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 Region) regions++;
    }
    String string = ""; //$NON-NLS-1$
    if (colors != 0) string += colors + " Color(s)\n"; //$NON-NLS-1$
    if (cursors != 0) string += cursors + " Cursor(s)\n"; //$NON-NLS-1$
    if (fonts != 0) string += fonts + " Font(s)\n"; //$NON-NLS-1$
    if (gcs != 0) string += gcs + " GC(s)\n"; //$NON-NLS-1$
    if (images != 0) string += images + " Image(s)\n"; //$NON-NLS-1$
    if (regions != 0) string += regions + " Region(s)\n"; //$NON-NLS-1$
    if (string.length () != 0) {
        string = string.substring (0, string.length () - 1);
    }
    label.setText (string);
}
项目:applecommander    文件:Sleak.java   
void refreshLabel () {
    int colors = 0, cursors = 0, fonts = 0, gcs = 0, images = 0, regions = 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 Region) regions++;
    }
    String string = ""; //$NON-NLS-1$
    if (colors != 0) string += colors + " Color(s)\n"; //$NON-NLS-1$
    if (cursors != 0) string += cursors + " Cursor(s)\n"; //$NON-NLS-1$
    if (fonts != 0) string += fonts + " Font(s)\n"; //$NON-NLS-1$
    if (gcs != 0) string += gcs + " GC(s)\n"; //$NON-NLS-1$
    if (images != 0) string += images + " Image(s)\n"; //$NON-NLS-1$
    if (regions != 0) string += regions + " Region(s)\n"; //$NON-NLS-1$
    if (string.length () != 0) {
        string = string.substring (0, string.length () - 1);
    }
    label.setText (string);
}
项目:gef-gwt    文件:SWTGraphics.java   
/**
 * Simple implementation of clipping a Path within the context of current
 * clipping rectangle for now (not region) <li>Note that this method wipes
 * out the clipping rectangle area, hence if clients need to reset it call
 * {@link #restoreState()}
 * 
 * @see org.eclipse.draw2d.Graphics#clipPath(org.eclipse.swt.graphics.Path)
 */
public void clipPath(Path path) {
    initTransform(false);
    if (((appliedState.graphicHints ^ currentState.graphicHints) & FILL_RULE_MASK) != 0) {
        // If there is a pending change to the fill rule, apply it first.
        gc.setFillRule(((currentState.graphicHints & FILL_RULE_MASK) >> FILL_RULE_SHIFT)
                - FILL_RULE_WHOLE_NUMBER);
        // As long as the FILL_RULE is stored in a single bit, just toggling
        // it works.
        appliedState.graphicHints ^= FILL_RULE_MASK;
    }
    Rectangle clipping = currentState.relativeClip != null ? getClip(new Rectangle())
            : new Rectangle();
    if (!clipping.isEmpty()) {
        Path flatPath = new Path(path.getDevice(), path, 0.01f);
        PathData pathData = flatPath.getPathData();
        flatPath.dispose();
        Region region = new Region(path.getDevice());
        loadPath(region, pathData.points, pathData.types);
        region.intersect(new org.eclipse.swt.graphics.Rectangle(clipping.x,
                clipping.y, clipping.width, clipping.height));
        gc.setClipping(region);
        appliedState.relativeClip = currentState.relativeClip = null;
        region.dispose();
    }
}
项目:swtknob    文件:Sleak.java   
void refreshLabel() {
    @SuppressWarnings("unused")
    int colors = 0, cursors = 0, fonts = 0, gcs = 0, images = 0, regions = 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 Region) regions++;
    }
    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";
    /* Currently regions are not counted. */
    // if (regions != 0) string += regions + " Region(s)\n";
    if (string.length() != 0) {
        string = string.substring(0, string.length() - 1);
    }
    label.setText(string);
}
项目:birt    文件:SwtRendererImpl.java   
public void setClip( ClipRenderEvent cre )
{
    final Location[] loa = cre.getVertices( );

    if ( loa == null )
    {
        _gc.setClipping( (Region) null );
    }
    else
    {
        Region rgClipping = new Region( );
        rgClipping.add( getCoordinatesAsInts( loa,
                TRUNCATE,
                dTranslateX,
                dTranslateY,
                dScale ) );
        _gc.setClipping( rgClipping );
        rgClipping.dispose( );
    }
}
项目:birt    文件:RegionAction.java   
/**
 * RegionAction constructor taking a polygon to define the region
 * 
 * @param oSource
 *            StructureSource
 * @param loa
 *            Polygon points
 * @param ac
 *            Action
 * @param dTranslateX
 *            X Translation to apply on polygon coordinates
 * @param dTranslateY
 *            Y Translation to apply on polygon coordinates
 * @param dScale
 *            Scale to apply on polygon coordinates
 * @param clipping
 *            Clipping area, points outside it will be clipped
 */
RegionAction( StructureSource oSource, Location[] loa, Action ac,
        double dTranslateX, double dTranslateY, double dScale,
        Region clipping )
{
    _oSource = oSource;
    final int[] i2a = SwtRendererImpl.getCoordinatesAsInts( loa,
            SwtRendererImpl.TRUNCATE,
            dTranslateX,
            dTranslateY,
            dScale );
    Region sh = new Region( );
    sh.add( i2a );
    if ( clipping != null )
    {
        sh.intersect( clipping );
    }
    _ac = ac;

    this.region = sh;
}
项目:birt    文件:RegionAction.java   
/**
 * This constructor supports shape definition via a rectangle.
 * 
 * @param oSource
 *            StructureSource
 * @param bo
 *            Rectangle
 * @param ac
 *            Action
 * @param dTranslateX
 *            X translation to apply to rectangle
 * @param dTranslateY
 *            Y translation to apply to rectangle
 * @param dScale
 *            scale to apply to rectangle
 * @param clipping
 *            Clipping area, points outside it will be clipped
 */
RegionAction( StructureSource oSource, Bounds bo, Action ac,
        double dTranslateX, double dTranslateY, double dScale,
        Region clipping )
{
    _oSource = oSource;

    bo = goFactory.copyOf( bo );
    bo.translate( dTranslateX, dTranslateY );
    bo.scale( dScale );

    Rectangle rect = new Rectangle( (int) bo.getLeft( ),
            (int) bo.getTop( ),
            (int) bo.getWidth( ),
            (int) bo.getHeight( ) );

    Region sh = new Region( );
    sh.add( rect );
    if ( clipping != null )
    {
        sh.intersect( clipping );
    }
    _ac = ac;

    this.region = sh;
}
项目:JustDoIt-A-Task-Manager    文件:GUI.java   
/**
 * This method finds out transparent region in an image
 * 
 * @param image
 *            is the target image
 * @param offsetX
 *            is the distance offset on x axis
 * @param offsetY
 *            is the distance offset on y axis
 * @return Region is the found transparent region
 */
public Region handleTransparenceRegion(Image image, int offsetX, int

offsetY) {

    Region region = new Region();
    final ImageData imageData = image.getImageData();
    if (imageData.alphaData != null) {
        Rectangle pixel = new Rectangle(0, 0, 1, 1);
        for (int y = 0; y < imageData.height; y++) {
            for (int x = 0; x < imageData.width; x++) {
                if (imageData.getAlpha(x, y) != 255) {
                    pixel.x = imageData.x + x +

                    offsetX;
                    pixel.y = imageData.y + y +

                    offsetY;
                    region.add(pixel);
                }
            }
        }
    }
    return region;
}
项目:JustDoIt-A-Task-Manager    文件:GUI.java   
public void initializeBackgroundButton(Display display) {

        Button changeBgBt = new Button(shell, SWT.PUSH);
        Image changeBtImage = new Image(display,
                ResourceLoader.load("image/changeBg.png"));
        changeBgBt.setToolTipText("Change the background style");
        changeBgBt.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                final Shell changeBg = setChangeDialog();
                center(changeBg);
                changeBg.open();
            }
        });

        Region startBtRegion = new Region();
        startBtRegion.add(circle(circularButtonRadius, circularButtonOffsetX,
                circularButtonOffsetY));
        changeBgBt.setRegion(startBtRegion);
        changeBgBt.setImage(changeBtImage);
        FormData changeBgData = new FormData(circularButtonFormData,
                circularButtonFormData);
        changeBgData.right = new FormAttachment(89);
        changeBgData.top = new FormAttachment(2);
        changeBgBt.setLayoutData(changeBgData);
    }
项目:JustDoIt-A-Task-Manager    文件:GUI.java   
/**
 * This method generate a region from a background image
 * 
 * @param display
 *            is the display area of this region
 * @param image
 *            is the file path of the background image
 */
public static Region getBackRegionFromImage(Display display, String image) {

    ImageLoader loader = new ImageLoader();
    ImageData[] imageData = loader.load(ResourceLoader.load(image));
    Region region = new Region(display);
    ImageData data = imageData[0];
    ImageData mask = data.getTransparencyMask();
    org.eclipse.swt.graphics.Rectangle pixel = new org.eclipse.swt.graphics.Rectangle(
            0, 0, 1, 1);
    for (int y = 0; y < mask.height; y++) {
        for (int x = 0; x < mask.width; x++) {
            if (mask.getPixel(x, y) != 0) {
                pixel.x = data.x + x;
                pixel.y = data.y + y;
                region.add(pixel);
            }
        }
    }
    return region;
}
项目:swt-bling    文件:Sleak.java   
void refreshLabel () {
  int colors = 0, cursors = 0, fonts = 0, gcs = 0, images = 0, regions = 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 Region) regions++;
  }
  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";
  /* Currently regions are not counted. */
  //  if (regions != 0) string += regions + " Region(s)\n";
  if (string.length () != 0) {
    string = string.substring (0, string.length () - 1);
  }
  label.setText (string);
}
项目:swt-bling    文件:PopOverShell.java   
/**
 * Shows the PopOverShell in a suitable location relative to the parent component. Classes extending PopOverShell will
 * provide the <code>Region</code> via the abstract <code>getAppropriatePopOverRegion()</code> method.
 */
public void show() {
  runBeforeShowPopOverShell();

  Point popOverShellSize = getAppropriatePopOverSize();
  popOverRegion = new Region();
  popOverRegion.add(new Rectangle(0, 0, popOverShellSize.x, popOverShellSize.y));

  Point location = getPopOverShellLocation(parentShell, poppedOverItem, popOverRegion);

  popOverShell.setRegion(popOverRegion);
  popOverShell.setSize(popOverRegion.getBounds().width, popOverRegion.getBounds().height);
  popOverShell.setLocation(location);
  popOverShell.setAlpha(FULLY_VISIBLE_ALPHA);
  popOverShell.setVisible(true);
}
项目:EasySnap    文件:ScreenSelectorShell.java   
private Region getRegion(boolean subRect) {
    Region region = new Region();
    region.add(this.shell.getBounds());
    if (subRect) {
        region.subtract(this.getRect());
    }
    return region;
}
项目:bts    文件:PerspectiveSwitcherSwtTrim.java   
void paintContainer(PaintEvent event) {
    GC gc = event.gc;
    gc.setAdvanced(true);
    if (gc.getAdvanced())
        gc.setAntialias(SWT.ON);

    Point size = composite.getSize();
    int h = size.y;
    int[] simpleCurve = new int[] { 0, h - 1, 1, h - 1, 2, h - 2, 2, 1, 3,
            0 };

    gc.setForeground(getContainerCurveColor(event));
    gc.drawPolyline(simpleCurve);

    Rectangle bounds = ((Control) event.widget).getBounds();
    bounds.x = bounds.y = 0;
    Region r = new Region();
    r.add(bounds);

    int[] simpleCurveClose = new int[simpleCurve.length + 4];
    System.arraycopy(simpleCurve, 0, simpleCurveClose, 0,
            simpleCurve.length);
    int index = simpleCurve.length;
    simpleCurveClose[index++] = bounds.width;
    simpleCurveClose[index++] = 0;
    simpleCurveClose[index++] = bounds.width;
    simpleCurveClose[index++] = bounds.height;

    r.subtract(simpleCurveClose);

    Region clipping = new Region();
    gc.getClipping(clipping);
    r.intersect(clipping);
    gc.setClipping(r);

    clipping.dispose();
    r.dispose();
}
项目:birt    文件:R31Enhance.java   
/**
 * Equivalent to <code><b>GC.setAdvanced()</b></code> in r3.1.
 * 
 * @param gc
 * @param value
 */
static void setAdvanced( GC gc, boolean value, Region clipping )
{
    if ( R31_AVAILABLE )
    {
        gc.setAdvanced( value );

        // setAdvanced will clean the clipping info, restore it here.
        gc.setClipping( clipping );
    }
}
项目:birt    文件:RegionAction.java   
/**
 * This constructor supports shape definition via an elliptical arc
 * 
 * @param oSource
 * @param boEllipse
 * @param dStart
 * @param dExtent
 * @param iArcType
 * @param ac
 */
RegionAction( StructureSource oSource, Bounds boEllipse, double dStart,
        double dExtent, int iArcType, Action ac, double dTranslateX,
        double dTranslateY, double dScale, Region clipping )
{
    _oSource = oSource;

    boEllipse = goFactory.copyOf( boEllipse );
    boEllipse.translate( dTranslateX, dTranslateY );
    boEllipse.scale( dScale );

    Shape shape = new Arc2D.Double( boEllipse.getLeft( ),
            boEllipse.getTop( ),
            boEllipse.getWidth( ),
            boEllipse.getHeight( ),
            dStart,
            dExtent,
            toSwingArcType( iArcType ) );

    int[] i2a = shape2polyCoords( shape );
    Region sh = new Region( );
    sh.add( i2a );

    if ( clipping != null )
    {
        sh.intersect( clipping );
    }

    _ac = ac;
    this.region = sh;

}
项目:JustDoIt-A-Task-Manager    文件:GUI.java   
public void setShell() {

        Region region = getBackRegionFromImage(display, backgroundImageName);

        /* Capture the transparent regions and remove them */
        Region corner = handleTransparenceRegion(backgroundImage, 0, 0);
        region.subtract(corner);
        shell.setRegion(region);

        /* Set shell size and background according to the region */
        Rectangle size = region.getBounds();
        shell.setSize(size.width, size.height);

        /* Load background */
        ImageLoader loader = new ImageLoader();
        ImageData[] imageData = loader.load(ResourceLoader
                .load(backgroundImageName));
        Image image = new Image(null, imageData[0]);
        shell.setBackgroundImage(image);
        shell.setBackgroundMode(SWT.INHERIT_FORCE);

        /* Set icon */
        Image shellIcon = new Image(Display.getCurrent(),
                GUI.class.getResourceAsStream("/GUI/JustDoIt/image/icon.png"));
        shell.setImage(shellIcon);

        /* Put the shell in center of screen */
        center(shell);
    }
项目: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);
}
项目:cogtool    文件:ManagedText.java   
@Override
public Region getRegion()
{
    if (outer != null) {
        return outer.getRegion();
    }

    return super.getRegion();
}
项目:swt-bling    文件:ResourceQueryTest.java   
@Test
public void getResources_Create4Regions_CountEquals4() {
  Map<String, Integer> counts = ResourceQuery.getAllocatedResourceCounts(display);
  for (int i = 10; i < 14; i++) {
    Region r = new Region(display);
    r.add(0,0, i,i);
  }
  Assert.assertEquals(4, ResourceQuery.getAllocatedResourceCounts(display).get(Region.class.getName()).intValue());
}
项目:swt-bling    文件:PopOverShell.java   
private Point getPopOverLocationControlOffscreen(Rectangle displayBounds,
                                                 Region popOverRegion,
                                                 Point poppedOverItemLocationRelativeToDisplay,
                                                 Point popOverOffscreenLocation) {
  Point appropriateDisplayLocation = popOverOffscreenLocation;
  Rectangle popOverRegionBounds = popOverRegion.getBounds();
  if (!displayBounds.contains(new Point(poppedOverItemLocationRelativeToDisplay.x + popOverRegionBounds.width, 0))) {
    appropriateDisplayLocation.x = displayBounds.width - popOverRegionBounds.width;
  }
  if (!displayBounds.contains(new Point(0, poppedOverItemLocationRelativeToDisplay.y + popOverRegionBounds.height))) {
    appropriateDisplayLocation.y = displayBounds.height - popOverRegionBounds.height;
  }

  return appropriateDisplayLocation;
}
项目: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);
}
项目:mytourbook    文件:ChartLayerMarker.java   
private void drawOverlay_Label( final ChartLabel chartLabel,
                                final GC gc,
                                final Color colorDefault,
                                final Color colorDevice,
                                final Color colorHidden,
                                final boolean isSelected) {

    if (chartLabel == null) {
        return;
    }

    if (isSelected) {
        gc.setAlpha(0x60);
    } else {
        gc.setAlpha(0x30);
    }

    if (isSelected) {

        final Color selectedColorBg = gc.getDevice().getSystemColor(SWT.COLOR_DARK_GRAY);
        gc.setBackground(selectedColorBg);

    } else if (chartLabel.isDeviceMarker()) {
        gc.setBackground(colorDevice);
    } else if (chartLabel.isVisible) {
        gc.setBackground(colorDefault);
    } else {
        gc.setBackground(colorHidden);
    }

    /*
     * Rectangles can be merged into a union with regions, took me some time to find this
     * solution :-)
     */
    final Region region = new Region(gc.getDevice());

    final Rectangle paintedLabel = chartLabel.paintedLabel;
    if (paintedLabel != null) {

        final int devLabelX = paintedLabel.x - MARKER_HOVER_SIZE;
        final int devLabelY = paintedLabel.y - MARKER_HOVER_SIZE;
        final int devLabelWidth = paintedLabel.width + 2 * MARKER_HOVER_SIZE;
        final int devLabelHeight = paintedLabel.height + 2 * MARKER_HOVER_SIZE;

        region.add(devLabelX, devLabelY, devLabelWidth, devLabelHeight);
    }

    final int devMarkerX = chartLabel.devXMarker - MARKER_HOVER_SIZE;
    final int devMarkerY = chartLabel.devYMarker - MARKER_HOVER_SIZE;
    final int devMarkerSize = MARKER_POINT_SIZE + 2 * MARKER_HOVER_SIZE;

    region.add(devMarkerX, devMarkerY, devMarkerSize, devMarkerSize);

    // get whole chart rect
    final Rectangle clientRect = gc.getClipping();

    gc.setClipping(region);
    {
        gc.fillRectangle(clientRect);
    }
    region.dispose();
    gc.setClipping((Region) null);
}
项目:birt    文件:DesignerRepresentation.java   
/**
 * Show the exception message that prevented to draw the chart
 * 
 * @param g2d
 * @param ex
 *            The exception that occured
 */
private final void showException( GC g2d, Exception ex )
{
    Point pTLC = new Point( 0, 0 );

    // String sWrappedException = ex.getClass( ).getName( );
    Throwable th = ex;

    String sMessage = null;
    if ( th instanceof BirtException )
    {
        sMessage = ( (BirtException) th ).getLocalizedMessage( );
    }
    else
    {
        sMessage = ex.getMessage( );
    }

    if ( sMessage == null )
    {
        sMessage = "<null>"; //$NON-NLS-1$
    }
    // StackTraceElement[] stea = ex.getStackTrace( );
    Dimension d = getSize( );

    Device dv = Display.getCurrent( );
    Font fo = new Font( dv, "Courier", SWT.BOLD, 12 ); //$NON-NLS-1$
    g2d.setFont( fo );
    FontMetrics fm = g2d.getFontMetrics( );
    g2d.setBackground( dv.getSystemColor( SWT.COLOR_WHITE ) );
    g2d.fillRectangle( pTLC.x + 20,
            pTLC.y + 20,
            d.width - 40,
            d.height - 40 );
    g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) );
    g2d.drawRectangle( pTLC.x + 20,
            pTLC.y + 20,
            d.width - 40,
            d.height - 40 );
    Region rgPrev = new Region( );
    g2d.getClipping( rgPrev );
    g2d.setClipping( pTLC.x + 20, pTLC.y + 20, d.width - 40, d.height - 40 );
    int x = pTLC.x + 25, y = pTLC.y + 20 + fm.getHeight( );
    g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) );
    g2d.drawString( ERROR_MSG, x, y );
    y += fm.getHeight( );
    g2d.setForeground( dv.getSystemColor( SWT.COLOR_RED ) );
    g2d.drawText( sMessage, x, y );

    g2d.setClipping( rgPrev );
    rgPrev.dispose( );
    fo.dispose( );
}
项目:birt    文件:SwtRendererImpl.java   
public final void setProperty( final String sProperty, final Object oValue )
{
    if ( sProperty.equals( IDeviceRenderer.UPDATE_NOTIFIER ) )
    {
        _iun = (IUpdateNotifier) oValue;
        iv.reset( );
        iv.setUpdateNotifier( _iun );

        cleanUpTriggers( );
        Object obj = _iun.peerInstance( );

        if ( obj instanceof Composite )
        {
            Composite jc = (Composite) obj;

            if ( _eh != null )
            {
                // We can't promise to remove all the old swtEventHandler
                // due to SWT limitation here, so be sure to just attach the
                // update_notifier only to one renderer.

                jc.removeMouseListener( _eh );
                jc.removeMouseMoveListener( _eh );
                jc.removeMouseTrackListener( _eh );
                jc.removeKeyListener( _eh );
                jc.removeFocusListener( _eh );

                _eh.dispose( );
            }

            _eh = new SwtEventHandler( iv, _lhmAllTriggers, _iun, getULocale( ) );

            jc.addMouseListener( _eh );
            jc.addMouseMoveListener( _eh );
            jc.addMouseTrackListener( _eh );
            jc.addKeyListener( _eh );
            jc.addFocusListener( _eh );
        }
    }
    else if ( sProperty.equals( IDeviceRenderer.GRAPHICS_CONTEXT ) )
    {
        _gc = (GC) oValue;

        if ( R31Enhance.isR31Available( ) )
        {
            Region rg = new Region( );
            _gc.getClipping( rg );

            R31Enhance.setAdvanced( _gc, true, rg );
            R31Enhance.setAntialias( _gc, SWT.ON );
            R31Enhance.setTextAntialias( _gc, SWT.ON );

            rg.dispose( );
        }
        _ids.setGraphicsContext(_gc );

        logger.log( ILogger.INFORMATION,
                Messages.getString( "SwtRendererImpl.info.graphics.context",//$NON-NLS-1$
                        new Object[]{
                                _gc.getClass( ).getName( ), _gc
                        },
                        getULocale( ) ) );
    }
    else if ( sProperty.equals( IDeviceRenderer.DPI_RESOLUTION ) )
    {
        getDisplayServer( ).setDpiResolution( ( (Integer) oValue ).intValue( ) );
    }
    else if ( sProperty.equals( IDeviceRenderer.EXPECTED_BOUNDS ) )
    {
        Bounds bo = (Bounds)oValue;
        int x = (int)Math.round( bo.getLeft( ) );
        int y = (int)Math.round( bo.getTop( ) );
        int width = (int)Math.round( bo.getWidth( ) );
        int height = (int)Math.round( bo.getHeight( ) );
        this._gc.setClipping( x, y, width, height );
    }
}
项目:birt    文件:RegionAction.java   
private RegionAction( StructureSource source, Region region, Action ac )
{
    this._oSource = source;
    this._ac = ac;
    this.region = region;
}
项目:JustDoIt-A-Task-Manager    文件:GUI.java   
private Shell setChangeDialog() {

        final Shell changeBg = new Shell(shell);
        changeBg.setText("Background Styles");
        changeBg.setSize(730, 150);

        /* Names of background styles, also part of image file names */
        String[] backgroundList = { "Rainbow world", "Raining glass",
                "Music girl", "Maple leaf", "Deep blue", "Snowing world",
                "Natural sight" };

        /* Produce previews of backgrounds in form of square buttons */
        for (int i = 0; i < 7; i++) {

            /* String to generate preview image paths */
            final StringBuffer backgroundSmallImageFileName = new StringBuffer(
                    "image/");

            /* String to generate background image paths */
            final StringBuffer backgroundImageFileName = new StringBuffer(
                    "image/");

            /* Generate preview image paths */
            backgroundSmallImageFileName.append(backgroundList[i]);
            backgroundSmallImageFileName.append(" small");
            backgroundSmallImageFileName.append(".png");

            /* Generate background image paths */
            backgroundImageFileName.append(backgroundList[i]);
            backgroundImageFileName.append(".png");
            Image backgoundImageSmall = new Image(
                    display,
                    ResourceLoader.load(backgroundSmallImageFileName.toString()));

            Button backgroundBt = new Button(changeBg, SWT.PUSH);
            backgroundBt.setToolTipText(backgroundList[i]);

            /* Reset background according to clicked preview image */
            backgroundBt.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {

                    backgroundImageName = backgroundImageFileName.toString();
                    backgroundImage = new Image(display, ResourceLoader
                            .load(backgroundImageName));
                    setShell();
                    saveBackgroungImage(backgroundImageName);
                    changeBg.dispose();
                }
            });

            Region startBtRegion = new Region();
            startBtRegion.add(square(100));
            backgroundBt.setRegion(startBtRegion);
            backgroundBt.setImage(backgoundImageSmall);
            int xOffset = i * 100 + 10;
            backgroundBt.setBounds(xOffset, 15, 100, 100);
        }
        return changeBg;
    }
项目:JustDoIt-A-Task-Manager    文件:GUI.java   
public void initializeHelpButton() {

        Button helpBt = new Button(shell, SWT.PUSH);
        Image changeBtImage = new Image(display,
                ResourceLoader.load("/GUI/JustDoIt/image/help.png"));
        helpBt.setToolTipText(MESSAGE_HELP);

        /* Clicking help button trigger the help information dialog */
        helpBt.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {

                if (Desktop.isDesktopSupported()) {
                    Desktop desktop = Desktop.getDesktop();
                    InputStream resource = getClass().getResourceAsStream(
                            "/GUI/JustDoIt/user_manual.pdf");
                    try {
                        File file = File.createTempFile("user_manual", ".pdf");
                        file.deleteOnExit();
                        OutputStream out = new FileOutputStream(file);
                        try {
                            int stream = resource.read();
                            while (stream != -1) {
                                out.write(stream);
                                stream = resource.read();
                            }
                        } finally {
                            out.close();
                        }
                        desktop.open(file);
                        resource.close();
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }
            }
        });

        Region startBtRegion = new Region();
        startBtRegion.add(circle(10, 16, 16));
        helpBt.setRegion(startBtRegion);
        helpBt.setImage(changeBtImage);
        FormData helpData = new FormData(33, 33);
        helpData.right = new FormAttachment(85);
        helpData.top = new FormAttachment(2);
        helpBt.setLayoutData(helpData);
    }
项目:TeamSubb    文件:GadgetController.java   
public void redrawGadget() {
    // create the region defining the gadget
    Region region = new Region();

    // set the circle data to the region
    int polygon = profiler.getPolygon();

    region.add(GadgetProfiler.generateCircle(polygon, polygon, polygon));

    // define the shape of the shell
    gadget.getShell().setRegion(region);

    Rectangle size = region.getBounds();
    gadget.getShell().setSize(size.width, size.height);

    // dispose of the region object
    region.dispose();

}
项目:eclipse-mylyn-notifications    文件:AbstractNotificationPopup.java   
private void addRegion(Shell shell) {
    Region region = new Region();
    Point s = shell.getSize();

    /* Add entire Shell */
    region.add(0, 0, s.x, s.y);

    /* Subtract Top-Left Corner */
    region.subtract(0, 0, 5, 1);
    region.subtract(0, 1, 3, 1);
    region.subtract(0, 2, 2, 1);
    region.subtract(0, 3, 1, 1);
    region.subtract(0, 4, 1, 1);

    /* Subtract Top-Right Corner */
    region.subtract(s.x - 5, 0, 5, 1);
    region.subtract(s.x - 3, 1, 3, 1);
    region.subtract(s.x - 2, 2, 2, 1);
    region.subtract(s.x - 1, 3, 1, 1);
    region.subtract(s.x - 1, 4, 1, 1);

    /* Subtract Bottom-Left Corner */
    region.subtract(0, s.y, 5, 1);
    region.subtract(0, s.y - 1, 3, 1);
    region.subtract(0, s.y - 2, 2, 1);
    region.subtract(0, s.y - 3, 1, 1);
    region.subtract(0, s.y - 4, 1, 1);

    /* Subtract Bottom-Right Corner */
    region.subtract(s.x - 5, s.y - 0, 5, 1);
    region.subtract(s.x - 3, s.y - 1, 3, 1);
    region.subtract(s.x - 2, s.y - 2, 2, 1);
    region.subtract(s.x - 1, s.y - 3, 1, 1);
    region.subtract(s.x - 1, s.y - 4, 1, 1);

    /* Dispose old first */
    if (shell.getRegion() != null) {
        shell.getRegion().dispose();
    }

    /* Apply Region */
    shell.setRegion(region);

    /* Remember to dispose later */
    lastUsedRegion = region;
}
项目:simpledance    文件:Sleak.java   
void refreshLabel()
{
    int colors = 0,
        cursors = 0,
        fonts = 0,
        gcs = 0,
        images = 0,
        regions = 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 Region)
            regions++;
    }
    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 (regions != 0) string += regions + " Region(s)\n";
    if (string.length() != 0)
    {
        string = string.substring(0, string.length() - 1);
    }
    label.setText(string);
}
项目: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 );
}
项目:swt-bling    文件:PopOverShell.java   
private Point getPopOverShellLocation(Shell parentShell, PoppedOverItem poppedOverItem, Region popOverRegion) {

    Point location;
    Rectangle displayBounds = null;

    try {
      Display display = displaySafe.getLatestDisplay();
      displayBounds = display.getBounds();
    } catch (DisplaySafe.NullDisplayException nde) {
      LOG.warning("Could not find display");
    }

    Rectangle popOverBounds = popOverRegion.getBounds();
    Point poppedOverItemLocationRelativeToDisplay =
            getPoppedOverItemRelativeLocation(poppedOverItem);

    // Guess on the location first
    location = getPopOverDisplayPoint(popOverBounds, poppedOverItem, poppedOverItemLocationRelativeToDisplay,
            popOverEdgeCenteredOnParent, popOverAboveOrBelowParent);

    // Adjust as needed
    if (popOverAboveOrBelowParent == VerticalLocation.BELOW) {
      if (isBottomCutOff(displayBounds, location, popOverBounds)) {
        popOverAboveOrBelowParent = VerticalLocation.ABOVE;
        location.y = getPopOverYLocation(popOverBounds, poppedOverItem, poppedOverItemLocationRelativeToDisplay,
                popOverAboveOrBelowParent);
      }
    } else {
      if (isTopCutOff(location)) {
        popOverAboveOrBelowParent = VerticalLocation.BELOW;
        location.y = getPopOverYLocation(popOverBounds, poppedOverItem, poppedOverItemLocationRelativeToDisplay,
            popOverAboveOrBelowParent);
      }
    }

    if (popOverEdgeCenteredOnParent == CenteringEdge.LEFT) {
      if (isRightCutOff(displayBounds, location, popOverBounds)) {
        popOverEdgeCenteredOnParent = CenteringEdge.RIGHT;
        location.x = getPopOverXLocation(popOverBounds, poppedOverItem, poppedOverItemLocationRelativeToDisplay,
                popOverEdgeCenteredOnParent);
      }
    } else {
      if (isLeftCutOff(location)) {
        popOverEdgeCenteredOnParent = CenteringEdge.LEFT;
        location.x = getPopOverXLocation(popOverBounds, poppedOverItem, poppedOverItemLocationRelativeToDisplay,
            popOverEdgeCenteredOnParent);
      }
    }

    if (isStillOffScreen(displayBounds, location, popOverBounds)) {
      location = getPopOverLocationControlOffscreen(displayBounds, popOverRegion,
              poppedOverItemLocationRelativeToDisplay, location);
    }

    return location;
  }
项目:gef-gwt    文件:Shell.java   
/**
 * Sets the shape of the shell to the region specified by the argument. When
 * the argument is null, the default shape of the shell is restored. The
 * shell must be created with the style SWT.NO_TRIM in order to specify a
 * region.
 * 
 * @param region
 *            the region that defines the shape of the shell (or null)
 * 
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_INVALID_ARGUMENT - if the region has been
 *                disposed</li>
 *                </ul>
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the receiver has been
 *                disposed</li>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the receiver</li>
 *                </ul>
 * 
 * @since 3.0
 * 
 */
public void setRegion(Region region) {
    checkWidget();
    if ((style & SWT.NO_TRIM) == 0)
        return;
    super.setRegion(region);
}
项目:BiglyBT    文件:PieUtils.java   
public static void
drawPie(
    GC gc,Image image, int x, int y,int width,int height,int percent, boolean draw_border )
{
    Rectangle image_size = image.getBounds();

    int width_pad   = ( width - image_size.width  )/2;
    int height_pad  = ( height - image_size.height  )/2;

    int angle = (percent * 360) / 100;
    if(angle<4){
        angle = 0; // workaround fillArc rendering bug
    }

    Region old_clipping = new Region();

    gc.getClipping(old_clipping);

    Path path_done = new Path(gc.getDevice());

    path_done.addArc(x,y,width,height,90,-angle);
    path_done.lineTo( x+width/2, y+height/2);
    path_done.close();

    gc.setClipping( path_done );

    gc.drawImage(image, x+width_pad, y+height_pad+1);

    Path path_undone = new Path(gc.getDevice());

    path_undone.addArc(x,y,width,height,90-angle,angle-360);
    path_undone.lineTo( x+width/2, y+height/2);
    path_undone.close();

    gc.setClipping( path_undone );

    gc.setAlpha( 75 );
    gc.drawImage(image, x+width_pad, y+height_pad+1);
    gc.setAlpha( 255 );

    gc.setClipping( old_clipping );

    if ( draw_border ){

        gc.setForeground(Colors.blue);

        if ( percent == 100 ){

            gc.drawOval(x , y , width-1, height-1);

        }else{

            if ( angle > 0 ){

                gc.drawPath( path_done );
            }
        }
    }

    path_done.dispose();
    path_undone.dispose();
    old_clipping.dispose();

}
项目:AcademicTorrents-Downloader    文件:PieUtils.java   
public static void 
drawPie(
    GC gc,Image image, int x, int y,int width,int height,int percent, boolean draw_border ) 
{
    Rectangle image_size = image.getBounds();

    int width_pad   = ( width - image_size.width  )/2;
    int height_pad  = ( height - image_size.height  )/2;

    int angle = (percent * 360) / 100;
    if(angle<4){
        angle = 0; // workaround fillArc rendering bug
    }

    Region old_clipping = new Region();

    gc.getClipping(old_clipping);

    Path path_done = new Path(gc.getDevice());

    path_done.addArc(x,y,width,height,90,-angle);
    path_done.lineTo( x+width/2, y+height/2);
    path_done.close();

    gc.setClipping( path_done );

    gc.drawImage(image, x+width_pad, y+height_pad+1);

    Path path_undone = new Path(gc.getDevice());

    path_undone.addArc(x,y,width,height,90-angle,angle-360);
    path_undone.lineTo( x+width/2, y+height/2);
    path_undone.close();

    gc.setClipping( path_undone );

    gc.setAlpha( 75 );
    gc.drawImage(image, x+width_pad, y+height_pad+1);
    gc.setAlpha( 255 );

    gc.setClipping( old_clipping );

    if ( draw_border ){

        gc.setForeground(Colors.blue);

        if ( percent == 100 ){

            gc.drawOval(x , y , width-1, height-1);

        }else{

            if ( angle > 0 ){

                gc.drawPath( path_done );
            }
        }
    }

    path_done.dispose();
    path_undone.dispose();
    old_clipping.dispose();

}
项目:gef-gwt    文件:Control.java   
/**
 * Sets the shape of the control to the region specified by the argument.
 * When the argument is null, the default shape of the control is restored.
 * 
 * @param region
 *            the region that defines the shape of the control (or null)
 * 
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_INVALID_ARGUMENT - if the region has been
 *                disposed</li>
 *                </ul>
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the receiver has been
 *                disposed</li>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the receiver</li>
 *                </ul>
 * 
 * @since 3.4
 */
public void setRegion(Region region) {
}
项目:gef-gwt    文件:Control.java   
/**
 * Returns the region that defines the shape of the control, or null if the
 * control has the default shape.
 * 
 * @return the region that defines the shape of the shell (or null)
 * 
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the receiver has been
 *                disposed</li>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the receiver</li>
 *                </ul>
 * 
 * @since 3.4
 */
public Region getRegion() {
    checkWidget();
    return region;
}
项目:gef-gwt    文件:Shell.java   
/**
 * Returns the region that defines the shape of the shell, or
 * <code>null</code> if the shell has the default shape.
 * 
 * @return the region that defines the shape of the shell, or
 *         <code>null</code>
 * 
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the receiver has been
 *                disposed</li>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the receiver</li>
 *                </ul>
 * 
 * @since 3.0
 * 
 */
public Region getRegion() {
    /* This method is needed for @since 3.0 Javadoc */
    checkWidget();
    return region;
}