예제 #1
0
  /** @param gc */
  private void paintSpellError(GC gc) {
    if (ranges.isEmpty()) return;

    int lineStyle = gc.getLineStyle();
    int lineWidth = gc.getLineWidth();
    Color lineColor = gc.getForeground();
    gc.setLineWidth(2);
    gc.setLineStyle(SWT.LINE_DOT);
    gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_RED));
    int charCount = contentAdapter.getControlContents(control).length();
    Rectangle clipping = gc.getClipping();
    lineCache.clear();
    for (Object obj : ranges.values().toArray()) {
      SpellCheckEvent range = (SpellCheckEvent) obj;
      int start = range.getWordContextPosition();
      if (start < 0 || start >= charCount) continue;

      int length = Math.min(range.getInvalidWord().length(), charCount - start);
      if (length <= 0) continue;

      drawLines(gc, start, start + length - 1, clipping);
    }
    gc.setLineWidth(lineWidth);
    gc.setLineStyle(lineStyle);
    gc.setForeground(lineColor);
  }
예제 #2
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));
  }
예제 #3
0
      public void paint(GC gc) {
        int i = 2 * x + 1;
        if (values == null || i >= values.length) {
          return;
        }

        int value = getNextValue() * (90 + RANDOM.nextInt(20)) / 100 + RANDOM.nextInt(4) - 2;
        if (value > 100) {
          value = 100;
        } else if (value < -100) {
          value = -100;
        }

        int fx = y + value * channelHeight / 100;
        values[i] = fx;

        gc.setForeground(white);
        gc.setLineWidth(1);
        gc.drawPolyline(values);

        gc.setForeground(black);
        gc.setLineWidth(2);
        gc.drawRectangle(x, fx, 2, 2);

        if (++x >= width) {
          x = 0;
        }
      }
예제 #4
0
  public void setStroke(Stroke s) {
    _stroke = s;

    /*
     * Code borrowed from SwingWT
     */
    if (s == null) {
      _gc.setLineWidth(1);
      _gc.setLineCap(SWT.CAP_SQUARE);
      _gc.setLineJoin(SWT.JOIN_MITER);
      _gc.setLineDash(null);
      return;
    }

    if (!(s instanceof BasicStroke)) {
      return;
    }

    BasicStroke bs = (BasicStroke) s;

    // Setup the line width
    _gc.setLineWidth((int) bs.getLineWidth());

    // Setup the line cap
    int gcCap = SWT.CAP_SQUARE;
    switch (bs.getEndCap()) {
      case BasicStroke.CAP_BUTT:
        gcCap = SWT.CAP_FLAT;
        break;
      case BasicStroke.CAP_ROUND:
        gcCap = SWT.CAP_ROUND;
        break;
      case BasicStroke.CAP_SQUARE:
        gcCap = SWT.CAP_SQUARE;
        break;
    }
    _gc.setLineCap(gcCap);

    // Setup the line Join
    int gcJoin = SWT.JOIN_MITER;
    switch (bs.getLineJoin()) {
      case BasicStroke.JOIN_BEVEL:
        gcJoin = SWT.JOIN_BEVEL;
        break;
      case BasicStroke.JOIN_MITER:
        gcJoin = SWT.JOIN_MITER;
        break;
      case BasicStroke.JOIN_ROUND:
        gcJoin = SWT.JOIN_ROUND;
    }
    _gc.setLineJoin(gcJoin);

    float d[] = bs.getDashArray();
    int[] dashes = new int[d.length];
    for (int i = 0; i < d.length; i++) {
      dashes[i] = (int) d[i];
    }
    _gc.setLineDash(dashes);
  }
예제 #5
0
 private void drawBorder(GC gc) {
   gc.setForeground(parentShell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
   gc.setLineWidth(1);
   gc.setLineStyle(SWT.LINE_SOLID);
   gc.drawRectangle(
       pageClientArea.x, pageClientArea.y, pageClientArea.width - 1, pageClientArea.height - 1);
 }
예제 #6
0
 void pairDraw(GC gc, StyledRegion sr, int start, int end) {
   if (start > text.getCharCount() || end > text.getCharCount()) return;
   if (gc != null) {
     Point left = text.getLocationAtOffset(start);
     Point right = text.getLocationAtOffset(end);
     if (sr != null) {
       if (highlightStyle == HLS_XOR) {
         int resultColor = sr.fore ^ cm.getColor(text.getBackground());
         if (text.getLineAtOffset(text.getCaretOffset()) == text.getLineAtOffset(start)
             && horzCross
             && horzCrossColor != null
             && ((StyledRegion) horzCrossColor).bback)
           resultColor = sr.fore ^ ((StyledRegion) horzCrossColor).back;
         Color color = cm.getColor(sr.bfore, resultColor);
         gc.setBackground(color);
         gc.setXORMode(true);
         gc.fillRectangle(left.x, left.y, right.x - left.x, gc.getFontMetrics().getHeight());
       } else if (highlightStyle == HLS_OUTLINE) {
         Color color = cm.getColor(sr.bfore, sr.fore);
         gc.setForeground(color);
         gc.drawRectangle(
             left.x, left.y, right.x - left.x - 1, gc.getFontMetrics().getHeight() - 1);
       } else if (highlightStyle == HLS_OUTLINE2) {
         Color color = cm.getColor(sr.bfore, sr.fore);
         gc.setForeground(color);
         gc.setLineWidth(2);
         gc.drawRectangle(
             left.x + 1, left.y + 1, right.x - left.x - 2, gc.getFontMetrics().getHeight() - 2);
       }
     }
   } else {
     text.redrawRange(start, end - start, true);
   }
 }
예제 #7
0
  private void paint(PaintEvent event) {
    GC gc = event.gc;

    gc.setAntialias(SWT.ON);
    gc.setLineWidth(1);
    Rectangle rect = getClientArea();
    gc.setClipping(rect);
    gc.setForeground(getForeground());
    gc.setBackground(getForeground());

    Color[] palette = new Color[32];
    for (int i = 0; i < palette.length; i++) {
      float hue = 270.0f * i / (palette.length - 1);
      palette[palette.length - 1 - i] = new Color(Display.getDefault(), new RGB(hue, 1.0f, 1.0f));
      //			gc.setBackground(palette[i]);
      //			gc.fillRectangle(rect.x + i*rect.width/palette.length, rect.y, rect.width/palette.length,
      // 100);
    }

    frame.adjust();

    int x = (int) (rect.x - frame.offsetX);
    int y = (int) (rect.y - frame.offsetY);
    int extent = (int) (Math.min(rect.width, rect.height) * frame.scale);
    treeMap.paint(x, y, extent, gc, curve, palette);

    for (Color color : palette) color.dispose();

    gc.setAlpha(255);
    gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    gc.setLineStyle(SWT.LINE_DASHDOT);
    gc.setLineWidth(1);
    gc.drawRectangle(x - 1, y - 1, extent + 2, extent + 2);

    if (selection.size() > 0) {
      gc.setLineStyle(SWT.LINE_SOLID);
      gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION));
      for (TreeMap subtree : selection) {
        gc.drawRectangle(getItemBounds(subtree));
      }
    }
  }
예제 #8
0
  @Override
  public void paintBefore(MapValues map, GC gc) {
    image = descriptor(MEEPLE).createImage();
    bounds = image.getBounds();
    diameter = (int) Math.sqrt(bounds.width * bounds.width + bounds.height * bounds.height);

    Device d = gc.getDevice();
    gc.setBackground(d.getSystemColor(SWT.COLOR_WHITE));
    gc.setForeground(d.getSystemColor(SWT.COLOR_BLACK));
    gc.setLineWidth(1);
    gc.setAntialias(SWT.ON);
  }
예제 #9
0
 public void drawRectangle(GC gc) {
   offsetX = endX - startX;
   offsetY = endY - startY;
   if (gc != null) {
     gc.setLineWidth(3);
     gc.setForeground(new Color(Display.getDefault(), 255, 0, 0));
     setParams(startX, startY, offsetX, offsetY);
     gc.drawRectangle(startX, startY, offsetX, offsetY);
     tempImage = new Image(Display.getDefault(), "./temp/temp.png");
     gc.copyArea(tempImage, 0, 0);
     imagesList.add(image);
   }
 }
 @Override
 public void paint(DrawComponent dc, GC g) {
   ShapeDrawComponent sdc = (ShapeDrawComponent) dc;
   Path path = convertShape(sdc.getGeneralShape());
   if (sdc.isFill()) {
     g.setBackground(ColorUtil.toSWTColor(sdc.getFillColor()));
     g.fillPath(path);
   }
   g.setForeground(ColorUtil.toSWTColor(sdc.getLineColor()));
   //    g.setLineWidth(sdc.getLineWidth());
   g.setLineWidth((int) sdc.getLineWidth());
   g.setLineStyle(convertLineStyle(sdc.getLineStyle()));
   g.drawPath(path);
 }
예제 #11
0
  /** Paint the Label's border. */
  private void paintBorder(GC gc, Rectangle r) {
    Display disp = getDisplay();

    Color c1 = null;
    Color c2 = null;

    int style = getStyle();
    if ((style & SWT.SHADOW_IN) != 0) {
      c1 = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
      c2 = disp.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
    }
    if ((style & SWT.SHADOW_OUT) != 0) {
      c1 = disp.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
      c2 = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
    }

    if (c1 != null && c2 != null) {
      gc.setLineWidth(1);
      drawBevelRect(gc, r.x, r.y, r.width - 1, r.height - 1, c1, c2);
    }
  }
예제 #12
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;
    }
  }
예제 #13
0
  protected void drawImage() {
    if (imageData != null) {
      int deltaX = (canvas.getSize().x - imageData.width) / 2;
      int deltaY = (canvas.getSize().y - imageData.height) / 2;
      image.dispose();
      image = new Image(Display.getCurrent(), imageData);
      bgImage.dispose();
      bgImage = new Image(Display.getCurrent(), canvas.getSize().x, canvas.getSize().y);
      GC gc = new GC(bgImage);
      gc.drawImage(image, deltaX, deltaY);
      gc.setLineWidth(3);
      gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));

      Vector3f coords0 =
          implementor
              .getCamera()
              .getWorldCoordinates(
                  new Vector2f(
                      implementor.getCanvas().getSize().x / 2,
                      implementor.getCanvas().getSize().y / 2),
                  0);
      Vector3f coords1 =
          implementor
              .getCamera()
              .getWorldCoordinates(
                  new Vector2f(
                      implementor.getCanvas().getSize().x / 2,
                      implementor.getCanvas().getSize().y / 2),
                  1);
      Vector3f direction = coords0.subtract(coords1).normalizeLocal();
      coords0.subtractLocal(direction.mult(coords0.y / direction.y));
      Vector3f coords = mapCamera.getScreenCoordinates(coords0);
      gc.drawRectangle(deltaX + (int) coords.x - 25, 200 + deltaY - (int) coords.y - 25, 50, 50);

      canvas.setBackgroundImage(bgImage);
      gc.dispose();
    }
  }
예제 #14
0
  private static void paintImage2(GC gc, Point size, int f) {
    gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    gc.fillRectangle(0, 0, size.x, size.y);

    // Scale line width, corner roundness, and font size.
    // Caveat: line width expands in all directions, so the origin also has to move.

    gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION));
    gc.fillRoundRectangle(f / 2, f / 2, size.x - f, size.y - f, 10 * f, 10 * f);

    gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    gc.setLineWidth(f);
    gc.drawRoundRectangle(f / 2, f / 2, size.x - f, size.y - f, 10 * f, 10 * f);
    FontData fontData = gc.getFont().getFontData()[0];
    fontData.setHeight(fontData.getHeight() * f);
    Font font = new Font(gc.getDevice(), fontData);
    try {
      gc.setFont(font);
      gc.drawText(fontData.toString(), 10 * f, 10 * f, true);
    } finally {
      font.dispose();
    }
  }
예제 #15
0
  /**
   * Paints the preview at the given x/y position
   *
   * @param gc the graphics context to paint it into
   * @param x the x coordinate to paint the preview at
   * @param y the y coordinate to paint the preview at
   */
  void paint(GC gc, int x, int y) {
    mTitleHeight = paintTitle(gc, x, y, true /*showFile*/);
    y += mTitleHeight;
    y += 2;

    int width = getWidth();
    int height = getHeight();
    if (mThumbnail != null && mError == null) {
      gc.drawImage(mThumbnail, x, y);

      if (mActive) {
        int oldWidth = gc.getLineWidth();
        gc.setLineWidth(3);
        gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION));
        gc.drawRectangle(x - 1, y - 1, width + 2, height + 2);
        gc.setLineWidth(oldWidth);
      }
    } else if (mError != null) {
      if (mThumbnail != null) {
        gc.drawImage(mThumbnail, x, y);
      } else {
        gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BORDER));
        gc.drawRectangle(x, y, width, height);
      }

      gc.setClipping(x, y, width, height);
      Image icon = IconFactory.getInstance().getIcon("renderError"); // $NON-NLS-1$
      ImageData data = icon.getImageData();
      int prevAlpha = gc.getAlpha();
      int alpha = 96;
      if (mThumbnail != null) {
        alpha -= 32;
      }
      gc.setAlpha(alpha);
      gc.drawImage(icon, x + (width - data.width) / 2, y + (height - data.height) / 2);

      String msg = mError;
      Density density = mConfiguration.getDensity();
      if (density == Density.TV || density == Density.LOW) {
        msg =
            "Broken rendering library; unsupported DPI. Try using the SDK manager "
                + "to get updated layout libraries.";
      }
      int charWidth = gc.getFontMetrics().getAverageCharWidth();
      int charsPerLine = (width - 10) / charWidth;
      msg = SdkUtils.wrap(msg, charsPerLine, null);
      gc.setAlpha(255);
      gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_BLACK));
      gc.drawText(msg, x + 5, y + HEADER_HEIGHT, true);
      gc.setAlpha(prevAlpha);
      gc.setClipping((Region) null);
    } else {
      gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BORDER));
      gc.drawRectangle(x, y, width, height);

      Image icon = IconFactory.getInstance().getIcon("refreshPreview"); // $NON-NLS-1$
      ImageData data = icon.getImageData();
      int prevAlpha = gc.getAlpha();
      gc.setAlpha(96);
      gc.drawImage(icon, x + (width - data.width) / 2, y + (height - data.height) / 2);
      gc.setAlpha(prevAlpha);
    }

    if (mActive) {
      int left = x;
      int prevAlpha = gc.getAlpha();
      gc.setAlpha(208);
      Color bg = mCanvas.getDisplay().getSystemColor(SWT.COLOR_WHITE);
      gc.setBackground(bg);
      gc.fillRectangle(left, y, x + width - left, HEADER_HEIGHT);
      gc.setAlpha(prevAlpha);

      y += 2;

      // Paint icons
      gc.drawImage(CLOSE_ICON, left, y);
      left += CLOSE_ICON_WIDTH;

      gc.drawImage(ZOOM_IN_ICON, left, y);
      left += ZOOM_IN_ICON_WIDTH;

      gc.drawImage(ZOOM_OUT_ICON, left, y);
      left += ZOOM_OUT_ICON_WIDTH;

      gc.drawImage(EDIT_ICON, left, y);
      left += EDIT_ICON_WIDTH;
    }
  }
 public static void drawPushButtonBorder(
     GC gc,
     Point pos,
     Point size,
     int borderSize,
     boolean pushed,
     boolean isOver,
     Color borderColor,
     Color pushDownBorderColor,
     Color pushUpBorderColor) {
   if (borderSize > 0) {
     gc.setLineWidth(borderSize);
     gc.setForeground(borderColor);
     gc.drawRectangle(pos.x, pos.y, size.x - 1, size.y - 1);
   }
   if (pushed) {
     gc.setLineWidth(1);
     gc.setForeground(pushDownBorderColor);
     gc.drawLine(
         pos.x + borderSize, pos.y + borderSize, pos.x + size.x - borderSize, pos.y + borderSize);
     gc.drawLine(
         pos.x + borderSize,
         pos.y + borderSize,
         pos.x + borderSize,
         pos.y + size.y - 1 - borderSize);
     gc.setForeground(pushUpBorderColor);
     gc.drawLine(
         pos.x + size.x - borderSize,
         pos.y + borderSize + 1,
         pos.x + size.x - borderSize,
         pos.y + size.y + borderSize);
     gc.drawLine(
         pos.x + borderSize,
         pos.y + size.y - borderSize,
         pos.x + size.x - borderSize,
         pos.y + size.y - borderSize);
   } else if (isOver) {
     gc.setLineWidth(1);
     gc.setForeground(pushUpBorderColor);
     gc.drawLine(
         pos.x + borderSize,
         pos.y + borderSize,
         pos.x + size.x - 1 - borderSize,
         pos.y + borderSize);
     gc.drawLine(
         pos.x + borderSize,
         pos.y + borderSize,
         pos.x + borderSize,
         pos.y + size.y - 2 - borderSize);
     gc.setForeground(pushDownBorderColor);
     gc.drawLine(
         pos.x + size.x - 1 - borderSize,
         pos.y + borderSize + 1,
         pos.x + size.x - 1 - borderSize,
         pos.y + size.y - 1 - borderSize);
     gc.drawLine(
         pos.x + borderSize,
         pos.y + size.y - 1 - borderSize,
         pos.x + size.x - 1 - borderSize,
         pos.y + size.y - 1 - borderSize);
   }
 }
예제 #17
0
  protected void buildBars() {
    long now = TimeUtil.getCurrentTime();
    if ((now - lastDrawTime) < REFRESH_INTERVAL || area == null) {
      return;
    }
    if (onGoing) return;
    onGoing = true;
    int width = area.width > 100 ? area.width : 100;
    int height = area.height > 50 ? area.height : 50;
    Image img = new Image(null, width, height);
    GC gc = new GC(img);
    try {
      lastDrawTime = now;
      double maxValue = 0;
      ArrayList<EqData> list = new ArrayList<EqData>();
      synchronized (valueSet) {
        for (EqData e : valueSet) {
          if (objSelMgr.isUnselectedObject(e.objHash)) {
            continue;
          }
          double max = ChartUtil.getEqMaxValue(e.asd.act1 + e.asd.act2 + e.asd.act3);
          if (max > maxValue) {
            maxValue = max;
          }
          list.add(e);
        }
      }
      size = list.size();
      if (size < 1) {
        datas = new EqData[0];
        return;
      }
      datas = list.toArray(new EqData[size]);
      unitHeight = (height - AXIS_PADDING) / size;

      if (unitHeight < MINIMUM_UNIT_HEIGHT) {
        unitHeight = MINIMUM_UNIT_HEIGHT;
      }

      // draw horizontal line
      gc.setForeground(XLogViewPainter.color_grid_narrow);
      gc.setLineStyle(SWT.LINE_DOT);
      for (int i = AXIS_PADDING + unitHeight; i <= height - unitHeight; i = i + unitHeight) {
        gc.drawLine(0, i, width, i);
      }

      // draw axis line
      gc.setForeground(black);
      gc.setLineStyle(SWT.LINE_SOLID);
      int verticalLineX = 6;
      gc.drawLine(verticalLineX, AXIS_PADDING, verticalLineX, height);
      gc.drawLine(verticalLineX, AXIS_PADDING, width, AXIS_PADDING);

      int groundWidth = area.width - verticalLineX;
      int barSpace = width - verticalLineX - (3 * BAR_WIDTH);
      int imgHeight = unitHeight - (BAR_PADDING_HEIGHT * 2);
      int mod = (int) (TimeUtil.getCurrentTime() % CYCLE_INTERVAL);
      for (int i = 0; i < datas.length; i++) {
        // draw objName
        String objName = datas[i].displayName;
        gc.setForeground(dark_gary);
        gc.setFont(verdana10Italic);
        int strWidth = gc.stringExtent(objName).x;
        while (groundWidth <= (strWidth + 5)) {
          objName = objName.substring(1);
          strWidth = gc.stringExtent(objName).x;
        }
        int x1 = width - strWidth - 5;
        int y1 =
            AXIS_PADDING + (unitHeight * i) + ((unitHeight - (gc.stringExtent(objName).y + 2)));
        gc.drawString(objName, x1, y1, true);
        if (datas[i].isAlive == false) {
          gc.setForeground(dark_gary);
          gc.setLineWidth(2);
          gc.drawLine(
              x1 - 1,
              y1 + (gc.stringExtent(objName).y / 2),
              x1 + gc.stringExtent(objName).x + 1,
              y1 + (gc.stringExtent(objName).y / 2));
        }
        gc.setLineWidth(1);
        ActiveSpeedData asd = datas[i].asd;
        long total = asd.act1 + asd.act2 + asd.act3;
        double reach = barSpace * (total / maxValue);
        int barX = verticalLineX + 1;
        if (total > 0) {
          try {
            // distribute bars to 3 types
            int noOfBars = (int) reach / BAR_WIDTH;
            int noOfAct1 = (int) (noOfBars * ((double) asd.act1 / total));
            int noOfAct2 = (int) (noOfBars * ((double) asd.act2 / total));
            int noOfAct3 = (int) (noOfBars * ((double) asd.act3 / total));
            int sediments = noOfBars - (noOfAct1 + noOfAct2 + noOfAct3);
            while (sediments > 0) {
              if (asd.act3 > 0) {
                noOfAct3++;
                sediments--;
              }
              if (sediments > 0 && asd.act2 > 0) {
                noOfAct2++;
                sediments--;
              }
              if (sediments > 0 && asd.act1 > 0) {
                noOfAct1++;
                sediments--;
              }
            }
            int barY = AXIS_PADDING + ((unitHeight * i) + BAR_PADDING_HEIGHT);
            Color lastColor = null;

            for (int j = 0; j < noOfAct3; j++) {
              // draw red bar
              drawNemo(
                  gc,
                  ColorUtil.getInstance().ac3,
                  barX + 1,
                  barY + 1,
                  BAR_WIDTH - 2,
                  imgHeight - 2);
              barX += BAR_WIDTH;
              lastColor = ColorUtil.getInstance().ac3;
            }
            for (int j = 0; j < noOfAct2; j++) {
              // draw yellow bar
              drawNemo(
                  gc,
                  ColorUtil.getInstance().ac2,
                  barX + 1,
                  barY + 1,
                  BAR_WIDTH - 2,
                  imgHeight - 2);
              barX += BAR_WIDTH;
              lastColor = ColorUtil.getInstance().ac2;
            }
            for (int j = 0; j < noOfAct1; j++) {
              // draw blue bar
              drawNemo(
                  gc,
                  ColorUtil.getInstance().ac1,
                  barX + 1,
                  barY + 1,
                  BAR_WIDTH - 2,
                  imgHeight - 2);
              barX += BAR_WIDTH;
              lastColor = ColorUtil.getInstance().ac1;
            }

            // draw tong-tong bar
            if (lastColor != null) {
              drawNemo(
                  gc,
                  lastColor,
                  barX + 1 + (int) calculateReach(mod, BAR_WIDTH * 0.7d),
                  barY + 1,
                  BAR_WIDTH - 2,
                  imgHeight - 2);
            }
          } catch (Throwable th) {
            th.printStackTrace();
          }
        }

        // draw count text
        if (datas[i].isAlive) {
          gc.setFont(verdana10Bold);
          gc.setForeground(black);
          String v = Long.toString(total);
          gc.drawString(
              v,
              barX + (BAR_WIDTH * 2),
              AXIS_PADDING + (unitHeight * i) + ((unitHeight - gc.stringExtent(v).y) / 2),
              true);
        }
      }

      // draw scale text
      gc.setForeground(black);
      gc.setFont(verdana7);
      int max = (int) maxValue;
      String v = Integer.toString(max);
      String v2 = Integer.toString(max / 2);
      gc.drawString(v, width - gc.stringExtent(v).x - 2, 2, true);
      gc.drawString(
          v2, verticalLineX + ((width - verticalLineX) / 2) - gc.stringExtent(v2).x, 2, true);
      gc.drawString("0", verticalLineX, 2, true);
    } catch (Throwable th) {
      th.printStackTrace();
    } finally {
      gc.dispose();
      Image old = ibuffer;
      ibuffer = img;
      if (old != null) {
        old.dispose();
      }
      onGoing = false;
    }
  }
예제 #18
0
파일: Grid.java 프로젝트: itm/spyglass
  @Override
  public void draw(final GC gc) {

    final Rectangle clipping = gc.getClipping();

    final Color color = new Color(gc.getDevice(), getColor());

    gc.setLineWidth(lineWidth);
    gc.setForeground(color);

    final AbsolutePosition pos = getPosition();
    AbsolutePosition origin, dest;
    PixelPosition pxOrigin, pxDest;
    int originX, originY, destX, destY;

    int x1, x2, y1, y2;

    originX = pos.x;
    destX = originX + (gridElementWidth * numCols);

    for (int row = 0; row <= numRows; row++) {

      originY = destY = pos.y + (row * gridElementHeight);

      origin = new AbsolutePosition(originX, originY, 0);
      dest = new AbsolutePosition(destX, destY, 0);

      pxOrigin = getDrawingArea().absPoint2PixelPoint(origin);
      pxDest = getDrawingArea().absPoint2PixelPoint(dest);

      if ((pxOrigin.y >= clipping.y) && (pxOrigin.y <= (clipping.y + clipping.height))) {

        x1 = Math.max(clipping.x, pxOrigin.x);
        y1 = pxOrigin.y;
        x2 = Math.min((clipping.x + clipping.width), pxDest.x);
        y2 = pxDest.y;

        gc.drawLine(x1, y1, x2, y2);
      }
    }

    originY = pos.y;
    destY = originY + (gridElementHeight * numRows);

    for (int col = 0; col <= numCols; col++) {

      originX = destX = pos.x + (col * gridElementWidth);

      origin = new AbsolutePosition(originX, originY, 0);
      dest = new AbsolutePosition(destX, destY, 0);

      pxOrigin = getDrawingArea().absPoint2PixelPoint(origin);
      pxDest = getDrawingArea().absPoint2PixelPoint(dest);

      if ((pxOrigin.x >= clipping.x) && (pxOrigin.x <= (clipping.x + clipping.width))) {

        x1 = pxOrigin.x;
        y1 = Math.max(clipping.y, pxDest.y);
        x2 = pxDest.x;
        y2 = Math.min((clipping.y + clipping.height), pxOrigin.y);

        gc.drawLine(x1, y1, x2, y2);
      }
    }

    color.dispose();
  }
예제 #19
0
  private void drawAttitudeControls(GC gc, int width, int height) {
    int size = Math.min(width / 2, height);
    int verticalOffset = (height - size) / 2;

    gc.setLineWidth(2);

    gc.setBackground(background1);
    gc.fillArc(width / 2 - size, verticalOffset, size, size, 0, 360);
    gc.fillArc(width / 2, verticalOffset, size, size, 0, 360);

    gc.setBackground(background2);
    gc.fillArc(width / 2 - size, verticalOffset, size, size, (int) pitch, -180);
    gc.fillArc(width / 2, verticalOffset, size, size, (int) roll, -180);

    gc.setForeground(foregroundWhite);
    gc.drawArc(width / 2 - size, verticalOffset, size, size, 0, 360);
    gc.drawArc(width / 2, verticalOffset, size, size, 0, 360);

    String value = "";
    gc.setForeground(foregroundWhite);

    for (int i = 0; i < 2; i++) {
      int centerX = width / 2 - i * size;
      int tickSize = 20;
      int step = 20;

      for (int theta = 10; theta <= 360; theta += step) {
        int x = (int) (size / 2 + size / 2 * Math.cos(theta * Math.PI / 180.0)) + centerX;
        int y = (int) (size / 2 + size / 2 * Math.sin(theta * Math.PI / 180.0));

        int xx =
            (int) ((size) / 2 + (size - tickSize) / 2 * Math.cos(theta * Math.PI / 180.0))
                + centerX;
        int yy = (int) ((size) / 2 + (size - tickSize) / 2 * Math.sin(theta * Math.PI / 180.0));

        gc.drawLine(x, verticalOffset + y, xx, verticalOffset + yy);

        if (theta < 180) {
          if (theta > 90 && theta < 180) {
            yy = yy - 15;
            xx = xx + 2;
            value = String.valueOf(theta);
          } else if (theta > 45 && theta <= 90) {
            yy = yy - 15;
            xx = xx - 10;
            value = String.valueOf(theta);
          } else if (theta < 45) {
            yy = yy - 15;
            xx = xx - 15;
            value = String.valueOf(theta);
          }
          gc.drawText(value, xx, verticalOffset + yy, true);
        } else {
          if (theta > 270) {
            xx = xx - 9;
            value = String.valueOf(theta - 360);
          } else {
            xx = xx - 3;
            value = String.valueOf(theta - 360);
          }

          if (theta == 180) {
            yy = yy - 7;
            xx = xx + 10;
          } else if (theta == 360) {
            yy = yy - 7;
            xx = xx - 3;
          }
          gc.drawText(value, xx, verticalOffset + yy, true);
        }
      }
    }
  }
예제 #20
0
  @SuppressWarnings("deprecation")
  public void handleEvent(Event event) {

    curPaintArea = getVisibleRect();

    // System.out.println("event: " + event.type);
    if (event.type == SWT.MouseDown) {
      startX = event.x;
      startY = event.y;
      // start mouse activity
      mouseDown = true;
    } else if (event.type == SWT.MouseUp) {
      endX = event.x;
      endY = event.y;

      boolean mouseWasMoved = startX != endX || startY != endY;
      if (toolCanMove && mouseWasMoved) {
        // if the tool is able to move draw the moved image
        afterImageMove();
      }
      // stop mouse activity
      mouseDown = false;
      isDragging = false;
    } else if (event.type == SWT.Paint) {
      // System.out.println("PAINT CALLED (DOESN'T MEAN I'M DRAWING)");

      if (acceptRepaintRequests) {
        gc = event.gc;

        // System.out.println(toolCanDraw + "/" + toolCanMove + "/" + isDragging + "/" +
        // redrawBaseImage);

        /*
         * if the mouse is dragging and the current tool can
         * move the map we just draw what we already have
         * on white background. At the end of the moving
         * we will take care of adding the missing pieces.
         */
        if (toolCanMove && isDragging) {
          // System.out.println("toolCanMove && isDragging");
          if (gc != null && !gc.isDisposed() && swtImage != null) {
            /*
             * double buffer necessary, since the SWT.NO_BACKGROUND
             * needed by the canvas to properly draw background, doesn't
             * clean the parts outside the bounds of the moving panned image,
             * giving a spilling image effect.
             */
            Image tmpImage = new Image(getDisplay(), curPaintArea.width, curPaintArea.height);
            GC tmpGc = new GC(tmpImage);
            tmpGc.setBackground(white);
            tmpGc.fillRectangle(0, 0, curPaintArea.width, curPaintArea.height);
            tmpGc.drawImage(swtImage, imageOrigin.x, imageOrigin.y);
            gc.drawImage(tmpImage, 0, 0);
            tmpImage.dispose();
          }
          return;
        }

        /*
         * if the mouse is dragging and the current tool can
         * draw a boundingbox while dragging, we draw the box
         * keeping the current drawn image
         */
        if (toolCanDraw && toolManager.getCursorTool().isDrawing() && isDragging) {
          // System.out.println("draw box: " + startX + "/" + startY + "/" + endX +
          // "/" + endY);
          if (swtImage != null) {
            drawFinalImage(swtImage);
          }
          gc.setXORMode(true);

          org.eclipse.swt.graphics.Color fC = gc.getForeground();
          gc.setLineStyle(cursorToolLineStyle);
          gc.setLineWidth(cursorToolLineWidth);
          gc.setForeground(cursorToolColor);
          gc.drawRectangle(startX, startY, endX - startX, endY - startY);

          gc.setForeground(fC);
          gc.setXORMode(false);
          return;
        }

        if (!toolCanDraw && !toolCanMove && isDragging) {
          return;
        }

        if (curPaintArea == null || content == null || renderer == null) {
          return;
        }

        if (content.layers().size() == 0) {
          // if no layers available, return only if there are also no overlays

          gc.setForeground(yellow);
          gc.fillRectangle(0, 0, curPaintArea.width + 1, curPaintArea.height + 1);
          if (overlayImage == null) return;
        }

        final ReferencedEnvelope mapAOI = content.getViewport().getBounds();
        if (mapAOI == null) {
          return;
        }

        if (redrawBaseImage) {
          MapPaneEvent ev = new MapPaneEvent(this, MapPaneEvent.Type.RENDERING_STARTED);
          publishEvent(ev);

          baseImage =
              new BufferedImage(
                  curPaintArea.width + 1, curPaintArea.height + 1, BufferedImage.TYPE_INT_ARGB);
          Graphics2D g2d = baseImage.createGraphics();
          g2d.fillRect(0, 0, curPaintArea.width + 1, curPaintArea.height + 1);
          g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

          // renderer.setContext(context);
          java.awt.Rectangle awtRectangle = Utils.toAwtRectangle(curPaintArea);
          renderer.paint(g2d, awtRectangle, mapAOI, getWorldToScreenTransform());
          // swtImage.dispose();

          if (swtImage != null && !swtImage.isDisposed()) {
            swtImage.dispose();
            swtImage = null;
          }
          // System.out.println("READRAWBASEIMAGE");
          swtImage =
              new Image(
                  getDisplay(),
                  awtToSwt(baseImage, curPaintArea.width + 1, curPaintArea.height + 1));
        }

        if (swtImage != null) {
          drawFinalImage(swtImage);
        }

        MapPaneEvent ev = new MapPaneEvent(this, MapPaneEvent.Type.RENDERING_STOPPED);
        publishEvent(ev);
        clearLabelCache = true;
        onRenderingCompleted();
        redrawBaseImage = false;
      }
    }
  }
  protected void paintControl(PaintEvent e) {

    long start = System.currentTimeMillis();

    for (int c = 0; c < chan.length; c++) {

      // if (chan[c].tailSize <= 0) {
      // chan[c].stack.popNegate(0);
      // continue;
      // }

      // Go calculate the line
      Object[] result = calculate(c);
      int[] l1 = (int[]) result[0];
      int[] l2 = (int[]) result[1];

      PositionPolyLine(l1);
      PositionPolyLine(l2);
      // System.out.print(System.currentTimeMillis() - start + "-");

      // Draw it
      GC gc = e.gc;
      gc.setForeground(getForeground(c));
      gc.setAdvanced(true);
      gc.setAntialias(SWT.ON);
      gc.setLineWidth(getLineWidth(c));

      // Fade tail
      if (isFade(c)) {
        gc.setAlpha(0);
        double fade = 0;
        double fadeOutStep = (double) 125 / (double) ((getTailSize(c) * (getTailFade(c)) / 100));
        for (int i = 0; i < l1.length - 4; ) {
          fade += (fadeOutStep / 2);
          setAlpha(gc, fade);

          gc.drawLine(l1[i], l1[i + 1], l1[i + 2], l1[i + 3]);
          i += 2;
        }

        for (int i = 0; i < l2.length - 4; ) {
          fade += (fadeOutStep / 2);
          setAlpha(gc, fade);
          gc.drawLine(l2[i], l2[i + 1], l2[i + 2], l2[i + 3]);
          i += 2;
        }

      } else {
        long time = System.nanoTime();
        gc.drawPolyline(l1);
        gc.drawPolyline(l2);
        // System.out.println(System.nanoTime() - time + " nanoseconds");
      }

      // Connects the head with the tail
      if (isConnect(c)
          && !isFade(c)
          && chan[c].originalTailSize == TAILSIZE_MAX
          && l1.length > 0
          && l2.length > 0) {
        gc.drawLine(l2[l2.length - 2], l2[l2.length - 1], l1[0], l1[1]);
      }
    }

    // System.out.println(System.currentTimeMillis() - start + " milliseconds for all channels");

  }
예제 #22
0
  private void drawGraph(PaintEvent e) {
    GC gc = e.gc;
    Point size = canvasCurve.getSize();
    int gridSize = 50 - sliderZoom.getSelection();
    Color black = new Color(canvasCurve.getDisplay(), 0, 0, 0);
    Color grey = new Color(canvasCurve.getDisplay(), 235, 235, 235);

    // first, draw the grid
    gc.setForeground(grey);
    for (int i = 0; i < size.x / 2; i += gridSize) {
      gc.drawLine(size.x / 2 - i, 0, size.x / 2 - i, size.y);
      gc.drawLine(size.x / 2 + i, 0, size.x / 2 + i, size.y);
    }
    for (int i = 0; i < size.y / 2; i += gridSize) {
      gc.drawLine(0, size.y / 2 - i, size.x, size.y / 2 - i);
      gc.drawLine(0, size.y / 2 + i, size.x, size.y / 2 + i);
    }

    // Draw the axis
    gc.setForeground(black); // Black
    gc.drawLine(size.x / 2, 0, size.x / 2, size.y);
    gc.drawLine(0, size.y / 2, size.x, size.y / 2);
    int labeljumps = 5;
    int scale = (size.x / 2 / gridSize) - ((size.x / 2 / gridSize) % labeljumps);
    if (scale > 50) labeljumps = 10;
    for (int i = 0; i < size.x / 2; i += gridSize) {
      if ((i / gridSize) % labeljumps == 0) {
        gc.drawLine(size.x / 2 + i, size.y / 2 - 8, size.x / 2 + i, size.y / 2 + 8);
        gc.drawLine(size.x / 2 - i, size.y / 2 - 8, size.x / 2 - i, size.y / 2 + 8);
        gc.drawLine(size.x / 2 - 8, size.y / 2 + i, size.x / 2 + 8, size.y / 2 + i);
        gc.drawLine(size.x / 2 - 8, size.y / 2 - i, size.x / 2 + 8, size.y / 2 - i);

        int label = i / gridSize;
        if (label < 10) {
          if (label != 0) {
            gc.drawText(label + "", size.x / 2 + i - 2, size.y / 2 + 10, true); // $NON-NLS-1$
            gc.drawText(-label + "", size.x / 2 - i - 5, size.y / 2 + 10, true); // $NON-NLS-1$

            gc.drawText(label + "", size.x / 2 + 13, size.y / 2 - i - 7, true); // $NON-NLS-1$
            gc.drawText(-label + "", size.x / 2 + 13, size.y / 2 + i - 7, true); // $NON-NLS-1$
          } else {
            gc.drawText(label + "", size.x / 2 + i + 13, size.y / 2 + 10, true); // $NON-NLS-1$
          }
        } else {
          gc.drawText(label + "", size.x / 2 + i - 6, size.y / 2 + 10, true); // $NON-NLS-1$
          gc.drawText(-label + "", size.x / 2 - i - 10, size.y / 2 + 10, true); // $NON-NLS-1$

          gc.drawText(label + "", size.x / 2 + 13, size.y / 2 - i - 7, true); // $NON-NLS-1$
          gc.drawText(-label + "", size.x / 2 + 13, size.y / 2 + i - 7, true); // $NON-NLS-1$
        }

      } else {
        gc.drawLine(size.x / 2 + i, size.y / 2 - 2, size.x / 2 + i, size.y / 2 + 2);
        gc.drawLine(size.x / 2 - i, size.y / 2 - 2, size.x / 2 - i, size.y / 2 + 2);
        gc.drawLine(size.x / 2 - 2, size.y / 2 + i, size.x / 2 + 2, size.y / 2 + i);
        gc.drawLine(size.x / 2 - 2, size.y / 2 - i, size.x / 2 + 2, size.y / 2 - i);
      }
    }

    if (points != null) {
      gc.setForeground(blue);
      double step = Math.pow((double) gridSize, -1);
      double x1, y1, x2, y2;
      for (int i = 2; i < points.length; i++) {
        if (points[i - 2].y == 0) {
          if (points[i - 1] != null && points[i - 1].y != 0) {
            x1 = (double) points[i - 2].x / 100 / step + size.x / 2;
            y1 = -(double) points[i - 2].y / 100 / step + size.y / 2;
            x2 = (double) points[i - 1].x / 100 / step + size.x / 2;
            y2 = -(double) points[i - 1].y / 100 / step + size.y / 2;
            gc.drawLine((int) x1, (int) y1, (int) x2, (int) y2);
            gc.drawLine((int) x1, (int) y1 + 1, (int) x2, (int) y2 + 1);
            x1 = (double) points[i - 2].x / 100 / step + size.x / 2;
            y1 = -(double) points[i - 2].y / 100 / step + size.y / 2;
            x2 = (double) points[i].x / 100 / step + size.x / 2;
            y2 = -(double) points[i].y / 100 / step + size.y / 2;
            gc.drawLine((int) x1, (int) y1, (int) x2, (int) y2);
            gc.drawLine((int) x1, (int) y1 + 1, (int) x2, (int) y2 + 1);
          } else {
            x1 = (double) points[i - 2].x / 100 / step + size.x / 2;
            y1 = -(double) points[i - 2].y / 100 / step + size.y / 2;
            x2 = (double) points[i - 3].x / 100 / step + size.x / 2;
            y2 = -(double) points[i - 3].y / 100 / step + size.y / 2;
            gc.drawLine((int) x1, (int) y1, (int) x2, (int) y2);
            gc.drawLine((int) x1, (int) y1 + 1, (int) x2, (int) y2 + 1);
            x1 = (double) points[i - 2].x / 100 / step + size.x / 2;
            y1 = -(double) points[i - 2].y / 100 / step + size.y / 2;
            x2 = (double) points[i - 4].x / 100 / step + size.x / 2;
            y2 = -(double) points[i - 4].y / 100 / step + size.y / 2;
            gc.drawLine((int) x1, (int) y1, (int) x2, (int) y2);
            gc.drawLine((int) x1, (int) y1 + 1, (int) x2, (int) y2 + 1);
          }
        } else {
          x1 = (double) points[i - 2].x / 100 / step + size.x / 2;
          y1 = -(double) points[i - 2].y / 100 / step + size.y / 2;
          x2 = (double) points[i].x / 100 / step + size.x / 2;
          y2 = -(double) points[i].y / 100 / step + size.y / 2;
          if ((int) Math.signum(points[i - 2].y + 0.0) == (int) Math.signum(points[i].y + 0.0)) {
            gc.drawLine((int) x1, (int) y1, (int) x2, (int) y2);
            gc.drawLine((int) x1, (int) y1 + 1, (int) x2, (int) y2 + 1);
          }
        }
        if (points[points.length - 1].y == 0) {
          x1 = (double) points[points.length - 1].x / 100 / step + size.x / 2;
          y1 = -(double) points[points.length - 1].y / 100 / step + size.y / 2;
          x2 = (double) points[points.length - 2].x / 100 / step + size.x / 2;
          y2 = -(double) points[points.length - 2].y / 100 / step + size.y / 2;
          gc.drawLine((int) x1, (int) y1, (int) x2, (int) y2);
          gc.drawLine((int) x1, (int) y1 + 1, (int) x2, (int) y2 + 1);
          x1 = (double) points[points.length - 1].x / 100 / step + size.x / 2;
          y1 = -(double) points[points.length - 1].y / 100 / step + size.y / 2;
          x2 = (double) points[points.length - 3].x / 100 / step + size.x / 2;
          y2 = -(double) points[points.length - 3].y / 100 / step + size.y / 2;
          gc.drawLine((int) x1, (int) y1, (int) x2, (int) y2);
          gc.drawLine((int) x1, (int) y1 + 1, (int) x2, (int) y2 + 1);
        }
      }

      if (pointR != null && !pointR.isInfinite()) {
        int rX;
        int rY;
        int lX;
        int lY;
        FpPoint p = pointP;
        FpPoint q = pointQ;
        FpPoint r = pointR;
        if (q != null) {
          if (p.x < q.x && p.x < r.x) { // if pointP is the most left point
            lX = (int) ((double) p.x / 100 / step + size.x / 2);
            lY = (int) ((double) -p.y / 100 / step + size.y / 2);
          } else if (q.x < r.x) { // if pointQ is the most left point
            lX = (int) ((double) q.x / 100 / step + size.x / 2);
            lY = (int) ((double) -q.y / 100 / step + size.y / 2);
          } else { // if pointR is the most left point
            lX = (int) ((double) r.x / 100 / step + size.x / 2);
            lY = (int) ((double) r.y / 100 / step + size.y / 2);
          }

          if (p.x > q.x && p.x > r.x) { // if pointP is the most right point
            rX = (int) ((double) p.x / 100 / step + size.x / 2);
            rY = (int) ((double) -p.y / 100 / step + size.y / 2);
          } else if (q.x > r.x) { // if pointQ is the most right point
            rX = (int) ((double) q.x / 100 / step + size.x / 2);
            rY = (int) ((double) -q.y / 100 / step + size.y / 2);
          } else { // if pointR is the most left point
            rX = (int) ((double) r.x / 100 / step + size.x / 2);
            rY = (int) ((double) r.y / 100 / step + size.y / 2);
          }
        } else {
          if (p.x < r.x) { // if pointP is the most left point
            lX = (int) ((double) p.x / 100 / step + size.x / 2);
            lY = (int) ((double) -p.y / 100 / step + size.y / 2);
            rX = (int) ((double) r.x / 100 / step + size.x / 2);
            rY = (int) ((double) r.y / 100 / step + size.y / 2);
          } else { // if pointR is the most left point
            lX = (int) ((double) r.x / 100 / step + size.x / 2);
            lY = (int) ((double) r.y / 100 / step + size.y / 2);
            rX = (int) ((double) p.x / 100 / step + size.x / 2);
            rY = (int) ((double) -p.y / 100 / step + size.y / 2);
          }
        }

        int startX;
        int endX;
        int startY;
        int endY;

        if ((rX > lX ? rX - lX : lX - rX) > (rY > lY ? rY - lY : lY - rY)) {
          double alfa = (double) (rY - lY) / (double) (rX - lX);
          startX = lX - 30;
          endX = rX + 30;
          startY = lY - (int) (alfa * 30);
          endY = rY + (int) (alfa * 30);
        } else {
          double alfa = (double) (rX - lX) / (double) (rY - lY);
          startX = lX + (lY > rY ? (int) (alfa * 30) : -(int) (alfa * 30));
          endX = rX + (lY > rY ? -(int) (alfa * 30) : (int) (alfa * 30));
          ;
          startY = lY + (lY > rY ? 30 : -30);
          endY = rY + (lY > rY ? -30 : 30);
        }

        if (startY < 0) {
          double alfa = (double) (rX - lX) / (double) (rY - lY);
          startX += (double) (-startY) * alfa;
          startY = 0;
        } else if (startY > size.y) {
          double alfa = (double) (rX - lX) / (double) (rY - lY);
          startX += -(double) (startY - size.y) * alfa;
          startY = size.y;
        }

        if (endY < 0) {
          double alfa = (double) (rX - lX) / (double) (rY - lY);
          endX += (double) (-endY - 1) * alfa;
          endY = -1;
        } else if (endY > size.y) {
          double alfa = (double) (rX - lX) / (double) (rY - lY);
          endX -= (double) (endY - size.y) * alfa + 0.5;
          endY = size.y;
        }

        gc.setForeground(darkPurple);
        gc.setLineWidth(2);
        gc.drawLine(startX, startY, endX, endY);

        startX = (int) ((double) pointR.x / 100 / step + size.x / 2);
        endX = startX;
        if (pointR.y > 0) {
          startY = (int) ((double) pointR.y / 100 / step + size.y / 2) + 30;
          endY = (int) ((double) -pointR.y / 100 / step + size.y / 2) - 30;
        } else {
          startY = (int) ((double) pointR.y / 100 / step + size.y / 2) - 30;
          endY = (int) ((double) -pointR.y / 100 / step + size.y / 2) + 30;
        }
        gc.setForeground(purple);
        gc.drawLine(startX, startY, endX, endY);
        gc.setLineWidth(1);

        double x = (double) pointR.x / 100 / step + size.x / 2;
        double y = (double) pointR.y / 100 / step + size.y / 2;
        gc.setForeground(black);
        gc.setBackground(darkPurple);
        gc.fillOval((int) x - 3, (int) y - 3, 7, 7);
        gc.drawOval((int) x - 3, (int) y - 3, 6, 6);
        gc.setForeground(darkPurple);
        gc.setBackground(white);
        if (y < size.x / 2) {
          gc.drawText("-R", (int) x + 8, (int) y + 4, true); // $NON-NLS-1$
        } else {
          gc.drawText("-R", (int) x + 8, (int) y - 10, true); // $NON-NLS-1$
        }
      } else if (pointP != null) {
        gc.setForeground(darkPurple);
        gc.setLineWidth(2);
        int x = (int) ((double) pointP.x / 100 / step + size.x / 2);
        gc.drawLine(x, 0, x, size.y);
        gc.setLineWidth(1);
      }

      if (pointSelect != null) {
        double x = (double) pointSelect.x / 100 / step + size.x / 2;
        double y = -(double) pointSelect.y / 100 / step + size.y / 2;
        String caption = "Q"; // $NON-NLS-1$
        if (pointP == null) caption = "P"; // $NON-NLS-1$
        markPoint(x, y, caption, black, lightBlue, gc);
      }

      if (pointP != null) {
        double x = (double) pointP.x / 100 / step + size.x / 2;
        double y = -(double) pointP.y / 100 / step + size.y / 2;
        String caption = "P"; // $NON-NLS-1$
        if (pointP.equals(pointQ)) caption = "P=Q"; // $NON-NLS-1$
        if (pointP.equals(pointR)) caption = "P=R"; // $NON-NLS-1$

        markPoint(x, y, caption, red, red, gc);
      }

      if (pointQ != null && !pointQ.equals(pointP)) {
        double x = (double) pointQ.x / 100 / step + size.x / 2;
        double y = -(double) pointQ.y / 100 / step + size.y / 2;
        if (!pointQ.equals(pointP)) markPoint(x, y, "Q", red, red, gc); // $NON-NLS-1$
      }

      if (pointR != null && !pointR.isInfinite()) {
        double x = (double) pointR.x / 100 / step + size.x / 2;
        double y = -(double) pointR.y / 100 / step + size.y / 2;
        markPoint(x, y, "R", purple, purple, gc); // $NON-NLS-1$
      }
    }
  }