Examples of DeviceCMYKColorSpace


Examples of org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace

            g2d.setColor(colRGB);
            g2d.fillRect(10, 30, 40, 40);

            //Just convert RGB to CMYK and use that
            float[] compsRGB = colRGB.getColorComponents(null);
            DeviceCMYKColorSpace cmykCS = ColorSpaces.getDeviceCMYKColorSpace();
            float[] compsCMYK = cmykCS.fromRGB(compsRGB);
            Color colCMYK = DeviceCMYKColorSpace.createCMYKColor(compsCMYK);
            g2d.setColor(colCMYK);
            g2d.fillRect(60, 30, 40, 40);

            //Try CIELab (not implemented, yet)
View Full Code Here

Examples of org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace

        String ser = b1.toString();
        BorderProps b2 = BorderProps.valueOf(null, ser);
        assertEquals(b1, b2);

        float[] cmyk = new float[] {1.0f, 1.0f, 0.5f, 1.0f};
        DeviceCMYKColorSpace cmykCs = DeviceCMYKColorSpace.getInstance();
        float[] rgb = cmykCs.toRGB(cmyk);
        col = ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2],
                "#CMYK", null, cmykCs, cmyk);
        b1 = new BorderProps(Constants.EN_INSET, 9999,
                col, BorderProps.SEPARATE);
        ser = b1.toString();
View Full Code Here

Examples of org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace

                        || (black < 0.0 || black > 1.0)) {
                    throw new PropertyException("Color values out of range"
                            + "Arguments to cmyk() must be in the range [0%-100%] or [0.0-1.0]");
                }
                float[] cmyk = new float[] {cyan, magenta, yellow, black};
                DeviceCMYKColorSpace cmykCs = DeviceCMYKColorSpace.getInstance();
                float[] rgb = cmykCs.toRGB(cmyk);
                parsedColor = ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2],
                        CMYK_PSEUDO_PROFILE, null, cmykCs, cmyk);
            } catch (PropertyException pe) {
                throw pe;
            } catch (Exception e) {
View Full Code Here

Examples of org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace

     * @param black the gray component (0 - 1)
     * @return the CMYK color
     */
    public static Color toCMYKGrayColor(float black) {
        float[] cmyk = new float[] {0f, 0f, 0f, 1.0f - black};
        DeviceCMYKColorSpace cmykCs = DeviceCMYKColorSpace.getInstance();
        float[] rgb = cmykCs.toRGB(cmyk);
        return ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2],
                CMYK_PSEUDO_PROFILE, null, cmykCs, cmyk);
    }
View Full Code Here

Examples of org.jpedal.color.DeviceCMYKColorSpace

                    //DeviceRGB colorspace
                    c = new Color(f[0],f[1],f[2],0.5f);
                    break;
                  case 4:
                    //DeviceCMYK colorspace
                    DeviceCMYKColorSpace cmyk = new DeviceCMYKColorSpace();
                    cmyk.setColor(f, 4);
                    c = new Color(cmyk.getColor().getRGB());
                    c = new Color(c.getRed(), c.getGreen(), c.getBlue(),0.5f);

                    break;
                  default:
                    break;
                  }                 
                }
               
                float[] quad = form.getFloatArray(PdfDictionary.QuadPoints);
                if(quad==null){
                  quad = form.getFloatArray(PdfDictionary.Rect);
                }
               
                BufferedImage icon = new BufferedImage(form.getBoundingRectangle().width, form.getBoundingRectangle().height, BufferedImage.TYPE_4BYTE_ABGR);
              Graphics g = icon.getGraphics();
//              g.setColor(Color.blue);
//              g.fillRect(0,0, icon.getWidth(), icon.getHeight());
              if(quad.length>=8)
                for(int hi=0; hi!=quad.length; hi+=8){
                  int x = (int)quad[hi]-form.getBoundingRectangle().x;
                  int y = (int)quad[hi+5]-form.getBoundingRectangle().y;
                  //Adjust y for display
                  y = (form.getBoundingRectangle().height-y)-(int)(quad[hi+1]-quad[hi+5]);
                  int width = (int)(quad[hi+2]-quad[hi]);
                  int height = (int)(quad[hi+1]-quad[hi+5]);
                  Rectangle rh = new Rectangle(x, y, width, height);
                 
                  try {
                    g.setColor(c);
                    g.fillRect(rh.x,rh.y, rh.width, rh.height);
                    but.setBackground(new Color(0,0,0,0));
                    but.setIcon(new FixImageIcon(icon,0));
                  } catch (Exception e){
                    e.printStackTrace();
                  }
                }
              }
              break;
            case PdfDictionary.Underline :
              if(newAnnots){
                but.setBounds(form.getBoundingRectangle());
               
                float[] underlineColor = form.getFloatArray(PdfDictionary.C);
                Color c1 = new Color(0);
                if(underlineColor!=null){
                  switch(underlineColor.length){
                  case 0:
                    //Should not happen. Do nothing. Annotation is transparent
                    break;
                  case 1:
                    //DeviceGrey colorspace
                    c1 = new Color(underlineColor[0],underlineColor[0],underlineColor[0],1.0f);
                    break;
                  case 3:
                    //DeviceRGB colorspace
                    c1 = new Color(underlineColor[0],underlineColor[1],underlineColor[2],1.0f);
                    break;
                  case 4:
                    //DeviceCMYK colorspace
                    DeviceCMYKColorSpace cmyk = new DeviceCMYKColorSpace();
                    cmyk.setColor(underlineColor, 4);
                    c1 = new Color(cmyk.getColor().getRGB());

                    break;
                  default:
                    break;
                  }                 
                }

                float[] quad = form.getFloatArray(PdfDictionary.QuadPoints);
                if(quad==null){
                  quad = form.getFloatArray(PdfDictionary.Rect);
                }
               
                BufferedImage icon = new BufferedImage(form.getBoundingRectangle().width, form.getBoundingRectangle().height, BufferedImage.TYPE_4BYTE_ABGR);
              Graphics g = icon.getGraphics();
//              g.setColor(Color.blue);
//              g.fillRect(0,0, icon.getWidth(), icon.getHeight());
              if(quad.length>=8)
                for(int hi=0; hi!=quad.length; hi+=8){
                  int x = (int)quad[hi]-form.getBoundingRectangle().x;
                  int y = (int)quad[hi+5]-form.getBoundingRectangle().y;
                  //Adjust y for display
                  y = (form.getBoundingRectangle().height-y)-(int)(quad[hi+1]-quad[hi+5]);
                  int width = (int)(quad[hi+2]-quad[hi]);
                  int height = (int)(quad[hi+1]-quad[hi+5]);
                  Rectangle rh = new Rectangle(x, y, width, height);
                 
                  try {
                      g.setColor(new Color(0.0f,0.0f,0.0f,0.0f));
                      g.fillRect(rh.x,rh.y, rh.width, rh.height);
                      g.setColor(c1);
                      g.fillRect(rh.x,rh.y+rh.height-1, rh.width, 1);
                      but.setBackground(new Color(0,0,0,0));
                      but.setIcon(new FixImageIcon(icon,0));
                    } catch (Exception e){
                      e.printStackTrace();
                    }
                }
              }
              break;
            case PdfDictionary.StrickOut :
              if(newAnnots){
               
                float[] strikeColor = form.getFloatArray(PdfDictionary.C);
                Color c2 = new Color(0);
                if(strikeColor!=null){
                  switch(strikeColor.length){
                  case 0:
                    //Should not happen. Do nothing. Annotation is transparent
                    break;
                  case 1:
                    //DeviceGrey colorspace
                    c2 = new Color(strikeColor[0],strikeColor[0],strikeColor[0],1.0f);
                    break;
                  case 3:
                    //DeviceRGB colorspace
                    c2 = new Color(strikeColor[0],strikeColor[1],strikeColor[2],1.0f);
                    break;
                  case 4:
                    //DeviceCMYK colorspace
                    DeviceCMYKColorSpace cmyk = new DeviceCMYKColorSpace();
                    cmyk.setColor(strikeColor, 4);
                    c2 = new Color(cmyk.getColor().getRGB());

                    break;
                  default:
                    break;
                  }                 
View Full Code Here

Examples of org.jpedal.color.DeviceCMYKColorSpace

                Float.parseFloat(toks[1]),
                Float.parseFloat(toks[2]),
                Float.parseFloat(toks[3])
        };*/

        DeviceCMYKColorSpace cs=new DeviceCMYKColorSpace();
        cs.setColor(C,3);
        newColor =(Color) cs.getColor();

        //newColor = new Color(ColorSpace.getInstance(ColorSpace.TYPE_CMYK),cmyk,1);

    }else{
        //LogWriter.writeFormLog("{stream} ERROR i="+i+" toks="+ConvertToString.convertArrayToString(toks),debugUnimplemented);
View Full Code Here

Examples of org.jpedal.color.DeviceCMYKColorSpace

          newColor = new Color((int)tok0,(int)tok1,(int)tok2);
        }

    }else if(i==4){
        
        DeviceCMYKColorSpace cs=new DeviceCMYKColorSpace();
            cs.setColor(new float[]{toks[3],toks[2],toks[1],toks[0]},4);
        newColor =(Color) cs.getColor();

    }
   
    return newColor;
  }
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.