Examples of HSSFColor


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(Integer.valueOf(index));
      if (clr == null) return deflt;
      return getAWTColor(clr);
    }
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

        fis = new FileInputStream(temp);
        book = new HSSFWorkbook(fis);
        fis.close();
       
        palette = book.getCustomPalette();
        HSSFColor color = palette.getColor(HSSFColor.CORAL.index)//unmodified
        assertNotNull("Unexpected null in custom palette (unmodified index)", color);
        short[] expectedRGB = HSSFColor.CORAL.triplet;
        short[] actualRGB = color.getTriplet();
        String msg = "Expected palette position to remain unmodified";
        assertEquals(msg, expectedRGB[0], actualRGB[0]);
        assertEquals(msg, expectedRGB[1], actualRGB[1]);
        assertEquals(msg, expectedRGB[2], actualRGB[2]);
       
        color = palette.getColor((short) 0x12);
        assertNotNull("Unexpected null in custom palette (modified)", color);
        actualRGB = color.getTriplet();
        msg = "Expected palette modification to be preserved across save";
        assertEquals(msg, (short) 101, actualRGB[0]);
        assertEquals(msg, (short) 230, actualRGB[1]);
        assertEquals(msg, (short) 100, actualRGB[2]);
    }
View Full Code Here

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

        Map colors = HSSFColor.getIndexHash();
        Iterator it = colors.keySet().iterator();
        while (it.hasNext())
        {
            Number index = (Number) it.next();
            HSSFColor expectedColor = (HSSFColor) colors.get(index);
            HSSFColor paletteColor = hssfPalette.getColor(index.shortValue());
            c.compare(expectedColor, paletteColor);
        }
    }
View Full Code Here

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

    public void testAddColor() throws Exception
    {
        try
        {
            HSSFColor hssfColor = hssfPalette.addColor((byte)10,(byte)10,(byte)10);
            fail();
        }
        catch ( RuntimeException e )
        {
            // Failing because by default there are no colours left in the palette.
View Full Code Here

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

        textbox.setString( s );
    }

    private HSSFFont matchFont( Font font )
    {
        HSSFColor hssfColor = workbook.getCustomPalette()
                .findColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
        if (hssfColor == null)
            hssfColor = workbook.getCustomPalette().findSimilarColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue());
        boolean bold = (font.getStyle() & Font.BOLD) != 0;
        boolean italic = (font.getStyle() & Font.ITALIC) != 0;
        HSSFFont hssfFont = workbook.findFont(bold ? HSSFFont.BOLDWEIGHT_BOLD : 0,
                    hssfColor.getIndex(),
                    (short)(font.getSize() * 20),
                    font.getName(),
                    italic,
                    false,
                    (short)0,
                    (byte)0);
        if (hssfFont == null)
        {
            hssfFont = workbook.createFont();
            hssfFont.setBoldweight(bold ? HSSFFont.BOLDWEIGHT_BOLD : 0);
            hssfFont.setColor(hssfColor.getIndex());
            hssfFont.setFontHeight((short)(font.getSize() * 20));
            hssfFont.setFontName(font.getName());
            hssfFont.setItalic(italic);
            hssfFont.setStrikeout(false);
            hssfFont.setTypeOffset((short) 0);
View Full Code Here

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

          Font font = new Font(f.getFontName(),fontstyle,fontheight);
          setFont(font);
         

          HSSFColor clr = null;
          if (s.getFillPattern() == HSSFCellStyle.SOLID_FOREGROUND) {
            clr = (HSSFColor)colors.get(new Integer(s.getFillForegroundColor()));
          }
          if (clr == null) clr = new HSSFColor.WHITE();

          short[] rgb = clr.getTriplet();
          Color awtcolor = new Color(rgb[0],rgb[1],rgb[2]);

          setBackground(awtcolor);

          clr = (HSSFColor)colors.get(new Integer(f.getColor()));
          if (clr == null) clr = new HSSFColor.BLACK();
          rgb = clr.getTriplet();
          awtcolor = new Color(rgb[0],rgb[1],rgb[2]);
          setForeground(awtcolor);

          if (s.getBorderBottom() != HSSFCellStyle.BORDER_NONE ||
              s.getBorderTop()    != HSSFCellStyle.BORDER_NONE ||
View Full Code Here

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

            HSSFPalette palette = ((HSSFWorkbook) workbook).getCustomPalette();
            byte r = toRgb(color.getRed());
            byte g = toRgb(color.getGreen());
            byte b = toRgb(color.getBlue());

            HSSFColor index = palette.findColor(r, g, b);
            if (index == null) {
                index = palette.findSimilarColor(r, g, b);
            }
            return index.getIndex();
        }
        throw new IllegalStateException("Unexpected workbook type: " + workbook.getClass());
    }
View Full Code Here

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

        {
            // no fill
        }
        else if ( cellStyle.getFillPattern() == 1 )
        {
            final HSSFColor foregroundColor = cellStyle
                    .getFillForegroundColorColor();
            if ( foregroundColor != null )
                cellTarget.setAttribute( "background-color",
                        ExcelToFoUtils.getColor( foregroundColor ) );
        }
        else
        {
            final HSSFColor backgroundColor = cellStyle
                    .getFillBackgroundColorColor();
            if ( backgroundColor != null )
                cellTarget.setAttribute( "background-color",
                        ExcelToHtmlUtils.getColor( backgroundColor ) );
        }
View Full Code Here

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

            return;

        StringBuilder borderStyle = new StringBuilder();
        borderStyle.append( ExcelToHtmlUtils.getBorderWidth( xlsBorder ) );

        final HSSFColor color = workbook.getCustomPalette().getColor(
                borderColor );
        if ( color != null )
        {
            borderStyle.append( ' ' );
            borderStyle.append( ExcelToHtmlUtils.getColor( 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.