Package org.jpedal.objects.acroforms.overridingImplementations

Examples of org.jpedal.objects.acroforms.overridingImplementations.FixImageIcon


        AbstractButton tmp=(AbstractButton) e.getSource();
       
        //width = tmp.getWidth();
        //height = tmp.getHeight();
       
      FixImageIcon imgI = (FixImageIcon) tmp.getPressedIcon();
//        imgI.setAttributes(width,height);//unneeded call
        imgI.swapImage(tmp.isSelected());
    }
View Full Code Here


                      */
                    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();
                    }
                }
              }
View Full Code Here

            sigBut.setOpaque(false);
            BufferedImage img=new BufferedImage(1,1, BufferedImage.TYPE_INT_ARGB);
            Graphics2D imgG2=img.createGraphics();
            imgG2.setPaint(new Color(221,228,255,175));
            imgG2.fillRect(0,0,1,1);
            sigBut.setIcon(new FixImageIcon(img,0));

           // sigBut.setBackground(new Color(221,228,255,175)); //r,g,b,a
        }

        return sigBut;
View Full Code Here

        if (form.hasNormalOff()) {
          comp.setText(null);
          //store normal off as ma be used in generating the down image
          normalOff = form.getNormalOffImage();
          comp.setIcon(new FixImageIcon(normalOff,form.getDictionary(PdfDictionary.MK).getInt(PdfDictionary.R)));
         
          if (showImages)
            ShowGUIMessage.showGUIMessage("normalAppOffImage", form.getNormalOffImage(), "normalAppOff");
        }
        if (form.hasNormalOn()) {
          comp.setText(null);
          //store normal on as ma be used in generating the down image
          normalOn = form.getNormalOnImage();
          comp.setSelectedIcon(new FixImageIcon(normalOn,form.getDictionary(PdfDictionary.MK).getInt(PdfDictionary.R)));
           
          if (showImages)
            ShowGUIMessage.showGUIMessage("normalAppOnImage", form.getNormalOnImage(), "normalAppOn");
        }

        if (form.hasNoDownIcon()) {
          comp.setPressedIcon(comp.getIcon());
        } else {
          if(!form.hasDownImage()){
            if (form.hasNormalOff()) {
              if (form.hasNormalOn()) {
                if(form.hasOffsetDownIcon()){
                  downOn = createPressedLook(normalOn);
                  downOff = createPressedLook(normalOff);
                }else {
                  downOff = invertImage(normalOff);
                  downOn = invertImage(normalOn);
                }
              } else {
                if(form.hasOffsetDownIcon()){
                  downOff = createPressedLook(normalOff);
                }else {
                  downOff = invertImage(normalOff);
                }
              }
            } else if (form.hasNormalOn()) {
              if(form.hasOffsetDownIcon()){
                downOff = createPressedLook(normalOn);
              }else {
                downOff = invertImage(normalOn);
              }
            }
          } else {
            downOff = form.getDownOffImage();
            downOn = form.getDownOnImage();
          }
        }
       
        if (downOff == null || downOn == null) {
          if (downOff != null) {
            comp.setText(null);
            comp.setPressedIcon(new FixImageIcon(downOff,form.getDictionary(PdfDictionary.MK).getInt(PdfDictionary.R)));
          } else if (downOn != null) {
            comp.setText(null);
            comp.setPressedIcon(new FixImageIcon(downOn,form.getDictionary(PdfDictionary.MK).getInt(PdfDictionary.R)));
          }

        } else {
          comp.setPressedIcon(new FixImageIcon(downOn,downOff,form.getDictionary(PdfDictionary.MK).getInt(PdfDictionary.R),comp.isSelected()?1:0));
          comp.addActionListener((ActionListener)formsActionHandler.setupChangingDownIcon(downOff, downOn,form.getDictionary(PdfDictionary.MK).getInt(PdfDictionary.R)));
        }

        if (showImages) {
          ShowGUIMessage.showGUIMessage("downAppOffImage", downOff, "downAppOff");
          ShowGUIMessage.showGUIMessage("downAppOnImage", downOn, "downAppOn");
        }

        if (form.hasRolloverOff()) {
          comp.setRolloverEnabled(true);
          comp.setText(null);
          comp.setRolloverIcon(new FixImageIcon(form.getRolloverOffImage(),form.getDictionary(PdfDictionary.MK).getInt(PdfDictionary.R)));
         
          if (showImages)
            ShowGUIMessage.showGUIMessage("rolloverAppOffImage", form.getRolloverOffImage(), "rolloverAppOff");
        }
        if (form.hasRolloverOn()) {
          comp.setRolloverEnabled(true);
          comp.setText(null);
          comp.setRolloverSelectedIcon(new FixImageIcon(form.getRolloverOnImage(),form.getDictionary(PdfDictionary.MK).getInt(PdfDictionary.R)));
         
          if (showImages)
            ShowGUIMessage.showGUIMessage("rolloverAppOnImage", form.getRolloverOnImage(), "rolloverAppOn");
        }
      }
View Full Code Here

TOP

Related Classes of org.jpedal.objects.acroforms.overridingImplementations.FixImageIcon

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.