Package org.apache.poi.hssf.util

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


    /** 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


     * @return  The closest color or null if there are no custom
     *          colors currently defined.
     */
    public HSSFColor findSimilarColor(byte red, byte green, byte blue)
    {
        HSSFColor result = null;
        int minColorDistance = Integer.MAX_VALUE;
        byte[] b = palette.getColor(PaletteRecord.FIRST_COLOR_INDEX);
        for (short i = (short) PaletteRecord.FIRST_COLOR_INDEX; b != null;
            b = palette.getColor(++i))
        {
View Full Code Here

        }
        return cellFont;
    }

    private HSSFColor getHssfColor(Color awtColor) {
        HSSFColor color = null;
        if (hssfColorMap != null && hssfColorMap.size() > 0) {
            HSSFColor crtColor = null;
            short[] rgb = null;
            int diff = 0;
            int minDiff = 999;

            for (Iterator<HSSFColor> it = hssfColorMap.values().iterator(); it.hasNext();) {
                crtColor = it.next();
                rgb = crtColor.getTriplet();
                diff = Math.abs(rgb[0] - awtColor.getRed())
                        + Math.abs(rgb[1] - awtColor.getGreen())
                        + Math.abs(rgb[2] - awtColor.getBlue());

                if (diff == 0) {
View Full Code Here

     * @return  The closest color or null if there are no custom
     *          colors currently defined.
     */
    public HSSFColor findSimilarColor(byte red, byte green, byte blue)
    {
        HSSFColor result = null;
        int minColorDistance = Integer.MAX_VALUE;
        byte[] b = palette.getColor(PaletteRecord.FIRST_COLOR_INDEX);
        for (short i = (short) PaletteRecord.FIRST_COLOR_INDEX; b != null;
            b = palette.getColor(++i))
        {
View Full Code Here

        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

        //writing to disk; reading in and verifying palette
        book = HSSFTestDataSamples.writeOutAndReadBack(book);

        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

        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

        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

        {
            // 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

            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

Related Classes of org.apache.poi.hssf.util.HSSFColor$LIGHT_BLUE

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.