Package org.newdawn.slick

Examples of org.newdawn.slick.Font


      throws SlickException {
    if (!visible)
      return;
    super.render(container, g);
    g.setColor(Color.black);
    Font oldFont = g.getFont();
    g.setFont(font);
    int startx = (int) x + 5;
    int starty = (int) y + 5;
    for (String line : messageLines) {
      g.drawString(line, startx, starty);
View Full Code Here


    prepareTestScenario(container, world);
    addState(world);
  }

  private void prepareTestScenario(GameContainer container, World world) {
    Font defaultFont = container.getDefaultFont();
    // add some entities to our world
    // images rotating, scaling and alpha
    world.add(new TextEntity(10, 50, defaultFont, "rotating"));
    world.add(new AngleAlphaScaleMoveEntity(100, 150, true, false, false,
        false));
View Full Code Here

    IngameState state = (IngameState) this.world;
    RoundedRectangle r = new RoundedRectangle(x, y,
        container.getWidth() - 1, 40, 20);
    Color c = Color.blue;
    c.a = 0.3f;
    Font oldFont = g.getFont();
    g.setFont(font);
    g.setColor(c);
    g.fill(r);
    g.draw(r);
    g.setColor(Color.white);
View Full Code Here

 
  @Override
  public void render(GameContainer container, Graphics graphics) {
   
    if(this.shape.getWidth() == 0){
      Font font = graphics.getFont();
      int width = font.getWidth(text) + this.padding * 2;
      int height = font.getHeight(text) + this.padding * 2;
      this.shape = new Rectangle(this.x - width / 2, this.y - height / 2, width, height);
      this.setShape(this.shape);
    }
   
    super.render(container, graphics);
View Full Code Here

  }

  @Override
  public void render(Graphics g) throws SlickException {
    UIHelper.drawDarkBox(g, this.ox, this.oy, this.width, this.height);
    Font font = FontHelper.getFont(FontHelper.HEMI_HEAD, this.filledColor, 20);
    if (this.state == HOVERED) {
      // The progressbar is hovered. If there is a title, it is shown in
      // place of the percentage
      if (this.title != null) {
        g.setColor(this.filledColor);
        font.drawString(this.ox + 2, this.oy + 2, this.title);
        return;
      }
    }
    int percentage;
    if (this.maxValue.equals(BigDecimal.ZERO)) {
      // Avoiding division by zero
      percentage = 0;
    } else {
      percentage = this.value.multiply(HUNDRED)
          .divide(this.maxValue, 2, RoundingMode.HALF_UP).intValue();
    }

    final int max = this.width - 1;
    final int w = NumberHelper.ruleOf3(100, max, percentage);
    final int midHeight = this.height / 2;
    for (int i = 0; i < max - 1; i++) {
      if (i % 2 == 1 || i == max) {
        continue;
      }
      if (i < w) {
        g.setColor(this.filledColor);
      } else {
        g.setColor(Color.black);
      }
      int drawX = this.ox + i + 2;
      int height = this.oy + (this.height - 2);
      if (this.displayValues) {
        height = midHeight + this.oy;
      }
      g.drawLine(drawX, this.oy + 2, drawX, height);
    }

    if (this.displayValues) {
      Font sfont = FontHelper.getFont(FontHelper.VISITOR,
          FontHelper.convert(Color.white), midHeight);
      sfont.drawString(this.ox + 2, this.oy + midHeight + 1, this.value
          + "/" + this.maxValue);
    }

  }
View Full Code Here

    Image gfx = ImageManager.getGfx(this.selectedBuilding.getType()
        .toString().toLowerCase());
    gfx.draw(ox + PADDING + 1, oy + PADDING * 2 + 32);

    // Building name
    Font fontBig = FontHelper
        .getFont(FontHelper.HEMI_HEAD, Color.white, 30);
    Font fontNormal = FontHelper.getFont(FontHelper.HEMI_HEAD, Color.white,
        20);

    int x = ox + PADDING * 2 + 32;
    int y = oy + PADDING * 2;
    fontBig.drawString(x - 40, y, FontHelper.firstToUpper(I18n
        .get(this.selectedBuilding.getI18n())));

    // Building level
    String temp = I18n.get("global.level") + " : "
        + this.selectedBuilding.getLevel();
    fontNormal.drawString(x, y += 40, FontHelper.firstToUpper(temp));

    // Current action
    String title = null;
    BigDecimal maxValue = null;
    BigDecimal value = null;
    DelayedAction a = getSelectedBuildingAction();
    this.selectedBuildingPB.setFilledColor(Color.red);
    if (a instanceof BuildingAction) {
      BuildingAction ba = (BuildingAction) a;
      if (ba.isUpgrade()) {
        // Upgrade process
        title = FontHelper.firstToUpper(I18n.get("global.upgrading"))
            + "...";
        this.selectedBuildingPB.setFilledColor(Color.magenta);
      } else if (!ba.isUpgrade()) {
        // Building process
        title = FontHelper.firstToUpper(I18n.get("global.building"))
            + "...";
      }
      maxValue = BigDecimal.valueOf(ba.getDuration());
      value = BigDecimal.valueOf(ba.getCurrentValue());
    } else if (a instanceof ColonyAction) {
      ColonyAction sa = (ColonyAction) a;
      title = FontHelper.firstToUpper(I18n.get(sa.getI18nKey())) + "...";
      this.selectedBuildingPB.setFilledColor(Color.red);
      maxValue = BigDecimal.valueOf(sa.getDuration());
      value = BigDecimal.valueOf(sa.getCurrentValue());
    }

    if (a != null) {
      fontNormal.drawString(x, y += 35, title);

      // Action progress
      this.selectedBuildingPB.setMaxValue(maxValue);
      this.selectedBuildingPB.setValue(value);
      this.selectedBuildingPB.setOX(x);
View Full Code Here

    renderProgressBars(g, x + TOGGLE_BUTTON_ZONE_WIDTH, y);

    // Render the colony name
    UIHelper.drawWindow(g, Settings.WIDTH - 140, 0, 140, 46, 5);
    Font font = FontHelper.getFont(FontHelper.HEMI_HEAD, Color.white, 20);
    font.drawString(Settings.WIDTH - 130, 15, GameData.getSelectedColony()
        .getName());
  }
View Full Code Here

    }
   
    // Render the background box
    UIHelper.drawBox(g, this.getOX(), this.getOY(), WIDTH, HEIGHT);

    final Font bigFont = FontHelper.getFont(FontHelper.HEMI_HEAD,
        Color.white, 20);
    final Font smallFont = FontHelper.getFont(FontHelper.HEMI_HEAD,
        Color.white, 15);
    final int dpadding = 4;

    int x = this.getOX() + 2;
    int y = this.getOY() + 2;

    // Colony info background
    UIHelper.drawDarkBox(g, x, y, 175, 40);

    // Colony name
    bigFont.drawString(x + 2, y + 2, this.colony.getName());

    // The planet name
    y += 20;
    smallFont.drawString(x + 12, y + 2, this.colony.getPlanetName());

    UIHelper.drawDarkBox(g, x, y + 35, 175, 40);

    ResearchAction research = this.colony.getResearch();
    if (research != null) {
      // The colony's current research name
      smallFont.drawString(x + 4, y + 45, research.getTechnology()
          .getName());

      // The colony's current research progress
      this.researchPB.setMaxValue(BigDecimal.valueOf(research
          .getDuration()));
View Full Code Here

    for (Button b : this.buttons) {
      b.render(g);
    }

    // Rendering of the information zone
    Font font = FontHelper.getDefaultFont();
    final int padding = 10;
    int y = this.getOY() + 140;
    int x = this.getOX() + padding;

    g.setColor(Style.BORDER_COLOR);
    g.drawLine(x, y, this.getOX() + this.width - padding, y);

    y += 10;
    g.setColor(Color.black);
    font.drawString(this.getOX() + 10, y, this.name);

    y += 20;
    font.drawString(x + 100, y, I18n.getFirstToUpper("resource.price"));
    font.drawString(x + 200, y, I18n.getFirstToUpper("resource.income"));
    font.drawString(x + 300, y, I18n.getFirstToUpper("resource.store"));

    y += 20;
    g.drawLine(x, y, this.getOX() + 400, y);
    final int pitch = 20;
    Resource[] resources = Resource.values();
    for (Resource r : resources) {
      font.drawString(x, y, FontHelper.firstToUpper(r.getI18n()));

      font.drawString(x + 100, y, this.cost.get(r).toString() + " U");
      font.drawString(x + 200, y, this.prod.get(r).toString() + " UPM");
      font.drawString(x + 300, y, this.store.get(r).toString() + " U");
      y += pitch;
    }
  }
View Full Code Here

      x = Settings.WIDTH / 2 - w / 2;
      y = Settings.HEIGHT / 2 - h / 2;
      UIHelper.drawWindow(g, x, y, w, h, 5);

      // The info label
      Font font = FontHelper.getFont(FontHelper.HEMI_HEAD, Color.white,
          16);
      font.drawString(x + 15, y + 15,
          FontHelper.firstToUpper(I18n.get("colony.create_label"))
              + " :");

      this.cancelColonyButton.setPosition(x + 10, y + 65);
      this.createColonyButton.setPosition(x + w - 10
View Full Code Here

TOP

Related Classes of org.newdawn.slick.Font

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.