Examples of GlyphVector


Examples of java.awt.font.GlyphVector

   * @param y position of the table header baseline
   * @throws FontFormatException
   * @throws IOException
   */
  private void drawTableHeader(Graphics2D g2d,final int y) throws FontFormatException, IOException{
    GlyphVector gv = opPainter.createGlyphVector(g2d, "Ware", 19); // TODO externalize
    int x = positions.xWare-(int)Math.rint(gv.getVisualBounds().getWidth());
    g2d.drawGlyphVector(gv, x, y);
    String columnTitle = "Stock";
    gv = opPainter.createGlyphVector(g2d, columnTitle, 19);
    g2d.drawGlyphVector(gv, positions.xCity, y);
    gv = opPainter.createGlyphVector(g2d, "from City", 19);
View Full Code Here

Examples of java.awt.font.GlyphVector

  protected BufferedImage initBackgroundImage(IImageLoader loader,Point topLeft) {
    BufferedImage bg = super.initBackgroundImage(loader,topLeft);
    Graphics2D g2d = bg.createGraphics();
    g2d.setColor(Color.BLACK);
    try {
      GlyphVector gv = opPainter.createGlyphVector(g2d, "Wares in stock", 24); // TODO externalize
      double titleHeight = gv.getVisualBounds().getHeight();
      int length = (int) Math.rint(gv.getVisualBounds().getWidth());
      int x = ((bg.getWidth()-getInset().left-getInset().right)-length)/2;
      int y = getInset().top+10+(int)Math.rint(titleHeight*2/3);
      g2d.drawGlyphVector(gv, x, y);
      // Dynamic row
      y += titleHeight;
      y += (int)Math.rint(titleHeight*2/3);
     
      BufferedImage waxSeal = loader.getImage("waxseal");
      int leftBorderX = topLeft.x+getInset().left;
      int xWare = leftBorderX+100; // right aligned
      int xCity = leftBorderX+110;
      int xBuy = leftBorderX+200; // size of the image + 10
      int xSell = leftBorderX+280;// size of the image + 10
      int yLineDiff = waxSeal.getHeight();
      // Initialize the position relative to the frame
      positions = new DialogPositions(titleHeight, yLineDiff, leftBorderX, xWare, xCity, xBuy, xSell);
     
      leftBorderX = getInset().left; // Use local coordinates
      xWare = leftBorderX+100; // right aligned
     
      // table header
      y += positions.lineHeight; // more space to the title
      y += positions.lineHeight;
     
      // Table
      EWare[] wares = EWare.values();
      for (EWare ware : wares) {
        // Ware name
        y += positions.lineHeight;
        gv = opPainter.createGlyphVector(g2d, ware.getLocalDisplayName(), 18);
        x = xWare-(int)Math.rint(gv.getVisualBounds().getWidth());
        g2d.drawGlyphVector(gv, x, y);
        // Amount available
       
        // from city
       
        // to city
      }
      // Footer buttons
      y = bg.getHeight()-getInset().bottom-positions.lineHeight;
      x = getInset().left+30;
      int footerWidth = bg.getWidth()-getInset().left-getInset().right-2*30;
      x += 3*footerWidth/4;
      // close
      g2d.drawImage(waxSeal, x,y-(int)(positions.lineHeight*0.8), null);
      NamedPolygon polygon = new NamedPolygon("Close");
      polygon.addPoint(topLeft.x+x, topLeft.y+y-(int)(positions.lineHeight*0.8));
      polygon.addPoint(topLeft.x+x+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8));
      polygon.addPoint(topLeft.x+x+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
      polygon.addPoint(topLeft.x+x, topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
      footerPolygons.add(polygon, new CloseAction(this));
      g2d.setColor(new Color(0xEA,0xC1,0x17)); // Gold
      gv = opPainter.createGlyphVector(g2d, "X", 18);
      int xPadding = imageUtils.computeCenterAlignX(x, waxSeal.getWidth(), (int)gv.getVisualBounds().getWidth());
      g2d.drawGlyphVector(gv, xPadding, y); // centeralign


    } catch (FontFormatException e1) {
      e1.printStackTrace();
View Full Code Here

Examples of java.awt.font.GlyphVector

  private int drawAvailableAmount(Graphics2D g2d, ICity city,IWare ware,BufferedImage barrel, BufferedImage bale,int y) throws FontFormatException, IOException{
    AmountablePrice available = city.getWare(ware);
    int availableAmount = available.getAmount();
    int value = availableAmount; // amount available
    if (value>0){
      GlyphVector gv = opPainter.createGlyphVector(g2d, String.valueOf(value), 18);
      g2d.drawGlyphVector(gv, positions.xCity, y);
      // draw barrel or burden
      if (ware.getSizeAsBarrels()==1){
        // barrel
        g2d.drawImage(barrel, (int)(positions.xCity+gv.getVisualBounds().getWidth())+5, y-positions.lineHeight*2/3, null);
      } else {
        g2d.drawImage(bale, (int)(positions.xCity+gv.getVisualBounds().getWidth())+5, y-positions.lineHeight*2/3, null);
      }
    }
    return availableAmount;

  }
View Full Code Here

Examples of java.awt.font.GlyphVector

    if (availableAmount>0){
      value = String.valueOf(ware.computeBuyPrice(availableAmount, amount));
    } else {
      value = "0"; // cannot buy anything if nothing is there
    }
    GlyphVector gv = opPainter.createGlyphVector(g2d, value, 18);
    final int coinSpace = 3;
    final int coindWidth = coin.getWidth();
    final int maxPriceWidth = (int)opPainter.createGlyphVector(g2d, "00000", 18).getVisualBounds().getWidth();
    int xRight = positions.xBuy-15+10+maxPriceWidth+coinSpace+coindWidth;
    int x = xRight-((int)gv.getVisualBounds().getWidth()+coinSpace+coindWidth);
    g2d.drawGlyphVector(gv, x, y);
    x = xRight-coindWidth;
    y -= (int) Math.ceil(gv.getVisualBounds().getHeight());
    g2d.drawImage(coin, x, y, null);
  }
View Full Code Here

Examples of java.awt.font.GlyphVector

   * @throws IOException Error while reading a resource
   */
  private void drawSellIconText(Graphics2D g2d, int availableAmount, IWare ware, BufferedImage coin, int y) throws FontFormatException, IOException{
    int amount = 1;
    String value = String.valueOf(ware.computeSellPrice(availableAmount, amount));
    GlyphVector gv = opPainter.createGlyphVector(g2d, value, 18);
    final int coinSpace = 3;
    final int coindWidth = coin.getWidth();
    final int maxPriceWidth = (int)opPainter.createGlyphVector(g2d, "00000", 18).getVisualBounds().getWidth();
    int xRight = positions.xSell-30+10+maxPriceWidth+coinSpace+coindWidth;
    int x = xRight-((int)gv.getVisualBounds().getWidth()+coinSpace+coindWidth);
    g2d.drawGlyphVector(gv, x, y);
    x = xRight-coindWidth;
    y -= (int) Math.ceil(gv.getVisualBounds().getHeight());
    g2d.drawImage(coin, x, y, null);

   
//    GlyphVector gv = opPainter.createGlyphVector(g2d, value, 18);
//    int xPadding = imageUtils.computeCenterAlignX(positions.xSell, waxSeal.getWidth(), (int)gv.getVisualBounds().getWidth());
View Full Code Here

Examples of java.awt.font.GlyphVector

    BufferedImage img = painter.createScaledPlank(rect.width, rect.height);
    g.drawImage(img, rect.x, rect.y, img.getWidth(), img.getHeight(), null);
    String s = getSelected();
    if (s!=null && s.length()>0){
      try {
        GlyphVector gv = painter.createGlyphVector(s, getFont().getSize());
        Insets insets = getInsets();
        int x = rect.x+insets.left;
        int y = rect.y+insets.top+rect.height;//
        int descent = metric.getDescent();
        int textHeight = descent+metric.getAscent();
View Full Code Here

Examples of java.awt.font.GlyphVector

   * @param y position of the table header baseline
   * @throws FontFormatException
   * @throws IOException
   */
  private void drawTableHeader(Graphics2D g2d,final int y) throws FontFormatException, IOException{
    GlyphVector gv = opPainter.createGlyphVector(g2d, "Ware", 19); // TODO externalize
    int x = positions.xWare-(int)Math.rint(gv.getVisualBounds().getWidth());
    g2d.drawGlyphVector(gv, x, y);
   
    String columnTitle = "Stock";
    gv = opPainter.createGlyphVector(g2d, columnTitle, 19);
    g2d.drawGlyphVector(gv, positions.xCity, y);
View Full Code Here

Examples of java.awt.font.GlyphVector

  protected BufferedImage initBackgroundImage(IImageLoader loader,Point topLeft) {
    BufferedImage bg = super.initBackgroundImage(loader,topLeft); // get a copy
    Graphics2D g2d = bg.createGraphics();
    g2d.setColor(Color.BLACK);
    try {
      GlyphVector gv = opPainter.createGlyphVector(g2d, "Production and Consumtion", 24); // TODO externalize
      double titleHeight = gv.getVisualBounds().getHeight();
      int length = (int) Math.rint(gv.getVisualBounds().getWidth());
      int x = ((bg.getWidth()-getInset().left-getInset().right)-length)/2;
      int y = getInset().top+10+(int)Math.rint(titleHeight*2/3);
      g2d.drawGlyphVector(gv, x, y);
      // Dynamic row
      y += titleHeight;
      y += (int)Math.rint(titleHeight*2/3);
     
      BufferedImage waxSeal = loader.getImage("waxseal");
      int leftBorderX = topLeft.x+getInset().left;
      int xWare = leftBorderX+100; // right aligned
      int xCity = leftBorderX+110;
      int prodCity = leftBorderX+160;
      int prodChandler = leftBorderX+200;
      int consCiticens = leftBorderX+270;
      int consWorkshops = leftBorderX+330;
      int consTotal = leftBorderX+380;
      int yLineDiff = waxSeal.getHeight();
      // Initialize the position relative to the frame
      positions = new DialogPositions(titleHeight, yLineDiff, xWare, xCity, prodCity, prodChandler, consCiticens, consWorkshops, consTotal);
     
      leftBorderX = getInset().left; // Use local coordinates
      xWare = leftBorderX+100; // right aligned
     
      // table header
      gv = opPainter.createGlyphVector(g2d, "on a weekly basis", 18); // TODO externalize
      length = (int) Math.rint(gv.getVisualBounds().getWidth());
      x = ((bg.getWidth()-getInset().left-getInset().right)-length)/2;
      g2d.drawGlyphVector(gv, x, y);
      y += positions.lineHeight; // more space to the title
      y += positions.lineHeight;
     
      // Table
      EWare[] wares = EWare.values();
      for (EWare ware : wares) {
        // Ware name
        y += positions.lineHeight;
        gv = opPainter.createGlyphVector(g2d, ware.getLocalDisplayName(), 18);
        x = xWare-(int)Math.rint(gv.getVisualBounds().getWidth());
        g2d.drawGlyphVector(gv, x, y);
        // Amount available
       
        // from city
       
        // to city
      }
      // Footer buttons
      y = bg.getHeight()-getInset().bottom-positions.lineHeight;
      x = getInset().left+30;
      int footerWidth = bg.getWidth()-getInset().left-getInset().right-2*30;
      x += 3*footerWidth/4;
      // close
      g2d.drawImage(waxSeal, x,y-(int)(positions.lineHeight*0.8), null);
      NamedPolygon polygon = new NamedPolygon("Close");
      polygon.addPoint(topLeft.x+x, topLeft.y+y-(int)(positions.lineHeight*0.8));
      polygon.addPoint(topLeft.x+x+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8));
      polygon.addPoint(topLeft.x+x+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
      polygon.addPoint(topLeft.x+x, topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
      footerPolygons.add(polygon, new CloseAction(this));
      g2d.setColor(new Color(0xEA,0xC1,0x17)); // Gold
      gv = opPainter.createGlyphVector(g2d, "X", 18);
      int xPadding = imageUtils.computeCenterAlignX(x, waxSeal.getWidth(), (int)gv.getVisualBounds().getWidth());
      g2d.drawGlyphVector(gv, xPadding, y); // centeralign


    } catch (FontFormatException e1) {
      e1.printStackTrace();
View Full Code Here

Examples of java.awt.font.GlyphVector

   */
  private void drawWareAmount(Graphics2D g2d, EWare ware,
      BufferedImage barrel, BufferedImage bale, int y, int amount,
      int xPadding) throws FontFormatException, IOException {
    if (amount>0){
      GlyphVector gv = opPainter.createGlyphVector(g2d, String.valueOf(amount), 18);
      g2d.drawGlyphVector(gv, xPadding, y);
      // draw barrel or burden
      if (ware.getSizeAsBarrels()==1){
        // barrel
        g2d.drawImage(barrel, (int)(xPadding+gv.getVisualBounds().getWidth())+5, y-positions.lineHeight*2/3, null);
      } else {
        g2d.drawImage(bale, (int)(xPadding+gv.getVisualBounds().getWidth())+5, y-positions.lineHeight*2/3, null);
      }
    }
  }
View Full Code Here

Examples of java.awt.font.GlyphVector

   * @param y position of the table header baseline
   * @throws FontFormatException
   * @throws IOException
   */
  private void drawTableHeader(Graphics2D g2d,final int y) throws FontFormatException, IOException{
    GlyphVector gv = opPainter.createGlyphVector(g2d, "Weapons", 19); // TODO externalize
    int x = positions.firstColumn-(int)Math.rint(gv.getVisualBounds().getWidth());
    g2d.drawGlyphVector(gv, x, y);
    String columnTitle = "In Stock";
    gv = opPainter.createGlyphVector(g2d, columnTitle, 19);
    g2d.drawGlyphVector(gv, positions.secondcolumn, y);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.