示例#1
0
  public void draw(GlowTransform t, int highlight, int hot, Object node, Object colornode) {
    if (cmn.nodraw != 0) return;
    int i;
    boolean draw_text = (Math.abs(increment) > Double.MIN_VALUE);
    int idx;
    int x, y;
    String text;
    int line_length;
    int x_text, y_text;
    int z_height = 0, z_width, z_descent = 0;
    int max_z_width = 0;
    double rotation;
    int drawtype;
    int text_idx = (int) (cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * (text_size + 4) - 4);
    double tsize = cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * (8 + 2 * text_size);
    text_idx = Math.min(text_idx, Glow.DRAW_TYPE_SIZE - 1);

    if (node != null && ((GrowNode) node).line_width != 0)
      idx =
          (int) (cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * ((GrowNode) node).line_width - 1);
    else idx = (int) (cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * line_width - 1);
    idx += hot;

    idx = Math.max(0, idx);
    idx = Math.min(idx, Glow.DRAW_TYPE_SIZE - 1);
    int x1, y1, x2, y2, ll_x, ll_y, ur_x, ur_y;

    if (t == null) {
      x1 = (int) (trf.x(ll.x, ll.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
      y1 = (int) (trf.y(ll.x, ll.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
      x2 = (int) (trf.x(ur.x, ur.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
      y2 = (int) (trf.y(ur.x, ur.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
      rotation = (trf.rot() / 360 - Math.floor(trf.rot() / 360)) * 360;
    } else {
      x1 = (int) (trf.x(t, ll.x, ll.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
      y1 = (int) (trf.y(t, ll.x, ll.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
      x2 = (int) (trf.x(t, ur.x, ur.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
      y2 = (int) (trf.y(t, ur.x, ur.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
      rotation = (trf.rot(t) / 360 - Math.floor(trf.rot(t) / 360)) * 360;
    }

    ll_x = Math.min(x1, x2);
    ur_x = Math.max(x1, x2);
    ll_y = Math.min(y1, y2);
    ur_y = Math.max(y1, y2);
    drawtype =
        GlowColor.get_drawtype(
            draw_type, Glow.eDrawType_LineHighlight, highlight, (GrowNode) colornode, 0, 0);

    if (45 >= rotation || rotation > 315) {
      // Vertical line to the right and values to the left

      cmn.gdraw.line(ur_x, ll_y, ur_x, ur_y, drawtype, idx, 0);

      // Calculate max value text width
      if (draw_text) {
        for (i = 0; i < lines; i++) {
          if (i % valuequotient == 0) {
            text = format_text(format, max_value - i * increment);
            GlowDimension d =
                cmn.gdraw.getTextExtent(
                    text, Math.max(0, text_idx), Glow.eFont_Helvetica, text_drawtype);
            z_width = d.width;
            z_height = d.height;
            z_descent = z_height / 4;
            if (max_z_width < z_width) max_z_width = z_width;
          }
        }
        x_text = ll_x + max_z_width;
        line_length = ur_x - ll_x - max_z_width;
        if (line_length < 3) line_length = 3;
      } else {
        x_text = ll_x;
        line_length = ur_x - ll_x;
      }

      for (i = 0; i < lines; i++) {
        y = (int) (ll_y + (double) (ur_y - ll_y) / (lines - 1) * i);
        if (i % longquotient == 0) cmn.gdraw.line(ur_x - line_length, y, ur_x, y, drawtype, idx, 0);
        else cmn.gdraw.line(ur_x - (int) (2.0 / 3 * line_length), y, ur_x, y, drawtype, idx, 0);
        if (draw_text) {
          text = format_text(format, max_value - i * increment);

          if (text_idx >= 0 && max_z_width < ur_x - ll_x && i % valuequotient == 0) {
            if (i == lines - 1) y_text = y;
            else if (i == 0) y_text = y + z_height - z_descent - 3;
            else y_text = y + (z_height - z_descent) / 2;
            cmn.gdraw.text(
                ll_x,
                y_text,
                text,
                text_drawtype,
                text_color_drawtype,
                text_idx,
                highlight,
                0,
                Glow.eFont_Helvetica,
                tsize,
                0);
          }
        }
      }
    } else if (45 < rotation && rotation <= 135) {
      // Horizontal line at bottom and values to the top

      cmn.gdraw.line(ll_x, ur_y, ur_x, ur_y, drawtype, idx, 0);

      // Calculate max value text height
      if (draw_text) {
        GlowDimension d =
            cmn.gdraw.getTextExtent(
                "0", Math.max(0, text_idx), Glow.eFont_Helvetica, text_drawtype);

        z_width = d.width;
        z_height = d.height;
        z_descent = z_height / 4;
        line_length = ur_y - ll_y - z_height;
        if (line_length < 3) line_length = 3;
      } else {
        line_length = ur_y - ll_y;
      }

      for (i = 0; i < lines; i++) {
        x = (int) (ll_x + (double) (ur_x - ll_x) / (lines - 1) * (lines - 1 - i));
        if (i % longquotient == 0) cmn.gdraw.line(x, ur_y - line_length, x, ur_y, drawtype, idx, 0);
        else cmn.gdraw.line(x, ur_y - (int) (2.0 / 3 * line_length), x, ur_y, drawtype, idx, 0);

        if (draw_text && i % valuequotient == 0) {
          text = format_text(format, max_value - i * increment);
          GlowDimension d =
              cmn.gdraw.getTextExtent(
                  text, Math.max(0, text_idx), Glow.eFont_Helvetica, text_drawtype);
          z_width = d.width;
          z_height = d.height;
          z_descent = z_height / 4;

          if (text_idx >= 0 && z_height < ur_y - ll_y) {
            if (i == lines - 1) x_text = x;
            else if (i == 0) x_text = x - z_width;
            else x_text = x - (z_width) / 2;
            cmn.gdraw.text(
                x_text,
                ll_y + z_height - z_descent,
                text,
                text_drawtype,
                text_color_drawtype,
                text_idx,
                highlight,
                0,
                Glow.eFont_Helvetica,
                tsize,
                0);
          }
        }
      }
    } else if (135 < rotation && rotation <= 225) {
      // Vertical line to the left and values to the right

      cmn.gdraw.line(ll_x, ll_y, ll_x, ur_y, drawtype, idx, 0);

      // Calculate max value text width
      if (draw_text) {
        for (i = 0; i < lines; i++) {
          if (i % valuequotient == 0) {
            text = format_text(format, max_value - i * increment);
            GlowDimension d =
                cmn.gdraw.getTextExtent(
                    text, Math.max(0, text_idx), Glow.eFont_Helvetica, text_drawtype);
            z_width = d.width;
            z_height = d.height;
            z_descent = z_height / 4;
            if (max_z_width < z_width) max_z_width = z_width;
          }
        }
        x_text = ur_x - max_z_width;
        line_length = ur_x - ll_x - max_z_width;
        if (line_length < 3) line_length = 3;
      } else {
        x_text = ur_x;
        line_length = ur_x - ll_x;
      }

      for (i = 0; i < lines; i++) {
        y = (int) (ll_y + (double) (ur_y - ll_y) / (lines - 1) * (lines - 1 - i));
        if (i % longquotient == 0) cmn.gdraw.line(ll_x, y, ll_x + line_length, y, drawtype, idx, 0);
        else cmn.gdraw.line(ll_x, y, ll_x + (int) (2.0 / 3 * line_length), y, drawtype, idx, 0);
        text = format_text(format, max_value - i * increment);

        if (draw_text && text_idx >= 0 && max_z_width < ur_x - ll_x && i % valuequotient == 0) {
          if (i == lines - 1) y_text = y + z_height - z_descent - 3;
          else if (i == 0) y_text = y;
          else y_text = y + (z_height - z_descent) / 2;
          cmn.gdraw.text(
              x_text,
              y_text,
              text,
              text_drawtype,
              text_color_drawtype,
              text_idx,
              highlight,
              0,
              Glow.eFont_Helvetica,
              tsize,
              0);
        }
      }
    } else { // if ( 225 < rotation && rotation <= 315)
      // Horizontal line at top and values at the bottom

      cmn.gdraw.line(ll_x, ll_y, ur_x, ll_y, drawtype, idx, 0);

      // Calculate max value text height
      if (draw_text) {
        GlowDimension d =
            cmn.gdraw.getTextExtent(
                "0", Math.max(0, text_idx), Glow.eFont_Helvetica, text_drawtype);

        z_width = d.width;
        z_height = d.height;
        z_descent = z_height / 4;
        line_length = ur_y - ll_y - (z_height - z_descent);
        if (line_length < 3) line_length = 3;
      } else {
        line_length = ur_y - ll_y;
      }

      for (i = 0; i < lines; i++) {
        x = (int) (ll_x + (double) (ur_x - ll_x) / (lines - 1) * i);
        if (i % longquotient == 0) cmn.gdraw.line(x, ll_y, x, ll_y + line_length, drawtype, idx, 0);
        else cmn.gdraw.line(x, ll_y, x, ll_y + (int) (2.0 / 3 * line_length), drawtype, idx, 0);
        if (draw_text && i % valuequotient == 0) {
          text = format_text(format, max_value - i * increment);
          GlowDimension d =
              cmn.gdraw.getTextExtent(
                  text, Math.max(0, text_idx), Glow.eFont_Helvetica, text_drawtype);
          z_width = d.width;
          z_height = d.height;
          z_descent = z_height / 4;

          if (text_idx >= 0 && z_height - z_descent < ur_y - ll_y) {
            if (i == lines - 1) x_text = x - z_width;
            else if (i == 0) x_text = x;
            else x_text = x - (z_width) / 2;
            cmn.gdraw.text(
                x_text,
                ur_y,
                text,
                text_drawtype,
                text_color_drawtype,
                text_idx,
                highlight,
                0,
                Glow.eFont_Helvetica,
                tsize,
                0);
          }
        }
      }
    }
  }
示例#2
0
  public void draw(GlowTransform t, int highlight, int hot, Object node, Object colornode) {
    if (cmn.nodraw != 0) return;

    int idx;
    int drawtype;
    double rotation;
    int grad = gradient;
    if (gradient == Glow.eGradient_No
        && (node != null && ((GrowNode) node).gradient != Glow.eGradient_No)
        && disable_gradient == 0) grad = ((GrowNode) node).gradient;

    int bar_border_idx =
        (int) (cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * bar_borderwidth - 1);
    bar_border_idx = Math.min(Glow.DRAW_TYPE_SIZE - 1, Math.max(0, bar_border_idx));

    if (node != null && ((GrowNode) node).line_width != 0)
      idx =
          (int) (cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * ((GrowNode) node).line_width - 1);
    else idx = (int) (cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * line_width - 1);
    idx += hot;

    idx = Math.max(0, idx);
    idx = Math.min(idx, Glow.DRAW_TYPE_SIZE - 1);
    int x1, y1, x2, y2, ll_x, ll_y, ur_x, ur_y;

    if (t == null) {
      x1 = (int) (trf.x(ll.x, ll.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
      y1 = (int) (trf.y(ll.x, ll.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
      x2 = (int) (trf.x(ur.x, ur.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
      y2 = (int) (trf.y(ur.x, ur.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
    } else {
      x1 = (int) (trf.x(t, ll.x, ll.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
      y1 = (int) (trf.y(t, ll.x, ll.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
      x2 = (int) (trf.x(t, ur.x, ur.y) * cmn.mw.zoom_factor_x) - cmn.mw.offset_x;
      y2 = (int) (trf.y(t, ur.x, ur.y) * cmn.mw.zoom_factor_y) - cmn.mw.offset_y;
    }

    ll_x = Math.min(x1, x2);
    ur_x = Math.max(x1, x2);
    ll_y = Math.min(y1, y2);
    ur_y = Math.max(y1, y2);
    if (fill != 0) {
      drawtype =
          GlowColor.get_drawtype(
              fill_drawtype, Glow.eDrawType_FillHighlight, highlight, colornode, 1, 0);

      if (grad == Glow.eGradient_No)
        cmn.gdraw.fill_rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype);
      else {
        int f1, f2;

        if (t != null) rotation = trf.rot(t);
        else rotation = trf.rot();
        if (gradient_contrast >= 0) {
          f2 = GlowColor.shift_drawtype(drawtype, -gradient_contrast / 2, null);
          f1 =
              GlowColor.shift_drawtype(
                  drawtype, (int) ((float) (gradient_contrast) / 2 + 0.6), null);
        } else {
          f2 =
              GlowColor.shift_drawtype(
                  drawtype, -(int) ((float) (gradient_contrast) / 2 - 0.6), null);
          f1 = GlowColor.shift_drawtype(drawtype, gradient_contrast / 2, null);
        }
        cmn.gdraw.gradient_fill_rect(
            ll_x,
            ll_y,
            ur_x - ll_x,
            ur_y - ll_y,
            drawtype,
            f1,
            f2,
            cmn.gdraw.gradient_rotate(rotation, grad));
      }
    }
    drawtype =
        GlowColor.get_drawtype(
            draw_type, Glow.eDrawType_LineHighlight, highlight, (GrowNode) colornode, 0, 0);

    if (max_value != min_value) {
      int x0, y0, width, height, l_x0, l_y0, l_x1, l_y1;

      if (t != null) rotation = (trf.rot(t) / 360 - Math.floor(trf.rot(t) / 360)) * 360;
      else rotation = (trf.rot() / 360 - Math.floor(trf.rot() / 360)) * 360;
      if (45 >= rotation || rotation > 315) {
        height = (int) ((bar_value - min_value) / (max_value - min_value) * (ur_y - ll_y));
        height = Math.max(0, Math.min(height, ur_y - ll_y));
        width = ur_x - ll_x;
        x0 = ll_x;
        y0 = ur_y - height;
        l_x0 = ll_x;
        l_y0 = ur_y - height;
        l_x1 = ur_x;
        l_y1 = ur_y - height;
      } else if (45 < rotation && rotation <= 135) {
        width = (int) ((bar_value - min_value) / (max_value - min_value) * (ur_x - ll_x));
        width = Math.max(0, Math.min(width, ur_x - ll_x));
        height = ur_y - ll_y;
        x0 = ll_x;
        y0 = ll_y;
        l_x0 = ll_x + width;
        l_y0 = ll_y;
        l_x1 = ll_x + width;
        l_y1 = ur_y;
      } else if (135 < rotation && rotation <= 225) {
        height = (int) ((bar_value - min_value) / (max_value - min_value) * (ur_y - ll_y));
        height = Math.max(0, Math.min(height, ur_y - ll_y));
        width = ur_x - ll_x;
        x0 = ll_x;
        y0 = ll_y;
        l_x0 = ll_x;
        l_y0 = ll_y + height;
        l_x1 = ur_x;
        l_y1 = ll_y + height;
      } else { // if ( 225 < rotation && rotation <= 315)
        width = (int) ((bar_value - min_value) / (max_value - min_value) * (ur_x - ll_x));
        width = Math.max(0, Math.min(width, ur_x - ll_x));
        height = ur_y - ll_y;
        x0 = ur_x - width;
        y0 = ll_y;
        l_x0 = ur_x - width;
        l_y0 = ll_y;
        l_x1 = ur_x - width;
        l_y1 = ur_y;
      }

      int dt = drawtype;
      if (bar_drawtype != Glow.eDrawType_Inherit) dt = bar_drawtype;

      if (grad == Glow.eGradient_No) cmn.gdraw.fill_rect(x0, y0, width, height, dt);
      else {
        int f1, f2;

        if (t != null) rotation = trf.rot(t);
        else rotation = trf.rot();
        if (gradient_contrast >= 0) {
          f2 = GlowColor.shift_drawtype(dt, -gradient_contrast / 2, null);
          f1 = GlowColor.shift_drawtype(dt, (int) ((float) (gradient_contrast) / 2 + 0.6), null);
        } else {
          f2 = GlowColor.shift_drawtype(dt, -(int) ((float) (gradient_contrast) / 2 - 0.6), null);
          f1 = GlowColor.shift_drawtype(dt, gradient_contrast / 2, null);
        }
        cmn.gdraw.gradient_fill_rect(
            x0, y0, width, height, dt, f1, f2, cmn.gdraw.gradient_rotate(rotation, grad));
      }

      dt = drawtype;
      if (bar_bordercolor != Glow.eDrawType_Inherit) dt = bar_bordercolor;
      cmn.gdraw.line(l_x0, l_y0, l_x1, l_y1, dt, bar_border_idx, 0);
    }

    if (border != 0) {
      cmn.gdraw.rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype, idx, 0);
    }
  }
示例#3
0
  public void draw_shadow(int border, int shadow, int highlight, int hot) {
    if (cmn.nodraw != 0) return;

    int ll_x, ll_y, ur_x, ur_y;
    ll_x = (int) (ll.x * cmn.mw.zoom_factor_x + 0.5) - cmn.mw.offset_x;
    ll_y = (int) (ll.y * cmn.mw.zoom_factor_y + 0.5) - cmn.mw.offset_y;
    ur_x = (int) (ur.x * cmn.mw.zoom_factor_x + 0.5) - cmn.mw.offset_x;
    ur_y = (int) (ur.y * cmn.mw.zoom_factor_y + 0.5) - cmn.mw.offset_y;
    int idx = (int) (cmn.mw.zoom_factor_y / cmn.mw.base_zoom_factor * line_width - 1);
    idx += hot;
    idx = Math.max(0, idx);
    idx = Math.min(idx, Glow.DRAW_TYPE_SIZE - 1);
    int ish = 1;
    int offs = border;

    if (shadow != 0 && idx > 2) {
      if (angle1 == 0) {
        cmn.gdraw.arc(
            ll_x + idx / 2 - idx + offs,
            ll_y + idx / 2 - idx + offs,
            ur_x - ll_x + idx - offs * 2,
            ur_y - ll_y + idx - offs * 2,
            angle1 + 45,
            angle2 - 45,
            GlowColor.shift_drawtype(draw_type, -2, null),
            ish - 1,
            highlight);
        cmn.gdraw.arc(
            ll_x + idx / 2 - idx + offs,
            ll_y + idx / 2 - idx + offs,
            ur_x - ll_x + idx - offs * 2,
            ur_y - ll_y + idx - offs * 2,
            angle1,
            angle2 - 45,
            GlowColor.shift_drawtype(draw_type, 2, null),
            ish - 1,
            highlight);
        cmn.gdraw.arc(
            ll_x + idx / 2 - offs,
            ll_y + idx / 2 - offs,
            Math.max(0, ur_x - ll_x - idx + offs * 2),
            Math.max(0, ur_y - ll_y - idx + offs * 2),
            angle1 + 45,
            angle2 - 45,
            GlowColor.shift_drawtype(draw_type, 2, null),
            ish - 1,
            highlight);
        cmn.gdraw.arc(
            ll_x + idx / 2 - offs,
            ll_y + idx / 2 - offs,
            Math.max(0, ur_x - ll_x - idx + offs * 2),
            Math.max(0, ur_y - ll_y - idx + offs * 2),
            angle1,
            angle2 - 45,
            GlowColor.shift_drawtype(draw_type, -2, null),
            ish - 1,
            highlight);
      } else if (angle1 == 90) {
        cmn.gdraw.arc(
            ll_x + idx / 2 - idx + offs,
            ll_y + idx / 2 - idx + offs,
            ur_x - ll_x + idx - offs * 2,
            ur_y - ll_y + idx - offs * 2,
            angle1,
            angle2,
            GlowColor.shift_drawtype(draw_type, -2, null),
            ish - 1,
            highlight);
        cmn.gdraw.arc(
            ll_x + idx / 2 - offs,
            ll_y + idx / 2 - offs,
            Math.max(0, ur_x - ll_x - idx + offs * 2),
            Math.max(0, ur_y - ll_y - idx + offs * 2),
            angle1,
            angle2,
            GlowColor.shift_drawtype(draw_type, 2, null),
            ish - 1,
            highlight);
      } else if (angle1 == 180) {
        cmn.gdraw.arc(
            ll_x + idx / 2 - idx + offs,
            ll_y + idx / 2 - idx + offs,
            ur_x - ll_x + idx - offs * 2,
            ur_y - ll_y + idx - offs * 2,
            angle1 + 45,
            angle2 - 45,
            GlowColor.shift_drawtype(draw_type, 2, null),
            ish - 1,
            highlight);
        cmn.gdraw.arc(
            ll_x + idx / 2 - idx + offs,
            ll_y + idx / 2 - idx + offs,
            ur_x - ll_x + idx - offs * 2,
            ur_y - ll_y + idx - offs * 2,
            angle1,
            angle2 - 45,
            GlowColor.shift_drawtype(draw_type, -2, null),
            ish - 1,
            highlight);
        cmn.gdraw.arc(
            ll_x + idx / 2 - offs,
            ll_y + idx / 2 - offs,
            Math.max(0, ur_x - ll_x - idx + offs * 2),
            Math.max(0, ur_y - ll_y - idx + offs * 2),
            angle1 + 45,
            angle2 - 45,
            GlowColor.shift_drawtype(draw_type, -2, null),
            ish - 1,
            highlight);
        cmn.gdraw.arc(
            ll_x + idx / 2 - offs,
            ll_y + idx / 2 - offs,
            Math.max(0, ur_x - ll_x - idx + offs * 2),
            Math.max(0, ur_y - ll_y - idx + offs * 2),
            angle1,
            angle2 - 45,
            GlowColor.shift_drawtype(draw_type, 2, null),
            ish - 1,
            highlight);
      } else if (angle1 == 270) {
        cmn.gdraw.arc(
            ll_x + idx / 2 - idx + offs,
            ll_y + idx / 2 - idx + offs,
            ur_x - ll_x + idx - offs * 2,
            ur_y - ll_y + idx - offs * 2,
            angle1,
            angle2,
            GlowColor.shift_drawtype(draw_type, 2, null),
            ish - 1,
            highlight);
        cmn.gdraw.arc(
            ll_x + idx / 2 - offs,
            ll_y + idx / 2 - offs,
            Math.max(0, ur_x - ll_x - idx + offs * 2),
            Math.max(0, ur_y - ll_y - idx + offs * 2),
            angle1,
            angle2,
            GlowColor.shift_drawtype(draw_type, -2, null),
            ish - 1,
            highlight);
      }
    }
    if (border != 0) {
      cmn.gdraw.arc(
          ll_x + idx / 2 - idx,
          ll_y + idx / 2 - idx,
          ur_x - ll_x + idx,
          ur_y - ll_y + idx,
          angle1,
          angle2,
          Glow.eDrawType_Line,
          0,
          highlight);
      if (idx > 0)
        cmn.gdraw.arc(
            ll_x + idx / 2,
            ll_y + idx / 2,
            Math.max(0, ur_x - ll_x - idx),
            Math.max(0, ur_y - ll_y - idx),
            angle1,
            angle2,
            Glow.eDrawType_Line,
            0,
            highlight);
    }
  }