Пример #1
0
  /*-------------------------------------------------------------------------*/
  public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g.create();

    Portal[] portals = zone.getPortals();

    if (display.displayFeatures.get(MapDisplay.Display.PORTALS)) {
      for (Portal portal : portals) {
        int fromIndex = calcIndex(portal.getFrom());
        int toIndex = calcIndex(portal.getTo());

        Rectangle fromBounds = display.getTileBounds(fromIndex);
        Rectangle toBounds = display.getTileBounds(toIndex);
        int tileSize = display.tileSize * display.zoomLevel;
        int offset = tileSize / 4;
        int diameter = tileSize / 2;

        g2d.setColor(Color.WHITE);
        g2d.drawLine(
            fromBounds.x + tileSize / 2 + 1,
            fromBounds.y + tileSize / 2 + 1,
            toBounds.x + tileSize / 2 + 1,
            toBounds.y + tileSize / 2 + 1);
        g2d.setColor(Color.BLACK);
        g2d.drawLine(
            fromBounds.x + tileSize / 2,
            fromBounds.y + tileSize / 2,
            toBounds.x + tileSize / 2,
            toBounds.y + tileSize / 2);

        g2d.setColor(Color.WHITE);
        g2d.drawOval(fromBounds.x + offset + 1, fromBounds.y + offset + 1, diameter, diameter);
        g2d.setColor(Color.BLACK);
        g2d.drawOval(fromBounds.x + offset, fromBounds.y + offset, diameter, diameter);

        if (portal.isTwoWay()) {
          g2d.setColor(Color.WHITE);
          g2d.drawOval(toBounds.x + offset + 1, toBounds.y + offset + 1, diameter, diameter);
          g2d.setColor(Color.BLACK);
          g2d.drawOval(toBounds.x + offset, toBounds.y + offset, diameter, diameter);
        }
      }
    }
  }
Пример #2
0
 /*-------------------------------------------------------------------------*/
 private int calcIndex(Point p) {
   int width = zone.getWidth();
   return p.y * width + p.x % width;
 }