org.apache.poi.ss.usermodel.Color Java Examples

The following examples show how to use org.apache.poi.ss.usermodel.Color. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StylerHelper.java    From easypoi with Apache License 2.0 5 votes vote down vote up
public void styleColor(Formatter out, String attr, Color color) {
    XSSFColor xSSFColor = (XSSFColor) color;
    if (color == null || xSSFColor.isAuto())
        return;

    byte[] rgb = xSSFColor.getRgb();
    if (rgb == null) {
        return;
    }
    out.format("  %s: #%02x%02x%02x;%n", attr, rgb[0], rgb[1], rgb[2]);
}
 
Example #2
Source File: HSSFColorScaleFormatting.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void setColors(Color[] colors) {
    ExtendedColor[] cr = new ExtendedColor[colors.length];
    for (int i=0; i<colors.length; i++) {
        cr[i] = ((HSSFExtendedColor)colors[i]).getExtendedColor();
    }
    colorFormatting.setColors(cr);
}
 
Example #3
Source File: HSSFPatternFormatting.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void setFillForegroundColor(Color fg) {
    HSSFColor hcolor = HSSFColor.toHSSFColor(fg);
    if (hcolor == null) {
        setFillForegroundColor((short)0);
    } else {
        setFillForegroundColor(hcolor.getIndex());
    }
}
 
Example #4
Source File: HSSFPatternFormatting.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void setFillBackgroundColor(Color bg) {
    HSSFColor hcolor = HSSFColor.toHSSFColor(bg);
    if (hcolor == null) {
        setFillBackgroundColor((short)0);
    } else {
        setFillBackgroundColor(hcolor.getIndex());
    }
}
 
Example #5
Source File: HSSFFontFormatting.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void setFontColor(Color color) {
    HSSFColor hcolor = HSSFColor.toHSSFColor(color);
    if (hcolor == null) {
        fontFormatting.setFontColorIndex((short)0);
    } else {
        fontFormatting.setFontColorIndex(hcolor.getIndex());
    }
}
 
Example #6
Source File: StylerHelper.java    From autopoi with Apache License 2.0 5 votes vote down vote up
private Color getColor(Font font) {
	if (helper instanceof HSSFHtmlHelper) {
		return ((HSSFWorkbook) sheet.getWorkbook()).getCustomPalette().getColor(font.getColor());
	} else {
		return ((XSSFFont) font).getXSSFColor();
	}
}
 
Example #7
Source File: HSSFColor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checked type cast <tt>color</tt> to an HSSFColor.
 *
 * @param color the color to type cast
 * @return the type casted color
 * @throws IllegalArgumentException if color is null or is not an instance of HSSFColor
 */
public static HSSFColor toHSSFColor(Color color) {
    // FIXME: this method would be more useful if it could convert any Color to an HSSFColor
    // Currently the only benefit of this method is to throw an IllegalArgumentException
    // instead of a ClassCastException.
    if (color != null && !(color instanceof HSSFColor)) {
        throw new IllegalArgumentException("Only HSSFColor objects are supported");
    }
    return (HSSFColor)color;
}
 
Example #8
Source File: StylerHelper.java    From easypoi with Apache License 2.0 5 votes vote down vote up
private Color getColor(Font font) {
    if (helper instanceof HSSFHtmlHelper) {
        return ((HSSFWorkbook) sheet.getWorkbook()).getCustomPalette()
            .getColor(font.getColor());
    } else {
        return ((XSSFFont) font).getXSSFColor();
    }
}
 
Example #9
Source File: HSSFBorderFormatting.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setTopBorderColor(Color color) {
    HSSFColor hcolor = HSSFColor.toHSSFColor(color);
    if (hcolor == null) {
        setTopBorderColor((short)0);
    } else {
        setTopBorderColor(hcolor.getIndex());
    }
}
 
Example #10
Source File: HSSFBorderFormatting.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setRightBorderColor(Color color) {
    HSSFColor hcolor = HSSFColor.toHSSFColor(color);
    if (hcolor == null) {
        setRightBorderColor((short)0);
    } else {
        setRightBorderColor(hcolor.getIndex());
    }
}
 
Example #11
Source File: HSSFBorderFormatting.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setLeftBorderColor(Color color) {
    HSSFColor hcolor = HSSFColor.toHSSFColor(color);
    if (hcolor == null) {
        setLeftBorderColor((short)0);
    } else {
        setLeftBorderColor(hcolor.getIndex());
    }
}
 
Example #12
Source File: HSSFBorderFormatting.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setDiagonalBorderColor(Color color) {
    HSSFColor hcolor = HSSFColor.toHSSFColor(color);
    if (hcolor == null) {
        setDiagonalBorderColor((short)0);
    } else {
        setDiagonalBorderColor(hcolor.getIndex());
    }
}
 
Example #13
Source File: HSSFBorderFormatting.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void setBottomBorderColor(Color color) {
    HSSFColor hcolor = HSSFColor.toHSSFColor(color);
    if (hcolor == null) {
        setBottomBorderColor((short)0);
    } else {
        setBottomBorderColor(hcolor.getIndex());
    }
}
 
Example #14
Source File: StylerHelper.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
public void styleColor(Formatter out, String attr, Color color) {
	XSSFColor xSSFColor = (XSSFColor) color;
	if (color == null || xSSFColor.isAuto())
		return;

	byte[] rgb = xSSFColor.getRgb();
	if (rgb == null) {
		return;
	}
	out.format("  %s: #%02x%02x%02x;%n", attr, rgb[0], rgb[1], rgb[2]);
}
 
Example #15
Source File: StylerHelper.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
public void styleColor(Formatter out, String attr, Color color) {
	if (color == null) {
		return;
	}
	HSSFColor hSSFColor = (HSSFColor) color;
	short[] rgb = hSSFColor.getTriplet();
	out.format("  %s: #%02x%02x%02x; %n", attr, rgb[0], rgb[1], rgb[2]);
}
 
Example #16
Source File: StylerHelper.java    From easypoi with Apache License 2.0 5 votes vote down vote up
public void styleColor(Formatter out, String attr, Color color) {
    if (color == null) {
        return;
    }
    HSSFColor hSSFColor = (HSSFColor) color;
    short[] rgb = hSSFColor.getTriplet();
    out.format("  %s: #%02x%02x%02x; %n", attr, rgb[0], rgb[1], rgb[2]);
}
 
Example #17
Source File: StylerHelper.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
private Color getColor(Font font) {
	if (helper instanceof HSSFHtmlHelper) {
		return ((HSSFWorkbook) sheet.getWorkbook()).getCustomPalette().getColor(font.getColor());
	} else {
		return ((XSSFFont) font).getXSSFColor();
	}
}
 
Example #18
Source File: StylerHelper.java    From autopoi with Apache License 2.0 5 votes vote down vote up
public void styleColor(Formatter out, String attr, Color color) {
	XSSFColor xSSFColor = (XSSFColor) color;
	if (color == null || xSSFColor.isAuto())
		return;

	byte[] rgb = xSSFColor.getRgb();
	if (rgb == null) {
		return;
	}
	out.format("  %s: #%02x%02x%02x;%n", attr, rgb[0], rgb[1], rgb[2]);
}
 
Example #19
Source File: StylerHelper.java    From autopoi with Apache License 2.0 5 votes vote down vote up
public void styleColor(Formatter out, String attr, Color color) {
	if (color == null) {
		return;
	}
	HSSFColor hSSFColor = (HSSFColor) color;
	short[] rgb = hSSFColor.getTriplet();
	out.format("  %s: #%02x%02x%02x; %n", attr, rgb[0], rgb[1], rgb[2]);
}
 
Example #20
Source File: HSSFColor.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public HSSFColor(int index, int index2, java.awt.Color color) {
    this.index = index;
    this.index2 = index2;
    this.color = color;
}
 
Example #21
Source File: HSSFDataBarFormatting.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public void setColor(Color color) {
    HSSFExtendedColor hcolor = (HSSFExtendedColor)color;
    databarFormatting.setColor(hcolor.getExtendedColor());
}
 
Example #22
Source File: HSSFColor.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
HSSFColorPredefined(int index, int index2, int rgb) {
    this.color = new HSSFColor(index, index2, new java.awt.Color(rgb));
}
 
Example #23
Source File: HSSFColor.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** Creates a new instance of HSSFColor */
public HSSFColor() {
    // automatic index
    this(0x40, -1, java.awt.Color.BLACK);
}
 
Example #24
Source File: HSSFBorderFormatting.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Not available for HSSF.
 * @see org.apache.poi.ss.usermodel.BorderFormatting#setHorizontalBorderColor(org.apache.poi.ss.usermodel.Color)
 */
public void setHorizontalBorderColor(Color color) {
    // nothing
}
 
Example #25
Source File: HSSFBorderFormatting.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Not available for HSSF.
 * @see org.apache.poi.ss.usermodel.BorderFormatting#setVerticalBorderColor(org.apache.poi.ss.usermodel.Color)
 */
public void setVerticalBorderColor(Color color) {
    // nothing
}
 
Example #26
Source File: HSSFBorderFormatting.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * HSSF Doesn't support table borders, so always {@link HSSFColorPredefined#AUTOMATIC}
 * @see org.apache.poi.ss.usermodel.BorderFormatting#getHorizontalBorderColorColor()
 */
public Color getHorizontalBorderColorColor() {
    return HSSFColorPredefined.AUTOMATIC.getColor();
}
 
Example #27
Source File: HSSFBorderFormatting.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * HSSF Doesn't support table borders, so always {@link HSSFColorPredefined#AUTOMATIC}
 * @see org.apache.poi.ss.usermodel.BorderFormatting#getVerticalBorderColorColor()
 */
public Color getVerticalBorderColorColor() {
    return HSSFColorPredefined.AUTOMATIC.getColor();
}
 
Example #28
Source File: StylerHelper.java    From easypoi with Apache License 2.0 votes vote down vote up
void styleColor(Formatter out, String attr, Color color); 
Example #29
Source File: StylerHelper.java    From jeasypoi with Apache License 2.0 votes vote down vote up
void styleColor(Formatter out, String attr, Color color); 
Example #30
Source File: StylerHelper.java    From autopoi with Apache License 2.0 votes vote down vote up
void styleColor(Formatter out, String attr, Color color);