Examples of GlyphVector


Examples of java.awt.font.GlyphVector

   * @throws FontFormatException
   * @throws IOException
   */
  private int drawRow(Graphics2D g2d, int y,int leftBorder, String text) throws FontFormatException, IOException{
    y += positions.lineHeight;
    GlyphVector gv = opPainter.createGlyphVector(g2d, text, 18);
    int x = leftBorder;
    g2d.drawGlyphVector(gv, x, y);
    return y;
  }
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;
    switch (type) {
    case CITY_TO_SHIP:
    case CITY_TO_STORAGE:
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, "Trade goods", 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+170; // size of the image + 10
      int xSell = leftBorderX+220;// size of the image + 10
      int xShip = leftBorderX+270;
      int xPrice = leftBorderX+330;
      int yLineDiff = waxSeal.getHeight();
      // Initialize the position relative to the frame
      positions = new DialogPositions(titleHeight, yLineDiff, leftBorderX, xWare, xCity, xBuy, xSell, xShip, xPrice);
     
      leftBorderX = getInset().left; // Use local coordinates
      xWare = leftBorderX+100; // right aligned
      xCity = leftBorderX+110;
      xBuy = leftBorderX+170; // size of the image + 10
      xSell = leftBorderX+220;// size of the image + 10
      xShip = leftBorderX+270;
      xPrice = leftBorderX+330;
     
      // 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
       
        // Buy button
        g2d.drawImage(waxSeal, xBuy,y-(int)(positions.lineHeight*0.8), null);
        NamedPolygon polygon = new NamedPolygon(ware.name()+"Buy");
        // The positions of the polygons must be global
        polygon.addPoint(positions.xBuy, topLeft.y+y-(int)(positions.lineHeight*0.8));
        polygon.addPoint(positions.xBuy+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8));
        polygon.addPoint(positions.xBuy+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
        polygon.addPoint(positions.xBuy, topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
        polygons.add(polygon, new BuyProxyAction(ware,this));
       
        // Sell button
        g2d.drawImage(waxSeal, xSell,y-(int)(positions.lineHeight*0.8), null);
        polygon = new NamedPolygon(ware.name()+"Sell");
        polygon.addPoint(positions.xSell, topLeft.y+y-(int)(positions.lineHeight*0.8));
        polygon.addPoint(positions.xSell+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8));
        polygon.addPoint(positions.xSell+waxSeal.getWidth(), topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
        polygon.addPoint(positions.xSell, topLeft.y+y-(int)(positions.lineHeight*0.8)+waxSeal.getHeight());
        polygons.add(polygon, new SellProxyAction(ware,this));
      }
      // Footer buttons
      y = bg.getHeight()-getInset().bottom-positions.lineHeight;
      x = getInset().left+30;
      int footerWidth = bg.getWidth()-getInset().left-getInset().right-2*30;
      // 1 item
      g2d.setColor(new Color(0xEA,0xC1,0x17)); // Gold
      NamedPolygon polygon;
      g2d.drawImage(waxSeal, x,y-(int)(positions.lineHeight*0.8), null);
      polygon = new NamedPolygon("One");
      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 TransferAmountChangeAction(ETransferAmount.ONE));
      gv = opPainter.createGlyphVector(g2d, "1", 18);
      int xPadding = imageUtils.computeCenterAlignX(x, waxSeal.getWidth(), (int)gv.getVisualBounds().getWidth());
      g2d.drawGlyphVector(gv, xPadding, y);
      x += footerWidth/4;
      // 5 items
      g2d.drawImage(waxSeal, x,y-(int)(positions.lineHeight*0.8), null);
      polygon = new NamedPolygon("five");
      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 TransferAmountChangeAction(ETransferAmount.FIVE));
      gv = opPainter.createGlyphVector(g2d, "5", 18);
      xPadding = imageUtils.computeCenterAlignX(x, waxSeal.getWidth(), (int)gv.getVisualBounds().getWidth());
      g2d.drawGlyphVector(gv, xPadding, y); // centeralign
      x += footerWidth/4;
      // Max item
      g2d.drawImage(waxSeal, x,y-(int)(positions.lineHeight*0.8), null);
      polygon = new NamedPolygon("Max");
      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 TransferAmountChangeAction(ETransferAmount.MAX));
      gv = opPainter.createGlyphVector(g2d, "Max", 18); //externalize
      xPadding = imageUtils.computeCenterAlignX(x, waxSeal.getWidth(), (int)gv.getVisualBounds().getWidth());
      g2d.drawGlyphVector(gv, xPadding, y); // centeralign
      x += footerWidth/4;
      // close
      g2d.drawImage(waxSeal, x,y-(int)(positions.lineHeight*0.8), null);
      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));
      gv = opPainter.createGlyphVector(g2d, "X", 18);
      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

    AmountablePrice amounable = getStoredAmount(ware, ship, office);
    int storedAmount =amounable.getAmount();
    int value = 0;
    if (storedAmount>0){
      value = amounable.getAVGPrice();
      GlyphVector gv = opPainter.createGlyphVector(g2d, String.valueOf(value), 18);
      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
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.