Пример #1
0
  public void paint(Graphics g) {
    super.paint(g);

    Dimension size = getSize();
    double w = size.getWidth() - 50;
    double h = size.getHeight() + 20;

    try {
      readFile();
    } catch (IOException e) {
      System.err.println("IO issue");
    }

    barWidth = ((int) (w / numBars)) - 20;
    pos = 5;

    int xPos[] = {pos, pos, pos, pos};
    int yPos[] = {pos, pos, pos, pos};

    maxVal = maxValue(values);
    double barH, ratio;

    for (int i = 0; i < numBars - 1; i++) {
      Color col[] = new Color[numBars];
      for (int j = 0; j < numBars - 1; j++) {
        col[j] = new Color((int) (Math.random() * 0x1000000));
      }

      ratio = (double) values[i] / (double) maxVal;
      barH = ((h) * ratio) - 10;

      xPos[0] = pos;
      xPos[2] = pos + barWidth;
      xPos[1] = xPos[0];
      xPos[3] = xPos[2];
      yPos[0] = (int) h;
      yPos[1] = (int) barH;
      yPos[2] = yPos[1];
      yPos[3] = yPos[0];

      System.out.println(
          "xPos:" + xPos[1] + " yPos:" + yPos[0] + " h:" + h + " barH:" + barH + " ratio:" + ratio
              + " pos:" + pos);

      int stringPtsY[] = {
        ((i + 1) * 20) + 180, ((i + 1) * 20) + 200, ((i + 1) * 20) + 200, ((i + 1) * 20) + 180
      };
      int stringPtsX[] = {600, 600, 580, 580};

      g.setColor(col[i]);
      g.fillPolygon(xPos, yPos, xPos.length);

      g.fillPolygon(stringPtsX, stringPtsY, 4);
      g.setColor(Color.black);
      g.drawString(labels[i], 610, ((i + 1) * 20) + 195);
      pos = pos + barWidth + 10;
    }
  }
Пример #2
0
  private void draw_horizon(int rad, Point center, int[] angles) {
    // Draw an arc
    int arc_angle =
        ((angles[0] > angles[1]) ? (360 - angles[0]) + angles[1] : (angles[1] - angles[0]));

    Polygon remainder = new Polygon();

    offgraphics_.setColor(GREEN);
    offgraphics_.fillArc(center.x - rad, center.y - rad, 2 * rad, 2 * rad, angles[0], arc_angle);

    if (pitch_ != 0) {
      if ((pitch_ > 0 && Math.abs(roll_) < 90) || (pitch_ < 0 && Math.abs(roll_) >= 90))
        offgraphics_.setColor(BLUE);

      int cover_angle = (angles[0] + arc_angle / 2 + ((arc_angle < 180) ? 180 : 0)) % 360;

      // System.out.println (points[0] + " " + points[1]);

      // System.out.println (accepted_point);

      remainder.addPoint(
          center.x + polar_to_rect_x(rad, cover_angle),
          center.y - polar_to_rect_y(rad, cover_angle));
      remainder.addPoint(
          center.x + polar_to_rect_x(rad, angles[0]), center.y - polar_to_rect_y(rad, angles[0]));
      remainder.addPoint(
          center.x + polar_to_rect_x(rad, angles[1]), center.y - polar_to_rect_y(rad, angles[1]));
      offgraphics_.fillPolygon(remainder);
      // offgraphics_.setColor (getBackground ());
      // offgraphics_.drawPolygon (remainder);
    }
  }
Пример #3
0
 public static void drawArrow(Graphics g, int x1, int y1, int x2, int y2, int lineWidth) {
   // Draw line using user defined drawline() which can specify line width
   drawLine(g, x1, y1, x2, y2, lineWidth);
   // Calculate x-y values for arrow head
   calcValues(x1, y1, x2, y2);
   g.fillPolygon(xValues, yValues, 3);
 }
Пример #4
0
    /**
     * Draws this polygon on the screen. If any of the points are not visible (ie. behind the
     * camera) then do not attempt to draw this polygon.
     */
    void draw(Graphics g) {
      if (n <= 1) return;
      g.setColor(getColor());

      for (int i = 0; i < n; i++) {
        if (!visibles[points[i] / 3]) return;
        xs[i] = (int) ps_[points[i] + 1];
        ys[i] = (int) ps_[points[i] + 2];
      }

      g.fillPolygon(xs, ys, xs.length);
    }
Пример #5
0
  public void drawVertArrow(Graphics g, int x1, int y1, int x2, int y2) {
    g.drawLine(x1, y1, x2, y2);

    int[] axPoints = new int[3];
    int[] ayPoints = new int[3];

    axPoints[0] = x2;
    ayPoints[0] = y2;
    axPoints[1] = x2 - 1;
    ayPoints[1] = y2 - 2;
    axPoints[2] = x2 + 2;
    ayPoints[2] = y2 - 2;

    g.fillPolygon(axPoints, ayPoints, 3);
  }
Пример #6
0
 public static void drawLine(Graphics g, int x1, int y1, int x2, int y2, int lineWidth) {
   if (lineWidth == 1) g.drawLine(x1, y1, x2, y2);
   else {
     double angle;
     double halfWidth = ((double) lineWidth) / 2.0;
     double deltaX = (double) (x2 - x1);
     double deltaY = (double) (y2 - y1);
     if (x1 == x2) angle = Math.PI;
     else angle = Math.atan(deltaY / deltaX) + Math.PI / 2;
     int xOffset = (int) (halfWidth * Math.cos(angle));
     int yOffset = (int) (halfWidth * Math.sin(angle));
     int[] xCorners = {x1 - xOffset, x2 - xOffset + 1, x2 + xOffset + 1, x1 + xOffset};
     int[] yCorners = {y1 - yOffset, y2 - yOffset, y2 + yOffset + 1, y1 + yOffset + 1};
     g.fillPolygon(xCorners, yCorners, 4);
   }
 }
Пример #7
0
  public void drawHexBoard(Graphics g) {
    g.setColor(Color.BLACK);
    double mx1, mx2, mx3, mx4, my1, my2, my3, my4; // Margin attributes

    mx1 = data.a[0][0].x - bst.scale * (r3 / 2 + 0.5);
    mx2 = data.a[0][bst.getOrder() - 1].x + bst.scale * (r3 + 1);
    mx3 = data.a[bst.getOrder() - 1][0].x - bst.scale * (r3 + 1);
    mx4 = data.a[bst.getOrder() - 1][bst.getOrder() - 1].x + bst.scale * (r3 / 2 + 0.5);
    my1 = data.a[0][0].y - bst.scale * 1.5;
    my2 = data.a[0][bst.getOrder() - 1].y - bst.scale * 1.5;
    my3 = data.a[bst.getOrder() - 1][0].y + bst.scale * 1.5;
    my4 = data.a[bst.getOrder() - 1][bst.getOrder() - 1].y + bst.scale * 1.5;

    g.fillPolygon(
        getIntArray(new double[] {mx1, mx2, mx4, mx3}),
        getIntArray(new double[] {my1, my2, my4, my3}),
        4);
    switch (gst.theme) {
      case 0:
        g.setColor(Color.RED);
        break;
      case 1:
        g.setColor(Color.BLACK);
        break;
      case 2:
        g.setColor(Color.YELLOW);
        break;
    }
    g.fillPolygon(
        getIntArray(new double[] {mx1 + 1, mx3 + 1, (mx2 + mx3) / 2}),
        getIntArray(new double[] {my1 + 1, my3 - 1, (my2 + my3) / 2}),
        3);
    g.fillPolygon(
        getIntArray(new double[] {mx2 - 1, mx4 - 1, (mx2 + mx3) / 2}),
        getIntArray(new double[] {my2 + 1, my4 - 1, (my2 + my3) / 2}),
        3);
    switch (gst.theme) {
      case 0:
        g.setColor(Color.BLUE);
        break;
      case 1:
        g.setColor(new Color(1, 175, 1));
        break;
      case 2:
        g.setColor(Color.lightGray);
    }
    g.fillPolygon(
        getIntArray(new double[] {mx1 + 1, mx2 - 1, (mx2 + mx3) / 2}),
        getIntArray(new double[] {my1 + 1, my2 + 1, (my2 + my3) / 2}),
        3);
    g.fillPolygon(
        getIntArray(new double[] {mx3 + 1, mx4 - 1, (mx2 + mx3) / 2}),
        getIntArray(new double[] {my3 - 1, my4 - 1, (my2 + my3) / 2}),
        3);

    for (int i = 0; i < bst.getOrder(); i++)
      for (int j = 0; j < bst.getOrder(); j++) {
        g.setColor(Color.BLACK);
        g.fillPolygon(getIntArray(data.a[i][j].polyX), getIntArray(data.a[i][j].polyY), 6);
        g.setColor(Color.WHITE);
        g.fillPolygon(getIntArray(data.a[i][j].polyXIn()), getIntArray(data.a[i][j].polyYIn()), 6);
        g.setColor(Color.BLACK);
        double x = data.a[i][j].x, y = data.a[i][j].y;
        g.drawLine((int) x, (int) y, (int) x + 1, (int) y + 1);
        circle(g, x, y, data.a[i][j].getState());
      }
    if (ptm == null) return;
    if (ptm.length == 0) return;
    for (int i = 0; i < ptm.length; i++) {
      g.setColor(Color.YELLOW);
      g.fillPolygon(
          getIntArray(data.a[ptm[i][0]][ptm[i][1]].polyXIn()),
          getIntArray(data.a[ptm[i][0]][ptm[i][1]].polyYIn()),
          6);
      g.setColor(Color.BLACK);
      double x = data.a[ptm[i][0]][ptm[i][1]].x, y = data.a[ptm[i][0]][ptm[i][1]].y;
      circle(g, x, y, data.a[ptm[i][0]][ptm[i][1]].getState());
    }
  }
Пример #8
0
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    int width = getWidth() - rightMargin - leftMargin - 10;
    int height = getHeight() - topMargin - bottomMargin;
    if (width <= 0 || height <= 0) {
      // not enough room to paint anything
      return;
    }

    Color oldColor = g.getColor();
    Font oldFont = g.getFont();
    Color fg = getForeground();
    Color bg = getBackground();
    boolean bgIsLight = (bg.getRed() > 200 && bg.getGreen() > 200 && bg.getBlue() > 200);

    ((Graphics2D) g)
        .setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    if (smallFont == null) {
      smallFont = oldFont.deriveFont(9.0F);
    }

    r.x = leftMargin - 5;
    r.y = topMargin - 8;
    r.width = getWidth() - leftMargin - rightMargin;
    r.height = getHeight() - topMargin - bottomMargin + 16;

    if (border == null) {
      // By setting colors here, we avoid recalculating them
      // over and over.
      border =
          new BevelBorder(
              BevelBorder.LOWERED,
              getBackground().brighter().brighter(),
              getBackground().brighter(),
              getBackground().darker().darker(),
              getBackground().darker());
    }

    border.paintBorder(this, g, r.x, r.y, r.width, r.height);

    // Fill background color
    g.setColor(bgColor);
    g.fillRect(r.x + 2, r.y + 2, r.width - 4, r.height - 4);
    g.setColor(oldColor);

    long tMin = Long.MAX_VALUE;
    long tMax = Long.MIN_VALUE;
    long vMin = Long.MAX_VALUE;
    long vMax = 1;

    int w = getWidth() - rightMargin - leftMargin - 10;
    int h = getHeight() - topMargin - bottomMargin;

    if (times.size > 1) {
      tMin = Math.min(tMin, times.time(0));
      tMax = Math.max(tMax, times.time(times.size - 1));
    }
    long viewRangeMS;
    if (viewRange > 0) {
      viewRangeMS = viewRange * MINUTE;
    } else {
      // Display full time range, but no less than a minute
      viewRangeMS = Math.max(tMax - tMin, 1 * MINUTE);
    }

    // Calculate min/max values
    for (Sequence seq : seqs) {
      if (seq.size > 0) {
        for (int i = 0; i < seq.size; i++) {
          if (seq.size == 1 || times.time(i) >= tMax - viewRangeMS) {
            long val = seq.value(i);
            if (val > Long.MIN_VALUE) {
              vMax = Math.max(vMax, val);
              vMin = Math.min(vMin, val);
            }
          }
        }
      } else {
        vMin = 0L;
      }
      if (unit == Unit.BYTES || !seq.isPlotted) {
        // We'll scale only to the first (main) value set.
        // TODO: Use a separate property for this.
        break;
      }
    }

    // Normalize scale
    vMax = normalizeMax(vMax);
    if (vMin > 0) {
      if (vMax / vMin > 4) {
        vMin = 0;
      } else {
        vMin = normalizeMin(vMin);
      }
    }

    g.setColor(fg);

    // Axes
    // Draw vertical axis
    int x = leftMargin - 18;
    int y = topMargin;
    FontMetrics fm = g.getFontMetrics();

    g.drawLine(x, y, x, y + h);

    int n = 5;
    if (("" + vMax).startsWith("2")) {
      n = 4;
    } else if (("" + vMax).startsWith("3")) {
      n = 6;
    } else if (("" + vMax).startsWith("4")) {
      n = 4;
    } else if (("" + vMax).startsWith("6")) {
      n = 6;
    } else if (("" + vMax).startsWith("7")) {
      n = 7;
    } else if (("" + vMax).startsWith("8")) {
      n = 8;
    } else if (("" + vMax).startsWith("9")) {
      n = 3;
    }

    // Ticks
    ArrayList<Long> tickValues = new ArrayList<Long>();
    tickValues.add(vMin);
    for (int i = 0; i < n; i++) {
      long v = i * vMax / n;
      if (v > vMin) {
        tickValues.add(v);
      }
    }
    tickValues.add(vMax);
    n = tickValues.size();

    String[] tickStrings = new String[n];
    for (int i = 0; i < n; i++) {
      long v = tickValues.get(i);
      tickStrings[i] = getSizeString(v, vMax);
    }

    // Trim trailing decimal zeroes.
    if (decimals > 0) {
      boolean trimLast = true;
      boolean removedDecimalPoint = false;
      do {
        for (String str : tickStrings) {
          if (!(str.endsWith("0") || str.endsWith("."))) {
            trimLast = false;
            break;
          }
        }
        if (trimLast) {
          if (tickStrings[0].endsWith(".")) {
            removedDecimalPoint = true;
          }
          for (int i = 0; i < n; i++) {
            String str = tickStrings[i];
            tickStrings[i] = str.substring(0, str.length() - 1);
          }
        }
      } while (trimLast && !removedDecimalPoint);
    }

    // Draw ticks
    int lastY = Integer.MAX_VALUE;
    for (int i = 0; i < n; i++) {
      long v = tickValues.get(i);
      y = topMargin + h - (int) (h * (v - vMin) / (vMax - vMin));
      g.drawLine(x - 2, y, x + 2, y);
      String s = tickStrings[i];
      if (unit == Unit.PERCENT) {
        s += "%";
      }
      int sx = x - 6 - fm.stringWidth(s);
      if (y < lastY - 13) {
        if (checkLeftMargin(sx)) {
          // Wait for next repaint
          return;
        }
        g.drawString(s, sx, y + 4);
      }
      // Draw horizontal grid line
      g.setColor(Color.lightGray);
      g.drawLine(r.x + 4, y, r.x + r.width - 4, y);
      g.setColor(fg);
      lastY = y;
    }

    // Draw horizontal axis
    x = leftMargin;
    y = topMargin + h + 15;
    g.drawLine(x, y, x + w, y);

    long t1 = tMax;
    if (t1 <= 0L) {
      // No data yet, so draw current time
      t1 = System.currentTimeMillis();
    }
    long tz = timeDF.getTimeZone().getOffset(t1);
    long tickInterval = calculateTickInterval(w, 40, viewRangeMS);
    if (tickInterval > 3 * HOUR) {
      tickInterval = calculateTickInterval(w, 80, viewRangeMS);
    }
    long t0 = tickInterval - (t1 - viewRangeMS + tz) % tickInterval;
    while (t0 < viewRangeMS) {
      x = leftMargin + (int) (w * t0 / viewRangeMS);
      g.drawLine(x, y - 2, x, y + 2);

      long t = t1 - viewRangeMS + t0;
      String str = formatClockTime(t);
      g.drawString(str, x, y + 16);
      // if (tickInterval > (1 * HOUR) && t % (1 * DAY) == 0) {
      if ((t + tz) % (1 * DAY) == 0) {
        str = formatDate(t);
        g.drawString(str, x, y + 27);
      }
      // Draw vertical grid line
      g.setColor(Color.lightGray);
      g.drawLine(x, topMargin, x, topMargin + h);
      g.setColor(fg);
      t0 += tickInterval;
    }

    // Plot values
    int start = 0;
    int nValues = 0;
    int nLists = seqs.size();
    if (nLists > 0) {
      nValues = seqs.get(0).size;
    }
    if (nValues == 0) {
      g.setColor(oldColor);
      return;
    } else {
      Sequence seq = seqs.get(0);
      // Find starting point
      for (int p = 0; p < seq.size; p++) {
        if (times.time(p) >= tMax - viewRangeMS) {
          start = p;
          break;
        }
      }
    }

    // Optimization: collapse plot of more than four values per pixel
    int pointsPerPixel = (nValues - start) / w;
    if (pointsPerPixel < 4) {
      pointsPerPixel = 1;
    }

    // Draw graphs
    // Loop backwards over sequences because the first needs to be painted on top
    for (int i = nLists - 1; i >= 0; i--) {
      int x0 = leftMargin;
      int y0 = topMargin + h + 1;

      Sequence seq = seqs.get(i);
      if (seq.isPlotted && seq.size > 0) {
        // Paint twice, with white and with color
        for (int pass = 0; pass < 2; pass++) {
          g.setColor((pass == 0) ? Color.white : seq.color);
          int x1 = -1;
          long v1 = -1;
          for (int p = start; p < nValues; p += pointsPerPixel) {
            // Make sure we get the last value
            if (pointsPerPixel > 1 && p >= nValues - pointsPerPixel) {
              p = nValues - 1;
            }
            int x2 = (int) (w * (times.time(p) - (t1 - viewRangeMS)) / viewRangeMS);
            long v2 = seq.value(p);
            if (v2 >= vMin && v2 <= vMax) {
              int y2 = (int) (h * (v2 - vMin) / (vMax - vMin));
              if (x1 >= 0 && v1 >= vMin && v1 <= vMax) {
                int y1 = (int) (h * (v1 - vMin) / (vMax - vMin));

                if (y1 == y2) {
                  // fillrect is much faster
                  g.fillRect(x0 + x1, y0 - y1 - pass, x2 - x1, 1);
                } else {
                  Graphics2D g2d = (Graphics2D) g;
                  Stroke oldStroke = null;
                  if (seq.transitionStroke != null) {
                    oldStroke = g2d.getStroke();
                    g2d.setStroke(seq.transitionStroke);
                  }
                  g.drawLine(x0 + x1, y0 - y1 - pass, x0 + x2, y0 - y2 - pass);
                  if (oldStroke != null) {
                    g2d.setStroke(oldStroke);
                  }
                }
              }
            }
            x1 = x2;
            v1 = v2;
          }
        }

        // Current value
        long v = seq.value(seq.size - 1);
        if (v >= vMin && v <= vMax) {
          if (bgIsLight) {
            g.setColor(seq.color);
          } else {
            g.setColor(fg);
          }
          x = r.x + r.width + 2;
          y = topMargin + h - (int) (h * (v - vMin) / (vMax - vMin));
          // a small triangle/arrow
          g.fillPolygon(new int[] {x + 2, x + 6, x + 6}, new int[] {y, y + 3, y - 3}, 3);
        }
        g.setColor(fg);
      }
    }

    int[] valueStringSlots = new int[nLists];
    for (int i = 0; i < nLists; i++) valueStringSlots[i] = -1;
    for (int i = 0; i < nLists; i++) {
      Sequence seq = seqs.get(i);
      if (seq.isPlotted && seq.size > 0) {
        // Draw current value

        // TODO: collapse values if pointsPerPixel >= 4

        long v = seq.value(seq.size - 1);
        if (v >= vMin && v <= vMax) {
          x = r.x + r.width + 2;
          y = topMargin + h - (int) (h * (v - vMin) / (vMax - vMin));
          int y2 = getValueStringSlot(valueStringSlots, y, 2 * 10, i);
          g.setFont(smallFont);
          if (bgIsLight) {
            g.setColor(seq.color);
          } else {
            g.setColor(fg);
          }
          String curValue = getFormattedValue(v, true);
          if (unit == Unit.PERCENT) {
            curValue += "%";
          }
          int valWidth = fm.stringWidth(curValue);
          String legend = (displayLegend ? seq.name : "");
          int legendWidth = fm.stringWidth(legend);
          if (checkRightMargin(valWidth) || checkRightMargin(legendWidth)) {
            // Wait for next repaint
            return;
          }
          g.drawString(legend, x + 17, Math.min(topMargin + h, y2 + 3 - 10));
          g.drawString(curValue, x + 17, Math.min(topMargin + h + 10, y2 + 3));

          // Maybe draw a short line to value
          if (y2 > y + 3) {
            g.drawLine(x + 9, y + 2, x + 14, y2);
          } else if (y2 < y - 3) {
            g.drawLine(x + 9, y - 2, x + 14, y2);
          }
        }
        g.setFont(oldFont);
        g.setColor(fg);
      }
    }
    g.setColor(oldColor);
  }
Пример #9
0
  public void Draw_Arrow(Graphics g) {
    double arrow_angle;
    int[] arrow_x = new int[3];
    int[] arrow_y = new int[3];
    int[] arrow_pt = new int[2];
    double gradient, constant;
    double distance, temp_dist;
    double mid_x_diff, mid_y_diff;
    double arrow_ratio;
    double trans_pts_x, trans_pts_y;

    trans_pts_x = 0.00;
    trans_pts_y = 0.00;
    arrow_ratio = 0.00;
    mid_x_diff = 0.00;
    mid_y_diff = 0.00;
    distance = 0.00;
    temp_dist = 0.00;
    gradient = 0.00;
    constant = 0.00;
    arrow_x[0] = 0;
    arrow_x[1] = 0;
    arrow_x[2] = 0;
    arrow_y[0] = 0;
    arrow_y[1] = 0;
    arrow_y[2] = 0;
    arrow_angle = 0.00;

    arrow_angle = (start_angle + arc_angle / 2) * Math.PI / 180;
    //		if (num_arcs != 1) {
    arrow_x[0] = (int) Math.round(img_mid_x + img_cir * Math.cos(arrow_angle));
    arrow_y[0] = (int) Math.round(img_mid_y - img_cir * Math.sin(arrow_angle));
    //			}
    //		else {
    //			arrow_x[0] = mid_pt_x;
    //			arrow_y[0] = mid_pt_y;
    //			g.drawString("1", (int)arrow_x[0], (int)arrow_y[0]);
    //		}
    /*calculate the distance between the midpt (on arc) and start node*/
    mid_x_diff = Math.abs(arrow_x[0] - start_x);
    mid_y_diff = Math.abs(arrow_y[0] - start_y);

    distance = Math.sqrt((mid_x_diff * mid_x_diff) + (mid_y_diff * mid_y_diff));

    temp_dist = distance - HEAD_DISTANCE;
    arrow_ratio = temp_dist / distance;
    arrow_x[1] = (int) ((arrow_x[0] - start_x) * arrow_ratio + start_x);
    arrow_y[1] = (int) ((arrow_y[0] - start_y) * arrow_ratio + start_y);

    // calculate the gradient of the tangent
    // equation of the circle is (x-c)^2 + (y-d)^2 = R^2
    // equation of the line is y = mx + c
    gradient = ((-1) * (arrow_x[0] - img_mid_x)) / (arrow_y[0] - img_mid_y);
    // find the constant value of the line
    constant = arrow_y[0] - gradient * arrow_x[0];

    arrow_pt = Translated_Point(constant, arrow_x, arrow_y, gradient);
    arrow_x[2] = arrow_pt[0];
    arrow_y[2] = arrow_pt[1];

    if (num_arcs == 1 && testcase != 10) {
      /*x and y distances between mid pts and arc mid pts */
      trans_pts_x = arrow_x[0] - mid_pt_x;
      trans_pts_y = arrow_y[0] - mid_pt_y;
      arrow_x[0] = mid_pt_x;
      arrow_y[0] = mid_pt_y;
      arrow_x[1] = arrow_x[1] - (int) trans_pts_x;
      arrow_y[1] = arrow_y[1] - (int) trans_pts_y;
      arrow_x[2] = arrow_x[2] - (int) trans_pts_x;
      arrow_y[2] = arrow_y[2] - (int) trans_pts_y;
    } else if (num_arcs == 1 && testcase == 10) {
      System.out.println("hello...");
      arrow_x[0] = (int) (start_x - diameter);
      arrow_y[0] = (int) start_y;
      arrow_x[1] = (int) (diameter / 4 + arrow_x[0]);
      arrow_y[1] = (int) (diameter / 6 - arrow_y[0]);
      arrow_x[2] = (int) (diameter / 4 - arrow_x[0]);
      arrow_y[2] = (int) (diameter / 6 - arrow_y[0]);
    }
    g.setColor(arrow_colour);
    g.fillPolygon(arrow_x, arrow_y, 3);
    if (value != 0) {
      g.setColor(value_colour);
      if (show_cost) {
        Display_Value(g, arrow_x, arrow_y);
      }
    }
  }