Changeset 125


Ignore:
Timestamp:
07/03/08 19:05:00 (16 years ago)
Author:
bjn8
Message:

Fixed some drawing issues with the message bay

Location:
trunk/src/org/expeditee/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/FrameGraphics.java

    r124 r125  
    789789                                        for (Rectangle r : damagedAreas) {
    790790                                                if (clip == null) clip = new Area(r);
    791                                                 clip.add(new Area(r)); 
     791                                                else clip.add(new Area(r));     
    792792                                        }
    793793                                        damagedAreas.clear();
    794                                 } else return; // nothing to render
     794                                       
     795                                } else if (MessageBay.isDirty()) {
     796                                        // Paint dirty message bay
     797                                        Graphics dg = _DisplayGraphics.create();
     798                                        MessageBay.refresh(true, dg, Item.DEFAULT_BACKGROUND);
     799                                        return;
     800                                }
    795801                        }
    796802               
     
    813819                // Paint message bay
    814820                MessageBay.refresh(useInvalidation, dg, Item.DEFAULT_BACKGROUND);
    815                
     821
    816822                dg.dispose();
    817823        }
  • trunk/src/org/expeditee/gui/MessageBay.java

    r122 r125  
    7878                _messageLink.setOffset(0, -FrameGraphics.getMaxFrameSize().height);
    7979                _messageLink.setMaxSize(FrameGraphics.getMaxFrameSize());
    80                 _messageLink.setPosition(FrameGraphics.getMaxFrameSize().width - MESSAGE_LINK_Y_OFFSET,
    81                                 MESSAGE_LINK_X);
    82                
     80               
     81                updateLink();
     82                initBuffer();
    8383        }
    8484       
     
    113113                return _messages;
    114114        }
     115       
     116        public static boolean isDirty() {
     117                return !_dirtyAreas.isEmpty();
     118        }
     119       
     120        public static void invalidateFullBay() {
     121                _dirtyAreas.clear();
     122                addDirtyArea(new Rectangle(0, FrameGraphics.getMaxFrameSize().height,
     123                                _messageBuffer.getWidth(), _messageBuffer.getHeight()));
     124        }
     125       
     126        private static void initBuffer() {
     127                if (_messageBuffer == null) {
     128                        GraphicsEnvironment ge = GraphicsEnvironment
     129                                        .getLocalGraphicsEnvironment();
     130                        _messageBuffer = ge.getDefaultScreenDevice()
     131                                        .getDefaultConfiguration().createCompatibleVolatileImage(
     132                                                        FrameGraphics.getMaxFrameSize().width,
     133                                                        (FrameGraphics.isAudienceMode() ? 0 : MESSAGE_BUFFER_HEIGHT));
     134                }
     135        }
     136       
     137       
     138        private static boolean isLinkInitialized = false;
     139       
     140        private static void updateLink() {
     141               
     142                if (!isLinkInitialized && FrameGraphics.getMaxFrameSize().width > 0) {
     143                        // set up 'Messages' link on the right hand side
     144                        _messageLink.setPosition(FrameGraphics.getMaxFrameSize().width - MESSAGE_LINK_Y_OFFSET,
     145                                        MESSAGE_LINK_X);
     146                        _messageLink.setOffset(0, -FrameGraphics.getMaxFrameSize().height);
     147                        isLinkInitialized = true;
     148                       
     149                       
     150                } else {
     151                        _messageLink.setPosition(FrameGraphics.getMaxFrameSize().width - MESSAGE_LINK_Y_OFFSET,
     152                                        MESSAGE_LINK_X);
     153                }
     154        }
     155       
     156
    115157       
    116158        /**
     
    129171                        Graphics g, Color background) {
    130172               
     173                if (FrameGraphics.getMaxFrameSize().width <= 0) return;
     174               
    131175                Area clip = null;
     176               
    132177                if (useInvalidation) { // build clip
    133                        
    134178
    135179                        if (!_dirtyAreas.isEmpty()) {
    136180                               
    137181                                for (Rectangle r : _dirtyAreas) {
     182                                        r.y = (r.y < 0) ? 0 : r.y;
     183                                        r.x = (r.x < 0) ? 0 : r.x;
    138184                                        if (clip == null) clip = new Area(r);
    139                                         clip.add(new Area(r)); 
     185                                        else clip.add(new Area(r));     
    140186                                }
    141187
    142188                        } else return; // nothing to render
    143                        
    144                
     189
    145190                }
    146191
     
    152197                // Now repaint to screen
    153198                if (!FrameGraphics.isAudienceMode()) {
    154                         g.setClip(clip);
     199                       
     200                        // Translate clip to messagebox coords
     201                        //clip.transform(t) // TODO
     202                        //g.setClip(clip);
     203                       
    155204                        g.drawImage(_messageBuffer, 0, FrameGraphics.getMaxFrameSize().height, null);
    156205                }
     
    159208       
    160209        private static void updateBuffer(Color background, Area clip) {
    161                
    162                 if (_messageBuffer == null) {
    163                         GraphicsEnvironment ge = GraphicsEnvironment
    164                                         .getLocalGraphicsEnvironment();
    165                         _messageBuffer = ge.getDefaultScreenDevice()
    166                                         .getDefaultConfiguration().createCompatibleVolatileImage(
    167                                                         FrameGraphics.getMaxFrameSize().width,
    168                                                         (FrameGraphics.isAudienceMode() ? 0 : MESSAGE_BUFFER_HEIGHT));
    169                 }
    170 
     210
     211                initBuffer();
     212               
    171213                Graphics2D g = _messageBuffer.createGraphics();
    172                
     214
    173215                g.setClip(clip);
    174                
     216
    175217                g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
    176218                                RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
     
    187229                }
    188230               
    189                 if (_messageLink.getLink() != null &&
    190                                 (clip == null || _messageLink.isInDrawingArea(clip)))
     231                if (//_messageLink.getLink() != null
     232                                //&&
     233                                (clip == null || _messageLink.isInDrawingArea(clip))) {
    191234                        FrameGraphics.PaintItem(g, _messageLink);
     235                }
    192236               
    193237                g.dispose();
     
    205249                System.out.println(message);
    206250                assert (message != null);
    207 
     251               
     252                // Invalidate whole area
     253                invalidateFullBay();
     254               
    208255                if (_supressMessages)
    209256                        return;
     
    217264                if (_creator == null) {
    218265                        _creator = new FrameCreator(MESSAGES_FRAMESET_NAME, true);
    219 
    220                         // set up 'Messages' link on the right hand side
    221                         _messageLink.setPosition(FrameGraphics.getMaxFrameSize().width - MESSAGE_LINK_Y_OFFSET,
    222                                         MESSAGE_LINK_X);
    223                         _messageLink.setOffset(0, -FrameGraphics.getMaxFrameSize().height);
    224                 }
     266                }
     267               
     268                // set up 'Messages' link on the right hand side
     269                updateLink();
    225270
    226271                // if the message slots have not all been used yet
Note: See TracChangeset for help on using the changeset viewer.