protected static Colour getNearestColour(Color awtColor) { Colour color = (Colour) colorsCache.get(awtColor); if (color == null) { Colour[] colors = Colour.getAllColours(); if ((colors != null) && (colors.length > 0)) { int minDiff = 999; for (int i = 0; i < colors.length; i++) { Colour crtColor = colors[i]; int diff = rgbDistance(awtColor, crtColor.getDefaultRGB()); if (diff < minDiff) { minDiff = diff; color = crtColor; } } } colorsCache.put(awtColor, color); } return color; }
/** * Gets the colour for this font * * @return the colour */ public Colour getColour() { return Colour.getInternalColour(colourIndex); }
/** * Gets the internal colour from the value * * @param val * @return the colour with that value */ public static Colour getInternalColour(int val) { for (int i = 0 ; i < colours.length ; i++) { if (colours[i].getValue() == val) { return colours[i]; } } return UNKNOWN; }
public static Colour addNewColor(String s, int r, int g, int b) { // check if color doesn't exists Colour[] cols = getAllColours(); for (int i = 0; i < 32; i++) { if (compareColours(cols[i], r, g, b)) { return cols[i]; } } for (int i = cols.length - 1; i >= coloursCounter; i--) { if (compareColours(cols[i], r, g, b)) { return cols[i]; } } coloursCounter--; if (coloursCounter < 32) coloursCounter = 63; return new Colour(coloursCounter, s, r, g, b); }
/** * Gets the colour RGB from the palette * * @param c the colour * @return an RGB structure */ public RGB getColourRGB(Colour c) { // Only colours on the standard palette with values 8-64 are acceptable int pos = c.getValue() - 8; if (pos < 0 || pos >= numColours) { return c.getDefaultRGB(); } if (!initialized) { initialize(); } return rgbColours[pos]; }
protected void setColourUsed(Colour colour) { usedColours.put(colour, colour.getDefaultRGB()); }
&& (cf.getColour().getValue() == forecolor) && (cf.getPointSize() == fontSize) && (cf.getUnderlineStyle() == UnderlineStyle.SINGLE ? (font.isUnderline()) : (!font.isUnderline())) font.isItalic(), font.isUnderline() ? UnderlineStyle.SINGLE : UnderlineStyle.NO_UNDERLINE, Colour.getInternalColour(forecolor) ); cellFont.setStruckout(font.isStrikeThrough());
bw.newLine(); bw.write(" colour=\"" + font.getColour().getDescription() + "\""); bw.newLine(); bw.write(" script=\"" + format.getBackgroundColour().getDescription() + "\""); bw.newLine(); bw.write(" pattern=\"" +
/** * Gets the colour RGB from the palette * * @param c the colour * @return an RGB structure */ public RGB getColourRGB(Colour c) { // Only colours on the standard palette with values 8-64 are acceptable int pos = c.getValue() - 8; if (pos < 0 || pos >= numColours) { return c.getDefaultRGB(); } if (!initialized) { initialize(); } return rgbColours[pos]; }
/** * Accessor for the RGB value for the specified colour * * @return the RGB for the specified colour */ public RGB getColourRGB(Colour c) { if (palette == null) { return c.getDefaultRGB(); } return palette.getColourRGB(c); } }
bw.newLine(); bw.write(" colour=\"" + font.getColour().getDescription() + "\""); bw.newLine(); bw.write(" script=\"" + format.getBackgroundColour().getDescription() + "\""); bw.newLine(); bw.write(" pattern=\"" +
/** * Default constructor - used when there is no palette specified */ public PaletteRecord() { super(Type.PALETTE); initialized = true; dirty = false; read = false; // Initialize the array with all the default colours Colour[] colours = Colour.getAllColours(); for (int i = 0; i < colours.length; i++) { Colour c = colours[i]; setColourRGB(c, c.getDefaultRGB().getRed(), c.getDefaultRGB().getGreen(), c.getDefaultRGB().getBlue()); } }
/** * Gets the internal colour from the value * * @param val * @return the colour with that value */ public static Colour getInternalColour(int val) { for (int i = 0 ; i < colours.length ; i++) { if (colours[i].getValue() == val) { return colours[i]; } } return UNKNOWN; }
/** * Accessor for the RGB value for the specified colour * * @return the RGB for the specified colour */ public RGB getColourRGB(Colour c) { if (palette == null) { return c.getDefaultRGB(); } return palette.getColourRGB(c); } }
/** * Gets the colour for this font * * @return the colour */ public Colour getColour() { return Colour.getInternalColour(colourIndex); }
public static void dump() { Colour[] cols = getAllColours(); for (int i = 0; i < cols.length; i++) { RGB rgb = cols[i].getDefaultRGB(); System.out.println(i + ") " + rgb.getRed() + ", " + rgb.getGreen() + ", " + rgb.getBlue()); } }
public String toString() { return "(" + borderStyle[TOP].getValue() + "/" + borderColour[TOP].getValue() + "," + borderStyle[BOTTOM].getValue() + "/" + borderColour[BOTTOM].getValue() + "," + borderStyle[LEFT].getValue() + "/" + borderColour[LEFT].getValue() + "," + borderStyle[RIGHT].getValue() + "/" + borderColour[RIGHT].getValue() + ")"; } }
private static Boolean compareColours(Colour col, int r, int g, int b) { RGB rgb = col.getDefaultRGB(); if ((rgb.getRed() == r) && (rgb.getGreen() == g) && (rgb.getBlue() == b)) return true; else return false; }
leftBorderColour = Colour.getInternalColour(borderColourMask & 0x7f); rightBorderColour = Colour.getInternalColour ((borderColourMask & 0x3f80) >> 7); topBorderColour = Colour.getInternalColour(borderColourMask & 0x7f); bottomBorderColour = Colour.getInternalColour ((borderColourMask & 0x3f80) >> 7); backgroundColour = Colour.getInternalColour(colourPaletteMask & 0x3f);
/** * Default constructor - used when there is no palette specified */ public PaletteRecord() { super(Type.PALETTE); initialized = true; dirty = false; read = false; // Initialize the array with all the default colours Colour[] colours = Colour.getAllColours(); for (int i = 0; i < colours.length; i++) { Colour c = colours[i]; setColourRGB(c, c.getDefaultRGB().getRed(), c.getDefaultRGB().getGreen(), c.getDefaultRGB().getBlue()); } }