Examples of findSimilarColor()


Examples of org.apache.poi.hssf.usermodel.HSSFPalette.findSimilarColor()

            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.usermodel.HSSFPalette.findSimilarColor()

    byte red = (byte) color.getRed();
    byte green = (byte) color.getGreen();
    byte blue = (byte) color.getBlue();
    HSSFPalette palette = workbook.getCustomPalette();

    HSSFColor c = palette.findSimilarColor(red, green, blue);
    if (c == null) {
      try {
        c = palette.addColor(red, green, blue);
      } catch (RuntimeException e) {
        c = palette.findSimilarColor(red, green, blue);
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFPalette.findSimilarColor()

    HSSFColor c = palette.findSimilarColor(red, green, blue);
    if (c == null) {
      try {
        c = palette.addColor(red, green, blue);
      } catch (RuntimeException e) {
        c = palette.findSimilarColor(red, green, blue);
      }
    }
    return c;
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFPalette.findSimilarColor()

       
        /* first test the defaults */
        assertTrue(
            Arrays.equals(
                new short[] {(short) 255, (short) 255, (short) 0}, // not [204, 255, 255]
                p.findSimilarColor((byte) 204, (byte) 255, (byte) 0).getTriplet()
            )
        );

        assertTrue(
            Arrays.equals(
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFPalette.findSimilarColor()

        );

        assertTrue(
            Arrays.equals(
                new short[] {(short) 153, (short) 204, (short) 0}, // not [128, 0, 0]
                p.findSimilarColor((byte) 128, (byte) 255, (byte) 0).getTriplet()
            )
        );

        assertTrue(
            Arrays.equals(
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFPalette.findSimilarColor()

        );

        assertTrue(
            Arrays.equals(
                new short[] {(short) 0, (short) 255, (short) 0}, // not [0, 51, 102]
                p.findSimilarColor((byte) 0, (byte) 255, (byte) 102).getTriplet()
            )
        );

        assertTrue(
            Arrays.equals(
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFPalette.findSimilarColor()

        );

        assertTrue(
            Arrays.equals(
                new short[] {(short) 0, (short) 102, (short) 204}, // not [255, 102, 0]
                p.findSimilarColor((byte) 0, (byte) 102, (byte) 255).getTriplet()
            )
        );

        assertTrue(
            Arrays.equals(
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFPalette.findSimilarColor()

        );

        assertTrue(
            Arrays.equals(
                new short[] {(short) 255, (short) 0, (short) 255}, // not [128, 0, 0]
                p.findSimilarColor((byte) 128, (byte) 0, (byte) 255).getTriplet()
            )
        );

        assertTrue(
            Arrays.equals(
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFPalette.findSimilarColor()

        );

        assertTrue(
            Arrays.equals(
                new short[] {(short) 255, (short) 0, (short) 255}, // not [255, 255, 153]
                p.findSimilarColor((byte) 255, (byte) 0, (byte) 153).getTriplet()
            )
        );


        // Add a few edge colours in
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFPalette.findSimilarColor()

        );

        // Now check we get the right stuff back
        assertEquals(
                p.getColor((short)8).getHexString(),
                p.findSimilarColor((byte)-1, (byte)0, (byte)0).getHexString()
        );
        assertEquals(
                p.getColor((short)8).getHexString(),
                p.findSimilarColor((byte)-2, (byte)0, (byte)0).getHexString()
        );
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.