Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      any

      Description

      I was attempting to apply an outer border to an image border and found out it did not work. The following patch does add this feature. It also allows for applying the 'thickness' value for image borders which is currently not accessible. And it allows to configure the inner border to be painted first, or the other way around. Also changed the type constants accessibility to public which is useful when extending the Border class. Here is the patch for your consideration, maybe you find this (or something similar) useful:

      # This patch file was generated by NetBeans IDE
      # It uses platform neutral UTF-8 encoding and \n newlines.
      --- Base (BASE)
      +++ Locally Modified (Based On LOCAL)
      @@ -47,25 +47,25 @@
       public class Border {
           private static Border defaultBorder = Border.createEtchedRaised(0x020202, 0xBBBBBB);
           
      -    private static final int TYPE_EMPTY = 0;
      -    private static final int TYPE_LINE = 1;
      -    private static final int TYPE_ROUNDED = 2;
      -    private static final int TYPE_ROUNDED_PRESSED = 3;
      -    private static final int TYPE_ETCHED_LOWERED = 4;
      -    private static final int TYPE_ETCHED_RAISED = 5;
      -    private static final int TYPE_BEVEL_RAISED = 6;
      -    private static final int TYPE_BEVEL_LOWERED = 7;
      -    private static final int TYPE_IMAGE = 8;
      -    private static final int TYPE_COMPOUND = 9;
      -    private static final int TYPE_IMAGE_HORIZONTAL = 10;
      -    private static final int TYPE_IMAGE_VERTICAL = 11;
      -    private static final int TYPE_DASHED = 12;
      -    private static final int TYPE_DOTTED = 13;
      -    private static final int TYPE_DOUBLE = 14;
      -    private static final int TYPE_GROOVE = 15;
      -    private static final int TYPE_RIDGE = 16;
      -    private static final int TYPE_INSET = 17;
      -    private static final int TYPE_OUTSET = 18;
      +    public static final int TYPE_EMPTY = 0;
      +    public static final int TYPE_LINE = 1;
      +    public static final int TYPE_ROUNDED = 2;
      +    public static final int TYPE_ROUNDED_PRESSED = 3;
      +    public static final int TYPE_ETCHED_LOWERED = 4;
      +    public static final int TYPE_ETCHED_RAISED = 5;
      +    public static final int TYPE_BEVEL_RAISED = 6;
      +    public static final int TYPE_BEVEL_LOWERED = 7;
      +    public static final int TYPE_IMAGE = 8;
      +    public static final int TYPE_COMPOUND = 9;
      +    public static final int TYPE_IMAGE_HORIZONTAL = 10;
      +    public static final int TYPE_IMAGE_VERTICAL = 11;
      +    public static final int TYPE_DASHED = 12;
      +    public static final int TYPE_DOTTED = 13;
      +    public static final int TYPE_DOUBLE = 14;
      +    public static final int TYPE_GROOVE = 15;
      +    public static final int TYPE_RIDGE = 16;
      +    public static final int TYPE_INSET = 17;
      +    public static final int TYPE_OUTSET = 18;
       
           // variables are package protected for the benefit of the resource editor!
           int type;
      @@ -921,11 +921,30 @@
            * @param c component whose border should be drawn
            */
           public void paintBorderBackground(Graphics g, Component c) {
      -        int originalColor = g.getColor();
               int x = c.getX();
               int y = c.getY();
               int width = c.getWidth();
               int height = c.getHeight();
      +        if (outerBorder != null) {
      +            if (paintOuterBorderFirst) {
      +                outerBorder.paintBorderBackground(g, c);
      +                this.paintBorderBackground(g, x + thickness, y + thickness, width - thickness * 2, height - thickness * 2, c);
      +            } else {
      +                this.paintBorderBackground(g, x + thickness, y + thickness, width - thickness * 2, height - thickness * 2, c);
      +                outerBorder.paintBorderBackground(g, c);
      +            }
      +        } else {
      +            this.paintBorderBackground(g, x, y, width, height, c);
      +        }
      +    }
      +    
      +    public void paintBorderBackground(Graphics g, final int xParameter, final int yParameter, 
      +            final int widthParameter, final int heightParameter, Component c) {
      +        int originalColor = g.getColor();
      +        int x = xParameter;
      +        int y = yParameter;
      +        int width = widthParameter;
      +        int height = heightParameter;
               switch(type) {
                   case TYPE_ROUNDED_PRESSED:
                       x++;
      @@ -1061,10 +1080,10 @@
                       
                       g.setClip(clipX, clipY, clipWidth, clipHeight);
                       
      -                x = c.getX();
      -                y = c.getY();
      -                width = c.getWidth();
      -                height = c.getHeight();
      +                x = xParameter;
      +                y = yParameter;
      +                width = widthParameter;
      +                height = heightParameter;
                       
                       g.drawImage(topLeft, x, y);
                       g.drawImage(bottomLeft, x, y + height - bottomLeft.getHeight());
      @@ -1140,8 +1159,13 @@
               int width = c.getWidth();
               int height = c.getHeight();
               if (outerBorder!=null) {
      +            if(paintOuterBorderFirst){
      +                outerBorder.paint(g, x, y, width, height, c);
                   paint(g, x+thickness, y+thickness, width-thickness*2, height-thickness*2, c);
      +            } else {
      +                paint(g, x+thickness, y+thickness, width-thickness*2, height-thickness*2, c);
                   outerBorder.paint(g, x, y, width, height, c);
      +            }
               } else {
                   paint(g, x, y, width, height, c);
               }
      @@ -1497,6 +1521,15 @@
               return thickness;
           }
       
      +    public void setThickness(int thickness) {
      +        this.thickness = thickness;
      +    }
      +    
      +    private boolean paintOuterBorderFirst;
      +    public void setPaintOuterBorderFirst(boolean paintOuterBorderFirst){
      +        this.paintOuterBorderFirst = paintOuterBorderFirst;
      +    }
      +
           /**
            * This method returns the Compound Borders array.
            * The array size is 4 and the borders arranged as follows :
      
      

        Activity

        Hide
        vprise added a comment -

        Regarding thickness I don't think it should be added to image borders and its a problematic property with several border types.
        Ofir, Does the ordering of outer inner border make sense? Would there be implications from this patch on the HTML/CSS functionality?

        Show
        vprise added a comment - Regarding thickness I don't think it should be added to image borders and its a problematic property with several border types. Ofir, Does the ordering of outer inner border make sense? Would there be implications from this patch on the HTML/CSS functionality?
        Hide
        vprise added a comment -

        Committed this to SVN.

        Show
        vprise added a comment - Committed this to SVN.

          People

          • Assignee:
            ofirl
            Reporter:
            thorsten_s
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: