Exemplo n.º 1
0
 public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
   if (comp.hasFocus() || focusLostTemporarily) {
     Color color = g.getColor();
     g.setColor(focusColor);
     BasicGraphicsUtils.drawDashedRect(g, x, y, width, height);
     g.setColor(color);
   }
 }
Exemplo n.º 2
0
 @Override
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   Graphics2D g2 = (Graphics2D) g.create();
   g2.translate(x, y);
   g2.setPaint(borderSelectionColor);
   g2.drawRect(0, 0, w - 1, h - 1);
   g2.setPaint(getLineColor());
   BasicGraphicsUtils.drawDashedRect(g2, 0, 0, w, h);
   g2.dispose();
 }
Exemplo n.º 3
0
 protected void paintFocus(
     Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
   Graphics2D g2D = (Graphics2D) g;
   int width = b.getWidth();
   int height = b.getHeight();
   if (((width < 64) || (height < 16)) && ((b.getText() == null) || b.getText().length() == 0)) {
     g.setColor(AbstractLookAndFeel.getFocusColor());
     BasicGraphicsUtils.drawDashedRect(g, 4, 3, width - 8, height - 6);
   } else {
     Object savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
     g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
     g2D.setColor(AbstractLookAndFeel.getFocusColor());
     int d = b.getHeight() - 4;
     g2D.drawRoundRect(2, 2, b.getWidth() - 5, b.getHeight() - 5, d, d);
     g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, savedRenderingHint);
   }
 }
Exemplo n.º 4
0
  public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    int lx = 10;
    super.paint(g);
    long time = System.currentTimeMillis();
    if (mapImage != null) {
      mapImage.paintIcon(this, g, 0, 0);
    }
    MapNode[] nodes = nodeList;
    if (nodes != null) {
      Line2D line = new Line2D.Double();
      for (int i = 0, m = nodes.length; i < m; i++) {
        MapNode n = nodes[i];
        int x, y;
        if (n.node.hasLocation()) {
          x = n.node.getX();
          y = n.node.getY();
        } else {
          x = lx;
          y = 10;
          lx += 30;
        }

        if (!hideNetwork) {
          FontMetrics fm = g.getFontMetrics();
          int fnHeight = fm.getHeight();
          int fnDescent = fm.getDescent();
          for (int j = 0, mu = n.node.getLinkCount(); j < mu; j++) {
            Link link = n.node.getLink(j);
            if (link.node.hasLocation()) {
              long age = (time - link.getLastActive()) / 100;
              int x2 = link.node.getX();
              int y2 = link.node.getY();
              if (n.isSelected) {
                if (age > LINK_COLOR.length) {
                  age = 100;
                } else {
                  age -= 50;
                }
              }
              line.setLine(x, y, x2, y2);
              if (age < LINK_COLOR.length) {
                g.setColor(age < 0 ? LINK_COLOR[0] : LINK_COLOR[(int) age]);
              } else {
                g.setColor(LINK_COLOR[LINK_COLOR.length - 1]);
              }
              g2d.draw(line);
              //              g.setColor(Color.lightGray);
              int xn1, xn2, yn1, yn2;
              if (x <= x2) {
                xn1 = x;
                xn2 = x2;
                yn1 = y;
                yn2 = y2;
              } else {
                xn1 = x2;
                xn2 = x;
                yn1 = y2;
                yn2 = y;
              }
              int dx = xn1 + (xn2 - xn1) / 2 + 4;
              int dy = yn1 + (yn2 - yn1) / 2 - fnDescent;
              if (yn2 < yn1) {
                dy += fnHeight - fnDescent;
              }
              g.drawString("ETX:" + (((int) (link.getETX() * 100 + 0.5)) / 100.0), dx, dy);
            }
          }
        }

        n.paint(g, x, y);

        g.setColor(Color.black);
        if (n.isSelected) {
          BasicGraphicsUtils.drawDashedRect(g, x - delta, y - delta, 2 * delta, 2 * delta);
        }
        if (selectedNode != null && selectedNode.message != null) {
          g.drawString(selectedNode.message, 10, 10);
        }
      }
    }
  }