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

Text item changed to use a tighter intersects() method based on PixelBounds. Older version of intersects() also still available as intersectsOLD()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/Text.java

    r906 r909  
    13371337        }
    13381338
    1339         @Override
    1340         public boolean intersects(Polygon p) {
     1339        //@Override
     1340        public boolean intersectsOLD(Polygon p) {
    13411341                if (super.intersects(p)) {
    13421342                        float textY = getY();
     
    13561356                        }
    13571357                }
     1358                return false;
     1359        }
     1360       
     1361        // The following version of intersect uses a tighter definition for the text, based on
     1362    @Override
     1363        public boolean intersects(Polygon p) {
     1364                if (super.intersects(p)) {
     1365                        float textY = getY();
     1366
     1367                        for (TextLayout text : _textLayouts) {
     1368                               
     1369                                Rectangle text_pixel_bounds_rect = this.getPixelBounds(text);
     1370                               
     1371                                if (p.intersects(text_pixel_bounds_rect)) {
     1372                                        return true;
     1373                                }
     1374                        }
     1375                }
     1376               
    13581377                return false;
    13591378        }
     
    18561875                                int ldx = 1+getX()+getJustOffset(layout); // Layout draw x
    18571876                               
    1858                                 boolean debug = false;
     1877                                boolean debug = true;
    18591878                                if (debug) {
    18601879                                        g.setColor(new Color(c.getRed(),c.getGreen(),c.getBlue(),40));
     
    26142633
    26152634       
     2635        protected Rectangle getPixelBounds(TextLayout layout)
     2636        {
     2637                // Does 'layout' need to be synchronized (similar to _textLayouts below)??
     2638                int x = getX();
     2639                int y = getY();
     2640
     2641                int ldx = 1+x+getJustOffset(layout); // Layout draw x                           
     2642                Rectangle layout_rect = layout.getPixelBounds(null, ldx, y);
     2643
     2644                return layout_rect;             
     2645        }
     2646       
    26162647       
    26172648        public Rectangle getPixelBoundsUnion()
Note: See TracChangeset for help on using the changeset viewer.