Package java.awt.font

Examples of java.awt.font.GlyphVector


   * @throws FontFormatException
   * @throws IOException
   */
  private void drawBalanceRow(Graphics2D g2d, BufferedImage coin, int y, int lastWeek, int forcaset) throws FontFormatException, IOException{
    int xPadding = positions.lastWeek;
    GlyphVector gv = opPainter.createGlyphVector(g2d, String.valueOf(lastWeek), 18);
    g2d.drawGlyphVector(gv, xPadding, y);
    g2d.drawImage(coin, (int)(xPadding+gv.getVisualBounds().getWidth())+5, y-positions.lineHeight*2/3, null);
   
    xPadding = positions.forecast;
    gv = opPainter.createGlyphVector(g2d, String.valueOf(forcaset), 18);
    g2d.drawGlyphVector(gv, xPadding, y);
    g2d.drawImage(coin, (int)(xPadding+gv.getVisualBounds().getWidth())+5, y-positions.lineHeight*2/3, null);
  }
View Full Code Here


    DisplayImageDIResolver resolver = DisplayImageDIResolver.getInstance();
    fontLoader =resolver.getFontLoader();
    opPainter = resolver.getOpenPatricianPainter();
    int size;
    try {
      GlyphVector gv = opPainter.createGlyphVector((Graphics2D)scrollDown.getGraphics(), "8ypg", fontLoader.createDefaultFont(18));
      size = (int)Math.ceil(gv.getVisualBounds().getHeight());
    } catch (Exception e) {
      logger.warn("Error initializing font", e);
      size = 35;
    }
    font18Height=size;
View Full Code Here

    Graphics2D g2d = (Graphics2D) fullNotice.getGraphics();
    g2d.setColor(ColorProvider.getStringColor(((TradingOfficeDialogMataData)metaData).balance));
    Font font =fontLoader.createDefaultFont(18);
    font = font.deriveFont(Font.BOLD);
    String s = "Balance sheet"; // TODO externalize
    GlyphVector gv = opPainter.createGlyphVector(g2d, s, font);
    int x = insets.left+(int)Math.ceil((width-gv.getVisualBounds().getWidth())/2);
    int y = insets.top+topOffset+2/3*font18Height;
    g2d.drawGlyphVector(gv, x, y);
    if (((TradingOfficeDialogMataData)metaData).balance!=EStringSelectionState.DISABLE){
      addOffsetPolygon(bounds, gv, x, y,"BalanceDialog",new TradingOfficeChangeAction(ENoticeItem.TO_BALANCE));
    }
   

    s = "Personal"; // TODO externalize
    gv = opPainter.createGlyphVector(g2d, s, font);
    y += lineSpacing+font18Height;
    x = insets.left+(int)Math.ceil((width-gv.getVisualBounds().getWidth())/2);
    g2d.setColor(ColorProvider.getStringColor(((TradingOfficeDialogMataData)metaData).personal));
    g2d.drawGlyphVector(gv, x, y);
    if (((TradingOfficeDialogMataData)metaData).personal!=EStringSelectionState.DISABLE){
      addOffsetPolygon(bounds, gv, x, y,"PersonalDialog",new TradingOfficeChangeAction(ENoticeItem.TO_PERSONAL));
    }

    s = "Consumtion/Production"; // TODO externalize
    gv = opPainter.createGlyphVector(g2d, s, font);
    y += lineSpacing+font18Height;
    x = insets.left+(int)Math.ceil((width-gv.getVisualBounds().getWidth())/2);
    g2d.setColor(ColorProvider.getStringColor(((TradingOfficeDialogMataData)metaData).consumtionProduction));
    g2d.drawGlyphVector(gv, x, y);
    if (((TradingOfficeDialogMataData)metaData).consumtionProduction!=EStringSelectionState.DISABLE){
      addOffsetPolygon(bounds, gv, x, y,"ConsumptionProductionDialog",new TradingOfficeChangeAction(ENoticeItem.TO_CONSUMPTION_PRODUCTION));
    }

    s = "Weapons"; // TODO externalize
    gv = opPainter.createGlyphVector(g2d, s, font);
    y += lineSpacing+font18Height;
    x = insets.left+(int)Math.ceil((width-gv.getVisualBounds().getWidth())/2);
    g2d.setColor(ColorProvider.getStringColor(((TradingOfficeDialogMataData)metaData).weapons));
    g2d.drawGlyphVector(gv, x, y);
    if (((TradingOfficeDialogMataData)metaData).weapons!=EStringSelectionState.DISABLE){
      addOffsetPolygon(bounds, gv, x, y,"WeaponsDialog",new TradingOfficeChangeAction(ENoticeItem.TO_WEAPONS));
    }
   
    s = "Warehouses"; // TODO externalize
    gv = opPainter.createGlyphVector(g2d, s, font);
    y += lineSpacing+font18Height;
    x = insets.left+(int)Math.ceil((width-gv.getVisualBounds().getWidth())/2);
    g2d.setColor(ColorProvider.getStringColor(((TradingOfficeDialogMataData)metaData).warehouses));
    g2d.drawGlyphVector(gv, x, y);
    if (((TradingOfficeDialogMataData)metaData).warehouses!=EStringSelectionState.DISABLE){
      addOffsetPolygon(bounds, gv, x, y,"WarehouseDialog",new TradingOfficeChangeAction(ENoticeItem.TO_WAREHOUSES));
    }

    s = "Storage Manager/Trading"; // TODO externalize
    gv = opPainter.createGlyphVector(g2d, s, font);
    y += lineSpacing+font18Height;
    x = insets.left+(int)Math.ceil((width-gv.getVisualBounds().getWidth())/2);
    g2d.setColor(ColorProvider.getStringColor(((TradingOfficeDialogMataData)metaData).storageManager));
    logger.debug("Draw string '"+s+"' at "+x+","+y);
    g2d.drawGlyphVector(gv, x, y);
    if (((TradingOfficeDialogMataData)metaData).storageManager!=EStringSelectionState.DISABLE){
      addOffsetPolygon(bounds, gv, x, y,"OfficeTraidingDialog",new TradingOfficeChangeAction(ENoticeItem.TO_OFFICE_TRADING));
View Full Code Here

    Graphics2D g2d = (Graphics2D) fullNotice.getGraphics();
    g2d.setColor(ColorProvider.getStringColor(((MarketBoothDialogMetaData)metaData).stockPrices));
    Font font =fontLoader.createDefaultFont(18);
    font = font.deriveFont(Font.BOLD);
    String s = "Stock and Prices"; // TODO externalize
    GlyphVector gv = opPainter.createGlyphVector(g2d, s, font);
    int x = insets.left+(int)Math.ceil((width-gv.getVisualBounds().getWidth())/2);
    int y = insets.top+topOffset+2/3*font18Height;
    g2d.drawGlyphVector(gv, x, y);
    if (((MarketBoothDialogMetaData)metaData).stockPrices!=EStringSelectionState.DISABLE){
      addOffsetPolygon(bounds, gv, x, y,"TradingStockDialog",new MarketBoothChangeAction(ENoticeItem.MB_STOCK_PRICES));
    }
   

    s = "Consumtion/Production"; // TODO externalize
    gv = opPainter.createGlyphVector(g2d, s, font);
    y += lineSpacing+font18Height;
    x = insets.left+(int)Math.ceil((width-gv.getVisualBounds().getWidth())/2);
    g2d.setColor(ColorProvider.getStringColor(((MarketBoothDialogMetaData)metaData).consumtionProduction));
    g2d.drawGlyphVector(gv, x, y);
    if (((MarketBoothDialogMetaData)metaData).consumtionProduction!=EStringSelectionState.DISABLE){
      addOffsetPolygon(bounds, gv, x, y,"ConsumptionProductionDialog",new MarketBoothChangeAction(ENoticeItem.MB_CONSUMPTION_PRODUCTION));
    }   
View Full Code Here

    font = font.deriveFont(Font.BOLD);
    String s = "City <- -> Ship";// TODO externalize
    if (((TradeDialogMetaData)metaData).getCityProxy().getActiveShip() instanceof IConvoy){
      s = "City <- -> Convoy";// TODO externalize
    }
    GlyphVector gv = opPainter.createGlyphVector(g2d, s, font);
    int x = insets.left+(int)Math.ceil((width-gv.getVisualBounds().getWidth())/2);
    int y = insets.top+topOffset+2/3*font18Height;
    g2d.drawGlyphVector(gv, x, y);
    if (((TradeDialogMetaData)metaData).city2ship!=EStringSelectionState.DISABLE){
      addOffsetPolygon(bounds, gv, x, y,"City2ShipTradeDialog",new TradeDialogeChangeAction(ETransferDialogType.CITY_TO_SHIP));
    }
   
    g2d.setColor(ColorProvider.getStringColor(((TradeDialogMetaData)metaData).office2ship));
    s = "Ship <- -> Trading Office";
    if (((TradeDialogMetaData)metaData).getCityProxy().getActiveShip() instanceof IConvoy){
      s = "Convoy <- -> Trading Office";// TODO externalize
    }
    gv = opPainter.createGlyphVector(g2d, s, font);
    y += lineSpacing+font18Height;
    x = insets.left+(int)Math.ceil((width-gv.getVisualBounds().getWidth())/2);
    g2d.drawGlyphVector(gv, x, y);
    if (((TradeDialogMetaData)metaData).office2ship!=EStringSelectionState.DISABLE){
      addOffsetPolygon(bounds, gv, x, y,"Ship2StorageTradeDialog",new TradeDialogeChangeAction(ETransferDialogType.STORAGE_TO_SHIP));
    }
   
    g2d.setColor(ColorProvider.getStringColor(((TradeDialogMetaData)metaData).city2office));
    s = "City <- -> Trading Office";// TODO externalize
    gv = opPainter.createGlyphVector(g2d, s, font);
    y += lineSpacing+font18Height;
    x = insets.left+(int)Math.ceil((width-gv.getVisualBounds().getWidth())/2);
    g2d.drawGlyphVector(gv, x, y);
    if (((TradeDialogMetaData)metaData).city2office!=EStringSelectionState.DISABLE){
      addOffsetPolygon(bounds, gv, x, y,"City2StorageTradeDialog",new TradeDialogeChangeAction(ETransferDialogType.CITY_TO_STORAGE));
    }
   
    g2d.setColor(ColorProvider.getStringColor(((TradeDialogMetaData)metaData).weapons));
    s = "Weapons";// TODO externalize
    gv = opPainter.createGlyphVector(g2d, s, font);
    y += lineSpacing+font18Height;
    x = insets.left+(int)Math.ceil((width-gv.getVisualBounds().getWidth())/2);
    g2d.drawGlyphVector(gv, x, y);
    if (((TradeDialogMetaData)metaData).weapons!=EStringSelectionState.DISABLE){
      addOffsetPolygon(bounds, gv, x, y,"WeaponsTradeDialog",new TradeDialogeChangeAction(ETransferDialogType.WEAPON));
    }
  }
View Full Code Here

            g2d.setComposite(fSelected
                    ? AlphaComposite.DstOut : AlphaComposite.SrcOver);
            // calculate the bottom left point to draw the text at.
            Font font = g2d.getFont();
            FontRenderContext renderContext = g2d.getFontRenderContext();
            GlyphVector glyphVector = font.createGlyphVector(renderContext, getText());
            Rectangle visualBounds = glyphVector.getVisualBounds().getBounds();
            int x = getWidth() / 2 - g2d.getFontMetrics().stringWidth(getText()) / 2;
            int y = getHeight() / 2 - visualBounds.height / 2 - visualBounds.y;

            // draw the badge text.
            g2d.drawString(getText(), x, y);
View Full Code Here

      dummyFont.createGlyphVector(
        new FontRenderContext(null, antialiasOn_, false),
        phrase_
      );
     
      GlyphVector glyphVector = font_.createGlyphVector(
        new FontRenderContext(null, antialiasOn_, false),
        phrase_
      );   
      // Use precedent set by applications like MS Word to place
      // glyph vector in the canvas:
      // 1. If the total width of the glyph vector is less than the
      //   width of the canvas, the glyph vector will be horizontally centered
      //   in the canvas; else the glyph vector will be left-aligned
      // 2. If the total height of the glyph vector is less than the height of
      //   the canvas, the glyph vector will be vertically centered in the
      //   canvas; else the glyph vector will be bottom-aligned
      Rectangle2D logicalBounds = glyphVector.getLogicalBounds();
      double x;
      if (logicalBounds.getWidth() < this.getWidth()) {
        x = (this.getWidth()/2) - (logicalBounds.getWidth()/2);
      }
      else { x = 0; }
View Full Code Here

        RenderingHints.VALUE_ANTIALIAS_ON);
    graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
        RenderingHints.VALUE_INTERPOLATION_BICUBIC);

    // Create glyph vector
    GlyphVector gv = myfont.createGlyphVector(graphics.getFontRenderContext(), c);

    // Calculate scale
    Rectangle2D bounds = gv.getLogicalBounds();
    double xscale = (image_size - glyph_pad) / bounds.getWidth();
    double yscale = (image_size - glyph_pad) / bounds.getHeight();
    double scale;  // Global scale to be applied (do not distort)
    if (xscale > yscale) scale = xscale;
    else scale = yscale;


    double midx = (bounds.getMinX() + bounds.getMaxX()) / 2 * scale;
    double midy = (bounds.getMinY() + bounds.getMaxY()) / 2 * scale;


    AffineTransform at = AffineTransform.getScaleInstance(scale, scale);

    // The commented code below does not work on Macs.
/*    //graphics.setTransform(at);
    gv.setGlyphTransform(0, at);

    Rectangle2D rbounds = gv.getGlyphPixelBounds(0, null, 0, 0)
          .getBounds2D();

    gv.setGlyphTransform(0, null);

    double midx = (rbounds.getMinX() + rbounds.getMaxX()) / 2;
    double midy = (rbounds.getMinY() + rbounds.getMaxY()) / 2;

    System.out.println(rbounds.getMinX() + " " + rbounds.getMinY()
      + " " + rbounds.getMaxX() + " " + rbounds.getMaxY());*/

    // Set transform
    at = AffineTransform.getTranslateInstance(image_size/2.0 -midx, image_size/2.0 -midy);
    at.concatenate(AffineTransform.getScaleInstance(scale, scale));
    graphics.setTransform(at);

    // Draw glyph
    graphics.setColor(new Color(0, 0, 0));
    graphics.fill(gv.getOutline());

    return bi;

  }
View Full Code Here

    /** @see TextHandler#drawString(java.lang.String, float, float) */
    public void drawString(String text, float x, float y) {
        java.awt.Font awtFont = g2d.getFont();
        FontRenderContext frc = g2d.getFontRenderContext();
        GlyphVector gv = awtFont.createGlyphVector(frc, text);
        Shape glyphOutline = gv.getOutline(x, y);
        g2d.fill(glyphOutline);
    }
View Full Code Here

        char[] chars = { (char) code };
       
        if (!font.canDisplay((char) code))
            return null;
       
        GlyphVector gv = font.createGlyphVector(frc, chars);
        Shape glyph_shape = new Shape();
        glyph_shape.drawAWTPathIterator(gv.getGlyphOutline(0).getPathIterator(trans));
        GlyphMetrics gm = gv.getGlyphMetrics(0);
       
        //    FontDefinition.Glyph g = new FontDefinition.Glyph(s, metrics.charWidth(chars[0]) * scale, code);
        FontDefinition.Glyph g = new FontDefinition.Glyph(glyph_shape, gm.getAdvanceX() * scale, code);
       
        return g;
View Full Code Here

TOP

Related Classes of java.awt.font.GlyphVector

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.