public void paintIcon(Component c, Graphics g, int x, int y) {
      Color color = c == null ? Color.GRAY : c.getBackground();
      // In a compound sort, make each succesive triangle 20%
      // smaller than the previous one.
      int dx = (int) (size / 2 * Math.pow(0.8, priority));
      int dy = descending ? dx : -dx;
      // Align icon (roughly) with font baseline.
      y = y + 5 * size / 6 + (descending ? -dy : 0);
      int shift = descending ? 1 : -1;
      g.translate(x, y);

      // Right diagonal.
      g.setColor(color.darker());
      g.drawLine(dx / 2, dy, 0, 0);
      g.drawLine(dx / 2, dy + shift, 0, shift);

      // Left diagonal.
      g.setColor(color.brighter());
      g.drawLine(dx / 2, dy, dx, 0);
      g.drawLine(dx / 2, dy + shift, dx, shift);

      // Horizontal line.
      if (descending) {
        g.setColor(color.darker().darker());
      } else {
        g.setColor(color.brighter().brighter());
      }
      g.drawLine(dx, 0, 0, 0);

      g.setColor(color);
      g.translate(-x, -y);
    }
Example #2
0
    private void drawSquare(Graphics g, int x, int y, Tetrominoes shape) {

      int squareWidth = (int) getSize().getWidth() / model.getWidth();
      int squareHeight = (int) getSize().getHeight() / model.getHeight();

      Color colors[] = {
        new Color(0, 0, 0),
        new Color(204, 102, 102),
        new Color(102, 204, 102),
        new Color(102, 102, 204),
        new Color(204, 204, 102),
        new Color(204, 102, 204),
        new Color(102, 204, 204),
        new Color(218, 170, 0)
      };

      Color color = colors[shape.ordinal()];
      g.setColor(color);
      g.fillRect(x + 1, y + 1, squareWidth - 2, squareHeight - 2);
      g.setColor(color.brighter());
      g.drawLine(x, y + squareHeight - 1, x, y);
      g.drawLine(x, y, x + squareWidth - 1, y);

      g.setColor(color.darker());
      g.drawLine(x + 1, y + squareHeight - 1, x + squareWidth - 1, y + squareHeight - 1);
      g.drawLine(x + squareWidth - 1, y + squareHeight - 1, x + squareWidth - 1, y + 1);
    }
 /**
  * Draw character in minimap
  *
  * @param g Graphics
  * @param Dx X Displacement
  * @param Dy Y Displacement
  */
 public void MapDraw(Graphics g, int Dx, int Dy, double Scale, Color col) {
   // Color
   g.setColor(col.darker().darker().darker());
   g.drawOval((int) (X * Scale + Dx), (int) (Y * Scale + Dy), 7, 7);
   g.setColor(col);
   g.fillOval((int) (X * Scale + Dx), (int) (Y * Scale + Dy), 7, 7);
 }
 private static void debugAcre(
     Acre a, String label, Set<Long> visitedAcreIds, Set<String> show, OutputGraph out) {
   if (visitedAcreIds != null) {
     visitedAcreIds.add(a.id);
   }
   double x = 0, y = 0;
   int l = a.points.length;
   double[] coords = new double[l * 2 + 2];
   for (int j = 0; j <= l; j++) {
     Point p = a.points[j % l].toPoint(1000.0);
     coords[j * 2] = p.x;
     coords[j * 2 + 1] = p.z;
     if (j < l) {
       x += p.x;
       y += p.z;
     }
   }
   x /= l;
   y /= l;
   for (int j = 0; j <= l; j++) {
     coords[j * 2] = coords[j * 2] * 0.85 + x * 0.15;
     coords[j * 2 + 1] = coords[j * 2 + 1] * 0.85 + y * 0.15;
   }
   if (label == null) {
     out.addLine(Color.white, coords);
   } else {
     Color polyColor, textColor = Color.black;
     AbstractCartographicElement parent = a.getParent();
     boolean inverted = parent instanceof Sector && ((Sector) parent).isInverted();
     int neighbors = 0;
     for (long id : a.neighbors) {
       if (id != 0) {
         neighbors++;
       }
     }
     switch (a.flavor) {
       case INNER1:
         polyColor = inverted ? Color.green : Color.red;
         break;
       case INNER2:
         polyColor = inverted ? Color.red : Color.green;
         break;
       case INNER3:
         //                    polyColor = Color.blue;
         //                    break;
       case DUAL_SECTOR:
         polyColor = new Color(51, 51, 255);
         break;
       case MULTI_SECTOR:
         polyColor = Color.gray.brighter();
         textColor = Color.black;
         break;
       default:
         polyColor = Color.black;
         textColor = Color.red;
         break;
     }
     if (neighbors < 6) {
       polyColor = polyColor.darker().darker();
       if (textColor == Color.black) {
         textColor = Color.white;
       }
       out.addPoly(polyColor, coords);
       double[] closed = new double[coords.length + 2];
       System.arraycopy(coords, 0, closed, 0, coords.length);
       System.arraycopy(coords, 0, closed, coords.length, 2);
       out.addLine(polyColor, closed);
     } else {
       out.addPoly(polyColor, coords);
     }
     if (show.contains("labels")) {
       if (label.contains("~")) {
         Matcher matcher = Pattern.compile("^(.*):\\[(.*)~(.*)]$").matcher(label);
         matcher.find();
         out.addLabel(
             textColor,
             matcher.group(1) + "\n" + matcher.group(2) + "\n" + matcher.group(3),
             x,
             y);
       } else {
         Matcher matcher = Pattern.compile("^(.*?):(.*)$").matcher(label);
         matcher.find();
         out.addLabel(textColor, matcher.group(1) + "\n" + matcher.group(2), x, y);
       }
     }
   }
 }