Ignore:
Timestamp:
04/23/14 11:10:21 (10 years ago)
Author:
davidb
Message:

Overspill cases, when text pokes outside of a rect, now handled more simply by cropping top and bottom at the start of the mapInItem()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/io/flowlayout/XGroupItem.java

    r908 r910  
    2323{
    2424        enum FlowType { in_flow, out_of_flow_original, out_of_flow_faked_position };
    25 
     25       
    2626        class MultiArrowHeadComparable implements Comparator<Item>{
    2727                 
     
    111111                       
    112112                        XRawItem x_raw_item = new XRawItem(text_item);
     113                        // overspill can occur (and is acceptable) when raw-text item spills out of enclosing shape (such as a rectangle)
    113114                        mapInItem(x_raw_item);
    114115                }
     
    222223               
    223224                if ((y_index<0) || (y_index>=yitems_span_array.length)) {
    224                     int y_top = getBoundingYTop();
    225                     int y_bot = y_top + yitems_span_array.length -1;
    226                     System.err.println("Error in getYOverlappingItemsSpan(): index out of bounds for value " + y);
    227                     System.err.println("  => Operation mapped into local array: y-top=" + y_top + ", y-bot=" + y_bot);
     225                        int y_top = getBoundingYTop();
     226                        int y_bot = y_top + yitems_span_array.length -1;
     227
     228                        System.err.println("Error in getYOverlappingItemsSpan(): index out of bounds for value " + y);
     229                        System.err.println("  => Operation mapped into local array: y-top=" + y_top + ", y-bot=" + y_bot);
     230                 
    228231                    return null;
    229232                }
     
    231234        }
    232235       
     236        protected int cropToTop(int y) {
     237                int y_index = y - getBoundingYTop();
     238               
     239                if (y_index<0) {
     240                        y = getBoundingYTop();
     241                }
     242               
     243                return y;
     244        }
     245       
     246        protected int cropToBot(int y) {
     247                int y_index = y - getBoundingYTop();
     248       
     249                if (y_index>=yitems_span_array.length) {
     250                        y = getBoundingYBot();
     251                }
     252               
     253                return y;
     254        }
     255       
    233256        public void setYOverlappingItemsSpan(int y,YOverlappingItemsSpan yitems_span)
    234257        {
     
    236259
    237260                if ((y_index<0) || (y_index>=yitems_span_array.length)) {
    238                     int y_top = getBoundingYTop();
    239                     int y_bot = y_top + yitems_span_array.length -1;
    240                     System.err.println("Error in setYOverlappingItemsSpan(): index out of bounds for value " + y);
    241                     System.err.println("  => Operation mapped into local array: y-top=" + y_top + ", y-bot=" + y_bot);
     261       
     262                        int y_top = getBoundingYTop();
     263                        int y_bot = y_top + yitems_span_array.length -1;
     264
     265                        System.err.println("Error in setYOverlappingItemsSpan(): index out of bounds for value " + y);
     266                        System.err.println("  => Operation mapped into local array: y-top=" + y_top + ", y-bot=" + y_bot);
     267
    242268                    return;
    243269                }
     
    577603                                                                Point pt_to_check = new Point(item_to_check.getX(),item_to_check.getY());
    578604                                                               
    579                                                                 if (area_enclosed_polygon.isPerimieterPoint(pt_to_check)) {
     605                                                                if (area_enclosed_polygon.isPerimeterPoint(pt_to_check)) {
    580606                                                                        items_on_perimeter.add(item_to_check);
    581607                                                                }
     
    652678                               
    653679                                // Filter out enclosed-items points that are part of the polygon's perimeter
    654                                 if (area_polygon.isPerimieterPoint(enclosed_item.getPosition())) {
     680                                if (area_polygon.isPerimeterPoint(enclosed_item.getPosition())) {
    655681                                        enclosed_item_list.remove(i);
    656682                                }
     
    678704               
    679705                for (int y=yt; y<=yb; y++) {
    680                         setYOverlappingItemsSpan(y,y_span_shadow);
     706
     707                        setYOverlappingItemsSpan(y,y_span_shadow);
    681708                }
    682709        }
     
    700727                                // Our shadow has run into another top-edged zone
    701728                                //   => need to extend the shadow to include this zone as well
    702                                 //      (making this encountered top-edge obsolete
     729                                //      (making this encountered top-edge obsolete)
    703730                               
    704731                                // Merge the newly encountered top-line in with the current one
     
    741768                int yb = xitem.getBoundingYBot();
    742769                               
     770                // top-edge over-spill can occur (and is acceptable) when (for example) the given xitem is a raw-text item
     771                // that doesn't neatly fit in an enclosed area (i,e., is poking out the top of an enclosing rectangle) 
     772                yt = cropToTop(yt); // Only changes yt if in an over-spill situation
     773       
     774                // similarly, bottom-edge over-spill can occur (and is acceptable) with a less than precise placed raw-text item
     775                yb = cropToBot(yb); // Only changes yb if in an over-spill situation
     776                       
    743777                // Merge into 'items_span' checking for overlaps (based on xitem's y-span)
    744778                               
     
    794828
    795829                                        // Effectively after the shadow reference lookup this is the same
    796                                         // as the above, with the need to worry about Step 2 (as no move is needed)
     830                                        // as the above, without the need to worry about Step 2 (as no move is needed)
    797831
    798832                                        YOverlappingItemsShadow y_item_span_shadow = (YOverlappingItemsShadow)item_span;
     
    827861                       
    828862                        YOverlappingItemsTopEdge y_item_span_top_edge = new YOverlappingItemsTopEdge(xitem_line);
     863               
    829864                        setYOverlappingItemsSpan(yt,y_item_span_top_edge);
    830865
    831866                        castShadowIntoEmptySpace(y_item_span_top_edge, yt+1, yb);
    832 
    833867                }
    834868
Note: See TracChangeset for help on using the changeset viewer.