Examples of HSSFColor


Examples of org.apache.poi.hssf.util.HSSFColor

    {
        super.initialize(attributes, parent);
        EPStyle pstyle = (EPStyle)getAncestor(EPStyle.class);
        if ((pstyle != null) && pstyle.isValid()) {
            Hashtable colorhash = pstyle.getColorHash();       
            HSSFColor color = null;

            HSSFCellStyle style = pstyle.getStyle()//oops a little confusing
                                                      //below is the style attribute
                                                      //this is an HSSFCellStyle
                                                      //associated with EPStyle
            style.setBorderRight((short)getStyle());

            ColorCode colorCode = getColor();
            if (colorCode != null) {
                color = (HSSFColor)colorhash.get(colorCode.toString());
            }
            if (color == null) color = new HSSFColor.BLACK();


            style.setRightBorderColor(color.getIndex());
        }
       
    }       
View Full Code Here

Examples of org.apache.poi.hssf.util.HSSFColor

        Map colors = HSSFColor.getIndexHash();
        Iterator indexes = colors.keySet().iterator();
        while (indexes.hasNext())
        {
            Integer index = (Integer) indexes.next();
            HSSFColor c = (HSSFColor) colors.get(index);
            short[] rgbTriplet = c.getTriplet();
            byte[] paletteTriplet = palette.getColor(index.shortValue());
            String msg = "Expected HSSFColor constant to match PaletteRecord at index 0x"
                + Integer.toHexString(c.getIndex());
            assertEquals(msg, rgbTriplet[0], paletteTriplet[0] & 0xff);
            assertEquals(msg, rgbTriplet[1], paletteTriplet[1] & 0xff);
            assertEquals(msg, rgbTriplet[2], paletteTriplet[2] & 0xff);
        }
    }
View Full Code Here

Examples of org.apache.poi.hssf.util.HSSFColor

    /** This method retrieves the AWT Color representation from the colour hash table
     *
     */
    private final Color getAWTColor(int index, Color deflt) {
      HSSFColor clr = (HSSFColor)colors.get(new Integer(index));
      if (clr == null) return deflt;
      return getAWTColor(clr);
    }
View Full Code Here

Examples of org.apache.poi.hssf.util.HSSFColor

           
            if (getShade() == 1) {   //TODO: change to constant when upgrade to new HSSF
                                     //solid w/foreground, bg doesn't matter
                getLogger().debug("shade = 1");
                HSSFColor color = (HSSFColor) colorhash.get(getBackgroundColor().toString());
                if (color == null) {
                    getLogger().debug("s1 BG couldn't find color for "+ getBackgroundColor().toString());
                    color = new HSSFColor.WHITE();          
                }
                style.setFillForegroundColor(color.getIndex());
                color = (HSSFColor) colorhash.get(getPatternColor().toString());
                if (color == null) {
                    getLogger().debug("s1 PC couldn't find color for "+ getPatternColor().toString());
                    color = new HSSFColor.BLACK();  
                }
                style.setFillBackgroundColor(color.getIndex());
            } else {
                HSSFColor color = (HSSFColor) colorhash.get(getBackgroundColor().toString());
                if (color == null) {               
                    getLogger().debug("BG couldn't find color for "+ getBackgroundColor().toString());
                    color = new HSSFColor.BLACK();  
                }
                style.setFillBackgroundColor(color.getIndex());           
                color = (HSSFColor) colorhash.get(getPatternColor().toString());
                if (color == null) {
                    getLogger().debug("PC couldn't find color for "+ getPatternColor().toString());
                    color = new HSSFColor.WHITE();    
                }
                style.setFillForegroundColor(color.getIndex());           
            }
            style.setWrapText(getWrapText());
            style.setLocked(true);
           
            String format = null;
View Full Code Here

Examples of org.apache.poi.hssf.util.HSSFColor

    {
        super.initialize(attributes, parent);
        EPStyle pstyle = (EPStyle) getAncestor(EPStyle.class);
        if ((pstyle != null) && pstyle.isValid()) {
            Hashtable colorhash = pstyle.getColorHash();       
            HSSFColor color = null;

            HSSFCellStyle style = pstyle.getStyle()//oops a little confusing
                                                      //below is the style attribute
                                                      //this is an HSSFCellStyle
                                                      //associated with EPStyle
            style.setBorderBottom((short)getStyle());

            ColorCode colorCode = getColor();
            if (colorCode != null) {
                color = (HSSFColor)colorhash.get(colorCode.toString());
            }
            if (color == null) color = new HSSFColor.BLACK();


            style.setBottomBorderColor(color.getIndex());
        }
       
    }   
View Full Code Here

Examples of org.apache.poi.hssf.util.HSSFColor

           
            if (getShade() == 1) {   //TODO: change to constant when upgrade to new HSSF
                                     //solid w/foreground, bg doesn't matter
                getLogger().debug("shade = 1");
                HSSFColor color = (HSSFColor) colorhash.get(getBackgroundColor().toString());
                if (color == null) {
                    getLogger().debug("s1 BG couldn't find color for "+ getBackgroundColor().toString());
                    color = new HSSFColor.WHITE();          
                }
                style.setFillForegroundColor(color.getIndex());
                color = (HSSFColor) colorhash.get(getPatternColor().toString());
                if (color == null) {
                    getLogger().debug("s1 PC couldn't find color for "+ getPatternColor().toString());
                    color = new HSSFColor.BLACK();  
                }
                style.setFillBackgroundColor(color.getIndex());
            } else {
                HSSFColor color = (HSSFColor) colorhash.get(getBackgroundColor().toString());
                if (color == null) {               
                    getLogger().debug("BG couldn't find color for "+ getBackgroundColor().toString());
                    color = new HSSFColor.BLACK();  
                }
                style.setFillBackgroundColor(color.getIndex());           
                color = (HSSFColor) colorhash.get(getPatternColor().toString());
                if (color == null) {
                    getLogger().debug("PC couldn't find color for "+ getPatternColor().toString());
                    color = new HSSFColor.WHITE();    
                }
                style.setFillForegroundColor(color.getIndex());           
            }
            style.setWrapText(getWrapText());
            style.setLocked(true);
        } else {
           
View Full Code Here

Examples of org.apache.poi.hssf.util.HSSFColor

    final HSSFRow row = sheetAt.getRow(0);
    final HSSFCell cell0 = row.getCell(0);

    // assert that we are in the correct export type ..
    final HSSFCellStyle cellStyle = cell0.getCellStyle();
    final HSSFColor fillBackgroundColorColor = cellStyle.getFillBackgroundColorColor();
    final HSSFColor fillForegroundColorColor = cellStyle.getFillForegroundColorColor();
    assertEquals("0:0:0", fillBackgroundColorColor.getHexString());
    assertEquals("FFFF:FFFF:9999", fillForegroundColorColor.getHexString());

    // assert that there are no extra columns ..
    final HSSFRow row8 = sheetAt.getRow(7);
    assertNull(row8);
View Full Code Here

Examples of org.apache.poi.hssf.util.HSSFColor

      // we ran out of palette... try to get nearest color then
      return StaticExcelColorSupport.getNearestColor(awtColor, usedTripplets);
    }

    final HSSFPalette palette = workbook.getCustomPalette();
    final HSSFColor hssfColor = palette.findColor((byte) awtColor.getRed(),
        (byte) awtColor.getGreen(),
        (byte) awtColor.getBlue());

    if (hssfColor != null && hssfColor.getIndex() < lastUsedColor)
    {
      return hssfColor.getIndex();
    }
    else
    {
      palette.setColorAtIndex(lastUsedColor, (byte) awtColor.getRed(),
          (byte) awtColor.getGreen(),
          (byte) awtColor.getBlue());
      final HSSFColor color = palette.getColor(lastUsedColor);
      usedTripplets.put(color.getHexString(), color);
      return lastUsedColor++;
    }
  }
View Full Code Here

Examples of org.apache.poi.hssf.util.HSSFColor

    float[] excelHsb = null;
    final Iterator elements = triplets.values().iterator();
    while (elements.hasNext())
    {
      final HSSFColor crtColor = (HSSFColor) elements.next();
      final short[] rgb = crtColor.getTriplet();
      excelHsb = Color.RGBtoHSB(rgb[0], rgb[1], rgb[2], excelHsb);

      final double weight =
              3.0 * (Math.min
                  (Math.abs(excelHsb[0] - hsb[0]),
                   Math.abs(excelHsb[0] - hsb[0] + 1))) +
              Math.abs(excelHsb[1] - hsb[1]) +
              Math.abs(excelHsb[2] - hsb[2]);

      if (weight < minDiff)
      {
        minDiff = weight;
        if (minDiff == 0)
        {
          // we found the color ...
          return crtColor.getIndex();
        }
        color = crtColor.getIndex();
      }
    }
    return color;
  }
View Full Code Here

Examples of org.apache.poi.hssf.util.HSSFColor

  }

  public HSSFColor getColor(final short index)
  {
    final Integer s = IntegerCache.getInteger(index);
    final HSSFColor color = (HSSFColor) indexes.get(s);
    if (color == null)
    {
      throw new IllegalStateException("No such color.");
    }
    return color;
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.