Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Path


    fadedImage.dispose();

  }

  private Path createTopLeftRoundRectangle(Rectangle rectangle, int radius) {
    Path path = new Path(null);

    int l = rectangle.x;
    int t = rectangle.y;
    int w = rectangle.width;
    int h = rectangle.height;
    int d = radius << 1;

    path.addArc(l, t, d, d, -180, -90); // topleft
    path.lineTo(l + radius, t);
    path.lineTo(l + w, t);
    path.lineTo(l + w, t + h);
    path.lineTo(l, t + h);
    path.lineTo(l, t + radius);
    path.close();

    return path;
  }
View Full Code Here


    return path;
  }

  private Path createTopRightRoundRectangle(Rectangle rectangle, int radius) {
    Path path = new Path(null);

    int l = rectangle.x;
    int t = rectangle.y;
    int w = rectangle.width;
    int h = rectangle.height;
    int d = radius << 1;

    path.moveTo(l, t); // topleft
    path.lineTo(l + w - radius, t);
    path.addArc(l + w - d, t, d, d, -270, -90); // topright
    path.lineTo(l + w, t + radius);
    path.lineTo(l + w, t + h);
    path.lineTo(l, t + h);
    path.lineTo(l, t);
    path.close();

    return path;
  }
View Full Code Here

    return path;
  }

  public static Path createLeftRoundPath(Rectangle rectangle, int radius) {
    Path path = new Path(null);

    int l = rectangle.x;
    int t = rectangle.y;
    int w = rectangle.width;
    int h = rectangle.height;
    int d = radius << 1;

    path.moveTo(l + w, t);
    path.lineTo(l + radius, t);
    path.addArc(l, t, d, d, 90, 90);

    path.lineTo(l, t + radius);
    path.lineTo(l, t + h - radius);
    path.addArc(l, t + h - d, d, d, 180, 90);
    path.lineTo(l + radius, t + h);
    path.lineTo(l + w, t + h);

    return path;
  }
View Full Code Here

    return path;
  }

  public static Path createRightRoundPath(Rectangle rectangle, int radius) {
    Path path = new Path(null);

    int l = rectangle.x;
    int t = rectangle.y;
    int w = rectangle.width;
    int h = rectangle.height;
    int d = radius << 1;

    path.moveTo(l, t);
    path.lineTo(l + w - radius, t);
    path.addArc(l + w - d, t, d, d, -270, -90);
    path.lineTo(l + w, t + radius);
    path.lineTo(l + w, t + h - radius);
    path.addArc(l + w - d, t + h - d, d, d, 0, -90);
    path.lineTo(l + w - radius, t + h);
    path.lineTo(l, t + h); // top

    return path;
  }
View Full Code Here

    return mergeColors(color1, percent1, color2, percent2,
        new RGB(0, 0, 0), 0f);
  }

  public static Path createRoundPath(Rectangle rect, float cut) {
    Path path = new Path(null);

    path.moveTo(rect.x + cut, (float) rect.y);
    path.lineTo(rect.x + rect.width - cut, (float) rect.y);

    path.lineTo(rect.x + rect.width - cut, (float) rect.y);
    path.lineTo((float) rect.x + rect.width, rect.y + cut);

    path.lineTo((float) rect.x + rect.width, rect.y + cut);
    path.lineTo((float) rect.x + rect.width, rect.y + rect.height - cut);

    path.lineTo((float) rect.x + rect.width, rect.y + rect.height - cut);
    path.lineTo(rect.x + rect.width - cut, (float) rect.y + rect.height);

    path.lineTo(rect.x + rect.width - cut, (float) rect.y + rect.height);
    path.lineTo(rect.x + cut, (float) rect.y + rect.height);

    path.lineTo(rect.x + cut, (float) rect.y + rect.height);
    path.lineTo((float) rect.x, rect.y + rect.height - cut);

    path.lineTo((float) rect.x, rect.y + rect.height - cut);
    path.lineTo((float) rect.x, rect.y + cut);

    path.lineTo((float) rect.x, rect.y + cut);
    path.lineTo(rect.x + cut, (float) rect.y);

    return path;
  }
View Full Code Here

    return path;
  }

  public static Path createRoundRectangle(Rectangle rectangle, int radius) {
    Path path = new Path(null);
    int l = rectangle.x;
    int t = rectangle.y;
    int w = rectangle.width;
    int h = rectangle.height;
    int d = radius << 1;

    path.addArc(l, t, d, d, -180, -90);
    path.lineTo(l + radius, t);
    path.lineTo(l + w - radius, t);
    path.addArc(l + w - d, t, d, d, -270, -90);
    path.lineTo(l + w, t + radius);
    path.lineTo(l + w, t + h - radius);
    path.addArc(l + w - d, t + h - d, d, d, 0, -90);
    path.lineTo(l + w - radius, t + h);
    path.lineTo(l + radius, t + h); // top
    path.addArc(l, t + h - d, d, d, -90, -90);
    path.lineTo(l, t + h - radius);
    path.lineTo(l, t + radius);
    path.close();

    return path;
  }
View Full Code Here

    return path;
  }

  public static Path createTopRoundRectangle(Rectangle rectangle, int radius) {
    Path path = new Path(null);
    int l = rectangle.x;
    int t = rectangle.y;
    int w = rectangle.width;
    int h = rectangle.height;
    int d = radius << 1;

    path.addArc(l, t, d, d, -180, -90); // topleft
    path.lineTo(l + radius, t);
    path.lineTo(l + w - radius, t);
    path.addArc(l + w - d, t, d, d, -270, -90); // topright
    path.lineTo(l + w, t + radius);
    path.lineTo(l + w, t + h);
    path.lineTo(l, t + h);
    path.lineTo(l, t + radius);
    path.close();

    return path;
  }
View Full Code Here

    return path;
  }

  public static Path createBottomRoundRectangle(Rectangle rectangle,
      int radius) {
    Path path = new Path(null);
    int l = rectangle.x;
    int t = rectangle.y;
    int w = rectangle.width;
    int h = rectangle.height;
    int d = radius << 1;

    path.moveTo(l, t);
    path.lineTo(l + w, t);
    path.lineTo(l + w, t + h - radius);
    path.addArc(l + w - d, t + h - d, d, d, 0, -90);
    path.lineTo(l + w - radius, t + h);
    path.lineTo(l + radius, t + h);
    path.addArc(l, t + h - d, d, d, -90, -90);
    path.lineTo(l, t + h - radius);
    path.lineTo(l, t);
    path.close();

    return path;
  }
View Full Code Here

    float w = bounds[2];
    float h = bounds[3];
    float d = w;
    float g = h;

    Path path = new Path(null);

    path.addArc(l, t, d, g, -180, -90);
    path.addArc(l + w - d, t, d, g, -270, -90);
    path.addArc(l + w - d, t + h - g, d, g, 0, -90);
    path.addArc(l, t + h - g, d, g, -90, -90);
    path.close();
    return path;
  }
View Full Code Here

            Pattern pattern = new Pattern(null, 0, glossy.y, 0, glossy.y
                + glossy.height, themeRender.getMenu_item_bg_color1(),
                themeRender.getMenu_item_bg_color1_alpha(), themeRender
                    .getMenu_item_bg_color2(), themeRender
                    .getMenu_item_bg_color2_alpha());
            Path path = new Path(null);
            path.addRectangle(glossy.x, glossy.y, glossy.width, glossy.height);
            gc.setBackgroundPattern(pattern);
            gc.fillPath(path);
            path.dispose();

            path = GraphicsUtil.createRoundRectangle(outerBorder, 2);
            gc.setForeground(themeRender.getMenu_item_outer_border());
            gc.drawPath(path);
            path.dispose();

            if (!selected) pattern = new Pattern(null, 0, glossy.y, 0, glossy.y
                + glossy.height, themeRender.getMenu_item_bg_glossy_track1(),
                themeRender.getMenu_item_bg_glossy_track1_alpha(), themeRender
                    .getMenu_item_bg_glossy_track2(), themeRender
                    .getMenu_item_bg_glossy_track2_alpha());
            else
              pattern = new Pattern(null, 0, glossy.y, 0, glossy.y
                  + glossy.height, themeRender
                  .getMenu_item_bg_glossy_selected1(), themeRender
                  .getMenu_item_bg_glossy_selected1_alpha(), themeRender
                  .getMenu_item_bg_glossy_selected2(), themeRender
                  .getMenu_item_bg_glossy_selected2_alpha());
            path = GraphicsUtil.createTopRoundRectangle(glossy, 2);
            gc.setBackgroundPattern(pattern);
            gc.fillPath(path);
            path.dispose();

            Color innerBorderColor = selected
                || (mc != null && (mc.getStyle() & SWT.CHECK) != 0 && mc
                    .getSelection()) ? themeRender
                .getMenu_item_inner_border_selected() : themeRender
                .getMenu_item_inner_border_track();

            path = GraphicsUtil.createRoundRectangle(innerBorder, 2);
            gc.setForeground(innerBorderColor);
            gc.drawPath(path);
            path.dispose();

            if (!selected)
            {
              path = GraphicsUtil.createRoundRectangle(glow, 2);
              gc.setClipping(path);
              path.dispose();

              Color glowColor = themeRender.getMenu_item_bg_glow_track();
              path = createBottomRadialPath(glow);
              float[] point = new float[2];
              float[] bounds = new float[4];
              path.getBounds(bounds);
              point[0] = (bounds[0] + bounds[0] + bounds[2]) / 2f;
              point[1] = (bounds[1] + bounds[1] + bounds[3]) / 2f;
              GCExtension extension = new GCExtension(gc);
              extension.fillGradientPath(path, point, glowColor, 255,
                  new Color[] { glowColor }, new int[] { 0 });
              path.dispose();
              gc.setClipping((Path) null);
            }
            gc.setAdvanced(false);
          }
          if (selected) showMenuShadow(gc, dc.getSelectRect(), dc.getMenuItem());
View Full Code Here

TOP

Related Classes of org.eclipse.swt.graphics.Path

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.