// renders font characters to be used for text painting in tests (to make font rendering
 // platform-independent)
 public static void main(String[] args) throws Exception {
   Font font =
       Font.createFont(
           Font.TRUETYPE_FONT,
           EditorPaintingTest.class.getResourceAsStream("/fonts/Inconsolata.ttf"));
   BitmapFont bitmapFont = BitmapFont.createFromFont(font);
   bitmapFont.saveToFile(getFontFile());
 }
Exemplo n.º 2
0
 /**
  * Loads the Bootstrap font containing the glyphs
  *
  * @param size Desired font size
  * @return Font object for Bootstrap Glyph Font
  * @throws FontFormatException
  * @throws IOException
  */
 private Font loadGlyphFont(float size) throws FontFormatException, IOException {
   Font fontRaw =
       Font.createFont(
           Font.TRUETYPE_FONT,
           this.getClass()
               .getResourceAsStream("/resource/image/glyphicons-halflings-regular.ttf"));
   Font fontBase = fontRaw.deriveFont(16f);
   return fontBase.deriveFont(Font.PLAIN, size);
 }
    private Font getProductFont() {
      String name = "/fonts/Roboto-Light.ttf";
      URL url = AppUIUtil.class.getResource(name);
      if (url == null) {
        Logger.getInstance(AppUIUtil.class).warn("Resource missing: " + name);
      } else {

        try {
          InputStream is = url.openStream();
          try {
            return Font.createFont(Font.TRUETYPE_FONT, is);
          } finally {
            is.close();
          }
        } catch (Throwable t) {
          Logger.getInstance(AppUIUtil.class).warn("Cannot load font: " + url, t);
        }
      }
      return UIUtil.getLabelFont();
    }
  private void registerFont(String name) {
    if (isHeadlessEnvironment()) return;

    InputStream is = null;
    try {
      is = getClass().getResourceAsStream(name);
      final Font font = Font.createFont(Font.TRUETYPE_FONT, is);
      GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(font);
    } catch (Exception e) {
      LOG.info(e);
    } finally {
      if (is != null) {
        try {
          is.close();
        } catch (IOException e) {
          LOG.error(e);
        }
      }
    }
  }
Exemplo n.º 5
0
  public shit() {
    this.addWindowListener(this);
    setSize(1280, 720);
    setVisible(true);

    r = new Random();
    //		ap = new AudioPlayer();//THIS SHIT DOESN'T WORK WHAT THE F**K DEHOWE
    timer = System.currentTimeMillis();
    options.add("");
    options.add("");
    options.add(""); // These 3 lines are to populate options.
    state = 1; // The first line will always be a story panel so the state is 1.
    try {
      URL url = getClass().getResource("options.png");
      obox = ImageIO.read((url));
      url = getClass().getResource("Text Boxes.png");
      textBox = ImageIO.read(url); // reads in the text boxes file.
      p = new parser("Introduction.txt"); // reads in the story file.
      progress(); // the function that calls going through to the next line
    } catch (IOException e) {
      e.printStackTrace();
    }

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    try {
      URL url = getClass().getResource("sspr.ttf");
      ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, url.openStream()));
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    resize(SCREENWIDTH, SCREENHEIGHT); // Makes the applet the size we want it
    addMouseListener(this); // Lets us use mouse
    addKeyListener(this); // Lets us use keyboard

    Thread t = new Thread(this);
    t.start();
  }
Exemplo n.º 6
0
  public MancalaPanel(LetsPlayMancala game) {

    // ------------------------------------------------------------------------------
    // Import font "Belta Regular"
    // -----------------------------------------------------------------------------
    try {
      InputStream in = MancalaPanel.class.getResourceAsStream("belta-regular.ttf");
      Font font = Font.createFont(Font.TRUETYPE_FONT, in);
    } catch (Exception ex) {
      System.out.println("Font couldn't be loaded.");
    }

    // ----------------------------------------------------------------------------
    // Set background image
    // ----------------------------------------------------------------------------
    imageFile = "/Images/GameBackground.png";
    this.game = game;
    SMALL_PIT_COUNT = 12;

    setLayout(new BorderLayout());

    add(northWindowPanel(), BorderLayout.NORTH);
    add(westWindowPanel(), BorderLayout.WEST);
    add(makeBoardPanel(), BorderLayout.CENTER);
    add(eastWindowPanel(), BorderLayout.EAST);
    add(southWindowPanel(), BorderLayout.SOUTH);

    winners = new LinkedStack<String>();
    winnersLabel = new JLabel();

    resultFrame = new JFrame();
    boardResultPanel = new BkImagePanel("/Images/board2.png");
    resultNorth = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 50));
    resultNorth.setOpaque(false);
    resultCenter = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
    resultCenter.setOpaque(false);
    resultSouth = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 20));
    resultSouth.setOpaque(false);

    playAgainBtn.setPreferredSize(new Dimension(240, 80));
    playAgainBtn.setBackground(new Color(135, 17, 76));
    playAgainBtn.setForeground(Color.white);
    playAgainBtn.setBorder(BorderFactory.createLineBorder(Color.white, 6));
    playAgainBtn.setFont(new Font("Belta Regular", Font.BOLD, 40));
    playAgainBtn.addActionListener(new ButtonListener());

    scoresBtn.setPreferredSize(new Dimension(340, 80));
    scoresBtn.setBorder(BorderFactory.createLineBorder(Color.white, 6));
    scoresBtn.addActionListener(new ButtonListener());

    quitBtn.setPreferredSize(new Dimension(150, 80));
    quitBtn.setBorder(BorderFactory.createLineBorder(Color.white, 6));
    quitBtn.addActionListener(new ButtonListener());

    result = new JLabel();
    result.setFont(new Font("Belta Regular", Font.BOLD, 40));
    result.setForeground(Color.white);
    result.setBackground(new Color(0, 158, 121));
    result.setBorder(BorderFactory.createLineBorder(Color.white, 6));
    result.setOpaque(true);
    result.setPreferredSize(new Dimension(380, 80));

    winnersLabel = new JLabel();
    winnersLabel.setFont(new Font("Belta Regular", Font.BOLD, 40));
    winnersLabel.setForeground(Color.white);
    winnersLabel.setPreferredSize(new Dimension(420, 200));

    boardResultPanel.setLayout(new BorderLayout(50, 50));
    boardResultPanel.setPreferredSize(new Dimension(800, 700));
    boardResultPanel.setBackground(Color.yellow);
    boardResultPanel.add(resultNorth, BorderLayout.NORTH);
    boardResultPanel.add(resultCenter, BorderLayout.CENTER);
    boardResultPanel.add(resultSouth, BorderLayout.SOUTH);

    resultCenter.add(winnersLabel);
    resultSouth.add(scoresBtn);
    resultSouth.add(playAgainBtn);
    resultSouth.add(quitBtn);

    resultFrame.add(boardResultPanel);
  }
Exemplo n.º 7
0
  public GamePanel(String name, int l) {
    setFocusable(true);
    grabFocus();
    addMouseListener(this);
    addMouseMotionListener(this);
    addKeyListener(this);
    keys = new boolean[10000];

    try {
      scoreFont =
          Font.createFont(Font.TRUETYPE_FONT, new FileInputStream(new File("BRLNSB.ttf")))
              .deriveFont(0, 32);
    } catch (IOException ioe) {
      System.out.println("error loading BRLNSB.tff");
    } catch (FontFormatException ffe) {
      System.out.println("Something went wrong with the font.");
    }

    gameBckgrnd = new ImageIcon("Backgroundimage.png").getImage();
    for (int i = 1; i < 7; i++) {
      magnetList.add(new ImageIcon("gamelayerstuff/powerups/magnet" + i + ".png").getImage());
    }

    coinPic = new ImageIcon("gamelayerstuff/coins/byellowcoin1.png").getImage();
    player1 = new Player(200, 300, 100, "sheldon");

    click = false;
    ground = true;
    pause = false;
    lvlClear = false;
    die = false;
    musicOn = true;

    player1.setVelo(150);
    player1.setInvi(true);
    // ------------------------------------------------------------------------------------------------------------------------------------
    // Sound
    coinSound = Applet.newAudioClip(getClass().getResource("coin_pickup_2.wav"));
    clicked = Applet.newAudioClip(getClass().getResource("menu_deselect.wav"));
    starSound = Applet.newAudioClip(getClass().getResource("star.wav"));
    bounce = Applet.newAudioClip(getClass().getResource("grav_step_4.wav"));
    bckGrndMusic = Applet.newAudioClip(getClass().getResource("bgmusic00.wav"));
    bckGrndMusic.loop();
    // ------------------------------------------------------------------------------------------------------------------------------------

    // distance=0;
    score = 0;
    coins = 0;
    level = 1;
    prevLvl = level;
    backy = 0;
    height = backy;
    dieHeight = 0;
    dieMenuHeight = 0;

    pauseB = new SButton(400, 670, "pause", "");
    resumeB = new SButton(100, 500, "resume", "");
    menuB = new SButton(100, 620, "back", "");
    muteB = new SButton(400, 600, "mute", "");
    unmuteB = new SButton(400, 600, "unmute", "");
    // System.out.println("characters/"+name+"/"+name+"35.png");
  }