*/
if(name.equals("Comment")){
try {
BufferedImage commentIcon = ImageIO.read(getClass().getResource("/org/jpedal/objects/acroforms/res/comment.png"));
but.setIcon(new FixImageIcon(commentIcon,0));
} catch (Exception e){
e.printStackTrace();
}
}else {
}
//show as popup
break;
//PdfDictionary.Open;
//PdfDictionary.Popup;
}
break;
case PdfDictionary.Highlight :
if(newAnnots){
float[] f = form.getFloatArray(PdfDictionary.C);
Color c = new Color(0);
if(f!=null){
switch(f.length){
case 0:
//Should not happen. Do nothing. Annotation is transparent
break;
case 1:
//DeviceGrey colorspace
c = new Color(f[0],f[0],f[0],0.5f);
break;
case 3:
//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;
}
}
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(0,0, rh.width, rh.height);
g.setColor(c2);
g.fillRect(rh.x,rh.y+(rh.height/2), rh.width, 1);
but.setBackground(new Color(0,0,0,0));
but.setIcon(new FixImageIcon(icon,0));
} catch (Exception e){
e.printStackTrace();
}
}
}