Package com.extentech.formats.XLS

Examples of com.extentech.formats.XLS.Font


      StringBuffer svg= new StringBuffer();
   
      float[] coords= this.getCoords();
    coords[0]= (int)Math.ceil(Pos.convertFromSPRC(coords[0], chartMetrics.get("canvasw").floatValue(), 0))-3
    coords[1]= (int)Math.ceil(Pos.convertFromSPRC(coords[1], 0, chartMetrics.get("canvash").floatValue()));
    Font fx = this.getFont(wkbook);

    svg.append("<g>\r\n")
    float fh=10;
    if (fx!=null) fh= (float)fx.getFontHeightInPoints();
    float x= (float) (chartMetrics.get("x") + chartMetrics.get("w")/2);
    float y= (float) (chartMetrics.get("TITLEOFFSET").floatValue() + fh)/2;
    Frame f= (Frame) Chart.findRec(this.chartArr, Frame.class);
    if (f!=null) {
      coords[0]= coords[0]+x;
      coords[1]= y+coords[1]+fh;
      coords[3]= fh*2// just a test really
      svg.append(f.getSVG(coords));
    } else {
      coords[0]= x;
      coords[1]= y+fh/2;
    }
     
    svg.append("<text " + GenericChartObject.getScript("charttitle") + " x='" + (coords[0]) + "' y='" + (coords[1]) + "' style='text-anchor: middle;' alignment-baseline='text-after-edge' ");
    if(fx != null)
      svg.append(" " + fx.getSVG() + ">");
    else
      svg.append(" font-family='Arial' font-size='14pt' font-weight='bold'>");         
    svg.append(this.toString() + "</text>\r\n");
    svg.append("</g>\r\n");
    return svg;
View Full Code Here


    this.wbh= d.wbh;
  }
 
  public Dxf() {   }
    public static OOXMLElement parseOOXML(XmlPullParser xpp, WorkBookHandle bk) {
      Font fnt= null;
      NumFmt nf= null;
      Fill f= null;
      Alignment a= null;
      Border b= null;
      try {
View Full Code Here

 
  /**
   * for BIFF8->OOXML Compatiblity, create a dxf from Cf style info
   */
  public void createFont(int w, boolean i, int ustyle, int cl, int h) {
    font= new Font("", w, h);
    if (w==700)
      font.setBold(true)// why doesn't constructor do this?
    if (i) font.setItalic(i);
    if (ustyle!=0) font.setUnderlineStyle((byte) ustyle);
    font.setColor(cl);
View Full Code Here

            if(eventType == XmlPullParser.START_TAG) {
              String tnm= xpp.getName();
              if (tnm.equals("rPr")) {  // intra-string formatting properties
                int idx= s.length()// index into character string to apply formatting to
                Ss_rPr rp= (Ss_rPr) Ss_rPr.parseOOXML(xpp, bk)//.cloneElement();                        
                Font f= rp.generateFont(bk)// NOW CONVERT ss_rPr to a font!!
                int fIndex= bk.getWorkBook().getFontIdx(f)// index for specific font formatting
                if (fIndex==-1// must insert new font
                  fIndex= bk.getWorkBook().insertFont(f)+1;
                if (formattingRuns==null) formattingRuns= new ArrayList<short[]>();
                formattingRuns.add(new short[] {Integer.valueOf(idx).shortValue(), Integer.valueOf(fIndex).shortValue()});
View Full Code Here

   * @param bk
   * @return
   */
  public Font generateFont(DocumentHandle bk) {
    // not using attributes:  charset, family, condense, extend, shadow, scheme, outline==bold
     Font f= new Font("Arial",400,200);
     Object o;
    
     o= this.getAttr("rFont");
     f.setFontName((String) o);
     o= this.getAttr("sz");
     if (o!=null) f.setFontHeight(Font.PointsToFontHeight(Double.parseDouble((String)o)));
   
    // boolean attributes
     o= this.getAttr("b");
     if (o!=nullf.setBold(true);
     o= this.getAttr("i");
     if (o!=nullf.setItalic(true);
     o= this.getAttr("u");
     if (o!=nullf.setUnderlined(true);
     o= this.getAttr("strike");
     if (o!=nullf.setStricken(true);
     o= this.getAttr("outline");
     if (o!=nullf.setBold(true);
     o= this.getAttr("vertAlign");
     if (o!=null) {
       String s= (String) o;
       if (s.equals("baseline"))
         f.setScript(0);
       else if (s.equals("superscript"))
         f.setScript(1);
       else if (s.equals("subscript"))
         f.setScript(2);
     }
     f.setOOXMLColor(color);
     return f;
  }
View Full Code Here

    Object o = textprops.get("sz"); // Whole points are specified in
                    // increments of 100 starting with 100
                    // being a point size of 1
    if (o != null)
      h = Font.PointsToFontHeight(Integer.parseInt((String) o) / 100);
    Font f = new Font(face, w, new Float(h).intValue());
    if (b)
      f.setBold(true);
    if (i)
      f.setItalic(i);
    if (u != 0)
      f.setUnderlineStyle((byte) u);
    o = textprops.get("vertAlign");
    if (o != null) {
      String s = (String) o;
      if (s.equals("baseline"))
        f.setScript(0);
      else if (s.equals("superscript"))
        f.setScript(1);
      else if (s.equals("subscript"))
        f.setScript(2);
    }
    o = textprops.get("strike");
    if (o != null)
      f.setStricken(true);
    // f.setFontColor(cl);
    return com.extentech.ExtenXLS.FormatHandle.addFont(f, wb);
  }
View Full Code Here

    
     */
    public void incrementHeight(float h) {
  Pos p= (Pos) Chart.findRec(this.chartArr, Pos.class);
  int[] coords= p.getLegendCoords()// x, y, w, h, fh, legendpos
  Font f= this.getFnt();
  int fh= 10// default
  if (f!=null)
      fh=(int)(f.getFontHeightInPoints()*1.2)// a little padding
  if (coords!=null) {
      int z= coords[1]-(int)Math.ceil(Pos.convertToSPRC(fh/2, 0, h));
      p.setY(z);
  }     
    }
View Full Code Here

     */
    public void adjustWidth(HashMap<String, Double> chartMetrics, int chartType, String[] legends) {
  Pos p= (Pos) Chart.findRec(this.chartArr, Pos.class);
  int[] coords= p.getLegendCoords()// x, y, w, h, fh, legendpos
  if (coords!=null) {
      Font f= this.getFnt();
      // legend position LEFT and RIGHT display each legend on a separate line (fVert==true)
      // TOP and BOTTOM are displayed horizontally with symbols and spacing between entries (fVert==false)     
      int position= this.getLegendPosition()
      float cw= chartMetrics.get("canvasw").floatValue();
      float x= (int)Math.ceil(Pos.convertFromSPRC(coords[0], cw, 0))-3;
      float w= chartMetrics.get("w").floatValue();
     
      // calculate how much width the legends take up -- algorithm works well for about 80% of the cases ...
      double legendsWidth= 0;
      java.awt.Font jf= new java.awt.Font(f.getFontName(), f.getFontWeight(), (int)f.getFontHeightInPoints());
      int extras= (chartType==ChartConstants.LINECHART|| chartType==ChartConstants.RADARCHART?15:5)// pad for legend symbols, etc  - 
      for (int i= 0; i < legends.length; i++) {
    if (fVert)
        legendsWidth= Math.max(legendsWidth, StringTool.getApproximateStringWidth(jf, " " + legends[i] + " "));
    else 
View Full Code Here

   * @return
   */
  public Font getFnt() {
    try {
      Fontx fx= getLegendFont();
      Font f= this.getParentChart().getWorkBook().getFont(fx.getIfnt());
      if (f!=null)
        return f;
      else  // shouldn't get here ...
        return this.getParentChart().getDefaultFont();     
    } catch (NullPointerException e) {
View Full Code Here

 
  public void getMetrics(HashMap<String, Double> chartMetrics, int chartType, ChartSeries s) {
    String[] legends= s.getLegends();
    if (legends==null || legends.length==0) return;
   
    Font f= getFnt();
    if (f!=null) {
        legendCoords= this.getCoords(chartType, chartMetrics, legends, new java.awt.Font(f.getFontName(), f.getFontWeight(), (int)f.getFontHeightInPoints()));
    } else // can't find any font ... shouldn't really happen ...?
        legendCoords= this.getCoords(chartType, chartMetrics, legends, new java.awt.Font("Arial", 400, 10));
    }
  }
View Full Code Here

TOP

Related Classes of com.extentech.formats.XLS.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.