示例#1
0
  /**
   * Returns the state indicating if there is a space to draw tick label.
   *
   * @param previousPosition the previously drawn tick label position.
   * @param tickLabelPosition the tick label position.
   * @param tickLabel the tick label text
   * @return true if there is a space to draw tick label
   */
  private boolean hasSpaceToDraw(int previousPosition, int tickLabelPosition, String tickLabel) {
    Point p = Util.getExtentInGC(axis.getTick().getFont(), tickLabel);
    int interval = tickLabelPosition - previousPosition;
    int textLength = axis.isHorizontalAxis() ? p.x : p.y;

    return interval > textLength;
  }
示例#2
0
  /*
   * @see PaintListener#paintControl(PaintEvent)
   */
  public void paintControl(PaintEvent e) {
    if (!axis.getTick().isVisible()) {
      return;
    }

    e.gc.setBackground(chart.getBackground());
    e.gc.setForeground(getForeground());
    if (axis.isHorizontalAxis()) {
      drawXTick(e.gc);
    } else {
      drawYTick(e.gc);
    }
  }
示例#3
0
 /** Updates the tick labels layout. */
 protected void updateLayoutData() {
   widthHint = SWT.DEFAULT;
   heightHint = SWT.DEFAULT;
   if (!axis.getTick().isVisible()) {
     widthHint = 0;
     heightHint = 0;
   } else {
     if (axis.isHorizontalAxis()) {
       double angle = axis.getTick().getTickLabelAngle();
       heightHint =
           Axis.MARGIN
               + (int)
                   (tickLabelMaxLength * Math.sin(Math.toRadians(angle))
                       + Util.getExtentInGC(getFont(), "dummy").y
                           * Math.cos(Math.toRadians(angle)));
     } else {
       widthHint = tickLabelMaxLength + Axis.MARGIN;
     }
   }
 }