public void update() {
   for (int i = 0; i < entities.size(); i++) {
     Entity entity = entities.get(i);
     entity.update();
   }
   entities.sort(renderSort);
 }
 @Override
 public int compare(Entity a, Entity b) {
   if (a.getY() + a.getHeight() < b.getY() + b.getHeight()) {
     return -1;
   }
   return 1;
 }
Ejemplo n.º 3
0
 private void renderEnergyBar(Entity entity, int x, int y) {
   int yPos = y + ((int) entity.boundingRadius() + 10);
   graphics.drawRect(x - 15, yPos, 30, 7);
   Color originalColor = graphics.getColor();
   graphics.setColor(Color.BLUE);
   double energyBarLength = 29.0 * entity.energy();
   graphics.fillRect(x - 14, yPos + 1, (int) energyBarLength, 6);
   graphics.setColor(originalColor);
 }
Ejemplo n.º 4
0
 private void renderHealthBar(Entity entity, int x, int y) {
   int yPos = y - ((int) entity.boundingRadius() + 10);
   graphics.drawRect(x - 15, yPos, 30, 7);
   Color originalColor = graphics.getColor();
   double health = entity.health();
   graphics.setColor(getColorFor(health));
   double healthBarLength = 29.0 * health;
   graphics.fillRect(x - 14, yPos + 1, (int) healthBarLength, 6);
   graphics.setColor(originalColor);
 }
Ejemplo n.º 5
0
 @Override
 protected void updateItem(final Tab tab, boolean empty) {
   super.updateItem(tab, empty);
   if (tab != null) {
     tab.getUnreadProperty()
         .addListener(
             new ChangeListener<Boolean>() {
               @Override
               public void changed(
                   ObservableValue<? extends Boolean> observableValue,
                   Boolean oldValue,
                   Boolean newValue) {
                 if (newValue) {
                   getStyleClass().add("unread");
                 } else {
                   getStyleClass().remove("unread");
                 }
               }
             });
     Entity entity = tab.getEntity();
     setPrefHeight(32);
     if (entity instanceof Server) {
       setPrefHeight(40);
       Label net = new Label("network");
       net.getStyleClass().add("network");
       VBox box = new VBox();
       Label name = new Label(entity.getName());
       name.getStyleClass().add("network-name");
       box.getChildren().addAll(net, name);
       setGraphic(box);
     } else if (entity instanceof Channel) {
       final Label label = new Label(entity.getName().substring(1));
       label.getStyleClass().add("name");
       final HBox box = new HBox();
       box.getChildren().addAll(FontAwesome.createIcon(FontAwesome.COMMENTS), label);
       setGraphic(box);
     } else if (entity instanceof User) {
       final Label label = new Label(entity.getName());
       label.getStyleClass().add("name");
       final HBox box = new HBox();
       box.getChildren().addAll(FontAwesome.createIcon(FontAwesome.USER), label);
       setGraphic(box);
     }
   }
 }
Ejemplo n.º 6
0
 public void addTargetedMessage(Connection connection, Message message, MessageRow.Type type) {
   Entity target = message.getTarget();
   if (target.equals(connection.getLocalUser())) {
     target = message.getSource();
   }
   Tab tab = null;
   for (Tab _tab : getItems()) {
     if (_tab.getEntity().equals(target)) {
       tab = _tab;
       break;
     }
   }
   if (tab == null) {
     if (type == MessageRow.Type.PART && message.getSource().equals(connection.getLocalUser())) {
       return;
     }
     tab = create(connection, target);
   }
   tab.getContentPane().getMessagePane().addRow(new MessageRow(message, type));
 }
 public void render(Graphics graphics) {
   for (Entity entity : entities) {
     entity.render(graphics);
   }
 }