示例#1
0
  private void drawBackground(GC gc) {
    Rectangle bounds = mShell.getBounds();
    if (!getMaximized()) {
      Color borderColor = null;
      if (Display.getDefault().getActiveShell() == mShell)
        borderColor = AbstractShellPainter.outerBorderNonMaximized;
      else borderColor = AbstractShellPainter.outerBorderNonMaximized_Inactive;
      gc.setBackground(borderColor);

      gc.fillRectangle(0, 0, bounds.width, bounds.height);

      gc.setBackground(bgColor);
      gc.fillRectangle(1, 1, bounds.width - 2, bounds.height - 2);

      // draw pretty borders, only bottoms, the top borders (as the menubar needs to connect for the
      // big button to work)
      // are drawn in a similar fashion in the RibbonTabFolder

      gc.setForeground(borderColor);
      // bottom left
      gc.drawLine(1, bounds.height - 4, 1, bounds.height - 4);
      gc.drawLine(1, bounds.height - 3, 2, bounds.height - 3);
      gc.drawLine(2, bounds.height - 2, 3, bounds.height - 2);

      // bottom right
      gc.drawLine(bounds.width - 4, bounds.height - 2, bounds.width - 3, bounds.height - 2);
      gc.drawLine(bounds.width - 3, bounds.height - 3, bounds.width - 2, bounds.height - 3);
      gc.drawLine(bounds.width - 2, bounds.height - 4, bounds.width - 2, bounds.height - 4);
    } else {
      gc.setBackground(bgColor);
      gc.fillRectangle(bounds);
    }
  }
示例#2
0
  /**
   * paint progress bar
   *
   * @param paintEvent paint event
   */
  private void paint(PaintEvent paintEvent) {
    GC gc;
    Rectangle bounds;
    int x, y, w, h;

    gc = paintEvent.gc;
    bounds = getBounds();
    x = 0;
    y = 0;
    w = bounds.width;
    h = bounds.height;

    // shadow
    gc.setForeground(colorNormalShadow);
    gc.drawRectangle(x + 0, y + 0, w - 2, h - 2);

    gc.setForeground(colorHighlightShadow);
    gc.drawLine(x + 1, y + 1, x + w - 3, y + 1);
    gc.drawLine(x + 1, y + 2, x + 1, y + h - 3);
    gc.drawLine(x + 0, y + h - 1, x + w - 1, y + h - 1);
    gc.drawLine(x + w - 1, y + 0, x + w - 1, y + h - 2);

    // draw bar
    gc.setBackground(colorBar);
    gc.fillRectangle(x + 2, y + 2, w - 4, h - 4);
    gc.setBackground(colorBarSet);
    gc.fillRectangle(x + 2, y + 2, (int) ((double) (w - 4) * value), h - 4);

    // draw percentage text
    gc.setForeground(colorBlack);
    gc.drawString(text, (w - textSize.x) / 2, (h - textSize.y) / 2, true);
  }
    @Override
    public void paintLayer(
        ILayer natLayer,
        GC gc,
        int xOffset,
        int yOffset,
        Rectangle rectangle,
        IConfigRegistry configRegistry) {
      super.paintLayer(natLayer, gc, xOffset, yOffset, rectangle, configRegistry);

      Color separatorColor =
          configRegistry.getConfigAttribute(
              IFreezeConfigAttributes.SEPARATOR_COLOR, DisplayMode.NORMAL);
      if (separatorColor == null) {
        separatorColor = GUIHelper.COLOR_BLUE;
      }

      gc.setClipping(rectangle);
      Color oldFg = gc.getForeground();
      gc.setForeground(separatorColor);
      final int freezeWidth = freezeLayer.getWidth() - 1;
      if (freezeWidth > 0) {
        gc.drawLine(
            xOffset + freezeWidth, yOffset, xOffset + freezeWidth, yOffset + getHeight() - 1);
      }
      final int freezeHeight = freezeLayer.getHeight() - 1;
      if (freezeHeight > 0) {
        gc.drawLine(
            xOffset, yOffset + freezeHeight, xOffset + getWidth() - 1, yOffset + freezeHeight);
      }
      gc.setForeground(oldFg);
    }
  /**
   * Manually paints the checked or unchecked symbol. This provides a fast replacement for the
   * variant that paints the images defined in this class.
   *
   * <p>The reason for this is that painting manually is 2-3 times faster than painting the image -
   * which is very notable if you have a completely filled table! (see example!)
   *
   * @param gc The GC to use when dawing
   * @param rect The cell ara where the symbol should be painted into.
   * @param checked Wether the symbol should be the checked or unchecked
   * @param bgColor The background color of the cell.
   * @param fillColor The color of the box drawn (with of without checked mark). Used when a click
   *     indication is desired.
   */
  protected void drawCheckedSymbol(
      GC gc, Rectangle rect, boolean checked, Color bgColor, Color fillColor) {
    // clear background:
    gc.setBackground(bgColor);
    gc.fillRectangle(rect);

    // paint rectangle:
    Rectangle bound = getAlignedLocation(rect, IMAGE_CHECKED);

    gc.setForeground(BORDER_LIGHT);
    gc.drawLine(bound.x, bound.y, bound.x + bound.width, bound.y);
    gc.drawLine(bound.x, bound.y, bound.x, bound.y + bound.height);
    gc.setForeground(BORDER_DARK);
    gc.drawLine(
        bound.x + bound.width, bound.y + 1, bound.x + bound.width, bound.y + bound.height - 1);
    gc.drawLine(bound.x, bound.y + bound.height, bound.x + bound.width, bound.y + bound.height);

    if (!bgColor.equals(fillColor)) {
      gc.setBackground(fillColor);
      gc.fillRectangle(bound.x + 1, bound.y + 1, bound.width - 1, bound.height - 1);
    }

    if (checked) // draw a check symbol:
    drawCheckSymbol(gc, bound);
  }
  protected void drawInformation(GC gc) {
    super.drawInformation(gc);

    Point size = getSize();
    gc.setForeground(SWTResourceManager.getColor(0xFF, 0x99, 0x00));
    gc.drawLine(0, size.y / 2 + paintOffset.y, size.x, size.y / 2 + paintOffset.y);
    gc.drawLine(size.x / 2 + paintOffset.x, 0, size.x / 2 + paintOffset.x, size.y);

    // 绘制起始点和目标点
    if (position != null) {
      int blockSize = 2;
      if (ratio > 1.0f) {
        blockSize *= ratio;
      }
      gc.setForeground(SWTResourceManager.getColor(0xFF, 0x99, 0x00));
      Point pt = new Point(position.x, position.y);
      pt = coordToPos(pt);
      gc.drawRectangle(pt.x - blockSize, pt.y - blockSize, blockSize * 2, blockSize * 2);
      gc.drawLine(pt.x - blockSize, pt.y, pt.x + blockSize, pt.y);
      gc.drawLine(pt.x, pt.y - blockSize, pt.x, pt.y + blockSize);

      gc.setForeground(SWTResourceManager.getColor(0x00, 0x99, 0xFF));
      Point pt2 = new Point(directionX, directionY);
      pt2 = coordToPos(pt2);
      gc.drawRectangle(pt2.x - blockSize, pt2.y - blockSize, blockSize * 2, blockSize * 2);
      gc.drawLine(pt2.x - blockSize, pt2.y, pt2.x + blockSize, pt2.y);
      gc.drawLine(pt2.x, pt2.y - blockSize, pt2.x, pt2.y + blockSize);

      gc.drawLine(pt.x, pt.y, pt2.x, pt2.y);
    }

    // 绘制选项按钮
    drawButtons(gc);
  }
示例#6
0
 void drawItem(GC gc, boolean drawFocus) {
   int headerHeight = parent.getBandHeight();
   Display display = getDisplay();
   gc.setForeground(display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND));
   gc.setBackground(display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT));
   gc.fillGradientRectangle(x, y, width, headerHeight, true);
   if (expanded) {
     gc.setForeground(display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT));
     gc.drawLine(x, y + headerHeight, x, y + headerHeight + height - 1);
     gc.drawLine(x, y + headerHeight + height - 1, x + width - 1, y + headerHeight + height - 1);
     gc.drawLine(x + width - 1, y + headerHeight + height - 1, x + width - 1, y + headerHeight);
   }
   int drawX = x;
   if (image != null) {
     drawX += ExpandItem.TEXT_INSET;
     if (imageHeight > headerHeight) {
       gc.drawImage(image, drawX, y + headerHeight - imageHeight);
     } else {
       gc.drawImage(image, drawX, y + (headerHeight - imageHeight) / 2);
     }
     drawX += imageWidth;
   }
   if (text.length() > 0) {
     drawX += ExpandItem.TEXT_INSET;
     Point size = gc.stringExtent(text);
     gc.setForeground(parent.getForeground());
     gc.drawString(text, drawX, y + (headerHeight - size.y) / 2, true);
   }
   int chevronSize = ExpandItem.CHEVRON_SIZE;
   drawChevron(gc, x + width - chevronSize, y + (headerHeight - chevronSize) / 2);
   if (drawFocus) {
     gc.drawFocus(x + 1, y + 1, width - 2, headerHeight - 2);
   }
 }
示例#7
0
文件: KTable.java 项目: URMC/i2b2
  protected void drawBottomSpace(GC gc) {
    Rectangle r = getClientArea();
    if (m_Model.getRowCount() > 0) {
      r.y =
          m_Model.getFirstRowHeight()
              + (m_Model.getFixedRowCount() - 1 + m_RowsVisible) * m_Model.getRowHeight()
              + 1;
    }

    gc.setBackground(getBackground());
    gc.fillRectangle(r);
    gc.fillRectangle(getLastColumnRight() + 2, 0, r.width, r.height);

    if (m_Model.getRowCount() > 0) {
      if (flatStyleSpecified)
        // gc.setForeground(this.getBackground());
        gc.setForeground(m_Display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
      else gc.setForeground(m_Display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
      // Linke Schattenlinie
      gc.drawLine(0, 0, 0, r.y - 1);
    }

    if (!flatStyleSpecified) gc.setForeground(this.getBackground());
    else gc.setForeground(m_Display.getSystemColor(SWT.COLOR_WHITE));
    // Untere Abschlusslinie
    gc.drawLine(0, r.y - 1, getLastColumnRight() + 1, r.y - 1);

    // Rechte Abschlusslinie
    gc.drawLine(getLastColumnRight() + 1, 0, getLastColumnRight() + 1, r.y - 1);
  }
  void resize() {
    Point size = comp.getSize();
    Image oldBackgroundImage = backgroundImage;
    backgroundImage = new Image(comp.getDisplay(), size.x, size.y);
    GC gc = new GC(backgroundImage);
    comp.getParent().drawBackground(gc, 0, 0, size.x, size.y, 0, 0);
    Color background = comp.getBackground();
    Color border = comp.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
    RGB backgroundRGB = background.getRGB();
    // TODO naive and hard coded, doesn't deal with high contrast, etc.
    Color gradientTop =
        new Color(
            comp.getDisplay(),
            backgroundRGB.red + 12,
            backgroundRGB.green + 10,
            backgroundRGB.blue + 10);
    int h = size.y;
    int curveStart = 0;
    int curve_width = 5;

    int[] curve =
        new int[] {
          0, h, 1, h, 2, h - 1, 3, h - 2, 3, 2, 4, 1, 5, 0,
        };
    int[] line1 = new int[curve.length + 4];
    int index = 0;
    int x = curveStart;
    line1[index++] = x + 1;
    line1[index++] = h;
    for (int i = 0; i < curve.length / 2; i++) {
      line1[index++] = x + curve[2 * i];
      line1[index++] = curve[2 * i + 1];
    }
    line1[index++] = x + curve_width;
    line1[index++] = 0;

    int[] line2 = new int[line1.length];
    index = 0;
    for (int i = 0; i < line1.length / 2; i++) {
      line2[index] = line1[index++] - 1;
      line2[index] = line1[index++];
    }

    // custom gradient
    gc.setForeground(gradientTop);
    gc.setBackground(background);
    gc.drawLine(4, 0, size.x, 0);
    gc.drawLine(3, 1, size.x, 1);
    gc.fillGradientRectangle(2, 2, size.x - 2, size.y - 3, true);
    gc.setForeground(background);
    gc.drawLine(2, size.y - 1, size.x, size.y - 1);
    gradientTop.dispose();

    gc.setForeground(border);
    gc.drawPolyline(line2);
    gc.dispose();
    comp.setBackgroundImage(backgroundImage);
    if (oldBackgroundImage != null) oldBackgroundImage.dispose();
  }
示例#9
0
  private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) {
    gc.setForeground(topleft);
    gc.drawLine(x, y, x + w - 1, y);
    gc.drawLine(x, y, x, y + h - 1);

    gc.setForeground(bottomright);
    gc.drawLine(x + w, y, x + w, y + h);
    gc.drawLine(x, y + h, x + w, y + h);
  }
示例#10
0
  /** @param e */
  protected void drawTitleBackground(PaintEvent e) {

    Rectangle bounds = getClientArea();
    Point tsize = null;
    Point labelSize = null;
    int twidth = bounds.width - marginWidth - marginWidth;
    if (label != null) {
      labelSize = label.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    }
    if (labelSize != null) {
      twidth -= labelSize.x + 4;
    }
    int tvmargin = 4;
    int theight = getHeight();
    if (tsize != null) {
      theight += Math.max(theight, tsize.y);
    }
    if (labelSize != null) {
      theight = Math.max(theight, labelSize.y);
    }
    theight += tvmargin + tvmargin;
    int midpoint = (theight * 66) / 100;
    int rem = theight - midpoint;
    GC gc = e.gc;
    gc.setForeground(bg);
    gc.setBackground(gbg);
    gc.fillGradientRectangle(
        marginWidth,
        marginHeight,
        bounds.width - 1 - marginWidth - marginWidth,
        midpoint - 1,
        true);
    gc.setForeground(gbg);
    gc.setBackground(getBackground());
    gc.fillGradientRectangle(
        marginWidth,
        marginHeight + midpoint - 1,
        bounds.width - 1 - marginWidth - marginWidth,
        rem - 1,
        true);
    gc.setForeground(border);
    gc.drawLine(marginWidth, marginHeight + 2, marginWidth, marginHeight + theight - 1);
    gc.drawLine(marginWidth, marginHeight + 2, marginWidth + 2, marginHeight);
    gc.drawLine(marginWidth + 2, marginHeight, bounds.width - marginWidth - 3, marginHeight);
    gc.drawLine(
        bounds.width - marginWidth - 3,
        marginHeight,
        bounds.width - marginWidth - 1,
        marginHeight + 2);
    gc.drawLine(
        bounds.width - marginWidth - 1,
        marginHeight + 2,
        bounds.width - marginWidth - 1,
        marginHeight + theight - 1);
  }
  /**
   * Create a background image that shows the scale and channels as requested
   *
   * @return
   */
  private Image CreateBackgroundImage(int numHorizontalLines, int numVerticalLines) {
    // * Image i = new Image(device, boundsRectangle);
    // * GC gc = new GC(i);
    // * gc.drawRectangle(0, 0, 50, 50);
    // * gc.dispose();
    Rectangle rect = getBounds();
    if ((rect.width == 0) || (rect.height == 0)) return null;
    Image TheImage = new Image(getDisplay(), rect);
    GC gc = new GC(TheImage);
    gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
    int step = (getSize().y - 20) / (numHorizontalLines - 1);
    int width = getSize().x;
    int height = getSize().y;
    gc.fillRectangle(0, 0, width, getSize().y);
    gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_CYAN));
    int Value =
        myLowRangeValue
            + (int) (10.0 * (float) (myhighValue - myLowRangeValue) / (float) rect.height);
    int RangeStep =
        (int)
            ((float) (rect.height - 20)
                / (float) (numHorizontalLines - 1)
                * (float) (myhighValue - myLowRangeValue)
                / (float) rect.height);
    for (int i = 0; i < numHorizontalLines; i++) {
      gc.drawLine(0, 10 + (step * i), width, 10 + (step * i));
      gc.drawString(
          Integer.toString(Value + RangeStep * (numHorizontalLines - (i + 1))),
          10,
          10 + (step * i));
    }
    step = (getSize().x - 20) / (numVerticalLines - 1);
    for (int i = 0; i < numVerticalLines; i++) {
      gc.drawLine(10 + (step * i), 0, 10 + (step * i), height);
    }
    step = (int) Math.round(gc.getFont().getFontData()[0].height * 1.5);
    if (ShowLabels) {
      for (int i = 0; i < chan.length; i++) {
        gc.setForeground(chan[i].fg);
        gc.drawString(chan[i].name, 50, 10 + (step * i));
      }
    }
    gc.setForeground(chan[0].fg);
    gc.drawString(myStatus, 200, 10);

    // gc.drawString(string, x, y)
    gc.dispose();
    return TheImage;
  }
 void drawBar(GC g) {
   if (g != null) {
     // g.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
     // g.setXORMode(true);
     g.drawLine(playHeadPixel, 0, playHeadPixel, getClientArea().height);
   }
 }
示例#13
0
  private void drawYGrid(GC gc, double lineStart, double lineStep) {
    Color color_light_blue = new Color(display, 220, 220, 255);

    // double line = minValue;
    double line = lineStart;

    while (line <= maxValue) {
      int y = valueToGraph(line);
      gc.setForeground(color_light_blue);
      gc.drawLine(xStart, y, xEnd, y);
      gc.setForeground(color_black);

      String valueText;
      if (lineStep >= 1d) {
        valueText = Util.doubleToString0(line);
      } else if (lineStep >= 0.1d) {
        valueText = Util.doubleToString1(line);
      } else if (lineStep >= 0.01d) {
        valueText = Util.doubleToString2(line);
      } else {
        valueText = Util.doubleToStringFull(line);
      }

      Painter.drawText(valueText, gc, xStart, y, PosHorizontal.RIGHT, PosVerical.CENTER);
      line += lineStep;
    }
  }
示例#14
0
  public void plotLine(GC gc) {
    /*	int x1;
    int y1;
    int x2;
    int y2;
    if (p1.getBlock()!=null)
    {
    	// in this case p1 is connected to block
    	BlockIORect ioblock = p1.getBlock();
    	//Point pp  = p1.get.getDisplay().map(ioblock.getBlock().getR2(), ioblock.getShell(), ioblock.getCenter().x, ioblock.getCenter().y);
    	Point pp  = ioblock.getDisplay().map(ioblock.getBlock().getR2(), ioblock.getShell(), ioblock.getCenter().x, ioblock.getCenter().y);
    	x1=pp.x;
    	y1=pp.y;

    }
    else
    {
    	 x1 = p1.getP().x;
    	 y1 = p1.getP().y;
    }

     x1 = p1.getP().x;
     y1 = p1.getP().y;*/
    gc.setLineWidth(3);
    gc.drawLine(p1.getP().x, p1.getP().y, p2.getP().x, p2.getP().y);
    gc.setLineWidth(1);

    gc.drawPolygon(circle(r, p1.getP().x, p1.getP().y));
    gc.drawPolygon(circle(r, p2.getP().x, p2.getP().y));
  }
 public void mouseMove(MouseEvent e) {
   if ((e.stateMask & SWT.BUTTON1) == 0) return;
   GC gc = new GC((Canvas) e.widget);
   gc.drawLine(p.x, p.y, e.x, e.y);
   gc.dispose();
   updatePoint(e);
 }
  /**
   * Draw the composite images.
   *
   * <p>Subclasses must implement this framework method to paint images within the given bounds
   * using one or more calls to the <code>drawImage</code> framework method.
   *
   * @param width the width
   * @param height the height
   * @see org.eclipse.jface.resource.CompositeImageDescriptor#drawCompositeImage(int, int)
   */
  protected void drawCompositeImage(int width, int height) {
    Display display = Display.getDefault();

    Image image = new Image(display, ARROW_SIZE, ARROW_SIZE * 2);

    GC gc = new GC(image);

    Color triangle = createColor(SWT.COLOR_LIST_FOREGROUND, SWT.COLOR_LIST_BACKGROUND, 20, display);
    Color aliasing = createColor(SWT.COLOR_LIST_FOREGROUND, SWT.COLOR_LIST_BACKGROUND, 30, display);
    gc.setBackground(triangle);

    if (fLTR) {
      gc.fillPolygon(
          new int[] {mirror(0), 0, mirror(ARROW_SIZE), ARROW_SIZE, mirror(0), ARROW_SIZE * 2});
    } else {
      gc.fillPolygon(new int[] {ARROW_SIZE, 0, 0, ARROW_SIZE, ARROW_SIZE, ARROW_SIZE * 2});
    }

    gc.setForeground(aliasing);
    gc.drawLine(mirror(0), 1, mirror(ARROW_SIZE - 1), ARROW_SIZE);
    gc.drawLine(mirror(ARROW_SIZE - 1), ARROW_SIZE, mirror(0), ARROW_SIZE * 2 - 1);

    gc.dispose();
    triangle.dispose();
    aliasing.dispose();

    ImageData imageData = image.getImageData();
    for (int y = 1; y < ARROW_SIZE; y++) {
      for (int x = 0; x < y; x++) {
        imageData.setAlpha(mirror(x), y, 255);
      }
    }
    for (int y = 0; y < ARROW_SIZE; y++) {
      for (int x = 0; x <= y; x++) {
        imageData.setAlpha(mirror(x), ARROW_SIZE * 2 - y - 1, 255);
      }
    }

    int offset = 0;
    if (!fLTR) {
      offset = -1;
    }
    drawImage(imageData, width / 2 - ARROW_SIZE / 2 + offset, height / 2 - ARROW_SIZE - 1);

    image.dispose();
  }
  /** {@inheritDoc} */
  public void paint(GC gc, Object value) {

    gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));

    gc.fillRectangle(getBounds());

    gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));

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

    gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));

    gc.drawLine(getBounds().x + 2, getBounds().y + 4, getBounds().x + 6, getBounds().y + 4);

    if (!isExpanded()) {
      gc.drawLine(getBounds().x + 4, getBounds().y + 2, getBounds().x + 4, getBounds().y + 6);
    }
  }
 /** @param e */
 protected void drawTitleBackground(PaintEvent e) {
   Rectangle bounds = getClientArea();
   //		label.setBackground(new Color[] {
   //				factory.getColors().getColor(IFormColors.H_GRADIENT_END),
   //				factory.getColors().getColor(IFormColors.H_GRADIENT_START) },
   //				new int[] { 100 }, true);
   Color bg = factory.getColors().getColor(IFormColors.H_GRADIENT_END);
   Color gbg = factory.getColors().getColor(IFormColors.H_GRADIENT_START);
   GC gc = e.gc;
   gc.setForeground(bg);
   gc.setBackground(gbg);
   gc.fillGradientRectangle(bounds.x, bounds.y, bounds.width, bounds.height, true);
   // background bottom separator
   gc.setForeground(factory.getColors().getColor(IFormColors.H_BOTTOM_KEYLINE1));
   gc.drawLine(bounds.x, bounds.height - 2, bounds.x + bounds.width - 1, bounds.height - 2);
   gc.setForeground(factory.getColors().getColor(IFormColors.H_BOTTOM_KEYLINE2));
   gc.drawLine(bounds.x, bounds.height - 1, bounds.x + bounds.width - 1, bounds.height - 1);
 }
示例#19
0
    private void draw(GC gc) {
      Rectangle r = getClientArea();
      gc.setForeground(color);

      int y0, y1;
      if (r.height > HEIGHT) {
        y0 = (r.height - HEIGHT) / 2;
        y1 = y0 + HEIGHT;
      } else {
        y0 = 0;
        y1 = r.height;
      }

      gc.drawLine(DX, y0, DX, y1);

      gc.drawLine(0, y0 + 3, DX, y0);
      gc.drawLine(2 * DX, y0 + 3, DX, y0);
    }
 /** {@inheritDoc} */
 @Override
 public void drawTickLabel(
     final GC gc, final SWTMediaPool media, final Double tick, final boolean floating) {
   final Rectangle region = getBounds();
   final int x = getScreenCoord(tick);
   gc.drawLine(x, region.y, x, region.y + TICK_LENGTH);
   final String mark = ticks.format(tick);
   final Point mark_size = gc.textExtent(mark);
   gc.drawString(mark, x - mark_size.x / 2, region.y + TICK_LENGTH, !floating);
 }
示例#21
0
 private static final Image createCloseImage(Display display, Color bg, Color fg) {
   int size = 11, off = 1;
   Image image = new Image(display, size, size);
   GC gc = new GC(image);
   gc.setBackground(bg);
   gc.fillRectangle(image.getBounds());
   gc.setForeground(fg);
   gc.drawLine(0 + off, 0 + off, size - 1 - off, size - 1 - off);
   gc.drawLine(1 + off, 0 + off, size - 1 - off, size - 2 - off);
   gc.drawLine(0 + off, 1 + off, size - 2 - off, size - 1 - off);
   gc.drawLine(size - 1 - off, 0 + off, 0 + off, size - 1 - off);
   gc.drawLine(size - 1 - off, 1 + off, 1 + off, size - 1 - off);
   gc.drawLine(size - 2 - off, 0 + off, 0 + off, size - 2 - off);
   /*gc.drawLine(1, 0, size-2, 0);
   gc.drawLine(1, size-1, size-2, size-1);
   gc.drawLine(0, 1, 0, size-2);
   gc.drawLine(size-1, 1, size-1, size-2);*/
   gc.dispose();
   return image;
 }
示例#22
0
  /*
   * (non-Javadoc)
   *
   * @see org.talend.commons.ui.swt.drawing.link.AbstractDrawableLink#drawBody(org.eclipse.swt.graphics.GC)
   */
  @Override
  protected void drawBody(GC gc) {
    boolean point1Above = point1.y > point2.y;

    int mult = point1Above ? 1 : -1;

    int keyLinksCounter = 0;

    int xOffset = 4 * keyLinksCounter + 1;

    gc.drawLine(point1.x, point1.y, point1.x - connectorWidth - xOffset, point1.y);

    gc.drawArc(
        point1.x - connectorWidth - radius - xOffset,
        point1.y - (point1Above ? 2 * radius : 0),
        2 * radius,
        2 * radius,
        point1Above ? 180 : 90,
        90);

    // // in1 pr
    gc.drawLine(
        point1.x - connectorWidth - radius - xOffset,
        point1.y - mult * radius,
        point2.x - connectorWidth - radius - xOffset,
        point2.y + mult * radius);

    gc.drawArc(
        point2.x - connectorWidth - radius - xOffset,
        point2.y - (point1Above ? 0 : 2 * radius),
        2 * radius,
        2 * radius,
        point1Above ? 90 : 180,
        90);

    // // connector pr (in)
    gc.drawLine(point2.x - connectorWidth - xOffset, point2.y, point2.x, point2.y);

    keyLinksCounter++;
  }
示例#23
0
  /**
   * Draws a X as a sign that the cell value is true.
   *
   * @param gc The gc to use when painting
   * @param bound
   */
  private void drawCheckSymbol(GC gc, Rectangle bound) {
    if ((m_Style & SIGN_X) != 0) { // Draw a X
      gc.setForeground(BORDER_LIGHT);

      gc.drawLine(bound.x + 3, bound.y + 2, bound.x - 2 + bound.width, bound.y - 3 + bound.height);
      gc.drawLine(bound.x + 2, bound.y + 3, bound.x - 3 + bound.width, bound.y - 2 + bound.height);

      gc.drawLine(bound.x + 3, bound.y - 2 + bound.height, bound.x - 2 + bound.width, bound.y + 3);
      gc.drawLine(bound.x + 2, bound.y - 3 + bound.height, bound.x - 3 + bound.width, bound.y + 2);

      gc.setForeground(COLOR_TEXT);

      gc.drawLine(bound.x + 2, bound.y + 2, bound.x - 2 + bound.width, bound.y - 2 + bound.height);
      gc.drawLine(bound.x + 2, bound.y - 2 + bound.height, bound.x - 2 + bound.width, bound.y + 2);
    } else { // Draw a check sign
      gc.setForeground(getForeground());

      gc.drawLine(bound.x + 2, bound.y + bound.height - 4, bound.x + 4, bound.y + bound.height - 2);
      gc.drawLine(bound.x + 2, bound.y + bound.height - 5, bound.x + 5, bound.y + bound.height - 3);
      gc.drawLine(bound.x + 2, bound.y + bound.height - 6, bound.x + 4, bound.y + bound.height - 4);

      for (int i = 1; i < 4; i++)
        gc.drawLine(
            bound.x + 2 + i,
            bound.y + bound.height - 3,
            bound.x + bound.width - 2,
            bound.y + 1 + i);
    }
  }
示例#24
0
  void paintStripes(GC gc) {

    if (!showStripes) return;

    Rectangle rect = getClientArea();
    // Subtracted border painted by paint.
    rect = new Rectangle(rect.x + 2, rect.y + 2, rect.width - 4, rect.height - 4);

    gc.setLineWidth(2);
    gc.setClipping(rect);
    Color color = getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
    gc.setBackground(color);
    gc.fillRectangle(rect);
    gc.setForeground(this.getBackground());
    int step = 12;
    int foregroundValue = value == 0 ? step - 2 : value - 2;
    if (orientation == SWT.HORIZONTAL) {
      int y = rect.y - 1;
      int w = rect.width;
      int h = rect.height + 2;
      for (int i = 0; i < w; i += step) {
        int x = i + foregroundValue;
        gc.drawLine(x, y, x, h);
      }
    } else {
      int x = rect.x - 1;
      int w = rect.width + 2;
      int h = rect.height;

      for (int i = 0; i < h; i += step) {
        int y = i + foregroundValue;
        gc.drawLine(x, y, w, y);
      }
    }

    if (active) {
      value = (value + 2) % step;
    }
  }
示例#25
0
 private void drawLines(GC gc, int start, int end, Rectangle clipping) {
   Line startLine = getLine(gc, start);
   Line endLine = getLine(gc, end);
   if (startLine.y == endLine.y) {
     gc.drawLine(startLine.x1, startLine.y, endLine.x2, endLine.y);
   } else if (start < end) {
     int mid = (start + end) / 2;
     drawLines(gc, start, mid, clipping);
     if (mid < end) {
       drawLines(gc, mid + 1, end, clipping);
     }
   }
 }
  @Override
  public void renderStatic(GC gc, ViewPort vp) {
    final Graph<? extends ConnectionData> graph = grm.getGraph();
    for (final Connection<? extends ConnectionData> e : graph.getConnections()) {
      final int x1 = vp.toCoordX(e.from.x);
      final int y1 = vp.toCoordY(e.from.y);

      final int x2 = vp.toCoordX(e.to.x);
      final int y2 = vp.toCoordY(e.to.y);
      gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_BLACK));
      gc.drawLine(x1, y1, x2, y2);
    }
  }
示例#27
0
  private void drawXYAxis(GC gc) {

    gc.setForeground(color_black);

    // gc.drawText(""+timestampToDataTime(dataMinTimestamp), xStart, yStart+2);
    // gc.drawText(""+timestampToDataTime(dataMaxTimestamp), xEnd-70, yStart+2);

    // gc.drawText(Util.floatToString(minValue), 3, yStart-10);
    // gc.drawText(Util.floatToString(maxValue), 3, yEnd-10);

    gc.setForeground(color_grey);

    gc.drawLine(xStart, yStart, xEnd, yStart); // x-Aches
    gc.drawLine(xStart, yEnd, xEnd, yEnd); // x-Grenze
    gc.drawLine(xEnd, yStart, xEnd, yEnd); // y-Achse
    gc.drawLine(xStart, yStart, xStart, yEnd); // y-Grenze

    gc.setForeground(color_black);
    int zeroY = valueToGraph(0d);
    if (yStart <= zeroY && zeroY <= yEnd) {
      gc.drawLine(xStart, zeroY, xEnd, zeroY);
    }

    // int zero_y = (int) ((height-minValue)*valueFactor+border);

    //  min  zero max

    //  height   * (value-min)
    // -----------------
    // (max-min)

    // int y = (int) ((yRange-(/*0f-*/minValue)*valueFactor)+border);

    // int zero_y = (int) ((int) yRange-(yRange*(/*0-*/minValue)/(maxValue-minValue))+border);
    // gc.drawLine(xStart , zero_y, xEnd, zero_y);

    // System.out.println(yStart+" "+zero_y+" "+y+" "+yEnd);
  }
示例#28
0
 public void drawMesh(Mesh m, GC gc, Point c) {
   for (int i = 0; i < m.polygons.size(); i++) {
     for (int j = 0; j < m.polygons.get(i).vertecies.length; j++) {
       gc.drawPoint(
           (int) m.polygons.get(i).vertecies[j].getX() + c.x,
           (int) m.polygons.get(i).vertecies[j].getY() + c.y);
     }
     for (int j = 0; j < m.polygons.get(i).edges.length; j++) {
       gc.drawLine(
           (int) m.polygons.get(i).edges[j].getVertex(0).getX() + c.x,
           (int) m.polygons.get(i).edges[j].getVertex(0).getY() + c.y,
           (int) m.polygons.get(i).edges[j].getVertex(1).getX() + c.x,
           (int) m.polygons.get(i).edges[j].getVertex(1).getY() + c.y);
     }
   }
 }
示例#29
0
 public Image getCheckedImage(Display display, Label l, ArrayList<Mesh> meshes, Rectangle r) {
   Point p = l.getSize();
   Point c = new Point(r.width / 2, r.height / 2);
   Image image = new Image(display, p.x - 20, p.y - 20);
   GC gc = new GC(image);
   gc.drawLine((int) beginX, (int) beginY, (int) endX, (int) endY);
   //		    gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
   //		    gc.fillOval(0, 0, p.x-20, p.y-20);
   //		    gc.setForeground(display.getSystemColor(SWT.COLOR_DARK_GREEN));
   //		    gc.drawLine(0, 0, p.x-20, p.y-20);
   //		    gc.drawLine(p.x-20, 0, 0, p.y-20);
   gc.setForeground(display.getSystemColor(SWT.COLOR_RED));
   for (int i = 0; i < meshes.size(); i++) {
     drawMesh(meshes.get(i), gc, c);
   }
   gc.dispose();
   return image;
 }
示例#30
0
 public void drawImage(FSImage image, int x, int y) {
   Image img = ((SWTFSImage) image).getImage();
   if (img == null) {
     int width = image.getWidth();
     int height = image.getHeight();
     Color oldBG = _gc.getBackground();
     Color oldFG = _gc.getForeground();
     _gc.setBackground(_gc.getDevice().getSystemColor(SWT.COLOR_WHITE));
     _gc.setForeground(_gc.getDevice().getSystemColor(SWT.COLOR_BLACK));
     _gc.fillRectangle(x, y, width, height);
     _gc.drawRectangle(x, y, width, height);
     _gc.drawLine(x, y, x + width - 1, y + height - 1);
     _gc.drawLine(x, y + height - 1, x + width - 1, y);
     _gc.setBackground(oldBG);
     _gc.setForeground(oldFG);
   } else {
     Rectangle bounds = img.getBounds();
     _gc.drawImage(
         img, 0, 0, bounds.width, bounds.height, x, y, image.getWidth(), image.getHeight());
   }
 }