Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Path


  {
    if (GraphicsUtil.checkGdip())
    {
      g.setAdvanced(true);
      Rectangle backRect = new Rectangle(rect.x, rect.y, rect.width, rect.height);
      Path path = GraphicsUtil.createRoundPath(backRect, 1.2f);
      g.setForeground(colors[8]);
      g.drawPath(path);
      path.dispose();
      g.setAdvanced(false);
    }
    else
    {
      g.setForeground(colors[8]);
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

    Pattern pattern = new Pattern(null, 0, glossy.y, 0, glossy.y + glossy.height,
        themeRender.getTool_item_bg_color1(), themeRender
            .getTool_item_bg_color1_alpha(), themeRender.getTool_item_bg_color2(),
        themeRender.getTool_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();

    // draw border
    path = GraphicsUtil.createRoundRectangle(outerBorder, 2);
    gc.setForeground(themeRender.getTool_item_outer_border());
    gc.drawPath(path);
    path.dispose();

    if (tracked
        && dc.getToolItem() != null
        && selected
        && (menuTracked || (dc.getToolItem().getMenu() != null && !dc.getToolItem()
            .canSelected())))
    {
      path = GraphicsUtil.createTopRoundRectangle(innerBorder, 2);
      gc.setBackground(themeRender.getTool_item_bg_glossy_showMenu());
      gc.fillPath(path);
      path.dispose();

      path = GraphicsUtil.createTopRoundRectangle(innerBorder, 2);
      gc.setForeground(themeRender.getTool_item_bg_glossy_showMenu());
      gc.drawPath(path);
      path.dispose();
      gc.setAdvanced(false);
      return;
    }
    else if (tracked && dc.getToolItem() != null && selected
        && dc.getToolItem().getMenu() != null)
    {
      pattern = new Pattern(null, 0, glossy.y, 0, glossy.y + glossy.height, themeRender
          .getTool_item_bg_glossy_selected1(), themeRender
          .getTool_item_bg_glossy_selected1_alpha(), themeRender
          .getTool_item_bg_glossy_selected2(), themeRender
          .getTool_item_bg_glossy_selected2_alpha());
      Rectangle nonMenuRect = getNonMenuRect(dc);
      Rectangle nonMenuGlossy = new Rectangle(innerBorder.x, innerBorder.y,
          nonMenuRect.width - 1, innerBorder.height / 2);
      path = createTopLeftRoundRectangle(nonMenuGlossy, 2);
      gc.setBackgroundPattern(pattern);
      gc.fillPath(path);
      path.dispose();

      pattern = new Pattern(null, 0, glossy.y, 0, glossy.y + glossy.height, themeRender
          .getTool_item_bg_glossy_track1(), themeRender
          .getTool_item_bg_glossy_track1_alpha(), themeRender
          .getTool_item_bg_glossy_track2(), themeRender
          .getTool_item_bg_glossy_track2_alpha());

      Rectangle menuRect = getMenuRect(dc);
      Rectangle menuGlossy = new Rectangle(menuRect.x, innerBorder.y,
          menuRect.width - 1, innerBorder.height / 2);
      path = createTopRightRoundRectangle(menuGlossy, 2);
      gc.setBackgroundPattern(pattern);
      gc.fillPath(path);
      path.dispose();

      Color innerBorderColor = themeRender.getTool_item_inner_border_selected();

      path = createLeftRoundPath(new Rectangle(innerBorder.x, innerBorder.y,
          nonMenuRect.width - 1, innerBorder.height), 2);
      gc.setForeground(innerBorderColor);
      gc.drawPath(path);
      path.dispose();

      innerBorderColor = themeRender.getTool_item_inner_border_track();

      path = createRightRoundPath(new Rectangle(menuRect.x, innerBorder.y,
          menuRect.width, innerBorder.height), 2);
      gc.setForeground(innerBorderColor);
      gc.drawPath(path);
      path.dispose();

      path = GraphicsUtil.createRoundRectangle(glow, 2);
      gc.setClipping(path);
      path.dispose();

      Color glowColor = themeRender.getTool_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((Region) null);

      gc.setAdvanced(false);
      return;
    }

    if (!(selected && tracked)) pattern = new Pattern(null, 0, glossy.y, 0, glossy.y
        + glossy.height, themeRender.getTool_item_bg_glossy_track1(), themeRender
        .getTool_item_bg_glossy_track1_alpha(), themeRender
        .getTool_item_bg_glossy_track2(), themeRender
        .getTool_item_bg_glossy_track2_alpha());
    else
      pattern = new Pattern(null, 0, glossy.y, 0, glossy.y + glossy.height, themeRender
          .getTool_item_bg_glossy_selected1(), themeRender
          .getTool_item_bg_glossy_selected1_alpha(), themeRender
          .getTool_item_bg_glossy_selected2(), themeRender
          .getTool_item_bg_glossy_selected2_alpha());
    path = GraphicsUtil.createTopRoundRectangle(glossy, 2);
    gc.setBackgroundPattern(pattern);
    gc.fillPath(path);
    path.dispose();

    Color innerBorderColor = (selected && tracked)
        || (dc.getToolItem() != null && (dc.getToolItem().getStyle() & SWT.CHECK) != 0 && dc
            .getToolItem().getSelection()) ? themeRender
        .getTool_item_inner_border_selected() : themeRender
        .getTool_item_inner_border_track();

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

    if (!((menuTracked || (dc.getToolItem() != null && dc.getToolItem().getMenu() != null && !dc
        .getToolItem().canSelected()))
        && selected && tracked))
    {
      path = GraphicsUtil.createRoundRectangle(glow, 2);
      gc.setClipping(path);
      path.dispose();

      Color glowColor = themeRender.getTool_item_bg_glow_track();

      if (dc.getToolItem() != null && (dc.getToolItem().getStyle() & SWT.CHECK) != 0
          && dc.getToolItem().getSelection())
      {
        if (tracked)
        {
          glowColor = themeRender.getTool_item_bg_checked_glow_track();
        }
        else
        {
          glowColor = themeRender.getTool_item_bg_checked_glow();
        }
      }

      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((Region) null);
    }
    gc.setAdvanced(false);
  }
View Full Code Here

  {
    if (GraphicsUtil.checkGdip())
    {
      g.setAdvanced(true);
      Rectangle backRect = new Rectangle(rect.x, rect.y, rect.width, rect.height);
      Path path = GraphicsUtil.createRoundPath(backRect, 1.2f);
      g.setForeground(colors[8]);
      g.drawPath(path);
      path.dispose();
      g.setAdvanced(false);
    }
    else
    {
      g.setForeground(colors[8]);
View Full Code Here

        .getToolbar_bg_glossy_color1(), themeRender
        .getToolbar_bg_glossy_color1_alpha(), themeRender
        .getToolbar_bg_glossy_color2(), themeRender
        .getToolbar_bg_glossy_color2_alpha());
    gc.setBackgroundPattern(pattern);
    Path path = new Path(null);
    path.addRectangle(glossyRect.x, glossyRect.y, glossyRect.width, glossyRect.height);
    gc.fillPath(path);
    path.dispose();

    int glowSize = (int) (toolbar.getSize().y * 0.15);
    Rectangle glowRect = new Rectangle(0, toolbar.getSize().y - glowSize, toolbar
        .getSize().x, glowSize);
    pattern = new Pattern(null, 0, glowRect.y, 0, glowRect.y + glowRect.height,
        themeRender.getToolbar_bg_glow_color1(), themeRender
            .getToolbar_bg_glow_color1_alpha(), themeRender
            .getToolbar_bg_glow_color2(), themeRender
            .getToolbar_bg_glow_color2_alpha());
    gc.setBackgroundPattern(pattern);
    path = new Path(null);
    path.addRectangle(glowRect.x, glowRect.y, glowRect.width, glowRect.height);
    gc.fillPath(path);
    path.dispose();
  }
View Full Code Here

    return null;
  }

  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

     * Applies the specified clip.
     *
     * @param s  the shape for the clip.
     */
    public void clip(Shape s) {
        Path path = toSwtPath(s);
        this.gc.setClipping(path);
        path.dispose();
    }
View Full Code Here

     */
    public void setClip(Shape clip) {
        if (clip == null) {
            return;
        }
        Path clipPath = toSwtPath(clip);
        this.gc.setClipping(clipPath);
        clipPath.dispose();
    }
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.