Package com.google.code.appengine.awt

Examples of com.google.code.appengine.awt.Color


                os.write(RtfRow.tableBorderWidth);
                writeInt(os, (int) (lWidth * RtfWriter.TWIPSFACTOR));
                os.write(RtfWriter.escape);
                os.write(RtfRow.tableBorderColor);
                if (store.getBorderColor() == null)
                    writeInt(os, writer.addColor(new
                            Color(0, 0, 0)));
                else
                    writeInt(os, writer.addColor(store.getBorderColor()));
                os.write((byte) '\n');
            }
            if (((store.getBorder() & Rectangle.TOP) == Rectangle.TOP) && (tWidth > 0)) {
                os.write(RtfWriter.escape);
                os.write(cellBorderTop);
                os.write(RtfWriter.escape);
                os.write(tStyle);
                os.write(RtfWriter.escape);
                os.write(RtfRow.tableBorderWidth);
                writeInt(os, (int) (tWidth * RtfWriter.TWIPSFACTOR));
                os.write(RtfWriter.escape);
                os.write(RtfRow.tableBorderColor);
                if (store.getBorderColor() == null)
                    writeInt(os, writer.addColor(new
                            Color(0, 0, 0)));
                else
                    writeInt(os, writer.addColor(store.getBorderColor()));
                os.write((byte) '\n');
            }
            if (((store.getBorder() & Rectangle.BOTTOM) == Rectangle.BOTTOM) &&
                    (bWidth > 0)) {
                os.write(RtfWriter.escape);
                os.write(cellBorderBottom);
                os.write(RtfWriter.escape);
                os.write(bStyle);
                os.write(RtfWriter.escape);
                os.write(RtfRow.tableBorderWidth);
                writeInt(os, (int) (bWidth * RtfWriter.TWIPSFACTOR));
                os.write(RtfWriter.escape);
                os.write(RtfRow.tableBorderColor);
                if (store.getBorderColor() == null)
                    writeInt(os, writer.addColor(new
                            Color(0, 0, 0)));
                else
                    writeInt(os, writer.addColor(store.getBorderColor()));
                os.write((byte) '\n');
            }
            if (((store.getBorder() & Rectangle.RIGHT) == Rectangle.RIGHT) &&
                    (rWidth > 0)) {
                os.write(RtfWriter.escape);
                os.write(cellBorderRight);
                os.write(RtfWriter.escape);
                os.write(rStyle);
                os.write(RtfWriter.escape);
                os.write(RtfRow.tableBorderWidth);
                writeInt(os, (int) (rWidth * RtfWriter.TWIPSFACTOR));
                os.write(RtfWriter.escape);
                os.write(RtfRow.tableBorderColor);
                if (store.getBorderColor() == null)
                    writeInt(os, writer.addColor(new
                            Color(0, 0, 0)));
                else
                    writeInt(os, writer.addColor(store.getBorderColor()));
                os.write((byte) '\n');
            }
            os.write(RtfWriter.escape);
            os.write(cellBackgroundColor);
            if (store.getBackgroundColor() == null) {
                writeInt(os, writer.addColor(new Color(255, 255, 255)));
            } else {
                writeInt(os, writer.addColor(store.getBackgroundColor()));
            }
            os.write((byte) '\n');
            os.write(RtfWriter.escape);
View Full Code Here


        String fontname = null;
        String encoding = defaultEncoding;
        boolean embedded = defaultEmbedding;
        float size = Font.UNDEFINED;
        int style = Font.NORMAL;
        Color color = null;
        String value = attributes.getProperty(Markup.HTML_ATTR_STYLE);
        if (value != null && value.length() > 0) {
            Properties styleAttributes = Markup.parseAttributes(value);
            if (styleAttributes.isEmpty()) {
                attributes.put(Markup.HTML_ATTR_STYLE, value);
            }
            else {
                fontname = styleAttributes.getProperty(Markup.CSS_KEY_FONTFAMILY);
                if (fontname != null) {
                    String tmp;
                    while (fontname.indexOf(',') != -1) {
                        tmp = fontname.substring(0, fontname.indexOf(','));
                        if (isRegistered(tmp)) {
                            fontname = tmp;
                        }
                        else {
                            fontname = fontname.substring(fontname.indexOf(',') + 1);
                        }
                    }
                }
                if ((value = styleAttributes.getProperty(Markup.CSS_KEY_FONTSIZE)) != null) {
                    size = Markup.parseLength(value);
                }
                if ((value = styleAttributes.getProperty(Markup.CSS_KEY_FONTWEIGHT)) != null) {
                    style |= Font.getStyleValue(value);
                }
                if ((value = styleAttributes.getProperty(Markup.CSS_KEY_FONTSTYLE)) != null) {
                    style |= Font.getStyleValue(value);
                }
                if ((value = styleAttributes.getProperty(Markup.CSS_KEY_COLOR)) != null) {
                    color = Markup.decodeColor(value);
                }
                attributes.putAll(styleAttributes);
                for (Enumeration e = styleAttributes.keys(); e.hasMoreElements();) {
                    Object o = e.nextElement();
                    attributes.put(o, styleAttributes.get(o));
                }
            }
        }
        if ((value = attributes.getProperty(ElementTags.ENCODING)) != null) {
            encoding = value;
        }
        if ("true".equals(attributes.getProperty(ElementTags.EMBEDDED))) {
            embedded = true;
        }
        if ((value = attributes.getProperty(ElementTags.FONT)) != null) {
            fontname = value;
        }
        if ((value = attributes.getProperty(ElementTags.SIZE)) != null) {
            size = Markup.parseLength(value);
        }
        if ((value = attributes.getProperty(Markup.HTML_ATTR_STYLE)) != null) {
            style |= Font.getStyleValue(value);
        }
        if ((value = attributes.getProperty(ElementTags.STYLE)) != null) {
            style |= Font.getStyleValue(value);
        }
        String r = attributes.getProperty(ElementTags.RED);
        String g = attributes.getProperty(ElementTags.GREEN);
        String b = attributes.getProperty(ElementTags.BLUE);
        if (r != null || g != null || b != null) {
            int red = 0;
            int green = 0;
            int blue = 0;
            if (r != null) red = Integer.parseInt(r);
            if (g != null) green = Integer.parseInt(g);
            if (b != null) blue = Integer.parseInt(b);
            color = new Color(red, green, blue);
        }
        else if ((value = attributes.getProperty(ElementTags.COLOR)) != null) {
            color = Markup.decodeColor(value);
        }
        if (fontname == null) {
View Full Code Here

     * @throws    DocumentException
     */
    private void writeList(com.lowagie.text.List list, ByteArrayOutputStream out) throws IOException, DocumentException {
        int type = 0;
        int align = 0;
        int fontNr = addFont(new Font(Font.SYMBOL, 10, Font.NORMAL, new Color(0, 0, 0)));
        if (!list.isNumbered()) type = 23;
        if (listLevel == 0) {
            maxListLevel = 0;
            listtable.write(openGroup);
            listtable.write(escape);
            listtable.write(listDefinition);
            int i = getRandomInt();
            listtable.write(escape);
            listtable.write(listTemplateID);
            writeInt(listtable, i);
            listtable.write(escape);
            listtable.write(hybridList);
            listtable.write((byte) '\n');
        }
        if (listLevel >= maxListLevel) {
            maxListLevel++;
            listtable.write(openGroup);
            listtable.write(escape);
            listtable.write(listLevelDefinition);
            listtable.write(escape);
            listtable.write(listLevelTypeOld);
            writeInt(listtable, type);
            listtable.write(escape);
            listtable.write(listLevelTypeNew);
            writeInt(listtable, type);
            listtable.write(escape);
            listtable.write(listLevelAlignOld);
            writeInt(listtable, align);
            listtable.write(escape);
            listtable.write(listLevelAlignNew);
            writeInt(listtable, align);
            listtable.write(escape);
            listtable.write(listLevelStartAt);
            writeInt(listtable, 1);
            listtable.write(openGroup);
            listtable.write(escape);
            listtable.write(listLevelTextDefinition);
            listtable.write(escape);
            listtable.write(listLevelTextLength);
            if (list.isNumbered()) {
                writeInt(listtable, 2);
            } else {
                writeInt(listtable, 1);
            }
            listtable.write(escape);
            if (list.isNumbered()) {
                listtable.write(listLevelTextStyleNumbers);
            } else {
                listtable.write(listLevelTextStyleBullet);
            }
            listtable.write(commaDelimiter);
            listtable.write(closeGroup);
            listtable.write(openGroup);
            listtable.write(escape);
            listtable.write(listLevelNumbersDefinition);
            if (list.isNumbered()) {
                listtable.write(delimiter);
                listtable.write(listLevelNumbers);
                writeInt(listtable, listLevel + 1);
            }
            listtable.write(commaDelimiter);
            listtable.write(closeGroup);
            if (!list.isNumbered()) {
                listtable.write(escape);
                listtable.write(fontNumber);
                writeInt(listtable, fontNr);
            }
            listtable.write(escape);
            listtable.write(firstIndent);
            writeInt(listtable, (int) (list.getIndentationLeft() * TWIPSFACTOR * -1));
            listtable.write(escape);
            listtable.write(listIndent);
            writeInt(listtable, (int) ((list.getIndentationLeft() + list.getSymbolIndent()) * TWIPSFACTOR));
            listtable.write(escape);
            listtable.write(rightIndent);
            writeInt(listtable, (int) (list.getIndentationRight() * TWIPSFACTOR));
            listtable.write(escape);
            listtable.write(tabStop);
            writeInt(listtable, (int) (list.getSymbolIndent() * TWIPSFACTOR));
            listtable.write(closeGroup);
            listtable.write((byte) '\n');
        }
        // Actual List Begin in Content
        out.write(escape);
        out.write(paragraphDefaults);
        out.write(escape);
        out.write(alignLeft);
        out.write(escape);
        out.write(firstIndent);
        writeInt(out, (int) (list.getIndentationLeft() * TWIPSFACTOR * -1));
        out.write(escape);
        out.write(listIndent);
        writeInt(out, (int) ((list.getIndentationLeft() + list.getSymbolIndent()) * TWIPSFACTOR));
        out.write(escape);
        out.write(rightIndent);
        writeInt(out, (int) (list.getIndentationRight() * TWIPSFACTOR));
        out.write(escape);
        out.write(fontSize);
        writeInt(out, 20);
        out.write(escape);
        out.write(listBegin);
        writeInt(out, currentListID);
        if (listLevel > 0) {
            out.write(escape);
            out.write(listCurrentLevel);
            writeInt(out, listLevel);
        }
        out.write(openGroup);
        ListIterator listItems = list.getItems().listIterator();
        Element listElem;
        int count = 1;
        while (listItems.hasNext()) {
            listElem = (Element) listItems.next();
            if (listElem.type() == Element.CHUNK) {
                listElem = new ListItem((Chunk) listElem);
            }
            if (listElem.type() == Element.LISTITEM) {
                out.write(openGroup);
                out.write(escape);
                out.write(listTextOld);
                out.write(escape);
                out.write(paragraphDefaults);
                out.write(escape);
                out.write(fontNumber);
                if (list.isNumbered()) {
                    writeInt(out, addFont(new Font(Font.TIMES_ROMAN, Font.NORMAL, 10, new Color(0, 0, 0))));
                } else {
                    writeInt(out, fontNr);
                }
                out.write(escape);
                out.write(firstIndent);
View Full Code Here

    /**
     * Write the colour list to the final <code>ByteArrayOutputStream</code>
     * @throws IOException
     */
    private void writeColorList() throws IOException {
        Color color = null;

        os.write(openGroup);
        os.write(escape);
        os.write(colorTable);
        for (int i = 0; i < colorList.size(); i++) {
            color = (Color) colorList.get(i);
            os.write(escape);
            os.write(colorRed);
            writeInt(os, color.getRed());
            os.write(escape);
            os.write(colorGreen);
            writeInt(os, color.getGreen());
            os.write(escape);
            os.write(colorBlue);
            writeInt(os, color.getBlue());
            os.write(commaDelimiter);
        }
        os.write(closeGroup);
    }
View Full Code Here

        listtable = new ByteArrayOutputStream();
        listoverride = new ByteArrayOutputStream();
        document.addProducer();
        document.addCreationDate();
        addFont(new Font(Font.TIMES_ROMAN, 10, Font.NORMAL));
        addColor(new Color(0, 0, 0));
        addColor(new Color(255, 255, 255));
        listIds = new ArrayList();
        try {
            listtable.write(openGroup);
            listtable.write(extendedEscape);
            listtable.write(listtableGroup);
View Full Code Here

        this.borderWidth = (int) (borderWidth * TWIPS_FACTOR);
        if(this.borderWidth == 0) {
            this.borderStyle = BORDER_NONE;
        }
        if(borderColor == null) {
            this.borderColor = new RtfColor(this.document, new Color(0, 0, 0));
        } else {
            this.borderColor = new RtfColor(this.document, borderColor);
        }
    }
View Full Code Here

       
        if(this.listLevel == 0) {
            correctIndentation();
        }
       
        fontNumber = new RtfFont(document, new Font(Font.TIMES_ROMAN, 10, Font.NORMAL, new Color(0, 0, 0)));
        if (list.getSymbol() != null && list.getSymbol().getFont() != null && !list.getSymbol().getContent().startsWith("-") && list.getSymbol().getContent().length() > 0) {
            // only set this to bullet symbol is not default
            this.fontBullet = new RtfFont(document, list.getSymbol().getFont());
            this.bulletCharacter = list.getSymbol().getContent().substring(0, 1);
        } else {
            this.fontBullet = new RtfFont(document, new Font(Font.SYMBOL, 10, Font.NORMAL, new Color(0, 0, 0)));
        }       
    }
View Full Code Here

        } else {
          result.write("0".getBytes());
        }
        break;
      case PROPERTY_TYPE_COLOR:
            Color color = (Color) this.value;
            result.write(intToByteArray(color.getRed() | (color.getGreen() << 8) | (color.getBlue() << 16)));
        break;
      case PROPERTY_TYPE_ARRAY:
          if(this.value instanceof int[]) {
              int[] values = (int[]) this.value;
              result.write("4;".getBytes());
View Full Code Here

            dStyle = this.getStyle();
        } else if(font.getStyle() != Font.UNDEFINED) {
            dStyle = font.getStyle();
        }

        Color dColor = font.getColor();
        if(dColor == null) {
            dColor = this.getColor();
        }
       
        int dCharset = this.charset;
View Full Code Here

 
  public static Color decodeColor(String s) {
      if (s == null)
          return null;
      s = s.toLowerCase().trim();
      Color c = (Color)WebColors.getRGBColor(s);
      if (c != null)
          return c;
      try {
          if (s.startsWith("#")) {
              if (s.length() == 4)
                  s = "#" + s.substring(1, 2) + s.substring(1, 2)
                      + s.substring(2, 3) + s.substring(2, 3)
                      + s.substring(3, 4) + s.substring(3, 4);
              if (s.length() == 7)
                  return new Color(Integer.parseInt(s.substring(1), 16));
          }
          else if (s.startsWith("rgb")) {
              StringTokenizer tk = new StringTokenizer(s.substring(3), " \t\r\n\f(),");
              int[] cc = new int [3];
              for (int k = 0; k < 3; ++k) {
                  if (!tk.hasMoreTokens())
                      return null;
                  String t = tk.nextToken();
                  float n;
                  if (t.endsWith("%")) {
                      n = Float.parseFloat(t.substring(0, t.length() - 1));
                      n = n * 255f / 100f;
                  }
                  else
                      n = Float.parseFloat(t);
                  int ni = (int)n;
                  if (ni > 255)
                      ni = 255;
                  else if (ni < 0)
                      ni = 0;
                  cc[k] = ni;
              }
              return new Color(cc[0], cc[1], cc[2]);
          }
      }
      catch (Exception e) {
      }
      return null;
View Full Code Here

TOP

Related Classes of com.google.code.appengine.awt.Color

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.